Skip to content
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

530 titul from tamplate #4500

Merged
merged 19 commits into from
Dec 1, 2024
20 changes: 16 additions & 4 deletions api/stationar/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,13 @@ def get_result_value_iss(iss_pk, research_pk, titles_field):
cursor.execute(
"""
WITH
t_field AS (SELECT "id", title FROM directory_paraclinicinputfield
t_field AS (SELECT "id", title, cda_option_id FROM directory_paraclinicinputfield
WHERE group_id in (SELECT "id" FROM directory_paraclinicinputgroups WHERE research_id=%(id_research)s)
AND title = ANY(ARRAY[%(titles_field)s]))

SELECT field_id, issledovaniye_id, "value", title FROM public.directions_paraclinicresult
SELECT field_id, issledovaniye_id, "value", title, cda_option_id FROM public.directions_paraclinicresult
LEFT JOIN t_field ON directions_paraclinicresult.field_id = t_field.id
where field_id in (SELECT "id" FROM t_field) and issledovaniye_id = %(id_iss)s


""",
params={'id_iss': iss_pk, 'id_research': research_pk, 'titles_field': titles_field},
)
Expand Down Expand Up @@ -247,3 +245,17 @@ def get_assignments_by_history(history_id: int):
)
rows = namedtuplefetchall(cursor)
return rows


def get_title_fields_by_cda_relation(id_research, cda_id_field):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT "id", title, cda_option_id FROM directory_paraclinicinputfield
WHERE group_id in (SELECT "id" FROM directory_paraclinicinputgroups WHERE research_id=%(id_research)s)
AND directory_paraclinicinputfield.cda_option_id IN %(cda_option)s
""",
params={"id_research": id_research, 'cda_option': cda_id_field},
)
rows = namedtuplefetchall(cursor)
return rows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[black-format] reported by reviewdog 🐶

Suggested change
return rows
return rows

7 changes: 7 additions & 0 deletions external_system/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,14 @@ def get_cda_params(is_doc_refferal, is_treatment, is_form, is_extract):
result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_form=True).order_by("title")]]
elif is_extract:
result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_extract=True).order_by("title")]]
else:
result = [{"id": -1, "label": "Пусто"}, *[{"id": x.pk, "label": f"{x.title} - {x.code}"} for x in CdaFields.objects.filter(is_doc_refferal=True).order_by("title")]]

return result

@staticmethod
def get_cda_id_by_titles(cda_titles):
result = CdaFields.objects.filter(title__in=cda_titles)
return result


Expand Down
16 changes: 16 additions & 0 deletions external_system/sql_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,19 @@ def get_nsi_code_fsidi(method):
)
rows = namedtuplefetchall(cursor)
return rows


def cda_data_by_title(cda_title):
with connection.cursor() as cursor:
cursor.execute(
"""
SELECT
id,
title
from external_system_cdafields
where title in %(cda_title)s
""",
params={'cda_title': cda_title},
)
rows = namedtuplefetchall(cursor)
return rows
Loading