{
  "resourceType": "StructureDefinition",
  "id": "TR04-response",
  "meta": {
    "versionId": "22",
    "lastUpdated": "2022-09-20T14:13:42.855+00:00"
  },
  "url": "http://fhir.cezih.hr/specifikacije/StructureDefinition/TR04-response",
  "version": "0.1",
  "name": "TR04Response",
  "title": "Poruka odgovora dopune uputnice (TR04)",
  "status": "active",
  "description": "Ovaj profil definira poruku koju CEZIH šalje kao odgovor na registraciju dopune uputnice (TR04 Request).",
  "fhirVersion": "4.0.1",
  "kind": "resource",
  "abstract": false,
  "type": "Bundle",
  "baseDefinition": "http://hl7.org/fhir/StructureDefinition/Bundle",
  "derivation": "constraint",
  "differential": {
    "element": [
      {
        "id": "Bundle",
        "path": "Bundle",
        "constraint": [
          {
            "key": "rsp-1",
            "severity": "error",
            "human": "Odgovor mora sadržavati podatke o uputnici, statusu uputnice (Task, ServiceRequest) ako je zahtjev obrađen uspješno ili podatke o grešci (OperationOutcome)",
            "expression": "(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() )"
          },
          {
            "key": "rsp-2",
            "severity": "error",
            "human": "Zaglavlje poruke mora sadržavati referencu prema svim elementima poruke",
            "expression": "(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() )"
          },
          {
            "key": "rsp-3",
            "severity": "error",
            "human": "ServiceRequest mora sadržavati barem jedan priloženi dokument kojim je nadopunjena uputnica",
            "expression": "entry.resource.ofType(ServiceRequest).contained.ofType(DocumentReference).exists()"
          }
        ]
      },
      {
        "id": "Bundle.id",
        "path": "Bundle.id",
        "short": "Jedinstveni identifikator poruke",
        "min": 1
      },
      {
        "id": "Bundle.type",
        "path": "Bundle.type",
        "fixedCode": "message",
        "mustSupport": true
      },
      {
        "id": "Bundle.timestamp",
        "path": "Bundle.timestamp",
        "short": "Vrijeme kreiranja poruke",
        "min": 1
      },
      {
        "id": "Bundle.entry",
        "path": "Bundle.entry",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "resource"
            }
          ],
          "rules": "closed"
        }
      },
      {
        "id": "Bundle.entry:MessageHeader",
        "path": "Bundle.entry",
        "sliceName": "MessageHeader",
        "short": "Zaglavlje poruke",
        "min": 1,
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Bundle.entry:MessageHeader.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "Jedinstveni identifikator zapisa u poruci",
        "definition": "Identifikator definira pošiljatelj poruke u UUID formatu. Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)",
        "min": 1
      },
      {
        "id": "Bundle.entry:MessageHeader.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "MessageHeader",
            "profile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/hr-message-header"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.event[x]",
        "path": "Bundle.entry.resource.event[x]",
        "short": "Kod poruke",
        "definition": "Kod poruke definira koja je tranzicija inicirana request porukom.",
        "fixedCoding": {
          "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/message-types",
          "code": "3.4"
        }
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.response",
        "path": "Bundle.entry.resource.response",
        "short": "Reference na poruku zahtjeva",
        "min": 1
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.focus",
        "path": "Bundle.entry.resource.focus",
        "slicing": {
          "discriminator": [
            {
              "type": "type",
              "path": "$this.resolve()"
            }
          ],
          "rules": "closed"
        }
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.focus:stanje-procesa",
        "path": "Bundle.entry.resource.focus",
        "sliceName": "stanje-procesa",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/stanje-procesa-uputnice"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.focus:uputnica",
        "path": "Bundle.entry.resource.focus",
        "sliceName": "uputnica",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/specijalisticka-uputnica"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.focus:ishod-obrade-zahtjeva",
        "path": "Bundle.entry.resource.focus",
        "sliceName": "ishod-obrade-zahtjeva",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:MessageHeader.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:MessageHeader.request",
        "path": "Bundle.entry.request",
        "max": "0"
      },
      {
        "id": "Bundle.entry:MessageHeader.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Stanje",
        "path": "Bundle.entry",
        "sliceName": "Stanje",
        "short": "Stanje procesa",
        "definition": "Obavezno u slučaju uspjeha. \n\nU slučaju uspješno registrirane uputnice poruka će sadržavati Task resurs s trenutnim stanjem procesa uputnice.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Bundle.entry:Stanje.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "Jedinstveni identifikator zapisa u poruci",
        "definition": "Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)",
        "min": 1
      },
      {
        "id": "Bundle.entry:Stanje.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "Task",
            "profile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/stanje-procesa-uputnice"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:Stanje.resource.status",
        "path": "Bundle.entry.resource.status",
        "fixedCode": "requested"
      },
      {
        "id": "Bundle.entry:Stanje.resource.statusReason",
        "path": "Bundle.entry.resource.statusReason",
        "short": "Tranzicija",
        "definition": "Element sadrži informaciju o tranziciji koja je dovela do trenutnog stanja poslovnog procesa uputnice. U ovom slučaju to je TR04.",
        "min": 1,
        "fixedCodeableConcept": {
          "coding": [
            {
              "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/tranzicije-procesa-specijalisticke-uputnice",
              "code": "TR04"
            }
          ]
        }
      },
      {
        "id": "Bundle.entry:Stanje.resource.businessStatus",
        "path": "Bundle.entry.resource.businessStatus",
        "short": "Stanje poslovnog procesa uputnice",
        "definition": "Element sadrži trenutno stanje poslovnog procesa uputnice. U ovom slučaju, nakon odobravanja uputnica se nalazi u stanju ST04.",
        "min": 1,
        "fixedCodeableConcept": {
          "coding": [
            {
              "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/status-procesa-specijalisticke-uputnice",
              "code": "ST04"
            }
          ]
        }
      },
      {
        "id": "Bundle.entry:Stanje.resource.intent",
        "path": "Bundle.entry.resource.intent",
        "fixedCode": "order"
      },
      {
        "id": "Bundle.entry:Stanje.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Stanje.request",
        "path": "Bundle.entry.request",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Stanje.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Uputnica",
        "path": "Bundle.entry",
        "sliceName": "Uputnica",
        "short": "Uputnica",
        "comment": "Obavezno u slučaju uspjeha.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Bundle.entry:Uputnica.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "Jedinstveni identifikator zapisa u poruci",
        "definition": "Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)",
        "min": 1
      },
      {
        "id": "Bundle.entry:Uputnica.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "ServiceRequest",
            "profile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/specijalisticka-uputnica"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:Uputnica.resource.contained",
        "path": "Bundle.entry.resource.contained",
        "short": "Priloženi dokument",
        "definition": "ServiceRequest mora sadržavati barem jedan contained resurs koji sadrži priloženi dokument kojim je nadopunjena uputnica.",
        "min": 1
      },
      {
        "id": "Bundle.entry:Uputnica.resource.identifier",
        "path": "Bundle.entry.resource.identifier",
        "slicing": {
          "discriminator": [
            {
              "type": "value",
              "path": "system"
            }
          ],
          "ordered": false,
          "rules": "closed"
        },
        "min": 1,
        "max": "1"
      },
      {
        "id": "Bundle.entry:Uputnica.resource.identifier:identifikatorUputnice",
        "path": "Bundle.entry.resource.identifier",
        "sliceName": "identifikatorUputnice",
        "min": 1,
        "max": "1"
      },
      {
        "id": "Bundle.entry:Uputnica.resource.identifier:CustomerOrderNumber",
        "path": "Bundle.entry.resource.identifier",
        "sliceName": "CustomerOrderNumber",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Uputnica.resource.status",
        "path": "Bundle.entry.resource.status",
        "fixedCode": "active"
      },
      {
        "id": "Bundle.entry:Uputnica.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Uputnica.request",
        "path": "Bundle.entry.request",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Uputnica.response",
        "path": "Bundle.entry.response",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Ishod",
        "path": "Bundle.entry",
        "sliceName": "Ishod",
        "short": "Ishod operacije",
        "comment": "Šalje se u slučaju pogreške. Sadrži informaciju o pogrešci.",
        "max": "1",
        "mustSupport": true
      },
      {
        "id": "Bundle.entry:Ishod.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "Jedinstveni identifikator zapisa u poruci",
        "definition": "Ovaj identifikator mora biti jednak identifikatoru resursa (atribut id) koji se nalazi u zapisu (entry)",
        "min": 1
      },
      {
        "id": "Bundle.entry:Ishod.resource",
        "path": "Bundle.entry.resource",
        "min": 1,
        "type": [
          {
            "code": "OperationOutcome",
            "profile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:Ishod.search",
        "path": "Bundle.entry.search",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Ishod.request",
        "path": "Bundle.entry.request",
        "max": "0"
      },
      {
        "id": "Bundle.entry:Ishod.response",
        "path": "Bundle.entry.response",
        "max": "0"
      }
    ]
  }
}