Laboratory order
DSP lab orders map onto ServiceRequest with category=laboratory. The lab concept is a LOINC-coded CodeableConcept in ServiceRequest.code, and sample_type becomes a Specimen resource.
order.laboratory
ServiceRequest (category=laboratory) + Specimen
Field-by-field
| DSP | FHIR R4 | Notes |
|---|---|---|
type: LAB_ORDER | ServiceRequest.category = laboratory | Use http://snomed.info/sct|108252007. |
intent | ServiceRequest.intent | |
description | ServiceRequest.code.text | |
order_data.lab.codes (LOINC) | ServiceRequest.code.coding[] | |
order_data.lab_abbreviation | Extension abbreviation | "CMP" / "CBC". |
order_data.sample_type | ServiceRequest.specimen → Specimen.type | SNOMED specimen codes. |
order_data.lab_instructions | ServiceRequest.note.text | |
order_data.patient_instructions | ServiceRequest.patientInstruction | |
reason / reason_references | reasonCode / reasonReference | |
confidence_score | DSP extension |
Side-by-side example
DSP
{
"id": "a61aa82032764e389481dba3dc090748",
"type": "LAB_ORDER",
"context": { "content_type": "order.laboratory" },
"description": "Comprehensive metabolic panel to assess kidney function",
"intent": "order",
"order_data": {
"lab": {
"text": "Comprehensive metabolic panel to assess kidney function",
"codes": [{
"system":"LOINC","code":"24323-8",
"description":"Comprehensive metabolic 2000 panel"
}]
},
"lab_abbreviation": "CMP",
"sample_type": "blood",
"lab_instructions": "Fasting specimen preferred",
"patient_instructions": "Fast for 8-12 hours before blood draw. Repeat in 3 months."
},
"confidence_score": 1.0
} FHIR R4 (DSP-FHIR profile)
{
"resourceType":"ServiceRequest",
"status":"active","intent":"order",
"category":[{"coding":[{"system":"http://snomed.info/sct","code":"108252007","display":"Laboratory procedure"}]}],
"code":{
"text":"Comprehensive metabolic panel to assess kidney function",
"coding":[{"system":"http://loinc.org","code":"24323-8"}]
},
"specimen":[{"reference":"Specimen/spec-1"}],
"patientInstruction":"Fast for 8-12 hours before blood draw. Repeat in 3 months.",
"note":[{"text":"Fasting specimen preferred"}],
"subject":{"reference":"Patient/pat-67890"},
"encounter":{"reference":"Encounter/enc-12345"},
"extension":[
{"url":"https://dsp-fhir.org/StructureDefinition/abbreviation","valueString":"CMP"},
{"url":"https://dsp-fhir.org/StructureDefinition/confidence-score","valueDecimal":1.0}
]
}
// Companion Specimen resource
{
"resourceType":"Specimen",
"id":"spec-1",
"type":{"coding":[{"system":"http://snomed.info/sct","code":"119297000","display":"Blood specimen"}]},
"subject":{"reference":"Patient/pat-67890"}
} DSP → FHIR mapping
Skeleton for DspLabOrder → ServiceRequest(category=laboratory). The companion Specimen is created by a sibling group not shown here.
map "https://dsp-fhir.org/StructureMap/DspLabOrderToServiceRequest" = "DspLabOrderToServiceRequest"
uses "https://dsp-fhir.org/StructureDefinition/DspOrderLabResource" alias DspLabOrder as source
uses "http://hl7.org/fhir/StructureDefinition/ServiceRequest" alias ServiceRequest as target
group DspLabOrderToServiceRequest(source src : DspLabOrder, target tgt : ServiceRequest) {
src.id as id -> tgt.id = id;
src -> tgt.status = 'active';
src -> tgt.intent = 'order';
src -> tgt.category as cat, cat.coding as co,
co.system = 'http://terminology.hl7.org/CodeSystem/service-category',
co.code = 'laboratory' "category";
src.payload as p then {
p.test as t -> tgt.code as code, code.text = t "test-text";
p.loinc as l -> tgt.code as code, code.coding as co,
co.system = 'http://loinc.org', co.code = l "loinc";
p.abbreviation as ab -> tgt.extension as ext then {
ab -> ext.url = 'https://dsp-fhir.org/StructureDefinition/dsp-abbreviation',
ext.value = create('string') as v, v.value = ab;
} "abbrev";
};
src.confidence as conf -> tgt.extension as ext then {
conf -> ext.url = 'https://dsp-fhir.org/StructureDefinition/dsp-confidence-score',
ext.value = create('decimal') as v, v.value = conf;
} "confidence";
} FHIR → DSP (canonical $graphql read)
Standard FHIR $graphql selects every native ServiceRequest field and DSP-namespaced extension that the write projection populated. A small adapter renames the result into the DSP shape.
Canonical query
query DspLabOrder($id: ID!) {
ServiceRequest(id: $id) {
id status intent
category { coding { system code display } }
code {
text
coding { system code display }
}
specimen { reference }
note { text }
patientInstruction
reasonCode { text }
reasonReference { reference }
abbreviation: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-abbreviation") {
valueString
}
confidence: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-confidence-score") {
valueDecimal
}
turnRefs: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-transcript-turn-ref") {
transcript: extension(url: "transcript") { valueReference { reference } }
turn: extension(url: "turn") { valueInteger }
}
}
} DSP reconstruction adapter
function toDspLabOrder(s) {
const turnRefs = s.turnRefs ?? [];
return {
id: s.id,
type: 'LAB_ORDER',
intent: s.intent,
description: s.code?.text,
order_data: {
lab: {
text: s.code?.text,
codes: (s.code?.coding ?? []).map(toDspCode),
},
lab_abbreviation: s.abbreviation?.[0]?.valueString,
sample_type: s.specimen?.[0]?.reference,
lab_instructions: s.note?.map(n => n.text).join('\n'),
patient_instructions: s.patientInstruction,
},
reason: s.reasonCode?.[0]?.text,
reason_references: s.reasonReference?.map(r => r.reference),
confidence_score: s.confidence?.[0]?.valueDecimal,
provenance: turnRefs.map(t => t.turn?.valueInteger),
transcript_ref: turnRefs[0]?.transcript?.valueReference?.reference,
};
} dsp-* extension — and the canonical read selects each one explicitly.
SQL-on-FHIR v2 ViewDefinition that flattens every field above — including DSP extensions — into a tabular projection. Runnable as-is on any spec-conformant engine (Pathling, sof-exec, Aidbox SQL-on-FHIR, Databricks). See the SQL-on-FHIR v2 spec. These ViewDefinitions also ship as JSON in the IG zip.
dsp_service_request_lab — DSP Lab order (ServiceRequest)
Flattens DSP dsp lab order (servicerequest) orders. Filtered by category=laboratory.
{
"resourceType": "ViewDefinition",
"url": "https://dsp-fhir.org/ViewDefinition/dsp-service-request-lab",
"name": "dsp_service_request_lab",
"title": "DSP Lab order (ServiceRequest)",
"status": "draft",
"description": "Flattens DSP dsp lab order (servicerequest) orders. Filtered by category=laboratory.",
"resource": "ServiceRequest",
"fhirVersion": [
"4.0.1"
],
"where": [
{
"path": "category.coding.where(code='laboratory').exists()"
}
],
"select": [
{
"column": [
{
"name": "id",
"path": "id",
"type": "id",
"description": "Server-assigned logical id."
},
{
"name": "version_id",
"path": "meta.versionId",
"type": "id",
"description": "FHIR version id (drives NEW/UPDATED classification)."
},
{
"name": "last_updated",
"path": "meta.lastUpdated",
"type": "instant",
"description": "Instant of last mutation."
},
{
"name": "meta_source",
"path": "meta.source",
"type": "uri"
},
{
"name": "payload_version",
"path": "meta.tag.where(system='https://dsp-fhir.org/CodeSystem/payload-version').code.first()",
"type": "code",
"description": "DSP payload version this resource was last emitted under."
},
{
"name": "confidence_score",
"path": "extension('https://dsp-fhir.org/StructureDefinition/confidence-score').value.ofType(decimal)",
"type": "decimal",
"description": "DSP confidence (0..1)."
},
{
"name": "transcript_ref",
"path": "extension('https://dsp-fhir.org/StructureDefinition/transcript-turn-refs').extension('transcript').value.ofType(Reference).reference",
"type": "string",
"description": "DocumentReference/<id>/_history/<v> that pins the transcript version for turn indices."
},
{
"name": "turn_indices",
"path": "extension('https://dsp-fhir.org/StructureDefinition/transcript-turn-refs').extension('turn').value.ofType(integer)",
"type": "integer",
"collection": true,
"description": "Turn indices joined by $ground into transcript content."
},
{
"name": "spoken_forms",
"path": "extension('https://dsp-fhir.org/StructureDefinition/spoken-forms').extension('form').value.ofType(string)",
"type": "string",
"collection": true
},
{
"name": "search_terms",
"path": "extension('https://dsp-fhir.org/StructureDefinition/search-terms').extension('term').value.ofType(string)",
"type": "string",
"collection": true
},
{
"name": "status",
"path": "status",
"type": "code"
},
{
"name": "intent",
"path": "intent",
"type": "code"
},
{
"name": "priority",
"path": "priority",
"type": "code"
},
{
"name": "subject_patient_id",
"path": "subject.reference.substring(8)",
"type": "string"
},
{
"name": "encounter_id",
"path": "encounter.reference.substring(10)",
"type": "string"
},
{
"name": "authored_on",
"path": "authoredOn",
"type": "dateTime"
},
{
"name": "requester_practitioner_id",
"path": "requester.reference.where($this.startsWith('Practitioner/')).substring(13).first()",
"type": "string"
},
{
"name": "code_system",
"path": "code.coding.system.first()",
"type": "uri"
},
{
"name": "code",
"path": "code.coding.code.first()",
"type": "code"
},
{
"name": "code_display",
"path": "code.coding.display.first()",
"type": "string"
},
{
"name": "code_text",
"path": "code.text",
"type": "string"
},
{
"name": "reason_code_text",
"path": "reasonCode.text.first()",
"type": "string"
},
{
"name": "reason_reference",
"path": "reasonReference.reference.first()",
"type": "string"
},
{
"name": "body_site_code",
"path": "bodySite.coding.code.first()",
"type": "code"
},
{
"name": "specimen_ref",
"path": "specimen.reference.first()",
"type": "string"
},
{
"name": "occurrence_datetime",
"path": "occurrence.ofType(dateTime)",
"type": "dateTime"
},
{
"name": "fasting_required",
"path": "extension('http://hl7.org/fhir/StructureDefinition/servicerequest-questionnaireRequest').exists()",
"type": "boolean"
}
]
}
]
}