{
  "resourceType": "StructureDefinition",
  "id": "au-healthcareservice",
  "url": "http://hl7.org.au/fhir/StructureDefinition/au-healthcareservice",
  "version": "1.1.0",
  "name": "AUBaseHealthcareService",
  "title": "AU Base Healthcare Service",
  "status": "active",
  "date": "2018-08-03",
  "publisher": "Health Level Seven Australia (Patient Administration WG)",
  "contact": [
    {
      "telecom": [
        {
          "system": "url",
          "value": "http://hl7.org.au/fhir",
          "use": "work"
        }
      ]
    }
  ],
  "description": "This profile defines a healthcare service administration details structure that includes core localisation concepts for use in an Australian context.",
  "fhirVersion": "3.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "HealthcareService",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/HealthcareService",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "HealthcareService",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-standards-status",
            "valueCode": "trial-use"
          }
        ],
        "path": "HealthcareService",
        "short": "A healthcare service in an Australian healthcare context",
        "definition": "The details of a healthcare service."
      },
      {
        "id": "HealthcareService.extension",
        "path": "HealthcareService.extension",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "url"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "HealthcareService.extension:eligibilityDetails",
        "path": "HealthcareService.extension",
        "sliceName": "eligibilityDetails",
        "short": "Healthcare Service Eligibility Detail",
        "type": [
          {
            "code": "Extension",
            "profile": "http://hl7.org.au/fhir/StructureDefinition/healthcareservice-eligibility-detail"
          }
        ]
      },
      {
        "id": "HealthcareService.extension:communication",
        "path": "HealthcareService.extension",
        "sliceName": "communication",
        "short": "Healthcare Service Communication Languages",
        "type": [
          {
            "code": "Extension",
            "profile": "http://hl7.org.au/fhir/StructureDefinition/healthcareservice-communication"
          }
        ]
      },
      {
        "id": "HealthcareService.identifier",
        "path": "HealthcareService.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "type"
            },
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "short": "Healthcare service identifiers"
      },
      {
        "id": "HealthcareService.identifier:hpio",
        "path": "HealthcareService.identifier",
        "sliceName": "hpio",
        "short": "Healthcare Provider Identifier – Organisation (HPI-O)",
        "definition": "National identifier Health Provider Identifier for Organisations (HPI-O).",
        "constraint": [
          {
            "key": "inv-hpio-0",
            "severity": "error",
            "human": "HPI-O shall be an exactly 16 digit number",
            "expression": "value.matches('^([0-9]{16})$')"
          },
          {
            "key": "inv-hpio-1",
            "severity": "error",
            "human": "HPI-O prefix is 800362",
            "expression": "value.startsWith('800362')"
          },
          {
            "key": "inv-hpio-2",
            "severity": "error",
            "human": "HPI-O shall pass the Luhn algorithm check",
            "expression": "(((select(value.substring(0,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(1,1).toInteger())+(select(value.substring(2,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(3,1).toInteger())+(select(value.substring(4,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(5,1).toInteger())+(select(value.substring(6,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(7,1).toInteger())+(select(value.substring(8,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(9,1).toInteger())+(select(value.substring(10,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(11,1).toInteger())+(select(value.substring(12,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(13,1).toInteger())+(select(value.substring(14,1).toInteger()).select(iif($this<5, $this*2, (($this*2)-9))))+(value.substring(15,1).toInteger()))mod 10=0)"
          }
        ]
      },
      {
        "id": "HealthcareService.identifier:hpio.type",
        "path": "HealthcareService.identifier.type",
        "short": "Identifier type for HPI-O",
        "definition": "Healthcare Provider Identifier – Organisation (HPI-O) identifier type.",
        "patternCodeableConcept": {
          "coding": [
            {
              "system": "http://hl7.org.au/fhir/v2/0203",
              "code": "NOI"
            }
          ]
        },
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "IdentifierType"
            },
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-isCommonBinding",
              "valueBoolean": true
            }
          ],
          "strength": "required",
          "description": "Local identifier type",
          "valueSetReference": {
            "reference": "http://hl7.org.au/fhir/ValueSet/au-hl7v2-0203"
          }
        }
      },
      {
        "id": "HealthcareService.identifier:hpio.type.text",
        "extension": [
          {
            "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-translatable",
            "valueBoolean": true
          }
        ],
        "path": "HealthcareService.identifier.type.text",
        "definition": "hpi-o",
        "fixedString": "HPI-O"
      },
      {
        "id": "HealthcareService.identifier:hpio.system",
        "path": "HealthcareService.identifier.system",
        "short": "Namespace for HPI-O",
        "definition": "This namespace is used for qualified identifiers to represent Healthcare Provider Identifier for Organisations (HPI-O) numbers. An example of the syntax of a HPI-O represented as a qualified identifer using this namespace is: http://ns.electronichealth.net.au/id/hi/hpio/1.0/8003620000000000",
        "min": 1,
        "fixedUri": "http://ns.electronichealth.net.au/id/hi/hpio/1.0"
      },
      {
        "id": "HealthcareService.identifier:hpio.value",
        "path": "HealthcareService.identifier.value",
        "short": "HPI-O number",
        "definition": "Identifier for the organization that is used to identify the organization across multiple disparate systems.",
        "min": 1,
        "example": [
          {
            "label": "HPI-O number",
            "valueString": "8003621566684455"
          }
        ],
        "maxLength": 16
      },
      {
        "id": "HealthcareService.type",
        "path": "HealthcareService.type",
        "short": "Healthcare service types",
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "service-type"
            }
          ],
          "strength": "preferred",
          "description": "A type of service that a healthcare service may provide.",
          "valueSetReference": {
            "reference": "http://hl7.org.au/fhir/ValueSet/snomed-healthcareservice-services"
          }
        }
      },
      {
        "id": "HealthcareService.specialty",
        "path": "HealthcareService.specialty",
        "short": "Healthcare service provided specialties",
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "service-specialty"
            }
          ],
          "strength": "preferred",
          "description": "A specialty role that a healthcare service may provide.",
          "valueSetReference": {
            "reference": "http://hl7.org.au/fhir/ValueSet/snomed-healthcareservice-roles"
          }
        }
      },
      {
        "id": "HealthcareService.serviceProvisionCode",
        "path": "HealthcareService.serviceProvisionCode",
        "short": "Healthcare service provision conditions",
        "binding": {
          "extension": [
            {
              "url": "http://hl7.org/fhir/StructureDefinition/elementdefinition-bindingName",
              "valueString": "ServiceProvisionConditions"
            }
          ],
          "strength": "preferred",
          "valueSetReference": {
            "reference": "http://hl7.org.au/fhir/ValueSet/service-provision-conditions"
          }
        }
      },
      {
        "id": "HealthcareService.eligibility",
        "path": "HealthcareService.eligibility",
        "short": "Primary eligibility criteria for service",
        "definition": "Primary eligibility criterial for service.",
        "comment": "The extension Healthcare Service; eligibilityDetails allows for specific desciption of multiple criteria."
      }
    ]
  }
}