<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="e200-bundle" />
  <url value="http://esveikata.lt/Profile/Bundle/E200" />
  <version value="1.0.0" />
  <name value="E200Bundle" />
  <status value="active" />
  <date value="2023-02-09" />
  <description value="Lithuanian national fhir profile for E200 form bundle." />
  <fhirVersion value="5.0.0" />
  <kind value="resource" />
  <abstract value="false" />
  <type value="Bundle" />
  <baseDefinition value="http://hl7.org/fhir/StructureDefinition/Bundle" />
  <derivation value="constraint" />
  <differential>
    <element id="Bundle">
      <path value="Bundle" />
      <constraint>
        <key value="e200-bundle-9" />
        <severity value="error" />
        <human value="Can't find DiagnosticReport results in bundle." />
        <expression value="Bundle.entry.resource.ofType(DiagnosticReport).select(result.resolve().count() = result.count()).allTrue()" />
      </constraint>
      <constraint>
        <key value="e200-bundle-10" />
        <severity value="error" />
        <human value="Can't find ServiceRequest condition in bundle." />
        <expression value="Bundle.entry.resource.ofType(ServiceRequest).select(supportingInfo.reference.resolve().count() = supportingInfo.reference.count()).allTrue()" />
      </constraint>
      <constraint>
        <key value="e200-bundle-12" />
        <severity value="error" />
        <human value="Transaction must not contain SearchParameter resources." />
        <expression value="Bundle.entry.resource.ofType(SearchParameter).exists().not() and Bundle.entry.resource.ofType(CodeSystem).exists().not()" />
      </constraint>
    </element>
    <element id="Bundle.type">
      <path value="Bundle.type" />
      <min value="1" />
      <constraint>
        <key value="e200-bundle-1" />
        <severity value="error" />
        <human value="Bundle must be a document or a transaction." />
        <expression value="$this in ('document' | 'transaction')" />
      </constraint>
    </element>
    <element id="Bundle.entry.resource">
      <path value="Bundle.entry.resource" />
      <constraint>
        <key value="e200-bundle-2" />
        <severity value="error" />
        <human value="ServiceRequest must conform to the 'http://esveikata.lt/Profile/ServiceRequest' profile." />
        <expression value="$this is ServiceRequest implies $this.meta.profile.contains('http://esveikata.lt/Profile/ServiceRequest')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-3" />
        <severity value="error" />
        <human value="Specimen must conform to the 'http://esveikata.lt/Profile/Specimen' profile." />
        <expression value="$this is Specimen implies $this.meta.profile.contains('http://esveikata.lt/Profile/Specimen')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-4" />
        <severity value="error" />
        <human value="DiagnosticReport must conform to the 'http://esveikata.lt/Profile/DiagnosticReport' profile." />
        <expression value="$this is DiagnosticReport implies $this.meta.profile.contains('http://esveikata.lt/Profile/DiagnosticReport')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-5" />
        <severity value="error" />
        <human value="Observation must conform to the 'http://esveikata.lt/Profile/Observation' profile." />
        <expression value="$this is Observation implies $this.meta.profile.contains('http://esveikata.lt/Profile/Observation')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-6" />
        <severity value="error" />
        <human value="Practitioner must conform to the 'http://esveikata.lt/Profile/Practitioner' profile." />
        <expression value="$this is Practitioner implies $this.meta.profile.contains('http://esveikata.lt/Profile/Practitioner')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-7" />
        <severity value="error" />
        <human value="Organization must conform to the 'http://esveikata.lt/Profile/Organization' profile." />
        <expression value="$this is Organization implies $this.meta.profile.contains('http://esveikata.lt/Profile/Organization')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-8" />
        <severity value="error" />
        <human value="Composition must conform to the 'http://esveikata.lt/Profile/Composition/E200' profile." />
        <expression value="$this is Composition implies $this.meta.profile.contains('http://esveikata.lt/Profile/Composition/E200')" />
      </constraint>
      <constraint>
        <key value="e200-bundle-11" />
        <severity value="error" />
        <human value="Condition must conform to the 'http://esveikata.lt/Profile/Condition' profile." />
        <expression value="$this is Condition implies $this.meta.profile.contains('http://esveikata.lt/Profile/Condition')" />
      </constraint>
    </element>
  </differential>
</StructureDefinition>