Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional provider details to ecr viewer #2591

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
616 changes: 602 additions & 14 deletions containers/ecr-viewer/seed-scripts/sql/data.sql

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions containers/ecr-viewer/src/app/api/fhirPath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ facilityState: "Bundle.entry.resource.where(resourceType = 'Location')[0].addres
facilityStreetAddress: "Bundle.entry.resource.where(resourceType = 'Location')[0].address.line[0]"
facilityType: "Bundle.entry.resource.where(resourceType = 'Encounter')[0].location[0].extension.where(url = 'http://build.fhir.org/ig/HL7/case-reporting/StructureDefinition-us-ph-location-definitions.html#Location.type').valueCodeableConcept.coding[0].display"
facilityZipCode: "Bundle.entry.resource.where(resourceType = 'Location')[0].address.postalCode"
providerContact: "Bundle.entry.resource.where(resourceType = 'Practitioner')[0].telecom.where(system = 'phone')[0].value"
providerFamilyName: "Bundle.entry.resource.where(resourceType = 'Practitioner')[0].name[1].family"
providerGivenName: "Bundle.entry.resource.where(resourceType = 'Practitioner')[0].name[1].given"
providerName: "idk"

compositionEncounterRef: "Bundle.entry.resource.where(resourceType = 'Composition').encounter.reference"
encounterIndividualRef: "Encounter.participant.where(type.coding.code = 'ATND').individual.reference"

rrDetails: "Bundle.entry.resource.where(meta.profile = 'http://hl7.org/fhir/us/ecr/StructureDefinition/rr-reportability-information-observation')"
rrDisplayNames: "Bundle.entry.resource.where(meta.profile = 'http://hl7.org/fhir/us/ecr/StructureDefinition/rr-reportability-information-observation').valueCodeableConcept.coding.display"
Expand Down
75 changes: 71 additions & 4 deletions containers/ecr-viewer/src/app/services/evaluateFhirDataService.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {
Bundle,
CodeableConcept,
Encounter,
Identifier,
Location,
Organization,
Practitioner,
PractitionerRole,
Quantity,
} from "fhir/r4";
import { evaluate } from "@/app/view-data/utils/evaluate";
import * as dateFns from "date-fns";
import { PathMappings, evaluateData } from "../view-data/utils/utils";
import {
formatAddress,
formatContactPoint,
formatName,
formatPhoneNumber,
formatStartEndDateTime,
Expand Down Expand Up @@ -386,21 +391,83 @@ export const evaluateProviderData = (
fhirBundle: Bundle,
mappings: PathMappings,
) => {
const encounterRef: string | undefined = evaluate(
fhirBundle,
mappings["compositionEncounterRef"],
)[0];
const encounter: Encounter = evaluateReference(
fhirBundle,
mappings,
encounterRef ?? "",
);
const encounterParticipantRef: string | undefined = evaluate(
encounter,
mappings["encounterIndividualRef"],
)[0];
const practitionerRole: PractitionerRole | undefined = evaluateReference(
fhirBundle,
mappings,
encounterParticipantRef ?? "",
);
const practitioner: Practitioner | undefined = evaluateReference(
fhirBundle,
mappings,
practitionerRole?.practitioner?.reference ?? "",
);
const organization: Organization | undefined = evaluateReference(
fhirBundle,
mappings,
practitionerRole?.organization?.reference ?? "",
);

const providerData = [
{
title: "Provider Name",
value: formatName(
evaluate(fhirBundle, mappings["providerGivenName"]),
evaluate(fhirBundle, mappings["providerFamilyName"])[0],
practitioner?.name?.[0].given,
practitioner?.name?.[0].family,
practitioner?.name?.[0].prefix,
practitioner?.name?.[0].suffix,
),
},
{
title: "Provider Address",
value: practitioner?.address?.map((address) =>
formatAddress(
address.line ?? [],
address.city ?? "",
address.state ?? "",
address.postalCode ?? "",
address.country ?? "",
),
),
},
{
title: "Provider Contact",
value: formatPhoneNumber(
evaluate(fhirBundle, mappings["providerContact"])[0],
value: formatContactPoint(practitioner?.telecom).join("\n"),
},
{
title: "Provider Facility Name",
value: organization?.name,
},
{
title: "Provider Facility Address",
value: organization?.address?.map((address) =>
formatAddress(
address.line ?? [],
address.city ?? "",
address.state ?? "",
address.postalCode ?? "",
address.country ?? "",
),
),
},
{
title: "Provider ID",
value: practitioner?.identifier?.map((id) => id.value).join("\n"),
},
];

return evaluateData(providerData);
};

Expand Down
Loading
Loading