diff --git a/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts b/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts index a6e4f20c4..227c5ac07 100644 --- a/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts +++ b/containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts @@ -632,7 +632,10 @@ export const evaluateReference = ( * @param path - The path within the resource to extract the value from. * @returns - The evaluated value as a string. */ -export const evaluateValue = (entry: Element, path: string | Path): string => { +export const evaluateValue = ( + entry: Element | Element[], + path: string | Path, +): string => { let originalValue = evaluate(entry, path, undefined, fhirpath_r4_model)[0]; let value = ""; @@ -755,22 +758,22 @@ export const evaluatePatientLanguage = ( mappings.patientPreferredCommunication, ); - const patientProficiencyExtension: Extension | undefined = evaluate( + const patientProficiencyExtension: Extension[] = evaluate( patientCommunication, "extension.where(url = 'http://hl7.org/fhir/StructureDefinition/patient-proficiency')", - )[0]; - const patientLanguage: string | undefined = evaluate( + ); + const patientLanguage: string | undefined = evaluateValue( patientCommunication, - "language.coding.display", - )[0]; - const languageProficency: string | undefined = evaluate( + "language.coding", + ); + const languageProficency: string | undefined = evaluateValue( patientProficiencyExtension, - "extension.where(url = 'level').valueCoding.display", - )[0]; - const languageMode: string | undefined = evaluate( + "extension.where(url = 'level').value", + ); + const languageMode: string | undefined = evaluateValue( patientProficiencyExtension, - "extension.where(url = 'type').valueCoding.display", - )[0]; + "extension.where(url = 'type').value", + ); return [patientLanguage, languageProficency, languageMode] .filter(Boolean)