DSP ↔ FHIR resource mapping

Every DSP concept, its FHIR home (R4 unless noted), and the delta that requires an extension or a cross-version borrow.

Envelope

DSPFHIRNotes
payload_versionBundle.meta.tag + DSP extension4-part version (major/minor/revision/quality) encoded as structured extension.
priorityEncounter.priority (R4 native) for encounter-scope; DSP extension on Bundle if truly envelope-scopeBound to request-priority (routine/urgent/asap/stat).
external_callback_urlExtension dsp-external-callback-urlCarried on Encounter; consumed by Dragon's SubscriptionTopic.

Identifier systems used on the envelope (payload GUID, session, passthrough source-refs) are catalogued on Interop & layering → Identifiers.

DSP

{
  "payload_version": {
    "major": 1, "minor": 0, "revision": 0, "quality": "release"
  },
  "priority": "urgent",
  "external_callback_url": "https://ehr.example.org/dsp/callback/abc-123",
  "encounter": { "...": "..." }
}

FHIR

{
  "resourceType": "Bundle",
  "type": "document",
  "meta": {
    "tag": [
      { "system": "https://dsp-fhir.org/CodeSystem/payload-version",
        "code": "1.0.0" }
    ],
    "extension": [{
      "url": "https://dsp-fhir.org/StructureDefinition/payload-version",
      "extension": [
        { "url": "major",    "valueInteger": 1 },
        { "url": "minor",    "valueInteger": 0 },
        { "url": "revision", "valueInteger": 0 },
        { "url": "quality",  "valueCode":    "release" }
      ]
    }]
  },
  "entry": [{
    "resource": {
      "resourceType": "Encounter",
      "priority": {
        "coding": [{
          "system": "http://terminology.hl7.org/CodeSystem/v3-ActPriority",
          "code": "UR", "display": "urgent"
        }]
      },
      "extension": [{
        "url": "https://dsp-fhir.org/StructureDefinition/dsp-external-callback-url",
        "valueUrl": "https://ehr.example.org/dsp/callback/abc-123"
      }]
    }
  }]
}
map "https://dsp-fhir.org/StructureMap/DspEnvelopeToBundle" = "DspEnvelopeToBundle"

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

group Envelope(source src : DspPayload, target bnd : Bundle) {
  src.payload_version as pv -> bnd.meta as m then {
    pv -> m.tag as t then {
      pv -> t.system = 'https://dsp-fhir.org/CodeSystem/payload-version',
            t.code = (pv.major + '.' + pv.minor + '.' + pv.revision);
    };
    pv -> m.extension as ext then {
      pv -> ext.url = 'https://dsp-fhir.org/StructureDefinition/payload-version';
      pv.major    as v -> ext.extension as e then { v -> e.url = 'major',    e.value = v; };
      pv.minor    as v -> ext.extension as e then { v -> e.url = 'minor',    e.value = v; };
      pv.revision as v -> ext.extension as e then { v -> e.url = 'revision', e.value = v; };
      pv.quality  as v -> ext.extension as e then { v -> e.url = 'quality',  e.value = v; };
    };
  };
  src.priority as p -> bnd.entry.resource.priority "priority-on-encounter";
  src.external_callback_url as u -> bnd.entry.resource.extension as ext then {
    u -> ext.url = 'https://dsp-fhir.org/StructureDefinition/dsp-external-callback-url',
         ext.value = u;
  };
}
# Reconstruct the DSP envelope (payload_version, priority, callback_url)
# from the Bundle root + the Encounter that anchors the document.
query DspEnvelope($bundleId: ID!) {
  Bundle(id: $bundleId) {
    id
    meta {
      payloadVersion: extension(url: "https://dsp-fhir.org/StructureDefinition/payload-version") {
        major:    extension(url: "major")    { valueInteger }
        minor:    extension(url: "minor")    { valueInteger }
        revision: extension(url: "revision") { valueInteger }
        quality:  extension(url: "quality")  { valueCode }
      }
    }
    entry {
      resource {
        ... on Encounter {
          id
          priority { coding { system code display } }
          callbackUrl: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-external-callback-url") {
            valueUrl
          }
        }
      }
    }
  }
}

// Adapter (envelope is a header object, not a list)
function toDspEnvelope(b) {
  const enc = b.entry.map(e => e.resource).find(r => r.priority || r.callbackUrl);
  const pv  = b.meta?.payloadVersion?.[0];
  return {
    payload_version: pv && {
      major:    pv.major?.[0]?.valueInteger,
      minor:    pv.minor?.[0]?.valueInteger,
      revision: pv.revision?.[0]?.valueInteger,
      quality:  pv.quality?.[0]?.valueCode,
    },
    priority:               enc?.priority?.coding?.[0]?.code,
    external_callback_url:  enc?.callbackUrl?.[0]?.valueUrl,
  };
}

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_bundle — DSP Bundle envelope

Flattens DSP-FHIR Bundle-level tags and extensions carrying payload version + priority + callback url.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-bundle",
  "name": "dsp_bundle",
  "title": "DSP Bundle envelope",
  "status": "draft",
  "description": "Flattens DSP-FHIR Bundle-level tags and extensions carrying payload version + priority + callback url.",
  "resource": "Bundle",
  "fhirVersion": [
    "4.0.1"
  ],
  "select": [
    {
      "column": [
        {
          "name": "id",
          "path": "id",
          "type": "id"
        },
        {
          "name": "type",
          "path": "type",
          "type": "code"
        },
        {
          "name": "timestamp",
          "path": "timestamp",
          "type": "instant"
        },
        {
          "name": "payload_version",
          "path": "meta.tag.where(system='https://dsp-fhir.org/CodeSystem/payload-version').code.first()",
          "type": "code"
        },
        {
          "name": "payload_version_major",
          "path": "meta.extension('https://dsp-fhir.org/StructureDefinition/payload-version').extension('major').value.ofType(integer)",
          "type": "integer"
        },
        {
          "name": "payload_version_minor",
          "path": "meta.extension('https://dsp-fhir.org/StructureDefinition/payload-version').extension('minor').value.ofType(integer)",
          "type": "integer"
        },
        {
          "name": "payload_version_revision",
          "path": "meta.extension('https://dsp-fhir.org/StructureDefinition/payload-version').extension('revision').value.ofType(integer)",
          "type": "integer"
        },
        {
          "name": "payload_version_quality",
          "path": "meta.extension('https://dsp-fhir.org/StructureDefinition/payload-version').extension('quality').value.ofType(code)",
          "type": "code"
        },
        {
          "name": "priority",
          "path": "entry.resource.ofType(Encounter).priority.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-ActPriority').code.first()",
          "type": "code"
        },
        {
          "name": "external_callback_url",
          "path": "entry.resource.ofType(Encounter).extension('https://dsp-fhir.org/StructureDefinition/dsp-external-callback-url').value.ofType(url)",
          "type": "url"
        },
        {
          "name": "entry_count",
          "path": "entry.count()",
          "type": "integer"
        }
      ]
    }
  ]
}

