/** * WHETHER A UNIT CAN BE NAMED ON AN OBSERVATION, as a lookup rather than a branch. * * This came out of FhirObservation because the rule lived in a 300-line if/else-if chain that set * nine pieces of state per profile, and the chain got it wrong twice in the same way. */ /** * THE TWO WAYS THE CHAIN FAILED, both of which a table makes impossible: * * 1. NO TERMINAL ELSE. With no profile nothing ran, the flag kept its initial false, and the Unit * box rendered disabled and empty - so a result stored with no unit could never be given one. * 19 of 4,160 stored observations carry a profile, so that was the ordinary case. * 2. A BRANCH THAT FORGOT THE SETTER. us-core-pulse-oximetry sets every other flag and not this * one, so it silently inherited whatever the previously rendered profile had left behind. */ /** * THE RULE: a profile leaves the unit OPEN when several units are clinically legitimate - a * temperature may be Cel or degF, a weight kg or lb - and closes it when only one is, as a heart * rate is beats per minute and nothing else. Values are copied from the branches they replace. */ const UNIT_IS_MUTABLE_BY_PROFILE: Record = { 'us-core-average-blood-pressure': false, 'us-core-care-experience-preference': false, 'us-core-observation-adi-documentation': false, 'us-core-observation-lab': true, 'us-core-observation-occupation': false, 'us-core-observation-pregnancyintent': false, 'us-core-observation-pregnancystatus': false, 'us-core-observation-screening-assessment': true, 'us-core-observation-sexual-orientation': false, 'us-core-smokingstatus': false, 'us-core-treatment-intervention-preference': true, 'us-core-vital-signs': true, 'pediatric-bmi-for-age': false, 'pediatric-weight-for-height': false, 'us-core-blood-pressure': false, 'us-core-bmi': false, 'us-core-body-height': true, 'us-core-body-temperature': true, 'us-core-body-weight': true, 'us-core-head-circumference': true, 'us-core-heart-rate': false, // CHOSEN, not copied: this branch set no value at all. Oxygen saturation is a percentage and // nothing else, which is how heart rate and respiratory rate beside it are treated. 'us-core-pulse-oximetry': false, 'us-core-respiratory-rate': false, 'head-occipital-frontal-circumference-percentile': false, }; /** An unknown or absent profile leaves the unit open: nothing has fixed it, so somebody must be * able to name it. */ export const unitIsMutableFor = (profile?: string): boolean => profile === undefined ? true : UNIT_IS_MUTABLE_BY_PROFILE[profile] ?? true;