<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="HealthLinkDiagnosticReport" />
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-category">
    <valueString value="Clinical.Diagnostics" />
  </extension>
  <extension url="http://hl7.org/fhir/StructureDefinition/structuredefinition-security-category">
    <valueCode value="patient" />
  </extension>
  <url value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport" />
  <version value="0.5.2" />
  <name value="HealthLinkDiagnosticReport" />
  <title value="Health Link DiagnosticReport 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="v2" />
    <uri value="http://hl7.org/v2" />
    <name value="HL7 v2 Mapping" />
  </mapping>
  <mapping>
    <identity value="rim" />
    <uri value="http://hl7.org/v3" />
    <name value="RIM Mapping" />
  </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="DiagnosticReport" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/DiagnosticReport" />
  <derivation value="constraint" />
  <differential>
    <element id="DiagnosticReport.id">
      <path value="DiagnosticReport.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/HealthLinkDiagnosticReport" />
      </constraint>
    </element>
    <element id="DiagnosticReport.identifier">
      <path value="DiagnosticReport.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="DiagnosticReport.identifier:mdp">
      <path value="DiagnosticReport.identifier" />
      <sliceName value="mdp" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="DiagnosticReport.identifier:mdp.use">
      <path value="DiagnosticReport.identifier.use" />
      <patternCode value="official" />
    </element>
    <element id="DiagnosticReport.identifier:mdp.system">
      <path value="DiagnosticReport.identifier.system" />
      <min value="1" />
      <patternUri value="http://203.157.10.8/hcode_2020/query_set.php" />
    </element>
    <element id="DiagnosticReport.identifier:mdp.value">
      <path value="DiagnosticReport.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/HealthLinkDiagnosticReport" />
      </constraint>
    </element>
    <element id="DiagnosticReport.category">
      <path value="DiagnosticReport.category" />
      <min value="1" />
      <constraint>
        <key value="health-link-7" />
        <severity value="error" />
        <human value="CodableConcept of a required field must have a coding or text" />
        <expression value="coding.exists() or text.exists()" />
        <source value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport" />
      </constraint>
      <binding>
        <strength value="preferred" />
        <valueSet value="http://hl7.org/fhir/ValueSet/diagnostic-service-sections" />
      </binding>
    </element>
    <element id="DiagnosticReport.category.coding.system">
      <path value="DiagnosticReport.category.coding.system" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.category.coding.code">
      <path value="DiagnosticReport.category.coding.code" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.category.coding.display">
      <path value="DiagnosticReport.category.coding.display" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.code">
      <path value="DiagnosticReport.code" />
      <constraint>
        <key value="health-link-7" />
        <severity value="error" />
        <human value="CodableConcept of a required field must have a coding or text" />
        <expression value="coding.exists() or text.exists()" />
        <source value="https://healthlink.go.th/fhir/StructureDefinition/HealthLinkDiagnosticReport" />
      </constraint>
    </element>
    <element id="DiagnosticReport.code.coding.system">
      <path value="DiagnosticReport.code.coding.system" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.code.coding.code">
      <path value="DiagnosticReport.code.coding.code" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.code.coding.display">
      <path value="DiagnosticReport.code.coding.display" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.subject">
      <path value="DiagnosticReport.subject" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Patient" />
      </type>
    </element>
    <element id="DiagnosticReport.subject.reference">
      <path value="DiagnosticReport.subject.reference" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.encounter.reference">
      <path value="DiagnosticReport.encounter.reference" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.effective[x]">
      <path value="DiagnosticReport.effective[x]" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this" />
        </discriminator>
        <ordered value="false" />
        <rules value="open" />
      </slicing>
      <min value="1" />
    </element>
    <element id="DiagnosticReport.effectivePeriod">
      <path value="DiagnosticReport.effectivePeriod" />
      <min value="0" />
      <max value="1" />
      <type>
        <code value="Period" />
      </type>
    </element>
    <element id="DiagnosticReport.effectivePeriod.start">
      <path value="DiagnosticReport.effectivePeriod.start" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.performer">
      <path value="DiagnosticReport.performer" />
      <min value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://hl7.org/fhir/StructureDefinition/Organization" />
      </type>
    </element>
    <element id="DiagnosticReport.performer.reference">
      <path value="DiagnosticReport.performer.reference" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.result.reference">
      <path value="DiagnosticReport.result.reference" />
      <min value="1" />
    </element>
    <element id="DiagnosticReport.media.link.reference">
      <path value="DiagnosticReport.media.link.reference" />
      <min value="1" />
    </element>
  </differential>
</StructureDefinition>