FHIR © HL7.org  |  FHIRsmith 4.0.1  |  Server Home  |  XIG Home  |  XIG Stats  | 

FHIR IG analytics

Packagesilfhirprofileig
Resource TypeStructureMap
IdStructureMap-ExtractBloodDonorQuestionnaire.json
FHIR VersionR5
Sourcehttps://build.fhir.org/ig/savannahghi/sil_fhir_profile_ig/StructureMap-ExtractBloodDonorQuestionnaire.html
URLhttps://fhir.slade360.co.ke/fhir/StructureMap/ExtractBloodDonorQuestionnaire
Version0.1.0
Statusactive
Date2026-09-11T12:18:36+00:00
NameExtractBloodDonorQuestionnaire
TitleBlood Donor Questionnaire Extraction
DescriptionThe KTTA donor form out as: one Observation carrying the thirteen deferral questions as components, because eligibility is a judgement over the whole set; the screening measurements each as their own Observation, so a haemoglobin below the 12.5 g/dL line is findable by its LOINC code; the eligibility decision as its own Observation with an abnormal interpretation when the donor was deferred, and the reason beside it; a Consent from the signed declaration, with the research opt-in as a second provision because it is a separate question the form asks separately; a Procedure for the collection itself; and one Observation carrying the nine post-donation adverse events.

Resources that use this resource

No resources found


Resources that this resource uses

No resources found


Narrative

Note: links and images are rebased to the (stated) source

Generated Narrative: StructureMap ExtractBloodDonorQuestionnaire

/// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractBloodDonorQuestionnaire'
/// name = 'ExtractBloodDonorQuestionnaire'
/// title = 'Blood Donor Questionnaire Extraction'
/// status = 'active'
/// description = 'The KTTA donor form out as: one Observation carrying the thirteen deferral questions as components, because eligibility is a judgement over the whole set; the screening measurements each as their own Observation, so a haemoglobin below the 12.5 g/dL line is findable by its LOINC code; the eligibility decision as its own Observation with an abnormal interpretation when the donor was deferred, and the reason beside it; a Consent from the signed declaration, with the research opt-in as a second provision because it is a separate question the form asks separately; a Procedure for the collection itself; and one Observation carrying the nine post-donation adverse events.'

uses "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse" alias QR as source
uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as target
uses "http://hl7.org/fhir/StructureDefinition/Observation" alias Observation as target
uses "http://hl7.org/fhir/StructureDefinition/Consent" alias Consent as target
uses "http://hl7.org/fhir/StructureDefinition/Procedure" alias Procedure as target