Encounter block

DSPFHIRNotes
encounter.date_of_encounterEncounter.periodISO 8601.
encounter.statusEncounter.statusMap planned/in_progress/complete/cancelled to R4 codes.
encounter.external_encounter_idsEncounter.identifiertype → Identifier.type.
encounter.correlation_idEncounter.identifier (system=DAX)
patient.medical_record_numberPatient.identifier (type=MR)
patient.name/gender/birthdate/agePatientage is derived in FHIR; carry via extension if preserving source-reported.
patient.gender_identity / pronoun_preferenceUS Core extensions (genderIdentity, pronouns)
practitioner.npiPractitioner.identifier (system=http://hl7.org/fhir/sid/us-npi)
practitioner.qualifications/specialties/rolesPractitioner.qualification + PractitionerRole
visit.visit_typeEncounter.class + type
visit.admission_date/discharge_dateEncounter.period.start/end
visit.reasonEncounter.reasonCode / reasonReference
visit.locationEncounter.locationLocation
visit.accompanied_byEncounter.participant with role=accompanyingOr RelatedPerson.
organization_id (on encounter)Extension dsp-tenant-organization on EncounterThis is the Nuance/MSFT tenant org UUID, not a clinical organization. Distinct from Encounter.serviceProvider.
Clinical organization (if distinct)Encounter.serviceProviderOrganizationPopulate when DSP provides the delivering facility/practice.
recording_locales / timezoneExtensions on EncounterLocale maps to Composition.language for the document.

DSP

{
  "encounter": {
    "date_of_encounter": "2026-04-23T14:00:00Z",
    "status": "in_progress",
    "correlation_id": "dax-7c21-...",
    "external_encounter_ids": [
      { "system": "urn:ehr:visit", "value": "V-9981", "type": "VN" }
    ]
  },
  "patient": {
    "medical_record_number": "MRN-67890",
    "name": "Alice Example",
    "gender": "female",
    "birthdate": "1972-03-11",
    "pronoun_preference": "she/her"
  },
  "practitioner": {
    "npi": "1234567893",
    "name": "Dr. Bob Example",
    "specialties": ["internal medicine"]
  },
  "visit": {
    "visit_type": "ambulatory",
    "admission_date": "2026-04-23T14:00:00Z",
    "accompanied_by": "Jane Doe, spouse"
  },
  "organization_id": "tenant-uuid-acme",
  "recording_locales": ["en-US"],
  "timezone": "America/Los_Angeles"
}

FHIR

{
  "resourceType": "Encounter",
  "id": "enc-12345",
  "status": "in-progress",
  "class": {
    "system": "http://terminology.hl7.org/CodeSystem/v3-ActCode",
    "code": "AMB", "display": "ambulatory"
  },
  "identifier": [
    { "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0203", "code": "VN" }] },
      "system": "urn:ehr:visit", "value": "V-9981" },
    { "system": "https://dsp-fhir.org/correlation-id", "value": "dax-7c21-..." }
  ],
  "subject": { "reference": "Patient/pat-67890" },
  "participant": [
    { "individual": { "reference": "Practitioner/pract-001" } },
    { "type": [{ "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v3-ParticipationType", "code": "ESC" }] }],
      "individual": { "display": "Jane Doe, spouse" } }
  ],
  "period": { "start": "2026-04-23T14:00:00Z" },
  "serviceProvider": { "reference": "Organization/facility-01" },
  "extension": [
    { "url": "https://dsp-fhir.org/StructureDefinition/dsp-tenant-organization",
      "valueReference": { "reference": "Organization/tenant-uuid-acme" } },
    { "url": "https://dsp-fhir.org/StructureDefinition/recording-locale",
      "valueCode": "en-US" },
    { "url": "https://dsp-fhir.org/StructureDefinition/dsp-timezone",
      "valueString": "America/Los_Angeles" }
  ]
}

// Patient
{
  "resourceType": "Patient", "id": "pat-67890",
  "identifier": [{
    "type": { "coding": [{ "system": "http://terminology.hl7.org/CodeSystem/v2-0203", "code": "MR" }]},
    "value": "MRN-67890"
  }],
  "name": [{ "text": "Alice Example" }],
  "gender": "female", "birthDate": "1972-03-11",
  "extension": [{
    "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-pronouns",
    "valueCodeableConcept": {
      "coding": [{ "system": "http://loinc.org", "code": "LA29519-8", "display": "she/her" }]
    }
  }]
}
map "https://dsp-fhir.org/StructureMap/DspEncounterToFhir" = "DspEncounterToFhir"

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

group EncounterBlock(source src : DspEncounter, target enc : Encounter) {
  src.encounter.date_of_encounter as d -> enc.period.start = d;
  src.encounter.status            as s -> enc.status       = translate(s, 'dsp-status-to-fhir', 'code');
  src.encounter.correlation_id    as c -> enc.identifier as id then {
    c -> id.system = 'https://dsp-fhir.org/correlation-id', id.value = c;
  };
  src.encounter.external_encounter_ids as xid -> enc.identifier as id then {
    xid.system as sys -> id.system = sys;
    xid.value  as v   -> id.value  = v;
    xid.type   as t   -> id.type.coding as coding then {
      t -> coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203', coding.code = t;
    };
  };
  src.visit.visit_type as vt -> enc.class as cls then {
    vt -> cls.system = 'http://terminology.hl7.org/CodeSystem/v3-ActCode',
          cls.code = translate(vt, 'dsp-visit-type-to-v3', 'code');
  };
  src.visit.admission_date as a -> enc.period.start = a;
  src.visit.discharge_date as d -> enc.period.end   = d;
  src.visit.accompanied_by as ab -> enc.participant as p then {
    ab -> p.type.coding.system = 'http://terminology.hl7.org/CodeSystem/v3-ParticipationType',
          p.type.coding.code = 'ESC',
          p.individual.display = ab;
  };
  src.organization_id as oid -> enc.extension as ext then {
    oid -> ext.url = 'https://dsp-fhir.org/StructureDefinition/dsp-tenant-organization',
           ext.value = create('Reference') as r, r.reference = ('Organization/' + oid);
  };
}

