Skip to content

Commit ccabdb4

Browse files
committed
replaced shajs and updated fixtures
1 parent 0da2dec commit ccabdb4

File tree

4 files changed

+7
-14
lines changed

4 files changed

+7
-14
lines changed

package-lock.json

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"lodash": "^4.17.21",
3232
"moment": "^2.26.0",
3333
"nodemailer": "^6.4.16",
34-
"sha.js": "^2.4.9",
3534
"winston": "^3.2.1"
3635
},
3736
"devDependencies": {

src/helpers/patientUtils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable no-underscore-dangle */
22
const fhirpath = require('fhirpath');
3-
const shajs = require('sha.js');
3+
const crypto = require('crypto');
44
const { extensionArr, dataAbsentReasonExtension } = require('../templates/snippets/extension.js');
55

66
// Based on the OMB Ethnicity table found here:http://hl7.org/fhir/us/core/STU3.1/ValueSet-omb-ethnicity-category.html
@@ -104,7 +104,9 @@ function maskPatientData(bundle, mask) {
104104
patient._gender = masked;
105105
} else if (field === 'mrn' && 'identifier' in patient) {
106106
// id and fullURL still need valid values, so we use a hashed version of MRN instead of dataAbsentReason
107-
const maskedMRN = shajs('sha256').update(patient.id).digest('hex');
107+
const hash = crypto.createHash('sha256');
108+
const maskedMRN = hash.update(patient.id).digest('hex');
109+
108110
patient.id = maskedMRN;
109111
const patientEntry = fhirpath.evaluate(
110112
bundle,

src/templates/ResourceGenerator.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const _ = require('lodash');
2-
const shajs = require('sha.js');
2+
const crypto = require('crypto');
33
const logger = require('../helpers/logger');
44

55
const { adverseEventTemplate } = require('./AdverseEventTemplate');
@@ -36,7 +36,8 @@ function loadFhirTemplate(mcodeProfileID) {
3636

3737
// Hash a data object to get a unique, deterministic ID for it
3838
function generateResourceId(data) {
39-
return shajs('sha256').update(JSON.stringify(data)).digest('hex');
39+
const hash = crypto.createHash('sha256');
40+
return hash.update(JSON.stringify(data)).digest('hex');
4041
}
4142

4243
// Ensures that empty data in the resource object carries a null value, rather than being undefined or an empty string

0 commit comments

Comments
 (0)