-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto create case #3238
Auto create case #3238
Changes from 31 commits
0cc5ae3
978073c
1bdadea
1397dba
03539c5
5888006
84ca305
2445ab8
31f5da7
dc19770
d5dfd19
7d5e25e
2261f93
3adb63a
c6ca074
a376901
fade0f2
ba3be4a
ced95a8
19af03b
1eba55f
a3acaaf
3817047
d062dd3
3061b84
c9c7cc8
9058714
eb0d8bc
f1c5cba
14adc33
02902ad
ad10dd5
199632d
97c5b4a
3fca858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1059,7 +1059,6 @@ def gen_napravleniye( | |
hospital=-1, | ||
external_order=None, | ||
price_name_id=None, | ||
slot_fact_id=None, | ||
) -> 'Napravleniya': | ||
""" | ||
Генерация направления | ||
|
@@ -1131,12 +1130,6 @@ def gen_napravleniye( | |
if save: | ||
dir.save() | ||
dir.set_polis() | ||
if slot_fact_id: | ||
from doctor_schedule.models import SlotFact | ||
|
||
f = SlotFact.objects.get(pk=slot_fact_id) | ||
f.direction = dir | ||
f.save(update_fields=['direction']) | ||
return dir | ||
|
||
@staticmethod | ||
|
@@ -1298,6 +1291,7 @@ def gen_napravleniya_by_issledovaniya( | |
price_name=None, | ||
case_id=-2, | ||
case_by_direction=False, | ||
plan_start_date=None, | ||
slot_fact_id=None, | ||
): | ||
result = {"r": False, "list_id": [], "list_stationar_id": [], "messageLimit": ""} | ||
|
@@ -1563,7 +1557,6 @@ def gen_napravleniya_by_issledovaniya( | |
hospital=hospital_override, | ||
external_order=external_order, | ||
price_name_id=price_name, | ||
slot_fact_id=slot_fact_id, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тут что то странное происходит |
||
) | ||
research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() | ||
issledovaniye_case = Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False) | ||
|
@@ -1595,7 +1588,6 @@ def gen_napravleniya_by_issledovaniya( | |
hospital=hospital_override, | ||
external_order=external_order, | ||
price_name_id=price_name, | ||
slot_fact_id=slot_fact_id, | ||
) | ||
npk = directions_for_researches[dir_group].pk | ||
result["list_id"].append(npk) | ||
|
@@ -1627,7 +1619,6 @@ def gen_napravleniya_by_issledovaniya( | |
hospital=hospital_override, | ||
external_order=external_order, | ||
price_name_id=price_name, | ||
slot_fact_id=slot_fact_id, | ||
) | ||
npk = directions_for_researches[dir_group].pk | ||
result["list_id"].append(npk) | ||
|
@@ -1848,7 +1839,6 @@ def gen_napravleniya_by_issledovaniya( | |
external_organization=external_organization, | ||
price_category=price_category, | ||
hospital=hospital_override, | ||
slot_fact_id=slot_fact_id, | ||
) | ||
result["list_id"].append(new_direction.pk) | ||
Issledovaniya(napravleniye=new_direction, research_id=research_dir, deferred=False).save() | ||
|
@@ -2283,6 +2273,7 @@ class Issledovaniya(models.Model): | |
DoctorProfile, null=True, blank=True, related_name="doc_add_additional", db_index=True, help_text='Профиль-добавил исполнитель дополнительные услуги', on_delete=models.SET_NULL | ||
) | ||
external_add_order = models.ForeignKey(ExternalAdditionalOrder, db_index=True, blank=True, null=True, default=None, help_text="Внешний заказ", on_delete=models.SET_NULL) | ||
plan_start_date = models.DateTimeField(null=True, blank=True, db_index=True, help_text='Планируемое время начала услуги') | ||
|
||
urchinpro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@property | ||
def time_save_local(self): | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -84,3 +84,18 @@ def check_create_direction_patient_by_research(client_id, researches, months_ago | |||||
) | ||||||
rows = namedtuplefetchall(cursor) | ||||||
return rows | ||||||
|
||||||
|
||||||
def get_researches_by_number_directions(direction_numbers): | ||||||
with connection.cursor() as cursor: | ||||||
cursor.execute( | ||||||
""" | ||||||
SELECT | ||||||
directions_issledovaniya.research_id | ||||||
FROM directions_issledovaniya | ||||||
WHERE directions_issledovaniya.napravleniye_id in %(direction_numbers)s | ||||||
""", | ||||||
params={'direction_numbers': direction_numbers}, | ||||||
) | ||||||
rows = namedtuplefetchall(cursor) | ||||||
return rows | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [black-format] reported by reviewdog 🐶
Suggested change
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -27,16 +27,19 @@ | |||
from transliterate import translit | ||||
|
||||
import directory.models as directory | ||||
from directions.sql_func import get_researches_by_number_directions | ||||
from users.models import DoctorProfile | ||||
from api.sql_func import search_case_by_card_date | ||||
from hospitals.models import Hospitals | ||||
import slog.models as slog | ||||
from appconf.manager import SettingManager | ||||
from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult | ||||
from directions.models import Napravleniya, Issledovaniya, TubesRegistration, DirectionParamsResult, IstochnikiFinansirovaniya | ||||
from laboratory.decorators import logged_in_or_token | ||||
from laboratory.settings import FONTS_FOLDER, PRINT_ADDITIONAL_PAGE_DIRECTION_FIN_SOURCE, PRINT_APPENDIX_PAGE_DIRECTION | ||||
from laboratory.utils import strtime, strdate | ||||
from podrazdeleniya.models import Podrazdeleniya | ||||
from utils import xh | ||||
from utils.dates import try_parse_range | ||||
from utils.dates import try_parse_range, normalize_dots_date | ||||
from django.utils.module_loading import import_string | ||||
|
||||
from utils.matrix import transpose | ||||
|
@@ -1040,3 +1043,92 @@ def px(x=0.0): | |||
def pxr(x=0.0): | ||||
x *= mm | ||||
return w - x | ||||
|
||||
|
||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [black-format] reported by reviewdog 🐶
Suggested change
|
||||
def create_case_by_cards(cards): | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [flake8] <302> reported by reviewdog 🐶
urchinpro marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [flake8] <303> reported by reviewdog 🐶 |
||||
research_case = directory.Researches.objects.filter(is_case=True, hide=False).first() | ||||
doc = DoctorProfile.objects.filter(fio='Системный Пользователь', is_system_user=True).first() | ||||
card_directions = {} | ||||
number_directons = None | ||||
for card in cards: | ||||
card_id = card.get("card_id") | ||||
researches = card.get("research") | ||||
plan_start_date_case = normalize_dots_date(card.get("date")) | ||||
plan_start_date_case = f"{plan_start_date_case} 00:00:00" | ||||
result_search_case = search_case_by_card_date(card_id, plan_start_date_case, research_case.pk, 1) | ||||
case_issledovaniye_number, case_direction_number = None, None | ||||
for i in result_search_case: | ||||
case_issledovaniye_number = i.case_issledovaniye_number | ||||
case_direction_number = i.case_direction_number | ||||
break | ||||
financing_source = IstochnikiFinansirovaniya.objects.filter(title__in=["Профосмотр", "Юрлицо"]).first() | ||||
|
||||
if case_issledovaniye_number: | ||||
number_directons = Napravleniya.objects.values_list("id", flat=True).filter(parent_case_id=case_issledovaniye_number) | ||||
researches_sql = get_researches_by_number_directions(tuple(number_directons)) | ||||
current_researches_case = set([i.research_id for i in researches_sql]) | ||||
api_researches = set(researches) | ||||
api_researches -= current_researches_case | ||||
researches = list(api_researches) | ||||
result = Napravleniya.gen_napravleniya_by_issledovaniya( | ||||
card_id, | ||||
"", | ||||
financing_source.pk, | ||||
"", | ||||
None, | ||||
doc, | ||||
{-1: researches}, | ||||
{}, | ||||
False, | ||||
{}, | ||||
vich_code="", | ||||
count=1, | ||||
discount=0, | ||||
rmis_slot=None, | ||||
price_name=None, | ||||
case_id=case_direction_number, | ||||
case_by_direction=True, | ||||
plan_start_date=plan_start_date_case, | ||||
) | ||||
else: | ||||
napravleniye_case = Napravleniya.gen_napravleniye( | ||||
card_id, | ||||
doc, | ||||
financing_source, | ||||
"", | ||||
"", | ||||
doc, | ||||
-1, | ||||
doc, | ||||
) | ||||
|
||||
issledovaniye_case = Issledovaniya(napravleniye=napravleniye_case, research=research_case, deferred=False, plan_start_date=plan_start_date_case) | ||||
issledovaniye_case.save() | ||||
result = Napravleniya.gen_napravleniya_by_issledovaniya( | ||||
card_id, | ||||
"", | ||||
financing_source.pk, | ||||
"", | ||||
None, | ||||
doc, | ||||
{-1: researches}, | ||||
{}, | ||||
False, | ||||
{}, | ||||
vich_code="", | ||||
count=1, | ||||
discount=0, | ||||
rmis_slot=None, | ||||
price_name=None, | ||||
case_id=napravleniye_case.pk, | ||||
case_by_direction=True, | ||||
plan_start_date=plan_start_date_case, | ||||
) | ||||
if number_directons: | ||||
number_directons = [i for i in number_directons] | ||||
else: | ||||
number_directons = [] | ||||
number_directons.extend(result.get("list_id")) | ||||
card_directions[card_id] = list(set(number_directons)) | ||||
return card_directions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И тут странное