<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="TR03-TR05-response" />
  <meta>
    <versionId value="34" />
    <lastUpdated value="2022-09-20T12:51:17.253+00:00" />
    <source value="#PuvUcHMQv6erhey4" />
    <security>
      <system value="https://trifolia-fhir.lantanagroup.com/security" />
      <code value="everyone^read" />
    </security>
    <security>
      <system value="https://trifolia-fhir.lantanagroup.com/security" />
      <code value="everyone^write" />
    </security>
  </meta>
  <url value="http://fhir.cezih.hr/specifikacije/StructureDefinition/TR03-TR05-response" />
  <version value="0.1" />
  <name value="TR03TR05Response" />
  <title value="Poruka odgovora na zahtjeva za dopunu uputnice (TR03, TR05)" />
  <status value="active" />
  <description value="Ovaj profil definira poruku koju CEZIH šalje kao odgovor na poruku o potrebi dopune uputnice (TR03 ili TR05 Request)." />
  <fhirVersion value="4.0.1" />
  <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="rsp-1" />
        <severity value="error" />
        <human value="Odgovor mora sadržavati podatke o uputnici, statusu uputnice i opcionalno priloženom dokumentu i informacijama o potrebnom dopunom zahtjeva (Task, ServiceRequest, DocumentReference, Communication) ako je zahtjev obrađen uspješno ili podatke o grešci (OperationOutcome)" />
        <expression value="(entry.resource.ofType(Task).exists() and entry.resource.ofType(ServiceRequest).exists() and entry.resource.ofType(OperationOutcome).exists().not()) or (entry.resource.ofType(OperationOutcome).exists() and entry.resource.ofType(Task).exists().not() and entry.resource.ofType(ServiceRequest).exists().not() and entry.resource.ofType(DocumentReference).exists().not() and entry.resource.ofType(Communication).exists().not())" />
      </constraint>
      <constraint>
        <key value="rsp-2" />
        <severity value="error" />
        <human value="Zaglavlje poruke mora sadržavati referencu prema svim elementima poruke" />
        <expression value="(entry.resource.ofType(MessageHeader).focus.resolve().ofType(Task).exists() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(ServiceRequest).exists() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(OperationOutcome).exists().not()) or (entry.resource.ofType(MessageHeader).focus.resolve().ofType(OperationOutcome).exists() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(Task).exists().not() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(ServiceRequest).exists().not() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(DocumentReference).exists().not() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(Communication).exists().not())" />
      </constraint>
      <constraint>
        <key value="rsp-3" />
        <severity value="warning" />
        <human value="ServiceRequest resurs mora imati referencu na contained resurs Communication (poruku o dopuni)" />
        <expression value="entry.resource.ofType(ServiceRequest).contained.ofType(Communication).where(topic.coding.code=3).exists()" />
      </constraint>
    </element>
    <element id="Bundle.id">
      <path value="Bundle.id" />
      <short value="Jedinstveni identifikator poruke" />
      <min value="1" />
    </element>
    <element id="Bundle.type">
      <path value="Bundle.type" />
      <fixedCode value="message" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.timestamp">
      <path value="Bundle.timestamp" />
      <short value="Vrijeme kreiranja poruke" />
      <min value="1" />
    </element>
    <element id="Bundle.entry">
      <path value="Bundle.entry" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="resource" />
        </discriminator>
        <rules value="closed" />
      </slicing>
    </element>
    <element id="Bundle.entry:MessageHeader">
      <path value="Bundle.entry" />
      <sliceName value="MessageHeader" />
      <short value="Zaglavlje poruke" />
      <min value="1" />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:MessageHeader.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="Jedinstveni identifikator zapisa u poruci" />
      <definition value="Identifikator definira pošiljatelj poruke u UUID formatu. Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:MessageHeader.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="MessageHeader" />
        <profile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/hr-message-header" />
      </type>
    </element>
    <element id="Bundle.entry:MessageHeader.resource.event[x]">
      <path value="Bundle.entry.resource.event[x]" />
      <short value="Kod poruke" />
      <definition value="Kod poruke definira koja je tranzicija bila inicirana request porukom." />
      <binding>
        <strength value="required" />
        <valueSet value="http://fhir.cezih.hr/specifikacije/ValueSet/dopuna-uputnice" />
      </binding>
    </element>
    <element id="Bundle.entry:MessageHeader.resource.response">
      <path value="Bundle.entry.resource.response" />
      <short value="Reference na poruku zahtjeva" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:MessageHeader.resource.focus">
      <path value="Bundle.entry.resource.focus" />
      <slicing>
        <discriminator>
          <type value="type" />
          <path value="$this.resolve()" />
        </discriminator>
        <rules value="closed" />
      </slicing>
    </element>
    <element id="Bundle.entry:MessageHeader.resource.focus:stanje">
      <path value="Bundle.entry.resource.focus" />
      <sliceName value="stanje" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/stanje-procesa-uputnice" />
      </type>
    </element>
    <element id="Bundle.entry:MessageHeader.resource.focus:rezultat-zahtjeva">
      <path value="Bundle.entry.resource.focus" />
      <sliceName value="rezultat-zahtjeva" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod" />
      </type>
    </element>
    <element id="Bundle.entry:MessageHeader.resource.focus:uputnica">
      <path value="Bundle.entry.resource.focus" />
      <sliceName value="uputnica" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/specijalisticka-uputnica" />
      </type>
    </element>
    <element id="Bundle.entry:MessageHeader.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:MessageHeader.request">
      <path value="Bundle.entry.request" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:MessageHeader.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Stanje">
      <path value="Bundle.entry" />
      <sliceName value="Stanje" />
      <short value="Stanje procesa" />
      <definition value="Obavezno u slučaju uspjeha. &#xA;&#xA;U slučaju uspješno registriranog zahtjeva za nadopunom uputnice poruka će sadržavati Task resurs s trenutnim stanjem procesa uputnice." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:Stanje.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="Jedinstveni identifikator zapisa u poruci" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:Stanje.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="Task" />
        <profile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/stanje-procesa-uputnice" />
      </type>
    </element>
    <element id="Bundle.entry:Stanje.resource.status">
      <path value="Bundle.entry.resource.status" />
      <fixedCode value="in-progress" />
    </element>
    <element id="Bundle.entry:Stanje.resource.statusReason">
      <path value="Bundle.entry.resource.statusReason" />
      <short value="Tranziciija" />
      <definition value="Element sadrži informaciju o tranziciji koja je dovela do trenutnog stanja poslovnog procesa uputnice. U ovom slučaju to je TR03 ili TR05." />
      <min value="1" />
      <binding>
        <strength value="required" />
        <valueSet value="http://fhir.cezih.hr/specifikacije/ValueSet/tranzicije-dopune-uputnice" />
      </binding>
    </element>
    <element id="Bundle.entry:Stanje.resource.businessStatus">
      <path value="Bundle.entry.resource.businessStatus" />
      <short value="Stanje poslovnog procesa uputnice" />
      <definition value="Element sadrži trenutno stanje poslovnog procesa uputnice. U ovom slučaju, uputnica se nalazi u stanju ST03." />
      <min value="1" />
      <fixedCodeableConcept>
        <coding>
          <system value="http://fhir.cezih.hr/specifikacije/CodeSystem/status-procesa-specijalisticke-uputnice" />
          <code value="ST03" />
        </coding>
      </fixedCodeableConcept>
    </element>
    <element id="Bundle.entry:Stanje.resource.intent">
      <path value="Bundle.entry.resource.intent" />
      <fixedCode value="order" />
    </element>
    <element id="Bundle.entry:Stanje.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Stanje.request">
      <path value="Bundle.entry.request" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Stanje.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Ishod">
      <path value="Bundle.entry" />
      <sliceName value="Ishod" />
      <short value="Ishod operacije" />
      <comment value="Šalje se u slučaju pogreške. Sadrži informaciju o pogrešci." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:Ishod.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="Jedinstveni identifikator zapisa u poruci" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:Ishod.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="OperationOutcome" />
        <profile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod" />
      </type>
    </element>
    <element id="Bundle.entry:Ishod.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Ishod.request">
      <path value="Bundle.entry.request" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Ishod.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Uputnica">
      <path value="Bundle.entry" />
      <sliceName value="Uputnica" />
      <definition value="Obavezno u slučaju uspjeha. U slučaju uspješno registrirane poruke o potrebi dopune uputnice poruka će sadržavati ServiceRequest resurs originalne uputnice." />
      <max value="1" />
      <mustSupport value="true" />
    </element>
    <element id="Bundle.entry:Uputnica.fullUrl">
      <path value="Bundle.entry.fullUrl" />
      <short value="Jedinstveni identifikator zapisa u poruci" />
      <min value="1" />
    </element>
    <element id="Bundle.entry:Uputnica.resource">
      <path value="Bundle.entry.resource" />
      <min value="1" />
      <type>
        <code value="ServiceRequest" />
        <profile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/specijalisticka-uputnica" />
      </type>
    </element>
    <element id="Bundle.entry:Uputnica.resource.identifier">
      <path value="Bundle.entry.resource.identifier" />
      <slicing>
        <discriminator>
          <type value="value" />
          <path value="system" />
        </discriminator>
        <ordered value="false" />
        <rules value="closed" />
      </slicing>
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Bundle.entry:Uputnica.resource.identifier:identifikatorUputnice">
      <path value="Bundle.entry.resource.identifier" />
      <sliceName value="identifikatorUputnice" />
      <min value="1" />
      <max value="1" />
    </element>
    <element id="Bundle.entry:Uputnica.resource.identifier:CustomerOrderNumber">
      <path value="Bundle.entry.resource.identifier" />
      <sliceName value="CustomerOrderNumber" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Uputnica.resource.status">
      <path value="Bundle.entry.resource.status" />
      <fixedCode value="active" />
    </element>
    <element id="Bundle.entry:Uputnica.search">
      <path value="Bundle.entry.search" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Uputnica.request">
      <path value="Bundle.entry.request" />
      <max value="0" />
    </element>
    <element id="Bundle.entry:Uputnica.response">
      <path value="Bundle.entry.response" />
      <max value="0" />
    </element>
  </differential>
</StructureDefinition>