Mercurial > hgweb > health
changeset 7116:802d2903439d future
ImageMixin -> ImageReportMixin and use Pool.register_mixin to register to Report.
| author | Feng Shu <tumashu@163.com> |
|---|---|
| date | Thu, 14 Mar 2024 13:50:28 +0800 |
| parents | 6800449dc741 |
| children | e7461255b276 |
| files | tryton/health/__init__.py tryton/health/core.py tryton/health/health.py tryton/health/report/patient_card.fodt tryton/health_imaging/__init__.py tryton/health_imaging/health_imaging.py tryton/health_imaging/report/imaging_study_report.fodt tryton/health_lab/__init__.py tryton/health_lab/health_lab.py tryton/health_lab/report/labtest_report.fodt tryton/health_pediatrics/health_pediatrics.py tryton/health_pediatrics/report/newborn_card.fodt tryton/health_qrcodes/report/newborn_card.fodt tryton/health_qrcodes/report/patient_card.fodt |
| diffstat | 14 files changed, 38 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health/__init__.py +++ b/tryton/health/__init__.py @@ -12,10 +12,12 @@ ######################################################################### from trytond.pool import Pool +from trytond.report import Report from . import health from . import sequences from . import wizard from . import report +from . import core def register(): @@ -103,9 +105,14 @@ wizard.wizard_appointment_evaluation.CreateAppointmentEvaluation, wizard.wizard_check_immunization_status.CheckImmunizationStatus, module='health', type_='wizard') + Pool.register( report.health_report.PatientDiseaseReport, report.health_report.PatientMedicationReport, report.health_report.PatientVaccinationReport, report.immunization_status_report.ImmunizationStatusReport, module='health', type_='report') + + Pool.register_mixin( + core.ImageReportMixin, Report, + module='health')
--- a/tryton/health/core.py +++ b/tryton/health/core.py @@ -18,6 +18,7 @@ from trytond.transaction import Transaction from trytond.pool import Pool from trytond.i18n import gettext +from trytond.report import Report from .exceptions import (NoAssociatedHealthProfessional) @@ -304,8 +305,8 @@ print(f'Matplotlib: Use rcParams: {rc_conf}.') -class ImageMixin: - 'Mixin to operate image' +class ImageReportMixin: + 'Mixin to operate image in report.' __slots__ = () @classmethod @@ -397,3 +398,13 @@ return {'image': bytearray(new_img_png), 'mimetype': 'image/png'} + + @classmethod + def get_context(cls, records, header, data): + context = super(ImageReportMixin, cls).get_context( + records, header, data) + + context['image_crop'] = cls.image_crop + context['image_resize'] = cls.image_resize + + return context
--- a/tryton/health/health.py +++ b/tryton/health/health.py @@ -53,8 +53,7 @@ get_age_for_comparison, format_years_months_days, estimated_date_from_years, - get_health_professional, - ImageMixin) + get_health_professional) try: @@ -2975,7 +2974,7 @@ # PATIENT GENERAL INFORMATION -class PatientData(ModelSQL, ModelView, ImageMixin): +class PatientData(ModelSQL, ModelView): 'Patient related information' __name__ = 'gnuhealth.patient'
--- a/tryton/health/report/patient_card.fodt +++ b/tryton/health/report/patient_card.fodt @@ -1371,7 +1371,7 @@ <table:table-column table:style-name="Table1.C"/> <table:table-row table:style-name="Table1.1"> <table:table-cell table:style-name="Table1.A1" table:number-rows-spanned="5" office:value-type="string"> - <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr1" draw:name="image: patient.image_crop(patient.photo, 2.5, 3.5)" text:anchor-type="as-char" svg:y="-0.94cm" svg:width="2.499cm" svg:height="3.5cm" draw:z-index="0"> + <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr1" draw:name="image: image_crop(patient.photo, 2.5, 3.5)" text:anchor-type="as-char" svg:y="-0.94cm" svg:width="2.499cm" svg:height="3.5cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="Frame_20_contents"/> </draw:text-box>
--- a/tryton/health_imaging/__init__.py +++ b/tryton/health_imaging/__init__.py @@ -29,6 +29,7 @@ sequences.ImagingRequestSequence, sequences.ImagingTestSequence, module='health_imaging', type_='model') + Pool.register( wizard.wizard_health_imaging.WizardGenerateResult, wizard.wizard_health_imaging.RequestPatientImagingTest,
--- a/tryton/health_imaging/health_imaging.py +++ b/tryton/health_imaging/health_imaging.py @@ -20,7 +20,7 @@ from trytond.pool import Pool from trytond.modules.health.core import ( - get_health_professional, compute_age_from_dates, ImageMixin) + get_health_professional, compute_age_from_dates) __all__ = [ @@ -179,7 +179,7 @@ pass -class ImagingTestResult(ModelSQL, ModelView, ImageMixin): +class ImagingTestResult(ModelSQL, ModelView): 'Medical Imaging Study Result' __name__ = 'gnuhealth.imaging.test.result'
--- a/tryton/health_imaging/report/imaging_study_report.fodt +++ b/tryton/health_imaging/report/imaging_study_report.fodt @@ -1488,7 +1488,7 @@ </table:table-row> <table:table-row table:style-name="Table3.5"> <table:table-cell table:style-name="Table3.A4" office:value-type="string"> - <text:p text:style-name="Table_20_Contents_20_Center"><draw:frame draw:style-name="fr1" draw:name="image: interpretation.image_resize(image.data, 6.0, 6.0)" text:anchor-type="as-char" svg:y="0.132cm" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="0"> + <text:p text:style-name="Table_20_Contents_20_Center"><draw:frame draw:style-name="fr1" draw:name="image: image_resize(image.data, 6.0, 6.0)" text:anchor-type="as-char" svg:y="0.132cm" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="P13"/> </draw:text-box>
--- a/tryton/health_lab/__init__.py +++ b/tryton/health_lab/__init__.py @@ -33,6 +33,7 @@ sequences.LabRequestSequence, sequences.LabTestSequence, module='health_lab', type_='model') + Pool.register( wizard.wizard_create_lab_test.CreateLabTestOrder, wizard.wizard_create_lab_test.RequestPatientLabTest,
--- a/tryton/health_lab/health_lab.py +++ b/tryton/health_lab/health_lab.py @@ -17,8 +17,7 @@ from trytond.model import ModelView, ModelSQL, fields, Unique from trytond.pool import Pool, PoolMeta from trytond.pyson import Eval, Not, Bool -from trytond.modules.health.core import (get_health_professional, - ImageMixin) +from trytond.modules.health.core import get_health_professional import re @@ -196,7 +195,7 @@ return super(TestType, cls).write(test_types, values) -class Lab(ModelSQL, ModelView, ImageMixin): +class Lab(ModelSQL, ModelView): 'Patient Lab Test Results' __name__ = 'gnuhealth.lab'
--- a/tryton/health_lab/report/labtest_report.fodt +++ b/tryton/health_lab/report/labtest_report.fodt @@ -2251,7 +2251,7 @@ </table:table-row> <table:table-row> <table:table-cell table:style-name="Table8.C2" table:number-columns-spanned="3" office:value-type="string"> - <text:p text:style-name="GH-Table-Contents-Center"><text:placeholder text:placeholder-type="text"><for each="image in test.find_images(case.code)"></text:placeholder><text:s/><draw:frame draw:style-name="fr1" draw:name="image: test.image_resize(image.data, 6, 6)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="1"> + <text:p text:style-name="GH-Table-Contents-Center"><text:placeholder text:placeholder-type="text"><for each="image in test.find_images(case.code)"></text:placeholder><text:s/><draw:frame draw:style-name="fr1" draw:name="image: image_resize(image.data, 6, 6)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="1"> <draw:text-box> <text:p text:style-name="P21"/> </draw:text-box> @@ -2318,7 +2318,7 @@ </table:table-row> <table:table-row table:style-name="Table7.3"> <table:table-cell table:style-name="Table7.A1" office:value-type="string"> - <text:p text:style-name="Table_20_Contents_20_Center"><draw:frame draw:style-name="fr1" draw:name="image: test.image_resize(image.data, 5, 5)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="0"> + <text:p text:style-name="Table_20_Contents_20_Center"><draw:frame draw:style-name="fr1" draw:name="image: image_resize(image.data, 5, 5)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="P21"/> </draw:text-box> @@ -2345,7 +2345,7 @@ <table:table-column table:style-name="Table9.A"/> <table:table-row> <table:table-cell table:style-name="Table9.A1" office:value-type="string"> - <text:p text:style-name="GH-Table-Contents-Center"><text:placeholder text:placeholder-type="text"><for each="image in test.images"></text:placeholder><text:s/><draw:frame draw:style-name="fr1" draw:name="image: test.image_resize(image.data, 6.1, 6.1)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="2"> + <text:p text:style-name="GH-Table-Contents-Center"><text:placeholder text:placeholder-type="text"><for each="image in test.images"></text:placeholder><text:s/><draw:frame draw:style-name="fr1" draw:name="image: image_resize(image.data, 6.1, 6.1)" text:anchor-type="as-char" svg:width="1.928cm" svg:height="1.644cm" draw:z-index="2"> <draw:text-box> <text:p text:style-name="P21"/> </draw:text-box>
--- a/tryton/health_pediatrics/health_pediatrics.py +++ b/tryton/health_pediatrics/health_pediatrics.py @@ -16,15 +16,14 @@ from trytond.pool import Pool, PoolMeta from datetime import datetime from trytond.pyson import Eval, Not, Equal -from trytond.modules.health.core import (get_health_professional, - ImageMixin) +from trytond.modules.health.core import get_health_professional __all__ = ['Newborn', 'NeonatalApgar', 'NeonatalMedication', 'NeonatalCongenitalDiseases', 'PediatricSymptomsChecklist'] -class Newborn(ModelSQL, ModelView, ImageMixin): +class Newborn(ModelSQL, ModelView): 'Newborn Information' __name__ = 'gnuhealth.newborn'
--- a/tryton/health_pediatrics/report/newborn_card.fodt +++ b/tryton/health_pediatrics/report/newborn_card.fodt @@ -1383,7 +1383,7 @@ <table:table-column table:style-name="Table1.C"/> <table:table-row table:style-name="Table1.1"> <table:table-cell table:style-name="Table1.A1" table:number-rows-spanned="7" office:value-type="string"> - <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr1" draw:name="image: newborn.image_crop(newborn.photo, 2.6, 3.6)" text:anchor-type="as-char" svg:y="-0.071cm" svg:width="2.487cm" svg:height="3.6cm" draw:z-index="0"> + <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr1" draw:name="image: image_crop(newborn.photo, 2.6, 3.6)" text:anchor-type="as-char" svg:y="-0.071cm" svg:width="2.487cm" svg:height="3.6cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="Frame_20_contents"/> </draw:text-box>
--- a/tryton/health_qrcodes/report/newborn_card.fodt +++ b/tryton/health_qrcodes/report/newborn_card.fodt @@ -1425,7 +1425,7 @@ <table:table-column table:style-name="Table1.C"/> <table:table-row table:style-name="Table1.1"> <table:table-cell table:style-name="Table1.A1" table:number-rows-spanned="7" office:value-type="string"> - <text:p text:style-name="Table_20_Contents"><draw:frame draw:style-name="fr3" draw:name="image: newborn.image_crop(newborn.photo, 2.3, 3.3)" text:anchor-type="as-char" svg:y="0.079cm" svg:width="2.29cm" svg:height="3.445cm" draw:z-index="0"> + <text:p text:style-name="Table_20_Contents"><draw:frame draw:style-name="fr3" draw:name="image: image_crop(newborn.photo, 2.3, 3.3)" text:anchor-type="as-char" svg:y="0.079cm" svg:width="2.29cm" svg:height="3.445cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="Frame_20_contents"/> </draw:text-box>
--- a/tryton/health_qrcodes/report/patient_card.fodt +++ b/tryton/health_qrcodes/report/patient_card.fodt @@ -1407,7 +1407,7 @@ <table:table-column table:style-name="Table1.C"/> <table:table-row table:style-name="Table1.1"> <table:table-cell table:style-name="Table1.A1" table:number-rows-spanned="5" office:value-type="string"> - <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr3" draw:name="image: patient.image_crop(patient.photo, 2.0, 3.0)" text:anchor-type="as-char" svg:y="-0.94cm" svg:width="2cm" svg:height="3cm" draw:z-index="0"> + <text:p text:style-name="GH-Table-Contents-Center"><draw:frame draw:style-name="fr3" draw:name="image: image_crop(patient.photo, 2.0, 3.0)" text:anchor-type="as-char" svg:y="-0.94cm" svg:width="2cm" svg:height="3cm" draw:z-index="0"> <draw:text-box> <text:p text:style-name="Frame_20_contents"/> </draw:text-box>
