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

Report with params #3083

Merged
merged 6 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions api/monitorings/structure_sheet.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from openpyxl.styles import Border, Side, Alignment, Font, NamedStyle
from openpyxl.utils.cell import get_column_letter
import json


def monitoring_xlsx(ws1, monitoring_title, table_data, date):
Expand Down Expand Up @@ -48,15 +49,43 @@ def monitoring_xlsx(ws1, monitoring_title, table_data, date):

current_column = 1
current_row += 1
is_show_tables_title = False
json_data = {}
for row in table_data['rows']:
current_row += 1
ws1.cell(row=current_row, column=current_column).value = row['hospTitle']
ws1.cell(row=current_row, column=current_column).style = style_border
for value in row['values']:
for v in value:
current_column += 1
ws1.cell(row=current_row, column=current_column).value = v
ws1.cell(row=current_row, column=current_column).style = style_border
is_dict = False
if type(v) is str and "columns" in v:
try:
json_data = json.loads(v)
is_dict = True
except:
is_dict = False
if not is_dict:
current_column += 1
ws1.cell(row=current_row, column=current_column).value = v
ws1.cell(row=current_row, column=current_column).style = style_border
if is_dict:
col_title_data = json_data.get("columns")
col_title = col_title_data.get("titles")
start_col = current_column
if not is_show_tables_title:
for c_title in col_title:
start_col += 1
ws1.cell(row=current_row - 1, column=start_col).value = c_title
ws1.cell(row=current_row - 1, column=start_col).style = style_border
is_show_tables_title = True
rows_data = json_data.get("rows")
for r_data in rows_data:
start_col = current_column
for rd in r_data:
start_col += 1
ws1.cell(row=current_row, column=start_col).value = rd
ws1.cell(row=current_row, column=start_col).style = style_border
current_row += 1
current_column = 1

current_row += 1
Expand Down
2 changes: 2 additions & 0 deletions api/monitorings/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ def filexlsx(request):
wb = openpyxl.Workbook()
wb.remove(wb.get_sheet_by_name('Sheet'))
ws = wb.create_sheet(f'{monitoring.title}')
is_table = False
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <841> reported by reviewdog 🐶
local variable 'is_table' is assigned to but never used


ws = structure_sheet.monitoring_xlsx(ws, monitoring.title, table_data, date)

response['Content-Disposition'] = str.translate(f"attachment; filename=\"{monitoring.title}, {date}.xlsx\"", tr)
Expand Down
4 changes: 2 additions & 2 deletions api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
SEARCH_PAGE_STATISTIC_PARAMS,
UNLIMIT_PERIOD_STATISTIC_GROUP,
TITLE_REPORT_FILTER_HAS_ALL_FIN_SOURCE,
STATISTIC_TYPE_DEPARTMENT,
STATISTIC_TYPE_DEPARTMENT, USE_TFOMS_DISTRICT,
urchinpro marked this conversation as resolved.
Show resolved Hide resolved
)
from utils.response import status_response

Expand Down Expand Up @@ -1820,7 +1820,7 @@ def actual_districts(request):

if card_pk is not None:
card_hospital_id = -1
if SettingManager.l2('tfoms'):
if SettingManager.l2('tfoms') and USE_TFOMS_DISTRICT:
card = Card.objects.get(pk=data['card_pk'])
enp = card.individual.get_enp()
if enp:
Expand Down
4 changes: 3 additions & 1 deletion directions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,9 @@ def gen_napravleniye(
if issledovaniya is None:
pass
client = Clients.Card.objects.get(pk=client_id)
if price_name_id is None and istochnik_f.title.lower() in ["договор"]:
print(price_name_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <201> reported by reviewdog 🐶
print found.

print(istochnik_f)
Copy link
Contributor

Choose a reason for hiding this comment

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

[flake8] <201> reported by reviewdog 🐶
print found.

if price_name_id is None and istochnik_f and istochnik_f.title.lower() in ["договор"]:
price_name_obj = contracts.PriceName.get_hospital_price_by_date(doc.hospital_id, current_time(only_date=True), current_time(only_date=True), True)
price_name_id = price_name_obj.pk

Expand Down
1 change: 1 addition & 0 deletions laboratory/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ def __getitem__(self, item):
ECP_SEARCH_PATIENT = {}
DAYS_AGO_SEARCH_RESULT = {} # {"isLab: 90", "isInstrument: 365"}
NEED_ORDER_DIRECTION_FOR_DEFAULT_HOSPITAL = False
USE_TFOMS_DISTRICT = False

try:
from laboratory.local_settings import * # noqa: F403,F401
Expand Down