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

FHIR IG analytics

Packagesilfhirprofileig
Resource TypeStructureMap
IdStructureMap-ExtractHaemodialysisSession.json
FHIR VersionR5
Sourcehttps://build.fhir.org/ig/savannahghi/sil_fhir_profile_ig/StructureMap-ExtractHaemodialysisSession.html
URLhttps://fhir.slade360.co.ke/fhir/StructureMap/ExtractHaemodialysisSession
Version0.1.0
Statusactive
Date2026-09-11T12:18:36+00:00
NameExtractHaemodialysisSession
TitleHaemodialysis Session Extraction
DescriptionOne dialysis session out as: a Procedure for the session itself, coded to SNOMED 302497006, with the treatment time as its period and the access as a note; the pre-, target and post-dialysis weights each as their own Observation, because the nephrologist reads them against each other over weeks; the fluid actually removed as its own Observation; the prescription and the machine's function check as two panels, because neither of their parts means anything alone; and one Observation per timed reading through the run, each keeping the reading's own time, since the flow chart is a time series and the circuit pressures are what a run is judged on.

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 ExtractHaemodialysisSession

/// url = 'https://fhir.slade360.co.ke/fhir/StructureMap/ExtractHaemodialysisSession'
/// name = 'ExtractHaemodialysisSession'
/// title = 'Haemodialysis Session Extraction'
/// status = 'active'
/// description = 'One dialysis session out as: a Procedure for the session itself, coded to SNOMED 302497006, with the treatment time as its period and the access as a note; the pre-, target and post-dialysis weights each as their own Observation, because the nephrologist reads them against each other over weeks; the fluid actually removed as its own Observation; the prescription and the machine\'s function check as two panels, because neither of their parts means anything alone; and one Observation per timed reading through the run, each keeping the reading\'s own time, since the flow chart is a time series and the circuit pressures are what a run is judged on.'

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/Procedure" alias Procedure as target

