FHIR R5 ServiceRequest resource.
A record of a request for a service such as diagnostic investigations, treatments, or operations to be performed. The primary resource for representing lab exam orders.
https://www.hl7.org/fhir/R5/servicerequest.html
| Status codes: draft | active | on-hold | revoked | completed | entered-in-error | unknown |
| Intent codes: proposal | plan | directive | order | original-order | reflex-order |
filler-order | instance-order | optionPriority codes: routine | urgent | asap | stat
Polymorphic fields
Several fields use the FHIR [x] polymorphic pattern. In this struct, they are
represented as tagged tuples. See to_map/1 for how they serialize to JSON.
quantity→{:quantity, %Quantity{}}|{:ratio, %Ratio{}}|{:range, %Range{}}occurrence→{:date_time, "..."}|{:period, %Period{}}|{:timing, map()}as_needed→{:boolean, true}|{:codeable_concept, %CodeableConcept{}}
Example
alias FhirEx.Resources.ServiceRequest
alias FhirEx.Types.{Reference, CodeableConcept, Coding, Identifier}
order = %ServiceRequest{
id: "order-001",
identifier: [%Identifier{system: "http://hospital.org/orders", value: "ORD-2024-0042"}],
status: "active",
intent: "order",
priority: "routine",
code: %CodeableConcept{
coding: [%Coding{
system: "http://loinc.org",
code: "58410-2",
display: "CBC panel - Blood by Automated count"
}],
text: "Complete Blood Count"
},
subject: %Reference{reference: "Patient/patient-001"},
encounter: %Reference{reference: "Encounter/enc-001"},
requester: %Reference{reference: "Practitioner/pract-001"},
occurrence: {:date_time, "2024-01-15T10:00:00Z"}
}
json = FhirEx.JSON.encode!(order)
Summary
Functions
Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON). Polymorphic fields are decoded into tagged tuples.
Builds a new struct from a map or keyword list of field values.
Returns the FHIR resource type name string.
Converts the struct to a string-keyed map for use with FhirEx.JSON. Polymorphic fields (occurrence[x], quantity[x], asNeeded[x]) are serialised to their FHIR JSON keys.
Types
@type order_detail() :: %{ parameter_focus: FhirEx.Types.Reference.t() | nil, parameter: [map()] }
@type patient_instruction() :: %{ instruction_markdown: String.t() | nil, instruction_reference: FhirEx.Types.Reference.t() | nil }
@type t() :: %FhirEx.Resources.ServiceRequest{ as_needed: {:boolean, boolean()} | {:codeable_concept, FhirEx.Types.CodeableConcept.t()} | nil, authored_on: String.t() | nil, based_on: [FhirEx.Types.Reference.t()] | nil, body_site: [FhirEx.Types.CodeableConcept.t()] | nil, body_structure: FhirEx.Types.Reference.t() | nil, category: [FhirEx.Types.CodeableConcept.t()] | nil, code: map() | nil, do_not_perform: boolean() | nil, encounter: FhirEx.Types.Reference.t() | nil, extension: [FhirEx.Types.Extension.t()] | nil, focus: [FhirEx.Types.Reference.t()] | nil, id: String.t() | nil, identifier: [FhirEx.Types.Identifier.t()] | nil, instantiates_canonical: [String.t()] | nil, instantiates_uri: [String.t()] | nil, insurance: [FhirEx.Types.Reference.t()] | nil, intent: String.t(), location: [map()] | nil, meta: FhirEx.Types.Meta.t() | nil, note: [FhirEx.Types.Annotation.t()] | nil, occurrence: {:date_time, String.t()} | {:period, FhirEx.Types.Period.t()} | {:timing, map()} | nil, order_detail: [order_detail()] | nil, patient_instruction: [patient_instruction()] | nil, performer: [FhirEx.Types.Reference.t()] | nil, performer_type: FhirEx.Types.CodeableConcept.t() | nil, priority: String.t() | nil, quantity: {:quantity, FhirEx.Types.Quantity.t()} | {:ratio, FhirEx.Types.Ratio.t()} | {:range, FhirEx.Types.Range.t()} | nil, reason: [map()] | nil, relevant_history: [FhirEx.Types.Reference.t()] | nil, replaces: [FhirEx.Types.Reference.t()] | nil, requester: FhirEx.Types.Reference.t() | nil, requisition: FhirEx.Types.Identifier.t() | nil, specimen: [FhirEx.Types.Reference.t()] | nil, status: String.t(), subject: FhirEx.Types.Reference.t(), supporting_info: [map()] | nil, text: FhirEx.Types.Narrative.t() | nil }
Functions
Builds the struct from a string-keyed map (e.g., from decoded FHIR JSON). Polymorphic fields are decoded into tagged tuples.
Builds a new struct from a map or keyword list of field values.
@spec resource_type() :: String.t()
Returns the FHIR resource type name string.
Converts the struct to a string-keyed map for use with FhirEx.JSON. Polymorphic fields (occurrence[x], quantity[x], asNeeded[x]) are serialised to their FHIR JSON keys.