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

This is the continuous build for version 1.0.0. This version is based on the current content of https://github.com/WorldHealthOrganization/ddcc and changes regularly.

StructureMap: CertDCCtoCoreDataSet

Official URL: http://smart.who.int/ddcc/StructureMap/CertDCCtoCoreDataSet Version: 1.0.0
Draft as of 2024-01-19 Computable Name: CertDCCtoCoreDataSet

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

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

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

uses "http://smart.who.int/ddcc/StructureDefinition/CertDCC" alias CWTPayload as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias DDCCBundle as target
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet" alias DDCC as produced
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet.VS" alias DDCCVS as produced
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet.TR" alias DDCCTR as produced

group CertDCCtoCoreDataSet(source src : CWTPayload, target ddccBundle : DDCCBundle) {
  src."-260" as hcert then {
    hcert."1" as dcc then {
      dcc.v as v ->  ddccBundle.entry as outentry,  create('http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet.VS') as ddcc then {
        v then DCCtoCoreDataSet(dcc, ddcc) "set DDCC";
        v -> ddcc.certificate as certificate then CertDCCtoCoreDataSetCertificate(src, dcc, v, certificate) "set certificate";
        v -> ddcc.vaccination as vaccination then VtoCoreDataSetVS(v, vaccination) "set vaccination";
        v -> outentry.resource = ddcc "set outentry";
      dcc.t as t ->  ddccBundle.entry as outentry,  create('http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet.TR') as ddcc then {
        t then DCCtoCoreDataSet(dcc, ddcc) "set DDCC";
        t -> ddcc.certificate as certificate then CertDCCtoCoreDataSetCertificate(src, dcc, t, certificate) "set certificate";
        t -> ddcc.test as test then TtoCoreDataSetTR(t, test) "set test";
        t -> outentry.resource = ddcc "set outentry";
    } "eu_DCC_v1";
  } "hcert";

group DCCtoCoreDataSet(source dcc, target ddcc : DDCC) {
  dcc.dob as birthDate -> ddcc.birthDate = birthDate "set birthDate";
  dcc.nam as nam then {
    nam.gn as given -> ddcc.name = (given.replaceMatches('$', ' ')) "set given name";
    nam.fn as family ->  ddcc.name as tName,  ddcc.name = append(tName, family) "add family name";

group CertDCCtoCoreDataSetCertificate(source src : CWTPayload, source dcc, source g, target certificate) {
  src -> certificate.period = create('Period') as period then CwtToPeriod(src, period) "set period";
  dcc.ver as ver -> certificate.version = ver "set version";
  g.ci as ci ->  certificate.hcid as hcid,  hcid.value = ci "set hcid";
  g.is as is ->  certificate.issuer = create('Reference') as issuer,  issuer.display = is "set issuer";

group CwtToPeriod(source src : CWTPayload, target tgt : Period) {
  src."6" as iat ->  append(iat, ' seconds') as epoch,  tgt.start = (@1970-01-01T00:00:00.000+00:00 + epoch.toQuantity()) "set period start";
  src."4" as exp ->  append(exp, ' seconds') as epoch,  tgt.end = (@1970-01-01T00:00:00.000+00:00 + epoch.toQuantity()) "set period end";

group VtoCoreDataSetVS(source v, target vaccination) {
  v.tg as tg ->  vaccination.disease as coding,  coding.system = 'http://snomed.info/sct',  coding.code = tg "set target disease";
  v.vp as vp ->  vaccination.vaccine as coding,  coding.system = 'https://ec.europa.eu/health/documents/community-register/html/',  coding.code = vp "set vaccine";
  v.mp as mp then {
    mp ->  vaccination.brand as coding,  coding.system = 'https://id.uvci.eu/valuesets/vaccine-medicinal-product.json',  coding.code = mp "set default brand";
    mp -> c('https://ec.europa.eu/health/documents/community-register/html/', mp) as coded then {
      mp where coded.memberOf('http://smart.who.int/ddcc/ValueSet/vaccine-covid19-euur') -> vaccination.brand = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/vaccine-covid19-euur-to-icd11', 'Coding') "translate COVID19 brand";
    } "coding";
  v.ma as ma ->  vaccination.maholder as coding,  coding.system = 'https://id.uvci.eu/valuesets/vaccine-mah-manf.json',  coding.code = ma "set maholder";
  v.dt as date -> vaccination.date = date "set date";
  v.dn as dose -> vaccination.dose = dose "set dose";
  v.sd as totalDoses -> vaccination.totalDoses = totalDoses "set totalDoses";
  v.co as co ->  vaccination.country as coding,  coding.code = co,  coding.system = 'urn:iso:std:iso:3166' "set country";

group TtoCoreDataSetTR(source t, target test) {
  t.tg as tg then {
    tg ->  test.pathogen as coding,  coding.system = 'http://snomed.info/sct',  coding.code = tg "set default pathogen";
    tg -> c('http://snomed.info/sct', tg) as coded then {
      tg where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-pathogen-covid19-snomed') -> test.pathogen = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-pathogen-snomed-to-icd11', 'Coding') "translate COVID19 pathogen";
    } "coding";
  t.tt as tt then {
    tt ->  test.type as coding,  coding.system = 'http://loinc.org',  coding.code = tt "set default type";
    tt -> c('http://loinc.org', tt) as coded then {
      tt where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-type-covid19-loinc') -> test.type = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-type-covid19-loinc-to-icd11', 'Coding') "translate COVID19 type";
    } "coding";
  t.nm as nm ->  test.brand as coding,  coding.system = 'https://id.uvci.eu/valuesets/test-manf.json',  coding.code = nm "set brand";
  t.ma as ma ->  test.manufacturer as coding,  coding.system = 'https://covid-19-diagnostics.jrc.ec.europa.eu/devices',  coding.code = ma "set manufacturer";
  t.sc as date -> test.date = date "set date";
  t.tr as tr then {
    tr ->  test.result as coding,  coding.system = 'http://snomed.info/sct',  coding.code = tr "set default result";
    tr -> c('http://snomed.info/sct', tr) as coded then {
      tr where coded.memberOf('http://smart.who.int/ddcc/ValueSet/lab-test-qual-result-snomed') -> test.result = translate(coded, 'http://smart.who.int/ddcc/ConceptMap/lab-test-qual-result-snomed-to-icd11', 'Coding') "translate COVID19 result";
    } "coding";
  t.tc as tc ->  test.centre as coding,  coding.code = tc "set centre";
  t.co as co ->  test.country as coding,  coding.code = co,  coding.system = 'urn:iso:std:iso:3166' "set country";