Skip to content

Commit 83928b0

Browse files
committed
Typo addressed
1 parent 703c820 commit 83928b0

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src/helpers/patientUtils.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ function getEthnicityDisplay(code) {
1818
return ethnicityCodeToDisplay[code];
1919
}
2020

21-
2221
// Based on the OMB Race table found here: http://hl7.org/fhir/us/core/STU3.1/ValueSet-omb-race-category.html
2322
const raceCodeToCodesystem = {
2423
'1002-5': 'urn:oid:2.16.840.1.113883.6.238',
@@ -39,7 +38,6 @@ function getRaceCodesystem(code) {
3938
return raceCodeToCodesystem[code];
4039
}
4140

42-
4341
// Based on the OMB Race table found here: http://hl7.org/fhir/us/core/STU3.1/ValueSet-omb-race-category.html
4442
const raceCodeToDisplay = {
4543
'1002-5': 'American Indian or Alaska Native',
@@ -60,7 +58,6 @@ function getRaceDisplay(code) {
6058
return raceCodeToDisplay[code];
6159
}
6260

63-
6461
/**
6562
* Turn a FHIR name object into a single name string
6663
* @param {Object} name object of the following shape: [{
@@ -70,7 +67,7 @@ function getRaceDisplay(code) {
7067
* @return {string} concatenated string of name values
7168
*/
7269
function getPatientName(name) {
73-
return ('extension' in name[0]) ? 'masked' : `${name[0].given.join(' ')} ${name[0].family}`;
70+
return 'extension' in name[0] ? 'masked' : `${name[0].given.join(' ')} ${name[0].family}`;
7471
}
7572

7673
/**
@@ -84,10 +81,7 @@ function getPatientName(name) {
8481
*/
8582
function maskPatientData(bundle, mask) {
8683
// get Patient resource from bundle
87-
const patient = fhirpath.evaluate(
88-
bundle,
89-
'Bundle.entry.where(resource.resourceType=\'Patient\').resource,first()',
90-
)[0];
84+
const patient = fhirpath.evaluate(bundle, "Bundle.entry.where(resource.resourceType='Patient').resource,first()")[0];
9185

9286
const validFields = [
9387
'gender',
@@ -111,7 +105,11 @@ function maskPatientData(bundle, mask) {
111105

112106
mask.forEach((field) => {
113107
if (!validFields.includes(field)) {
114-
throw Error(`'${field}' is not a field that can be masked. Patient will only be extracted if all mask fields are valid. Valid fields include: Valid fields include: ${validFields.join(', ')}`);
108+
throw Error(
109+
`'${field}' is not a field that can be masked. Patient will only be extracted if all mask fields are valid. Valid fields include: Valid fields include: ${validFields.join(
110+
', ',
111+
)}`,
112+
);
115113
}
116114
// must check if the field exists in the patient resource, so we don't add unnecessary dataAbsent extensions
117115
if (field === 'gender' && 'gender' in patient) {
@@ -127,10 +125,7 @@ function maskPatientData(bundle, mask) {
127125
const maskedMRN = hash.update(patient.id).digest('hex');
128126

129127
patient.id = maskedMRN;
130-
const patientEntry = fhirpath.evaluate(
131-
bundle,
132-
'Bundle.entry.where(resource.resourceType=\'Patient\')',
133-
)[0];
128+
const patientEntry = fhirpath.evaluate(bundle, "Bundle.entry.where(resource.resourceType='Patient')")[0];
134129
patientEntry.fullUrl = `urn:uuid:${maskedMRN}`;
135130
patient.identifier = [masked];
136131
} else if (field === 'name' && 'name' in patient) {
@@ -148,7 +143,7 @@ function maskPatientData(bundle, mask) {
148143
// fields that are extensions need to be differentiated by URL using fhirpath
149144
const birthsex = fhirpath.evaluate(
150145
patient,
151-
'Patient.extension.where(url=\'http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex\')',
146+
"Patient.extension.where(url='http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex')",
152147
);
153148
// fhirpath.evaluate will return [] if there is no extension with the given URL
154149
// so checking if the result is an array with anything in it checks if the field exists to be masked
@@ -159,7 +154,7 @@ function maskPatientData(bundle, mask) {
159154
} else if (field === 'race') {
160155
const race = fhirpath.evaluate(
161156
patient,
162-
'Patient.extension.where(url=\'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race\')',
157+
"Patient.extension.where(url='http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')",
163158
);
164159
if (race.length > 0) {
165160
race[0].extension[0].valueCoding = masked;
@@ -169,7 +164,7 @@ function maskPatientData(bundle, mask) {
169164
} else if (field === 'ethnicity') {
170165
const ethnicity = fhirpath.evaluate(
171166
patient,
172-
'Patient.extension.where(url=\'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity\')',
167+
"Patient.extension.where(url='http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')",
173168
);
174169
if (ethnicity.length > 0) {
175170
ethnicity[0].extension[0].valueCoding = masked;
@@ -188,7 +183,7 @@ function maskPatientData(bundle, mask) {
188183
patient._multipleBirthInteger = masked;
189184
}
190185
} else if (field === 'photo' && 'photo' in patient) {
191-
delete patient.phoo;
186+
delete patient.photo;
192187
patient.photo = [masked];
193188
} else if (field === 'contact' && 'contact' in patient) {
194189
delete patient.contact;

0 commit comments

Comments
 (0)