{
  "resourceType": "StructureDefinition",
  "id": "0d4c24f3-ce93-4046-b6f6-caa2980885d5",
  "meta": {
    "versionId": "18",
    "lastUpdated": "2019-12-19T20:28:47.277+00:00"
  },
  "url": "http://www.agfa.com/ei/fhir/StructureDefinition/ei-patient",
  "name": "Enterprise_Imaging_Patient",
  "status": "draft",
  "date": "2019-12-19T20:26:20.3752307Z",
  "description": "AGFA Enterprise Imaging customized Patient resource definition",
  "fhirVersion": "4.0.0",
  "mapping": [
    {
      "identity": "agfa-ei-model",
      "name": "Enterprise Imaging DB model"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Patient",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Patient",
  "derivation": "constraint",
  "snapshot": {},
  "differential": {
    "element": [
      {
        "id": "Patient.id",
        "path": "Patient.id",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PK"
          }
        ]
      },
      {
        "id": "Patient.implicitRules",
        "path": "Patient.implicitRules",
        "max": "0"
      },
      {
        "id": "Patient.language",
        "path": "Patient.language",
        "max": "0"
      },
      {
        "id": "Patient.identifier",
        "path": "Patient.identifier",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier.extension",
        "path": "Patient.identifier.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.identifier.extension:DisplayName",
        "path": "Patient.identifier.extension",
        "sliceName": "DisplayName",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://www.agfa.com/ei/fhir/StructureDefinition/ei-display-name"
            ]
          }
        ],
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "EiDisplayNameExtension(systemsettingDataHolder.getDisplayPatientId(pid))",
            "comment": "TO DO: find out what this is about"
          }
        ]
      },
      {
        "id": "Patient.identifier.type",
        "path": "Patient.identifier.type",
        "short": "PAT_CODE|PAT_MEDICALRECORDNR",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://www.agfa.com/ei/fhir/ValueSet/ei-vs-patient-type"
        }
      },
      {
        "id": "Patient.identifier.type.coding",
        "path": "Patient.identifier.type.coding",
        "mustSupport": true
      },
      {
        "id": "Patient.identifier.type.coding.code",
        "path": "Patient.identifier.type.coding.code",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT_ID#PAT_ID_TYPE_CODE",
            "comment": "TODO: instead of using our own valueset, can't see use one from HL7 (http://hl7.org/fhir/v2/0203/PI), since we only support PAT_CODE anyhow"
          }
        ]
      },
      {
        "id": "Patient.identifier.system",
        "path": "Patient.identifier.system",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "ID_ISSUER#ENTITY_UID",
            "comment": "TODO: not yet implemented like this!"
          }
        ]
      },
      {
        "id": "Patient.identifier.value",
        "path": "Patient.identifier.value",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT_ID#PAT_ID"
          }
        ]
      },
      {
        "id": "Patient.identifier.assigner.display",
        "path": "Patient.identifier.assigner.display",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "ID_ISSUER#ENTITY_ID",
            "comment": "Namespace of the PatientID Issuer"
          }
        ]
      },
      {
        "id": "Patient.active",
        "path": "Patient.active",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#ACTIVE"
          }
        ]
      },
      {
        "id": "Patient.name",
        "path": "Patient.name",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "use"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.name:OfficialName",
        "path": "Patient.name",
        "sliceName": "OfficialName",
        "min": 1,
        "max": "1",
        "fixedHumanName": {
          "use": "official",
          "text": "Official name of the patient"
        }
      },
      {
        "id": "Patient.name:OfficialName.use",
        "path": "Patient.name.use",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PAT_NAME_FK"
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.text",
        "path": "Patient.name.text",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "systemsettingDataHolder.getDisplayName(p)",
            "comment": "TODO: determine what this code means..."
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.family",
        "path": "Patient.name.family",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PERSON_NAME#FAMILY_NAME"
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.given",
        "path": "Patient.name.given",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PERSON_NAME#GIVEN_NAME | PERSON_NAME#MIDDLE_NAME",
            "comment": "TODO: an extension on this to model the patient names like they really are in EI?"
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.prefix",
        "path": "Patient.name.prefix",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PERSON_NAME#PREFIX"
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.suffix",
        "path": "Patient.name.suffix",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PERSON_NAME#NAME_SUFFIX"
          }
        ]
      },
      {
        "id": "Patient.name:OfficialName.period",
        "path": "Patient.name.period",
        "max": "0"
      },
      {
        "id": "Patient.name:MaidenName",
        "path": "Patient.name",
        "sliceName": "MaidenName",
        "max": "1",
        "fixedHumanName": {
          "use": "maiden",
          "text": "The maiden name of the patient"
        }
      },
      {
        "id": "Patient.name:MaidenName.use",
        "path": "Patient.name.use",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#MAIDEN_NAME_FK"
          }
        ]
      },
      {
        "id": "Patient.name:MaidenName.text",
        "path": "Patient.name.text",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "humanMaidenName.setText(systemsettingDataHolder.getDisplayName(maidenName))"
          }
        ]
      },
      {
        "id": "Patient.name:MaidenName.family",
        "path": "Patient.name.family",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PERSON_NAME#FAMILY_NAME"
          }
        ]
      },
      {
        "id": "Patient.name:MaidenName.given",
        "path": "Patient.name.given",
        "max": "0"
      },
      {
        "id": "Patient.name:MaidenName.prefix",
        "path": "Patient.name.prefix",
        "max": "0"
      },
      {
        "id": "Patient.name:MaidenName.suffix",
        "path": "Patient.name.suffix",
        "max": "0"
      },
      {
        "id": "Patient.name:MaidenName.period",
        "path": "Patient.name.period",
        "max": "0"
      },
      {
        "id": "Patient.gender",
        "path": "Patient.gender",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PAT_SEX"
          }
        ]
      },
      {
        "id": "Patient.birthDate",
        "path": "Patient.birthDate",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PAT_BIRTHDATE",
            "comment": "TODO: what does this mean Extension eiDisplayNameExt = new EiDisplayNameExtension(systemsettingDataHolder.getDisplayTextOfDate(birthDate));"
          }
        ]
      },
      {
        "id": "Patient.birthDate.extension",
        "path": "Patient.birthDate.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.birthDate.extension:DisplayName",
        "path": "Patient.birthDate.extension",
        "sliceName": "DisplayName",
        "type": [
          {
            "code": "Extension",
            "profile": [
              "http://www.agfa.com/ei/fhir/StructureDefinition/ei-display-name"
            ]
          }
        ]
      },
      {
        "id": "Patient.deceased[x]",
        "path": "Patient.deceased[x]",
        "type": [
          {
            "code": "dateTime"
          }
        ],
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PAT_DECEASEDDATE",
            "comment": "TODO: same remark as the birthDate"
          }
        ]
      },
      {
        "id": "Patient.address.use",
        "path": "Patient.address.use",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "COMMUNICATION_CHANNEL#COMMUNICATION_TYPE",
            "comment": "HOME_ADDRESS -> home / OFFICE_ADDRESS -> work"
          }
        ]
      },
      {
        "id": "Patient.address.type",
        "path": "Patient.address.type",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "COMMUNICATION_CHANNEL#COMMUNICATION_TYPE",
            "comment": "HOME_ADDRESS / OFFICE_ADDRESS -> postal"
          }
        ]
      },
      {
        "id": "Patient.address.text",
        "path": "Patient.address.text",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "systemSetting.getDisplayNameOfPostalAddress(eiAddressWrapper)",
            "comment": "TODO: what does the above code do"
          }
        ]
      },
      {
        "id": "Patient.address.line",
        "path": "Patient.address.line",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "Line1 = COMMUNICATION_CHANNEL#ADDRESS_LINE1 / Line2 = COMMUNICATION_CHANNEL#STREET + COMMUNICATION_CHANNEL#STREETNR"
          }
        ]
      },
      {
        "id": "Patient.address.city",
        "path": "Patient.address.city",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "COMMUNICATION_CHANNEL#MUNICIPALITY -> MUNICPALITY#NAME"
          }
        ]
      },
      {
        "id": "Patient.address.district",
        "path": "Patient.address.district",
        "max": "0"
      },
      {
        "id": "Patient.address.state",
        "path": "Patient.address.state",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "MUNICPALITY#REGION -> REGION_LEVEL1#NAME",
            "comment": "TODO: this should be changed to only the 4 address lines"
          }
        ]
      },
      {
        "id": "Patient.address.postalCode",
        "path": "Patient.address.postalCode",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "MUNICIPALITY#ZIP"
          }
        ]
      },
      {
        "id": "Patient.address.country",
        "path": "Patient.address.country",
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "COMMUNICATION_CHANNEL#COUNTRY -> COUNTRY#CODE"
          }
        ]
      },
      {
        "id": "Patient.address.period",
        "path": "Patient.address.period",
        "max": "0"
      },
      {
        "id": "Patient.maritalStatus",
        "path": "Patient.maritalStatus",
        "max": "0"
      },
      {
        "id": "Patient.multipleBirth[x]",
        "path": "Patient.multipleBirth[x]",
        "max": "0"
      },
      {
        "id": "Patient.photo",
        "path": "Patient.photo",
        "max": "0"
      },
      {
        "id": "Patient.contact",
        "path": "Patient.contact",
        "max": "0"
      },
      {
        "id": "Patient.communication",
        "path": "Patient.communication",
        "max": "0"
      },
      {
        "id": "Patient.generalPractitioner",
        "path": "Patient.generalPractitioner",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Practitioner",
              "http://www.agfa.com/ei/fhir/StructureDefinition/ei-practitioner"
            ]
          }
        ],
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "PATIENT#PROFESSIONAL"
          }
        ]
      },
      {
        "id": "Patient.generalPractitioner.display",
        "path": "Patient.generalPractitioner.display",
        "mustSupport": true,
        "mapping": [
          {
            "identity": "agfa-ei-model",
            "map": "???",
            "comment": "TODO: find out what systemsettingDataHolder.getDisplayName(physician) means"
          }
        ]
      },
      {
        "id": "Patient.managingOrganization",
        "path": "Patient.managingOrganization",
        "max": "0"
      },
      {
        "id": "Patient.link",
        "path": "Patient.link",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "other.type"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Patient.link:sliceLink",
        "path": "Patient.link",
        "sliceName": "sliceLink"
      },
      {
        "id": "Patient.link:sliceLink.other",
        "path": "Patient.link.other",
        "type": [
          {
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-hierarchy",
                "valueBoolean": false
              }
            ],
            "code": "Reference",
            "targetProfile": [
              "http://www.agfa.com/ei/fhir/StructureDefinition/ei-patient"
            ],
            "aggregation": [
              "referenced"
            ]
          }
        ],
        "fixedReference": {
          "type": "Patient"
        }
      }
    ]
  }
}