{
  "resourceType": "StructureDefinition",
  "id": "ie-core-location",
  "url": "https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-location",
  "name": "IECoreLocation",
  "title": "IE Core Location",
  "status": "draft",
  "description": "The IE Core Location Profile is based upon the core FHIR Location Resource and defines the minimum set of data required to query and retrieve location information within the Irish healthcare system. It covers details such as the location name, type, address, and managing organization.",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Location",
  "baseDefinition": "http://hl7.eu/fhir/base/StructureDefinition/location-eu-core",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Location.identifier",
        "path": "Location.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "short": "Unique code or number identifying the location to its users",
        "mustSupport": true
      },
      {
        "id": "Location.identifier:GLN",
        "path": "Location.identifier",
        "sliceName": "GLN",
        "short": "Global Location Number (GLN)",
        "comment": "HIQA EP/PS 2.11 Location ID (GLN) (Required 0..1): a 13-digit number made up of a GS1 company prefix, a location reference and a check digit. Not an organisation identifier: each GP practice in a shared building has its own GLN. System: GS1 GLN (HL7 Terminology NamingSystem/GLN).",
        "min": 0,
        "max": "1",
        "constraint": [
          {
            "key": "ie-loc-gln-1",
            "severity": "error",
            "human": "GLN SHALL be 13 digits with a valid GS1 mod-10 check digit (HIQA EP/PS 2.11)",
            "expression": "value.matches('^[0-9]{13}$') and (((10 - ((value.substring(0,1).toInteger() + value.substring(1,1).toInteger()*3 + value.substring(2,1).toInteger() + value.substring(3,1).toInteger()*3 + value.substring(4,1).toInteger() + value.substring(5,1).toInteger()*3 + value.substring(6,1).toInteger() + value.substring(7,1).toInteger()*3 + value.substring(8,1).toInteger() + value.substring(9,1).toInteger()*3 + value.substring(10,1).toInteger() + value.substring(11,1).toInteger()*3) mod 10)) mod 10) = value.substring(12,1).toInteger())",
            "source": "https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-location"
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Location.identifier:GLN.system",
        "path": "Location.identifier.system",
        "min": 1,
        "patternUri": "http://www.gs1.org/gln",
        "mustSupport": true
      },
      {
        "id": "Location.identifier:GLN.value",
        "path": "Location.identifier.value",
        "min": 1,
        "mustSupport": true
      },
      {
        "id": "Location.status",
        "path": "Location.status",
        "mustSupport": true
      },
      {
        "id": "Location.operationalStatus",
        "path": "Location.operationalStatus",
        "mustSupport": true
      },
      {
        "id": "Location.name",
        "path": "Location.name",
        "short": "Name of the location as used by humans",
        "mustSupport": true
      },
      {
        "id": "Location.alias",
        "path": "Location.alias",
        "mustSupport": true
      },
      {
        "id": "Location.description",
        "path": "Location.description",
        "short": "Additional details about the location",
        "mustSupport": true
      },
      {
        "id": "Location.mode",
        "path": "Location.mode",
        "mustSupport": true
      },
      {
        "id": "Location.type",
        "path": "Location.type",
        "short": "Type of function performed at the location",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "http://terminology.hl7.org/ValueSet/v3-ServiceDeliveryLocationRoleType"
        }
      },
      {
        "id": "Location.telecom",
        "path": "Location.telecom",
        "short": "Contact details of the location",
        "mustSupport": true
      },
      {
        "id": "Location.telecom.system",
        "path": "Location.telecom.system",
        "mustSupport": true
      },
      {
        "id": "Location.telecom.value",
        "path": "Location.telecom.value",
        "mustSupport": true
      },
      {
        "id": "Location.telecom.use",
        "path": "Location.telecom.use",
        "mustSupport": true
      },
      {
        "id": "Location.address",
        "path": "Location.address",
        "short": "Physical location address",
        "mustSupport": true
      },
      {
        "id": "Location.address.line",
        "path": "Location.address.line",
        "mustSupport": true
      },
      {
        "id": "Location.address.city",
        "path": "Location.address.city",
        "mustSupport": true
      },
      {
        "id": "Location.address.state",
        "path": "Location.address.state",
        "short": "County",
        "mustSupport": true,
        "binding": {
          "strength": "extensible",
          "valueSet": "https://hl7-ie.github.io/ie-core/fhir/ie/core/ValueSet/ie-core-county"
        }
      },
      {
        "id": "Location.address.postalCode",
        "path": "Location.address.postalCode",
        "short": "Eircode or postal code",
        "mustSupport": true
      },
      {
        "id": "Location.address.country",
        "path": "Location.address.country",
        "mustSupport": true
      },
      {
        "id": "Location.physicalType",
        "path": "Location.physicalType",
        "mustSupport": true
      },
      {
        "id": "Location.position",
        "path": "Location.position",
        "mustSupport": true
      },
      {
        "id": "Location.position.longitude",
        "path": "Location.position.longitude",
        "mustSupport": true
      },
      {
        "id": "Location.position.latitude",
        "path": "Location.position.latitude",
        "mustSupport": true
      },
      {
        "id": "Location.managingOrganization",
        "path": "Location.managingOrganization",
        "short": "Organization responsible for provisioning and upkeep",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-organization"
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Location.partOf",
        "path": "Location.partOf",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://hl7-ie.github.io/ie-core/fhir/ie/core/StructureDefinition/ie-core-location"
            ],
            "extension": [
              {
                "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-hierarchy",
                "valueBoolean": true
              }
            ]
          }
        ],
        "mustSupport": true
      },
      {
        "id": "Location.endpoint",
        "path": "Location.endpoint",
        "mustSupport": true
      }
    ]
  }
}