group PatientBlock(source src : DspPatient, target pat : Patient) {
  src.medical_record_number as mrn -> pat.identifier as id then {
    mrn -> id.type.coding.system = 'http://terminology.hl7.org/CodeSystem/v2-0203',
           id.type.coding.code = 'MR',
           id.value = mrn;
  };
  src.name              as n  -> pat.name.text = n;
  src.gender            as g  -> pat.gender    = g;
  src.birthdate         as b  -> pat.birthDate = b;
  src.pronoun_preference as p -> pat.extension as ext then {
    p -> ext.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-pronouns',
         ext.value.coding.system = 'http://loinc.org',
         ext.value.coding.display = p;
  };
}
# Reconstruct the DSP encounter block from Encounter + Patient + Practitioner.
query DspEncounterBlock($encId: ID!) {
  Encounter(id: $encId) {
    id status
    period { start end }
    class { system code display }
    identifier {
      system value
      type { coding { system code display } }
    }
    participant {
      type { coding { system code display } }
      individual { reference display }
    }

    tenantOrg: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-tenant-organization") {
      valueReference { reference }
    }
    locale: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-recording-locale") { valueCode }
    timezone: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-timezone") { valueString }

    subject { resource { ... on Patient {
      id gender birthDate
      identifier {
        system value
        type { coding { system code display } }
      }
      name { text family given }
      pronouns: extension(url: "http://hl7.org/fhir/us/core/StructureDefinition/us-core-pronouns") {
        valueCodeableConcept { coding { system code display } }
      }
    }}}
  }
}

// Adapter
function toDspEncounterBlock(enc) {
  const pat = enc.subject?.resource;
  const mrn = pat?.identifier?.find(i => i.type?.coding?.[0]?.code === 'MR')?.value;
  return {
    encounter: {
      date_of_encounter: enc.period?.start,
      status: enc.status,
      correlation_id: enc.identifier?.find(i => i.system === 'https://dsp-fhir.org/correlation-id')?.value,
      external_encounter_ids: enc.identifier
        ?.filter(i => i.system && i.system !== 'https://dsp-fhir.org/correlation-id')
        ?.map(i => ({ system: i.system, value: i.value, type: i.type?.coding?.[0]?.code })),
    },
    patient: {
      medical_record_number: mrn,
      name:      pat?.name?.[0]?.text,
      gender:    pat?.gender,
      birthdate: pat?.birthDate,
      pronoun_preference: pat?.pronouns?.[0]?.valueCodeableConcept?.coding?.[0]?.display,
    },
    visit: {
      visit_type:      enc.class?.code,
      admission_date:  enc.period?.start,
      discharge_date:  enc.period?.end,
      accompanied_by:  enc.participant?.find(p => p.type?.coding?.[0]?.code === 'ESC')?.individual?.display,
    },
    organization_id:    enc.tenantOrg?.[0]?.valueReference?.reference?.replace('Organization/', ''),
    recording_locales:  enc.locale ? [enc.locale[0]?.valueCode] : undefined,
    timezone:           enc.timezone?.[0]?.valueString,
  };
}

SQL-on-FHIR v2 ViewDefinitions that flatten 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_encounter — DSP Encounter

Flattens the DSP encounter: class, type, period, tenant org, serviceProvider, accompanied-by, locale, timezone.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-encounter",
  "name": "dsp_encounter",
  "title": "DSP Encounter",
  "status": "draft",
  "description": "Flattens the DSP encounter: class, type, period, tenant org, serviceProvider, accompanied-by, locale, timezone.",
  "resource": "Encounter",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "class_code",
          "path": "class.code",
          "type": "code"
        },
        {
          "name": "class_system",
          "path": "class.system",
          "type": "uri"
        },
        {
          "name": "type_text",
          "path": "type.text.first()",
          "type": "string"
        },
        {
          "name": "priority_code",
          "path": "priority.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-ActPriority').code.first()",
          "type": "code"
        },
        {
          "name": "subject_patient_id",
          "path": "subject.reference.substring(8)",
          "type": "string",
          "description": "Strip 'Patient/' prefix."
        },
        {
          "name": "period_start",
          "path": "period.start",
          "type": "dateTime"
        },
        {
          "name": "period_end",
          "path": "period.end",
          "type": "dateTime"
        },
        {
          "name": "reason_text",
          "path": "reasonCode.text.first()",
          "type": "string"
        },
        {
          "name": "service_provider_org_id",
          "path": "serviceProvider.reference.substring(13)",
          "type": "string",
          "description": "Strip 'Organization/' prefix."
        },
        {
          "name": "tenant_organization_id",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/dsp-tenant-organization').value.ofType(Reference).reference.substring(13)",
          "type": "string"
        },
        {
          "name": "external_encounter_id",
          "path": "identifier.where(type.coding.where(code='VN').exists()).value.first()",
          "type": "string"
        },
        {
          "name": "correlation_id",
          "path": "identifier.where(system='https://dsp-fhir.org/correlation-id').value.first()",
          "type": "string"
        },
        {
          "name": "external_callback_url",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/dsp-external-callback-url').value.ofType(url)",
          "type": "url"
        },
        {
          "name": "recording_locale",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/recording-locale').value.ofType(code)",
          "type": "code"
        },
        {
          "name": "timezone",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/dsp-timezone').value.ofType(string)",
          "type": "string"
        },
        {
          "name": "accompanied_by_display",
          "path": "participant.where(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v3-ParticipationType' and code='ESC').exists()).individual.display.first()",
          "type": "string"
        },
        {
          "name": "accompanied_by_related_person_id",
          "path": "participant.where(type.coding.where(code='ESC').exists()).individual.reference.where($this.startsWith('RelatedPerson/')).substring(14).first()",
          "type": "string"
        }
      ]
    }
  ]
}

dsp_patient — DSP Patient

