updates to PR213. Added codeableConcept formatter and safe chaining to table explore view.

This commit is contained in:
Jason Kulatunga 2023-08-09 15:08:43 -07:00
parent 09640e50ae
commit a298635f84
20 changed files with 52 additions and 53 deletions

View File

@ -9,7 +9,7 @@ import {attributeXTime} from './utils';
})
export class ListAdverseEventComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Event', versions: '*', format: 'code', getter: a => a.event.coding[0] },
{ title: 'Event', versions: '*', format: 'codeableConcept', getter: a => a.event },
{ title: 'Date', versions: '*', format: 'date', getter: a => a.date }
]
}

View File

@ -10,11 +10,10 @@ import {attributeXTime} from './utils';
export class ListAllergyIntoleranceComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Date Recorded', versions: '*', format: 'date', getter: a => a.assertedDate || a.recordedDate },
// orig { title: 'Allergy', versions: '*', format: 'code', getter: a => a.code.coding[0] },
{ title: 'Allergy Type', versions: '*', getter: a => a.category[0] }, // Allergy Type
{ title: 'Allergic To', versions: '*', getter: a => a.code.text }, // Substance
{ title: 'Allergic To', versions: '*', format: 'codeableConcept', getter: a => a.code }, // Substance
{ title: 'Reaction', versions: '*', getter: a => a.reaction[0].manifestation[0].text }, // Reaction
{ title: 'Onset', versions: '*', format: 'date', getter: a => a.onsetDateTime },
{ title: 'Resolution Age', versions: '*', format: 'date', getter: a => a.extension.resolutionAge }
{ title: 'Resolution Age', versions: '*', format: 'date', getter: a => a.extension.resolutionAge },
]
}

View File

@ -9,9 +9,9 @@ import {attributeXTime} from './utils';
})
export class ListAppointmentComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Type', versions: '*', format: 'code', getter: a => a.type.coding[0] },
{ title: 'Type', versions: '*', format: 'codeableConcept', getter: a => a.serviceType },
{ title: 'Status', versions: '*', getter: a => a.status },
{ title: 'Reason', versions: '*', format: 'code', getter: a => a.reason.coding[0] },
{ title: 'Reason', versions: '*', format: 'code', getter: a => a.reason?.coding?.[0] },
{ title: 'Description', versions: '*', getter: a => a.description },
]
}

View File

@ -9,12 +9,11 @@ import {FORMATTERS} from './utils';
})
export class ListConditionComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
// orig { title: 'Condition', versions: '*', format: 'code', getter: c => c.code.coding[0] },
{ title: 'Condition', versions: '*', getter: c => c.code.text },
{ title: 'Condition', versions: '*', format: 'codeableConcept', getter: c => c.code },
{ title: 'Date of Onset', versions: '*', format: 'date', getter: c => c.onsetDateTime },
{ title: 'Date Resolved', 'versions': '*', format: 'date', getter: c => c.abatementDateTime, defaultValue: 'N/A' },
{ title: 'Recorded Date', versions: '*', format: 'date', getter: c => c.recordedDate },
{ title: 'Severity', versions: '*', format: 'code', getter: c => c.severity.coding[0] },
{ title: 'Body Site', versions: '*', format: 'code', getter: c => c.bodySite[0].coding[0] }
{ title: 'Severity', versions: '*', format: 'codeableConcept', getter: c => c.severity },
{ title: 'Body Site', versions: '*', format: 'codeableConcept', getter: c => c.bodySite?.[0] }
]
}

View File

@ -9,7 +9,7 @@ import {attributeXTime} from './utils';
})
export class ListCoverageComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Type', versions: '*', format: 'code', getter: c => c.type.coding[0] },
{ title: 'Type', versions: '*', format: 'codeableConcept', getter: c => c.type },
{ title: 'Period', versions: '*', format: 'period', getter: c => c.period }
]
}

View File

@ -9,10 +9,10 @@ import {attributeXTime} from './utils';
})
export class ListDeviceRequestComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Device', versions: '*', format: 'code', getter: d => d.codeCodeableConcept.coding[0] },
{ title: 'Device', versions: '*', format: 'codeableConcept', getter: d => d.codeCodeableConcept },
{ title: 'Author Date', versions: '*', format: 'date', getter: d => d.authoredOn },
{ title: 'Do Not Perform', versions: '*', getter: d => d.modifierExtension.doNotPerform },
{ title: 'Do Not Perform Reason', versions: '*', format: 'code', getter: s => s.extension.doNotPerformReason.coding[0] }
{ title: 'Do Not Perform Reason', versions: '*', format: 'codeableConcept', getter: s => s.extension?.doNotPerformReason }
]
}

