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/CertICAOtoCoreDataSet Version: 1.0.0
Draft as of 2024-10-15 Computable Name: CertICAOtoCoreDataSet

Structure map transforming CertICAO logical model to bundle of Core Data Set logical model

Generated Narrative: StructureMap CertICAOtoCoreDataSet

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

// Structure map transforming CertICAO logical model to bundle of Core Data Set logical model

uses "http://smart.who.int/ddcc/StructureDefinition/CertICAOVDS" alias VDS as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias DDCCBundle as target
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet" alias DDCC as target
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSetVS" alias DDCCVS as target
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSetTR" alias DDCCTR as target

group CertICAOtoCoreDataSet(source src : VDS, target ddccBundle : DDCCBundle) {
  src.data as data then {
    data.msg as msg then {
      msg.ve as ve then {
        ve.vd as vd ->  ddccBundle.entry as outentry,  create('http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSetVS') as ddcc then {
          data.hdr as hdr -> ddcc.certificate as certificate then VDStoCoreDataSetCertificate(hdr, msg, certificate) "set certificate";
          msg.pid as pid then ExtractPatient(pid, ddcc) "set patient";
          vd -> ddcc.vaccination as vaccination then ExtractVaccine(ve, vd, vaccination) "set vaccination";
          vd -> outentry.resource = ddcc "set outentry";
        };
      };
      msg.tr as tr ->  ddccBundle.entry as outentry,  create('http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSetTR') as ddcc then {
        data.hdr as hdr -> ddcc.certificate as certificate then VDStoCoreDataSetCertificate(hdr, msg, certificate) "set certificate";
        msg.pid as pid then ExtractPatient(pid, ddcc) "set patient";
        msg.sp as sp then {
          msg.dat as dat -> ddcc.test as test then ExtractTest(sp, dat, tr, test) "set test";
        };
        tr -> outentry.resource = ddcc "set outentry";
      };
    };
  };
}

group VDStoCoreDataSetCertificate(source hdr, source msg, target certificate) {
  hdr.v as v -> certificate.version = v "set version";
  msg.uvci as uvci ->  certificate.hcid as hcid,  hcid.value = uvci "set hcid from uvci";
  msg.utci as utci ->  certificate.hcid as hcid,  hcid.value = utci "set hcid from utci";
  hdr.is as is ->  certificate.issuer = create('Reference') as issuer,  issuer.display = is "set issuer";
}

group ExtractPatient(source pid, target ddcc : DDCC) {
  pid.n as name -> ddcc.name = name "set name";
  pid.dob as birthDate -> ddcc.birthDate = birthDate "set birthDate";
  pid.i as priorityIdentifier ->  ddcc.identifier as identifier,  identifier.value = priorityIdentifier "set priorityIdentifier";
  pid.dn -> ddcc.identifier as identifier then ExtractDocumentTypeNumber(pid, identifier) "set Document Type Number";
}

group ExtractDocumentTypeNumber(source src, target identif : Identifier) {
  src.dn as docNumber -> identif.value = docNumber "set doc number";
  src.dt as docType where (docType = 'P') -> identif.system = 'PPN' "set doc number P"; // P – Passport (Doc 9303-4)
  src.dt as docType where (docType = 'A') -> identif.system = 'DL' "set doc number A"; // A – ID Card (Doc 9303-5)
  src.dt as docType where (docType = 'C') -> identif.system = 'DL' "set doc number C"; // C – ID Card (Doc 9303-5)
  src.dt as docType where (docType = 'I') -> identif.system = 'DL' "set doc number I"; // I – ID Card Doc 9303-5)
  src.dt as docType where (docType = 'AC') -> identif.system = 'EN' "set doc number AC"; // AC - Crew Member Certificate (Doc 9303-5)
  src.dt as docType where (docType = 'V') -> identif.system = 'ACSN' "set doc number V"; // V – Visa (Doc 9303-7)
  src.dt as docType where (docType = 'D') -> identif.system = 'DL' "set doc number D"; // D – Driving License (ISO18013-1)
}

group ExtractVaccine(source ve, source vd, target vaccination) {
  ve.des as des ->  vaccination.vaccine as coding,  coding.system = 'http://id.who.int/icd11/mms',  coding.code = des "set vaccine";
  ve.nam as nam ->  vaccination.brand as coding,  coding.code = nam "set brand";
  ve.dis as dis ->  vaccination.disease as coding,  coding.system = 'http://id.who.int/icd11/mms',  coding.code = dis "set target disease";
  vd.dvc as dvc -> vaccination.date = dvc "set date";
  vd.seq as seq -> vaccination.dose = seq "set dose";
  vd.dvn as dvn -> vaccination.nextDose = dvn "set nextDose";
  vd.ctr as ctr -> vaccination.country as coding then {
    ctr then ExtractCountry(ctr, coding) "set country";
  };
  vd.adm as adm -> vaccination.centre = adm "set centre";
  vd.lot as lot -> vaccination.lot = lot "set lot";
}

group ExtractTest(source sp, source dat, source tr, target test) {
  tr ->  test.pathogen as coding,  coding.system = 'http://id.who.int/icd11/mms',  coding.code = 'XN109' "set pathogen";
  tr.tc as tc then {
    tc ->  test.type as coding,  coding.code = tc "set default type";
    tc -> c('http://smart.who.int/ddcc/CodeSystem/lab-test-type-icao', tc) as coded then {
      tc where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-type-icao') -> test.type = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-type-icao-to-icd11', 'Coding') "translate ICAO type";
    } "coding";
  };
  tr.m as m then {
    m ->  test.origin as coding,  coding.code = m "set default origin";
    m -> c('http://smart.who.int/ddcc/CodeSystem/lab-test-sample-origin-icao', m) as coded then {
      m where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-sample-origin-icao') -> test.origin = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-sample-origin-icao-to-icd11', 'Coding') "translate ICAO origin";
    } "coding";
  };
  dat.sc as date -> test.date = date "set date";
  tr.r as r then {
    r ->  test.result as coding,  coding.code = r "set default result";
    r -> c('http://smart.who.int/ddcc/CodeSystem/lab-test-qual-result-icao', r) as coded then {
      r where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-qual-result-icao') -> test.result = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-qual-result-icao-to-icd11', 'Coding') "translate ICAO result";
    } "coding";
  };
  sp.spn as spn ->  test.centre as coding,  coding.code = spn "set centre";
  sp.ctr as ctr -> test.country as coding then {
    ctr then ExtractCountry(ctr, coding) "set country";
  };
}

group ExtractCountry(source country, target coding) {
  // ICAO Doc 9303-1 country codes are a superset of ISO 3166 3 letter codes
  country -> coding.code = country "set default country";
  country -> c('urn:iso:std:iso:3166', country) as coded then {
    country where coded.memberOf('http://hl7.org/fhir/ValueSet/iso3166-1-3') ->  coding.code = country,  coding.system = 'urn:iso:std:iso:3166' "set country with system";
  } "coded";
}