<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="cyehr-sd-address" />
  <meta>
    <versionId value="3" />
    <lastUpdated value="2022-08-12T08:10:33.3145378+00:00" />
  </meta>
  <url value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-sd-address" />
  <name value="CYEHRSDAddress" />
  <title value="Cyprus EHR Address datatype" />
  <status value="draft" />
  <date value="2022-01-25T10:50:15.4266808+00:00" />
  <publisher value="eHealth4U" />
  <contact>
    <name value="eHealth Lab (University of Cyprus)" />
    <telecom>
      <system value="email" />
      <value value="ehealthl@ucy.ac.cy" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="A datatype for the parts of an address that willl be used for the protoptype of the national integrated EHR system of Cyprus. Defined by the project eHealth4U (ehealth4u.cs.ucy.ac.cy).  Can be used for birth place, current address, medical office location, etc." />
  <fhirVersion value="4.0.1" />
  <kind value="complex-type" />
  <abstract value="false" />
  <type value="Address" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Address" />
  <derivation value="constraint" />
  <differential>
    <element id="Address">
      <path value="Address" />
      <constraint>
        <key value="cyehr-address-1" />
        <requirements value="https://web.archive.org/web/20170227213520/http://www.moi.gov.cy/moi/da/dadmin.nsf/dmlhistory_gr/dmlhistory_gr?OpenDocument" />
        <severity value="error" />
        <human value="If the address is from country = Cyprus then only the following elements and extensions should be filled: line, city, district, postal code, village, settlement, country." />
        <expression value="Address.where(country = 'CY').exists() implies (Address.state.exists().not() and Address.extension.where(url = 'http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addressprovince').exists().not() and Address.extension.where(url = 'http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addresstown').exists().not())" />
        <source value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-sd-address" />
      </constraint>
      <constraint>
        <key value="cyehr-address-2" />
        <severity value="error" />
        <human value="If asserting no fixed address, the type shall be physical" />
        <expression value="extension('http://hl7.org.au/fhir/StructureDefinition/no-fixed-address').exists() implies type='physical'" />
        <source value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-sd-address" />
      </constraint>
      <constraint>
        <key value="cyehr-address-3" />
        <severity value="error" />
        <human value="If asserting no fixed address, the address text shall begin with &quot;NO FIXED ADDRESS&quot;" />
        <expression value="Address.extension.where(url='http://hl7.org.au/fhir/StructureDefinition/no-fixed-address').exists() implies text.startsWith('NO FIXED ADDRESS')" />
        <source value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-sd-address" />
      </constraint>
      <constraint>
        <key value="cyehr-address-4" />
        <severity value="error" />
        <human value="If this is a Cypriot address, the postal code shall have 4 digits" />
        <expression value="(Address.country = 'CY' and Address.postalCode.exists()) implies Address.postalCode.matches('^[0-9]{4}')" />
        <source value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-sd-address" />
      </constraint>
    </element>
    <element id="Address.extension">
      <path value="Address.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Address.extension:province">
      <path value="Address.extension" />
      <sliceName value="province" />
      <label value="Province" />
      <short value="Province as part of an address" />
      <definition value="Optional Extension Element of the datatype address" />
      <min value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addressprovince" />
      </type>
    </element>
    <element id="Address.extension:town">
      <path value="Address.extension" />
      <sliceName value="town" />
      <label value="Town" />
      <short value="Town as part of an address" />
      <definition value="Optional Extension Element of the datatype address" />
      <min value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addresstown" />
      </type>
    </element>
    <element id="Address.extension:village">
      <path value="Address.extension" />
      <sliceName value="village" />
      <label value="Village" />
      <short value="Village as part of the address" />
      <definition value="Optional Extension Element of the datatype address" />
      <min value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addressvillage" />
      </type>
    </element>
    <element id="Address.extension:settlement">
      <path value="Address.extension" />
      <sliceName value="settlement" />
      <label value="Settlement" />
      <short value="Settlement as part of the address" />
      <definition value="Optional Extension Element of the datatype address" />
      <min value="0" />
      <type>
        <code value="Extension" />
        <profile value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-addresssettlement" />
      </type>
    </element>
    <element id="Address.extension:noFixedAddress">
      <path value="Address.extension" />
      <sliceName value="noFixedAddress" />
      <comment value="CyprusEHR: When the value of the extension is &quot;true&quot; only temporary address can be created." />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://ig.ehealth4u.eu/fhir/StructureDefinition/cyehr-ext-nofixedaddress" />
      </type>
      <isModifier value="false" />
    </element>
    <element id="Address.line.extension">
      <path value="Address.line.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="0" />
    </element>
    <element id="Address.line.extension:streetName">
      <path value="Address.line.extension" />
      <sliceName value="streetName" />
      <label value="Street Name" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-streetName" />
      </type>
    </element>
    <element id="Address.line.extension:houseNumber">
      <path value="Address.line.extension" />
      <sliceName value="houseNumber" />
      <label value="houseNumber" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-houseNumber" />
      </type>
    </element>
    <element id="Address.line.extension:unitType">
      <path value="Address.line.extension" />
      <sliceName value="unitType" />
      <label value="unitType" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-unitType" />
      </type>
    </element>
    <element id="Address.line.extension:unitID">
      <path value="Address.line.extension" />
      <sliceName value="unitID" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-unitID" />
      </type>
    </element>
    <element id="Address.line.extension:postBox">
      <path value="Address.line.extension" />
      <sliceName value="postBox" />
      <label value="P.O. Box" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org/fhir/StructureDefinition/iso21090-ADXP-postBox" />
      </type>
    </element>
    <element id="Address.country">
      <path value="Address.country" />
      <label value="Country" />
      <short value="Country ISO 3166 2 letter code)" />
      <comment value="ISO 3166 2 letter codes can be used in place of a human readable country name." />
      <binding>
        <strength value="required" />
        <description value="This value set defines the ISO 3166 Part 1 2-letter codes" />
        <valueSet value="http://hl7.org/fhir/ValueSet/iso3166-1-2" />
      </binding>
    </element>
  </differential>
</StructureDefinition>