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

Render lab result HTML as is if it does not conform to the expected format #2897

Merged
merged 25 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d690959
need to add condition to display labs in old way when possible
austin-hall-skylight Nov 7, 2024
7567d04
Merge branch 'main' into austin/render-table-spike
austin-hall-skylight Nov 8, 2024
5b124c9
display different tables conditionally
austin-hall-skylight Nov 12, 2024
92eee2f
finish conditional display for lab info and refactor. Needs design re…
austin-hall-skylight Nov 12, 2024
4f64d25
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 13, 2024
bf7ea84
Merge branch 'main' into austin/render-table-spike
austin-hall-skylight Nov 13, 2024
4829ef5
Merge branch 'main' into austin/render-table-spike
austin-hall-skylight Nov 14, 2024
f8cfc21
add some tests
austin-hall-skylight Nov 18, 2024
f37e270
Tests done, need to update based on design feedback
austin-hall-skylight Nov 19, 2024
71dd5b5
Added another test
austin-hall-skylight Nov 19, 2024
ef909de
just need to make sure the divider line is correct
austin-hall-skylight Nov 19, 2024
fffb0a7
fixed the divider
austin-hall-skylight Nov 20, 2024
526590a
merged main
austin-hall-skylight Nov 20, 2024
f3db402
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 20, 2024
ff7f655
fix: 🗝️
mcmcgrath13 Nov 20, 2024
29615f1
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 20, 2024
1547560
remove console log
austin-hall-skylight Nov 21, 2024
2f09875
updated snapshot test
austin-hall-skylight Nov 21, 2024
b4011d4
quick fixes
austin-hall-skylight Nov 21, 2024
0576a67
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 21, 2024
5d6d2ed
removed another key
austin-hall-skylight Nov 21, 2024
9c601cb
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 21, 2024
f729bad
refactor evaluateLabInfoData
austin-hall-skylight Nov 21, 2024
c1b2620
Merge branch 'main' into austin/render-table-spike
austin-hall-skylight Nov 21, 2024
fb21d75
[pre-commit.ci] auto fixes from pre-commit hooks
pre-commit-ci[bot] Nov 21, 2024
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
22 changes: 15 additions & 7 deletions containers/ecr-viewer/src/app/services/ecrSummaryService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
} from "./evaluateFhirDataService";
import { DisplayDataProps } from "@/app/view-data/components/DataDisplay";
import { returnProblemsTable } from "@/app/view-data/components/common";
import { LabReport, evaluateLabInfoData } from "./labsService";
import {
LabReport,
evaluateLabInfoData,
isLabReportElementDataList,
} from "./labsService";
import { ConditionSummary } from "@/app/view-data/components/EcrSummary";
import React from "react";

Expand Down Expand Up @@ -338,12 +342,16 @@ export const evaluateEcrSummaryRelevantLabResults = (
"h4",
);

resultsArray = relevantLabElements.flatMap((element) =>
element.diagnosticReportDataElements.map((reportElement) => ({
value: reportElement,
dividerLine: false,
})),
);
if (isLabReportElementDataList(relevantLabElements)) {
resultsArray = relevantLabElements.flatMap((element) =>
element.diagnosticReportDataElements.map((reportElement) => ({
value: reportElement,
dividerLine: false,
})),
);
} else {
resultsArray.push(...relevantLabElements);
}

if (lastDividerLine) {
resultsArray.push({ dividerLine: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import fhirpath_r4_model from "fhirpath/fhir-context/r4";
import { Element } from "fhir/r4";
import { DisplayDataProps } from "@/app/view-data/components/DataDisplay";
import { evaluateTravelHistoryTable } from "./socialHistoryService";
import { Path } from "fhirpath";

/**
* Evaluates patient name from the FHIR bundle and formats it into structured data for display.
Expand Down Expand Up @@ -575,7 +576,7 @@ 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): string => {
export const evaluateValue = (entry: Element, path: string | Path): string => {
let originalValue = evaluate(entry, path, undefined, fhirpath_r4_model)[0];

let value = "";
Expand Down
21 changes: 19 additions & 2 deletions containers/ecr-viewer/src/app/services/formatService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,11 @@ export function formatTablesToJSON(htmlString: string): TableJson[] {
}

// <table><caption>{name}</caption></table>
const tableWithCaptionArray = doc.querySelectorAll("table:has(caption)");
const tableWithCaptionArray = doc.querySelectorAll(
"table:has(caption)",
) as NodeListOf<HTMLTableElement>;
if (tableWithCaptionArray.length > 0) {
doc.querySelectorAll("table").forEach((table) => {
tableWithCaptionArray.forEach((table) => {
const resultName = getElementContent(table.caption as Node);
const resultId = getDataId(table) ?? undefined;
jsonArray.push({ resultId, resultName, tables: [processTable(table)] });
Expand All @@ -397,9 +399,24 @@ export function formatTablesToJSON(htmlString: string): TableJson[] {
}
sibling = sibling.nextElementSibling;
}

if (tables.length > 0) jsonArray.push({ resultName, tables });
});

if (jsonArray.length > 0) {
return jsonArray;
}
}

// <table/>
const tableWithNoCaptionArray = doc.querySelectorAll("table");
if (tableWithNoCaptionArray.length > 0) {
tableWithNoCaptionArray.forEach((table) => {
const resultName = "";
const resultId = getDataId(table) ?? undefined;
jsonArray.push({ resultId, resultName, tables: [processTable(table)] });
});

return jsonArray;
}

Expand Down
Loading
Loading