Skip to content

Commit

Permalink
Merge pull request #3840 from mikhailprivalov/sendOrderFromOwnL2
Browse files Browse the repository at this point in the history
send order
  • Loading branch information
urchinpro authored May 28, 2024
2 parents 0d84d79 + 92f9178 commit 3e37e22
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
6 changes: 5 additions & 1 deletion api/directions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3645,11 +3645,15 @@ def tubes_register_get(request):
val = TubesRegistration.objects.get(number=pk)
issledovanie_in_tube = Issledovaniya.objects.filter(tubes__id=val.pk).first()
if issledovanie_in_tube:
all_issledovania = Issledovaniya.objects.filter(napravleniye_id=issledovanie_in_tube.napravleniye_id)
napravleniye_id = issledovanie_in_tube.napravleniye_id
all_issledovania = Issledovaniya.objects.filter(napravleniye_id=napravleniye_id)
for issledovanie in all_issledovania:
if len(issledovanie.tubes.all()) == 0:
issledovanie.tubes.add(val.pk)
issledovanie.save()
napravleniye = Napravleniya.objects.filter(pk=napravleniye_id).first()
if napravleniye.external_executor_hospital and napravleniye.external_executor_hospital.is_external_performing_organization:
napravleniye.need_order_redirection = True
if not val.doc_get and not val.time_get:
val.set_get(request.user.doctorprofile)
get_details[pk] = val.get_details()
Expand Down
4 changes: 4 additions & 0 deletions contracts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def get_hospital_price_by_date(hospital_id, date_start, date_end, is_subcontract
def get_hospital_many_prices_by_date(hospital_id, date_start, date_end, is_subcontract=False):
return PriceName.objects.filter(hospital_id=hospital_id, date_start__lte=date_start, date_end__gte=date_end, subcontract=is_subcontract)

@staticmethod
def get_hospital_extrenal_price_by_date(external_hospital_id, date_start, date_end, external_performer=True):
return PriceName.objects.filter(hospital_id=external_hospital_id, date_start__lte=date_start, date_end__gte=date_end, external_performer=external_performer)

class Meta:
verbose_name = "Название прайса"
verbose_name_plural = "Названия прайса"
Expand Down
18 changes: 12 additions & 6 deletions ftp_orders/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from ftp_orders.sql_func import get_tubesregistration_id_by_iss
from hospitals.models import Hospitals
from directory.models import Researches, Fractions
from laboratory.settings import BASE_DIR, NEED_RECIEVE_TUBE_TO_PUSH_ORDER, FTP_SETUP_TO_SEND_HL7_BY_RESEARCHES
from laboratory.settings import BASE_DIR, NEED_RECIEVE_TUBE_TO_PUSH_ORDER, FTP_SETUP_TO_SEND_HL7_BY_RESEARCHES, OWN_SETUP_TO_SEND_FTP_EXECUTOR
from laboratory.utils import current_time
from slog.models import Log
from users.models import DoctorProfile
Expand Down Expand Up @@ -461,10 +461,18 @@ def push_order(self, direction: Napravleniya):
pv = hl7.add_group("ORM_O01_PATIENT_VISIT")
pv.PV1.PV1_2.value = "O"

if direction.istochnik_f.title.lower() in ["договор"]:
pv.PV1.PV1_20.value = f"Договор^^{direction.price_name.title}^{direction.price_name.symbol_code}"
if OWN_SETUP_TO_SEND_FTP_EXECUTOR:
prices = PriceName.get_hospital_extrenal_price_by_date(direction.external_executor_hospital, direction.data_sozdaniya, direction.data_sozdaniya)
for price in prices:
if direction.istochnik_f.title.lower() == "омс" and "омс" in price.title.lower():
pv.PV1.PV1_20.value = f"Договор^^{price.contract_number}^{price.symbol_code}"
if direction.istochnik_f.title.lower() == "договор" and "договор" in price.title.lower():
pv.PV1.PV1_20.value = f"Договор^^{price.contract_number}^{price.symbol_code}"
else:
pv.PV1.PV1_20.value = "Наличные"
if direction.istochnik_f.title.lower() == "договор":
pv.PV1.PV1_20.value = f"Договор^^{direction.price_name.title}^{direction.price_name.symbol_code}"
else:
pv.PV1.PV1_20.value = "Наличные"
pv.PV1.PV1_44.value = direction.data_sozdaniya.strftime("%Y%m%d")
pv.PV1.PV1_46.value = ""

Expand All @@ -478,9 +486,7 @@ def push_order(self, direction: Napravleniya):
direction.need_order_redirection = False
direction.time_send_hl7 = current_time()
direction.save(update_fields=["time_send_hl7", "need_order_redirection"])

n = 0

for iss in direction.issledovaniya_set.all():
n += 1
obr = ordd.add_segment("OBR")
Expand Down
1 change: 1 addition & 0 deletions laboratory/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def __getitem__(self, item):
CDA_TEMPLATE_XML_DIRECTORY = ""
IDGTL_KEY = ""
ROUTE_LIST_ROW_HEIGHTS = 25
OWN_SETUP_TO_SEND_FTP_EXECUTOR = False


FCM_CERT_PATH = ""
Expand Down

0 comments on commit 3e37e22

Please sign in to comment.