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: QRespToVSCoreDataSet

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


uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QResp as source
uses "http://smart.who.int/ddcc/StructureDefinition/DDCCCoreDataSet.VS.CoC" alias DDCC as target

group QRespToCoreDataSet(source qr : QResp, target ddcc : DDCC) {
  qr as src then QRespToHeader(src, ddcc) "set header content";
  qr as src -> ddcc.vaccination as vaccination then QRespToVaccination(src, vaccination) "set vaccination content";
  qr as src -> ddcc.certificate as certificate then QRespToCertificate(src, certificate) "set certificate content";
}

group QRespToHeader(source qr, target ddcc) {
  qr.item as item then {
    item.answer first as answer where item.linkId = 'name' then {
      answer.valueString as content -> ddcc.name = content "set name";
    } "first answser for name";
    item.answer first as answer where item.linkId = 'birthDate' then {
      answer.valueDate as content -> ddcc.birthDate = content "set birthDate";
    } "first answer for birthDate";
    item.answer first as answer where item.linkId = 'identifier' -> ddcc.identifier as identifier then {
      answer.valueString as content -> identifier.value = content "set identifier";
    } "first answer for identifier";
    item.answer first as answer where item.linkId = 'sex' then {
      answer.valueCoding as coding then {
        coding.code as content -> ddcc.sex = content "set sex";
      } "process coding";
    } "first answer for sex";
  } "header items";
}

group QRespToVaccination(source qr, target vaccination) {
  qr.item as item then {
    item.answer first as answer where item.linkId = 'vaccine' then {
      answer.valueCoding as content -> vaccination.vaccine = content "set vaccine";
    } "first answer for vaccine";
    item.answer first as answer where item.linkId = 'brand' then {
      answer.valueCoding as content -> vaccination.brand = content "set brand";
    } "first answer for brand";
    item.answer first as answer where item.linkId = 'manufacturer' then {
      answer.valueCoding as content -> vaccination.manufacturer = content "set manufacturer";
    } "first answer for manufacturer";
    item.answer first as answer where item.linkId = 'ma_holder' then {
      answer.valueCoding as content -> vaccination.maholder = content "set maholder";
    } "first answer for maholder";
    item.answer first as answer where item.linkId = 'lot' then {
      answer.valueString as content -> vaccination.lot = content "set lot";
    } "first answser for lot";
    item.answer first as answer where item.linkId = 'date' then {
      answer.valueDate as content -> vaccination.date = content "set date";
    } "first answer for date";
    item.answer first as answer where item.linkId = 'vaccine_valid' then {
      answer.valueDate as content -> vaccination.validFrom = content "set validFrom";
    } "first answer for validFrom";
    item.answer first as answer where item.linkId = 'dose' then {
      answer.valueInteger as content -> vaccination.dose = content "set dose";
    } "first answer for dose";
    item.answer first as answer where item.linkId = 'total_doses' then {
      answer.valueInteger as content -> vaccination.totalDoses = content "set totalDoses";
    } "first answer for totalDoses";
    item.answer first as answer where item.linkId = 'country' then {
      answer.valueCoding as content -> vaccination.country = content "set country";
    } "first answer for country";
    item.answer first as answer where item.linkId = 'centre' then {
      answer.valueString as content -> vaccination.centre = content "set centre";
    } "first answser for centre";
    item.answer first as answer where item.linkId = 'hw' -> vaccination.practitioner as identifier then {
      answer.valueString as content -> identifier.value = content "set practitioner";
    } "first answser for practitioner";
    item.answer first as answer where item.linkId = 'disease' then {
      answer.valueCoding as content -> vaccination.disease = content "set disease";
    } "first answer for disease";
    item.answer first as answer where item.linkId = 'due_date' then {
      answer.valueDate as content -> vaccination.nextDose = content "set nextDose";
    } "first answer for nextDose";
  } "vaccination items";
}

group QRespToPeriod(source qr, target period) {
  qr.item as item then {
    item.answer first as answer where item.linkId = 'valid_from' then {
      answer.valueDate as content -> period.start = content "set valid_from";
    } "first answer for valid_from";
    item.answer first as answer where item.linkId = 'valid_until' then {
      answer.valueDate as content -> period.end = content "set valid_until";
    } "first answer for valid_until";
  } "vaccination validity items";
}

group QRespToCertificate(source qr, target certificate) {
  qr.item as item then {
    item.answer first as answer where item.linkId = 'pha' -> certificate.issuer as issuer then {
      answer.valueString as content -> issuer.identifier as identifier then {
        content as value -> identifier.value = value "set issuer identifier";
      } "set issuer";
    } "first answser for hcid";
    item.answer first as answer where item.linkId = 'hcid' -> certificate.hcid as hcid then {
      answer.valueString as content ->  hcid.value = content,  certificate.version = 'RC2' "set hcid and version";
    } "first answser for hcid";
  } "certificate items";
  qr as src -> certificate.period as period then QRespToPeriod(src, period) "set vaccination period";
}