-
Notifications
You must be signed in to change notification settings - Fork 15
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
Statistic pattern xls #4416
Merged
Merged
Statistic pattern xls #4416
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bf1112f
Query-sql
urchinpro 29bbb7c
fix permissions to costructor
urchinpro fc9703f
Merge branch 'develop' into statisticPatternXLS
urchinpro 6b68316
fix
urchinpro dfed664
Merge remote-tracking branch 'origin/statisticPatternXLS' into statis…
urchinpro fa0e3f9
Update api/reports/statistic_model/base_columns.py
urchinpro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
from openpyxl.styles import Border, Side, Alignment, Font, NamedStyle | ||
from openpyxl.utils.cell import get_column_letter | ||
|
||
|
||
def custom_research_data(query_sql): | ||
result = [] | ||
prev_direction = None | ||
step = 0 | ||
tmp_result = { | ||
"permanent_field": { | ||
"Случай": "", | ||
"Протокол": "", | ||
"Пациент": "", | ||
"Пол": "", | ||
"Дата рождения": "", | ||
"Возраст": "", | ||
"Адрес": "", | ||
}, | ||
"custom_field": {}, | ||
} | ||
custom_fields = [] | ||
for i in query_sql: | ||
if prev_direction != i.direction_id and step != 0: | ||
result.append(tmp_result.copy()) | ||
if prev_direction != i.direction_number: | ||
tmp_result = { | ||
"permanent_field": { | ||
"Случай": f"{i.hosp_direction}", | ||
"Протокол": f"{i.direction_id}", | ||
"Пациент": f"{i.family} {i.name} {i.patronymic}", | ||
"Пол": i.patient_sex, | ||
"Дата рождения": i.born, | ||
"Возраст": i.ind_age, | ||
"Адрес": i.patient_fact_address if i.patient_fact_address else i.patient_main_address, | ||
} | ||
} | ||
tmp_result["custom_field"][i.field_title] = i.field_value | ||
if i.field_title not in custom_fields: | ||
custom_fields.append(i.field_title) | ||
step += 1 | ||
prev_direction = i.direction_id | ||
result.append(tmp_result.copy()) | ||
fields = ["Случай", "Протокол", "Пациент", "Пол", "Дата рождения", "Возраст", "Адрес"] | ||
fields.extend(custom_fields) | ||
return {"result": result, "custom_fields": custom_fields, "fields": fields} | ||
|
||
|
||
def custom_research_base(ws1, d1, d2, result_query, research_title): | ||
style_border = NamedStyle(name="style_border_ca") | ||
bd = Side(style='thin', color="000000") | ||
style_border.border = Border(left=bd, top=bd, right=bd, bottom=bd) | ||
style_border.font = Font(bold=True, size=11) | ||
style_border.alignment = Alignment(wrap_text=True, horizontal='center', vertical='center') | ||
|
||
ws1.cell(row=1, column=1).value = 'Услуга:' | ||
ws1.cell(row=1, column=2).value = research_title | ||
ws1.cell(row=2, column=1).value = 'Период:' | ||
ws1.cell(row=3, column=1).value = f'c {d1} по {d2}' | ||
|
||
columns = [ | ||
('Направление', 15), | ||
('Источник', 15), | ||
('Пациент', 45), | ||
('Пол', 10), | ||
('Дата рождения', 26), | ||
('Возраст', 10), | ||
('Адрес', 40), | ||
('Исполнитель', 35), | ||
('Код врача', 15), | ||
] | ||
|
||
columns2 = [(i, 25) for i in result_query["custom_fields"]] | ||
columns.extend(columns2) | ||
row = 5 | ||
for idx, column in enumerate(columns, 1): | ||
ws1.cell(row=row, column=idx).value = column[0] | ||
ws1.column_dimensions[get_column_letter(idx)].width = column[1] | ||
ws1.cell(row=row, column=idx).style = style_border | ||
|
||
return ws1 | ||
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[black-format] reported by reviewdog 🐶