Skip to content

Commit

Permalink
Merge branch 'develop' into create-pull-request/patch
Browse files Browse the repository at this point in the history
  • Loading branch information
urchinpro authored Jul 1, 2024
2 parents a8e1b1b + 0fb4160 commit 5d96f3b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
1 change: 1 addition & 0 deletions directions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ class Napravleniya(models.Model):
cpp_upload_id = models.CharField(max_length=128, default=None, blank=True, null=True, db_index=True, help_text='Id-загрузки ЦПП')
need_resend_cpp = models.BooleanField(default=False, blank=True, help_text='Требуется отправка в ЦПП')
ecp_direction_number = models.CharField(max_length=64, default=None, blank=True, null=True, db_index=True, help_text='Id-направления ЕЦП')
is_cito = models.BooleanField(default=False, blank=True, help_text='Срочное исполнение')

def sync_confirmed_fields(self, skip_post=False):
has_confirmed_iss = Issledovaniya.objects.filter(napravleniye=self, time_confirmation__isnull=False).exists()
Expand Down
17 changes: 17 additions & 0 deletions directory/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,20 @@ def get_lab_research_reference_books():
)
rows = namedtuplefetchall(cursor)
return rows


def get_fsli_fractions_by_research_id(research_id):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT
directory_fractions.id as fraction_id,
directory_fractions.title as fraction_title,
directory_fractions.fsli as fraction_fsli
FROM directory_fractions
WHERE directory_fractions.research_id = %(research_id)s
""",
params={},
)
rows = namedtuplefetchall(cursor)
return rows
27 changes: 20 additions & 7 deletions ftp_orders/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from clients.models import Individual, CardBase
from contracts.models import PriceName
from directions.models import Napravleniya, RegisteredOrders, NumberGenerator, TubesRegistration, IstochnikiFinansirovaniya, NapravleniyaHL7LinkFiles, Issledovaniya, Result
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
from directory.models import Researches, Fractions
Expand Down Expand Up @@ -371,6 +372,17 @@ def pull_result(self, file: str):
external_add_order = obr.OBR_2.OBR_2_1.value
else:
iss_id = (obr.OBR_2.OBR_2_1.value).split("_")[1]
tube_number = obr.OBR_3.OBR_3_1.value
internal_code = obr.OBR_4.OBR_4_4.value
research_title = obr.OBR_4.OBR_4_5.value

if external_add_order:
iss = Issledovaniya.objects.filter(external_add_order__external_add_order=external_add_order).first()
else:
iss = Issledovaniya.objects.filter(id=iss_id).first()
fractions_data = get_fsli_fractions_by_research_id(iss.research_id)
fractions_fsl = [i.fraction_fsli for i in fractions_data]

doctor_family_confirm = obr.OBR_32.OBR_32_2.value
doctor_name_confirm = obr.OBR_32.OBR_32_3.value
doctor_patronymic_confirm = obr.OBR_32.OBR_32_4.value
Expand All @@ -384,6 +396,7 @@ def pull_result(self, file: str):
obxes = hl7_result.ORU_R01_RESPONSE.ORU_R01_ORDER_OBSERVATION.ORU_R01_OBSERVATION
fractions = {"fsli": "", "title_fraction": "", "value": "", "refs": "", "units": "", "jpeg": "", "html": "", "doc_confirm": "", "date_confirm": "", "note_data": ""}
result = []

for obx in obxes:
tmp_fractions = fractions.copy()
if (obx.OBX.obx_3.obx_3_1.value).lower == "pdf":
Expand All @@ -396,18 +409,18 @@ def pull_result(self, file: str):
tmp_fractions["html"] = obx.OBX.obx_5.obx_5_1.value
result.append(tmp_fractions.copy())
continue
tmp_fractions["fsli"] = obx.OBX.obx_3.obx_3_1.value
tmp_fsli = obx.OBX.obx_3.obx_3_1.value
if tmp_fsli not in fractions_fsl:
Log.log(key=tube_number, type=190005, body=json.dumps({"tube": tube_number, "internal_code": internal_code, "researchTile": research_title, "file": file}), user=None).save()
self.copy_file(file, FTP_PATH_TO_SAVE)
self.delete_file(file)
return
tmp_fractions["fsli"] = tmp_fsli
tmp_fractions["title_fraction"] = obx.OBX.obx_3.obx_3_2.value
tmp_fractions["value"] = obx.OBX.obx_5.obx_5_1.value
tmp_fractions["units"] = obx.OBX.obx_6.value
tmp_fractions["refs"] = obx.OBX.obx_7.obx_7_1.value
result.append(tmp_fractions.copy())

if external_add_order:
iss = Issledovaniya.objects.filter(external_add_order__external_add_order=external_add_order).first()
else:
iss = Issledovaniya.objects.filter(id=iss_id).first()

if is_confirm:
iss.lab_comment = ""
iss.time_confirmation = datetime.datetime.strptime(date_time_confirm, "%Y%m%d%H%M%S")
Expand Down
2 changes: 1 addition & 1 deletion ftp_orders/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def get_tubesregistration_id_by_iss(iss_id):
params={'iss_id': iss_id},
)
rows = namedtuplefetchall(cursor)
return rows
return rows
1 change: 1 addition & 0 deletions slog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class Log(models.Model):
(190002, 'FTP HL7: результат pull'),
(190003, 'FTP HL7: результат push'),
(190004, 'REST: заказ принятие'),
(190005, 'FTP HL7: Ошибка результат pull'),
(200000, 'Счет на оплату: подтверждение'),
(200001, 'Счет на оплату: сброс подтверждения'),
(210000, 'Комплексные услуги: создание комплекса'),
Expand Down

0 comments on commit 5d96f3b

Please sign in to comment.