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-03-24 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) "151e72fc-9cb8-4f02-84b3-1228d026033e";
  "setSubjectOfCareId" "bf3b89b6-d6de-44b9-8312-232ff9d202b8";
  src ->  tgt.meta as meta,  meta.dataClass as dataClass then {
    src -> dataClass.name = 'Subject of Care' "0732af00-5582-4eff-bfd9-f2b7354a3438";
  } "setDataClassName";
  src -> tgt.name as name then {
    src.name as humanName then {
      src -> name.given = evaluate(humanName, given[0]) "c1dd2823-0470-451d-9846-6c3e1f7dfb04";
      src -> name.family = evaluate(humanName, family) "3a5d78ac-bd46-4d13-a624-9f0ee429df68";
    } "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 "9aeb4c5c-ff43-4fc1-86c7-14790e7dcc52";
        src -> nhsNumber.statusIndicator as statusIndicator then {
          src -> statusIndicator.system = 'https://fhir.hl7.org.uk/CodeSystem/UKCore-NHSNumberVerificationStatusEngland' "15384b37-b8e8-4a6f-9595-e70a2eec1479";
          src -> statusIndicator.code = evaluate(nhsNumberTraceStatusExt, valueCodeableConcept.coding[0].code) "60146fef-d9e1-4289-972f-78b3f445a77a";
          src -> statusIndicator.display = evaluate(nhsNumberTraceStatusExt, valueCodeableConcept.coding[0].display) "1b6b4aaa-ceb5-4eae-97d9-018e676df272";
        } "c0469836-8323-4a43-99d1-b8bcabe26557";
      } "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') "707b2ba6-c4aa-4be0-aedc-04bcbad0713d";
    } "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' "7b9ed651-cea9-46b2-bc57-7264683bbe19";
        src -> maritalStatus.code = evaluate(maritalStatusCodeableConcept, coding.code) "a0ef89bb-7e8f-4db8-9df0-112743334a6f";
        src -> maritalStatus.display = evaluate(maritalStatusCodeableConcept, coding.display) "27c4c111-f8d3-421f-9178-9f4a77e6a7e0";
      } "b496a92b-22c1-4661-839a-97f184afd6d0";
      "setMaritalStatusCoding" "2c8166a7-0d1e-4fa1-9209-c76e68d91975";
    } "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' "3b37fb5e-2e83-4cce-8e65-5e4cc91e312b";
        src -> ethnicity.code = evaluate(ethnicCategory, coding.code) "68e82e0c-e728-4eab-973a-969cf226d0ec";
        src -> ethnicity.display = evaluate(ethnicCategory, coding.display) "b0446528-160e-4fca-bae4-af90163db1ef";
      } "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' "bca3b9da-1b57-4529-8bca-8a175a39a132";
        src -> givt.code = genderCode "d395d81e-e259-40d8-af72-9537e3e6bbd8";
        src -> demographics.genderIdentity = translate(givt, 'https://metadata.phase2.scip.synanetics.cloud/fhir/r4/ConceptMap/MODS-FHIRGenderIdentity-1', 'Coding') "b9de8d60-45a1-4e03-b8b9-1c516e2b6199";
      } "2a381668-3b86-4439-963d-83311f984f54";
    } "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) "88e490e7-3f31-430e-aab0-d76cba708ad1";
        src -> religion.display = evaluate(religiousAffiliation, coding.display) "06c9e054-6e71-48c3-9763-b02dbc6e7630";
        src -> religion.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-religion' "2af659f9-f1b6-4b6a-8cbc-188d4dc6830b";
      } "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) "21af66d5-46e6-400f-9443-ba8fc7b32b19";
        src -> firstLanguage.display = evaluate(language, coding.display) "47a5e1c7-8372-4af6-b13a-c69779fcc6da";
        src -> firstLanguage.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-language' "1d70b412-064e-4fd4-9748-fd9d86207d17";
      } "c6273fae-d859-43ae-94d6-93b77e72941b";
    } "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) "bbfa5d5a-bff6-4045-ab40-5745a5c0282d";
        src -> otherLanguage.display = evaluate(language, coding.display) "e20858a5-4fd0-40fc-83ea-ec1a24798594";
        src -> otherLanguage.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-language' "41d38585-b154-44e3-af7f-cc60b629f40b";
      } "0514913d-4c87-4b9c-9de9-b5baf7b9e913";
    } "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')) "923bade9-9be3-4694-98af-3d881345584f";
    } "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) "a4f4f82d-067f-41cc-ac52-1383e173c5c8";
        src -> orientation.display = evaluate(sexualOrientation, coding.display) "d3f9eb6a-8c3f-4103-8835-c9a7c4c469e5";
        src -> orientation.system = 'https://data.digitisingsocialcare.co.uk/mods/v1/person-sexual-orientation' "0c9c73cb-7d58-4bf1-aa1b-ccd83b6a73c7";
      } "setSexualOrientationCoding";
    } "setSexualOrientation";
  } "setDemographics";
  src.address as address -> tgt.address as addr then {
    src -> addr.addressEntry1 = evaluate(address, line[0]) "95432416-4785-4291-8f45-effd574787da";
    src -> addr.addressEntry2 = evaluate(address, line[1]) "593c5458-e865-4cc1-bfee-defe7c961cef";
    src -> addr.addressEntry3 = evaluate(address, line[2]) "754956fd-2c03-4981-8575-6a7a8c16d8a9";
    src -> addr.addressEntry4 = evaluate(address, line[3]) "c0b49511-d2e2-48b7-9623-6d9c998e5dcf";
    src -> addr.postCode = evaluate(address, postalCode) "b30d5798-757a-4886-8ed3-cca0230bab90";
    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' "d9072b37-e118-46bf-a7e3-1b208bf70fa2";
        src -> country.code = evaluate(countryExt, valueCoding.code) "e84087b8-1a49-4025-8fdd-b5d75c89fb93";
        src -> country.display = evaluate(countryExt, valueCoding.display) "f9805ba3-df96-4a47-9fb8-5ddcf7b75b02";
      } "80fe4365-9c9c-4545-b477-58016d00def9";
    };
  } "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) "67ad906f-1a85-4b7f-92bb-03b0922277a1";
      src -> emailAddressDetails.preferredOrder = evaluate(emailAddress, rank) "43e0d11a-4301-4000-b3b9-7b7b2134aab6";
      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' "951232f8-dcc4-4b5d-beba-2e2077610a73";
          src -> emailAddressType.code = evaluate(emailAddressTypeExt, valueCoding.code) "79f6f6d2-0393-4c4f-b7d5-b8e49c1910ed";
          src -> emailAddressType.display = evaluate(emailAddressTypeExt, valueCoding.display) "2d40b5a5-d0cb-4c49-a1a7-87c6f2f3a6af";
        } "369074a4-1c99-4d96-842d-463a50c6c609";
      };
    };
    src.telecom as telephoneNumber where $this.system='phone' -> contactDetails.telephoneDetails as telephoneNumberDetails then {
      src -> telephoneNumberDetails.telephoneNumber = evaluate(telephoneNumber, value) "07be6470-6f99-41c8-bcd5-32f74708b3b1";
      src -> telephoneNumberDetails.preferredOrder = evaluate(telephoneNumber, rank) "c4cf0def-3e23-4c8f-a9d4-456bdc257862";
      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' "5310bd0f-2104-48b3-a3a8-fb065b75a1de";
          src -> telephoneNumberType.code = evaluate(telephoneNumberExt, valueCoding.code) "3503123e-f245-4d1c-8285-bcbab47c6b55";
          src -> telephoneNumberType.display = evaluate(telephoneNumberExt, valueCoding.display) "85f41bb5-e8a1-4b89-8a07-726d574ef7f3";
        } "a74495d1-058d-48d8-9d62-c3757502c851";
      };
    };
  } "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' "a4e54425-1be9-4d75-87f1-670a2a50f11e";
          src -> deathCauseIdentificationMethod.code = evaluate(deathCauseIdentificationMethodCoding, code) "79b27933-27cc-4246-aa2f-40e1ecdd856e";
          src -> deathCauseIdentificationMethod.display = evaluate(deathCauseIdentificationMethodCoding, display) "78d73d39-7771-412b-b3f2-d13e58967b5f";
        } "0c5c4818-d666-48e4-92e5-f1bb55f921ba";
      } "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' "4ede752b-80f0-4597-9fd6-7d3efb1ce391";
          src -> deathLocationType.code = evaluate(deathLocationTypeCoding, code) "acd83a15-090f-460c-b034-7db7688d04ad";
          src -> deathLocationType.display = evaluate(deathLocationTypeCoding, display) "05912dfb-b237-469f-9acc-6868de1d05c1";
        } "33de70ac-0b3f-4a45-adef-c664707ec290";
      } "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' "f17aeb1c-f7ae-4097-aee5-355f7d633800";
          src -> deathNotAtPreferredLocationReason.code = evaluate(deathNotAtPreferredLocationReasonCoding, code) "f85cd3bf-f028-4be1-82b3-163c246a5eb2";
          src -> deathNotAtPreferredLocationReason.display = evaluate(deathNotAtPreferredLocationReasonCoding, display) "a1147b42-98e6-4e7a-8049-c0c1d1264358";
        } "b8823f41-f895-41c9-8a5f-4fa20c40cf03";
      } "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' "3c034992-69a9-4952-9774-c1993266a742";
          src -> personAtRiskOfUnexpectedDeath.code = evaluate(personAtRiskOfUnexpectedDeathCoding, code) "22c381c4-e90c-4e48-9e72-293b93fd74c2";
          src -> personAtRiskOfUnexpectedDeath.display = evaluate(personAtRiskOfUnexpectedDeathCoding, display) "c337baba-b43c-4856-9bf3-8245a7641f74";
        } "8656778d-a6a7-4b2c-a052-5d0ceb4bf5b2";
      } "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' "788b4cba-370e-46d2-8516-e78b837b672a";
          src -> preferredDeathLocationDiscussed.code = evaluate(preferredLocationOfDeathDiscussedCoding, code) "14b41539-f313-438c-9777-0527a62c58b3";
          src -> preferredDeathLocationDiscussed.display = evaluate(preferredLocationOfDeathDiscussedCoding, display) "05dc6068-4ee9-40bb-9b29-b9b84a9226dc";
        } "093f7a55-6019-4714-9ba1-5083938473e2";
      } "setPreferredLocationOfDeathDiscussed";
      deathDetailsExt.extension as personDateOfDeathExt where $this.url='personDateOfDeath' then {
        src -> deathDetails.personDeathDate = evaluate(personDateOfDeathExt, valueDate) "bc39d76b-dc34-4fd2-bed9-258723fa840d";
      } "setPersonDeathTime";
      deathDetailsExt.extension as personTimeOfDeathExt where $this.url='personTimeOfDeath' then {
        src -> deathDetails.personDeathTime = evaluate(personTimeOfDeathExt, valueTime) "8c3f173f-d9ec-41db-9c48-16687e7a4bac";
      } "setPersonDeathTime";
    } "c448219c-e93c-485a-8ad0-ecd8a1cbe465";
  } "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) "8c4ea278-3846-413b-9cc2-7501d495f79a";
      src -> careProvider.type = 'CareOrganisation' "ad36c453-f79f-4a53-937d-ac2247ba2b4a";
      src -> careProvider.display = evaluate(careProviderReference, display) "2b97e017-4ab9-46d9-a509-cb3cd3f5c339";
    };
  } "setCareProvider";
  src.generalPractitioner as generalPractitioner, generalPractitioner.identifier as generalPractitionerIdentifier then {
    src -> tgt.generalPractice as generalPractice then {
      src -> generalPractice.id = evaluate(generalPractitionerIdentifier, value) "3f7a4d90-6ea5-4be6-958d-ddfb8a89a2d3";
      src -> generalPractice.type = 'CareOrganisation' "dcfa5550-f50e-4527-b997-3c04c9a2935b";
      src -> generalPractice.display = evaluate(generalPractitioner, display) "738a6d9f-d778-4c75-b194-dea270aeff50";
    } "125eccb4-2cad-49aa-80a7-eb926eeaa7e5";
  } "setGeneralPractitioner";
}