group ExtractBloodDonorQuestionnaire(source qr : QR, target bundle : Bundle) {
  qr -> bundle.type = 'transaction' "setBundleType";
  // ── The thirteen deferral questions, as one panel ───────────────────────
  // Eligibility is decided by reading all thirteen together, so they travel
  // together. A single "yes" to any of several of them defers the donor, and a
  // reviewer has to be able to see which.
  qr.item as g where ((linkId = 'eligibility') and item.answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
    qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
    qr -> obs then SetSurveyCategory(qr, obs) "category";
    g -> obs.code as cc then {
      g -> cc.coding as cg then {
        g -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
        g -> cg.code = 'donor-eligibility-question' "cd";
        g -> cg.display = 'Donor eligibility question' "dsp";
      } "coding";
      g -> cc.text = 'KTTA donor eligibility questionnaire' "codeText";
    } "code";
    g.item as it where ((linkId = 'eligibility/feeling-well-today') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-feeling-well-today' "cd";
          it -> cg.display = 'Feeling well today' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_feeling_well_today";
    g.item as it where ((linkId = 'eligibility/eaten-in-last-6-hours') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-eaten-in-the-last-6-hours' "cd";
          it -> cg.display = 'Eaten in the last 6 hours' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_eaten_in_the_last_6_hours";
    g.item as it where ((linkId = 'eligibility/fainted-in-past-year') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-fainted-within-the-past-one-year' "cd";
          it -> cg.display = 'Fainted within the past one year' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_fainted_within_the_past_one_year";
    g.item as it where ((linkId = 'eligibility/pregnant-or-lactating') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-pregnant-or-lactating' "cd";
          it -> cg.display = 'Pregnant or lactating' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_pregnant_or_lactating";
    g.item as it where ((linkId = 'eligibility/travelled-in-last-14-days') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-travelled-in-the-last-14-days-outside-the-usual-area' "cd";
          it -> cg.display = 'Travelled in the last 14 days outside the usual area of residence' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_travelled_in_the_last_14_days_outside_the_usual_area";
    g.item as it where ((linkId = 'eligibility/regular-medication') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-on-regular-medication-antibiotics-or-analgesics' "cd";
          it -> cg.display = 'On regular medication, antibiotics or analgesics' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_on_regular_medication_antibiotics_or_analgesics";
    g.item as it where ((linkId = 'eligibility/tattoo-or-piercing-3-months') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-tattooing-or-body-piercing-in-the-last-3-months' "cd";
          it -> cg.display = 'Tattooing or body piercing in the last 3 months' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_tattooing_or_body_piercing_in_the_last_3_months";
    g.item as it where ((linkId = 'eligibility/sexual-activity-unknown-status') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-sexual-activity-in-the-last-3-months-with-a-person' "cd";
          it -> cg.display = 'Sexual activity in the last 3 months with a person of unknown health status' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_sexual_activity_in_the_last_3_months_with_a_person";
    g.item as it where ((linkId = 'eligibility/vaccination-3-months') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-vaccination-in-the-last-3-months' "cd";
          it -> cg.display = 'Vaccination in the last 3 months' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_vaccination_in_the_last_3_months";
    g.item as it where ((linkId = 'eligibility/surgery-or-treatment-6-months') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-surgery-or-medical-treatment-in-the-past-6-months' "cd";
          it -> cg.display = 'Surgery or medical treatment in the past 6 months' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_surgery_or_medical_treatment_in_the_past_6_months";
    g.item as it where ((linkId = 'eligibility/received-blood-6-months') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-received-blood-or-blood-products-in-the-past-6' "cd";
          it -> cg.display = 'Received blood or blood products in the past 6 months' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_received_blood_or_blood_products_in_the_past_6";
    g.item as it where ((linkId = 'eligibility/hepatitis-or-yellow-eyes') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-ever-had-hepatitis-or-yellow-eyes' "cd";
          it -> cg.display = 'Ever had hepatitis or yellow eyes' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_ever_had_hepatitis_or_yellow_eyes";
    g.item as it where ((linkId = 'eligibility/covid-exposure-14-days') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-q-exposed-to-a-suspected-case-of-covid-19-in-the-last' "cd";
          it -> cg.display = 'Exposed to a suspected case of COVID-19 in the last 14 days' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_q_exposed_to_a_suspected_case_of_covid_19_in_the_last";
  } "eligibilityPanel";
  // ── Screening measurements ──────────────────────────────────────────────
  qr.item as g where (linkId = 'screening') then {
    g.item as it where ((linkId = 'screening/weight') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetVitalSignsCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'http://loinc.org' "sys";
          it -> cg.code = '29463-7' "cd";
          it -> cg.display = 'Body weight' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
    } "measure_29463_7";
    g.item as it where ((linkId = 'screening/haemoglobin') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetLaboratoryCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'http://loinc.org' "sys";
          it -> cg.code = '718-7' "cd";
          it -> cg.display = 'Hemoglobin [Mass/volume] in Blood' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
      it ->  obs.note as n,  n.text = 'The KTTA form prints the acceptance threshold on the line: over 12.5 g/dL.' "note";
    } "measure_718_7";
    g.item as it where ((linkId = 'screening/pulse') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetVitalSignsCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'http://loinc.org' "sys";
          it -> cg.code = '8867-4' "cd";
          it -> cg.display = 'Heart rate' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
    } "measure_8867_4";
    g.item as it where ((linkId = 'screening/temperature') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetVitalSignsCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'http://loinc.org' "sys";
          it -> cg.code = '8310-5' "cd";
          it -> cg.display = 'Body temperature' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
    } "measure_8310_5";
    g.item as bpS where ((linkId = 'screening/systolic') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetVitalSignsCategory(qr, obs) "category";
      bpS -> obs.code as cc then {
        bpS -> cc.coding as cg then {
          bpS -> cg.system = 'http://loinc.org' "sys";
          bpS -> cg.code = '85354-9' "cd";
          bpS -> cg.display = 'Blood pressure panel with all children optional' "dsp";
        } "coding";
      } "code";
      g.item as it where ((linkId = 'screening/systolic') and answer.value.exists()) -> obs.component as comp then {
        it -> comp.code as cc then {
          it -> cc.coding as cg then {
            it -> cg.system = 'http://loinc.org' "sys";
            it -> cg.code = '8480-6' "cd";
            it -> cg.display = 'Systolic blood pressure' "dsp";
          } "coding";
        } "code";
        it -> comp then SetComponentValue(it, comp) "value";
      } "comp_8480_6";
      g.item as it where ((linkId = 'screening/diastolic') and answer.value.exists()) -> obs.component as comp then {
        it -> comp.code as cc then {
          it -> cc.coding as cg then {
            it -> cg.system = 'http://loinc.org' "sys";
            it -> cg.code = '8462-4' "cd";
            it -> cg.display = 'Diastolic blood pressure' "dsp";
          } "coding";
        } "code";
        it -> comp then SetComponentValue(it, comp) "value";
      } "comp_8462_4";
    } "screeningBloodPressure";
    // ── The eligibility decision ──────────────────────────────────────────
    // Its own Observation with an interpretation, because this is the finding
    // the whole form exists to produce, and a blood bank filters on it.
    g.item as it where ((linkId = 'screening/eligible') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetSurveyCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-eligible' "cd";
          it -> cg.display = 'Donor is eligible' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as cv -> obs.value = create('CodeableConcept') as vc then {
          cv -> vc.coding = cv "valueCoding";
          cv.display as d -> vc.text = d "valueText";
        } "codedValue";
      };
      it.answer first as a then {
        a.value as cv where (code = 'N') -> obs.interpretation as interp then {
          cv -> interp.coding as icg then {
            cv -> icg.system = 'http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation' "sys";
            cv -> icg.code = 'A' "cd";
            cv -> icg.display = 'Abnormal' "dsp";
          } "coding";
        } "deferredInterp";
      } "eligibilityInterpretation";
      // The deferral reason travels on the same Observation. A deferral without
      // a reason cannot be reviewed, and the questionnaire only asks for the
      // reason when the answer was no -- so this rule fires only then too.
      g.item as dr where ((linkId = 'screening/deferral-reason') and answer.value.exists()) then {
        dr.answer first as da then {
          da.value as txt ->  obs.note as n,  n.text = txt "deferralReasonNote";
        };
      } "deferralReasonRule";
    } "eligibilityObservation";
    g.item as it where ((linkId = 'screening/donor-type') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetSurveyCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-type' "cd";
          it -> cg.display = 'Type of donor' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as cv -> obs.value = create('CodeableConcept') as cc then {
          cv -> cc.coding = cv "valueCoding";
          cv.display as d -> cc.text = d "valueText";
        } "codedValue";
      };
    } "coded_donor_type";
    g.item as it where ((linkId = 'screening/donation-type') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetSurveyCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donation-type' "cd";
          it -> cg.display = 'Type of donation' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as cv -> obs.value = create('CodeableConcept') as cc then {
          cv -> cc.coding = cv "valueCoding";
          cv.display as d -> cc.text = d "valueText";
        } "codedValue";
      };
    } "coded_donation_type";
  } "screeningGroup";
  // ── The declaration and consent ─────────────────────────────────────────
  // Two provisions on one Consent, not two Consents. The donor signed one form,
  // and the research opt-in is a checkbox inside it -- but it is a *separate*
  // permission and the form prints its own yes and no boxes, so it cannot be
  // inferred from the signature. Where the donor did not answer it, no
  // provision is written, which reads as "not asked" rather than "declined".
  qr.item as g where (linkId = 'declaration') then {
    g.item as it where ((linkId = 'declaration/signed') and (answer.value = true)) ->  bundle.entry as entry,  entry.resource = create('Consent') as consent then {
      qr ->  consent,  entry then BuildConsentBase(qr, consent, entry) "base";
      it -> consent.status = 'active' "status";
      it -> consent.category as cat then {
        it -> cat.coding as cg then {
          it -> cg.system = 'http://loinc.org' "sys";
          it -> cg.code = '64293-4' "cd";
          it -> cg.display = 'Procedure consent Document' "dsp";
        } "coding";
        it -> cat.text = 'KTTA blood donor declaration and consent' "categoryText";
      } "category";
      it -> consent.decision = 'permit' "decision";
      qr.source as src -> consent.grantee = src "grantee";
      g.item as dt where ((linkId = 'declaration/signed-on') and answer.value.exists()) then {
        dt.answer first as a then {
          a.value as d -> consent.date = d "signedDate";
        };
      } "signedOnRule";
      it ->  consent.provision as prov,  prov.code as pc,  pc.text = 'The donor signed the KTTA declaration: that the form was filled truthfully, that they consent to give blood, that the donation will be screened for HIV, hepatitis B and C and syphilis, and that a reactive result will be communicated to them with counselling offered.' "declarationNote";
      // The research opt-in, as its own provision.
      g.item as ru where ((linkId = 'declaration/research-use') and (answer.value.ofType(Coding).code = 'Y')) -> consent.provision as prov then {
        ru -> prov.purpose as pur then {
          ru -> pur.system = 'http://terminology.hl7.org/CodeSystem/v3-ActReason' "purposeSystem";
          ru -> pur.code = 'HRESCH' "purposeCode";
          ru -> pur.display = 'healthcare research' "purposeDisplay";
        } "purpose";
      } "researchProvision";
    } "createConsent";
  } "declarationGroup";
  // ── The donation itself ─────────────────────────────────────────────────
  // A Procedure. `status = 'completed'` only when a volume was actually taken:
  // a form filled in for a donor who was then deferred records no collection,
  // and a completed Procedure would say blood was drawn that never was.
  qr.item as g where ((linkId = 'donation') and item.where(linkId = 'donation/volume').answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Procedure') as proc then {
    qr ->  proc,  entry then BuildProcedureBase(qr, proc, entry) "base";
    g -> proc.status = 'completed' "status";
    g -> proc.code as cc then {
      g -> cc.coding as cg then {
        g -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
        g -> cg.code = 'blood-donation' "cd";
        g -> cg.display = 'Blood donation' "dsp";
      } "coding";
    } "code";
    qr.authored as t -> proc.occurrence = t "occurrence";
    qr.encounter as e -> proc.encounter = e;
    qr.source as src ->  proc.performer as p,  p.actor = src "performer";
    g.item as bt where ((linkId = 'donation/bag-type') and answer.value.exists()) then {
      bt.answer first as a then {
        a.value as txt ->  proc.note as n,  n.text = txt "bagTypeNote";
      };
    } "bagTypeRule";
  } "donationProcedure";
  qr.item as g where (linkId = 'donation') then {
    g.item as it where ((linkId = 'donation/volume') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetProcedureCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'volume-donated' "cd";
          it -> cg.display = 'Volume donated' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
    } "measure_volume_donated";
  } "volumeGroup";
  // ── Post-donation adverse events ────────────────────────────────────────
  // One panel. Nine questions the KTTA form asks after every donation, and the
  // set is the haemovigilance record: a donation with no events recorded and a
  // donation where nobody asked look identical unless the panel exists.
  qr.item as g where ((linkId = 'donation') and item.answer.value.ofType(Coding).exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
    qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
    qr -> obs then SetSurveyCategory(qr, obs) "category";
    g -> obs.code as cc then {
      g -> cc.coding as cg then {
        g -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
        g -> cg.code = 'donation-adverse-event' "cd";
        g -> cg.display = 'Post-donation adverse event' "dsp";
      } "coding";
    } "code";
    g.item as it where ((linkId = 'donation/underweight-unit') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-underweight-unit' "cd";
          it -> cg.display = 'Underweight unit' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_underweight_unit";
    g.item as it where ((linkId = 'donation/more-than-one-venipuncture') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-more-than-one-venipuncture' "cd";
          it -> cg.display = 'More than one venipuncture' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_more_than_one_venipuncture";
    g.item as it where ((linkId = 'donation/haematoma') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-haematoma' "cd";
          it -> cg.display = 'Haematoma' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_haematoma";
    g.item as it where ((linkId = 'donation/fainting') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-fainting' "cd";
          it -> cg.display = 'Fainting' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_fainting";
    g.item as it where ((linkId = 'donation/nausea') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-nausea' "cd";
          it -> cg.display = 'Nausea' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_nausea";
    g.item as it where ((linkId = 'donation/vomiting') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-vomiting' "cd";
          it -> cg.display = 'Vomiting' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_vomiting";
    g.item as it where ((linkId = 'donation/headache') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-headache' "cd";
          it -> cg.display = 'Headache' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_headache";
    g.item as it where ((linkId = 'donation/convulsion') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-convulsion' "cd";
          it -> cg.display = 'Convulsion' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_convulsion";
    g.item as it where ((linkId = 'donation/incontinence') and answer.value.exists()) -> obs.component as comp then {
      it -> comp.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'donor-ae-incontinence-of-urine-or-stool' "cd";
          it -> cg.display = 'Incontinence of urine or stool' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_donor_ae_incontinence_of_urine_or_stool";
  } "adverseEventPanel";
  // ── Previous donations ──────────────────────────────────────────────────
  qr.item as g where (linkId = 'donor') then {
    g.item as it where ((linkId = 'donor/previous-donations') and answer.value.exists()) ->  bundle.entry as entry,  entry.resource = create('Observation') as obs then {
      qr ->  obs,  entry then BuildObsBase(qr, obs, entry) "base";
      qr -> obs then SetSurveyCategory(qr, obs) "category";
      it -> obs.code as cc then {
        it -> cc.coding as cg then {
          it -> cg.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "sys";
          it -> cg.code = 'previous-donation-count' "cd";
          it -> cg.display = 'Number of previous donations' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = v "set";
      };
    } "measure_previous_donation_count";
  } "donorGroup";
}

// ─────────────────────────────────────────────────────────────────────────────
// Shared scaffolding. Repeated in each map rather than imported: the transform
// engine resolves `imports` against whatever StructureMaps happen to be on the
// server, and a form that stops extracting because a shared map was not
// uploaded is a worse failure than a duplicated group.
// Two notes on what the publisher's StructureMap validator says about this file.
// Source parameters below are left untyped on purpose. Writing `: Element` makes
// the validator compare QuestionnaireResponse.item against the literal 'Element'
// and report them as incompatible with each other, which is noise, not a finding.
// `evaluate(context, expression)` is flagged as "takes 1 parameter but 2 were
// found". Leave it. The FML parser in the same jar refuses the one-argument form
// outright -- it wants a parameter, a comma, then the FHIRPath -- so the
// publisher is objecting to what its own compiler emits. Two arguments is the
// only form that compiles, and it is what the R5 transform engine executes.
// ─────────────────────────────────────────────────────────────────────────────
group BuildObsBase(source qr : QR, target obs : Observation, target entry) {
  qr -> obs then SetResponseProvenance(qr, obs) "responseProvenance";
  qr -> obs.id = uuid() then SetObservationFullUrl(obs, entry) "idAndFullUrl";
  qr -> entry.request as request then {
    qr -> request.method = 'POST' "requestMethod";
    qr -> request.url = 'Observation' "requestUrl";
  } "entryRequest";
  qr -> obs.status = 'final' "status";
  qr.subject as s -> obs.subject = s;
  qr.encounter as e -> obs.encounter = e;
  qr.authored as t -> obs.effective = t "effective";
  qr.source as src -> obs.performer = src "performerFromSource";
  qr where (source.exists().not()) then {
    qr.author as a -> obs.performer = a "performerFromAuthor";
  } "performerFallback";
  // A stored response's id already reads "QuestionnaireResponse/<id>", so it is
  // a relative reference as it stands. The hasValue() guard is what stops an
  // unsaved response -- one posted straight to $extract rather than saved first
  // -- from writing "QuestionnaireResponse/null" into the record.
  qr.id as qid where ($this.hasValue()) ->  obs.derivedFrom = create('Reference') as ref,  ref.reference = qid "linkQuestionnaireResponse";
}

group SetObservationFullUrl(source obs : Observation, target entry) {
  obs.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Observation/', id) "assignFullUrl";
}

// The two answer shapes a component can carry. Both read the answer through the
// untyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its
// typed property name fails at transform time on HAPI R5 with "Attempt to read
// invalid property ... on QuestionnaireResponse.item.answer".
group SetComponentCodedValue(source it, target comp) {
  it.answer first as a then {
    a.value as cv -> comp.value = create('CodeableConcept') as cc then {
      cv -> cc.coding = cv "valueCoding";
      cv.display as d -> cc.text = d "valueText";
    } "codedValue";
  } "componentAnswer";
}

group SetComponentValue(source it, target comp) {
  it.answer first as a then {
    a.value as v -> comp.value = v "plainValue";
  } "componentAnswer";
}

group SetSurveyCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'survey' "categoryCode";
      qr -> coding.display = 'Survey' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetVitalSignsCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'vital-signs' "categoryCode";
      qr -> coding.display = 'Vital Signs' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetLaboratoryCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'laboratory' "categoryCode";
      qr -> coding.display = 'Laboratory' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group SetProcedureCategory(source qr : QR, target obs : Observation) {
  qr -> obs.category as cat then {
    qr -> cat.coding as coding then {
      qr -> coding.system = 'http://terminology.hl7.org/CodeSystem/observation-category' "categorySystem";
      qr -> coding.code = 'procedure' "categoryCode";
      qr -> coding.display = 'Procedure' "categoryDisplay";
    } "categoryCoding";
  } "category";
}

group BuildConsentBase(source qr : QR, target r : Consent, target entry) {
  qr -> r then SetResponseProvenance(qr, r) "responseProvenance";
  qr -> r.id = uuid() then SetConsentFullUrl(r, entry) "idAndFullUrl";
  qr -> entry.request as request then {
    qr -> request.method = 'POST' "requestMethod";
    qr -> request.url = 'Consent' "requestUrl";
  } "entryRequest";
  qr.subject as s -> r.subject = s;
}

group SetConsentFullUrl(source r : Consent, target entry) {
  r.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Consent/', id) "assignFullUrl";
}

group BuildProcedureBase(source qr : QR, target r : Procedure, target entry) {
  qr -> r then SetResponseProvenance(qr, r) "responseProvenance";
  qr -> r.id = uuid() then SetProcedureFullUrl(r, entry) "idAndFullUrl";
  qr -> entry.request as request then {
    qr -> request.method = 'POST' "requestMethod";
    qr -> request.url = 'Procedure' "requestUrl";
  } "entryRequest";
  // The response's own time, as a floor, the way BuildObsBase does it. A rule
  // that reads a time off the form overwrites this; without it a procedure whose
  // date column was taken off on review has no time at all, and a procedure with
  // no time cannot be ordered against the rest of the admission.
  qr.authored as t -> r.occurrence = t "occurrenceFallback";
  qr.subject as s -> r.subject = s;
}

group SetProcedureFullUrl(source r : Procedure, target entry) {
  r.id as id -> entry.fullUrl = append('https://fhir.slade360.co.ke/fhir/Procedure/', id) "assignFullUrl";
}

// ── Provenance and tenancy ───────────────────────────────────────────────────
// Two tags on everything this map creates. The first says which questionnaire
// produced it, so a form that reopens mid-admission recalls its own earlier
// entries and not another form's. The second copies the tenant tags off the
// response, because nothing else on the path puts them there.
// The code is the form's document type, not the questionnaire's id: every
// environment mints its own ids, and there is only one set of maps, so an id
// here would tie the tag to whichever environment stamped it.
// ── Provenance and tenancy ───────────────────────────────────────────────────
group SetResponseProvenance(source qr : QR, target r) {
  qr -> r.meta as m then {
    qr -> m.tag as t then {
      qr -> t.system = 'http://slade360edi.com/questionnaire-provenance' "provenanceSystem";
      qr -> t.code = 'blood-donor-questionnaire' "provenanceCode";
      qr -> t.display = 'Blood donor questionnaire' "provenanceDisplay";
    } "provenanceTag";
  } "provenanceMeta";
  // Every tag the response carries, onto the resource. `meta` is 0..1, so this
  // lands on the same meta the rule above created rather than a second one.
  qr.meta as qm then {
    qm.tag as qt ->  r.meta as m,  m.tag = qt "copyTag";
  } "tenantTags";
}


Source1

{
  "resourceType": "StructureMap",
  "id": "ExtractBloodDonorQuestionnaire",
  "text": {
    "status": "generated",
    "div": "<!-- snip (see above) -->"
  },
  "url": "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractBloodDonorQuestionnaire",
  "version": "0.1.0",
  "name": "ExtractBloodDonorQuestionnaire",
  "title": "Blood Donor Questionnaire Extraction",
  "status": "active",
  "date": "2026-09-11T12:18:36+00:00",
  "publisher": "Kathurima Kimathi",
  "contact": [
    {
      "name": "Kathurima Kimathi",
      "telecom": [
        {
          "system": "url",
          "value": "https://www.linkedin.com/in/kathurima-kimathi/"
        },
        {
          "system": "email",
          "value": "kathurimakimathi415@gmail.com"
        }
      ]
    },
    {
      "name": "Oscar John",
      "telecom": [
        {
          "system": "email",
          "value": "oscarjohnotieno@gmail.com",
          "use": "work"
        }
      ]
    },
    {
      "name": "Kennedy Omondi",
      "telecom": [
        {
          "system": "email",
          "value": "kennankole@gmail.com",
          "use": "work"
        }
      ]
    }
  ],
  "description": "The KTTA donor form out as: one Observation carrying the thirteen deferral questions as components, because eligibility is a judgement over the whole set; the screening measurements each as their own Observation, so a haemoglobin below the 12.5 g/dL line is findable by its LOINC code; the eligibility decision as its own Observation with an abnormal interpretation when the donor was deferred, and the reason beside it; a Consent from the signed declaration, with the research opt-in as a second provision because it is a separate question the form asks separately; a Procedure for the collection itself; and one Observation carrying the nine post-donation adverse events.",
  "structure": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/QuestionnaireResponse",
      "mode": "source",
      "alias": "QR"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Bundle",
      "mode": "target",
      "alias": "Bundle"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Observation",
      "mode": "target",
      "alias": "Observation"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Consent",
      "mode": "target",
      "alias": "Consent"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/Procedure",
      "mode": "target",
      "alias": "Procedure"
    }
  ],
  "group": [
    {
      "name": "ExtractBloodDonorQuestionnaire",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "bundle",
          "type": "Bundle",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "setBundleType",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "bundle",
              "element": "type",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "transaction"
                }
              ]
            }
          ]
        },
        {
          "name": "eligibilityPanel",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'eligibility') and item.answer.value.exists()"
            }
          ],
          "target": [
            {
              "context": "bundle",
              "element": "entry",
              "variable": "entry"
            },
            {
              "context": "entry",
              "element": "resource",
              "variable": "obs",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Observation"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "base",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "obs"
                },
                {
                  "context": "entry"
                }
              ],
              "dependent": [
                {
                  "name": "BuildObsBase",
                  "parameter": [
                    {
                      "valueId": "qr"
                    },
                    {
                      "valueId": "obs"
                    },
                    {
                      "valueId": "entry"
                    }
                  ]
                }
              ]
            },
            {
              "name": "category",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "obs"
                }
              ],
              "dependent": [
                {
                  "name": "SetSurveyCategory",
                  "parameter": [
                    {
                      "valueId": "qr"
                    },
                    {
                      "valueId": "obs"
                    }
                  ]
                }
              ]
            },
            {
              "name": "code",
              "source": [
                {
                  "context": "g"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "code",
                  "variable": "cc"
                }
              ],
              "rule": [
                {
                  "name": "coding",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "coding",
                      "variable": "cg"
                    }
                  ],
                  "rule": [
                    {
                      "name": "sys",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "system",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "cd",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "code",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "donor-eligibility-question"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Donor eligibility question"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "codeText",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "KTTA donor eligibility questionnaire"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_feeling_well_today",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/feeling-well-today') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-feeling-well-today"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Feeling well today"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_eaten_in_the_last_6_hours",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/eaten-in-last-6-hours') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-eaten-in-the-last-6-hours"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Eaten in the last 6 hours"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_fainted_within_the_past_one_year",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/fainted-in-past-year') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-fainted-within-the-past-one-year"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Fainted within the past one year"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_pregnant_or_lactating",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/pregnant-or-lactating') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-pregnant-or-lactating"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Pregnant or lactating"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_travelled_in_the_last_14_days_outside_the_usual_area",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/travelled-in-last-14-days') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-travelled-in-the-last-14-days-outside-the-usual-area"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Travelled in the last 14 days outside the usual area of residence"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_on_regular_medication_antibiotics_or_analgesics",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/regular-medication') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-on-regular-medication-antibiotics-or-analgesics"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "On regular medication, antibiotics or analgesics"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_tattooing_or_body_piercing_in_the_last_3_months",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/tattoo-or-piercing-3-months') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-tattooing-or-body-piercing-in-the-last-3-months"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Tattooing or body piercing in the last 3 months"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_sexual_activity_in_the_last_3_months_with_a_person",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/sexual-activity-unknown-status') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-sexual-activity-in-the-last-3-months-with-a-person"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Sexual activity in the last 3 months with a person of unknown health status"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_vaccination_in_the_last_3_months",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/vaccination-3-months') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-vaccination-in-the-last-3-months"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Vaccination in the last 3 months"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_surgery_or_medical_treatment_in_the_past_6_months",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/surgery-or-treatment-6-months') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-surgery-or-medical-treatment-in-the-past-6-months"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Surgery or medical treatment in the past 6 months"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_received_blood_or_blood_products_in_the_past_6",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/received-blood-6-months') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-received-blood-or-blood-products-in-the-past-6"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Received blood or blood products in the past 6 months"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_ever_had_hepatitis_or_yellow_eyes",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/hepatitis-or-yellow-eyes') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-ever-had-hepatitis-or-yellow-eyes"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Ever had hepatitis or yellow eyes"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_q_exposed_to_a_suspected_case_of_covid_19_in_the_last",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'eligibility/covid-exposure-14-days') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-q-exposed-to-a-suspected-case-of-covid-19-in-the-last"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Exposed to a suspected case of COVID-19 in the last 14 days"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The thirteen deferral questions, as one panel ───────────────────────\r\nEligibility is decided by reading all thirteen together, so they travel\r\ntogether. A single \"yes\" to any of several of them defers the donor, and a\r\nreviewer has to be able to see which."
        },
        {
          "name": "screeningGroup",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'screening'"
            }
          ],
          "rule": [
            {
              "name": "measure_29463_7",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/weight') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetVitalSignsCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "29463-7"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Body weight"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measure_718_7",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/haemoglobin') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetLaboratoryCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "718-7"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Hemoglobin [Mass/volume] in Blood"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "note",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "note",
                      "variable": "n"
                    },
                    {
                      "context": "n",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "The KTTA form prints the acceptance threshold on the line: over 12.5 g/dL."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measure_8867_4",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/pulse') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetVitalSignsCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "8867-4"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Heart rate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measure_8310_5",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/temperature') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetVitalSignsCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "8310-5"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Body temperature"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "screeningBloodPressure",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "bpS",
                  "condition": "(linkId = 'screening/systolic') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetVitalSignsCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "bpS"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "bpS"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "bpS"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "bpS"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "85354-9"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "bpS"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Blood pressure panel with all children optional"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "comp_8480_6",
                  "source": [
                    {
                      "context": "g",
                      "element": "item",
                      "variable": "it",
                      "condition": "(linkId = 'screening/systolic') and answer.value.exists()"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "component",
                      "variable": "comp"
                    }
                  ],
                  "rule": [
                    {
                      "name": "code",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp",
                          "element": "code",
                          "variable": "cc"
                        }
                      ],
                      "rule": [
                        {
                          "name": "coding",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "coding",
                              "variable": "cg"
                            }
                          ],
                          "rule": [
                            {
                              "name": "sys",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "cd",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "8480-6"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "dsp",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Systolic blood pressure"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "value",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetComponentValue",
                          "parameter": [
                            {
                              "valueId": "it"
                            },
                            {
                              "valueId": "comp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "comp_8462_4",
                  "source": [
                    {
                      "context": "g",
                      "element": "item",
                      "variable": "it",
                      "condition": "(linkId = 'screening/diastolic') and answer.value.exists()"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "component",
                      "variable": "comp"
                    }
                  ],
                  "rule": [
                    {
                      "name": "code",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp",
                          "element": "code",
                          "variable": "cc"
                        }
                      ],
                      "rule": [
                        {
                          "name": "coding",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "coding",
                              "variable": "cg"
                            }
                          ],
                          "rule": [
                            {
                              "name": "sys",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://loinc.org"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "cd",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "8462-4"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "dsp",
                              "source": [
                                {
                                  "context": "it"
                                }
                              ],
                              "target": [
                                {
                                  "context": "cg",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Diastolic blood pressure"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "value",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "comp"
                        }
                      ],
                      "dependent": [
                        {
                          "name": "SetComponentValue",
                          "parameter": [
                            {
                              "valueId": "it"
                            },
                            {
                              "valueId": "comp"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "eligibilityObservation",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/eligible') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetSurveyCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-eligible"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Donor is eligible"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "codedValue",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "cv"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "variable": "vc",
                          "transform": "create",
                          "parameter": [
                            {
                              "valueString": "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule": [
                        {
                          "name": "valueCoding",
                          "source": [
                            {
                              "context": "cv"
                            }
                          ],
                          "target": [
                            {
                              "context": "vc",
                              "element": "coding",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "cv"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "valueText",
                          "source": [
                            {
                              "context": "cv",
                              "element": "display",
                              "variable": "d"
                            }
                          ],
                          "target": [
                            {
                              "context": "vc",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "eligibilityInterpretation",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "deferredInterp",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "cv",
                          "condition": "code = 'N'"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "interpretation",
                          "variable": "interp"
                        }
                      ],
                      "rule": [
                        {
                          "name": "coding",
                          "source": [
                            {
                              "context": "cv"
                            }
                          ],
                          "target": [
                            {
                              "context": "interp",
                              "element": "coding",
                              "variable": "icg"
                            }
                          ],
                          "rule": [
                            {
                              "name": "sys",
                              "source": [
                                {
                                  "context": "cv"
                                }
                              ],
                              "target": [
                                {
                                  "context": "icg",
                                  "element": "system",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "http://terminology.hl7.org/CodeSystem/v3-ObservationInterpretation"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "cd",
                              "source": [
                                {
                                  "context": "cv"
                                }
                              ],
                              "target": [
                                {
                                  "context": "icg",
                                  "element": "code",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "A"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "name": "dsp",
                              "source": [
                                {
                                  "context": "cv"
                                }
                              ],
                              "target": [
                                {
                                  "context": "icg",
                                  "element": "display",
                                  "transform": "copy",
                                  "parameter": [
                                    {
                                      "valueString": "Abnormal"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "deferralReasonRule",
                  "source": [
                    {
                      "context": "g",
                      "element": "item",
                      "variable": "dr",
                      "condition": "(linkId = 'screening/deferral-reason') and answer.value.exists()"
                    }
                  ],
                  "rule": [
                    {
                      "name": "answer",
                      "source": [
                        {
                          "context": "dr",
                          "element": "answer",
                          "listMode": "first",
                          "variable": "da"
                        }
                      ],
                      "rule": [
                        {
                          "name": "deferralReasonNote",
                          "source": [
                            {
                              "context": "da",
                              "element": "value",
                              "variable": "txt"
                            }
                          ],
                          "target": [
                            {
                              "context": "obs",
                              "element": "note",
                              "variable": "n"
                            },
                            {
                              "context": "n",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "txt"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "documentation": "The deferral reason travels on the same Observation. A deferral without\r\na reason cannot be reviewed, and the questionnaire only asks for the\r\nreason when the answer was no -- so this rule fires only then too."
                }
              ],
              "documentation": "── The eligibility decision ──────────────────────────────────────────\r\nIts own Observation with an interpretation, because this is the finding\r\nthe whole form exists to produce, and a blood bank filters on it."
            },
            {
              "name": "coded_donor_type",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/donor-type') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetSurveyCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-type"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Type of donor"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "codedValue",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "cv"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "variable": "cc",
                          "transform": "create",
                          "parameter": [
                            {
                              "valueString": "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule": [
                        {
                          "name": "valueCoding",
                          "source": [
                            {
                              "context": "cv"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "coding",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "cv"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "valueText",
                          "source": [
                            {
                              "context": "cv",
                              "element": "display",
                              "variable": "d"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "coded_donation_type",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'screening/donation-type') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetSurveyCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donation-type"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Type of donation"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "codedValue",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "cv"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "variable": "cc",
                          "transform": "create",
                          "parameter": [
                            {
                              "valueString": "CodeableConcept"
                            }
                          ]
                        }
                      ],
                      "rule": [
                        {
                          "name": "valueCoding",
                          "source": [
                            {
                              "context": "cv"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "coding",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "cv"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "valueText",
                          "source": [
                            {
                              "context": "cv",
                              "element": "display",
                              "variable": "d"
                            }
                          ],
                          "target": [
                            {
                              "context": "cc",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Screening measurements ──────────────────────────────────────────────"
        },
        {
          "name": "declarationGroup",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'declaration'"
            }
          ],
          "rule": [
            {
              "name": "createConsent",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'declaration/signed') and (answer.value = true)"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "consent",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Consent"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildConsentBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "consent"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "status",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "status",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "active"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "category",
                      "variable": "cat"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cat",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://loinc.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "64293-4"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Procedure consent Document"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "categoryText",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cat",
                          "element": "text",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "KTTA blood donor declaration and consent"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "decision",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "decision",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "permit"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "grantee",
                  "source": [
                    {
                      "context": "qr",
                      "element": "source",
                      "variable": "src"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "grantee",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueId": "src"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "signedOnRule",
                  "source": [
                    {
                      "context": "g",
                      "element": "item",
                      "variable": "dt",
                      "condition": "(linkId = 'declaration/signed-on') and answer.value.exists()"
                    }
                  ],
                  "rule": [
                    {
                      "name": "answer",
                      "source": [
                        {
                          "context": "dt",
                          "element": "answer",
                          "listMode": "first",
                          "variable": "a"
                        }
                      ],
                      "rule": [
                        {
                          "name": "signedDate",
                          "source": [
                            {
                              "context": "a",
                              "element": "value",
                              "variable": "d"
                            }
                          ],
                          "target": [
                            {
                              "context": "consent",
                              "element": "date",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "declarationNote",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "provision",
                      "variable": "prov"
                    },
                    {
                      "context": "prov",
                      "element": "code",
                      "variable": "pc"
                    },
                    {
                      "context": "pc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "The donor signed the KTTA declaration: that the form was filled truthfully, that they consent to give blood, that the donation will be screened for HIV, hepatitis B and C and syphilis, and that a reactive result will be communicated to them with counselling offered."
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "researchProvision",
                  "source": [
                    {
                      "context": "g",
                      "element": "item",
                      "variable": "ru",
                      "condition": "(linkId = 'declaration/research-use') and (answer.value.ofType(Coding).code = 'Y')"
                    }
                  ],
                  "target": [
                    {
                      "context": "consent",
                      "element": "provision",
                      "variable": "prov"
                    }
                  ],
                  "rule": [
                    {
                      "name": "purpose",
                      "source": [
                        {
                          "context": "ru"
                        }
                      ],
                      "target": [
                        {
                          "context": "prov",
                          "element": "purpose",
                          "variable": "pur"
                        }
                      ],
                      "rule": [
                        {
                          "name": "purposeSystem",
                          "source": [
                            {
                              "context": "ru"
                            }
                          ],
                          "target": [
                            {
                              "context": "pur",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://terminology.hl7.org/CodeSystem/v3-ActReason"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "purposeCode",
                          "source": [
                            {
                              "context": "ru"
                            }
                          ],
                          "target": [
                            {
                              "context": "pur",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "HRESCH"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "purposeDisplay",
                          "source": [
                            {
                              "context": "ru"
                            }
                          ],
                          "target": [
                            {
                              "context": "pur",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "healthcare research"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ],
                  "documentation": "The research opt-in, as its own provision."
                }
              ]
            }
          ],
          "documentation": "── The declaration and consent ─────────────────────────────────────────\r\nTwo provisions on one Consent, not two Consents. The donor signed one form,\r\nand the research opt-in is a checkbox inside it -- but it is a *separate*\r\npermission and the form prints its own yes and no boxes, so it cannot be\r\ninferred from the signature. Where the donor did not answer it, no\r\nprovision is written, which reads as \"not asked\" rather than \"declined\"."
        },
        {
          "name": "donationProcedure",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'donation') and item.where(linkId = 'donation/volume').answer.value.exists()"
            }
          ],
          "target": [
            {
              "context": "bundle",
              "element": "entry",
              "variable": "entry"
            },
            {
              "context": "entry",
              "element": "resource",
              "variable": "proc",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Procedure"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "base",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "proc"
                },
                {
                  "context": "entry"
                }
              ],
              "dependent": [
                {
                  "name": "BuildProcedureBase",
                  "parameter": [
                    {
                      "valueId": "qr"
                    },
                    {
                      "valueId": "proc"
                    },
                    {
                      "valueId": "entry"
                    }
                  ]
                }
              ]
            },
            {
              "name": "status",
              "source": [
                {
                  "context": "g"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "status",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "completed"
                    }
                  ]
                }
              ]
            },
            {
              "name": "code",
              "source": [
                {
                  "context": "g"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "code",
                  "variable": "cc"
                }
              ],
              "rule": [
                {
                  "name": "coding",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "coding",
                      "variable": "cg"
                    }
                  ],
                  "rule": [
                    {
                      "name": "sys",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "system",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "cd",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "code",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "blood-donation"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Blood donation"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "occurrence",
              "source": [
                {
                  "context": "qr",
                  "element": "authored",
                  "variable": "t"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "occurrence",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "t"
                    }
                  ]
                }
              ]
            },
            {
              "name": "encounter",
              "source": [
                {
                  "context": "qr",
                  "element": "encounter",
                  "variable": "e"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "encounter",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "e"
                    }
                  ]
                }
              ]
            },
            {
              "name": "performer",
              "source": [
                {
                  "context": "qr",
                  "element": "source",
                  "variable": "src"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "performer",
                  "variable": "p"
                },
                {
                  "context": "p",
                  "element": "actor",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "src"
                    }
                  ]
                }
              ]
            },
            {
              "name": "bagTypeRule",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "bt",
                  "condition": "(linkId = 'donation/bag-type') and answer.value.exists()"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "bt",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "bagTypeNote",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "txt"
                        }
                      ],
                      "target": [
                        {
                          "context": "proc",
                          "element": "note",
                          "variable": "n"
                        },
                        {
                          "context": "n",
                          "element": "text",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "txt"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The donation itself ─────────────────────────────────────────────────\r\nA Procedure. `status = 'completed'` only when a volume was actually taken:\r\na form filled in for a donor who was then deferred records no collection,\r\nand a completed Procedure would say blood was drawn that never was."
        },
        {
          "name": "volumeGroup",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'donation'"
            }
          ],
          "rule": [
            {
              "name": "measure_volume_donated",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/volume') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetProcedureCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "volume-donated"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Volume donated"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "adverseEventPanel",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'donation') and item.answer.value.ofType(Coding).exists()"
            }
          ],
          "target": [
            {
              "context": "bundle",
              "element": "entry",
              "variable": "entry"
            },
            {
              "context": "entry",
              "element": "resource",
              "variable": "obs",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Observation"
                }
              ]
            }
          ],
          "rule": [
            {
              "name": "base",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "obs"
                },
                {
                  "context": "entry"
                }
              ],
              "dependent": [
                {
                  "name": "BuildObsBase",
                  "parameter": [
                    {
                      "valueId": "qr"
                    },
                    {
                      "valueId": "obs"
                    },
                    {
                      "valueId": "entry"
                    }
                  ]
                }
              ]
            },
            {
              "name": "category",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "obs"
                }
              ],
              "dependent": [
                {
                  "name": "SetSurveyCategory",
                  "parameter": [
                    {
                      "valueId": "qr"
                    },
                    {
                      "valueId": "obs"
                    }
                  ]
                }
              ]
            },
            {
              "name": "code",
              "source": [
                {
                  "context": "g"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "code",
                  "variable": "cc"
                }
              ],
              "rule": [
                {
                  "name": "coding",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "coding",
                      "variable": "cg"
                    }
                  ],
                  "rule": [
                    {
                      "name": "sys",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "system",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "cd",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "code",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "donation-adverse-event"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Post-donation adverse event"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_underweight_unit",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/underweight-unit') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-underweight-unit"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Underweight unit"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_more_than_one_venipuncture",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/more-than-one-venipuncture') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-more-than-one-venipuncture"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "More than one venipuncture"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_haematoma",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/haematoma') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-haematoma"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Haematoma"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_fainting",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/fainting') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-fainting"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Fainting"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_nausea",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/nausea') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-nausea"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Nausea"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_vomiting",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/vomiting') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-vomiting"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Vomiting"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_headache",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/headache') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-headache"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Headache"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_convulsion",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/convulsion') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-convulsion"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Convulsion"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_donor_ae_incontinence_of_urine_or_stool",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donation/incontinence') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "component",
                  "variable": "comp"
                }
              ],
              "rule": [
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "donor-ae-incontinence-of-urine-or-stool"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Incontinence of urine or stool"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Post-donation adverse events ────────────────────────────────────────\r\nOne panel. Nine questions the KTTA form asks after every donation, and the\r\nset is the haemovigilance record: a donation with no events recorded and a\r\ndonation where nobody asked look identical unless the panel exists."
        },
        {
          "name": "donorGroup",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'donor'"
            }
          ],
          "rule": [
            {
              "name": "measure_previous_donation_count",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'donor/previous-donations') and answer.value.exists()"
                }
              ],
              "target": [
                {
                  "context": "bundle",
                  "element": "entry",
                  "variable": "entry"
                },
                {
                  "context": "entry",
                  "element": "resource",
                  "variable": "obs",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "base",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    },
                    {
                      "context": "entry"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "BuildObsBase",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        },
                        {
                          "valueId": "entry"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "category",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetSurveyCategory",
                      "parameter": [
                        {
                          "valueId": "qr"
                        },
                        {
                          "valueId": "obs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "code",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "code",
                      "variable": "cc"
                    }
                  ],
                  "rule": [
                    {
                      "name": "coding",
                      "source": [
                        {
                          "context": "it"
                        }
                      ],
                      "target": [
                        {
                          "context": "cc",
                          "element": "coding",
                          "variable": "cg"
                        }
                      ],
                      "rule": [
                        {
                          "name": "sys",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "cd",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "previous-donation-count"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Number of previous donations"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "set",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "v"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── Previous donations ──────────────────────────────────────────────────"
        }
      ]
    },
    {
      "name": "BuildObsBase",
      "documentation": "─────────────────────────────────────────────────────────────────────────────\r\nShared scaffolding. Repeated in each map rather than imported: the transform\r\nengine resolves `imports` against whatever StructureMaps happen to be on the\r\nserver, and a form that stops extracting because a shared map was not\r\nuploaded is a worse failure than a duplicated group.\r\nTwo notes on what the publisher's StructureMap validator says about this file.\r\nSource parameters below are left untyped on purpose. Writing `: Element` makes\r\nthe validator compare QuestionnaireResponse.item against the literal 'Element'\r\nand report them as incompatible with each other, which is noise, not a finding.\r\n`evaluate(context, expression)` is flagged as \"takes 1 parameter but 2 were\r\nfound\". Leave it. The FML parser in the same jar refuses the one-argument form\r\noutright -- it wants a parameter, a comma, then the FHIRPath -- so the\r\npublisher is objecting to what its own compiler emits. Two arguments is the\r\nonly form that compiles, and it is what the R5 transform engine executes.\r\n─────────────────────────────────────────────────────────────────────────────",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "responseProvenance",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs"
            }
          ],
          "dependent": [
            {
              "name": "SetResponseProvenance",
              "parameter": [
                {
                  "valueId": "qr"
                },
                {
                  "valueId": "obs"
                }
              ]
            }
          ]
        },
        {
          "name": "idAndFullUrl",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "id",
              "transform": "uuid"
            }
          ],
          "dependent": [
            {
              "name": "SetObservationFullUrl",
              "parameter": [
                {
                  "valueId": "obs"
                },
                {
                  "valueId": "entry"
                }
              ]
            }
          ]
        },
        {
          "name": "entryRequest",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "request",
              "variable": "request"
            }
          ],
          "rule": [
            {
              "name": "requestMethod",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "method",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "POST"
                    }
                  ]
                }
              ]
            },
            {
              "name": "requestUrl",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "url",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "Observation"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "status",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "status",
              "transform": "copy",
              "parameter": [
                {
                  "valueString": "final"
                }
              ]
            }
          ]
        },
        {
          "name": "subject",
          "source": [
            {
              "context": "qr",
              "element": "subject",
              "variable": "s"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "subject",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "s"
                }
              ]
            }
          ]
        },
        {
          "name": "encounter",
          "source": [
            {
              "context": "qr",
              "element": "encounter",
              "variable": "e"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "encounter",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "e"
                }
              ]
            }
          ]
        },
        {
          "name": "effective",
          "source": [
            {
              "context": "qr",
              "element": "authored",
              "variable": "t"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "effective",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "t"
                }
              ]
            }
          ]
        },
        {
          "name": "performerFromSource",
          "source": [
            {
              "context": "qr",
              "element": "source",
              "variable": "src"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "performer",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "src"
                }
              ]
            }
          ]
        },
        {
          "name": "performerFallback",
          "source": [
            {
              "context": "qr",
              "condition": "source.exists().not()"
            }
          ],
          "rule": [
            {
              "name": "performerFromAuthor",
              "source": [
                {
                  "context": "qr",
                  "element": "author",
                  "variable": "a"
                }
              ],
              "target": [
                {
                  "context": "obs",
                  "element": "performer",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "a"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "linkQuestionnaireResponse",
          "source": [
            {
              "context": "qr",
              "element": "id",
              "variable": "qid",
              "condition": "$this.hasValue()"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "derivedFrom",
              "variable": "ref",
              "transform": "create",
              "parameter": [
                {
                  "valueString": "Reference"
                }
              ]
            },
            {
              "context": "ref",
              "element": "reference",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "qid"
                }
              ]
            }
          ],
          "documentation": "A stored response's id already reads \"QuestionnaireResponse/<id>\", so it is\r\na relative reference as it stands. The hasValue() guard is what stops an\r\nunsaved response -- one posted straight to $extract rather than saved first\r\n-- from writing \"QuestionnaireResponse/null\" into the record."
        }
      ]
    },
    {
      "name": "SetObservationFullUrl",
      "input": [
        {
          "name": "obs",
          "type": "Observation",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "obs",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/Observation/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetComponentCodedValue",
      "documentation": "The two answer shapes a component can carry. Both read the answer through the\r\nuntyped `.value` accessor: reading `valueCoding` or `valueQuantity` by its\r\ntyped property name fails at transform time on HAPI R5 with \"Attempt to read\r\ninvalid property ... on QuestionnaireResponse.item.answer\".",
      "input": [
        {
          "name": "it",
          "mode": "source"
        },
        {
          "name": "comp",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "componentAnswer",
          "source": [
            {
              "context": "it",
              "element": "answer",
              "listMode": "first",
              "variable": "a"
            }
          ],
          "rule": [
            {
              "name": "codedValue",
              "source": [
                {
                  "context": "a",
                  "element": "value",
                  "variable": "cv"
                }
              ],
              "target": [
                {
                  "context": "comp",
                  "element": "value",
                  "variable": "cc",
                  "transform": "create",
                  "parameter": [
                    {
                      "valueString": "CodeableConcept"
                    }
                  ]
                }
              ],
              "rule": [
                {
                  "name": "valueCoding",
                  "source": [
                    {
                      "context": "cv"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "coding",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueId": "cv"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "valueText",
                  "source": [
                    {
                      "context": "cv",
                      "element": "display",
                      "variable": "d"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueId": "d"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetComponentValue",
      "input": [
        {
          "name": "it",
          "mode": "source"
        },
        {
          "name": "comp",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "componentAnswer",
          "source": [
            {
              "context": "it",
              "element": "answer",
              "listMode": "first",
              "variable": "a"
            }
          ],
          "rule": [
            {
              "name": "plainValue",
              "source": [
                {
                  "context": "a",
                  "element": "value",
                  "variable": "v"
                }
              ],
              "target": [
                {
                  "context": "comp",
                  "element": "value",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "v"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetSurveyCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "survey"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Survey"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetVitalSignsCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "vital-signs"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Vital Signs"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetLaboratoryCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "laboratory"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Laboratory"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetProcedureCategory",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "obs",
          "type": "Observation",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "category",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "obs",
              "element": "category",
              "variable": "cat"
            }
          ],
          "rule": [
            {
              "name": "categoryCoding",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "cat",
                  "element": "coding",
                  "variable": "coding"
                }
              ],
              "rule": [
                {
                  "name": "categorySystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://terminology.hl7.org/CodeSystem/observation-category"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "procedure"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "categoryDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "coding",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Procedure"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "BuildConsentBase",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "r",
          "type": "Consent",
          "mode": "target"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "responseProvenance",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "r"
            }
          ],
          "dependent": [
            {
              "name": "SetResponseProvenance",
              "parameter": [
                {
                  "valueId": "qr"
                },
                {
                  "valueId": "r"
                }
              ]
            }
          ]
        },
        {
          "name": "idAndFullUrl",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "id",
              "transform": "uuid"
            }
          ],
          "dependent": [
            {
              "name": "SetConsentFullUrl",
              "parameter": [
                {
                  "valueId": "r"
                },
                {
                  "valueId": "entry"
                }
              ]
            }
          ]
        },
        {
          "name": "entryRequest",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "request",
              "variable": "request"
            }
          ],
          "rule": [
            {
              "name": "requestMethod",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "method",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "POST"
                    }
                  ]
                }
              ]
            },
            {
              "name": "requestUrl",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "url",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "Consent"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "subject",
          "source": [
            {
              "context": "qr",
              "element": "subject",
              "variable": "s"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "subject",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "s"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetConsentFullUrl",
      "input": [
        {
          "name": "r",
          "type": "Consent",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "r",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/Consent/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "BuildProcedureBase",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "r",
          "type": "Procedure",
          "mode": "target"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "responseProvenance",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "r"
            }
          ],
          "dependent": [
            {
              "name": "SetResponseProvenance",
              "parameter": [
                {
                  "valueId": "qr"
                },
                {
                  "valueId": "r"
                }
              ]
            }
          ]
        },
        {
          "name": "idAndFullUrl",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "id",
              "transform": "uuid"
            }
          ],
          "dependent": [
            {
              "name": "SetProcedureFullUrl",
              "parameter": [
                {
                  "valueId": "r"
                },
                {
                  "valueId": "entry"
                }
              ]
            }
          ]
        },
        {
          "name": "entryRequest",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "request",
              "variable": "request"
            }
          ],
          "rule": [
            {
              "name": "requestMethod",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "method",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "POST"
                    }
                  ]
                }
              ]
            },
            {
              "name": "requestUrl",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "request",
                  "element": "url",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueString": "Procedure"
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "occurrenceFallback",
          "source": [
            {
              "context": "qr",
              "element": "authored",
              "variable": "t"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "occurrence",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "t"
                }
              ]
            }
          ],
          "documentation": "The response's own time, as a floor, the way BuildObsBase does it. A rule\r\nthat reads a time off the form overwrites this; without it a procedure whose\r\ndate column was taken off on review has no time at all, and a procedure with\r\nno time cannot be ordered against the rest of the admission."
        },
        {
          "name": "subject",
          "source": [
            {
              "context": "qr",
              "element": "subject",
              "variable": "s"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "subject",
              "transform": "copy",
              "parameter": [
                {
                  "valueId": "s"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetProcedureFullUrl",
      "input": [
        {
          "name": "r",
          "type": "Procedure",
          "mode": "source"
        },
        {
          "name": "entry",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "assignFullUrl",
          "source": [
            {
              "context": "r",
              "element": "id",
              "variable": "id"
            }
          ],
          "target": [
            {
              "context": "entry",
              "element": "fullUrl",
              "transform": "append",
              "parameter": [
                {
                  "valueString": "https://fhir.slade360.co.ke/fhir/Procedure/"
                },
                {
                  "valueId": "id"
                }
              ]
            }
          ]
        }
      ]
    },
    {
      "name": "SetResponseProvenance",
      "documentation": "── Provenance and tenancy ───────────────────────────────────────────────────\r\nTwo tags on everything this map creates. The first says which questionnaire\r\nproduced it, so a form that reopens mid-admission recalls its own earlier\r\nentries and not another form's. The second copies the tenant tags off the\r\nresponse, because nothing else on the path puts them there.\r\nThe code is the form's document type, not the questionnaire's id: every\r\nenvironment mints its own ids, and there is only one set of maps, so an id\r\nhere would tie the tag to whichever environment stamped it.\r\n── Provenance and tenancy ───────────────────────────────────────────────────",
      "input": [
        {
          "name": "qr",
          "type": "QR",
          "mode": "source"
        },
        {
          "name": "r",
          "mode": "target"
        }
      ],
      "rule": [
        {
          "name": "provenanceMeta",
          "source": [
            {
              "context": "qr"
            }
          ],
          "target": [
            {
              "context": "r",
              "element": "meta",
              "variable": "m"
            }
          ],
          "rule": [
            {
              "name": "provenanceTag",
              "source": [
                {
                  "context": "qr"
                }
              ],
              "target": [
                {
                  "context": "m",
                  "element": "tag",
                  "variable": "t"
                }
              ],
              "rule": [
                {
                  "name": "provenanceSystem",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "t",
                      "element": "system",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "http://slade360edi.com/questionnaire-provenance"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "provenanceCode",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "t",
                      "element": "code",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "blood-donor-questionnaire"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "provenanceDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "t",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Blood donor questionnaire"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "name": "tenantTags",
          "source": [
            {
              "context": "qr",
              "element": "meta",
              "variable": "qm"
            }
          ],
          "rule": [
            {
              "name": "copyTag",
              "source": [
                {
                  "context": "qm",
                  "element": "tag",
                  "variable": "qt"
                }
              ],
              "target": [
                {
                  "context": "r",
                  "element": "meta",
                  "variable": "m"
                },
                {
                  "context": "m",
                  "element": "tag",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "qt"
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "Every tag the response carries, onto the resource. `meta` is 0..1, so this\r\nlands on the same meta the rule above created rather than a second one."
        }
      ]
    }
  ]
}