group ExtractHaemodialysisSession(source qr : QR, target bundle : Bundle) {
  qr -> bundle.type = 'transaction' "setBundleType";
  // ── The session, as a Procedure ─────────────────────────────────────────
  // SNOMED 302497006, haemodialysis, checked against tx.fhir.org. The access
  // is a note rather than Procedure.usedCode: usedCode wants a device, and
  // "arteriovenous fistula" is an anatomical route, not a device the unit
  // issued.
  qr.item as g where (linkId = 'session') ->  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 = 'http://snomed.info/sct' "sys";
        g -> cg.code = '302497006' "cd";
        g -> cg.display = 'Haemodialysis' "dsp";
      } "coding";
    } "code";
    qr.encounter as e -> proc.encounter = e;
    g.item as d where ((linkId = 'session/date') and answer.value.exists()) then {
      d.answer first as a then {
        a.value as t -> proc.occurrence = t "occurrence";
      };
    } "dateRule";
    g.item as ph where ((linkId = 'session/physician') and answer.value.exists()) then {
      ph.answer first as a then {
        a.value as ref ->  proc.performer as p,  p.actor = ref "physician";
      };
    } "physicianRule";
    g.item as ac where ((linkId = 'session/access') and answer.value.exists()) then {
      ac.answer first as a then {
        a.value as cv then {
          cv.display as d ->  proc.note as n,  n.text = d "accessNote";
        } "display";
      };
    } "accessRule";
    g.item as tn where ((linkId = 'session/treatment-number') and answer.value.exists()) then {
      tn.answer first as a then {
        a.value as txt -> proc.identifier as ident then {
          txt -> ident.system = 'https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem' "identSystem";
          txt -> ident.value = txt "identValue";
        } "identifier";
      };
    } "treatmentNumberRule";
    // The nurses who started and finished the run. Both, because a run handed
    // over mid-session is exactly the case where knowing who did what matters.
    qr.item as tg where (linkId = 'timing') then {
      tg.item as nc where ((linkId = 'timing/nurse-commencing') and answer.value.exists()) then {
        nc.answer first as a then {
          a.value as ref ->  proc.performer as p,  p.actor = ref "nurseCommencing";
        };
      } "nurseCommencingRule";
      tg.item as nt where ((linkId = 'timing/nurse-terminating') and answer.value.exists()) then {
        nt.answer first as a then {
          a.value as ref ->  proc.performer as p,  p.actor = ref "nurseTerminating";
        };
      } "nurseTerminatingRule";
    } "timingGroup";
  } "dialysisProcedure";
  // ── The weights ─────────────────────────────────────────────────────────
  // Pre and post are both LOINC 29463-7 body weight, so each carries a note
  // saying which it is: without that a query for the patient's weight on the
  // day of dialysis returns two numbers with no way to tell them apart.
  qr.item as g where (linkId = 'weights') then {
    g.item as it where ((linkId = 'weights/pre-dialysis') 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";
      };
      it ->  obs.note as n,  n.text = 'Taken before the dialysis session.' "note";
    } "measure_29463_7";
    g.item as it where ((linkId = 'weights/post-dialysis') 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";
      };
      it ->  obs.note as n,  n.text = 'Taken after the dialysis session.' "note";
    } "measure_29463_72";
    g.item as it where ((linkId = 'weights/target') 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 = 'dialysis-target-weight' "cd";
          it -> cg.display = 'Target weight' "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 dry weight the session was aiming for.' "note";
    } "measure_fluid_removed";
    g.item as it where ((linkId = 'weights/fluid-lost') 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 = 'fluid-removed' "cd";
          it -> cg.display = 'Fluid removed' "dsp";
        } "coding";
      } "code";
      it.answer first as a then {
        a.value as v -> obs.value = create('Quantity') as q then {
          v -> q.value = v "qValue";
          v -> q.unit = 'kg' "qUnit";
          v -> q.system = 'http://unitsofmeasure.org' "qSystem";
          v -> q.code = 'kg' "qCode";
        } "quantity";
      };
      it ->  obs.note as n,  n.text = 'The difference between the pre- and post-dialysis weights, which is the fluid actually taken off. The unit is attached by the extraction map.' "note";
    } "measureq_fluid_removed";
  } "weightsGroup";
  // ── The prescription, as one panel ──────────────────────────────────────
  // Five components on one Observation. A treatment time without its dialyser,
  // bath potassium and heparinisation is not a prescription, and splitting them
  // would let one be changed without the others being reviewed.
  qr.item as g where ((linkId = 'prescription') 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 SetProcedureCategory(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 = 'dialysis-prescription' "cd";
        g -> cg.display = 'Dialysis prescription' "dsp";
      } "coding";
    } "code";
    g.item as it where ((linkId = 'prescription/treatment-time') 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 = 'dialysis-treatment-time' "cd";
          it -> cg.display = 'Treatment time' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_treatment_time";
    g.item as it where ((linkId = 'prescription/prime') 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 = 'dialysis-prime' "cd";
          it -> cg.display = 'Prime' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_prime";
    g.item as it where ((linkId = 'prescription/dialyser') 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 = 'dialysis-dialyser' "cd";
          it -> cg.display = 'Dialyser' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_dialyser";
    g.item as it where ((linkId = 'prescription/bath-potassium') 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 = 'dialysis-bath-k-plus' "cd";
          it -> cg.display = 'Bath K+' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_bath_k_plus";
    g.item as it where ((linkId = 'prescription/heparin-loading-dose') 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 = 'dialysis-heparin-loading-dose' "cd";
          it -> cg.display = 'Heparin loading dose' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_heparin_loading_dose";
    g.item as it where ((linkId = 'prescription/heparin-hourly') 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 = 'dialysis-heparin-units-per-hour' "cd";
          it -> cg.display = 'Heparin units per hour' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_heparin_units_per_hour";
  } "prescriptionPanel";
  // ── The machine's own function check ────────────────────────────────────
  // A panel, and one that is about the machine rather than the patient. It is
  // still an Observation on the patient's record: it is the evidence that the
  // machine the patient was put on had passed its self-test, which is what a
  // review after an adverse event asks for.
  qr.item as g where ((linkId = 'machine-check') 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 SetProcedureCategory(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 = 'machine-function-check' "cd";
        g -> cg.display = 'Machine function check' "dsp";
      } "coding";
    } "code";
    g.item as it where ((linkId = 'machine-check/t1-test-passed') 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 = 'machine-t1-test-passed' "cd";
          it -> cg.display = 'T1 test passed' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentCodedValue(it, comp) "value";
    } "comp_machine_t1_test_passed";
    g.item as it where ((linkId = 'machine-check/temperature') 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 = 'machine-temperature' "cd";
          it -> cg.display = 'Machine temperature' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_machine_temperature";
    g.item as it where ((linkId = 'machine-check/conductivity') 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 = 'machine-conductivity' "cd";
          it -> cg.display = 'Conductivity' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_machine_conductivity";
    g.item as it where ((linkId = 'machine-check/dialyser-flow-rate') 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 = 'machine-dialyser-flow-rate' "cd";
          it -> cg.display = 'Dialyser flow rate' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_machine_dialyser_flow_rate";
  } "machineCheckPanel";
  // ── The virology screen ─────────────────────────────────────────────────
  // A laboratory panel. The unit records HIV, HBsAg and HCV status on every
  // flow chart because a positive donor changes which machine and which bay the
  // patient uses, so it belongs on the session record and not only in the lab.
  qr.item as g where ((linkId = 'virology-screen') 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 SetLaboratoryCategory(qr, obs) "category";
    g -> obs.code as cc then {
      g -> cc.coding as cg then {
        g -> cg.system = 'http://loinc.org' "sys";
        g -> cg.code = '11502-2' "cd";
        g -> cg.display = 'Laboratory report' "dsp";
      } "coding";
      g -> cc.text = 'Virology screen for dialysis' "codeText";
    } "code";
    g.item as it where ((linkId = 'virology-screen/hiv') 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 = 'dialysis-hiv' "cd";
          it -> cg.display = 'HIV' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_hiv";
    g.item as it where ((linkId = 'virology-screen/hbsag') 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 = 'dialysis-hbs-ag' "cd";
          it -> cg.display = 'HBs Ag' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_hbs_ag";
    g.item as it where ((linkId = 'virology-screen/hcv') 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 = 'dialysis-hcv' "cd";
          it -> cg.display = 'HCV' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_hcv";
  } "virologyPanel";
  // ── The readings through the run ────────────────────────────────────────
  // One Observation per row of the flow chart. The circuit pressures are
  // deliberately coded to local concepts and not to the blood pressure LOINC
  // codes: arterial and venous pressure on an extracorporeal circuit are
  // machine readings on tubing, and coding them as the patient's arterial
  // pressure would put a figure of -180 mmHg into a vital signs chart.
  qr.item as g where ((linkId = 'reading') 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 SetProcedureCategory(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 = 'dialysis-session-reading' "cd";
        g -> cg.display = 'Dialysis session reading' "dsp";
      } "coding";
      g -> cc.text = 'Reading taken during the dialysis run' "codeText";
    } "code";
    g.item as it where ((linkId = 'reading/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 = 'reading/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";
    g.item as it where ((linkId = 'reading/pulse') 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 = '8867-4' "cd";
          it -> cg.display = 'Heart rate' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_8867_4";
    g.item as it where ((linkId = 'reading/blood-pump-rate') 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 = 'blood-pump-rate' "cd";
          it -> cg.display = 'Blood pump rate' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_blood_pump_rate";
    g.item as it where ((linkId = 'reading/transmembrane-pressure') 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 = 'transmembrane-pressure' "cd";
          it -> cg.display = 'Transmembrane pressure' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_transmembrane_pressure";
    g.item as it where ((linkId = 'reading/ultrafiltration') 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 = 'ultrafiltration-volume' "cd";
          it -> cg.display = 'Ultrafiltration volume' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_ultrafiltration_volume";
    g.item as it where ((linkId = 'reading/arterial-pressure') 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 = 'arterial-pressure-circuit' "cd";
          it -> cg.display = 'Arterial pressure (extracorporeal circuit)' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_arterial_pressure_circuit";
    g.item as it where ((linkId = 'reading/venous-pressure') 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 = 'venous-pressure-circuit' "cd";
          it -> cg.display = 'Venous pressure (extracorporeal circuit)' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_venous_pressure_circuit";
    g.item as it where ((linkId = 'reading/heparin') 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 = 'dialysis-heparin-given' "cd";
          it -> cg.display = 'Heparin given' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_heparin_given";
    g.item as it where ((linkId = 'reading/clotting-time') 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 = 'dialysis-clotting-time' "cd";
          it -> cg.display = 'Clotting time' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_clotting_time";
    g.item as it where ((linkId = 'reading/fluid') 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 = 'dialysis-fluid' "cd";
          it -> cg.display = 'Fluid' "dsp";
        } "coding";
      } "code";
      it -> comp then SetComponentValue(it, comp) "value";
    } "comp_dialysis_fluid";
    g.item as it where (linkId = 'reading/comments') then {
      it.answer first as a then {
        a.value as txt ->  obs.note as n,  n.text = txt "text";
      };
    } "note";
  } "runReading";
}

// ─────────────────────────────────────────────────────────────────────────────
// 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 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 = 'haemodialysis-session-record' "provenanceCode";
      qr -> t.display = 'Haemodialysis session record' "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": "ExtractHaemodialysisSession",
  "text": {
    "status": "generated",
    "div": "<!-- snip (see above) -->"
  },
  "url": "https://fhir.slade360.co.ke/fhir/StructureMap/ExtractHaemodialysisSession",
  "version": "0.1.0",
  "name": "ExtractHaemodialysisSession",
  "title": "Haemodialysis Session 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": "One dialysis session out as: a Procedure for the session itself, coded to SNOMED 302497006, with the treatment time as its period and the access as a note; the pre-, target and post-dialysis weights each as their own Observation, because the nephrologist reads them against each other over weeks; the fluid actually removed as its own Observation; the prescription and the machine's function check as two panels, because neither of their parts means anything alone; and one Observation per timed reading through the run, each keeping the reading's own time, since the flow chart is a time series and the circuit pressures are what a run is judged on.",
  "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/Procedure",
      "mode": "target",
      "alias": "Procedure"
    }
  ],
  "group": [
    {
      "name": "ExtractHaemodialysisSession",
      "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": "dialysisProcedure",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'session'"
            }
          ],
          "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": "http://snomed.info/sct"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "cd",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "code",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "302497006"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Haemodialysis"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "encounter",
              "source": [
                {
                  "context": "qr",
                  "element": "encounter",
                  "variable": "e"
                }
              ],
              "target": [
                {
                  "context": "proc",
                  "element": "encounter",
                  "transform": "copy",
                  "parameter": [
                    {
                      "valueId": "e"
                    }
                  ]
                }
              ]
            },
            {
              "name": "dateRule",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "d",
                  "condition": "(linkId = 'session/date') and answer.value.exists()"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "d",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "occurrence",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "t"
                        }
                      ],
                      "target": [
                        {
                          "context": "proc",
                          "element": "occurrence",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "t"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "physicianRule",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "ph",
                  "condition": "(linkId = 'session/physician') and answer.value.exists()"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "ph",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "physician",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "ref"
                        }
                      ],
                      "target": [
                        {
                          "context": "proc",
                          "element": "performer",
                          "variable": "p"
                        },
                        {
                          "context": "p",
                          "element": "actor",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "ref"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "accessRule",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "ac",
                  "condition": "(linkId = 'session/access') and answer.value.exists()"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "ac",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "display",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "cv"
                        }
                      ],
                      "rule": [
                        {
                          "name": "accessNote",
                          "source": [
                            {
                              "context": "cv",
                              "element": "display",
                              "variable": "d"
                            }
                          ],
                          "target": [
                            {
                              "context": "proc",
                              "element": "note",
                              "variable": "n"
                            },
                            {
                              "context": "n",
                              "element": "text",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "d"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "treatmentNumberRule",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "tn",
                  "condition": "(linkId = 'session/treatment-number') and answer.value.exists()"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "tn",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "identifier",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "txt"
                        }
                      ],
                      "target": [
                        {
                          "context": "proc",
                          "element": "identifier",
                          "variable": "ident"
                        }
                      ],
                      "rule": [
                        {
                          "name": "identSystem",
                          "source": [
                            {
                              "context": "txt"
                            }
                          ],
                          "target": [
                            {
                              "context": "ident",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "https://fhir.slade360.co.ke/fhir/CodeSystem/concept-codesystem"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "identValue",
                          "source": [
                            {
                              "context": "txt"
                            }
                          ],
                          "target": [
                            {
                              "context": "ident",
                              "element": "value",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "txt"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "timingGroup",
              "source": [
                {
                  "context": "qr",
                  "element": "item",
                  "variable": "tg",
                  "condition": "linkId = 'timing'"
                }
              ],
              "rule": [
                {
                  "name": "nurseCommencingRule",
                  "source": [
                    {
                      "context": "tg",
                      "element": "item",
                      "variable": "nc",
                      "condition": "(linkId = 'timing/nurse-commencing') and answer.value.exists()"
                    }
                  ],
                  "rule": [
                    {
                      "name": "answer",
                      "source": [
                        {
                          "context": "nc",
                          "element": "answer",
                          "listMode": "first",
                          "variable": "a"
                        }
                      ],
                      "rule": [
                        {
                          "name": "nurseCommencing",
                          "source": [
                            {
                              "context": "a",
                              "element": "value",
                              "variable": "ref"
                            }
                          ],
                          "target": [
                            {
                              "context": "proc",
                              "element": "performer",
                              "variable": "p"
                            },
                            {
                              "context": "p",
                              "element": "actor",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "ref"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "nurseTerminatingRule",
                  "source": [
                    {
                      "context": "tg",
                      "element": "item",
                      "variable": "nt",
                      "condition": "(linkId = 'timing/nurse-terminating') and answer.value.exists()"
                    }
                  ],
                  "rule": [
                    {
                      "name": "answer",
                      "source": [
                        {
                          "context": "nt",
                          "element": "answer",
                          "listMode": "first",
                          "variable": "a"
                        }
                      ],
                      "rule": [
                        {
                          "name": "nurseTerminating",
                          "source": [
                            {
                              "context": "a",
                              "element": "value",
                              "variable": "ref"
                            }
                          ],
                          "target": [
                            {
                              "context": "proc",
                              "element": "performer",
                              "variable": "p"
                            },
                            {
                              "context": "p",
                              "element": "actor",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "ref"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ],
              "documentation": "The nurses who started and finished the run. Both, because a run handed\r\nover mid-session is exactly the case where knowing who did what matters."
            }
          ],
          "documentation": "── The session, as a Procedure ─────────────────────────────────────────\r\nSNOMED 302497006, haemodialysis, checked against tx.fhir.org. The access\r\nis a note rather than Procedure.usedCode: usedCode wants a device, and\r\n\"arteriovenous fistula\" is an anatomical route, not a device the unit\r\nissued."
        },
        {
          "name": "weightsGroup",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "linkId = 'weights'"
            }
          ],
          "rule": [
            {
              "name": "measure_29463_7",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'weights/pre-dialysis') 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": "note",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "note",
                      "variable": "n"
                    },
                    {
                      "context": "n",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Taken before the dialysis session."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measure_29463_72",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'weights/post-dialysis') 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": "note",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "note",
                      "variable": "n"
                    },
                    {
                      "context": "n",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Taken after the dialysis session."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measure_fluid_removed",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'weights/target') 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": "dialysis-target-weight"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Target 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": "note",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "note",
                      "variable": "n"
                    },
                    {
                      "context": "n",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "The dry weight the session was aiming for."
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "measureq_fluid_removed",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'weights/fluid-lost') 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": "fluid-removed"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Fluid removed"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "quantity",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "v"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "value",
                          "variable": "q",
                          "transform": "create",
                          "parameter": [
                            {
                              "valueString": "Quantity"
                            }
                          ]
                        }
                      ],
                      "rule": [
                        {
                          "name": "qValue",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "q",
                              "element": "value",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueId": "v"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "qUnit",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "q",
                              "element": "unit",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "kg"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "qSystem",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "q",
                              "element": "system",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "http://unitsofmeasure.org"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "qCode",
                          "source": [
                            {
                              "context": "v"
                            }
                          ],
                          "target": [
                            {
                              "context": "q",
                              "element": "code",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "kg"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "note",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "obs",
                      "element": "note",
                      "variable": "n"
                    },
                    {
                      "context": "n",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "The difference between the pre- and post-dialysis weights, which is the fluid actually taken off. The unit is attached by the extraction map."
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The weights ─────────────────────────────────────────────────────────\r\nPre and post are both LOINC 29463-7 body weight, so each carries a note\r\nsaying which it is: without that a query for the patient's weight on the\r\nday of dialysis returns two numbers with no way to tell them apart."
        },
        {
          "name": "prescriptionPanel",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'prescription') 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": "SetProcedureCategory",
                  "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": "dialysis-prescription"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Dialysis prescription"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_treatment_time",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/treatment-time') 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": "dialysis-treatment-time"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Treatment time"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_prime",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/prime') 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": "dialysis-prime"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Prime"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_dialyser",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/dialyser') 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": "dialysis-dialyser"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Dialyser"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_bath_k_plus",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/bath-potassium') 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": "dialysis-bath-k-plus"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Bath K+"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_heparin_loading_dose",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/heparin-loading-dose') 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": "dialysis-heparin-loading-dose"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Heparin loading dose"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_heparin_units_per_hour",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'prescription/heparin-hourly') 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": "dialysis-heparin-units-per-hour"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Heparin units per hour"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The prescription, as one panel ──────────────────────────────────────\r\nFive components on one Observation. A treatment time without its dialyser,\r\nbath potassium and heparinisation is not a prescription, and splitting them\r\nwould let one be changed without the others being reviewed."
        },
        {
          "name": "machineCheckPanel",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'machine-check') 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": "SetProcedureCategory",
                  "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": "machine-function-check"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Machine function check"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_machine_t1_test_passed",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'machine-check/t1-test-passed') 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": "machine-t1-test-passed"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "T1 test passed"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentCodedValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_machine_temperature",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'machine-check/temperature') 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": "machine-temperature"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Machine temperature"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_machine_conductivity",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'machine-check/conductivity') 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": "machine-conductivity"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Conductivity"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_machine_dialyser_flow_rate",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'machine-check/dialyser-flow-rate') 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": "machine-dialyser-flow-rate"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Dialyser flow rate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The machine's own function check ────────────────────────────────────\r\nA panel, and one that is about the machine rather than the patient. It is\r\nstill an Observation on the patient's record: it is the evidence that the\r\nmachine the patient was put on had passed its self-test, which is what a\r\nreview after an adverse event asks for."
        },
        {
          "name": "virologyPanel",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'virology-screen') 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": "SetLaboratoryCategory",
                  "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": "http://loinc.org"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "cd",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "code",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "11502-2"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Laboratory report"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "codeText",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Virology screen for dialysis"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_hiv",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'virology-screen/hiv') 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": "dialysis-hiv"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "HIV"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_hbs_ag",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'virology-screen/hbsag') 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": "dialysis-hbs-ag"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "HBs Ag"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_hcv",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'virology-screen/hcv') 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": "dialysis-hcv"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "HCV"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The virology screen ─────────────────────────────────────────────────\r\nA laboratory panel. The unit records HIV, HBsAg and HCV status on every\r\nflow chart because a positive donor changes which machine and which bay the\r\npatient uses, so it belongs on the session record and not only in the lab."
        },
        {
          "name": "runReading",
          "source": [
            {
              "context": "qr",
              "element": "item",
              "variable": "g",
              "condition": "(linkId = 'reading') 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": "SetProcedureCategory",
                  "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": "dialysis-session-reading"
                            }
                          ]
                        }
                      ]
                    },
                    {
                      "name": "dsp",
                      "source": [
                        {
                          "context": "g"
                        }
                      ],
                      "target": [
                        {
                          "context": "cg",
                          "element": "display",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueString": "Dialysis session reading"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "codeText",
                  "source": [
                    {
                      "context": "g"
                    }
                  ],
                  "target": [
                    {
                      "context": "cc",
                      "element": "text",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Reading taken during the dialysis run"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_8480_6",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/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 = 'reading/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": "comp_8867_4",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/pulse') 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": "8867-4"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Heart rate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_blood_pump_rate",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/blood-pump-rate') 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": "blood-pump-rate"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Blood pump rate"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_transmembrane_pressure",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/transmembrane-pressure') 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": "transmembrane-pressure"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Transmembrane pressure"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_ultrafiltration_volume",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/ultrafiltration') 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": "ultrafiltration-volume"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Ultrafiltration volume"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_arterial_pressure_circuit",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/arterial-pressure') 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": "arterial-pressure-circuit"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Arterial pressure (extracorporeal circuit)"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_venous_pressure_circuit",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/venous-pressure') 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": "venous-pressure-circuit"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Venous pressure (extracorporeal circuit)"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_heparin_given",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/heparin') 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": "dialysis-heparin-given"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Heparin given"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_clotting_time",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/clotting-time') 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": "dialysis-clotting-time"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Clotting time"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "comp_dialysis_fluid",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "(linkId = 'reading/fluid') 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": "dialysis-fluid"
                                }
                              ]
                            }
                          ]
                        },
                        {
                          "name": "dsp",
                          "source": [
                            {
                              "context": "it"
                            }
                          ],
                          "target": [
                            {
                              "context": "cg",
                              "element": "display",
                              "transform": "copy",
                              "parameter": [
                                {
                                  "valueString": "Fluid"
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "value",
                  "source": [
                    {
                      "context": "it"
                    }
                  ],
                  "target": [
                    {
                      "context": "comp"
                    }
                  ],
                  "dependent": [
                    {
                      "name": "SetComponentValue",
                      "parameter": [
                        {
                          "valueId": "it"
                        },
                        {
                          "valueId": "comp"
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "name": "note",
              "source": [
                {
                  "context": "g",
                  "element": "item",
                  "variable": "it",
                  "condition": "linkId = 'reading/comments'"
                }
              ],
              "rule": [
                {
                  "name": "answer",
                  "source": [
                    {
                      "context": "it",
                      "element": "answer",
                      "listMode": "first",
                      "variable": "a"
                    }
                  ],
                  "rule": [
                    {
                      "name": "text",
                      "source": [
                        {
                          "context": "a",
                          "element": "value",
                          "variable": "txt"
                        }
                      ],
                      "target": [
                        {
                          "context": "obs",
                          "element": "note",
                          "variable": "n"
                        },
                        {
                          "context": "n",
                          "element": "text",
                          "transform": "copy",
                          "parameter": [
                            {
                              "valueId": "txt"
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ],
          "documentation": "── The readings through the run ────────────────────────────────────────\r\nOne Observation per row of the flow chart. The circuit pressures are\r\ndeliberately coded to local concepts and not to the blood pressure LOINC\r\ncodes: arterial and venous pressure on an extracorporeal circuit are\r\nmachine readings on tubing, and coding them as the patient's arterial\r\npressure would put a figure of -180 mmHg into a vital signs chart."
        }
      ]
    },
    {
      "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": "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": "haemodialysis-session-record"
                        }
                      ]
                    }
                  ]
                },
                {
                  "name": "provenanceDisplay",
                  "source": [
                    {
                      "context": "qr"
                    }
                  ],
                  "target": [
                    {
                      "context": "t",
                      "element": "display",
                      "transform": "copy",
                      "parameter": [
                        {
                          "valueString": "Haemodialysis session record"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "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."
        }
      ]
    }
  ]
}