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