<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="organization-er" />
  <url value="http://electronichealth.se/fhir/NDI/StructureDefinition/organization-er" />
  <version value="0.1.0" />
  <name value="OrganizationEr" />
  <title value="Organization (ER)" />
  <status value="active" />
  <description value="This profile holds information about organizations that can use endpoints." />
  <fhirVersion value="5.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Organization" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Organization" />
  <derivation value="constraint" />
  <differential>
    <element id="Organization.identifier">
      <path value="Organization.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <description value="Slice on identifier based on system value" />
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:organizationIdentifier">
      <path value="Organization.identifier" />
      <sliceName value="organizationIdentifier" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:organizationIdentifier.system">
      <path value="Organization.identifier.system" />
      <min value="1" />
      <fixedUri value="urn:oid:2.5.4.97" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:organizationIdentifier.value">
      <path value="Organization.identifier.value" />
      <min value="1" />
      <constraint>
        <key value="organization-identifier-value-er-1" />
        <severity value="error" />
        <human value="A Swedish organization identifier (sv: organisationsnummer) should follow format 7999000057" />
        <expression value="$this.matches('^\\d{6}\\d{4}$')" />
        <source value="http://electronichealth.se/fhir/NDI/StructureDefinition/organization-er" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:personalIdentityNumber">
      <path value="Organization.identifier" />
      <sliceName value="personalIdentityNumber" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:personalIdentityNumber.system">
      <path value="Organization.identifier.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/identifier/personnummer" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:personalIdentityNumber.value">
      <path value="Organization.identifier.value" />
      <min value="1" />
      <constraint>
        <key value="personal-identity-number-value-er-1" />
        <severity value="error" />
        <human value="A Swedish personal identity number (sv: personnummer) should follow format 198001032385" />
        <expression value="$this.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\d{4}$')" />
        <source value="http://electronichealth.se/fhir/NDI/StructureDefinition/organization-er" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:coordinationNumber">
      <path value="Organization.identifier" />
      <sliceName value="coordinationNumber" />
      <min value="0" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:coordinationNumber.system">
      <path value="Organization.identifier.system" />
      <min value="1" />
      <fixedUri value="http://electronichealth.se/identifier/samordningsnummer" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.identifier:coordinationNumber.value">
      <path value="Organization.identifier.value" />
      <min value="1" />
      <constraint>
        <key value="coordination-number-value-er-1" />
        <severity value="error" />
        <human value="A Swedish coordination number (sv: samordningsnummer) should follow format 201903682399" />
        <expression value="$this.matches('^([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(0[1-9]|1[0-2])([6-9][1-9])\\d{4}$')" />
        <source value="http://electronichealth.se/fhir/NDI/StructureDefinition/organization-er" />
      </constraint>
      <mustSupport value="true" />
    </element>
    <element id="Organization.type">
      <path value="Organization.type" />
      <max value="1" />
      <mustSupport value="true" />
      <binding>
        <strength value="required" />
        <valueSet value="http://electronichealth.se/fhir/NDI/ValueSet/er-organization-type" />
      </binding>
    </element>
    <element id="Organization.type.coding">
      <path value="Organization.type.coding" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.type.coding.system">
      <path value="Organization.type.coding.system" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.type.coding.code">
      <path value="Organization.type.coding.code" />
      <min value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Organization.endpoint">
      <path value="Organization.endpoint" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://electronichealth.se/fhir/NDI/StructureDefinition/endpoint-er" />
      </type>
      <mustSupport value="true" />
    </element>
  </differential>
</StructureDefinition>