Flattens DSP patient block including MRN, gender identity, pronouns.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-patient",
  "name": "dsp_patient",
  "title": "DSP Patient",
  "status": "draft",
  "description": "Flattens DSP patient block including MRN, gender identity, pronouns.",
  "resource": "Patient",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "mrn",
          "path": "identifier.where(type.coding.where(system='http://terminology.hl7.org/CodeSystem/v2-0203' and code='MR').exists()).value.first()",
          "type": "string"
        },
        {
          "name": "name_text",
          "path": "name.text.first()",
          "type": "string"
        },
        {
          "name": "family",
          "path": "name.family.first()",
          "type": "string"
        },
        {
          "name": "given",
          "path": "name.given.first()",
          "type": "string"
        },
        {
          "name": "gender",
          "path": "gender",
          "type": "code"
        },
        {
          "name": "birth_date",
          "path": "birthDate",
          "type": "date"
        },
        {
          "name": "age_years",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/source-reported-age').value.ofType(Age).value",
          "type": "decimal"
        },
        {
          "name": "pronouns",
          "path": "extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-pronouns').value.ofType(CodeableConcept).coding.display.first()",
          "type": "string"
        },
        {
          "name": "gender_identity",
          "path": "extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-genderIdentity').value.ofType(CodeableConcept).coding.display.first()",
          "type": "string"
        },
        {
          "name": "deceased",
          "path": "deceased.ofType(boolean)",
          "type": "boolean"
        }
      ]
    }
  ]
}

dsp_practitioner — DSP Practitioner

Flattens DSP practitioner block: NPI, qualifications, specialties (roles live on PractitionerRole).

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-practitioner",
  "name": "dsp_practitioner",
  "title": "DSP Practitioner",
  "status": "draft",
  "description": "Flattens DSP practitioner block: NPI, qualifications, specialties (roles live on PractitionerRole).",
  "resource": "Practitioner",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "npi",
          "path": "identifier.where(system='http://hl7.org/fhir/sid/us-npi').value.first()",
          "type": "string"
        },
        {
          "name": "name_text",
          "path": "name.text.first()",
          "type": "string"
        },
        {
          "name": "family",
          "path": "name.family.first()",
          "type": "string"
        },
        {
          "name": "given",
          "path": "name.given.first()",
          "type": "string"
        },
        {
          "name": "qualifications",
          "path": "qualification.code.text",
          "type": "string",
          "collection": true
        },
        {
          "name": "qualification_codes",
          "path": "qualification.code.coding.code",
          "type": "code",
          "collection": true
        }
      ]
    }
  ]
}

dsp_organization — DSP Organization

Flattens DSP Organization (both clinical serviceProvider and DSP tenant-org).

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-organization",
  "name": "dsp_organization",
  "title": "DSP Organization",
  "status": "draft",
  "description": "Flattens DSP Organization (both clinical serviceProvider and DSP tenant-org).",
  "resource": "Organization",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "name",
          "path": "name",
          "type": "string"
        },
        {
          "name": "type_code",
          "path": "type.coding.code.first()",
          "type": "code"
        },
        {
          "name": "type_system",
          "path": "type.coding.system.first()",
          "type": "uri"
        },
        {
          "name": "tenant_uuid",
          "path": "identifier.where(system='https://dsp-fhir.org/CodeSystem/tenant-id').value.first()",
          "type": "string"
        }
      ]
    }
  ]
}

Recordings, sessions, transcript

DSPFHIRNotes
recordings[]Media + DocumentReferenceMedia.createdPeriod, Media.content.url.
sessions[]Provenance with agent (user, org) and activity=DAX
transcript.turns[]DocumentReference JSON attachment (structured)Integer turn indices preserved; see Gaps.
transcript.speaker_countExtension on DocumentReference

📎 Recording payload portability. DSP-FHIR references audio via Media.content.url, typically a blob URL handed to the downstream store. A downstream server MAY re-host the payload as a Binary resource referenced by the same Media — both patterns are conformant. See Interop & layering → Media/Binary.

DSP

{
  "recordings": [
    { "id": "rec-01",
      "start_time": "2026-04-23T14:00:00Z",
      "end_time":   "2026-04-23T14:18:30Z",
      "media_url":  "https://dax.example.org/audio/rec-01.m4a",
      "content_type": "audio/m4a" }
  ],
  "sessions": [
    { "id": "sess-01",
      "start_time": "2026-04-23T14:00:00Z",
      "agent": { "user_id": "pract-001", "org_id": "tenant-uuid-acme" } }
  ],
  "transcript": {
    "speaker_count": 2,
    "turns": [
      { "index": 0, "speaker": "provider", "start_time": "00:00:00.0",
        "end_time": "00:00:04.2", "content": "What brings you in today?" }
    ]
  }
}

FHIR

// Media (audio recording)
{
  "resourceType": "Media", "id": "media-rec-01",
  "status": "completed",
  "type": { "coding": [{ "system":"http://terminology.hl7.org/CodeSystem/media-type",
                         "code":"audio" }]},
  "subject":  { "reference": "Patient/pat-67890" },
  "encounter": { "reference": "Encounter/enc-12345" },
  "createdPeriod": { "start":"2026-04-23T14:00:00Z", "end":"2026-04-23T14:18:30Z" },
  "content": { "contentType":"audio/m4a",
               "url":"https://dax.example.org/audio/rec-01.m4a" }
}

// Provenance (capture session)
{
  "resourceType": "Provenance", "id": "prov-sess-01",
  "target": [{ "reference":"Encounter/enc-12345" }],
  "recorded": "2026-04-23T14:00:00Z",
  "activity": {
    "coding": [{ "system":"https://dsp-fhir.org/CodeSystem/activity",
                 "code":"DAX_CAPTURE" }]
  },
  "agent": [
    { "who": { "reference":"Practitioner/pract-001" } },
    { "who": { "reference":"Organization/tenant-uuid-acme" },
      "type": { "coding":[{ "system":"http://terminology.hl7.org/CodeSystem/provenance-participant-type",
                            "code":"custodian" }]} }
  ]
}

// DocumentReference (transcript payload)
{
  "resourceType": "DocumentReference", "id": "dr-transcript-001",
  "status": "current", "docStatus": "preliminary",
  "type": { "coding": [{ "system":"http://loinc.org",
                         "code":"11488-4","display":"Consultation note" }]},
  "subject":  { "reference":"Patient/pat-67890" },
  "context":  { "encounter": [{ "reference":"Encounter/enc-12345" }] },
  "content": [{
    "attachment": {
      "contentType":"application/json",
      "url":"https://dax.example.org/transcripts/dr-transcript-001.json"
    }
  }],
  "extension": [{
    "url":"https://dsp-fhir.org/StructureDefinition/transcript-speaker-count",
    "valueInteger": 2
  }]
}
map "https://dsp-fhir.org/StructureMap/DspRecordingsToFhir" = "DspRecordingsToFhir"

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

