ac-fhir-models
Advanced tools
Comparing version 7.3.2 to 7.3.3
54
index.js
@@ -1756,24 +1756,2 @@ 'use strict'; | ||
const getObservationValues = data => { | ||
const initialValues = baseObservationDefinition.getValues(data); | ||
if (initialValues.observationType === 'physical-attributes') { | ||
return physicalAttributesObservationDefinition.getValues(data) | ||
} | ||
return initialValues | ||
}; | ||
const baseObservationDefinition = createFHIRModelDefinition({ | ||
resourceType: 'Observation', | ||
props: { | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
definition: sinks.buildDefinition( | ||
{ | ||
'code.coding.[].code': 'str', | ||
'code.coding.[].system': 'str', | ||
}, | ||
fhirFieldTypes | ||
), | ||
}); | ||
const rawWeightInKgProp = getObservationComponentValueQuantityProp( | ||
@@ -1846,8 +1824,13 @@ ncLoinc, | ||
// This is a definition that just lets us grab the observationType prop | ||
const observationTypeDefinition = createFHIRModelDefinition({ | ||
const baseObservationProps = { | ||
id: 'id', | ||
observationType: getXchartObservationCodeProp(), | ||
patientId: getDirectReferenceProp('subject', 'Patient'), | ||
dateTime: getTimeProp('effectiveDateTime'), | ||
status: 'status', | ||
}; | ||
const baseObservationDefinition = createFHIRModelDefinition({ | ||
resourceType: 'Observation', | ||
props: { | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
props: baseObservationProps, | ||
definition: baseObservationSinkDefinition, | ||
@@ -1860,6 +1843,3 @@ }); | ||
props: { | ||
id: 'id', | ||
status: 'status', | ||
patientId: getDirectReferenceProp('subject', 'Patient'), | ||
dateTime: getTimeProp('effectiveDateTime'), | ||
...baseObservationProps, | ||
weightInKg: weightInKgProp, | ||
@@ -1873,3 +1853,2 @@ heightInCm: heightInCmProp, | ||
}, | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
@@ -1892,2 +1871,12 @@ definition: baseObservationSinkDefinition, | ||
// Since we can have different observation types with different properties, | ||
// we need to determine which definition to use based on the observation type. | ||
const getObservationValues = data => { | ||
const baseValues = baseObservationDefinition.getValues(data); | ||
if (baseValues.observationType === 'physical-attributes') { | ||
return physicalAttributesObservationDefinition.getValues(data) | ||
} | ||
return baseValues | ||
}; | ||
// @ts-check | ||
@@ -1981,3 +1970,2 @@ | ||
exports.observationStatus = observationStatus; | ||
exports.observationTypeDefinition = observationTypeDefinition; | ||
exports.organizationDefinition = organizationDefinition; | ||
@@ -1984,0 +1972,0 @@ exports.organizationType = organizationType; |
{ | ||
"name": "ac-fhir-models", | ||
"version": "7.3.2", | ||
"version": "7.3.3", | ||
"author": "Henrik Joreteg <henrik@anesthesiacharting.com>", | ||
@@ -5,0 +5,0 @@ "dependencies": { |
@@ -77,24 +77,2 @@ // @ts-check | ||
export const getObservationValues = data => { | ||
const initialValues = baseObservationDefinition.getValues(data) | ||
if (initialValues.observationType === 'physical-attributes') { | ||
return physicalAttributesObservationDefinition.getValues(data) | ||
} | ||
return initialValues | ||
} | ||
export const baseObservationDefinition = createFHIRModelDefinition({ | ||
resourceType: 'Observation', | ||
props: { | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
definition: buildDefinition( | ||
{ | ||
'code.coding.[].code': 'str', | ||
'code.coding.[].system': 'str', | ||
}, | ||
fhirFieldTypes | ||
), | ||
}) | ||
const rawWeightInKgProp = getObservationComponentValueQuantityProp( | ||
@@ -167,8 +145,13 @@ ncLoinc, | ||
// This is a definition that just lets us grab the observationType prop | ||
export const observationTypeDefinition = createFHIRModelDefinition({ | ||
const baseObservationProps = { | ||
id: 'id', | ||
observationType: getXchartObservationCodeProp(), | ||
patientId: getDirectReferenceProp('subject', 'Patient'), | ||
dateTime: getTimeProp('effectiveDateTime'), | ||
status: 'status', | ||
} | ||
export const baseObservationDefinition = createFHIRModelDefinition({ | ||
resourceType: 'Observation', | ||
props: { | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
props: baseObservationProps, | ||
definition: baseObservationSinkDefinition, | ||
@@ -181,6 +164,3 @@ }) | ||
props: { | ||
id: 'id', | ||
status: 'status', | ||
patientId: getDirectReferenceProp('subject', 'Patient'), | ||
dateTime: getTimeProp('effectiveDateTime'), | ||
...baseObservationProps, | ||
weightInKg: weightInKgProp, | ||
@@ -194,3 +174,2 @@ heightInCm: heightInCmProp, | ||
}, | ||
observationType: getXchartObservationCodeProp(), | ||
}, | ||
@@ -212,1 +191,11 @@ definition: baseObservationSinkDefinition, | ||
) | ||
// Since we can have different observation types with different properties, | ||
// we need to determine which definition to use based on the observation type. | ||
export const getObservationValues = data => { | ||
const baseValues = baseObservationDefinition.getValues(data) | ||
if (baseValues.observationType === 'physical-attributes') { | ||
return physicalAttributesObservationDefinition.getValues(data) | ||
} | ||
return baseValues | ||
} |
@@ -9,5 +9,6 @@ // @ts-check | ||
test('getObservationValues', t => { | ||
const dateTimeString = new Date().toISOString() | ||
const physical = physicalAttributesObservationDefinition.create({ | ||
patientId: '123', | ||
dateTime: new Date().toISOString(), | ||
dateTime: dateTimeString, | ||
weightInKg: 72, | ||
@@ -34,3 +35,3 @@ heightInCm: 180, | ||
patientId: '123', | ||
dateTime: physicalValues.dateTime, | ||
dateTime: dateTimeString, | ||
weightInKg: 72, | ||
@@ -45,2 +46,5 @@ heightInCm: 180, | ||
t.deepEqual(otherValues, { | ||
patientId: '123', | ||
dateTime: dateTimeString, | ||
status: 'final', | ||
observationType: 'some-other-observation', | ||
@@ -47,0 +51,0 @@ }) |
162968
5624