Mercurial > hgweb > health
changeset 4820:64917af212cf
task #16043: Migration to GNU Health 4.0: Migration of health_gyneco package
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Tue, 21 Dec 2021 16:50:54 +0000 |
| parents | eb5654be6e64 |
| children | 15efa4e13c51 aa1f80f2176e |
| files | tryton/health_gyneco/__init__.py tryton/health_gyneco/data/messages/messages.xml tryton/health_gyneco/exceptions.py tryton/health_gyneco/health_gyneco.py tryton/health_gyneco/tryton.cfg |
| diffstat | 5 files changed, 55 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_gyneco/__init__.py +++ b/tryton/health_gyneco/__init__.py @@ -22,19 +22,19 @@ ############################################################################## from trytond.pool import Pool -from .health_gyneco import * +from . import health_gyneco def register(): Pool.register( - PatientPregnancy, - PrenatalEvaluation, - PuerperiumMonitor, - Perinatal, - PerinatalMonitor, - GnuHealthPatient, - PatientMenstrualHistory, - PatientMammographyHistory, - PatientPAPHistory, - PatientColposcopyHistory, + health_gyneco.PatientPregnancy, + health_gyneco.PrenatalEvaluation, + health_gyneco.PuerperiumMonitor, + health_gyneco.Perinatal, + health_gyneco.PerinatalMonitor, + health_gyneco.GnuHealthPatient, + health_gyneco.PatientMenstrualHistory, + health_gyneco.PatientMammographyHistory, + health_gyneco.PatientPAPHistory, + health_gyneco.PatientColposcopyHistory, module='health_gyneco', type_='model')
new file mode 100644 --- /dev/null +++ b/tryton/health_gyneco/data/messages/messages.xml @@ -0,0 +1,10 @@ +<?xml version="1.0"?> +<!-- This file is part of GNU Health. The COPYRIGHT file at the top level of +this repository contains the full copyright notices and license terms. --> +<tryton> + <data grouped="1"> + <record model="ir.message" id="msg_patient_already_pregnant"> + <field name="text">Our records indicate that the patient is already pregnant</field> + </record> + </data> +</tryton>
new file mode 100644 --- /dev/null +++ b/tryton/health_gyneco/exceptions.py @@ -0,0 +1,9 @@ +# This file is part of GNU Health. The COPYRIGHT file at the top level of +# this repository contains the full copyright notices and license terms. +from trytond.exceptions import UserError, UserWarning +from trytond.model.exceptions import ValidationError + + +class PatientAlreadyPregnant(ValidationError): + pass +
--- a/tryton/health_gyneco/health_gyneco.py +++ b/tryton/health_gyneco/health_gyneco.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- ############################################################################## # # GNU Health: The Free Health and Hospital Information System @@ -29,6 +28,10 @@ from trytond.transaction import Transaction from sql import * from sql.aggregate import * +from trytond.modules.health.core import get_health_professional, get_institution +from trytond.i18n import gettext + +from .exceptions import PatientAlreadyPregnant __all__ = ['PatientPregnancy', 'PrenatalEvaluation', 'PuerperiumMonitor', @@ -220,10 +223,6 @@ ] cls._order.insert(0, ('lmp', 'DESC')) - cls._error_messages.update({ - 'patient_already_pregnant': 'Our records indicate that the patient' - ' is already pregnant !'}) - @classmethod def validate(cls, pregnancies): super(PatientPregnancy, cls).validate(pregnancies) @@ -241,7 +240,8 @@ records = cursor.fetchone()[0] if records > 1: - self.raise_user_error('patient_already_pregnant') + raise PatientAlreadyPregnant( + gettext('health_gyneco.msg_patient_already_pregnant')) @staticmethod def default_current_pregnancy(): @@ -249,15 +249,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @fields.depends('reverse_weeks', 'pregnancy_end_date') def on_change_with_lmp(self): @@ -338,7 +334,7 @@ help="Signs of Urinary System Activity") digestive_activity_signs = fields.Boolean("SDA", - help="Signs of Digestive Systen Activity") + help="Signs of Digestive System Activity") notes = fields.Text("Notes") @@ -351,15 +347,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() def get_patient_evaluation_data(self, name): @@ -416,15 +408,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() class Perinatal(ModelSQL, ModelView): @@ -503,15 +491,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @@ -714,15 +698,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @staticmethod @@ -769,15 +749,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @staticmethod @@ -821,15 +797,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @staticmethod @@ -868,15 +840,11 @@ @staticmethod def default_institution(): - HealthInst = Pool().get('gnuhealth.institution') - institution = HealthInst.get_institution() - return institution + return get_institution() @staticmethod def default_healthprof(): - pool = Pool() - HealthProf= pool.get('gnuhealth.healthprofessional') - return HealthProf.get_health_professional() + return get_health_professional() @staticmethod
