From 29ca76fcfa242f6f56cab74a7772f3519bc098be Mon Sep 17 00:00:00 2001 From: Mary McGrath Date: Thu, 21 Nov 2024 16:31:56 -0500 Subject: [PATCH] fix: filter out generic patient IDs --- .../ecr-viewer/src/app/api/fhirPath.yml | 2 +- .../app/services/evaluateFhirDataService.ts | 19 +------------------ .../src/app/tests/assets/BundlePatient.json | 4 ++++ .../services/evaluateFhirDataServices.test.ts | 3 +-- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/containers/ecr-viewer/src/app/api/fhirPath.yml b/containers/ecr-viewer/src/app/api/fhirPath.yml index d42e84c057..9a4a998e34 100644 --- a/containers/ecr-viewer/src/app/api/fhirPath.yml +++ b/containers/ecr-viewer/src/app/api/fhirPath.yml @@ -4,7 +4,7 @@ patientPhoneNumbers: "Bundle.entry.resource.where(resourceType = 'Patient').tele patientEmails: "Bundle.entry.resource.where(resourceType = 'Patient').telecom.where(system = 'email')" patientCounty: "Bundle.entry.resource.where(resourceType = 'Patient').address.first().county" -patientIds: "Bundle.entry.resource.where(resourceType = 'Patient').identifier" +patientIds: "Bundle.entry.resource.where(resourceType = 'Patient').identifier.where(system != 'urn:ietf:rfc:3986').value.join('\n')" patientDOB: "Bundle.entry.resource.where(resourceType = 'Patient').birthDate" patientVitalStatus: "Bundle.entry.resource.where(resourceType = 'Patient').deceasedBoolean" patientDOD: "Bundle.entry.resource.where(resourceType = 'Patient').deceasedDate" diff --git a/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts b/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts index 450c0cff20..b955087387 100644 --- a/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts +++ b/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts @@ -3,7 +3,6 @@ import { CodeableConcept, Condition, Encounter, - Identifier, Location, Organization, PatientContact, @@ -350,7 +349,7 @@ export const evaluateDemographicsData = ( title: "Patient IDs", toolTip: "Unique patient identifier(s) from their medical record. For example, a patient's social security number or medical record number.", - value: evaluateIdentifiers(fhirBundle, mappings.patientIds), + value: evaluateValue(fhirBundle, mappings.patientIds), }, ]; return evaluateData(demographicsData); @@ -621,22 +620,6 @@ export const evaluateValue = (entry: Element, path: string): string => { return value.trim(); }; -/** - * Evaluate the identifiers string and return in a formatted list. - * @param fhirBundle The FHIR resource to evaluate. - * @param path The path within the resource to extract the value from. - * @returns Formatted string of identifiers - */ -export const evaluateIdentifiers = (fhirBundle: Bundle, path: string) => { - const identifiers = evaluate(fhirBundle, path) as Identifier[]; - - return identifiers - .map((identifier) => { - return `${identifier.value}`; - }) - .join("\n"); -}; - /** * Find facility ID based on the first encounter's location * @param fhirBundle - The FHIR bundle containing resources. diff --git a/containers/ecr-viewer/src/app/tests/assets/BundlePatient.json b/containers/ecr-viewer/src/app/tests/assets/BundlePatient.json index 41c4433dff..de89ad286f 100644 --- a/containers/ecr-viewer/src/app/tests/assets/BundlePatient.json +++ b/containers/ecr-viewer/src/app/tests/assets/BundlePatient.json @@ -19,6 +19,10 @@ { "system": "urn:oid:2.16.840.1.113883.3.3316.100", "value": "10308625" + }, + { + "system": "urn:ietf:rfc:3986", + "value": "urn:uuid:2.16.840.1.114222.4.3.4.52.2" } ], "name": [ diff --git a/containers/ecr-viewer/src/app/tests/services/evaluateFhirDataServices.test.ts b/containers/ecr-viewer/src/app/tests/services/evaluateFhirDataServices.test.ts index 849ce14a98..0e4ce23c34 100644 --- a/containers/ecr-viewer/src/app/tests/services/evaluateFhirDataServices.test.ts +++ b/containers/ecr-viewer/src/app/tests/services/evaluateFhirDataServices.test.ts @@ -2,7 +2,6 @@ import { loadYamlConfig } from "@/app/api/utils"; import { evaluateEncounterId, evaluateFacilityId, - evaluateIdentifiers, evaluatePatientRace, evaluatePatientEthnicity, evaluatePractitionerRoleReference, @@ -97,7 +96,7 @@ describe("evaluate value", () => { describe("Evaluate Identifier", () => { it("should return the Identifier value", () => { - const actual = evaluateIdentifiers( + const actual = evaluateValue( BundleWithPatient as unknown as Bundle, mappings.patientIds, );