group Recording(source rec : DspRecording, target m : Media) {
  rec.id           as i -> m.id = i;
  rec.start_time   as s -> m.createdPeriod.start = s;
  rec.end_time     as e -> m.createdPeriod.end   = e;
  rec.media_url    as u -> m.content.url         = u;
  rec.content_type as c -> m.content.contentType = c;
  rec -> m.status = 'completed';
}

group Session(source sess : DspSession, target p : Provenance) {
  sess.id         as i  -> p.id        = i;
  sess.start_time as s  -> p.recorded  = s;
  sess -> p.activity.coding as c then {
    sess -> c.system = 'https://dsp-fhir.org/CodeSystem/activity',
            c.code   = 'DAX_CAPTURE';
  };
  sess.agent.user_id as u -> p.agent as a then {
    u -> a.who = create('Reference') as r, r.reference = ('Practitioner/' + u);
  };
  sess.agent.org_id as o -> p.agent as a then {
    o -> a.who = create('Reference') as r, r.reference = ('Organization/' + o),
         a.type.coding.system = 'http://terminology.hl7.org/CodeSystem/provenance-participant-type',
         a.type.coding.code = 'custodian';
  };
}

group Transcript(source t : DspTranscript, target dr : DocumentReference) {
  t -> dr.status    = 'current',
       dr.docStatus = 'preliminary',
       dr.content.attachment.contentType = 'application/json';
  t.speaker_count as sc -> dr.extension as ext then {
    sc -> ext.url = 'https://dsp-fhir.org/StructureDefinition/transcript-speaker-count',
          ext.value = sc;
  };
}
# Reconstruct DSP recordings, sessions, and transcript metadata from
# Media, Provenance, and DocumentReference for one encounter.
query DspRecordingsAndTranscript($encId: ID!) {
  recordings: MediaList(encounter: $encId) {
    id status
    type { coding { system code display } }
    createdPeriod { start end }
    content { contentType url }
    source: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-recording-source") {
      valueCode
    }
  }

  sessions: ProvenanceList(target: $encId) {
    id recorded
    activity { coding { system code display } }
    agent {
      type { coding { system code display } }
      who { reference }
    }
  }

  transcripts: DocumentReferenceList(encounter: $encId, category: "https://dsp-fhir.org/CodeSystem/doc-category|transcript") {
    id status
    type { coding { system code display } }
    content { attachment { url contentType language } }
    context { period { start end } }
    speakerCount: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-speaker-count") {
      valuePositiveInt
    }
  }
}

// Adapters
function toDspRecording(m) {
  return {
    id: m.id,
    start_time: m.createdPeriod?.start,
    end_time:   m.createdPeriod?.end,
    media_url:  m.content?.url,
    content_type: m.content?.contentType,
    source: m.source?.[0]?.valueCode,
  };
}

function toDspSession(p) {
  const practitioner = p.agent?.find(a => a.who?.reference?.startsWith('Practitioner/'));
  const org          = p.agent?.find(a => a.who?.reference?.startsWith('Organization/'));
  return {
    id: p.id,
    start_time: p.recorded,
    agent: {
      user_id: practitioner?.who?.reference?.replace('Practitioner/', ''),
      org_id:  org?.who?.reference?.replace('Organization/', ''),
    },
  };
}

function toDspTranscript(refs) {
  const dr = refs?.[0];
  return dr && {
    transcript_ref: dr.id,
    transcript_url: dr.content?.[0]?.attachment?.url,
    speaker_count:  dr.speakerCount?.[0]?.valuePositiveInt,
  };
}

SQL-on-FHIR v2 ViewDefinitions that flatten 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_media — DSP recording Media

Flattens DSP recording metadata: url, content-type, period, subject, encounter.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-media",
  "name": "dsp_media",
  "title": "DSP recording Media",
  "status": "draft",
  "description": "Flattens DSP recording metadata: url, content-type, period, subject, encounter.",
  "resource": "Media",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "type_code",
          "path": "type.coding.code.first()",
          "type": "code"
        },
        {
          "name": "subject_patient_id",
          "path": "subject.reference.substring(8)",
          "type": "string"
        },
        {
          "name": "encounter_id",
          "path": "encounter.reference.substring(10)",
          "type": "string"
        },
        {
          "name": "period_start",
          "path": "createdPeriod.start",
          "type": "dateTime"
        },
        {
          "name": "period_end",
          "path": "createdPeriod.end",
          "type": "dateTime"
        },
        {
          "name": "content_type",
          "path": "content.contentType",
          "type": "code"
        },
        {
          "name": "content_url",
          "path": "content.url",
          "type": "url"
        },
        {
          "name": "content_size",
          "path": "content.size",
          "type": "unsignedInt"
        }
      ]
    }
  ]
}

dsp_provenance_session — DSP capture-session Provenance

Flattens DSP session metadata (DAX_CAPTURE activity).

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-provenance-session",
  "name": "dsp_provenance_session",
  "title": "DSP capture-session Provenance",
  "status": "draft",
  "description": "Flattens DSP session metadata (DAX_CAPTURE activity).",
  "resource": "Provenance",
  "fhirVersion": [
    "4.0.1"
  ],
  "where": [
    {
      "path": "activity.coding.where(system='https://dsp-fhir.org/CodeSystem/activity').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": "recorded",
          "path": "recorded",
          "type": "instant"
        },
        {
          "name": "activity_code",
          "path": "activity.coding.where(system='https://dsp-fhir.org/CodeSystem/activity').code.first()",
          "type": "code"
        },
        {
          "name": "target_ref",
          "path": "target.reference.first()",
          "type": "string"
        },
        {
          "name": "encounter_id",
          "path": "target.where(reference.startsWith('Encounter/')).reference.substring(10).first()",
          "type": "string"
        },
        {
          "name": "author_practitioner_id",
          "path": "agent.where(who.reference.startsWith('Practitioner/')).who.reference.substring(13).first()",
          "type": "string"
        },
        {
          "name": "custodian_org_id",
          "path": "agent.where(type.coding.code='custodian').who.reference.substring(13).first()",
          "type": "string"
        }
      ]
    }
  ]
}

dsp_document_reference_transcript — DSP transcript DocumentReference