View File

@ -10,7 +10,7 @@ import {attributeXTime} from './utils';
export class ListDeviceComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Device', versions: '*', getter: d => d.model },
{ title: 'Type', versions: '*', format: 'date', getter: d => d.type.coding[0] },
{ title: 'Type', versions: '*', format: 'codeableConcept', getter: d => d.type },
{ title: 'Unique ID', versions: '*', getter: d => d.udi?.name || d.udiCarrier?.deviceIdentifier },
]
}

View File

@ -10,9 +10,9 @@ import {attributeXTime} from './utils';
export class ListDiagnosticReportComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Issued', versions: '*', format: 'date', getter: d => d.issued },
{ title: 'Title', versions: '*', getter: d => d.code.text },
{ title: 'Document Title', versions: '*', getter: d => d.presentedForm[0].title }, //Doc title
{ title: 'Author', versions: '*', getter: d => d.performer[0].display },
{ title: 'Title', versions: '*', format: 'codeableConcept', getter: d => d.code },
{ title: 'Document Title', versions: '*', getter: d => d.presentedForm?.[0]?.title }, //Doc title
{ title: 'Author', versions: '*', getter: d => d.performer?.[0]?.display },
]
}

View File

@ -10,9 +10,9 @@ import {attributeXTime} from './utils';
export class ListDocumentReferenceComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Date', versions: '*', format: 'date', getter: d => d.date },
{ title: 'Content', versions: '*', getter: d => d.content[0].attachment.title }, // cerner works
{ title: 'Category', versions: '*', getter: d => d.category[0].text }, // Document category
{ title: 'Author', versions: '*', getter: d => d.author[0].display }, // Whoever creates the document
{ title: 'Content', versions: '*', getter: d => d.content?.[0]?.attachment.title },
{ title: 'Category', versions: '*', format: 'codeableConcept', getter: d => d.category }, // Document category
{ title: 'Author', versions: '*', getter: d => d.author?.[0]?.display }, // Whoever creates the document
]
}

View File

@ -8,12 +8,10 @@ import {GenericColumnDefn, ListGenericResourceComponent, ResourceListComponentIn
})
export class ListEncounterComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
// { title: 'Encounter', versions: '*', format: 'code', getter: e => e.type[0].coding[0] },
// { title: 'Encounter', versions: '*', getter: e => e.reasonCode[0].text },
{ title: 'Period', versions: '*', format: 'period', getter: e => e.period },
{ title: 'Encounter', versions: '*', getter: e => e.type[0].text },
{ title: 'Reason', versions: '*', getter: e => e.reasonCode[0].text },
{ title: 'Practioner', versions: '*', getter: e => e.participant[0].individual.display },
{ title: 'Discharge Disposition', versions: '*', format: 'code', getter: e => e.hospitalization?.dischargeDisposition.coding[0] },
{ title: 'Encounter', versions: '*', format: 'codeableConcept', getter: e => e.type?.[0] },
{ title: 'Reason', versions: '*', format: 'codeableConcept', getter: e => e.reasonCode?.[0] },
{ title: 'Practitioner', versions: '*', getter: e => e.participant?.[0]?.individual?.display },
{ title: 'Discharge Disposition', versions: '*', format: 'codeableConcept', getter: e => e.hospitalization?.dischargeDisposition },
]
}

View File

@ -8,7 +8,7 @@ import {GenericColumnDefn, ListGenericResourceComponent} from './list-generic-re
})
export class ListImmunizationComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Vaccine', versions: '*', format: 'code', getter: i => i.vaccineCode.coding[0] },
{ title: 'Vaccine', versions: '*', format: 'codeableConcept', getter: i => i.vaccineCode },
{ title: 'Status', versions: '*', getter: i => i.status },
{ title: 'Date Given', versions: '*', format: 'date', getter: i => i.date || i.occurrenceDateTime || i.occurrenceStringe },
{ title: 'Date Recorded', versions: '*', format: 'date', getter: i => i.recorded }

View File

