Procedure order

An order for a procedure is a ServiceRequest; the performed procedure itself is a separate Procedure resource created later. DSP's order_data fields map onto both sides.

DSP content_type

order.procedure

FHIR target

ServiceRequest (category=procedure) → Procedure (when performed)

Field-by-field

DSPFHIR R4Notes
type: PROCEDURE_ORDERServiceRequest.category = procedurehttp://snomed.info/sct|387713003.
descriptionServiceRequest.code.text
order_data.procedure.codes (CPT)ServiceRequest.code.coding[]+ SNOMED.
order_data.surgical_teamServiceRequest.performer[] → PractitionerOr preserve narrative in note.text if unresolved.
order_data.procedure_locationServiceRequest.locationReference → Location
order_data.devicesExtension procedure-devices or downstream Procedure.usedReference
order_data.instructionsServiceRequest.patientInstruction or note.text
reason / reason_referencesreasonCode / reasonReference

Side-by-side example

DSP

{
  "id": "h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4",
  "type": "PROCEDURE_ORDER",
  "context": { "content_type": "order.procedure" },
  "description": "Laparoscopic cholecystectomy for gallbladder stones",
  "intent": "order",
  "reason": "Gallbladder stones",
  "reason_references": ["a12345b67890cdef1234567890abcdef"],
  "order_data": {
    "procedure": {
      "text":"Laparoscopic cholecystectomy",
      "codes":[{"system":"CPT","code":"47562"}]
    },
    "surgical_team":["Dr. Sarah Johnson, MD","Dr. Michael Chen, MD"],
    "procedure_location":"OR 3, Main Hospital",
    "devices":["Laparoscopic camera system","Electrocautery device"],
    "instructions":"NPO after midnight. Pre-operative antibiotics per protocol."
  },
  "confidence_score": 1.0
}

FHIR R4 (DSP-FHIR profile)

{
  "resourceType":"ServiceRequest",
  "status":"active","intent":"order",
  "category":[{"coding":[{"system":"http://snomed.info/sct","code":"387713003","display":"Surgical procedure"}]}],
  "code":{
    "text":"Laparoscopic cholecystectomy",
    "coding":[{"system":"http://www.ama-assn.org/go/cpt","code":"47562"}]
  },
  "reasonCode":[{"text":"Gallbladder stones"}],
  "reasonReference":[{"reference":"Condition/cond-gbs-001"}],
  "performer":[
    {"display":"Dr. Sarah Johnson, MD"},
    {"display":"Dr. Michael Chen, MD"}
  ],
  "locationReference":[{"display":"OR 3, Main Hospital"}],
  "patientInstruction":"NPO after midnight. Pre-operative antibiotics per protocol.",
  "subject":{"reference":"Patient/pat-67890"},
  "encounter":{"reference":"Encounter/enc-12345"},
  "extension":[
    {"url":"https://dsp-fhir.org/StructureDefinition/procedure-devices",
     "extension":[
       {"url":"device","valueString":"Laparoscopic camera system"},
       {"url":"device","valueString":"Electrocautery device"}
     ]},
    {"url":"https://dsp-fhir.org/StructureDefinition/confidence-score","valueDecimal":1.0}
  ]
}

DSP → FHIR mapping

Skeleton for DspProcedureOrder → ServiceRequest(category=procedure). The downstream performed Procedure resource is created by a separate map.

map "https://dsp-fhir.org/StructureMap/DspProcedureOrderToServiceRequest" = "DspProcedureOrderToServiceRequest"

uses "https://dsp-fhir.org/StructureDefinition/DspResource" alias DspResource as source
uses "http://hl7.org/fhir/StructureDefinition/ServiceRequest" alias ServiceRequest as target

group DspProcedureOrderToServiceRequest(source src : DspResource, 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://snomed.info/sct', co.code = '387713003',
    co.display = 'Surgical procedure' "category";

  src.payload as p then {
    p.description as d -> tgt.code as code, code.text = d "code-text";
    p.devices as dev -> tgt.extension as ext,
      ext.url = 'https://dsp-fhir.org/StructureDefinition/dsp-procedure-devices',
      ext.value = create('string') as v, v.value = dev "devices";
  };

  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 the dsp-procedure-devices extension. The performed Procedure (when it materializes downstream) is queried separately.

Canonical query

query DspProcedureOrder($id: ID!) {
  ServiceRequest(id: $id) {
    id status intent
    code { text coding { system code display } }
    performer { reference display }
    locationReference { reference display }
    patientInstruction
    note { text }
    reasonCode { text }
    reasonReference { reference }

    devices: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-procedure-devices") {
      device: extension(url: "device") { 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 toDspProcedureOrder(s) {
  const turnRefs = s.turnRefs ?? [];
  return {
    id: s.id,
    type: 'PROCEDURE_ORDER',
    intent: s.intent,
    description: s.code?.text,
    reason: s.reasonCode?.[0]?.text,
    reason_references: s.reasonReference?.map(r => r.reference),
    order_data: {
      procedure: {
        text: s.code?.text,
        codes: (s.code?.coding ?? []).map(toDspCode),
      },
      surgical_team:      s.performer?.map(p => p.display ?? p.reference),
      procedure_location: s.locationReference?.[0]?.display ?? s.locationReference?.[0]?.reference,
      devices:            (s.devices?.[0]?.device ?? []).map(d => d.valueString),
      instructions:       s.patientInstruction ?? s.note?.map(n => n.text).join('\n'),
    },
    confidence_score: s.confidence?.[0]?.valueDecimal,
    provenance:       turnRefs.map(t => t.turn?.valueInteger),
    transcript_ref:   turnRefs[0]?.transcript?.valueReference?.reference,
  };
}
No data loss. Every DSP-originated field has a declared FHIR landing — native or dsp-* extension.

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_procedure — DSP Procedure order (ServiceRequest)

Flattens DSP dsp procedure order (servicerequest) orders. Filtered by category=procedure.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-service-request-procedure",
  "name": "dsp_service_request_procedure",
  "title": "DSP Procedure order (ServiceRequest)",
  "status": "draft",
  "description": "Flattens DSP dsp procedure order (servicerequest) orders. Filtered by category=procedure.",
  "resource": "ServiceRequest",
  "fhirVersion": [
    "4.0.1"
  ],
  "where": [
    {
      "path": "category.coding.where(code='procedure').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": "occurrence_datetime",
          "path": "occurrence.ofType(dateTime)",
          "type": "dateTime"
        },
        {
          "name": "occurrence_period_start",
          "path": "occurrence.ofType(Period).start",
          "type": "dateTime"
        },
        {
          "name": "performer_type_code",
          "path": "performerType.coding.code.first()",
          "type": "code"
        }
      ]
    }
  ]
}