Validate records of observations & investigations

validate_investigations(
  investigations,
  custom_units = c("breaths", "beats", "U")
)

Arguments

investigations

a data frame

custom_units

a character vector of valid unit codes not listed in the UCUM. Default is: c("breaths", "beats", "U").

Value

TRUE if the validation is passed

Mandatory variables

The following variables are required:

"observation_id"

a unique identifier with no missing value

"patient_id"

a patient identifier with no missing value

"status"

Codes from the following value set http://hl7.org/fhir/observation-status/

  • "registered": The existence of the observation is registered, but there is no result yet available.

  • "preliminary": his is an initial or interim observation: data may be incomplete or unverified.

  • "final": The observation is complete and there are no further actions needed.

  • "amended": Subsequent to being Final, the observation has been modified subsequent. This includes updates/new information and corrections.

  • "corrected": Subsequent to being Final, the observation has been modified to correct an error in the test result.

  • "cancelled": The observation is unavailable because the measurement was not started or not completed.

  • "entered-in-error": The observation has been withdrawn following previous final release. This electronic record should never have existed, though it is possible that real-world decisions were based on it. (If real-world activity has occurred, the status should be "cancelled" rather than "entered-in-error".).

  • "unknown": The authoring/source system does not know which of the status values currently applies for this observation. Note: This concept is not to be used for "other" - one of the listed statuses is presumed to apply, but the authoring/source system does not know which.

"request_datetime"

a datetime when the observation was requested with no missing value

"observation_datetime"

a datetime when the investigation was performed with no missing value

"observation_code_system"

URL of the code system (for instance: "http://snomed.info/sct", "http://loinc.org")

"observation_code"

LOINC concept code or SNOMED-CT concept code corresponding to a SNOMED CT observable entity or evaluation procedure

"observation_name"

code system name for the observation

"observation_display"

observation name to display

"observation_value_text"

observation string value or codable concept, for example: "TRUE"/"FALSE", "Yes"/"No", SNOMED CT qualifier value

"observation_value_numeric"

observation numeric value

"observation_unit"

a unit code passing as_units(). See examples. All observations with the same "observation_code" must be converted to the same "observation_unit". See also: valid_udunits, install_unit https://ucum.org/

Examples

# the units "breaths/min" (http://loinc.org/8867-4) or
# "beats/min" () do not exist in the https://ucum.org/. 
library(units)
#> udunits database from /usr/share/xml/udunits/udunits2.xml
if (FALSE) as_units("breaths/min") # fails

# Yet, they may be declared.
install_unit("breaths") 
as_units("breaths/min") # succeeds
#> 1 [breaths/min]