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

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

map "https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureMap/Patient-SubjectOfCare" = "PatientToSubjectOfCare"

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

group SubjectOfCare(source src : Patient, target tgt : SubjectOfCare) {
  src -> tgt.id = evaluate(src, id) "c66cf2c2-6b72-4a79-981c-e6a89095ea63";
  "setSubjectOfCareId" "0e7d642f-99de-452a-8ee1-0ea80276fd98";
  src ->  tgt.meta as meta,  meta.dataClass as dataClass then {
    src -> dataClass.name = 'Subject of Care' "c06760d6-1e0f-4856-9e3a-9152a2773c21";
  } "setDataClassName";
  src -> tgt.name as name then {
    src.name as humanName then {
      src -> name.given = evaluate(humanName, given[0]) "4a1ccca6-9234-4341-96e9-c2eef09011b1";
      src -> name.family = evaluate(humanName, family) "a8f815be-17c5-4790-a8ae-d674308f9c30";
    } "setFamilyAndGivenName";
  } "setName";
  src -> tgt.identification as identification then {
    src -> identification.nhsNumber as nhsNumber then {
      src.identifier as nhsNumberIdentifier where $this.system='https://fhir.nhs.uk/Id/nhs-number', nhsNumberIdentifier.value as nhsNumberValue, nhsNumberIdentifier.extension as nhsNumberTraceStatusExt then {
        src -> nhsNumber.value = nhsNumberValue "4a690410-ebf4-41d6-9d9c-d02bfe1dee76";
        src -> nhsNumber.statusIndicator as statusIndicator then {
          src -> statusIndicator.system = 'https://fhir.hl7.org.uk/CodeSystem/UKCore-NHSNumberVerificationStatusEngland' "86c86497-cdb3-4823-9abe-d050ed0cf4b2";
          src -> statusIndicator.code = evaluate(nhsNumberTraceStatusExt, valueCodeableConcept.coding[0].code) "6a51a585-feca-4948-8f93-3039e07f2672";
          src -> statusIndicator.display = evaluate(nhsNumberTraceStatusExt, valueCodeableConcept.coding[0].display) "4625aed3-a671-4dc5-869d-7d7a69608f89";
        } "3fcd39a3-c71b-4bc8-b114-5d9b021973d3";
      } "identifier";
    } "setNHSNumber";
    src.identifier where $this.system!='https://fhir.nhs.uk/Id/nhs-number' -> identification.otherIdentifier "setOtherIdentifier";
  } "setIdentification";
  src -> tgt.demographics as demographics then {
    src -> demographics.dateOfBirth = evaluate(src, birthDate) "setDateOfBirth";
    src.extension as birthSexExt where $this.url='https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-BirthSex', birthSexExt.valueCodeableConcept as birthSex then {
      src -> demographics.sex = translate(birthSex, 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/ConceptMap/MODS-FHIRBirthSex-1', 'Coding') "61e5a895-40b5-4b92-8d47-34eb96423d2c";
    } "setBirthSex";
    src.maritalStatus as maritalStatusCodeableConcept then {
      src -> demographics.maritalStatus as maritalStatus then {
        src -> maritalStatus.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-marital-status' "c1ec6e18-bd08-49d7-a808-aab2536eed41";
        src -> maritalStatus.code = evaluate(maritalStatusCodeableConcept, coding.code) "db86c673-82b3-439d-bd8f-3dff3ff9370b";
        src -> maritalStatus.display = evaluate(maritalStatusCodeableConcept, coding.display) "602c9a7f-1feb-4245-a3f5-829e00abed7d";
      } "2f9e5d8d-ba6a-4cdc-8d10-23553929ea2a";
      "setMaritalStatusCoding" "1556374d-9558-4710-b905-c305c663a26f";
    } "setMaritalStatus";
    src.extension as ethnicityExt where $this.url='https://fhir.hl7.org.uk/StructureDefinition/Extension-UKCore-EthnicCategory', ethnicityExt.valueCodeableConcept as ethnicCategory then {
      src -> demographics.ethnicity as ethnicity then {
        src -> ethnicity.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-ethnicity' "f2aef129-7eab-4811-b8e1-6a11c37187ed";
        src -> ethnicity.code = evaluate(ethnicCategory, coding.code) "4946e946-d4f3-40b9-bb5b-605a11b34b2d";
        src -> ethnicity.display = evaluate(ethnicCategory, coding.display) "34a269ea-39c6-4f6c-8989-ae7a4f4b366d";
      } "setEthnicityCoding";
    } "setEthnicity";
    src.gender as genderCode then {
      src -> src.genderIdentity = create('Coding') as givt then {
        src -> givt.system = 'http://hl7.org/fhir/R4/codesystem-administrative-gender' "feff2a87-7577-4542-a7d2-2fef509a62d9";
        src -> givt.code = genderCode "06103916-4a7b-44c9-ba00-21329f651e35";
        src -> demographics.genderIdentity = translate(givt, 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/ConceptMap/MODS-FHIRGenderIdentity-1', 'Coding') "5cd67acf-f443-4850-99c3-afa9e31a78d6";
      } "6869dfdf-4c9f-4b48-86d7-1177e9b93a99";
    } "setGenderIdentity";
    src.extension as religionExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonReligiousAffiliation', religionExt.valueCodeableConcept as religiousAffiliation then {
      src -> demographics.religion as religion then {
        src -> religion.code = evaluate(religiousAffiliation, coding.code) "0b74dabf-ade3-4561-82bb-e436c4d52bc2";
        src -> religion.display = evaluate(religiousAffiliation, coding.display) "aa1aed26-8414-41af-964f-64f5b17acb81";
        src -> religion.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-religion' "3b8ba31a-92b1-4c59-bfd2-19c07d13a8fe";
      } "setReligionCoding";
    } "setReligion";
    src.communication as communication where $this.preferred=true, communication.language as language then {
      src -> demographics.firstLanguage as firstLanguage then {
        src -> firstLanguage.code = evaluate(language, coding.code) "9d79f305-7d62-442c-b598-50bfcfe7a7f5";
        src -> firstLanguage.display = evaluate(language, coding.display) "c1b09c2e-9d52-48c5-992c-51650c374f98";
        src -> firstLanguage.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-language' "b6af1291-c27a-46df-9756-6bb56547fb7d";
      } "5abc4b29-aa68-446c-a605-396ba21aba8b";
    } "setFirstLanguage";
    src.communication as communication where $this.preferred.exists().not()or$this.preferred=false, communication.language as language then {
      src -> demographics.otherLanguage as otherLanguage then {
        src -> otherLanguage.code = evaluate(language, coding.code) "1dedf159-473f-4d56-998d-57fcf5fd38f8";
        src -> otherLanguage.display = evaluate(language, coding.display) "f629e776-1ade-4fae-afe2-d76ccccb2dd2";
        src -> otherLanguage.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-language' "e6f5c525-0164-4061-a3af-9cb21463ab34";
      } "0d5e0967-a976-48d4-b2d9-ad622e7b76e3";
    } "setOtherLanguage";
    src.extension as interpreterRequiredExt where $this.url='http://hl7.org/fhir/StructureDefinition/patient-interpreterRequired' then {
      src -> demographics.interpreterRequired = evaluate(interpreterRequiredExt, iif(valueBoolean,'Yes','No')) "d51c64e4-18fd-4377-8595-5d0bd5c760e8";
    } "setInterpreterRequired";
    src.extension as sexualOrientationExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonSexualOrientation', sexualOrientationExt.valueCodeableConcept as sexualOrientation then {
      src -> demographics.sexualOrientation as orientation then {
        src -> orientation.code = evaluate(sexualOrientation, coding.code) "021c83b5-fdbe-420c-9d79-b00ab38346db";
        src -> orientation.display = evaluate(sexualOrientation, coding.display) "49f40765-57a7-45bd-b299-6bd657fbe0ed";
        src -> orientation.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-sexual-orientation' "b39f3f83-d49a-4b8d-8182-79c3302940ce";
      } "setSexualOrientationCoding";
    } "setSexualOrientation";
  } "setDemographics";
  src.address as address -> tgt.address as addr then {
    src -> addr.addressEntry1 = evaluate(address, line[0]) "02289e33-a82c-4990-80b8-4f566045efcf";
    src -> addr.addressEntry2 = evaluate(address, line[1]) "7f24b293-828b-4aab-ad30-c9b6fd338889";
    src -> addr.addressEntry3 = evaluate(address, line[2]) "c9b66cec-3e2a-4a6a-b01a-487524d0f3f8";
    src -> addr.addressEntry4 = evaluate(address, line[3]) "6b3ac813-4534-48f1-a9ce-68677f621b63";
    src -> addr.postCode = evaluate(address, postalCode) "59ba4040-24f5-45f2-bc27-f4e8a2ac9bed";
    address.extension as countryExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-AddressCountry' then {
      src -> addr.country as country then {
        src -> country.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/country' "6db5e0de-eee1-4bf5-8a9d-7ad8e183795e";
        src -> country.code = evaluate(countryExt, valueCoding.code) "44bbeec2-a0e2-4178-b88d-c357b4a8f74c";
        src -> country.display = evaluate(countryExt, valueCoding.display) "35722430-0aef-4c1f-b416-4101977f787d";
      } "b1ee2b77-2b06-41c9-9fef-9e4ac78eff58";
    };
  } "setAddress";
  src -> tgt.contactDetails as contactDetails then {
    src.telecom as emailAddress where $this.system='email' -> contactDetails.emailAddressDetails as emailAddressDetails then {
      src -> emailAddressDetails.emailAddress = evaluate(emailAddress, value) "1f7289a7-c715-4fb1-9468-242a579093da";
      src -> emailAddressDetails.preferredOrder = evaluate(emailAddress, rank) "977a024b-6a60-47d7-9b4e-cd03a8e48eeb";
      emailAddress.extension as emailAddressTypeExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonEmailAddressType' then {
        src -> emailAddressDetails.type as emailAddressType then {
          src -> emailAddressType.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-email-address-type' "55bb36cc-25af-46cd-8773-72d776b59895";
          src -> emailAddressType.code = evaluate(emailAddressTypeExt, valueCoding.code) "c98d8a8b-801d-49f5-bbd8-677c484c0552";
          src -> emailAddressType.display = evaluate(emailAddressTypeExt, valueCoding.display) "ae9f6fe6-432f-4aac-aaf2-5e72ad4fc63b";
        } "a4ee9209-ba8d-4338-b69b-2ef1458b6c54";
      };
    };
    src.telecom as telephoneNumber where $this.system='phone' -> contactDetails.telephoneDetails as telephoneNumberDetails then {
      src -> telephoneNumberDetails.telephoneNumber = evaluate(telephoneNumber, value) "68fdbaba-721d-4963-a64d-aba8e7d062f0";
      src -> telephoneNumberDetails.preferredOrder = evaluate(telephoneNumber, rank) "2dc43dec-453c-44a0-a6cd-9c38ee6bd34c";
      telephoneNumber.extension as telephoneNumberExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonTelephoneNumberType' then {
        src -> telephoneNumberDetails.type as telephoneNumberType then {
          src -> telephoneNumberType.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-telephone-type' "c30cf451-0007-4e76-ba62-0856e20da0a5";
          src -> telephoneNumberType.code = evaluate(telephoneNumberExt, valueCoding.code) "2bd7645a-a3f1-46b2-8fce-e7147a4ee1af";
          src -> telephoneNumberType.display = evaluate(telephoneNumberExt, valueCoding.display) "640cb434-f4f7-44ab-86ad-e93742ccc00f";
        } "0db14264-f5b0-4b42-bd02-be40e6e289b7";
      };
    };
  } "setContactDetails";
  src.extension as deathDetailsExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonDeathDetails' then {
    src -> tgt.deathDetails as deathDetails then {
      deathDetailsExt.extension as deathCauseIdentificationMethodExt where $this.url='deathCauseIdentificationMethod', deathCauseIdentificationMethodExt.valueCoding as deathCauseIdentificationMethodCoding then {
        src -> deathDetails.deathCauseIdentificationMethod as deathCauseIdentificationMethod then {
          src -> deathCauseIdentificationMethod.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-death-cause-identification-method' "c811e374-5f5c-4739-8176-41b1f0e35e54";
          src -> deathCauseIdentificationMethod.code = evaluate(deathCauseIdentificationMethodCoding, code) "44ab488a-a75d-49da-b38d-4e9b5cc32001";
          src -> deathCauseIdentificationMethod.display = evaluate(deathCauseIdentificationMethodCoding, display) "661e417d-0527-4f57-a41b-582af8712548";
        } "2871f366-37b0-4677-9137-dbe1dcc52b4b";
      } "setPersonDeathCauseIdentificationMethod";
      deathDetailsExt.extension as deathLocationTypeExt where $this.url='deathLocationType', deathLocationTypeExt.valueCoding as deathLocationTypeCoding then {
        src -> deathDetails.deathLocationType as deathLocationType then {
          src -> deathLocationType.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-death-location-type' "f6a34a25-ad37-457e-8e58-00a7610018eb";
          src -> deathLocationType.code = evaluate(deathLocationTypeCoding, code) "2a2fb69c-2a97-47f9-9087-45d4d55763b1";
          src -> deathLocationType.display = evaluate(deathLocationTypeCoding, display) "a7272273-9f1f-452b-a700-cf051eefd923";
        } "87255fe8-f3c2-40e7-b016-01179320328c";
      } "setPersonDeathLocationType";
      deathDetailsExt.extension as deathNotAtPreferredLocationReasonExt where $this.url='deathNotAtPreferredLocationReason', deathNotAtPreferredLocationReasonExt.valueCoding as deathNotAtPreferredLocationReasonCoding then {
        src -> deathDetails.deathNotAtPreferredLocationReason as deathNotAtPreferredLocationReason then {
          src -> deathNotAtPreferredLocationReason.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-death-not-at-preferred-location-reason-code' "eee09d78-ed02-4ccd-afc5-2b8a3a9e0c9b";
          src -> deathNotAtPreferredLocationReason.code = evaluate(deathNotAtPreferredLocationReasonCoding, code) "b2eb9c06-46e0-47a2-89b4-e5646b34b7d7";
          src -> deathNotAtPreferredLocationReason.display = evaluate(deathNotAtPreferredLocationReasonCoding, display) "37dec606-7bf1-422d-9569-d09415e9b8cb";
        } "476e8f58-1ba5-4189-9201-ec1ee398704e";
      } "setPersonDeathNotAtPreferredLocationReason";
      deathDetailsExt.extension as personAtRiskOfUnexpectedDeathExt where $this.url='personAtRiskOfUnexpectedDeath', personAtRiskOfUnexpectedDeathExt.valueCoding as personAtRiskOfUnexpectedDeathCoding then {
        src -> deathDetails.personAtRiskOfUnexpectedDeath as personAtRiskOfUnexpectedDeath then {
          src -> personAtRiskOfUnexpectedDeath.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-at-risk-of-unexpected-death-indicator' "26b41b83-166a-4433-a211-54a241583f85";
          src -> personAtRiskOfUnexpectedDeath.code = evaluate(personAtRiskOfUnexpectedDeathCoding, code) "29634ef8-3af2-4b9d-904c-454b2d6c11dc";
          src -> personAtRiskOfUnexpectedDeath.display = evaluate(personAtRiskOfUnexpectedDeathCoding, display) "cf5df9bd-c18f-4b51-bc56-703d665cc1a1";
        } "c9674054-550e-49ca-9410-34332b16ffce";
      } "setPersonAtRiskOfUnexpectedDeath";
      deathDetailsExt.extension as preferredLocationOfDeathDiscussedExt where $this.url='preferredLocationOfDeathDiscussed', preferredLocationOfDeathDiscussedExt.valueCoding as preferredLocationOfDeathDiscussedCoding then {
        src -> deathDetails.preferredDeathLocationDiscussed as preferredDeathLocationDiscussed then {
          src -> preferredDeathLocationDiscussed.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-death-location-discussed-indicator' "a68f0b8d-f98b-4188-b5d5-694d0b46b680";
          src -> preferredDeathLocationDiscussed.code = evaluate(preferredLocationOfDeathDiscussedCoding, code) "d9f86300-ae41-4c21-adaf-db98cc400f70";
          src -> preferredDeathLocationDiscussed.display = evaluate(preferredLocationOfDeathDiscussedCoding, display) "ee0c8209-aed1-457b-8717-0cfbea9d8117";
        } "9734c3f2-c6db-4320-bfa1-7a955c63e4a0";
      } "setPreferredLocationOfDeathDiscussed";
      deathDetailsExt.extension as personDateOfDeathExt where $this.url='personDateOfDeath' then {
        src -> deathDetails.personDeathDate = evaluate(personDateOfDeathExt, valueDate) "39e347e8-e68e-44df-a9b8-58ffd4e46dac";
      } "setPersonDeathTime";
      deathDetailsExt.extension as personTimeOfDeathExt where $this.url='personTimeOfDeath' then {
        src -> deathDetails.personDeathTime = evaluate(personTimeOfDeathExt, valueTime) "5d3ff058-09fe-4a28-992d-de898ac62fee";
      } "setPersonDeathTime";
    } "131a002c-3978-44b4-b2ff-2e3732a50f53";
  } "setDeathDetails";
  src.extension as careProviderExt where $this.url='https://metadata.phase2.scip.synanetics.cloud/fhir/r4/StructureDefinition/Extension-MODS-PersonCareProvider' -> tgt.careProvider as careProvider then {
    careProviderExt.valueReference as careProviderReference then {
      src -> careProvider.id = evaluate(careProviderReference, identifier.value) "0224d1f8-9b36-4a55-a062-ec734f1518bc";
      src -> careProvider.type = 'CareOrganisation' "5e0a0ef2-a049-4ab7-aaf9-4a66a8f052ad";
      src -> careProvider.display = evaluate(careProviderReference, display) "4a1e02bb-1205-4b57-9ccc-8ecb8a103e60";
    };
  } "setCareProvider";
  src.generalPractitioner as generalPractitioner, generalPractitioner.identifier as generalPractitionerIdentifier then {
    src -> tgt.generalPractice as generalPractice then {
      src -> generalPractice.id = evaluate(generalPractitionerIdentifier, value) "9492df72-288d-492e-83e0-941e210989ad";
      src -> generalPractice.type = 'CareOrganisation' "54cc2e4a-f32f-4cd8-b3c8-7cb9543b1b51";
      src -> generalPractice.display = evaluate(generalPractitioner, display) "e516fb92-5a5e-467d-8a40-78b629ce028d";
    } "6a180226-e50c-4f16-ab4c-ccae0e9faedb";
  } "setGeneralPractitioner";
}