@ -9,11 +9,11 @@ import {attributeXTime} from './utils';
})
export class ListMedicationAdministrationComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Medication', versions: '*', format: 'code', getter: m => m.medicationCodeableConcept.coding[0] },
{ title: 'Route', versions: '*', format: 'code', getter: m => m.dosage.route.coding[0] },
{ title: 'Medication', versions: '*', format: 'codeableConcept', getter: m => m.medicationCodeableConcept },
{ title: 'Route', versions: '*', format: 'codeableConcept', getter: m => m.dosage.route },
{ title: 'Effective', versions: '*', getter: m => attributeXTime(m,'effective')},
{ title: 'Status', versions: '*', getter: m => m.status},
{ title: 'Status Reason', versions: '*', format: 'code', getter: m => m.statusReason[0].coding[0] },
{ title: 'Status Reason', versions: '*', format: 'codeableConcept', getter: m => m.statusReason?.[0] },
{ title: 'Recorded', versions: '*', format: 'date', getter: m => m.extension.recorded }
]
}

View File

@ -9,7 +9,7 @@ import {attributeXTime} from './utils';
})
export class ListMedicationDispenseComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Medication', versions: '*', format: 'code', getter: m => m.medicationCodeableConcept.coding[0] },
{ title: 'Medication', versions: '*', format: 'code', getter: m => m.medicationCodeableConcept?.coding?.[0] },
{ title: 'Handed Over Date', versions: '*', format: 'date', getter: m => m.whenHandedOver}
]
}

View File

@ -8,13 +8,12 @@ import {GenericColumnDefn, ListGenericResourceComponent} from './list-generic-re
})
export class ListMedicationRequestComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
// { title: 'Medication', versions: '*', format: 'code', getter: m => m.medicationCodeableConcept?.coding[0] },
{ title: 'Author Date', versions: '*', format: 'date', getter: m => m.authoredOn },
{ title: 'Medication', versions: '*', getter: m => m.medicationCodeableConcept.coding[0].display }, //remove drug code
{ title: 'Dosage Timing', versions: '*', format: 'period', getter: m => m.dosageInstruction[0]?.timing.repeat.boundsPeriod},
// Not used { title: 'Dosage Date', versions: '*', format: 'date', getter: m => m.dosageInstruction[0]?.timing.event},
{ title: 'Route', versions: '*', format: 'code', getter: m => m.dosageInstruction[0]?.route.coding[0] },
{ title: 'Medication', versions: '*', format: 'codeableConcept', getter: m => m.medicationCodeableConcept }, //remove drug code
{ title: 'Dosage Timing', versions: '*', format: 'period', getter: m => m.dosageInstruction?.[0]?.timing?.repeat?.boundsPeriod},
// { title: 'Dosage Date', versions: '*', format: 'date', getter: m => m.dosageInstruction[0]?.timing.event},
{ title: 'Route', versions: '*', format: 'codeableConcept', getter: m => m.dosageInstruction?.[0]?.route },
{ title: 'Do Not Perform', versions: '*', getter: m => m.doNotPerform},
{ title: 'Reason', versions: '*', format: 'code', getter: m => m.reasonCode[0]?.coding[0] },
{ title: 'Reason', versions: '*', format: 'codeableConcept', getter: m => m.reasonCode?.[0] },
]
}

View File

@ -8,7 +8,7 @@ import {GenericColumnDefn, ListGenericResourceComponent} from './list-generic-re
})
export class ListMedicationComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Medication', versions: '*', format: 'code', getter: c => c.medicationCodeableConcept.coding[0] },
{ title: 'Medication', versions: '*', format: 'codeableConcept', getter: c => c.medicationCodeableConcept },
{ title: 'Date Prescribed', versions: '*', format: 'date', getter: c => c.authoredOn },
{ title: 'Status', 'versions': '*', getter: c => c.status }
]

View File

@ -9,8 +9,8 @@ import {attributeXTime} from './utils';
})
export class ListNutritionOrderComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Preference', versions: '*', format: 'code', getter: n => n.foodPreferenceModifier[0].coding[0] },
{ title: 'Exclusion', versions: '*', format: 'code', getter: n => n.excludeFoodModifier[0].coding[0] },
{ title: 'Preference', versions: '*', format: 'code', getter: n => n.foodPreferenceModifier?.[0].coding?.[0] },
{ title: 'Exclusion', versions: '*', format: 'code', getter: n => n.excludeFoodModifier?.[0].coding?.[0] },
{ title: 'Date', versions: '*', format: 'date', getter: n => n.dateTime },
{ title: 'Status', versions: '*', getter: n => n.status }
]

View File