Flattens the DocumentReference whose attachment carries DSP transcript turns.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-document-reference-transcript",
  "name": "dsp_document_reference_transcript",
  "title": "DSP transcript DocumentReference",
  "status": "draft",
  "description": "Flattens the DocumentReference whose attachment carries DSP transcript turns.",
  "resource": "DocumentReference",
  "fhirVersion": [
    "4.0.1"
  ],
  "where": [
    {
      "path": "type.coding.where(system='http://loinc.org' and (code='11488-4' or code='11506-3')).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": "doc_status",
          "path": "docStatus",
          "type": "code"
        },
        {
          "name": "type_code",
          "path": "type.coding.code.first()",
          "type": "code"
        },
        {
          "name": "subject_patient_id",
          "path": "subject.reference.substring(8)",
          "type": "string"
        },
        {
          "name": "encounter_id",
          "path": "context.encounter.reference.substring(10).first()",
          "type": "string"
        },
        {
          "name": "attachment_content_type",
          "path": "content.attachment.contentType.first()",
          "type": "code"
        },
        {
          "name": "attachment_url",
          "path": "content.attachment.url.first()",
          "type": "url"
        },
        {
          "name": "speaker_count",
          "path": "extension('https://dsp-fhir.org/StructureDefinition/transcript-speaker-count').value.ofType(integer)",
          "type": "integer"
        }
      ]
    }
  ]
}

Document

DSPFHIRNotes
document (unstructured)DocumentReference with attachment
document (structured)Composition with sectionsEach document_section resource becomes a Composition.section.
document_statusComposition.status / DocumentReference.status + docStatusMap final_signedfinal+docStatus=final.
document_typeComposition.type (LOINC)
report_localeComposition.language

DSP

{
  "document_type": "progress_note",
  "document_status": "final_signed",
  "report_locale": "en-US",
  "sections": [
    { "section_type": "hpi",     "text": "..." },
    { "section_type": "overview","text": "..." },
    { "section_type": "a_and_p", "text": "..." }
  ]
}

FHIR

{
  "resourceType": "Composition", "id": "comp-001",
  "status": "final",
  "type": {
    "coding": [{ "system":"http://loinc.org","code":"11506-3",
                 "display":"Progress note" }]
  },
  "subject":   { "reference":"Patient/pat-67890" },
  "encounter": { "reference":"Encounter/enc-12345" },
  "date":      "2026-04-23T14:30:00Z",
  "author":    [{ "reference":"Practitioner/pract-001" }],
  "title":     "Progress note",
  "language":  "en-US",
  "section": [
    { "title":"History of present illness",
      "code": { "coding":[{"system":"http://loinc.org","code":"10164-2"}]},
      "text": { "status":"generated","div":"<div xmlns=\"http://www.w3.org/1999/xhtml\">…</div>" } },
    { "title":"Overview",
      "code": { "coding":[{"system":"http://loinc.org","code":"51848-0"}]} },
    { "title":"Assessment and plan",
      "code": { "coding":[{"system":"http://loinc.org","code":"51847-2"}]} }
  ]
}

// Optional companion DocumentReference wrapping the bundle:
{
  "resourceType":"DocumentReference","id":"dr-note-001",
  "status":"current","docStatus":"final",
  "type": { "coding":[{"system":"http://loinc.org","code":"11506-3"}]},
  "subject": { "reference":"Patient/pat-67890" },
  "context": { "encounter":[{"reference":"Encounter/enc-12345"}] }
}
map "https://dsp-fhir.org/StructureMap/DspDocumentToComposition" = "DspDocumentToComposition"

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

group DocumentToComposition(source src : DspDocument, target cmp : Composition) {
  src.document_type as t -> cmp.type.coding as c then {
    t -> c.system = 'http://loinc.org',
         c.code   = translate(t, 'dsp-document-type-to-loinc', 'code');
  };
  src.document_status as s -> cmp.status = translate(s, 'dsp-doc-status-to-fhir', 'code');
  src.report_locale   as l -> cmp.language = l;

  src.sections as section -> cmp.section as sec then SectionToFhirSection(section, sec);
}

group SectionToFhirSection(source ds : DspSection, target sec : Composition.Section) {
  ds.section_type as st -> sec.code.coding as cc then {
    st -> cc.system = 'http://loinc.org',
          cc.code   = translate(st, 'dsp-section-type-to-loinc', 'code');
  };
  ds.text as txt -> sec.text as narr then {
    txt -> narr.status = 'generated',
           narr.div    = ('<div xmlns="http://www.w3.org/1999/xhtml">' + txt + '</div>');
  };
}
# Reconstruct DSP document metadata + sections from the Composition.
# Per-section reconstruction reuses toDspDocumentSection() from /mapping/document-section.
query DspDocument($id: ID!) {
  Composition(id: $id) {
    id status language
    type { coding { system code display } }
    title
    section {
      title
      code { coding { system code display } }
      text { status div }
      entry { reference }
      narrativeSource: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-narrative-source") {
        valueString
      }
    }
  }
}

// Adapter
function toDspDocument(c) {
  return {
    document_type:   c.type?.coding?.find(x => x.system === 'http://loinc.org')?.code,
    document_status: c.status,
    report_locale:   c.language,
    sections: c.section?.map(toDspDocumentSection) ?? [],
  };
}

SQL-on-FHIR v2 ViewDefinitions that flatten 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_composition — DSP Composition

Flattens the clinical note Composition (type/status/title/author).

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-composition",
  "name": "dsp_composition",
  "title": "DSP Composition",
  "status": "draft",
  "description": "Flattens the clinical note Composition (type/status/title/author).",
  "resource": "Composition",
  "fhirVersion": [
    "4.0.1"
  ],
  "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": "type_code",
          "path": "type.coding.code.first()",
          "type": "code"
        },
        {
          "name": "type_display",
          "path": "type.coding.display.first()",
          "type": "string"
        },
        {
          "name": "subject_patient_id",
          "path": "subject.reference.substring(8)",
          "type": "string"
        },
        {
          "name": "encounter_id",
          "path": "encounter.reference.substring(10)",
          "type": "string"
        },
        {
          "name": "date",
          "path": "date",
          "type": "dateTime"
        },
        {
          "name": "author_practitioner_id",
          "path": "author.where(reference.startsWith('Practitioner/')).reference.substring(13).first()",
          "type": "string"
        },
        {
          "name": "title",
          "path": "title",
          "type": "string"
        },
        {
          "name": "language",
          "path": "language",
          "type": "code"
        },
        {
          "name": "section_count",
          "path": "section.count()",
          "type": "integer"
        }
      ]
    }
  ]
}

dsp_composition_section — DSP Composition section (unnested)

One row per Composition.section — unnests section array for warehouse-friendly section analytics.

{
  "resourceType": "ViewDefinition",
  "url": "https://dsp-fhir.org/ViewDefinition/dsp-composition-section",
  "name": "dsp_composition_section",
  "title": "DSP Composition section (unnested)",
  "status": "draft",
  "description": "One row per Composition.section — unnests section array for warehouse-friendly section analytics.",
  "resource": "Composition",
  "fhirVersion": [
    "4.0.1"
  ],
  "select": [
    {
      "column": [
        {
          "name": "composition_id",
          "path": "id",
          "type": "id"
        },
        {
          "name": "encounter_id",
          "path": "encounter.reference.substring(10)",
          "type": "string"
        },
        {
          "name": "subject_patient_id",
          "path": "subject.reference.substring(8)",
          "type": "string"
        }
      ],
      "select": [
        {
          "forEach": "section",
          "column": [
            {
              "name": "section_title",
              "path": "title",
              "type": "string"
            },
            {
              "name": "section_code_system",
              "path": "code.coding.system.first()",
              "type": "uri"
            },
            {
              "name": "section_code",
              "path": "code.coding.code.first()",
              "type": "code"
            },
            {
              "name": "section_code_display",
              "path": "code.coding.display.first()",
              "type": "string"
            },
            {
              "name": "section_text_status",
              "path": "text.status",
              "type": "code"
            },
            {
              "name": "has_narrative",
              "path": "text.div.exists()",
              "type": "boolean"
            },
            {
              "name": "entry_count",
              "path": "entry.count()",
              "type": "integer"
            }
          ]
        }
      ]
    }
  ]
}

Resources (clinical types)

Each row links to a deep-dive page with field-by-field table, side-by-side example, and FML mapping.

DSP content_typeFHIR resourceProfile lives at
document_section (HPI, Overview, A&P, …)Composition.section/mapping/document-section
conditionCondition/mapping/condition
order.medicationMedicationRequest/mapping/medication
order.laboratoryServiceRequest (category=laboratory)/mapping/lab
order.imagingServiceRequest (category=imaging)/mapping/imaging
order.procedureServiceRequest (category=procedure)/mapping/procedure
order.referralServiceRequest (intent=plan, category=referral)/mapping/referral
order.follow_upServiceRequest (category=follow-up) + Appointment (optional)/mapping/follow-up
order.dietaryNutritionOrder/mapping/dietary
order.immunizationImmunizationRecommendation (proposed) / Immunization (administered)/mapping/immunization
order.deviceDeviceRequest (+ Device/DeviceUseStatement downstream)/mapping/device
order.therapyServiceRequest (category=therapy) + optional Goal/mapping/therapy
order.activityCarePlan.activity (preferred) or ServiceRequest (category=activity)/mapping/activity
order.studyServiceRequest (category=study) or ResearchSubject+ResearchStudy/mapping/study

Cross-cutting resource fields

DSPFHIRNotes
context.codes.code or .category CodeableConceptLOINC/SNOMED.
context.display_description (localized)Coding.display + translation extensionPer-locale labels.
context.spoken_formsDSP extension spoken-formsNot a native FHIR concept.
provenance: [turn indices]Provenance.entity.what + DSP extension for integer refsSee Gaps.
confidence_scoreDSP extension confidence-score; applicable only where DSP populates it (orders in 1.0)0..1 decimal. Context is "any Resource" so the extension is tolerant of future expansion beyond orders.
source.typeProvenance.agent.typedragon_copilot / ehr_integration / extension.
parent_reference / child_referencesResource-specific reference (basedOn, partOf, reasonReference)Slot into the semantically correct field per resource type.
update_statusmeta.versionId + Provenance.activityNEW = no prior version; UPDATED = new version; DELETED = DELETE transaction.
search_termsDSP extension or CodeableConcept.text synonymsNot clinical; kept as hint metadata.
external_referenceidentifier + meta.sourcelinkage_confidence → DSP extension.

DSP (fragment on any resource)

{
  "context": {
    "codes": [
      { "system":"http://snomed.info/sct","code":"195967001" },
      { "system":"http://hl7.org/fhir/sid/icd-10-cm","code":"J45.909" }
    ],
    "display_description": {
      "en-US":"Asthma, unspecified, uncomplicated",
      "es-US":"Asma, no especificada"
    },
    "spoken_forms": ["asthma", "reactive airway"]
  },
  "confidence_score": 0.87,
  "provenance": [10, 11],
  "source": { "type": "dragon_copilot" },
  "search_terms": ["asthma","wheeze"],
  "external_reference": {
    "system":"urn:ehr:problem","value":"P-551",
    "linkage_confidence": 0.93
  },
  "update_status": "UPDATED"
}

FHIR (extensions + Provenance)

{
  "resourceType":"MedicationRequest","id":"med-001",
  "code": {
    "coding":[
      { "system":"http://snomed.info/sct","code":"195967001",
        "_display":{ "extension":[{
          "url":"http://hl7.org/fhir/StructureDefinition/translation",
          "extension":[
            { "url":"lang",    "valueCode":"es-US" },
            { "url":"content", "valueString":"Asma, no especificada" }
          ]
        }]},
        "display":"Asthma, unspecified, uncomplicated"
      },
      { "system":"http://hl7.org/fhir/sid/icd-10-cm","code":"J45.909" }
    ],
    "text":"asthma / wheeze"
  },
  "extension":[
    { "url":"https://dsp-fhir.org/StructureDefinition/spoken-forms",
      "extension":[
        { "url":"form","valueString":"asthma" },
        { "url":"form","valueString":"reactive airway" }
      ]},
    { "url":"https://dsp-fhir.org/StructureDefinition/confidence-score",
      "valueDecimal":0.87 },
    { "url":"https://dsp-fhir.org/StructureDefinition/search-terms",
      "extension":[
        { "url":"term","valueString":"asthma" },
        { "url":"term","valueString":"wheeze" }
      ]},
    { "url":"https://dsp-fhir.org/StructureDefinition/transcript-turn-refs",
      "extension":[
        { "url":"transcript","valueReference":{"reference":"DocumentReference/dr-transcript-001/_history/3"}},
        { "url":"turn","valueInteger":10 },
        { "url":"turn","valueInteger":11 }
      ]}
  ],
  "identifier":[{
    "system":"urn:ehr:problem","value":"P-551",
    "extension":[{
      "url":"https://dsp-fhir.org/StructureDefinition/linkage-confidence",
      "valueDecimal":0.93
    }]
  }],
  "meta": { "source":"https://ehr.example.org/...", "versionId":"2" }
}

