Skip to content

Commit

Permalink
Better DR filter and medias on regular view
Browse files Browse the repository at this point in the history
  • Loading branch information
dehall committed Jun 27, 2024
1 parent 2fd7da0 commit 372835d
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/ui/components/PatientViewer/EncounterSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const ROW_FUNCTIONS =
key: 'description',
getter: m => extractMedia(m)
},
VIEW_FHIR
// VIEW_FHIR // temporarily disabled
]
}
]
Expand Down
18 changes: 17 additions & 1 deletion src/ui/components/PatientViewer/FilterPresets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ const DR_CONDITIONS = [
'60951000119105', // blindness
];

const DR_OBSERVATIONS = [
'413078003', // visual acuity
'41633001', // iop
'71491-5', '71490-7', // severity L / R,
'4548-4', // hba1c
'79819-9', '79818-1', // OCT obs L/R

// OCT measurements
'57119-0','57108-3','57109-1','57110-9',
'57111-7','57112-5','57113-3','57114-1',
'57115-8','57116-6','57117-4','57118-2'

];

const SDOH_CONDITIONS = [
'314529007',
'5251000175109',
Expand Down Expand Up @@ -53,7 +67,9 @@ const FILTER_PRESETS = Object.freeze({
filters: {
Encounter: ["Encounter.type.coding.code = '185349003'"],
Condition: [`Condition.code.coding.code in (${fhirList(DR_CONDITIONS)})`],
Observation: []
Observation: [`Observation.code.coding.where($this.code in (${fhirList(DR_OBSERVATIONS)}))`],
CarePlan: [],
Immunization: []
}
},
'Hide SDOH Conditions': {
Expand Down
20 changes: 18 additions & 2 deletions src/ui/components/PatientViewer/PatientViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
ProceduresTable,
EncountersTable,
ImmunizationsTable,
DocumentReferencesTable
DocumentReferencesTable,
MediasTable
} from '../ResourceTables/ResourceTables';
import { useLocation } from 'react-router-dom';
import { HashLink as Link } from 'react-router-hash-link';
Expand Down Expand Up @@ -213,7 +214,8 @@ const LinksByType = () => {
'Encounters',
'Allergies',
'Immunizations',
'Documents'
'Documents',
'Images'
];
const location = useLocation();
return (
Expand Down Expand Up @@ -278,6 +280,18 @@ const EntireRecord = props => {
const immunizations = getByType('Immunization');
const documents = getByType('DocumentReference');

const medias = getByType('Media');

medias.forEach(m => {
if (m.partOf && m.partOf[0]) {
const partOf = allResources.find(r => `urn:uuid:${r.id}` === m.partOf[0].reference);

if (partOf?.resourceType === 'ImagingStudy') {
m.partOf[0].resource = partOf;
}
}
});

return (
<Section
conditions={conditions}
Expand All @@ -290,6 +304,7 @@ const EntireRecord = props => {
allergies={allergies}
immunizations={immunizations}
documents={documents}
medias={medias}
/>
);
};
Expand All @@ -311,6 +326,7 @@ const Section = props => {
{show(props.allergies) && <AllergiesTable rows={props.allergies} />}
{show(props.immunizations) && <ImmunizationsTable rows={props.immunizations} />}
{show(props.documents) && <DocumentReferencesTable rows={props.documents} />}
{show(props.medias) && <MediasTable rows={props.medias} />}
</div>
);
};
Expand Down
18 changes: 16 additions & 2 deletions src/ui/components/ResourceTables/ResourceTables.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class ReportsTable extends GenericTable {
},
{ name: 'Value', getter: () => '' },
{ name: 'Effective', getter: r => attributeXTime(r,'effective'), defaultValue: 'N/A' },
VIEW_FHIR
// VIEW_FHIR // temporarily disabled
],
rowClass: 'report-line',
nestedRows: [
Expand Down Expand Up @@ -355,6 +355,19 @@ class MedicationRequestsTable extends GenericTable {
};
}

class MediasTable extends GenericTable {
static defaultProps = {
title: 'Images',
columns: [
{ name: 'Code', getter: m => m.partOf[0].resource.procedureCode[0].coding[0].display },
{ name: 'Media', getter: m => extractMedia(m) },
{ name: 'Date', getter: m => m.partOf[0].resource.started },
// VIEW_FHIR // temporarily disabled
],
keyFn: m => m.id,
rowHeight: () => 200,
};
}

export {
ConditionsTable,
Expand All @@ -366,6 +379,7 @@ export {
EncountersTable,
ImmunizationsTable,
DocumentReferencesTable,
MedicationRequestsTable
MedicationRequestsTable,
MediasTable
};

16 changes: 8 additions & 8 deletions src/ui/fhirpath_utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ export function evaluateResource(resource, path, variables={}) {
* return raw values from FHIRPath engine
* @return Differs based on input - see above
*/
export function evaluateBundle(bundle, fhirpath, variables, returnResources) {
if (fhirpath.startsWith("Bundle")) {
export function evaluateBundle(bundle, path, variables, returnResources) {
if (path.startsWith("Bundle")) {
// run it on the entire bundle

// NOTE: this doesn't check returnResources -- would that be useful here?
return evaluateResource(bundle, fhirpath, variables);
return evaluateResource(bundle, path, variables);
} else {
// the fhirpath doesn't start with "Bundle"
// so we'll apply it to each resource within the bundle
results = [];

for (const entry of bundle.entry) {
const resourceResults = evaluateResource(entry.resource, fhirpath);
const resourceResults = evaluateResource(entry.resource, path);

if (returnResources) {
if (isTruthy(resourceResults)) {
Expand All @@ -59,12 +59,12 @@ export function evaluateBundle(bundle, fhirpath, variables, returnResources) {



export function appliesToResource(resource, fhirpath) {
return isTruthy(evaluateResource(resource, fhirpath));
export function appliesToResource(resource, path) {
return isTruthy(evaluateResource(resource, path));
}

export function appliesToBundle(bundle, fhirpath, variables) {
return isTruthy(evaluateBundle(bundle, fhirpath, variables, false));
export function appliesToBundle(bundle, path, variables) {
return isTruthy(evaluateBundle(bundle, path, variables, false));
}

/**
Expand Down

0 comments on commit 372835d

Please sign in to comment.