@ -10,9 +10,8 @@ import {GenericColumnDefn, ListGenericResourceComponent} from './list-generic-re
export class ListObservationComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Issued Date', 'versions': '*', format: 'date', getter: o => o.issued },
// { title: 'Effective', 'versions': '*', getter: o => attributeXTime(o,'effective') },
{ title: 'Effective', 'versions': '*', getter: o => attributeXTime(o,'effective') },
{ title: 'Observation', versions: '*', format: 'code', getter: o => o.code.coding[0] },
{ title: 'Observation', versions: '*', format: 'codeableConcept', getter: o => o.code },
{ title: 'Value', versions: '*', getter: o => obsValue(o) },
// { title: 'Issued Date', 'versions': '*', format: 'date', getter: o => o.issued },
{ title: 'ID', versions: '*', getter: o => o.id }

View File

@ -9,12 +9,12 @@ import {GenericColumnDefn, ListGenericResourceComponent} from './list-generic-re
})
export class ListProcedureComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
{ title: 'Procedure', versions: '*', format: 'code', getter: p => p.code.coding[0] },
{ title: 'Procedure', versions: '*', format: 'code', getter: p => p.code.coding?.[0] },
{ title: 'Performed', versions: '*', getter: p => attributeXTime(p,'performed') },
{ title: 'ID', versions: '*', getter: p => p.id },
{ title: 'Recorded', versions: '*', format: 'dateTime', getter: p => p.extension?.recorded },
{ title: 'Reason', versions: '*', format: 'code', getter: p => p.reasonCode?.coding[0] },
{ title: 'Reason', versions: '*', format: 'code', getter: p => p.reasonCode?.coding?.[0] },
{ title: 'Status', versions: '*', getter: p => p.status },
{ title: 'Status Reason', versions: '*', format: 'code', getter: p => p.statusReason?.coding[0] }
{ title: 'Status Reason', versions: '*', format: 'code', getter: p => p.statusReason?.coding?.[0] }
]
}

View File

@ -11,10 +11,10 @@ export class ListServiceRequestComponent extends ListGenericResourceComponent {
columnDefinitions: GenericColumnDefn[] = [
// orig { title: 'Service', versions: '*', format: 'code', getter: s => s.code.coding[0] },
{ title: 'Author Date', versions: '*', format: 'date', getter: s => s.authoredOn },
{ title: 'Service', versions: '*', getter: s => s.category[0].text },
{ title: 'Ordered', versions: '*', getter: s => s.code.text },
{ title: 'Dx', versions: '*', format: 'code', getter: s => s.reasonCode[0].coding[0] }, //Was Task
{ title: 'Ordered By', versions: '*', getter: s => s.requester.display },
{ title: 'Service', versions: '*', format:'codeableConcept', getter: s => s.category?.[0] },
{ title: 'Ordered', versions: '*', format:'codeableConcept', getter: s => s.code },
{ title: 'Dx', versions: '*', format: 'codeableConcept', getter: s => s.reasonCode?.[0] }, //Was Task
{ title: 'Ordered By', versions: '*', getter: s => s.requester?.display },
{ title: 'Status', versions: '*', getter: s => s.status },
// Useless { title: 'ID', versions: '*', getter: s => s.id },
// Not used { title: 'Do Not Perform', versions: '*', getter: s => s.doNotPerform },

View File

@ -15,11 +15,16 @@ export function getPath(obj, path = ""): string {
export const FORMATTERS = {
date: (str) => str ? moment(str).format('YYYY-MM-DD') : '',
time: (str) => str ? moment(str).format('HH:mm:ss') : '',
dateTime: (str) => str ? moment(str).format('YYYY-MM-DD - h:mm:ss a') : '',
time: (str) => str ? moment(str).format('HH:mm') : '',
dateTime: (str) => str ? moment(str).format('YYYY-MM-DD - h:mm a') : '',
numberWithCommas: (str) => str ? str.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : '',
code: (code) => code ? `${code.code}: ${code.display ? code.display : ''}` : '',
period: (period) => period ? `${moment(period.start).format('YYYY-MM-DD - h:mm:ss a')} -> ${moment(period.end).format('YYYY-MM-DD - h:mm:ss a')}` : ''
codeableConcept: (codeableConcept) => {
if(!codeableConcept) return ''
if(codeableConcept.text) return codeableConcept.text
return codeableConcept.coding && codeableConcept.coding[0] ? `${codeableConcept.coding[0].code}: ${codeableConcept.coding[0].display ? codeableConcept.coding[0].display : ''}` : ''
},
period: (period) => period ? `${moment(period.start).format('YYYY-MM-DD - h:mm a')} -> ${moment(period.end).format('YYYY-MM-DD - h:mm a')}` : ''
};
export function round(num, digits) {