{
  "resourceType": "StructureDefinition",
  "id": "HealthLinkProcedure",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Clinical.Summary"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "patient"
    }
  ],
  "url": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure",
  "version": "0.5.2",
  "name": "HealthLinkProcedure",
  "title": "Health Link Procedure Profile",
  "status": "active",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Procedure",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Procedure",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Procedure.id",
        "path": "Procedure.id",
        "min": 1,
        "constraint": [
          {
            "key": "health-link-6",
            "severity": "error",
            "human": "Resource id must be 'mdp9Id-cid-uuid' (9-digit mdp9id + 13-digit cid + any uuid). Total length does not excced 64 chars.",
            "expression": "matches(\"^[0-9]{9}-[0-9]{13}-.*\")",
            "source": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure"
          }
        ]
      },
      {
        "id": "Procedure.identifier",
        "path": "Procedure.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Procedure.identifier:mdp",
        "path": "Procedure.identifier",
        "sliceName": "mdp",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Procedure.identifier:mdp.use",
        "path": "Procedure.identifier.use",
        "patternCode": "official"
      },
      {
        "id": "Procedure.identifier:mdp.system",
        "path": "Procedure.identifier.system",
        "min": 1,
        "patternUri": "http://203.157.10.8/hcode_2020/query_set.php"
      },
      {
        "id": "Procedure.identifier:mdp.value",
        "path": "Procedure.identifier.value",
        "min": 1,
        "constraint": [
          {
            "key": "health-link-4",
            "severity": "error",
            "human": "Resource identifer.value must be a 9 digit number (hcode)",
            "expression": "matches(\"^[0-9]{9}$\")",
            "source": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure"
          }
        ]
      },
      {
        "id": "Procedure.code",
        "path": "Procedure.code",
        "min": 1,
        "constraint": [
          {
            "key": "health-link-7",
            "severity": "error",
            "human": "CodableConcept of a required field must have a coding or text",
            "expression": "coding.exists() or text.exists()",
            "source": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure"
          }
        ],
        "binding": {
          "strength": "preferred",
          "valueSet": "https://healthlink.go.th/fhir/ValueSet/icd-9"
        }
      },
      {
        "id": "Procedure.code.coding.system",
        "path": "Procedure.code.coding.system",
        "min": 1
      },
      {
        "id": "Procedure.code.coding.code",
        "path": "Procedure.code.coding.code",
        "min": 1
      },
      {
        "id": "Procedure.code.coding.display",
        "path": "Procedure.code.coding.display",
        "min": 1
      },
      {
        "id": "Procedure.subject",
        "path": "Procedure.subject",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Patient"
            ]
          }
        ]
      },
      {
        "id": "Procedure.subject.reference",
        "path": "Procedure.subject.reference",
        "min": 1
      },
      {
        "id": "Procedure.encounter.reference",
        "path": "Procedure.encounter.reference",
        "min": 1
      },
      {
        "id": "Procedure.performed[x]",
        "path": "Procedure.performed[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1,
        "type": [
          {
            "code": "dateTime"
          },
          {
            "code": "Period"
          }
        ]
      },
      {
        "id": "Procedure.performedPeriod",
        "path": "Procedure.performedPeriod",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Period"
          }
        ]
      },
      {
        "id": "Procedure.performedPeriod.start",
        "path": "Procedure.performedPeriod.start",
        "min": 1
      },
      {
        "id": "Procedure.performer",
        "path": "Procedure.performer",
        "min": 1
      },
      {
        "id": "Procedure.performer.actor",
        "path": "Procedure.performer.actor",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ]
      },
      {
        "id": "Procedure.performer.actor.reference",
        "path": "Procedure.performer.actor.reference",
        "min": 1
      }
    ]
  }
}