<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="au-address" />
  <url value="http://hl7.org.au/fhir/StructureDefinition/au-address" />
  <version value="1.1.0" />
  <name value="AUBaseAddress" />
  <title value="AU Base Address" />
  <status value="active" />
  <date value="2018-09-25" />
  <publisher value="Health Level Seven Australia (Patient Administration WG)" />
  <contact>
    <telecom>
      <system value="url" />
      <value value="http://hl7.org.au/fhir" />
      <use value="work" />
    </telecom>
  </contact>
  <description value="This profile is provided for use in an Australian context where some constraint on content is desirable to guarantee the quality of an Australian address whilst still supporting     other uses such as unstructured addresses." />
  <fhirVersion value="3.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" />
      <short value="An address in Australia for use within an Australian healthcare context" />
      <definition value="An Australian address expressed using postal conventions (as opposed to GPS or other location definition formats)." />
      <constraint>
        <key value="inv-add-0" />
        <severity value="error" />
        <human value="The address shall at least have text or a line" />
        <expression value="text.exists() or line.exists()" />
      </constraint>
      <constraint>
        <key value="inv-add-1" />
        <severity value="error" />
        <human value="If asserting no fixed address, the type shall be 'physical'" />
        <expression value="extension.where(url='http://hl7.org.au/fhir/StructureDefinition/no-fixed-address' and value=true).exists() implies type='physical'" />
      </constraint>
      <constraint>
        <key value="inv-add-2" />
        <severity value="error" />
        <human value="If asserting no fixed address, the address text shall begin with 'NO FIXED ADDRESS'" />
        <expression value="extension.where(url='http://hl7.org.au/fhir/StructureDefinition/no-fixed-address').exists() implies text.startsWith('NO FIXED ADDRESS')" />
      </constraint>
      <constraint>
        <key value="inv-add-3" />
        <severity value="error" />
        <human value="Postal code shall be 4 digits" />
        <expression value="postalCode.exists() implies postalCode.matches('^[0-9]{4}$')" />
      </constraint>
    </element>
    <element id="Address.extension">
      <path value="Address.extension" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="url" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Address.extension:noFixedAddress">
      <path value="Address.extension" />
      <sliceName value="noFixedAddress" />
      <definition value="No fixed address indicator." />
      <max value="1" />
      <type>
        <code value="Extension" />
        <profile value="http://hl7.org.au/fhir/StructureDefinition/no-fixed-address" />
      </type>
    </element>
    <element id="Address.city">
      <path value="Address.city" />
      <short value="Name of city, town, suburb, etc." />
      <definition value="The name of the city, town, village, suburb, or other community or delivery center." />
    </element>
    <element id="Address.state">
      <path value="Address.state" />
      <short value="Australian state and territory" />
      <binding>
        <strength value="required" />
        <valueSetUri value="https://healthterminologies.gov.au/fhir/ValueSet/australian-states-territories-2" />
      </binding>
    </element>
    <element id="Address.country">
      <path value="Address.country" />
      <short value="Australia as a 2 digit ISO 3166 code" />
      <definition value="Fixed value if present otherwise assumed to be Australia in this context." />
      <fixedString value="AU" />
    </element>
  </differential>
</StructureDefinition>