{
  "resourceType": "StructureDefinition",
  "id": "HealthLinkDiagnosticReport",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Clinical.Diagnostics"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "patient"
    }
  ],
  "url": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport",
  "version": "0.5.2",
  "name": "HealthLinkDiagnosticReport",
  "title": "Health Link DiagnosticReport Profile",
  "status": "active",
  "fhirVersion": "4.0.1",
  "mapping": [
    {
      "identity": "workflow",
      "uri": "http://hl7.org/fhir/workflow",
      "name": "Workflow Pattern"
    },
    {
      "identity": "v2",
      "uri": "http://hl7.org/v2",
      "name": "HL7 v2 Mapping"
    },
    {
      "identity": "rim",
      "uri": "http://hl7.org/v3",
      "name": "RIM Mapping"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "DiagnosticReport",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/DiagnosticReport",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "DiagnosticReport.id",
        "path": "DiagnosticReport.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/HealthLinkDiagnosticReport"
          }
        ]
      },
      {
        "id": "DiagnosticReport.identifier",
        "path": "DiagnosticReport.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "DiagnosticReport.identifier:mdp",
        "path": "DiagnosticReport.identifier",
        "sliceName": "mdp",
        "min": 1,
        "max": "1"
      },
      {
        "id": "DiagnosticReport.identifier:mdp.use",
        "path": "DiagnosticReport.identifier.use",
        "patternCode": "official"
      },
      {
        "id": "DiagnosticReport.identifier:mdp.system",
        "path": "DiagnosticReport.identifier.system",
        "min": 1,
        "patternUri": "http://203.157.10.8/hcode_2020/query_set.php"
      },
      {
        "id": "DiagnosticReport.identifier:mdp.value",
        "path": "DiagnosticReport.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/HealthLinkDiagnosticReport"
          }
        ]
      },
      {
        "id": "DiagnosticReport.category",
        "path": "DiagnosticReport.category",
        "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/HealthLinkDiagnosticReport"
          }
        ],
        "binding": {
          "strength": "preferred",
          "valueSet": "http://hl7.org/fhir/ValueSet/diagnostic-service-sections"
        }
      },
      {
        "id": "DiagnosticReport.category.coding.system",
        "path": "DiagnosticReport.category.coding.system",
        "min": 1
      },
      {
        "id": "DiagnosticReport.category.coding.code",
        "path": "DiagnosticReport.category.coding.code",
        "min": 1
      },
      {
        "id": "DiagnosticReport.category.coding.display",
        "path": "DiagnosticReport.category.coding.display",
        "min": 1
      },
      {
        "id": "DiagnosticReport.code",
        "path": "DiagnosticReport.code",
        "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/HealthLinkDiagnosticReport"
          }
        ]
      },
      {
        "id": "DiagnosticReport.code.coding.system",
        "path": "DiagnosticReport.code.coding.system",
        "min": 1
      },
      {
        "id": "DiagnosticReport.code.coding.code",
        "path": "DiagnosticReport.code.coding.code",
        "min": 1
      },
      {
        "id": "DiagnosticReport.code.coding.display",
        "path": "DiagnosticReport.code.coding.display",
        "min": 1
      },
      {
        "id": "DiagnosticReport.subject",
        "path": "DiagnosticReport.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Patient"
            ]
          }
        ]
      },
      {
        "id": "DiagnosticReport.subject.reference",
        "path": "DiagnosticReport.subject.reference",
        "min": 1
      },
      {
        "id": "DiagnosticReport.encounter.reference",
        "path": "DiagnosticReport.encounter.reference",
        "min": 1
      },
      {
        "id": "DiagnosticReport.effective[x]",
        "path": "DiagnosticReport.effective[x]",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this"
            }
          ],
          "ordered": false,
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "DiagnosticReport.effectivePeriod",
        "path": "DiagnosticReport.effectivePeriod",
        "min": 0,
        "max": "1",
        "type": [
          {
            "code": "Period"
          }
        ]
      },
      {
        "id": "DiagnosticReport.effectivePeriod.start",
        "path": "DiagnosticReport.effectivePeriod.start",
        "min": 1
      },
      {
        "id": "DiagnosticReport.performer",
        "path": "DiagnosticReport.performer",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ]
      },
      {
        "id": "DiagnosticReport.performer.reference",
        "path": "DiagnosticReport.performer.reference",
        "min": 1
      },
      {
        "id": "DiagnosticReport.result.reference",
        "path": "DiagnosticReport.result.reference",
        "min": 1
      },
      {
        "id": "DiagnosticReport.media.link.reference",
        "path": "DiagnosticReport.media.link.reference",
        "min": 1
      }
    ]
  }
}