diff --git a/laboratory/settings.py b/laboratory/settings.py index 8a04f4347e..6b592083c1 100644 --- a/laboratory/settings.py +++ b/laboratory/settings.py @@ -393,6 +393,7 @@ def __getitem__(self, item): TITLE_RESULT_FORM_USE_HOSPITAL_STAMP = False QR_CODE_ANKETA = "" RESULT_LABORATORY_FORM = "" +SELF_WATERMARKS = "" try: from laboratory.local_settings import * # noqa: F403,F401 diff --git a/results/laboratory_form.py b/results/laboratory_form.py index 8386f0b540..42322512dc 100644 --- a/results/laboratory_form.py +++ b/results/laboratory_form.py @@ -1,3 +1,4 @@ +from appconf.manager import SettingManager from directions.models import Result from refprocessor.common import RANGE_IN, RANGE_NOT_IN from utils.flowable import InteractiveTextField, QrCodeSite @@ -977,6 +978,9 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory styleLeft = deepcopy(style) styleLeft.alignment = TA_LEFT + styleLeftFont7 = deepcopy(style) + styleLeftFont7.fontSize = 7 + styleCenterBold = deepcopy(styleBold) styleCenterBold.alignment = TA_CENTER @@ -987,7 +991,8 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory styleJustified.leading = 4.5 * mm styleBackgroundcolor = deepcopy(style) - styleBackgroundcolor.backColor = HexColor(0xFF6666) + # styleBackgroundcolor.backColor = HexColor(0xFF6666) + styleBackgroundcolor.textColor = colors.white styleBackgroundcolor.alignment = TA_CENTER styleBackgroundcolor.spaceAfter = 2 * mm @@ -1171,7 +1176,7 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory result_is_norm.append(True) else: # tmp.append(Paragraph('' + result + RANGE_NOT_IN.get(sign, "") + "", styleBackgroundcolor)) - tmp.append(Paragraph('' + result + "", styleBackgroundcolor)) + tmp.append(Paragraph('' + result + "*" + "", styleBackgroundcolor)) result_is_norm.append(False) if not no_units_and_ref: tmp.append(Paragraph('' + get_r(ref) + "", stl)) @@ -1185,9 +1190,12 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory style_t.add('TOPPADDING', (0, 0), (0, -1), 0) style_t.add('BOTTOMPADDING', (0, 0), (0, -1), 0) + step = 0 for is_norm in result_is_norm: if not is_norm: - pass + style_t.add('BACKGROUND', (1, step + 1), (1, step + 1), HexColor(0xFF6666)) + + step += 1 t = Table(data, colWidths=cw) t.setStyle(style_t) @@ -1210,8 +1218,6 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory ] data.append(tmp) - # if iss.api_app and iss.api_app.name: - cw = (90 * mm, 90 * mm) t = Table(data, repeatRows=1, colWidths=cw, hAlign='CENTRE') @@ -1223,10 +1229,45 @@ def lab_form_2(fwb, interactive_text_field, pw, direction, styleSheet, directory ] ) + t.setStyle(style_t) + t.spaceBefore = 3 * mm + t.spaceAfter = 0 + fwb.append(t) + + data1 = [] + tmp = [ + Paragraph( + "* Референсные значения приводятся с учетом возраста, пола, фазы менструального цикла, срока беременности. " + "Результаты исследований не являются диагнозом, необходима консультация специалиста.", + styleLeftFont7), + Paragraph("", styleLeftFont7), + ] + + data1.append(tmp) + + cw = (150 * mm, 20 * mm) + t = Table(data1, repeatRows=1, colWidths=cw, hAlign='LEFT') + style_t = TableStyle( + [ + ('ALIGN', (0, 0), (-1, -1), 'LEFT'), + ('VALIGN', (0, 0), (-1, -1), 'TOP'), + ('LEFTPADDING', (0, 0), (-1, -1), 2 * mm), + ] + ) + t.setStyle(style_t) t.spaceBefore = 3 * mm t.spaceAfter = 0 fwb.append(t) + return fwb + + +def self_watermarks_func(canvas_mark): + canvas_mark.line(10 * mm, 10.7 * mm, 200 * mm, 10.7 * mm) + canvas_mark.setFont('FreeSans', 7) + canvas_mark.drawString(120 * mm, 8 * mm, 'Исследования выполнены в {} {} {}'.format(SettingManager.get("org_title"), SettingManager.get("org_www"), SettingManager.get("org_phones") )) + canvas_mark.drawString(15 * mm, 8 * mm, 'Дата печати: {}'.format("13.10.2023 12:15")) + return canvas_mark diff --git a/results/views.py b/results/views.py index b5297bbd91..9417ec494c 100644 --- a/results/views.py +++ b/results/views.py @@ -48,7 +48,7 @@ from directions.models import Issledovaniya, Result, Napravleniya, ParaclinicResult, Recipe, DirectionDocument, DocumentSign from laboratory.decorators import logged_in_or_token from laboratory.settings import DEATH_RESEARCH_PK, LK_USER, SYSTEM_AS_VI, QRCODE_OFFSET_SIZE, LEFT_QRCODE_OFFSET_SIZE, GISTOLOGY_RESEARCH_PK, RESEARCHES_NOT_PRINT_FOOTERS, \ - RESULT_LABORATORY_FORM + RESULT_LABORATORY_FORM, SELF_WATERMARKS from laboratory.settings import FONTS_FOLDER from laboratory.utils import strdate, strtime from podrazdeleniya.models import Podrazdeleniya @@ -357,7 +357,7 @@ def mark_pages(canvas_mark, direction: Napravleniya, qr_data: Optional[str] = No canvas_mark.drawString(155 * mm, 285 * mm, '{}'.format(" НЕ ПОДТВЕРЖДЕНО ")) canvas_mark.setFont('FreeSans', 12) canvas_mark.drawString(175 * mm, 281 * mm, '{}'.format("( образец )")) - if not watermarks and not DEATH_RESEARCH_PK and not GISTOLOGY_RESEARCH_PK: + if not watermarks and not DEATH_RESEARCH_PK and not GISTOLOGY_RESEARCH_PK and not SELF_WATERMARKS: if direction.hospital: canvas_mark.drawString(55 * mm, 13 * mm, direction.hospital.safe_short_title) else: @@ -378,6 +378,10 @@ def mark_pages(canvas_mark, direction: Napravleniya, qr_data: Optional[str] = No d = Drawing() d.add(qr_code) renderPDF.draw(d, canvas_mark, 20 * mm, 3 * mm) + if SELF_WATERMARKS: + self_watermarks_func = import_string('results.laboratory_form.' + SELF_WATERMARKS) + canvas_mark = self_watermarks_func(canvas_mark) + canvas_mark.restoreState() count_pages = 0 @@ -763,6 +767,8 @@ def local_mark_pages(c, _): if len(pk) == 1 and has_own_form_result: doc.build(fwb) + elif SELF_WATERMARKS: + doc.build(fwb) elif len(pk) == 1 and not link_result and not hosp and fwb: doc.build(fwb, canvasmaker=PageNumCanvas) elif len(pk) == 1 and not link_result and hosp: