WHO Digital Documentation of COVID-19 Certificates (DDCC)
1.0.0 - CI Build International flag

This page is part of the WHO Digital Documentation of COVID-19 Certificates (DDCC) (v1.0.0: releases Draft) based on FHIR (HL7® FHIR® Standard) R4. This is the current published version. For a full list of available versions, see the Directory of published versions

StructureMap:

Official URL: http://smart.who.int/ddcc/StructureMap/CertDCCtoDDCC Version: 1.0.0
Draft as of 2024-10-15 Computable Name: EUDCCtoDDCC

Generated Narrative: StructureMap EUDCCtoDDCC

map "http://smart.who.int/ddcc/StructureMap/CertDCCtoDDCC" = "EUDCCtoDDCC"

uses "http://smart.who.int/ddcc/StructureDefinition/CertDCC" alias CWT as source
uses "http://hl7.eu/fhir/ig/dcc/StructureDefinition/HC1" alias HC1 as source
uses "http://hl7.eu/fhir/ig/dcc/StructureDefinition/PersonName" alias PersonName as source
uses "http://hl7.eu/fhir/ig/dcc/StructureDefinition/v" alias VacEvent as source
uses "http://hl7.eu/fhir/ig/dcc/StructureDefinition/t" alias TestEvent as source
uses "http://hl7.eu/fhir/ig/dcc/StructureDefinition/r" alias RecEvent as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target

group EUDCCtoDDCC(source src : CWT, target bundle : Bundle) {
  src -> bundle.type = 'transaction' "set bundle type";
  src ->  bundle,  bundle.entry as entry,  entry.resource = create('Composition') as comp then {
    src.data as data then {
      data.cert as cert -> bundle then ExtractCert(cert, bundle, comp) "Certificate";
    } "Processing cert data";
    src -> bundle then ExtractComposition(src, comp) "Composition";
  } "Patient and Composition Create";
}

group ExtractCert(source src : HC1, target bundle : Bundle, target comp : Composition) {
  src ->  comp,  bundle.entry as entry,  entry.resource = create('Patient') as patient,  uuid() as pid then {
    src -> patient then ExtractPatient(src, pid, patient) "extract patient";
    src ->  comp.subject as subj,  subj.reference = append('Patient/', pid) "Set patient";
    src where (src.v.count() > 0) -> comp.section as section then {
      src ->  section.code as code,  code.coding as coding,  coding.system = 'http://loinc.org',  coding.code = '11369-6',  coding.display = 'History of Immunization Narrative' "add section";
      src.v as vac ->  comp,  bundle.entry as entryImm,  entryImm.resource = create('Immunization') as immunization,  uuid() as iid,  bundle.entry as entryOrg,  entryOrg.resource = create('Organization') as org,  uuid() as oid then {
        src -> immunization.id = iid "Immunization ID";
        src -> org.id = oid "Organization ID";
        src ->  section.entry as entry,  entry.reference = append('Immunization/', iid),  section.author as author,  author.reference = append('Organization/', oid) "add entry/author to section";
        src ->  comp.author as author,  author.reference = append('Organization/', oid) "Set org";
        src ->  immunization.patient as subj,  subj.reference = append('Patient/', pid) "Set patient";
        vac.is as is -> org.name = is "Set Organization name";
        src -> bundle then ExtractVaccine(vac, oid, immunization) "extract vaccine info";
      } "Immunization Create";
    } "Vaccination List";
  } "Patient Create";
}

group ExtractVaccine(source vac : VacEvent, source oid, target immunization : Immunization) {
  vac.dt as dt -> immunization.occurrence = dt "set occurrence date";
  vac.vp as vp ->  immunization.vaccineCode as type,  type.coding as coding,  coding.system = 'http://snomed.info/sct',  coding.code = vp "set vaccine coding";
  vac.ci as ci ->  immunization.identifier as identif,  identif.value = ci "set identifier ci";
  vac.mp as mp ->  immunization.extension as ext,  ext.value = create('Coding') as coding,  ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCVaccineBrand',  coding.code = mp,  coding.system = 'https://www.ema.europa.eu/en/medicines/human/EPAR/comirnaty' "set brand";
  vac.ma as ma ->  immunization.extension as ext,  ext.value = create('Coding') as coding,  ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCVaccineMarketAuthorization',  coding.code = ma,  coding.system = 'https://www.ema.europa.eu/en/medicines/human/EPAR/comirnaty' "set manufacturer extension";
  vac.co as co ->  immunization.extension as ext,  ext.value = create('Coding') as coding,  ext.url = 'https://smart.who.int/ddcc/StructureDefinition/DDCCCountryOfVaccination',  coding.code = co,  coding.system = 'urn:iso:std:iso:3166' "set country";
  vac -> immunization.protocolApplied as protocolApplied then ExtractProtocolApplied(vac, oid, protocolApplied) "set protocol applied";
}

group ExtractProtocolApplied(source vac : VacEvent, source oid, target protocol : ProtocolApplied) {
  vac.dn as dn -> protocol.doseNumber = dn "set dose number";
  vac.sd as sd -> protocol.seriesDoses = sd "set series doses";
  vac.tg as tg ->  protocol.targetDisease as codeable,  codeable.coding as coding,  coding.system = 'http://snomed.info/sct',  coding.code = tg "set target disease type";
  oid ->  protocol.authority as authority,  authority.reference = append('Organization/', oid) "set authority";
}

group ExtractPatient(source src : HC1, source pid, target patient : Patient) {
  pid -> patient.id = pid "Patient ID";
  src.nam as name -> patient then ExtractPersonName(name, patient) "Patient";
  src.dob as birthDate -> patient.birthDate = birthDate "set birthDate";
}

group ExtractPersonName(source src : PersonName, target tgt : DDCCPatient) {
  src -> tgt.name = create('HumanName') as humanName then ExtractHumanName(src, humanName) "Human Name";
  src -> tgt.name = create('HumanName') as humanNameStd then ExtractStandardizedName(src, humanNameStd) "Human Name Std";
}

group ExtractHumanName(source src : PersonName, target tgt : HumanName) {
  src.gn as givenName -> tgt.given = givenName "Given Name";
  src.fn as familyName -> tgt.family = familyName "Family Name";
  src -> tgt.use = 'official' "Use";
}

group ExtractStandardizedName(source src : PersonName, target tgt : HumanName) {
  src.gnt as givenName -> tgt.given = givenName "Given Name Std";
  src.fnt as familyName -> tgt.family = familyName "Family Name Std";
  src -> tgt.use = 'official' "Use Std";
}

group ExtractComposition(source src : CWT, target composition : Composition) {
  src -> composition.title = 'International Certificate of Vaccination or Prophylaxis' "Title";
  src ->  composition.category as category,  category.coding as coding then {
    src -> coding.code = 'ddcc-vs' "Category";
  } "set category";
  src ->  composition.type as type,  type.coding as coding then {
    src ->  coding.system = 'http://loinc.org',  coding.code = '82593-5',  coding.display = 'Immunization summary report' "set type coding";
  } "set type";
  src ->  composition.event as event,  event.period = create('Period') as period then ExtractPeriod(src, period) "Extract Period";
}

group ExtractPeriod(source src : CWT, target tgt : Period) {
  src.nbf as nbf -> tgt.start = nbf "Start notBefore";
  src.iat as iat -> tgt.start = iat "Start issuedAt";
  src.exp as exp -> tgt.end = exp "End expiration";
}