Skip to content

Commit

Permalink
add ersd warnings (#2632)
Browse files Browse the repository at this point in the history
* add ersd warnings

* Complete styling of table

* Fix linting issues

* Update test snapshot

* Add tests

* Design Review update and remove log

* Fix build issue

* Address requested changes

* Use built in whitespace control
  • Loading branch information
lina-roth authored Sep 27, 2024
1 parent fe4df2b commit 8b26578
Show file tree
Hide file tree
Showing 12 changed files with 255 additions and 11 deletions.
1 change: 1 addition & 0 deletions containers/ecr-viewer/src/app/api/fhirPath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dateTimeEcrCreated: "Bundle.entry.resource.where(resourceType = 'Composition').d
ehrSoftware: "Bundle.entry.resource.where(resourceType = 'Device').where(property[0].type.coding.code='software').version.value"
ehrManufacturerModel: "Bundle.entry.resource.where(resourceType = 'Device').where(property[0].type.coding.code='software').manufacturer"
senderFacilityName: "Bundle.entry.resource.where(resourceType = 'Encounter')[0].location[0].location.display"
eRSDwarnings: "Bundle.entry.resource.where(resourceType= 'Composition').section.where(title = 'Reportability Response Information Section').extension.where(url = 'http://hl7.org/fhir/us/ecr/StructureDefinition/rr-eicr-processing-status-extension').valueCodeableConcept.coding.entries.eRSDwarnings"

# Encounter Info
encounterEndDate: "Bundle.entry.resource.where(resourceType = 'Encounter').period.end"
Expand Down
1 change: 0 additions & 1 deletion containers/ecr-viewer/src/app/components/EcrTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const EcrTable = async ({
}) => {
const renderPage = async (pageNumber: number) => {
const startIndex = (pageNumber - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
const pageData = await listEcrData(startIndex, itemsPerPage);
return renderListEcrTableData(pageData);
};
Expand Down
35 changes: 35 additions & 0 deletions containers/ecr-viewer/src/app/services/ecrMetadataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export interface ReportableConditions {
};
}

export interface ERSDWarning {
warning: string;
versionUsed: string;
expectedVersion: string;
suggestedSolution: string;
}

/**
* Evaluates eCR metadata from the FHIR bundle and formats it into structured data for display.
* @param fhirBundle - The FHIR bundle containing eCR metadata.
Expand Down Expand Up @@ -73,6 +80,33 @@ export const evaluateEcrMetadata = (
}
};

const fhirERSDWarnings = evaluate(fhirBundle, mappings.eRSDwarnings);
let eRSDTextList: ERSDWarning[] = [];

for (const warning of fhirERSDWarnings) {
if (warning.code === "RRVS34") {
eRSDTextList.push({
warning:
"Sending organization is using an malformed eRSD (RCTC) version",
versionUsed: "2020-06-23",
expectedVersion:
"Sending organization should be using one of the following: 2023-10-06, 1.2.2.0, 3.x.x.x.",
suggestedSolution:
"The trigger code version your organization is using could not be determined. The trigger codes may be out date. Please have your EHR administrators update the version format for complete eCR functioning.",
});
} else if (warning.code === "RRVS29") {
eRSDTextList.push({
warning:
"Sending organization is using an outdated eRSD (RCTC) version",
versionUsed: "2020-06-23",
expectedVersion:
"Sending organization should be using one of the following: 2023-10-06, 1.2.2.0, 3.x.x.x.",
suggestedSolution:
"The trigger code version your organization is using is out-of-date. Please have your EHR administration install the current version for complete eCR functioning.",
});
}
}

const eicrDetails: DisplayDataProps[] = [
{
title: "eICR ID",
Expand Down Expand Up @@ -130,5 +164,6 @@ export const evaluateEcrMetadata = (
eicrDetails: evaluateData(eicrDetails),
ecrCustodianDetails: evaluateData(ecrCustodianDetails),
rrDetails: reportableConditionsList,
eRSDWarnings: eRSDTextList,
};
};
29 changes: 26 additions & 3 deletions containers/ecr-viewer/src/app/tests/assets/BundleEcrMetadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,32 @@
"valueCodeableConcept": {
"coding": [
{
"code": "RRVS19",
"display": "eICR processed",
"system": "urn:oid:2.16.840.1.114222.4.5.274"
"entries": [
{
"eRSDwarnings": [
{
"id": "e39d6ae2-8c6e-4638-9b33-412996586f42",
"code": "RRVS29",
"display": "The eICR was processed with the warning of: outdated eRSD (RCTC) version.",
"system": "urn:oid:2.16.840.1.114222.4.5.274"
},
{
"id": "80f7b4ff-4d96-46ef-ae8f-af1f9c1f206c",
"value": "2022-11-01",
"code": "RRVS31",
"display": "Outdated eRSD (RCTC) Version Detail",
"system": "urn:oid:2.16.840.1.114222.4.5.274"
},
{
"id": "80f7b4ff-4d96-46ef-ae8f-af1f9c1f206c",
"value": "The expected eRSD (RCTC) version should be one of the following: 2024-04-05,1.2.3.0,3.x.x",
"code": "RRVS33",
"display": "Expected eRSD (RCTC) Version Detail",
"system": "urn:oid:2.16.840.1.114222.4.5.274"
}
]
}
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { axe } from "jest-axe";
import EcrMetadata from "../../view-data/components/EcrMetadata";
import React from "react";
import { DisplayDataProps } from "@/app/view-data/components/DataDisplay";
import { ReportableConditions } from "@/app/services/ecrMetadataService";
import {
ERSDWarning,
ReportableConditions,
} from "@/app/services/ecrMetadataService";

describe("ECR Metadata", () => {
let container: HTMLElement;
Expand Down Expand Up @@ -45,6 +48,19 @@ describe("ECR Metadata", () => {
},
{ title: "EHR Manufacturer Model Name", value: "Epic - Version 10.1" },
];

const eRSDWarnings: ERSDWarning[] = [
{
warning:
"Sending organization is using an malformed eRSD (RCTC) version",
versionUsed: "2020-06-23",
expectedVersion:
"Sending organization should be using one of the following: 2023-10-06, 1.2.2.0, 3.x.x.x.",
suggestedSolution:
"The trigger code version your organization is using could not be determined. The trigger codes may be out date. Please have your EHR administrators update the version format for complete eCR functioning.",
},
];

const ecrCustodianDetails: DisplayDataProps[] = [
{
title: "Custodian ID",
Expand All @@ -67,8 +83,9 @@ describe("ECR Metadata", () => {
container = render(
<EcrMetadata
eicrDetails={eicrDetails}
eCRCustodianDetails={ecrCustodianDetails}
rrDetails={rrConditionsList}
eRSDWarnings={eRSDWarnings}
eCRCustodianDetails={ecrCustodianDetails}
/>,
).container;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,25 @@ exports[`Snapshot test for Accordion Content Given no data, info message for emp
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
>
<div
class="data-title padding-right-1"
>
eRSD Warnings
</div>
<div
class="grid-col maxw7 text-pre-line text-italic text-base"
>
No data
</div>
</div>
<div
class="section__line_gray"
/>
</div>
<div>
<div
class="grid-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,62 @@ exports[`ECR Metadata should match snapshot 1`] = `
</tr>
</tbody>
</table>
<div>
<div
class="section__line_gray"
/>
<table
class="usa-table usa-table--borderless width-full src-components-Table-Table-module__fixed--Eq00W ersd-table fixed-table border-top border-left border-right border-bottom"
data-testid="table"
>
<caption>
eRSD Warnings
</caption>
<thead>
<tr>
<th>
Warning
</th>
<th>
Version in Use
</th>
<th>
Expected Version
</th>
<th>
Suggested Solution
</th>
</tr>
</thead>
<tbody>
<tr>
<td
class="padding-105"
>
Sending organization is using an malformed eRSD (RCTC) version
</td>
<td
class="padding-105"
>
2020-06-23
</td>
<td
class="padding-105"
>
Sending organization should be using one of the following: 2023-10-06, 1.2.2.0, 3.x.x.x.
</td>
<td
class="padding-105"
>
The trigger code version your organization is using could not be determined. The trigger codes may be out date. Please have your EHR administrators update the version format for complete eCR functioning.
</td>
</tr>
</tbody>
</table>
<div
class="section__line_gray"
/>
</div>
<div
class="padding-bottom-1"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,22 @@ describe("Evaluate Ecr Metadata", () => {
},
});
});
it("should have eRSDwarnings", () => {
const actual = evaluateEcrMetadata(
BundleWithEcrMetadata as unknown as Bundle,
mappings,
);

expect(actual.eRSDWarnings).toEqual([
{
warning:
"Sending organization is using an outdated eRSD (RCTC) version",
versionUsed: "2020-06-23",
expectedVersion:
"Sending organization should be using one of the following: 2023-10-06, 1.2.2.0, 3.x.x.x.",
suggestedSolution:
"The trigger code version your organization is using is out-of-date. Please have your EHR administration install the current version for complete eCR functioning.",
},
]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const AccordionContent: React.FC<AccordionContainerProps> = ({
clinicalData.clinicalNotes.unavailableData,
...ecrMetadata.eicrDetails.unavailableData,
...ecrMetadata.ecrCustodianDetails.unavailableData,
ecrMetadata.eRSDWarnings,
];
return unavailableDataArrays.some(
(array) => Array.isArray(array) && array.length > 0,
Expand Down Expand Up @@ -161,6 +162,7 @@ const AccordionContent: React.FC<AccordionContainerProps> = ({
content: (
<>
{Object.keys(ecrMetadata.rrDetails).length > 0 ||
ecrMetadata.eRSDWarnings.length > 0 ||
ecrMetadata.eicrDetails.availableData.length > 0 ||
ecrMetadata.ecrCustodianDetails.availableData.length > 0 ? (
<EcrMetadata
Expand All @@ -169,6 +171,7 @@ const AccordionContent: React.FC<AccordionContainerProps> = ({
ecrMetadata.ecrCustodianDetails.availableData
}
rrDetails={ecrMetadata.rrDetails}
eRSDWarnings={ecrMetadata.eRSDWarnings}
/>
) : (
<p className="text-italic padding-bottom-05">
Expand Down Expand Up @@ -203,6 +206,9 @@ const AccordionContent: React.FC<AccordionContainerProps> = ({
clinicalNotesData={clinicalData.clinicalNotes.unavailableData}
ecrMetadataUnavailableData={[
...ecrMetadata.eicrDetails.unavailableData,
...(ecrMetadata.eRSDWarnings.length === 0
? [{ title: "eRSD Warnings", value: "" }]
: []),
...ecrMetadata.ecrCustodianDetails.unavailableData,
]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
} from "../component-utils";
import { Table } from "@trussworks/react-uswds";
import { ToolTipElement } from "@/app/view-data/components/ToolTipElement";
import { ReportableConditions } from "../../services/ecrMetadataService";
import {
ERSDWarning,
ReportableConditions,
} from "../../services/ecrMetadataService";
import {
DataDisplay,
DisplayDataProps,
Expand All @@ -15,6 +18,7 @@ import React from "react";
interface EcrMetadataProps {
rrDetails: ReportableConditions;
eicrDetails: DisplayDataProps[];
eRSDWarnings: ERSDWarning[];
eCRCustodianDetails: DisplayDataProps[];
}

Expand Down Expand Up @@ -66,12 +70,14 @@ const convertDictionaryToRows = (dictionary: ReportableConditionsList) => {
* @param props - Props containing eCR metadata.
* @param props.rrDetails - The reportable conditions details.
* @param props.eicrDetails - The eICR details.
* @param props.eRSDWarnings - The eRSD warnings.
* @param props.eCRCustodianDetails - The eCR custodian details.
* @returns The JSX element representing the eCR metadata.
*/
const EcrMetadata = ({
rrDetails,
eicrDetails,
eRSDWarnings,
eCRCustodianDetails,
}: EcrMetadataProps) => {
return (
Expand Down Expand Up @@ -115,6 +121,45 @@ const EcrMetadata = ({
</thead>
<tbody>{convertDictionaryToRows(rrDetails)}</tbody>
</Table>
{eRSDWarnings?.length > 0 ? (
<div>
<div className="section__line_gray"></div>
<Table
bordered={false}
className="ersd-table fixed-table border-top border-left border-right border-bottom"
caption="eRSD Warnings"
fixed={true}
fullWidth
>
<thead>
<tr>
<th>Warning</th>
<th>Version in Use</th>
<th>Expected Version</th>
<th>Suggested Solution</th>
</tr>
</thead>
<tbody>
{Array.isArray(eRSDWarnings) &&
eRSDWarnings.map((warningItem, index) => (
<tr key={index}>
<td className="padding-105">{warningItem.warning}</td>
<td className="padding-105">{warningItem.versionUsed}</td>
<td className="padding-105">
{warningItem.expectedVersion}
</td>
<td className="padding-105">
{warningItem.suggestedSolution}
</td>
</tr>
))}
</tbody>
</Table>
<div className="section__line_gray"></div>
</div>
) : (
""
)}
<div className={"padding-bottom-1"} />
<AccordionH4 id={"eicr-details"}>eICR Details</AccordionH4>
{eicrDetails.map((item, index) => {
Expand Down
3 changes: 1 addition & 2 deletions containers/ecr-viewer/src/styles/custom-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,8 @@ h4 {
}
}

.ecrTable {
.fixed-table {
table-layout: fixed;
width: 100%;
}

td {
Expand Down
Loading

0 comments on commit 8b26578

Please sign in to comment.