Skip to content

Commit

Permalink
Merge branch 'main' into boban/2873-env-variables-next-runtime-env
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanL committed Dec 19, 2024
2 parents 837e55e + fe69608 commit cbf5caf
Show file tree
Hide file tree
Showing 18 changed files with 581 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# they will be requested for review when someone opens a pull request.
* @akasper @angelathe @austin-hall-skylight @BobanL @gordonfarrell @JNygaard-Skylight @lina-roth @mcmcgrath13 @robertmitchellv
5 changes: 4 additions & 1 deletion containers/ecr-viewer/src/app/api/fhirPath.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ patientNameList: "Bundle.entry.resource.where(resourceType = 'Patient').name"
patientAddressList: "Bundle.entry.resource.where(resourceType = 'Patient').address"
patientTelecom: "Bundle.entry.resource.where(resourceType = 'Patient').telecom"
patientCounty: "Bundle.entry.resource.where(resourceType = 'Patient').address.first().county"
patientCountry: "Bundle.entry.resource.where(resourceType = 'Patient').address.first().country"

patientIds: "Bundle.entry.resource.where(resourceType = 'Patient').identifier.where(system != 'urn:ietf:rfc:3986').value.join('\n')"
patientDOB: "Bundle.entry.resource.where(resourceType = 'Patient').birthDate"
Expand All @@ -21,7 +22,9 @@ patientCurrentJobTitle: "Bundle.entry.resource.where(resourceType='Observation')
patientTobaccoUse: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.code='72166-2').where(category.coding.code='social-history').value"
patientHomelessStatus: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.code='75274-1').where(category.coding.code='social-history').value"
patientPregnancyStatus: "Bundle.entry.resource.where(resourceType='Observation').where(meta.profile='http://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-pregnancy-status-observation').value"
patientAlcoholUse: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.code='11331-6').where(category.coding.code='social-history').value"
patientAlcoholUse: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.where(code='11331-6' and system = 'http://loinc.org')).value"
patientAlcoholIntake: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.where(code='74013-4' and system = 'http://loinc.org')).value"
patientAlcoholComment: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.display='Alcohol Comment').value"
patientSexualOrientation: "Bundle.entry.resource.where(resourceType='Observation').where(code.coding.code='76690-7').value"
patientGenderIdentity: "Bundle.entry.resource.where(resourceType = 'Patient').extension.where(url='http://hl7.org/fhir/us/ecr/StructureDefinition/us-ph-genderidentity-extension').value"
patientReligion: "Bundle.entry.resource.where(resourceType = 'Patient').extension.where(url='http://hl7.org/fhir/StructureDefinition/patient-religion').value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,20 @@ export const saveMetadataToSqlServer = async (
sql.VarChar(50),
lab.test_result_code_system,
)
.input("test_result_interpretation", sql.VarChar(255), null) // Not implemented
.input("test_result_interpretation_code", sql.VarChar(50), null) // Not implemented
.input(
"test_result_interpretation",
sql.VarChar(255),
lab.test_result_interpretation,
)
.input(
"test_result_interpretation_code",
sql.VarChar(50),
lab.test_result_interpretation_code,
)
.input(
"test_result_interpretation_system",
sql.VarChar(255),
lab.test_result_interp_system,
lab.test_result_interpretation_system,
)
.input(
"test_result_ref_range_low_value",
Expand Down
4 changes: 3 additions & 1 deletion containers/ecr-viewer/src/app/api/save-fhir-data/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ interface Lab {
test_result_code: string | undefined;
test_result_code_display: string | undefined;
test_result_code_system: string | undefined;
test_result_interp_system: string | undefined;
test_result_interpretation: string | undefined;
test_result_interpretation_code: string | undefined;
test_result_interpretation_system: string | undefined;
test_result_ref_range_low: string | undefined;
test_result_ref_range_low_units: string | undefined;
test_result_ref_range_high: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { DisplayDataProps } from "@/app/view-data/components/DataDisplay";
import { evaluateTravelHistoryTable } from "./socialHistoryService";
import { Path } from "fhirpath";
import { returnTableFromJson } from "../view-data/components/common";
import { toSentenceCase } from "./formatService";

/**
* Evaluates patient name from the FHIR bundle and formats it into structured data for display.
Expand Down Expand Up @@ -197,6 +198,39 @@ export const calculatePatientAgeAtDeath = (
}
};

/**
* Evaluates alcohol use information from the FHIR bundle and formats it into structured data for display.
* @param fhirBundle - The FHIR bundle containing alcohol use data.
* @param fhirMappings - The object containing the fhir paths.
* @returns An array of evaluated and formatted alcohol use data.
*/
export const evaluateAlcoholUse = (
fhirBundle: Bundle,
fhirMappings: PathMappings,
) => {
const alcoholUse = evaluateValue(fhirBundle, fhirMappings.patientAlcoholUse);
const alcoholIntake = evaluateValue(
fhirBundle,
fhirMappings.patientAlcoholIntake,
);
let alcoholComment: string | undefined = evaluateValue(
fhirBundle,
fhirMappings.patientAlcoholComment,
);

if (alcoholComment) {
alcoholComment = toSentenceCase(alcoholComment);
}

return [
alcoholUse ? `Use: ${alcoholUse}` : null,
alcoholIntake ? `Intake (standard drinks/week): ${alcoholIntake}` : null,
alcoholComment ? `Comment: ${alcoholComment}` : null,
]
.filter(Boolean) // Removes null or undefined lines
.join("\n"); // Joins the remaining lines with newlines
};

/**
* Evaluates social data from the FHIR bundle and formats it into structured data for display.
* @param fhirBundle - The FHIR bundle containing social data.
Expand Down Expand Up @@ -227,7 +261,7 @@ export const evaluateSocialData = (
},
{
title: "Alcohol Use",
value: evaluateValue(fhirBundle, mappings["patientAlcoholUse"]),
value: evaluateAlcoholUse(fhirBundle, mappings),
},
{
title: "Sexual Orientation",
Expand Down Expand Up @@ -313,6 +347,10 @@ export const evaluateDemographicsData = (
title: "County",
value: evaluate(fhirBundle, mappings.patientCounty)[0],
},
{
title: "Country",
value: evaluate(fhirBundle, mappings.patientCountry)[0],
},
{
title: "Contact",
value: formatContactPoint(evaluate(fhirBundle, mappings.patientTelecom)),
Expand Down
6 changes: 5 additions & 1 deletion containers/ecr-viewer/src/app/services/labsService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,11 @@ export function evaluateObservationTable(
).filter(
(observation) =>
!observation.component &&
observation.code?.coding.some((c: Coding) => c?.display),
// Make sure there is a component name, but it isn't "Lab Interpretation" as that's handled
// via the tab on the result's name
observation.code?.coding.some(
(c: Coding) => c?.display && c?.display !== "Lab Interpretation",
),
);

let obsTable;
Expand Down
74 changes: 74 additions & 0 deletions containers/ecr-viewer/src/app/tests/assets/BundleLab.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
{
"display": "Organism ID",
"reference": "Observation/2a4f8fb5-f957-3c30-1353-a30aa441a12b"
},
{
"reference": "Observation/e9c8e4b3-3fec-4f29-a5c5-e45f96680a4c",
"display": "Lab Interpretation"
}
]
}
Expand Down Expand Up @@ -265,6 +269,9 @@
{
"reference": "Observation/1c0f3367-0588-c90e-fed0-0d8c15c5ac1b"
},
{
"reference": "Observation/e9c8e4b3-3fec-4f29-a5c5-e45f96680a4c"
},
{
"reference": "Observation/ab1ecbd4-6de0-4f78-cea6-a880a15e88bb"
}
Expand Down Expand Up @@ -396,6 +403,73 @@
"url": "DiagnosticReport/b0f590a6-4bf5-7add-9716-2bd3ba6defb2"
}
},
{
"fullUrl": "urn:uuid:e9c8e4b3-3fec-4f29-a5c5-e45f96680a4c",
"resource": {
"resourceType": "Observation",
"id": "e9c8e4b3-3fec-4f29-a5c5-e45f96680a4c",
"meta": {
"profile": [
"http://hl7.org/fhir/us/core/StructureDefinition/us-core-observationresults"
],
"source": "ecr"
},
"identifier": [
{
"system": "urn:oid:1.2.840.114350.1.13.202.3.7.2.798268",
"value": "476858944"
}
],
"category": [
{
"coding": [
{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "laboratory"
}
]
}
],
"status": "final",
"code": {
"coding": [
{
"code": "56850-1",
"system": "http://loinc.org",
"display": "Lab Interpretation"
}
]
},
"effectiveDateTime": "2022-09-29T21:13:00Z",
"valueString": "Abnormal",
"extension": [
{
"url": "http://hl7.org/fhir/R4/specimen.html",
"extension": [
{
"url": "specimen source",
"valueString": "Stool"
},
{
"url": "specimen collection time",
"valueDateTime": "2022-09-28T20:51:00Z"
},
{
"url": "specimen receive time",
"valueDateTime": "2022-09-28T20:51:36Z"
}
]
}
],
"subject": {
"reference": "Patient/1586f68b-1a17-4188-ac0b-82c3cbdbfbda"
}
},
"request": {
"method": "PUT",
"url": "Observation/e9c8e4b3-3fec-4f29-a5c5-e45f96680a4c"
}
},
{
"fullUrl": "urn:uuid:1c0f3367-0588-c90e-fed0-0d8c15c5ac1b",
"resource": {
Expand Down
Loading

0 comments on commit cbf5caf

Please sign in to comment.