{
  "resourceType": "StructureDefinition",
  "id": "HealthLinkVisitComposition",
  "extension": [
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-category",
      "valueString": "Foundation.Documents"
    },
    {
      "url": "http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category",
      "valueCode": "not-classified"
    }
  ],
  "url": "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkVisitComposition",
  "version": "0.5.2",
  "name": "HealthLinkVisitComposition",
  "title": "Health Link Visit Composition 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": "cda",
      "uri": "http://hl7.org/v3/cda",
      "name": "CDA (R2)"
    },
    {
      "identity": "fhirdocumentreference",
      "uri": "http://hl7.org/fhir/documentreference",
      "name": "FHIR DocumentReference"
    },
    {
      "identity": "w5",
      "uri": "http://hl7.org/fhir/fivews",
      "name": "FiveWs Pattern Mapping"
    }
  ],
  "kind": "resource",
  "abstract": false,
  "type": "Composition",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Composition",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Composition.id",
        "path": "Composition.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/HealthLinkVisitComposition"
          }
        ]
      },
      {
        "id": "Composition.identifier.use",
        "path": "Composition.identifier.use",
        "patternCode": "official"
      },
      {
        "id": "Composition.identifier.system",
        "path": "Composition.identifier.system",
        "patternUri": "http://203.157.10.8/hcode_2020/query_set.php"
      },
      {
        "id": "Composition.identifier.value",
        "path": "Composition.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/HealthLinkVisitComposition"
          }
        ]
      },
      {
        "id": "Composition.type",
        "path": "Composition.type",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "18842-5",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.subject",
        "path": "Composition.subject",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Patient"
            ]
          }
        ]
      },
      {
        "id": "Composition.subject.reference",
        "path": "Composition.subject.reference",
        "min": 1
      },
      {
        "id": "Composition.encounter",
        "path": "Composition.encounter",
        "min": 1
      },
      {
        "id": "Composition.encounter.reference",
        "path": "Composition.encounter.reference",
        "min": 1
      },
      {
        "id": "Composition.author",
        "path": "Composition.author",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://hl7.org/fhir/StructureDefinition/Organization"
            ]
          }
        ]
      },
      {
        "id": "Composition.author.reference",
        "path": "Composition.author.reference",
        "min": 1
      },
      {
        "id": "Composition.title",
        "path": "Composition.title",
        "fixedString": "Visit Composition"
      },
      {
        "id": "Composition.event",
        "path": "Composition.event",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "code"
            }
          ],
          "rules": "open"
        },
        "min": 1
      },
      {
        "id": "Composition.event:visit",
        "path": "Composition.event",
        "sliceName": "visit",
        "min": 1,
        "max": "*"
      },
      {
        "id": "Composition.event:visit.code",
        "path": "Composition.event.code",
        "min": 1,
        "max": "1",
        "binding": {
          "strength": "required",
          "valueSet": "https://healthlink.go.th/fhir/ValueSet/EncounterClass"
        }
      },
      {
        "id": "Composition.event:visit.code.coding",
        "path": "Composition.event.code.coding",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Composition.event:visit.period",
        "path": "Composition.event.period",
        "min": 1
      },
      {
        "id": "Composition.event:visit.period.start",
        "path": "Composition.event.period.start",
        "min": 1
      },
      {
        "id": "Composition.section",
        "path": "Composition.section",
        "slicing": {
          "discriminator": [
            {
              "type": "pattern",
              "path": "code"
            }
          ],
          "rules": "open"
        }
      },
      {
        "id": "Composition.section.code",
        "path": "Composition.section.code",
        "min": 1
      },
      {
        "id": "Composition.section:allergyIntolerance",
        "path": "Composition.section",
        "sliceName": "allergyIntolerance",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:allergyIntolerance.title",
        "path": "Composition.section.title",
        "fixedString": "AllergyIntolerance"
      },
      {
        "id": "Composition.section:allergyIntolerance.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "48765-2",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:allergyIntolerance.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkAllergyIntolerance"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:allergyIntolerance.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:medicationStatement",
        "path": "Composition.section",
        "sliceName": "medicationStatement",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:medicationStatement.title",
        "path": "Composition.section.title",
        "fixedString": "MedicationStatement"
      },
      {
        "id": "Composition.section:medicationStatement.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "10160-0",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:medicationStatement.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkMedicationStatement"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:medicationStatement.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:immunization",
        "path": "Composition.section",
        "sliceName": "immunization",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:immunization.title",
        "path": "Composition.section.title",
        "fixedString": "Immunization"
      },
      {
        "id": "Composition.section:immunization.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "11369-6",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:immunization.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkImmunization"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:immunization.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:encounterDiagnosis",
        "path": "Composition.section",
        "sliceName": "encounterDiagnosis",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:encounterDiagnosis.title",
        "path": "Composition.section.title",
        "fixedString": "Condition"
      },
      {
        "id": "Composition.section:encounterDiagnosis.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "11348-0",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:encounterDiagnosis.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkCondition"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:encounterDiagnosis.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:problemListItem",
        "path": "Composition.section",
        "sliceName": "problemListItem",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:problemListItem.title",
        "path": "Composition.section.title",
        "fixedString": "Condition"
      },
      {
        "id": "Composition.section:problemListItem.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "11450-4",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:problemListItem.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkCondition"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:problemListItem.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:procedure",
        "path": "Composition.section",
        "sliceName": "procedure",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:procedure.title",
        "path": "Composition.section.title",
        "fixedString": "Procedure"
      },
      {
        "id": "Composition.section:procedure.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "47519-4",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:procedure.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:procedure.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:diagnosticReport",
        "path": "Composition.section",
        "sliceName": "diagnosticReport",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:diagnosticReport.title",
        "path": "Composition.section.title",
        "fixedString": "DiagnosticReport"
      },
      {
        "id": "Composition.section:diagnosticReport.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "50398-7",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:diagnosticReport.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:diagnosticReport.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:laboratory",
        "path": "Composition.section",
        "sliceName": "laboratory",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:laboratory.title",
        "path": "Composition.section.title",
        "fixedString": "Observation"
      },
      {
        "id": "Composition.section:laboratory.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "30954-2",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:laboratory.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkObservation"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:laboratory.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:vitalSigns",
        "path": "Composition.section",
        "sliceName": "vitalSigns",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:vitalSigns.title",
        "path": "Composition.section.title",
        "fixedString": "Observation"
      },
      {
        "id": "Composition.section:vitalSigns.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "8716-3",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:vitalSigns.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkObservation"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:vitalSigns.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:documentReference",
        "path": "Composition.section",
        "sliceName": "documentReference",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:documentReference.title",
        "path": "Composition.section.title",
        "fixedString": "DocumentReference"
      },
      {
        "id": "Composition.section:documentReference.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "55109-3",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:documentReference.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDocumentReference"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:documentReference.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:specimen",
        "path": "Composition.section",
        "sliceName": "specimen",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:specimen.title",
        "path": "Composition.section.title",
        "fixedString": "Specimen"
      },
      {
        "id": "Composition.section:specimen.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "66746-9",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:specimen.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkSpecimen"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:specimen.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      },
      {
        "id": "Composition.section:media",
        "path": "Composition.section",
        "sliceName": "media",
        "min": 0,
        "max": "1"
      },
      {
        "id": "Composition.section:media.title",
        "path": "Composition.section.title",
        "fixedString": "Media"
      },
      {
        "id": "Composition.section:media.code",
        "path": "Composition.section.code",
        "patternCodeableConcept": {
          "coding": [
            {
              "code": "72170-4",
              "system": "http://loinc.org"
            }
          ]
        }
      },
      {
        "id": "Composition.section:media.entry",
        "path": "Composition.section.entry",
        "min": 1,
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "https://healthlink.go.th/fhir/StructureDefinition/HealthLinkMedia"
            ]
          }
        ]
      },
      {
        "id": "Composition.section:media.entry.reference",
        "path": "Composition.section.entry.reference",
        "min": 1
      }
    ]
  }
}