<StructureDefinition xmlns="http://hl7.org/fhir">
  <url value="https://cgm.com/fhir/his/medico/r4/sd/pip/Patient_PiPPatient_1" />
  <name value="Patient_PiPPatient_1" />
  <status value="active" />
  <description value="This profile describes the patient related data to be exchanged with Patient Portal" />
  <fhirVersion value="4.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Patient" />
  <baseDefinition value="https://gematik.de/fhir/isik/v2/Basismodul/StructureDefinition/ISiKPatient" />
  <derivation value="constraint" />
  <differential>
    <element id="Patient.id">
      <path value="Patient.id" />
      <definition value="The logical id of the resource, as used in the URL for the resource. Once assigned, this value never changes.&#xD;&#xA;if the patient is already registered within medico -&#xD;&#xA;the format will be Patient-#####&#xD;&#xA;where #### is the patient id (medico x1000per.per)&#xD;&#xA;otherwise if the patient was sent by patientportal in order to book an appointment&#xD;&#xA;the format will be Patient.PIP-######&#xD;&#xA;where ##### is the temporary patient id (medico x1016pes.pes)&#xD;&#xA;&#xD;&#xA;in case this resource is sent for creating a patient resource in medico - the sent value will be ignored and is replaced by an id generated by medico" />
    </element>
    <element id="Patient.meta">
      <path value="Patient.meta" />
      <min value="1" />
    </element>
    <element id="Patient.meta.lastUpdated">
      <path value="Patient.meta.lastUpdated" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.meta.profile">
      <path value="Patient.meta.profile" />
      <min value="1" />
      <max value="1" />
      <fixedCanonical value="https://cgm.com/fhir/his/medico/r4/sd/pip/Patient_PiPPatient_1" />
    </element>
    <element id="Patient.meta.tag">
      <path value="Patient.meta.tag" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Patient.meta.tag:commonMetaTagDe">
      <path value="Patient.meta.tag" />
      <sliceName value="commonMetaTagDe" />
      <definition value="If this tag is present - this patient resource was created by an external system." />
      <mustSupport value="true" />
    </element>
    <element id="Patient.meta.tag:commonMetaTagDe.system">
      <path value="Patient.meta.tag.system" />
      <min value="1" />
      <fixedUri value="http://fhir.de/CodeSystem/common-meta-tag-de" />
    </element>
    <element id="Patient.meta.tag:commonMetaTagDe.code">
      <path value="Patient.meta.tag.code" />
      <min value="1" />
      <fixedCode value="external" />
    </element>
    <element id="Patient.meta.tag:externalSource">
      <path value="Patient.meta.tag" />
      <sliceName value="externalSource" />
      <definition value="in case the Patient resource was created by an external System - this tag will be present and contain a code to specify which external system created this resource." />
      <meaningWhenMissing value="If this tag is missing - the patient resource was created within CGM MEDICO" />
      <mustSupport value="true" />
    </element>
    <element id="Patient.meta.tag:externalSource.system">
      <path value="Patient.meta.tag.system" />
      <min value="1" />
      <fixedUri value="https://cgm.com/fhir/his/medico/cs/ExternalSource" />
    </element>
    <element id="Patient.meta.tag:externalSource.code">
      <path value="Patient.meta.tag.code" />
      <min value="1" />
      <fixedCode value="PIP" />
    </element>
    <element id="Patient.identifier">
      <path value="Patient.identifier" />
      <definition value="An identifier for this patient.&#xD;&#xA;slice Patientennummer is mandatory due to ISiK profile - please refer to the slice for more information." />
    </element>
    <element id="Patient.identifier:Patientennummer">
      <path value="Patient.identifier" />
      <sliceName value="Patientennummer" />
      <definition value="An identifier for this patient.&#xD;&#xA;in case this resource is sent for creating a patient resource in medico a temporary identifier has to be sent to be compliant to the ISiK Profile - the sent value will be ignored and is replaced by an identifier generated by medico. to be compliant to the ISiK profile identifier.type.coding.system MUST equal http://terminology.hl7.org/CodeSystem/v2-0203 and identifier.type.coding.code must equal MR" />
    </element>
    <element id="Patient.identifier:LifeId-external">
      <path value="Patient.identifier" />
      <sliceName value="LifeId-external" />
      <definition value="An identifier for this patient.&#xD;&#xA;This identifier represents the LifeId known to the patient. There could be two identifiers due to it is possible to register using an email, a phone number or both. Will be used on printouts within CGM MEDICO" />
      <max value="2" />
      <patternIdentifier>
        <type>
          <coding>
            <system value="http://hl7.org/fhir/ValueSet/contact-point-system" />
          </coding>
        </type>
      </patternIdentifier>
    </element>
    <element id="Patient.identifier:LifeId-external.type">
      <path value="Patient.identifier.type" />
      <min value="1" />
    </element>
    <element id="Patient.identifier:LifeId-external.type.coding">
      <path value="Patient.identifier.type.coding" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Patient.identifier:LifeId-external.type.coding.system">
      <path value="Patient.identifier.type.coding.system" />
      <min value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="http://hl7.org/fhir/ValueSet/contact-point-system|4.0.0" />
      </binding>
    </element>
    <element id="Patient.identifier:LifeId-external.type.coding.code">
      <path value="Patient.identifier.type.coding.code" />
      <min value="1" />
    </element>
    <element id="Patient.identifier:LifeId-external.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <fixedUri value="https://cgm.com/ns/life/lifeid-external" />
    </element>
    <element id="Patient.identifier:LifeId-external.value">
      <path value="Patient.identifier.value" />
      <min value="1" />
    </element>
    <element id="Patient.identifier:LifeId-internal">
      <path value="Patient.identifier" />
      <sliceName value="LifeId-internal" />
      <definition value="An identifier for this patient.&#xD;&#xA;This identifier represents the internal Id used within Life which is not known by the patient and will be used in specific business usecases." />
      <max value="1" />
      <patternIdentifier>
        <system value="https://cgm.com/ns/life/lifeid-internal" />
      </patternIdentifier>
    </element>
    <element id="Patient.identifier:LifeId-internal.system">
      <path value="Patient.identifier.system" />
      <min value="1" />
      <fixedUri value="https://cgm.com/ns/life/lifeid-internal" />
    </element>
    <element id="Patient.identifier:LifeId-internal.value">
      <path value="Patient.identifier.value" />
      <min value="1" />
    </element>
    <element id="Patient.telecom">
      <path value="Patient.telecom" />
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>