Serializes a ClinicalScore into an HL7 FHIR R4
Observation resource (as a jsonlite-ready list): a survey-category
Observation whose code uses the LOINC map (falling back to a text-only
code), the total as valueQuantity, and each subscale as a
component. Provenance can be attached via derivedFrom.
Arguments
- score
- subject
Subject reference (e.g.
"Patient/123"); used verbatim. Defaults to the score'ssubject_id: a bare id becomes"Patient/<id>", while an id that is already a reference (contains a"/"or aurn:/URL scheme) is used as-is.- effectiveDateTime
ISO-8601 datetime; defaults to the score's timestamp.
- derivedFrom
Optional character vector of source references.
Examples
sc <- methods::new("ClinicalScore", instrument_id = "berg", total = 45,
subject_id = "P01", timestamp = "2026-07-26T09:00:00Z")
toFHIRObservation(sc)
#> <fhir_observation> Observation/final
#> code: Berg Balance Scale total score
#> subject: Patient/P01
#> value: 45 {score}