{
  "info": {
    "_postman_id": "dde4a938-4849-4658-abd5-326c358a05fd",
    "name": "Протокол 1.3 Заключение профилактической рентгенографии грудной клетки",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "23769375",
    "_collection_link": "https://go.postman.co/collection/23769375-dde4a938-4849-4658-abd5-326c358a05fd?source=collection_link"
  },
  "item": [
    {
      "name": "1. Импорт заключения профилактической рентгенографии грудной клетки в ЦИСЗ",
      "item": [
        {
          "name": "1.1 - 1.2 Медицинский работник формирует заключение и импортирует его в ЦИСЗ",
          "item": [
            {
              "name": "Предварительные условия - авторизация врача",
              "item": [
                {
                  "name": "Достать врача и организацию из токена врача и добавить в переменную",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const jwt = pm.request.auth.oauth2.get(\"accessToken\");\r",
                          "console.log(jwt);\r",
                          "if (jwt) {\r",
                          "    let payload = jwt.split('.')[1];\r",
                          "    payload = payload.replace(/-/g, '+').replace(/_/g, '/');\r",
                          "    while (payload.length % 4) payload += '=';\r",
                          "    let decoded = JSON.parse(atob(payload));\r",
                          "    console.log(decoded)\r",
                          "    let practitionerId = decoded.practitioner_id || decoded.practitionerId || decoded[\"practitioner_id\"];\r",
                          "    let organizationId = decoded.organization_id || decoded.organizationId || decoded[\"organization_id\"];\r",
                          "    if (practitionerId) pm.environment.set(\"PractitionerId\", practitionerId);\r",
                          "    if (organizationId) pm.environment.set(\"OrganizationId\", organizationId);\r",
                          "} else {\r",
                          "    console.log(\"JWT токен не найден в переменных коллекции\");\r",
                          "}"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "protocolProfileBehavior": {
                    "disableBodyPruning": true
                  },
                  "request": {
                    "method": "GET",
                    "header": [
                      {
                        "key": "X-Fhir-By-Version",
                        "value": "0.3.4934",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": ""
                    },
                    "url": {
                      "raw": "https://postman-echo.com/get",
                      "protocol": "https",
                      "host": [
                        "postman-echo",
                        "com"
                      ],
                      "path": [
                        "get"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Достать PractitionerRole врача (PractitionerRole)",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "var jsonData = pm.response.json();\r",
                          "let practitionerRole = jsonData.entry.find(obj => obj.resource.resourceType === \"PractitionerRole\").resource.id;\r",
                          "\r",
                          "pm.environment.set(\"PractitionerRole\", practitionerRole);\r",
                          "console.log(practitionerRole)\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [],
                    "url": {
                      "raw": "https://staging.cisz.by/api/fhir/PractitionerRole?practitioner={{PractitionerId}}",
                      "protocol": "https",
                      "host": [
                        "staging",
                        "cisz",
                        "by"
                      ],
                      "path": [
                        "api",
                        "fhir",
                        "PractitionerRole"
                      ],
                      "query": [
                        {
                          "key": "practitioner",
                          "value": "{{PractitionerId}}"
                        }
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Достать структурное подразделение врача (LocationId)",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "let json = pm.response.json();\r",
                          "let locationValue = null;\r",
                          "\r",
                          "if (Array.isArray(json.entry)) {\r",
                          "    for (let entry of json.entry) {\r",
                          "        if (\r",
                          "            entry.resource &&\r",
                          "            entry.resource.resourceType === \"PractitionerRole\" &&\r",
                          "            Array.isArray(entry.resource.location) &&\r",
                          "            entry.resource.location.length > 0\r",
                          "        ) {\r",
                          "            // Берём reference первого location и извлекаем только UUID\r",
                          "            let ref = entry.resource.location[0].reference;\r",
                          "            if (typeof ref === \"string\" && ref.startsWith(\"Location/\")) {\r",
                          "                locationValue = ref.split(\"/\")[1]; // или: ref.replace(\"Location/\", \"\")\r",
                          "            }\r",
                          "            break;\r",
                          "        }\r",
                          "    }\r",
                          "}\r",
                          "\r",
                          "if (locationValue) {\r",
                          "    pm.environment.set(\"LocationId\", locationValue);\r",
                          "    console.log(\"location сохранён:\", locationValue);\r",
                          "} else {\r",
                          "    console.log(\"location не найден\");\r",
                          "}\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [],
                    "url": {
                      "raw": "https://staging.cisz.by/api/fhir/PractitionerRole?_id={{PractitionerRole}}",
                      "protocol": "https",
                      "host": [
                        "staging",
                        "cisz",
                        "by"
                      ],
                      "path": [
                        "api",
                        "fhir",
                        "PractitionerRole"
                      ],
                      "query": [
                        {
                          "key": "_id",
                          "value": "{{PractitionerRole}}"
                        }
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "Поиск пациента по идентификатору (patientId)",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "var jsonData = pm.response.json();\r",
                      "let patientId = jsonData.entry.find(obj => obj.resource.resourceType === \"Patient\").resource.id;\r",
                      "\r",
                      "pm.environment.set(\"patientId\", patientId);\r",
                      "console.log(patientId)\r",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Patient?identifier=3021194E003PB3",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Patient"
                  ],
                  "query": [
                    {
                      "key": "identifier",
                      "value": "3021194E003PB3"
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Метод проверки наличия запроса на получение заключения в контексте Пациента",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Patient/{{patientId}}/DiagnosticReport?_profile=https://fhir.by/StructureDefinition/DiagnosticReportFluorography&_sort=-_lastUpdated",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Patient",
                    "{{patientId}}",
                    "DiagnosticReport"
                  ],
                  "query": [
                    {
                      "key": "_profile",
                      "value": "https://fhir.by/StructureDefinition/DiagnosticReportFluorography"
                    },
                    {
                      "key": "_sort",
                      "value": "-_lastUpdated"
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Метод импорта пакета медицинской информации - заключение профилактической рентгенографии грудной клетки",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Валидный бандл должен отработать со статусом 202\", function () {\r",
                      "    pm.response.to.have.status(202);\r",
                      "});\r",
                      "\r",
                      "var jsonData = pm.response.json();\r",
                      "let bundleId = jsonData.parameter.find(obj => obj.name === \"ResourceId\").valueString;\r",
                      "let statusReference = jsonData.parameter.find(obj => obj.name === \"OperationStatusReference\");\r",
                      "\r",
                      "console.log(statusReference.valueReference.reference);\r",
                      "\r",
                      "pm.collectionVariables.set(\"bundleId\", bundleId);\r",
                      "pm.collectionVariables.set(\"StatusUrl\", statusReference.valueReference.reference);\r",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                },
                {
                  "listen": "prerequest",
                  "script": {
                    "exec": [
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "X-Fhir-By-Version",
                    "value": "active",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\r\n    \"resourceType\": \"Bundle\",\r\n    \"id\": \"{{$guid}}\",\r\n    \"meta\": {\r\n        \"profile\": [\r\n            \"https://fhir.by/AbstractArea/StructureDefinition/Bundle/MedicationDocument\"\r\n        ]\r\n    },\r\n    \"identifier\": {\r\n        \"system\": \"urn:ietf:rfc:3986\",\r\n        \"value\": \"{{$guid}}\"\r\n    },\r\n    \"type\": \"document\",\r\n    \"timestamp\": \"{{$isoTimestamp}}\",\r\n    \"entry\": [\r\n        {\r\n            \"fullUrl\": \"Composition/CompositionTest\",\r\n            \"resource\": {\r\n                \"resourceType\": \"Composition\",\r\n                \"id\": \"CompositionBundleEpisode1\",\r\n                \"meta\": {\r\n                    \"profile\": [\r\n                        \"https://fhir.by/StructureDefinition/CompDocument\"\r\n                    ]\r\n                },\r\n                \"status\": \"final\",\r\n                \"type\": {\r\n                    \"coding\": [\r\n                        {\r\n                            \"system\": \"https://fhir.by/ValueSet/CompositionType\",\r\n                            \"code\": \"general\",\r\n                            \"display\": \"Общая медицинская информация\"\r\n                        }\r\n                    ]\r\n                },\r\n                \"subject\": [\r\n                    {\r\n                        \"reference\": \"Patient/pa-460c7c8a-355e-11f0-9dc6-b46dacb28658\"\r\n                    }\r\n                ],\r\n                \"date\": \"2025-12-03\",\r\n                \"author\": [\r\n                    {\r\n                        \"reference\": \"Practitioner/{{PractitionerId}}\"\r\n                    }\r\n                ],\r\n                \"title\": \"CompDocument\",\r\n                \"custodian\": {\r\n                    \"reference\": \"Organization/{{OrganizationId}}\"\r\n                }\r\n            }\r\n        },\r\n        {\r\n            \"fullUrl\": \"Patient/pa-460c7c8a-355e-11f0-9dc6-b46dacb28658\",\r\n            \"resource\": {\r\n                \"resourceType\": \"Patient\",\r\n                \"id\": \"pa-460c7c8a-355e-11f0-9dc6-b46dacb28658\",\r\n                \"meta\": {\r\n                    \"profile\": [\r\n                        \"https://fhir.by/StructureDefinition/PatientWithIdentificationNumber\"\r\n                    ]\r\n                },\r\n                \"identifier\": [\r\n                    {\r\n                        \"type\": {\r\n                            \"coding\": [\r\n                                {\r\n                                    \"system\": \"https://fhir.by/ValueSet/PersonalDocumentType\",\r\n                                    \"code\": \"INP\"\r\n                                }\r\n                            ]\r\n                        },\r\n                        \"value\": \"3021194E003PB3\",\r\n                        \"period\": {\r\n                            \"start\": \"2024-01-31\"\r\n                        }\r\n                    },\r\n                    {\r\n                        \"extension\": [\r\n                            {\r\n                                \"extension\": [\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PassportIssuedString\",\r\n                                        \"valueString\": \"Центральным РУВД г Минска, 11.08.2021\"\r\n                                    },\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PassportIssuedDate\",\r\n                                        \"valueDate\": \"2021-08-11\"\r\n                                    },\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PassportIssuedCode\",\r\n                                        \"valueCodeableConcept\": {\r\n                                            \"coding\": [\r\n                                                {\r\n                                                    \"system\": \"https://fhir.by/ValueSet/OCAM\",\r\n                                                    \"code\": \"106\"\r\n                                                }\r\n                                            ]\r\n                                        }\r\n                                    }\r\n                                ],\r\n                                \"url\": \"https://fhir.by/StructureDefinition/PassportIssued\"\r\n                            }\r\n                        ],\r\n                        \"use\": \"usual\",\r\n                        \"type\": {\r\n                            \"coding\": [\r\n                                {\r\n                                    \"system\": \"https://fhir.by/ValueSet/PersonalDocumentType\",\r\n                                    \"code\": \"Passport-RB\"\r\n                                }\r\n                            ]\r\n                        },\r\n                        \"value\": \"MP2633958\"\r\n                    }\r\n                ],\r\n                \"active\": true,\r\n                \"name\": [\r\n                    {\r\n                        \"family\": \"Иванов\",\r\n                        \"given\": [\r\n                            \"Владислав\",\r\n                            \"Эдуардович\"\r\n                        ]\r\n                    }\r\n                ],\r\n                \"telecom\": [\r\n                    {\r\n                        \"extension\": [\r\n                            {\r\n                                \"extension\": [\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PatientNotificationType\",\r\n                                        \"valueCodeableConcept\": {\r\n                                            \"coding\": [\r\n                                                {\r\n                                                    \"system\": \"https://fhir.by/ValueSet/PatientNotificationType\",\r\n                                                    \"version\": \"1.9\",\r\n                                                    \"code\": \"SMS\",\r\n                                                    \"display\": \"SMS\"\r\n                                                }\r\n                                            ]\r\n                                        }\r\n                                    },\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PatientConsentForNotification\",\r\n                                        \"valueBoolean\": true\r\n                                    }\r\n                                ],\r\n                                \"url\": \"https://fhir.by/StructureDefinition/PatientTelecomPurpose\"\r\n                            }\r\n                        ],\r\n                        \"system\": \"phone\",\r\n                        \"value\": \"+375 29 50011-11\"\r\n                    },\r\n                    {\r\n                        \"extension\": [\r\n                            {\r\n                                \"extension\": [\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PatientNotificationType\",\r\n                                        \"valueCodeableConcept\": {\r\n                                            \"coding\": [\r\n                                                {\r\n                                                    \"system\": \"https://fhir.by/ValueSet/PatientNotificationType\",\r\n                                                    \"version\": \"1.9\",\r\n                                                    \"code\": \"e-mail\",\r\n                                                    \"display\": \"e-mail\"\r\n                                                }\r\n                                            ]\r\n                                        }\r\n                                    },\r\n                                    {\r\n                                        \"url\": \"https://fhir.by/StructureDefinition/PatientConsentForNotification\",\r\n                                        \"valueBoolean\": true\r\n                                    }\r\n                                ],\r\n                                \"url\": \"https://fhir.by/StructureDefinition/PatientTelecomPurpose\"\r\n                            }\r\n                        ],\r\n                        \"system\": \"email\",\r\n                        \"value\": \"Ivanova@gmail.com\"\r\n                    }\r\n                ],\r\n                \"gender\": \"male\",\r\n                \"birthDate\": \"1999-03-18\",\r\n                \"deceasedBoolean\": false,\r\n                \"address\": [\r\n                    {\r\n                        \"extension\": [\r\n                            {\r\n                                \"url\": \"https://fhir.by/StructureDefinition/CoutryForAddresses\",\r\n                                \"valueCodeableConcept\": {\r\n                                    \"coding\": [\r\n                                        {\r\n                                            \"system\": \"https://fhir.by/ValueSet/CitizenshipCode\",\r\n                                            \"version\": \"1.51\",\r\n                                            \"code\": \"BY\",\r\n                                            \"display\": \"Беларусь\"\r\n                                        }\r\n                                    ]\r\n                                }\r\n                            },\r\n                            {\r\n                                \"url\": \"https://fhir.by/StructureDefinition/StreetGeoRegistry\",\r\n                                \"valueCodeableConcept\": {\r\n                                    \"coding\": [\r\n                                        {\r\n                                            \"system\": \"https://fhir.by/ValueSet/StreetGeoRegistry\",\r\n                                            \"version\": \"1.32\",\r\n                                            \"code\": \"517030647547449\",\r\n                                            \"display\": \"3\"\r\n                                        }\r\n                                    ]\r\n                                }\r\n                            },\r\n                            {\r\n                                \"url\": \"https://fhir.by/StructureDefinition/ApartmentRoom\",\r\n                                \"valueString\": \"кв. 19\"\r\n                            }\r\n                        ],\r\n                        \"use\": \"home\",\r\n                        \"text\": \"Минск, г. Минск, Переулок Вузовский, д. 3\",\r\n                        \"line\": [\r\n                            \"Переулок Вузовский, д. 3\"\r\n                        ],\r\n                        \"city\": \"г. Минск\",\r\n                        \"state\": \"Минск\",\r\n                        \"postalCode\": \"220007\",\r\n                        \"country\": \"Беларусь\"\r\n                    }\r\n                ]\r\n            }\r\n        },\r\n        {\r\n            \"fullUrl\": \"DiagnosticReport/FluorographyTest\",\r\n            \"resource\": {\r\n                \"resourceType\": \"DiagnosticReport\",\r\n                \"id\": \"27a63e71-f9e0-48c0-a220-e2fb356b48fc\",\r\n                \"meta\": {\r\n                    \"profile\": [\r\n                        \"https://fhir.by/StructureDefinition/DiagnosticReportFluorography\"\r\n                    ],\r\n                    \"lastUpdated\": \"2026-03-10T12:36:06Z\"\r\n                },\r\n                \"extension\": [\r\n                    {\r\n                        \"url\": \"https://fhir.by/StructureDefinition/ReceivedRadiationDose\",\r\n                        \"valueQuantity\": {\r\n                            \"value\": 0.5,\r\n                            \"unit\": \"мЗв\",\r\n                            \"system\": \"https://fhir.by/ValueSet/UnitsOfMeasureBy\",\r\n                            \"code\": \"mSv\"\r\n                        }\r\n                    }\r\n                ],\r\n                \"identifier\": [\r\n                    {\r\n                        \"value\": \"12605\",\r\n                        \"assigner\": {\r\n                            \"reference\": \"Organization/14736518-cc34-4e2e-8d60-204955589577\"\r\n                        }\r\n                    }\r\n                ],\r\n                \"status\": \"final\",\r\n                \"code\": {\r\n                    \"coding\": [\r\n                        {\r\n                            \"system\": \"https://fhir.by/ValueSet/PreventChestXRay\",\r\n                            \"code\": \"A06-09-006-008-add\",\r\n                            \"display\": \"Рентгенография грудной клетки профилактическая на цифровом аппарате сканирующего типа (в одной проекции)\"\r\n                        }\r\n                    ]\r\n                },\r\n                \"subject\": {\r\n                    \"reference\": \"Patient/pa-460c7c8a-355e-11f0-9dc6-b46dacb28658\",\r\n                    \"display\": \"Петр Сидорович Иванов\"\r\n                },\r\n                \"issued\": \"2026-03-10T10:00:00Z\",\r\n                \"performer\": [\r\n                    {\r\n                        \"reference\": \"Organization/14736518-cc34-4e2e-8d60-204955589577\",\r\n                        \"display\": \"АГСМ\"\r\n                    }\r\n                ],\r\n                \"resultsInterpreter\": [\r\n                    {\r\n                        \"reference\": \"PractitionerRole/1d55fcff-adb7-11f0-8021-9cb666297d63\",\r\n                        \"display\": \"Петров Петр Петрович, врач лучевой диагностики\"\r\n                    }\r\n                ],\r\n                \"conclusion\": \"Патологии не выявлено\"\r\n            }\r\n        }\r\n    ]\r\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Bundle/$import",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Bundle",
                    "$import"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Метод получения статуса импорта пакета медицинской информации",
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Bundle/{{bundleId}}/$status",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Bundle",
                    "{{bundleId}}",
                    "$status"
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    },
    {
      "name": "2. Получение информации о профилактических рентгенографиях грудной клетки",
      "item": [
        {
          "name": "2.1 - 2.2 Медицинский работник получает информацию о пройденных пациентом профилактических рентгенографиях грудной клетки",
          "item": [
            {
              "name": "Предварительные условия - авторизация врача",
              "item": [
                {
                  "name": "Достать врача и организацию из токена врача и добавить в переменную",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "const jwt = pm.request.auth.oauth2.get(\"accessToken\");\r",
                          "console.log(jwt);\r",
                          "if (jwt) {\r",
                          "    let payload = jwt.split('.')[1];\r",
                          "    payload = payload.replace(/-/g, '+').replace(/_/g, '/');\r",
                          "    while (payload.length % 4) payload += '=';\r",
                          "    let decoded = JSON.parse(atob(payload));\r",
                          "    console.log(decoded)\r",
                          "    let practitionerId = decoded.practitioner_id || decoded.practitionerId || decoded[\"practitioner_id\"];\r",
                          "    let organizationId = decoded.organization_id || decoded.organizationId || decoded[\"organization_id\"];\r",
                          "    if (practitionerId) pm.environment.set(\"PractitionerId\", practitionerId);\r",
                          "    if (organizationId) pm.environment.set(\"OrganizationId\", organizationId);\r",
                          "} else {\r",
                          "    console.log(\"JWT токен не найден в переменных коллекции\");\r",
                          "}"
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "protocolProfileBehavior": {
                    "disableBodyPruning": true
                  },
                  "request": {
                    "method": "GET",
                    "header": [
                      {
                        "key": "X-Fhir-By-Version",
                        "value": "0.3.4934",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": ""
                    },
                    "url": {
                      "raw": "https://postman-echo.com/get",
                      "protocol": "https",
                      "host": [
                        "postman-echo",
                        "com"
                      ],
                      "path": [
                        "get"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Достать PractitionerRole врача (PractitionerRole)",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "var jsonData = pm.response.json();\r",
                          "let practitionerRole = jsonData.entry.find(obj => obj.resource.resourceType === \"PractitionerRole\").resource.id;\r",
                          "\r",
                          "pm.environment.set(\"PractitionerRole\", practitionerRole);\r",
                          "console.log(practitionerRole)\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [],
                    "url": {
                      "raw": "https://staging.cisz.by/api/fhir/PractitionerRole?practitioner={{PractitionerId}}",
                      "protocol": "https",
                      "host": [
                        "staging",
                        "cisz",
                        "by"
                      ],
                      "path": [
                        "api",
                        "fhir",
                        "PractitionerRole"
                      ],
                      "query": [
                        {
                          "key": "practitioner",
                          "value": "{{PractitionerId}}"
                        }
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Достать структурное подразделение врача (LocationId)",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "let json = pm.response.json();\r",
                          "let locationValue = null;\r",
                          "\r",
                          "if (Array.isArray(json.entry)) {\r",
                          "    for (let entry of json.entry) {\r",
                          "        if (\r",
                          "            entry.resource &&\r",
                          "            entry.resource.resourceType === \"PractitionerRole\" &&\r",
                          "            Array.isArray(entry.resource.location) &&\r",
                          "            entry.resource.location.length > 0\r",
                          "        ) {\r",
                          "            // Берём reference первого location и извлекаем только UUID\r",
                          "            let ref = entry.resource.location[0].reference;\r",
                          "            if (typeof ref === \"string\" && ref.startsWith(\"Location/\")) {\r",
                          "                locationValue = ref.split(\"/\")[1]; // или: ref.replace(\"Location/\", \"\")\r",
                          "            }\r",
                          "            break;\r",
                          "        }\r",
                          "    }\r",
                          "}\r",
                          "\r",
                          "if (locationValue) {\r",
                          "    pm.environment.set(\"LocationId\", locationValue);\r",
                          "    console.log(\"location сохранён:\", locationValue);\r",
                          "} else {\r",
                          "    console.log(\"location не найден\");\r",
                          "}\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {},
                        "requests": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [],
                    "url": {
                      "raw": "https://staging.cisz.by/api/fhir/PractitionerRole?_id={{PractitionerRole}}",
                      "protocol": "https",
                      "host": [
                        "staging",
                        "cisz",
                        "by"
                      ],
                      "path": [
                        "api",
                        "fhir",
                        "PractitionerRole"
                      ],
                      "query": [
                        {
                          "key": "_id",
                          "value": "{{PractitionerRole}}"
                        }
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "Поиск пациента по идентификатору (patientId)",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "var jsonData = pm.response.json();\r",
                      "let patientId = jsonData.entry.find(obj => obj.resource.resourceType === \"Patient\").resource.id;\r",
                      "\r",
                      "pm.environment.set(\"patientId\", patientId);\r",
                      "console.log(patientId)\r",
                      ""
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Patient?identifier=3021194E003PB3",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Patient"
                  ],
                  "query": [
                    {
                      "key": "identifier",
                      "value": "3021194E003PB3"
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Метод проверки наличия запроса на получение заключения в контексте Пациента",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "var jsonData = pm.response.json();\r",
                      "let Fluorography = jsonData.entry.find(obj => obj.resource.resourceType === \"DiagnosticReport\").resource.id;\r",
                      "\r",
                      "pm.collectionVariables.set(\"Fluorography\", Fluorography);\r",
                      "console.log(Fluorography)"
                    ],
                    "type": "text/javascript",
                    "packages": {},
                    "requests": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Patient/{{patientId}}/DiagnosticReport?_profile=https://fhir.by/StructureDefinition/DiagnosticReportFluorography&_sort=-_lastUpdated",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Patient",
                    "{{patientId}}",
                    "DiagnosticReport"
                  ],
                  "query": [
                    {
                      "key": "_profile",
                      "value": "https://fhir.by/StructureDefinition/DiagnosticReportFluorography"
                    },
                    {
                      "key": "_sort",
                      "value": "-_lastUpdated"
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Метод получения визуального представления заключения",
              "protocolProfileBehavior": {
                "disabledSystemHeaders": {
                  "accept": true
                }
              },
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "Accept",
                    "value": "text/html",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "https://staging.cisz.by/api/fhir/Patient/{{patientId}}/DiagnosticReport/{{Fluorography}}",
                  "protocol": "https",
                  "host": [
                    "staging",
                    "cisz",
                    "by"
                  ],
                  "path": [
                    "api",
                    "fhir",
                    "Patient",
                    "{{patientId}}",
                    "DiagnosticReport",
                    "{{Fluorography}}"
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    },
    {
      "name": "Отмена импорта медицинской информации",
      "item": [
        {
          "name": "Отмена импорта медицинской информации",
          "request": {
            "method": "POST",
            "header": [],
            "url": {
              "raw": "https://staging.cisz.by/api/fhir/Bundle/{{bundleId}}/$cancel",
              "protocol": "https",
              "host": [
                "staging",
                "cisz",
                "by"
              ],
              "path": [
                "api",
                "fhir",
                "Bundle",
                "{{bundleId}}",
                "$cancel"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Получение статуса импорта пакета медицинской информации",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "https://staging.cisz.by/api/fhir/Bundle/{{bundleId}}/$status",
              "protocol": "https",
              "host": [
                "staging",
                "cisz",
                "by"
              ],
              "path": [
                "api",
                "fhir",
                "Bundle",
                "{{bundleId}}",
                "$status"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ],
  "auth": {
    "type": "oauth2",
    "oauth2": [
      {
        "key": "clientId",
        "value": "test.nastya1",
        "type": "string"
      },
      {
        "key": "refreshRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "tokenRequestParams",
        "value": [
          {
            "key": "origin",
            "value": "https://oauth.pstmn.io/v1/callback",
            "enabled": true,
            "send_as": "request_header"
          }
        ],
        "type": "any"
      },
      {
        "key": "authRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "tokenName",
        "value": "test1",
        "type": "string"
      },
      {
        "key": "challengeAlgorithm",
        "value": "S256",
        "type": "string"
      },
      {
        "key": "useBrowser",
        "value": true,
        "type": "boolean"
      },
      {
        "key": "scope",
        "value": "test",
        "type": "string"
      },
      {
        "key": "grant_type",
        "value": "authorization_code_with_pkce",
        "type": "string"
      },
      {
        "key": "authUrl",
        "value": "https://staging.cisz.by/auth/api/realms/iehr/auth",
        "type": "string"
      },
      {
        "key": "addTokenTo",
        "value": "header",
        "type": "string"
      },
      {
        "key": "client_authentication",
        "value": "body",
        "type": "string"
      },
      {
        "key": "accessTokenUrl",
        "value": "https://staging.cisz.by/auth/api/realms/iehr/token",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "requests": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "practitioner_id",
      "value": ""
    },
    {
      "key": "organization_id",
      "value": ""
    },
    {
      "key": "locationId",
      "value": ""
    },
    {
      "key": "patientId",
      "value": ""
    },
    {
      "key": "bundleId",
      "value": ""
    },
    {
      "key": "StatusUrl",
      "value": ""
    },
    {
      "key": "Fluorography",
      "value": ""
    }
  ]
}