{
  "resourceType": "StructureDefinition",
  "id": "TR01-response",
  "meta": {
    "versionId": "41",
    "lastUpdated": "2022-09-20T12:34:52.235+00:00",
    "source": "#eMKC1NLrCcOuFNh3",
    "security": [
      {
        "system": "https://trifolia-fhir.lantanagroup.com/security",
        "code": "everyone^read"
      },
      {
        "system": "https://trifolia-fhir.lantanagroup.com/security",
        "code": "everyone^write"
      }
    ]
  },
  "url": "http://fhir.cezih.hr/specifikacije/StructureDefinition/TR01-response",
  "version": "0.1",
  "name": "TR01Response",
  "title": "Poruka odgovora na zahtjev za kreiranje uputnice (TR01)",
  "status": "active",
  "description": "Ovaj profil definira poruku koju CEZIH šalje kao odgovor na registraciju uputnice (TR01 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 i opcionalno priloženom dokumentu (Task, ServiceRequest, DocumentReference) 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() and entry.resource.ofType(DocumentReference).exists().not())"
          },
          {
            "key": "rsp-2",
            "severity": "error",
            "human": "Zaglavlje poruke mora sadržavati reference prema svim FHIR resursima u poruci u atributu MessageHeader.focus",
            "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())"
          }
        ]
      },
      {
        "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": "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 bila inicirana request porukom.",
        "fixedCoding": {
          "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/message-types",
          "code": "3.1"
        }
      },
      {
        "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 TR01. ",
        "min": 1,
        "fixedCodeableConcept": {
          "coding": [
            {
              "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/tranzicije-procesa-specijalisticke-uputnice",
              "code": "TR01"
            }
          ]
        }
      },
      {
        "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 uputnica se nalazi u stanju ST01.",
        "min": 1,
        "fixedCodeableConcept": {
          "coding": [
            {
              "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/status-procesa-specijalisticke-uputnice",
              "code": "ST01"
            }
          ]
        }
      },
      {
        "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. U slučaju uspješno registrirane uputnice poruka će sadržavati ServiceRequest resurs s od strane FHIR servera definiranim identifikatorom uputnice.",
        "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": "Uključeni resursi",
        "definition": "ServiceRequest u odgovoru mora sadržavati sve dokumente priložene uz uputnicu."
      },
      {
        "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"
      }
    ]
  }
}