<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="HealthLinkVisitComposition" />
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-category">
    <valueString value="Foundation.Documents" />
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category">
    <valueCode value="not-classified" />
  </extension>
  <url value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkVisitComposition" />
  <version value="0.5.2" />
  <name value="HealthLinkVisitComposition" />
  <title value="Health Link Visit Composition Profile" />
  <status value="active" />
  <fhirVersion value="4.0.1" />
  <mapping>
    <identity value="workflow" />
    <uri value="http://hl7.org/fhir/workflow" />
    <name value="Workflow Pattern" />
  </mapping>
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </mapping>
  <mapping>
    <identity value="cda" />
    <uri value="http://hl7.org/v3/cda" />
    <name value="CDA (R2)" />
  </mapping>
  <mapping>
    <identity value="fhirdocumentreference" />
    <uri value="http://hl7.org/fhir/documentreference" />
    <name value="FHIR DocumentReference" />
  </mapping>
  <mapping>
    <identity value="w5" />
    <uri value="http://hl7.org/fhir/fivews" />
    <name value="FiveWs Pattern Mapping" />
  </mapping>
  <kind value="resource" />
  <abstract value="false" />
  <type value="Composition" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Composition" />
  <derivation value="constraint" />
  <differential>
    <element id="Composition.id">
      <path value="Composition.id" />
      <min value="1" />
      <constraint>
        <key value="health-link-6" />
        <severity value="error" />
        <human value="Resource id must be 'mdp9Id-cid-uuid' (9-digit mdp9id + 13-digit cid + any uuid). Total length does not excced 64 chars." />
        <expression value="matches(&quot;^[0-9]{9}-[0-9]{13}-.*&quot;)" />
        <source value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkVisitComposition" />
      </constraint>
    </element>
    <element id="Composition.identifier.use">
      <path value="Composition.identifier.use" />
      <patternCode value="official" />
    </element>
    <element id="Composition.identifier.system">
      <path value="Composition.identifier.system" />
      <patternUri value="http://203.157.10.8/hcode_2020/query_set.php" />
    </element>
    <element id="Composition.identifier.value">
      <path value="Composition.identifier.value" />
      <min value="1" />
      <constraint>
        <key value="health-link-4" />
        <severity value="error" />
        <human value="Resource identifer.value must be a 9 digit number (hcode)" />
        <expression value="matches(&quot;^[0-9]{9}$&quot;)" />
        <source value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkVisitComposition" />
      </constraint>
    </element>
    <element id="Composition.type">
      <path value="Composition.type" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="18842-5" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.subject">
      <path value="Composition.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
      </type>
    </element>
    <element id="Composition.subject.reference">
      <path value="Composition.subject.reference" />
      <min value="1" />
    </element>
    <element id="Composition.encounter">
      <path value="Composition.encounter" />
      <min value="1" />
    </element>
    <element id="Composition.encounter.reference">
      <path value="Composition.encounter.reference" />
      <min value="1" />
    </element>
    <element id="Composition.author">
      <path value="Composition.author" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
      </type>
    </element>
    <element id="Composition.author.reference">
      <path value="Composition.author.reference" />
      <min value="1" />
    </element>
    <element id="Composition.title">
      <path value="Composition.title" />
      <fixedString value="Visit Composition" />
    </element>
    <element id="Composition.event">
      <path value="Composition.event" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="code" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="Composition.event:visit">
      <path value="Composition.event" />
      <sliceName value="visit" />
      <min value="1" />
      <max value="*" />
    </element>
    <element id="Composition.event:visit.code">
      <path value="Composition.event.code" />
      <min value="1" />
      <max value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="https://healthlink.go.th/fhir/ValueSet/EncounterClass" />
      </binding>
    </element>
    <element id="Composition.event:visit.code.coding">
      <path value="Composition.event.code.coding" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Composition.event:visit.period">
      <path value="Composition.event.period" />
      <min value="1" />
    </element>
    <element id="Composition.event:visit.period.start">
      <path value="Composition.event.period.start" />
      <min value="1" />
    </element>
    <element id="Composition.section">
      <path value="Composition.section" />
      <slicing>
        <discriminator>
          <type value="pattern" />
          <path value="code" />
        </discriminator>
        <rules value="open" />
      </slicing>
    </element>
    <element id="Composition.section.code">
      <path value="Composition.section.code" />
      <min value="1" />
    </element>
    <element id="Composition.section:allergyIntolerance">
      <path value="Composition.section" />
      <sliceName value="allergyIntolerance" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:allergyIntolerance.title">
      <path value="Composition.section.title" />
      <fixedString value="AllergyIntolerance" />
    </element>
    <element id="Composition.section:allergyIntolerance.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="48765-2" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:allergyIntolerance.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkAllergyIntolerance" />
      </type>
    </element>
    <element id="Composition.section:allergyIntolerance.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:medicationStatement">
      <path value="Composition.section" />
      <sliceName value="medicationStatement" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:medicationStatement.title">
      <path value="Composition.section.title" />
      <fixedString value="MedicationStatement" />
    </element>
    <element id="Composition.section:medicationStatement.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="10160-0" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:medicationStatement.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkMedicationStatement" />
      </type>
    </element>
    <element id="Composition.section:medicationStatement.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:immunization">
      <path value="Composition.section" />
      <sliceName value="immunization" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:immunization.title">
      <path value="Composition.section.title" />
      <fixedString value="Immunization" />
    </element>
    <element id="Composition.section:immunization.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="11369-6" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:immunization.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkImmunization" />
      </type>
    </element>
    <element id="Composition.section:immunization.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:encounterDiagnosis">
      <path value="Composition.section" />
      <sliceName value="encounterDiagnosis" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:encounterDiagnosis.title">
      <path value="Composition.section.title" />
      <fixedString value="Condition" />
    </element>
    <element id="Composition.section:encounterDiagnosis.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="11348-0" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:encounterDiagnosis.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkCondition" />
      </type>
    </element>
    <element id="Composition.section:encounterDiagnosis.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:problemListItem">
      <path value="Composition.section" />
      <sliceName value="problemListItem" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:problemListItem.title">
      <path value="Composition.section.title" />
      <fixedString value="Condition" />
    </element>
    <element id="Composition.section:problemListItem.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="11450-4" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:problemListItem.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkCondition" />
      </type>
    </element>
    <element id="Composition.section:problemListItem.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:procedure">
      <path value="Composition.section" />
      <sliceName value="procedure" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:procedure.title">
      <path value="Composition.section.title" />
      <fixedString value="Procedure" />
    </element>
    <element id="Composition.section:procedure.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="47519-4" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:procedure.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkProcedure" />
      </type>
    </element>
    <element id="Composition.section:procedure.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:diagnosticReport">
      <path value="Composition.section" />
      <sliceName value="diagnosticReport" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:diagnosticReport.title">
      <path value="Composition.section.title" />
      <fixedString value="DiagnosticReport" />
    </element>
    <element id="Composition.section:diagnosticReport.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="50398-7" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:diagnosticReport.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport" />
      </type>
    </element>
    <element id="Composition.section:diagnosticReport.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:laboratory">
      <path value="Composition.section" />
      <sliceName value="laboratory" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:laboratory.title">
      <path value="Composition.section.title" />
      <fixedString value="Observation" />
    </element>
    <element id="Composition.section:laboratory.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="30954-2" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:laboratory.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkObservation" />
      </type>
    </element>
    <element id="Composition.section:laboratory.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:vitalSigns">
      <path value="Composition.section" />
      <sliceName value="vitalSigns" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:vitalSigns.title">
      <path value="Composition.section.title" />
      <fixedString value="Observation" />
    </element>
    <element id="Composition.section:vitalSigns.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="8716-3" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:vitalSigns.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkObservation" />
      </type>
    </element>
    <element id="Composition.section:vitalSigns.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:documentReference">
      <path value="Composition.section" />
      <sliceName value="documentReference" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:documentReference.title">
      <path value="Composition.section.title" />
      <fixedString value="DocumentReference" />
    </element>
    <element id="Composition.section:documentReference.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="55109-3" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:documentReference.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDocumentReference" />
      </type>
    </element>
    <element id="Composition.section:documentReference.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:specimen">
      <path value="Composition.section" />
      <sliceName value="specimen" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:specimen.title">
      <path value="Composition.section.title" />
      <fixedString value="Specimen" />
    </element>
    <element id="Composition.section:specimen.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="66746-9" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:specimen.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkSpecimen" />
      </type>
    </element>
    <element id="Composition.section:specimen.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
    <element id="Composition.section:media">
      <path value="Composition.section" />
      <sliceName value="media" />
      <min value="0" />
      <max value="1" />
    </element>
    <element id="Composition.section:media.title">
      <path value="Composition.section.title" />
      <fixedString value="Media" />
    </element>
    <element id="Composition.section:media.code">
      <path value="Composition.section.code" />
      <patternCodeableConcept>
        <coding>
          <system value="http://loinc.org" />
          <code value="72170-4" />
        </coding>
      </patternCodeableConcept>
    </element>
    <element id="Composition.section:media.entry">
      <path value="Composition.section.entry" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkMedia" />
      </type>
    </element>
    <element id="Composition.section:media.entry.reference">
      <path value="Composition.section.entry.reference" />
      <min value="1" />
    </element>
  </differential>
</StructureDefinition>