// Derive update_status from meta.versionId + a Provenance per mutation:
{
  "resourceType":"Provenance",
  "target":[{"reference":"MedicationRequest/med-001"}],
  "recorded":"2026-04-23T14:05:00Z",
  "activity":{"coding":[{
    "system":"http://terminology.hl7.org/CodeSystem/v3-DataOperation",
    "code":"UPDATE"
  }]},
  "agent":[{
    "type":{"coding":[{"system":"https://dsp-fhir.org/CodeSystem/source-type","code":"dragon_copilot"}]},
    "who":{"display":"Dragon Copilot"}
  }]
}
map "https://dsp-fhir.org/StructureMap/DspCrossCutting" = "DspCrossCutting"

// These rules apply to any DSP resource with an Element-level 'context' block.

group CrossCutting(source src : DspResourceFragment, target dst : Resource) {

  // Codes → .code.coding
  src.context.codes as c -> dst.code.coding as cc then {
    c.system as s -> cc.system = s;
    c.code   as k -> cc.code   = k;
  };

  // Localized display → Coding.display + translation extension
  src.context.display_description as dd -> dst.code.coding.first() as cc then {
    dd.item(0) as primary -> cc.display = primary.value;
    dd.where(key != 'en-US') as other -> cc._display.extension as ext then {
      other -> ext.url = 'http://hl7.org/fhir/StructureDefinition/translation';
      other.key   as k -> ext.extension as e then { k -> e.url='lang',    e.value=k; };
      other.value as v -> ext.extension as e then { v -> e.url='content', e.value=v; };
    };
  };

  // Spoken forms → DSP extension
  src.context.spoken_forms as sf -> dst.extension as ext then {
    sf -> ext.url = 'https://dsp-fhir.org/StructureDefinition/spoken-forms';
    sf as form -> ext.extension as e then { form -> e.url='form', e.value=form; };
  };

  // Confidence → decimal extension
  src.confidence_score as cs -> dst.extension as ext then {
    cs -> ext.url = 'https://dsp-fhir.org/StructureDefinition/confidence-score',
          ext.value = cs;
  };

  // Turn refs → structured extension
  src.provenance as turns -> dst.extension as ext then {
    turns -> ext.url = 'https://dsp-fhir.org/StructureDefinition/transcript-turn-refs';
    turns as idx -> ext.extension as e then { idx -> e.url='turn', e.value=idx; };
  };

  // Search terms → extension
  src.search_terms as st -> dst.extension as ext then {
    st -> ext.url = 'https://dsp-fhir.org/StructureDefinition/search-terms';
    st as term -> ext.extension as e then { term -> e.url='term', e.value=term; };
  };

  // External reference → Identifier (+ linkage-confidence extension)
  src.external_reference as xr -> dst.identifier as id then {
    xr.system as s -> id.system = s;
    xr.value  as v -> id.value  = v;
    xr.linkage_confidence as lc -> id.extension as ext then {
      lc -> ext.url = 'https://dsp-fhir.org/StructureDefinition/linkage-confidence',
            ext.value = lc;
    };
  };
}

// update_status is NOT a forward map: it's derived on read from
// meta.versionId + Provenance.activity. No FML rule; see operations: $everything?_since=.
# Cross-cutting fragment: every DSP-originated metadata field carried on
# any FHIR resource. Inline this fragment into each resource selection.
fragment DspCrossCutting on Resource {
  meta { profile source }

  confidence: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-confidence-score") {
    valueDecimal
  }
  spokenForms: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-spoken-forms") {
    valueString
  }
  searchTerms: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-search-terms") {
    valueString
  }
  source: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-resource-source") {
    valueCode
  }

  # One extension per turn ref; each carries its own version-pinned transcript reference (R1).
  turnRefs: extension(url: "https://dsp-fhir.org/StructureDefinition/dsp-transcript-turn-ref") {
    transcript: extension(url: "transcript") { valueReference { reference } }
    turn:       extension(url: "turn")       { valueInteger }
  }
}

// Adapter (composes with each resource's per-type adapter)
function applyDspCrossCutting(r, dst) {
  const turnRefs = r.turnRefs ?? [];
  return {
    ...dst,
    confidence_score: r.confidence?.[0]?.valueDecimal,
    spoken_forms:     r.spokenForms?.map(e => e.valueString) ?? [],
    search_terms:     r.searchTerms?.map(e => e.valueString) ?? [],
    source:           { type: r.source?.[0]?.valueCode, ref: r.meta?.source },
    provenance:       turnRefs.map(t => t.turn?.valueInteger),
    transcript_ref:   turnRefs[0]?.transcript?.valueReference?.reference,
  };
}

// Note: update_status is derived on read from meta.versionId + Provenance.activity (R4).
// External-reference + linkage-confidence are recovered from Resource.identifier and
// the dsp-linkage-confidence extension on it — see per-resource adapters.

Deep-dive pages: Condition · Medication · Lab · Imaging · Procedure · Referral · Follow-up · Dietary · Immunization · Device · Therapy · Activity · Study · Document section

Out of scope for DSP 1.0

DSP captures what is said during the encounter. The following resources commonly exist in a downstream canonical patient-context store but are not emitted by DSP-FHIR 1.0. Integrators should source them from the downstream store directly.

ResourceNot emitted becauseDownstream treatment
Observation Vitals and discrete result values aren't dictated as part of DSP 1.0 Sourced from the downstream EHR / context store
DiagnosticReport DSP emits the order (ServiceRequest); report finalization is a downstream concern Generated by the downstream system when results post
AllergyIntolerance Allergy reconciliation requires a curated list; ambient mentions alone are unreliable Captured as narrative in Composition.section; reconciled downstream
MedicationStatement DSP emits MedicationRequest for prescribing intent; "patient reports taking" without intent to prescribe is out of scope Maintained by the downstream medication reconciliation workflow
RelatedPerson Caregivers mentioned in dictation are narrative only in 1.0 Sourced from the downstream patient registry
Coverage Insurance details are not dictated Sourced from the downstream registration / billing system
Schedule / Task Workflow state is a downstream concern Owned by the EHR / context store
Basic DSP uses typed extensions rather than the Basic escape hatch Not applicable

See Interop & layering → Out of scope for the full layering rationale.