Parses an HL7 FHIR R4 Observation (as produced by
toFHIRObservation) back into a ClinicalScore,
the import counterpart of the to*/write* exporters. The
instrument_id and each subscale name are recovered from the bundled
LOINC map (reverse code lookup, then display, then the verbatim text); the
total and subscale values come from valueQuantity (a
dataAbsentReason becomes NA); the subject id strips a leading
"Patient/"; and the timestamp comes from effectiveDateTime.
Arguments
- observation
A FHIR Observation as a list (a
toFHIRObservationresult or a parsed jsonlite object), a JSON string, or a path to a.jsonfile.
Details
The round-trip is lossy for three slots that toFHIRObservation
does not serialize: items_used and missing_handling cannot be
recovered, and stratum is re-derived from the total only when the
instrument is registered (via getInstrument), otherwise
NA.
Examples
sc <- scoreInstrument("katz_adl",
stats::setNames(rep(1, 6), getInstrument("katz_adl")@items),
subject_id = "P01")
fromFHIR(toFHIRObservation(sc))@total
#> [1] 6