This function performs a series of checks for mandatory and optional requirements on prescriptions data.

validate_prescriptions(data)

Arguments

data

a data frame containing one row per prescription

Value

NULL if the data passes the validation. The function will trigger errors when mandatory requirements are not met and warnings when optional requirements are not met.

Mandatory fields

These fields are required in order to pass the validation:

patient_id

a patient identifier with no missing value

prescription_id

a prescription identifier with no missing value

prescription_text

a character string summarising the prescription (to be displayed in user interfaces, eg: 'Amoxicillin oral 500mg BDS')

drug_code

identifier of the drug (for antibacterials/antifungals, use as.ab())

drug_name

preferred name of the drug in the drug dictionary (see ab_name())

drug_display_name

drug name to display in reports and user interfaces (can be the same as drug_name)

drug_group

the antimicrobial class see ab_group()

antiinfective_type

type of antiinfective ("antibacterial", "antifungal", "antiviral", or "antiparasitic")

ATC_code

the ATC code, see ab_atc()

ATC_route

route of administration as defined in the ATC ( "O" = oral; "P" = parenteral; "Inhal" = inhaled; "N" = nasal; "SL" = sublingual/buccal/oromucosal; "TD" = transdermal; "R" = rectal; "V" = vaginal)

authoring_date

timestamp for when the prescription was issued

prescription_start

timestamp for the prescription start

prescription_end

timestamp for the prescription end (mandated except for one-off prescriptions with daily_frequency == -1 or prescriptions with prescription_status != "completed")

prescription_context

either 'inpatient', 'opat', or 'discharge'

prescription_status

one value from the following FHIR R4 reference set:

  • "active" the prescription is 'actionable', but not all actions that are implied by it have occurred yet.

  • "on-hold" actions implied by the prescription are to be temporarily halted, but are expected to continue later.

  • "cancelled" the prescription has been withdrawn before any administrations have occurred.

  • "completed" all actions that are implied by the prescription have occurred.

  • "entered-in-error" some of the actions that are implied by the medication request may have occurred. For example, the medication may have been dispensed and the patient may have taken some of the medication. Clinical decision support systems should take this status into account.

  • "stopped" actions implied by the prescription are to be permanently halted, before all of the administrations occurred. This should not be used if the original order was entered in error.

  • "draft" the prescription is not yet 'actionable', e.g. it is a work in progress, requires sign-off, verification or needs to be run through decision support process.

  • "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.

Note that prescriptions marked as "on-hold", "cancelled", "draft", "entered-in-error", or "unknown" will not count towards therapy episodes or antibiotic consumption estimates.

dose

a numeric vector of dosage quantities

unit

a character vector of dosage units

route

the route of administration value natively assigned by system

frequency

a character vector of frequencies of administrations (eg: "BDS" or "Twice a day"). See also: reference_drug_frequency

daily_frequency

a numeric translation of variable frequency indicating the number of times the drug is to be administered per day. Values can be lower than 1 for prescriptions administered less than daily. Values must be strictly positive, except for the following codes:

  • -1 for a single one-off administration

  • -9 for 'as required' (Pro Re Nata) prescriptions

Optional fields

combination_id

system-issued identifiers for drugs prescribed as a bundle to treat the same indication either simultaneously (eg clarithromycin and amoxiclav) or consecutively (eg doxicycline 200mg followed by 100mg). Unless provided, such identifiers will be created by Ramses using transitive closure.

DDD

the prescribed daily dose (dose x daily_frequency) expressed in defined daily doses, see compute_DDDs()

...

any other field, as desired, can be loaded into the database