diff --git a/api/directions/views.py b/api/directions/views.py index 410bfc991d..cb6c87f58d 100644 --- a/api/directions/views.py +++ b/api/directions/views.py @@ -3952,8 +3952,8 @@ def eds_documents(request): if v in ["", None]: error_doctor = f"{k} - не верно;{error_doctor}" - if not iss_obj.doc_confirmation.podrazdeleniye.n3_id or not iss_obj.doc_confirmation.hospital.code_tfoms: - return JsonResponse({"documents": [], "edsTitle": "", "executors": "", "error": True, "message": "UUID подразделения или код ТФОМС не заполнен"}) + # if not iss_obj.doc_confirmation.podrazdeleniye.n3_id or not iss_obj.doc_confirmation.hospital.code_tfoms: + # return JsonResponse({"documents": [], "edsTitle": "", "executors": "", "error": True, "message": "UUID подразделения или код ТФОМС не заполнен"}) base = SettingManager.get_cda_base_url() if base != "empty": diff --git a/ftp_orders/main.py b/ftp_orders/main.py index 8d6327a2e2..72c75dde2f 100644 --- a/ftp_orders/main.py +++ b/ftp_orders/main.py @@ -1,4 +1,5 @@ import base64 +from django.core.files.base import ContentFile import datetime import ftplib import json @@ -18,7 +19,17 @@ from appconf.manager import SettingManager from clients.models import Individual, CardBase from contracts.models import PriceName -from directions.models import Napravleniya, RegisteredOrders, NumberGenerator, TubesRegistration, IstochnikiFinansirovaniya, NapravleniyaHL7LinkFiles, Issledovaniya, Result +from directions.models import ( + Napravleniya, + RegisteredOrders, + NumberGenerator, + TubesRegistration, + IstochnikiFinansirovaniya, + NapravleniyaHL7LinkFiles, + Issledovaniya, + Result, + IssledovaniyaFiles, +) from directory.sql_func import get_fsli_fractions_by_research_id from ftp_orders.sql_func import get_tubesregistration_id_by_iss from hospitals.models import Hospitals @@ -410,7 +421,13 @@ def pull_result(self, file: str): for obx in obxes: tmp_fractions = fractions.copy() if (obx.OBX.obx_3.obx_3_1.value).lower == "pdf": - continue + pdf_base_64 = obx.OBX.obx_5.obx_5_5.value + base64_bytes = pdf_base_64.encode('utf-8') + data = ContentFile(base64.b64decode(base64_bytes)) + iss_file = IssledovaniyaFiles(issledovaniye=iss, uploaded_file=data) + file_name_internal_code = internal_code.replace(".", "_") + iss_file.uploaded_file.name = f"{tube_number}_{file_name_internal_code}.pdf" + iss_file.save() elif (obx.OBX.obx_3.obx_3_1.value).lower() == "jpg": tmp_fractions["jpg"] = obx.OBX.obx_5.obx_5_5.value result.append(tmp_fractions.copy()) @@ -421,6 +438,12 @@ def pull_result(self, file: str): continue tmp_fsli = obx.OBX.obx_3.obx_3_1.value if tmp_fsli not in fractions_fsl: + if is_confirm: + iss.lab_comment = "" + iss.time_confirmation = datetime.datetime.strptime(date_time_confirm, "%Y%m%d%H%M%S") + iss.time_save = current_time() + iss.doc_confirmation_string = doctor_fio + iss.save() Log.log(key=tube_number, type=190005, body={"tube": tube_number, "internal_code": internal_code, "researchTile": research_title, "file": file}, user=None) self.copy_file(file, FTP_PATH_TO_SAVE) self.delete_file(file) @@ -632,13 +655,14 @@ def check_replace_fields(field_replace, line_new, direction): for fr in field_replace: if fr == "2" and line_new[0] == "MSH": line_new[int(fr)] = direction.external_executor_hospital.hl7_sender_application + line_new[int(fr)] = direction.hospital.hl7_sender_application elif fr == "3" and line_new[0] == "MSH": - line_new[int(fr)] = direction.external_executor_hospital.short_title + line_new[int(fr)] = direction.hospital.hl7_sender_org elif fr == "2-2" and line_new[0] == "OBR": positions = fr.split("-") data = line_new[int(positions[0])] data_pos = data.split("^") - data_pos[int(positions[1]) - 1] = direction.external_executor_hospital.hl7_sender_application + data_pos[int(positions[1]) - 1] = direction.hospital.hl7_sender_application data = "^".join(data_pos) line_new[int(positions[0])] = data return line_new diff --git a/hospitals/models.py b/hospitals/models.py index 19bfd85132..56e8b5b641 100644 --- a/hospitals/models.py +++ b/hospitals/models.py @@ -51,6 +51,9 @@ class Hospitals(models.Model): result_pull_by_numbers = models.CharField( max_length=256, blank=True, default=None, null=True, help_text='URL для FTP директории получения результатов (ftp://user:password@host.example.com/path)' ) + result_push_by_numbers = models.CharField( + max_length=256, blank=True, default=None, null=True, help_text='URL для FTP директории отрпавки результатов (ftp://user:password@host.example.com/path)' + ) hl7_sender_application = models.CharField(max_length=55, blank=True, default=None, null=True, help_text='HL7 приложение отправитель') hl7_sender_org = models.CharField(max_length=55, blank=True, default=None, null=True, help_text='HL7 организация отправитель') hl7_receiver_appplication = models.CharField(max_length=55, blank=True, default=None, null=True, help_text='HL7 приложение получатель')