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

feat: add immunizations to condition summary section #3086

Merged
merged 10 commits into from
Jan 6, 2025
3 changes: 3 additions & 0 deletions containers/ecr-viewer/src/app/api/fhirPath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,6 @@ travelHistoryStartDate: "effectivePeriod.start"
travelHistoryEndDate: "effectivePeriod.end"
travelHistoryLocation: "component.where(code.coding.code='LOC').valueCodeableConcept.text"
travelHistoryPurpose: "component.where(code.coding.code='280147009').valueCodeableConcept.coding.display"

# Stamped
stampedImmunizations: "entry.resource.where(extension('https://reportstream.cdc.gov/fhir/StructureDefinition/condition-code').coding.code = %snomedCode and resourceType = 'Immunization')"
37 changes: 35 additions & 2 deletions containers/ecr-viewer/src/app/services/ecrSummaryService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import {
evaluateEncounterDiagnosis,
} from "./evaluateFhirDataService";
import { DisplayDataProps } from "@/app/view-data/components/DataDisplay";
import { returnProblemsTable } from "@/app/view-data/components/common";
import {
returnImmunizations,
returnProblemsTable,
} from "@/app/view-data/components/common";
import {
LabReport,
evaluateLabInfoData,
Expand Down Expand Up @@ -207,7 +210,7 @@ export const evaluateEcrSummaryConditionSummary = (

const conditionSummaries: ConditionSummary[] = [];
for (let conditionsListKey in conditionsList) {
const conditionSummary = {
const conditionSummary: ConditionSummary = {
title: conditionsList[conditionsListKey].snomedDisplay,
snomed: conditionsListKey,
conditionDetails: [
Expand All @@ -226,6 +229,11 @@ export const evaluateEcrSummaryConditionSummary = (
),
},
],
immunizationDetails: evaluateEcrSummaryRelevantImmunizations(
fhirBundle,
fhirPathMappings,
conditionsListKey,
),
clinicalDetails: evaluateEcrSummaryRelevantClinicalDetails(
fhirBundle,
fhirPathMappings,
Expand Down Expand Up @@ -401,3 +409,28 @@ const evaluateEncounterDate = (fhirBundle: Bundle, mappings: PathMappings) => {
evaluate(fhirBundle, mappings.encounterEndDate).join(""),
);
};

const evaluateEcrSummaryRelevantImmunizations = (
fhirBundle: Bundle,
mappings: PathMappings,
snomedCode: string,
): DisplayDataProps[] => {
const immunizations = evaluate(fhirBundle, mappings.stampedImmunizations, {
snomedCode,
});
const immunizationTable = returnImmunizations(
fhirBundle,
immunizations,
mappings,
"Immunizations Relevant to Reportable Condition",
"caption-data-title caption-width-full",
);
return immunizationTable
? [
{
value: immunizationTable,
dividerLine: true,
},
]
: [];
};
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,58 @@
"method": "PUT",
"url": "Condition/38e833d1-1001-9e83-4167-2684381498ac"
}
},
{
"fullUrl": "urn:uuid:6689c3f5-f256-9c28-bd98-89905630f28d",
"resource": {
"resourceType": "Immunization",
"id": "6689c3f5-f256-9c28-bd98-89905630f28d",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "urn:uuid:66d08d45-ab7b-11ec-81e0-9e7eef92c510"
}
],
"protocolApplied": [
{
"doseNumberPositiveInt": "2"
}
],
"occurrenceDateTime": "2022-03-24T09:34:00-04:00",
"vaccineCode": {
"coding": [
{
"code": "24",
"system": "urn:oid:2.16.840.1.113883.12.292",
"display": "SARS-CoV-2 PCR Vaccine"
}
]
},
"lotNumber": "LOT942X",
"status": "completed",
"primarySource": true,
"patient": {
"reference": "Patient/9745ad43-ad53-4928-ac88-1a2dce1f5777"
},
"meta": {
"source": "ecr"
},
"extension": [
{
"url": "https://reportstream.cdc.gov/fhir/StructureDefinition/condition-code",
"coding": [
{
"code": "840539006",
"system": "http://snomed.info/sct"
}
]
}
]
},
"request": {
"method": "PUT",
"url": "Immunization/6689c3f5-f256-9c28-bd98-89905630f28d"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ describe("EcrSummary", () => {
value: "covid lab",
},
],
immunizationDetails: [
{
title: "Relevant immmunizations",
value: "table would be here",
dividerLine: true,
},
],
},
];
const hepConditionDetails: ConditionSummary[] = [
Expand All @@ -92,6 +99,7 @@ describe("EcrSummary", () => {
value: "hep c lab",
},
],
immunizationDetails: [],
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ describe("Immunizations Table", () => {
BundleClinicalInfo as unknown as Bundle,
immunizationsData,
fhirPathMappings,
"Immunization History",
)!,
).container;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,22 @@ End: 05/13/2022 9:57 AM UTC
class="section__line_gray"
/>
</div>
<div
class="margin-top-0"
>
<div
class="grid-row"
>
<div
class="grid-col-auto width-full text-pre-line"
>
table would be here
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div
class="text-bold margin-top-0 margin-bottom-1"
id="relevant-clinical"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,19 @@ describe("Evaluate eCR Summary Condition Summary", () => {
).not.toBeInTheDocument();
expect(screen.getByText("SARS-CoV-2 PCR")).toBeInTheDocument();
});
it("should return immunization details based on snomed code", () => {
const actual = evaluateEcrSummaryConditionSummary(
BundleEcrSummary as unknown as Bundle,
mappings,
);
render(
actual[1].immunizationDetails.map((detail) => (
BobanL marked this conversation as resolved.
Show resolved Hide resolved
<React.Fragment key={Math.random()}>{detail.value}</React.Fragment>
)),
);

expect(screen.getByText("SARS-CoV-2 PCR Vaccine")).toBeInTheDocument();
});
it("should return empty array if none found", () => {
const actual = evaluateEcrSummaryConditionSummary({} as Bundle, mappings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ConditionSummary {
conditionDetails: DisplayDataProps[];
clinicalDetails: DisplayDataProps[];
labDetails: DisplayDataProps[];
immunizationDetails: DisplayDataProps[];
}

/**
Expand Down Expand Up @@ -51,6 +52,13 @@ const EcrSummary: React.FC<EcrSummaryProps> = ({
{condition.conditionDetails.map((item) => (
<DataDisplay item={item} key={item.title} />
))}
{condition.immunizationDetails.length > 0 && (
<div className={"margin-top-0"}>
{condition.immunizationDetails.map((item, index) => (
<DataTableDisplay item={item} key={index} />
))}
</div>
)}
<div
className="text-bold margin-top-0 margin-bottom-1"
id={"relevant-clinical"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ export const returnCareTeamTable = (
* @param fhirBundle - The FHIR bundle containing patient and immunizations information.
* @param immunizationsArray - An array containing the list of immunizations.
* @param mappings - An object containing the FHIR path mappings.
* @param caption - The string to display above the table
* @param className - Optional. The css class to be added to the table.
* @returns - A formatted table React element representing the list of immunizations, or undefined if the immunizations array is empty.
*/
export const returnImmunizations = (
fhirBundle: Bundle,
immunizationsArray: Immunization[],
mappings: PathMappings,
caption: string,
className?: string,
): React.JSX.Element | undefined => {
if (immunizationsArray.length === 0) {
return undefined;
Expand Down Expand Up @@ -159,8 +163,8 @@ export const returnImmunizations = (
resources={immunizationsArray}
mappings={mappings}
columns={columnInfo}
caption={"Immunization History"}
className={"margin-y-0"}
caption={caption}
className={classNames("margin-y-0", className)}
/>
);
};
Expand Down Expand Up @@ -580,6 +584,7 @@ export const evaluateClinicalData = (
fhirBundle,
evaluate(fhirBundle, mappings["immunizations"]),
mappings,
"Immunization History",
),
},
];
Expand Down
6 changes: 6 additions & 0 deletions containers/ecr-viewer/src/styles/custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ td {
}
}

.caption-width-full {
caption {
width: 100%
}
}

.usa-sidenav__item a:not(.usa-sidenav__sublist a) {
font-weight: bold;
}
Expand Down
2 changes: 1 addition & 1 deletion containers/trigger-code-reference/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
RESOURCE_TO_SERVICE_TYPES = {
"Observation": ["dxtc", "ostc", "lotc", "lrtc", "mrtc", "sdtc"],
"Condition": ["dxtc", "sdtc"],
"Immunization": ["ostc", "lotc", "lrtc"],
"Immunization": ["ostc", "lotc", "lrtc", "mrtc"],
"DiagnosticReport": ["dxtc", "ostc", "lotc", "lrtc", "mrtc", "sdtc"],
}

Expand Down
Loading