{
  "resourceType": "StructureDefinition",
  "id": "TR03-TR05-response",
  "meta": {
    "versionId": "34",
    "lastUpdated": "2022-09-20T12:51:17.253+00:00",
    "source": "#PuvUcHMQv6erhey4",
    "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/TR03-TR05-response",
  "version": "0.1",
  "name": "TR03TR05Response",
  "title": "Poruka odgovora na zahtjeva za dopunu uputnice (TR03, TR05)",
  "status": "active",
  "description": "Ovaj profil definira poruku koju CEZIH šalje kao odgovor na poruku o potrebi dopune uputnice (TR03 ili TR05 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 i informacijama o potrebnom dopunom zahtjeva (Task, ServiceRequest, DocumentReference, Communication) 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() and entry.resource.ofType(Communication).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() and entry.resource.ofType(MessageHeader).focus.resolve().ofType(Communication).exists().not())"
          },
          {
            "key": "rsp-3",
            "severity": "warning",
            "human": "ServiceRequest resurs mora imati referencu na contained resurs Communication (poruku o dopuni)",
            "expression": "entry.resource.ofType(ServiceRequest).contained.ofType(Communication).where(topic.coding.code=3).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 bila inicirana request porukom.",
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.cezih.hr/specifikacije/ValueSet/dopuna-uputnice"
        }
      },
      {
        "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",
        "path": "Bundle.entry.resource.focus",
        "sliceName": "stanje",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/stanje-procesa-uputnice"
            ]
          }
        ]
      },
      {
        "id": "Bundle.entry:MessageHeader.resource.focus:rezultat-zahtjeva",
        "path": "Bundle.entry.resource.focus",
        "sliceName": "rezultat-zahtjeva",
        "max": "1",
        "type": [
          {
            "code": "Reference",
            "targetProfile": [
              "http://fhir.cezih.hr/specifikacije/StructureDefinition/ishod"
            ]
          }
        ]
      },
      {
        "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.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 registriranog zahtjeva za nadopunom 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",
        "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": "in-progress"
      },
      {
        "id": "Bundle.entry:Stanje.resource.statusReason",
        "path": "Bundle.entry.resource.statusReason",
        "short": "Tranziciija",
        "definition": "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": 1,
        "binding": {
          "strength": "required",
          "valueSet": "http://fhir.cezih.hr/specifikacije/ValueSet/tranzicije-dopune-uputnice"
        }
      },
      {
        "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 ST03.",
        "min": 1,
        "fixedCodeableConcept": {
          "coding": [
            {
              "system": "http://fhir.cezih.hr/specifikacije/CodeSystem/status-procesa-specijalisticke-uputnice",
              "code": "ST03"
            }
          ]
        }
      },
      {
        "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: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",
        "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"
      },
      {
        "id": "Bundle.entry:Uputnica",
        "path": "Bundle.entry",
        "sliceName": "Uputnica",
        "definition": "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": "1",
        "mustSupport": true
      },
      {
        "id": "Bundle.entry:Uputnica.fullUrl",
        "path": "Bundle.entry.fullUrl",
        "short": "Jedinstveni identifikator zapisa u poruci",
        "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.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"
      }
    ]
  }
}