Skip to content

Commit

Permalink
use evaluateValue where possible evaluatePatientLanguage
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanL committed Jan 2, 2025
1 parent e43b7db commit 38068b5
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 38068b5

Please sign in to comment.