Social Care Interoperability Platform FHIR Implementation Guide
Version: 0.1.0, Status: draft

Social Care Interoperability Platform FHIR Implementation Guide - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

StructureMap: AllergyToAllergyIntelorance

Official URL: https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureMap/Allergy-AllergyIntelorance Version: 0.1.0
Draft as of 2026-06-10 Computable Name: AllergyToAllergyIntelorance

map "https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureMap/Allergy-AllergyIntelorance" = "AllergyToAllergyIntelorance"

uses "https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/MODS-Allergy" alias Allergy as source
uses "https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/MODS-AllergyIntolerance" alias AllergyIntolerance as target

group AllergyIntelorance(source src : Allergy, target tgt : AllergyIntolerance) {
  src -> tgt.id = evaluate(src, id) "setAllergyInteloranceId";
  src ->  tgt.meta as meta,  meta.tag as tag then {
    src -> tag.system = 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/CodeSystem/MODS-FhirStructureMapCatalog-1' "0cddd506-f4ad-44fd-a615-d4bdfd0d90a0";
    src -> tag.code = 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureMap/AllergyIntolerance-Allergy' "c86b31d7-4ae3-468c-acd3-881658908857";
  } "setMetaTag";
  src.type as type then {
    src -> src.allergyType = create('Coding') as allergyType then {
      src -> allergyType.code = evaluate(type, code) "3eb287e2-be03-40d0-ab0e-949faa382e7c";
      src -> allergyType.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/type-of-reaction' "d4789746-13da-4621-b353-212c3f91e864";
      src -> tgt.type = translate(allergyType, 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/ConceptMap/MODS-FHIRAllergyIntoleranceType-1', 'code') "549c4647-ae3c-42e8-b08e-d0e91653ee43";
    } "cbb0c55a-2da5-4e14-8b18-bbffcf76c6b2";
  } "setAllergyIntoleranceType";
  src.causativeAgent as causativeAgent then {
    src -> tgt.code = cc('http://snomed.info/sct', '', '') as vcc then {
      vcc.coding as coding then {
        vcc -> coding.code = evaluate(causativeAgent, code) "6693f82d-5491-4d90-ab47-ba6fd4b4e8a4";
        vcc -> coding.display = evaluate(causativeAgent, display) "2b9ef0dc-47ad-47b6-ae70-909a50db9a63";
      };
    } "818c31e6-39d8-4e54-ba53-95eadea3799d";
  } "setAllergyCode";
  src.subjectOfCare as subjectOfCare then {
    src -> tgt.patient as patient then {
      src -> patient.reference = evaluate(subjectOfCare, 'Patient/'+id) "18930ca9-653d-4bda-9a72-286a6024311d";
      src -> patient.display = evaluate(subjectOfCare, display) "c8d7f473-0583-44d1-ae45-da3ae8a23bf7";
    } "85608c74-6bec-4d9b-89d0-599325b3d080";
  } "setAllergyPatient";
  src.observer as observer then {
    src -> tgt.recorder as recorder then {
      src -> recorder.reference = evaluate(observer, 'Practitioner/'+id) "31530357-c42a-43b7-9e6d-1b86aa36061b";
      src -> recorder.display = evaluate(observer, display) "d2b98ecf-c394-4b7d-9f9f-99ee351187e3";
    } "450a4378-d1b6-4212-8dd4-0614ef469954";
  } "setAllergyRecorder";
  src -> src.onsetPeriod as period then {
    src.firstExperienced as start then {
      src -> period.start = evaluate(src, firstExperienced) "02371aa5-4d45-40d3-9ae3-cdb6f68b2b1b";
    };
    src.endDate as end then {
      src -> period.end = evaluate(src, endDate) "b4d7facb-9ade-4bc8-a6ba-0f488c9d1866";
    };
    period where $this.start.empty().not()or$this.end.empty().not() -> tgt.onsetPeriod "a532a305-26d5-4164-b824-9fe68c63739c";
  } "setAllergyOnsetPeriod";
  src.comment as comment -> tgt.note as note then {
    src -> note.text = evaluate(src, comment) "486d3c2f-36bc-4955-a434-cde5274983d0";
  } "setAllergyCommentNote";
  src.evidence as evidence -> tgt.note as note then {
    src -> note.text = evaluate(src, evidence) "034331a8-7002-489c-aef1-216f2040348a";
  } "setAllergyEvidenceNote";
  src.reaction as allergyReaction -> tgt.reaction as reaction then {
    allergyReaction.substance as substance then {
      src -> reaction.substance = cc('http://snomed.info/sct', '', '') as vcc then {
        vcc.coding as coding then {
          src -> coding.code = evaluate(substance, code) "f29553cb-3356-47f4-adbe-6db5a86ba143";
          src -> coding.display = evaluate(substance, display) "b55899dd-ef86-42e0-be02-ce623fa8600f";
        };
      } "setReactionSubstance";
      allergyReaction.description as description then {
        src -> reaction.manifestation = cc('http://snomed.info/sct', '', '') as vcc then {
          vcc.coding as coding then {
            src -> coding.code = evaluate(description, code) "2a29a76e-7acd-4ec3-8d84-9d5c149b905f";
            src -> coding.display = evaluate(description, display) "48c14339-442d-4b74-af03-0b92af912688";
          };
        } "setReactionManifestation";
        allergyReaction.route as route then {
          src -> reaction.exposureRoute = cc('http://snomed.info/sct', '', '') as vcc then {
            vcc.coding as coding then {
              src -> coding.code = evaluate(route, code) "c8d26798-5f6b-405f-b01a-582ef07b3dfc";
              src -> coding.display = evaluate(route, display) "f0de28d0-4ebf-4007-a6fe-135433df06b4";
            };
          } "setReactionRoute";
          allergyReaction.severity as severity then {
            src -> reaction.severity = evaluate(severity, code) "0609a717-13f2-4080-b332-44e65a84ae44";
          } "setReactionSeverity";
        } "setAllergyReaction";
      };
    };
  };
}