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

Official URL: http://worldhealthorganization.github.io/ddcc/StructureMap/DDCCtoCoredataset Version: 1.0.0
Draft as of 2022-06-01 Computable Name: DDCCtoCoredataset
map "http://worldhealthorganization.github.io/ddcc/StructureMap/DDCCtoCoredataset" = "DDCCtoCoredataset"


uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCVSComposition" alias DDCC as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCDocument" alias DDCCDocument as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCPatient" alias DDCCPatient as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCVSComposition" alias DDCCVSComposition as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCCountryOfVaccination" alias DDCCCountryOfVaccination as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCVaccineBrand" alias DDCCVaccineBrand as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCOrganization" alias DDCCOrganization as source
uses "http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCImmunization" alias DDCCImmunization as source
uses "http://worldhealthorganization.github.io/ddcc/DDCCCoreDataSet.VS.PoV" alias DDCCCoreDataSetPoV as target

group DecodeDDCCtoQR(source ddcc : DDCCDocument, target qr : DDCCCoreDataSetPoV) {
  ddcc.entry as entry then {
    // entry.resource : DDCCPatient as patient
    entry.resource : Patient as patient then DecodePatientToQR(patient, qr) "Patient";
  };
  ddcc.entry as entry then {
    entry.resource : Immunization as immunization log immunization then DecodeImmunizationToQR(ddcc, immunization, qr) "Immunization";
  };
}

group DecodePatientToQR(source patient : DDCCPatient, target qr : DDCCCoreDataSetPoV) {
  patient.birthDate as birthDate -> qr.birthDate = birthDate;
  patient.name as name then {
    name.text as text -> qr.name = text;
  };
}

group DecodeImmunizationToQR(source ddcc : DDCCDocument, source immunization : DDCCImmunization, target qr : DDCCCoreDataSetPoV) {
  immunization -> qr.vaccination = create('BackboneElement') as vacEvent then {
    immunization.protocolApplied as protocol then {
      protocol.doseNumberPositiveInt as dose -> vacEvent.dose = dose;
      protocol.seriesDosesPositiveInt as doseNum -> vacEvent.totalDoses = doseNum;
      protocol.targetDisease as targetDisease then {
        targetDisease.valueCodableConcept as valueCodableConcept -> vacEvent.disease = valueCodableConcept;
      } "Target-Disease";
    };
    immunization.occurrenceDateTime as date -> vacEvent.date = date;
    // TODO: need to populate vacEvent.maholder
    immunization.extension as country where (url = 'http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCCountryOfEvent') then {
      country.valueCode as code ->  vacEvent.country = create('Coding') as coding,  coding.code = code,  coding.system = 'http://hl7.org/fhir/ValueSet/iso3166-1-3';
    } "Country";
    // immunization.extension : DDCCBrand as brand
    immunization.extension as brand where (url = 'http://worldhealthorganization.github.io/ddcc/StructureDefinition/DDCCEventBrand') then {
      brand.valueCoding as valueCoding -> vacEvent.brand = valueCoding;
    } "Vaccine-Brand";
    immunization.vaccineCode as vaccineCode then {
      vaccineCode.coding as coding -> vacEvent.vaccine = coding;
    } "Vaccine-Code";
    ddcc.entry as entry then {
      // entry.resource : DDCCOrganization as organization
      entry.resource : Organization as organization then {
        organization.name as name -> vacEvent.centre = name;
      } "Centre-Name";
    } "Vaccination-Centre";
    ddcc.entry as entry then {
      // entry.resource : DDCCVSComposition as composition
      entry.resource : Composition as composition then {
        composition.identifier as identifier -> qr.identifier = identifier;
      } "Vaccination-Event-ID";
    } "Vaccination-Event";
  } "Vaccination";
}