Mercurial > hgweb > health
changeset 4794:a202b3a4bf79
health: Complete task task #16078: Add patient medical evaluation to health services
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Mon, 22 Nov 2021 11:53:29 +0000 |
| parents | a20d5f2bc315 |
| children | 320d3c300fed |
| files | tryton/health_services/__init__.py tryton/health_services/data/health_services_data.xml tryton/health_services/data/messages/messages.xml tryton/health_services/exceptions.py tryton/health_services/health_services.py tryton/health_services/health_services_view.xml tryton/health_services/tryton.cfg tryton/health_services/view/gnuhealth_patient_evaluation.xml |
| diffstat | 8 files changed, 133 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_services/__init__.py +++ b/tryton/health_services/__init__.py @@ -41,6 +41,7 @@ invoice.Invoice, invoice.InvoiceLine, health_services.PatientPrescriptionOrder, + health_services.PatientEvaluation, module='health_services', type_='model') Pool.register( wizard.CreateServiceInvoice,
new file mode 100644 --- /dev/null +++ b/tryton/health_services/data/health_services_data.xml @@ -0,0 +1,27 @@ +<?xml version="1"?> +<tryton> + <data noupdate="0"> + + <record id="product_category_medical_evaluation" model="product.category"> + <field name="name">Medical Evaluation</field> + </record> + + <record id="product_template_medical_services" model="product.template"> + <field name="name">Medical evaluation service</field> + <field eval="1" name="list_price"/> + <field name="default_uom" ref="product.uom_unit"/> + <field name="type">service</field> + </record> + + <record model="product.template-product.category" id="cat_product_template_medical_evaluation"> + <field name="template" ref="product_template_medical_services"/> + <field name="category" ref="product_category_medical_evaluation"/> + </record> + <!-- Link products with template --> + + <record id="product_product_medical_evaluation" model="product.product"> + <field name="template" model="product.template" ref="product_template_medical_services"/> + </record> + + </data> +</tryton>
--- a/tryton/health_services/data/messages/messages.xml +++ b/tryton/health_services/data/messages/messages.xml @@ -9,6 +9,9 @@ <record model="ir.message" id="msg_no_service_associated"> <field name="text">You need to associate a service</field> </record> + <record model="ir.message" id="msg_no_product_associated"> + <field name="text">You need to associate a product</field> + </record> <record model="ir.message" id="msg_no_invoice_address"> <field name="text">No invoice adress</field> </record>
--- a/tryton/health_services/exceptions.py +++ b/tryton/health_services/exceptions.py @@ -10,6 +10,9 @@ class NoServiceAssociated(UserError): pass +class NoProductAssociated(UserError): + pass + class NoInvoiceAddress(UserError): pass
--- a/tryton/health_services/health_services.py +++ b/tryton/health_services/health_services.py @@ -33,8 +33,8 @@ from trytond.pyson import Id from .exceptions import ( - ServiceAlreadyInvoiced, NoServiceAssociated, NoInvoiceAddress, - NoPaymentTerm + ServiceAlreadyInvoiced, NoServiceAssociated, NoProductAssociated, + NoInvoiceAddress, NoPaymentTerm ) @@ -225,3 +225,75 @@ service_data ['service_line'] = service_lines HealthService.write(hservice, service_data) + + +""" Include Patient Evaluation service""" + +class PatientEvaluation(ModelSQL, ModelView): + 'Patient Evaluation' + __name__ = 'gnuhealth.patient.evaluation' + + service = fields.Many2One( + 'gnuhealth.health_service', 'Service', + domain=[('patient', '=', Eval('patient'))], depends=['patient'], + states = {'readonly': Equal(Eval('state'), 'done')}, + help="Service document associated to this evaluation") + + product = fields.Many2One('product.product', 'Product') + + """ + @staticmethod + def default_product(): + return get_institution() + """ + + @classmethod + def __setup__(cls): + super(PatientEvaluation, cls).__setup__() + cls._buttons.update({ + 'update_service': { + 'readonly': Equal(Eval('state'), 'done'), + }, + }) + + + @classmethod + @ModelView.button + def update_service(cls, evaluations): + pool = Pool() + HealthService = pool.get('gnuhealth.health_service') + + hservice = [] + evaluation = evaluations[0] + + if not evaluation.service: + raise NoServiceAssociated( + gettext('health_service.msg_no_service_associated')) + + if not evaluation.product: + raise NoProductAssociated( + gettext('health_service.msg_no_product_associated')) + + + service_data = {} + service_lines = [] + + # Add the evaluation to the service document line + + service_lines.append(('create', [{ + 'product': evaluation.product.id, + 'desc': 'Medical evaluation services', + 'qty': 1 + }])) + + + hservice.append(evaluation.service) + + description = "Medical evaluation services" + service_data ['desc'] = description + service_data ['service_line'] = service_lines + + HealthService.write(hservice, service_data) + + +
--- a/tryton/health_services/health_services_view.xml +++ b/tryton/health_services/health_services_view.xml @@ -154,5 +154,13 @@ <field name="name">gnuhealth_prescription</field> </record> +<!-- Extend patient evaluation view to include the service --> + + <record model="ir.ui.view" id="view_evaluation_form"> + <field name="model">gnuhealth.patient.evaluation</field> + <field name="inherit" ref="health.gnuhealth_patient_evaluation_view" /> + <field name="name">gnuhealth_patient_evaluation</field> + </record> + </data> </tryton>
--- a/tryton/health_services/tryton.cfg +++ b/tryton/health_services/tryton.cfg @@ -10,5 +10,6 @@ data/health_service_sequences.xml data/gnuhealth_commands.xml data/messages/messages.xml + data/health_services_data.xml security/access_rights.xml invoice.xml
new file mode 100644 --- /dev/null +++ b/tryton/health_services/view/gnuhealth_patient_evaluation.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<data> + <xpath expr="//page[@id="page_patient_evaluation_extra_info"]" position="after"> + <page id="evaluation_services_page" string="Services"> + <group id="group_evaluation_services" string="Services"> + <label name="product"/> + <field name="product"/> + <label name="service"/> + <field name="service"/> + <newline/> + <button name="update_service" help="Update Service document with this evaluation" string="Update Services" icon="tryton-go-next" confirm="Transfer + this evaluation to services?" colspan="4"/> + </group> + </page> + </xpath> +</data>
