<StructureDefinition xmlns="http://hl7.org/fhir">
  <id value="TR01-response" />
  <meta>
    <versionId value="41" />
    <lastUpdated value="2022-09-20T12:34:52.235+00:00" />
    <source value="#eMKC1NLrCcOuFNh3" />
    <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/TR01-response" />
  <version value="0.1" />
  <name value="TR01Response" />
  <title value="Poruka odgovora na zahtjev za kreiranje uputnice (TR01)" />
  <status value="active" />
  <description value="Ovaj profil definira poruku koju CEZIH šalje kao odgovor na registraciju uputnice (TR01 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 (Task, ServiceRequest, DocumentReference) 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())" />
      </constraint>
      <constraint>
        <key value="rsp-2" />
        <severity value="error" />
        <human value="Zaglavlje poruke mora sadržavati reference prema svim FHIR resursima u poruci u atributu MessageHeader.focus" />
        <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())" />
      </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="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." />
      <fixedCoding>
        <system value="http://fhir.cezih.hr/specifikacije/CodeSystem/message-types" />
        <code value="3.1" />
      </fixedCoding>
    </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-procesa">
      <path value="Bundle.entry.resource.focus" />
      <sliceName value="stanje-procesa" />
      <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: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.resource.focus:ishod-obrade-zahtjeva">
      <path value="Bundle.entry.resource.focus" />
      <sliceName value="ishod-obrade-zahtjeva" />
      <max value="1" />
      <type>
        <code value="Reference" />
        <targetProfile value="http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod" />
      </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 registrirane 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" />
      <definition value="Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)" />
      <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="requested" />
    </element>
    <element id="Bundle.entry:Stanje.resource.statusReason">
      <path value="Bundle.entry.resource.statusReason" />
      <short value="Tranzicija" />
      <definition value="Element sadrži informaciju o tranziciji koja je dovela do trenutnog stanja poslovnog procesa uputnice. U ovom slučaju to je TR01." />
      <min value="1" />
      <fixedCodeableConcept>
        <coding>
          <system value="http://fhir.cezih.hr/specifikacije/CodeSystem/tranzicije-procesa-specijalisticke-uputnice" />
          <code value="TR01" />
        </coding>
      </fixedCodeableConcept>
    </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 ST01." />
      <min value="1" />
      <fixedCodeableConcept>
        <coding>
          <system value="http://fhir.cezih.hr/specifikacije/CodeSystem/status-procesa-specijalisticke-uputnice" />
          <code value="ST01" />
        </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:Uputnica">
      <path value="Bundle.entry" />
      <sliceName value="Uputnica" />
      <short value="Uputnica" />
      <comment value="Obavezno u slučaju uspjeha. U slučaju uspješno registrirane uputnice poruka će sadržavati ServiceRequest resurs s od strane FHIR servera definiranim identifikatorom 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" />
      <definition value="Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)" />
      <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.contained">
      <path value="Bundle.entry.resource.contained" />
      <short value="Uključeni resursi" />
      <definition value="ServiceRequest u odgovoru mora sadržavati sve dokumente priložene uz uputnicu." />
    </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>
    <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" />
      <definition value="Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)" />
      <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>
  </differential>
</StructureDefinition>