Mercurial > hgweb > health
changeset 5141:02401b033f18
health_services: New functionality. Group all tests within a lab order in a single health service document
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Tue, 10 May 2022 18:53:55 +0100 |
| parents | 74fd1ef8db89 |
| children | b44efd712deb |
| files | tryton/health_services_lab/view/gnuhealth_lab_start_request.xml tryton/health_services_lab/wizard/wizard_health_services.py |
| diffstat | 2 files changed, 39 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_services_lab/view/gnuhealth_lab_start_request.xml +++ b/tryton/health_services_lab/view/gnuhealth_lab_start_request.xml @@ -3,6 +3,8 @@ <xpath expr="//field[@name="tests"]" position="after"> <newline/> <group id="group_lab_services" colspan="4"> + <label name="ungroup_tests"/> + <field name="ungroup_tests"/> <label name="service"/> <field name="service"/> </group>
--- a/tryton/health_services_lab/wizard/wizard_health_services.py +++ b/tryton/health_services_lab/wizard/wizard_health_services.py @@ -25,7 +25,6 @@ from trytond.wizard import Wizard from trytond.pool import Pool - __all__ = ['RequestPatientLabTestStart', 'RequestPatientLabTest'] @@ -34,6 +33,15 @@ 'Request Patient Lab Test Start' __name__ = 'gnuhealth.patient.lab.test.request.start' + ungroup_tests = fields.Boolean( + 'Ungroup', + help="Check if you DO NOT want to include each individual lab test" + " from this order in the lab test generation step." + " This is useful when some services are not provided in" + " the same institution.\n" + "In this case, you need to individually update the service" + " document from each individual test") + service = fields.Many2One( 'gnuhealth.health_service', 'Service', domain=[('patient', '=', Eval('patient'))], depends=['patient'], @@ -53,6 +61,30 @@ if sequence: return sequence.get() + def append_services(self, labtest, service): + """ If the ungroup flag is not set, append the lab test + to the associated health service + """ + HealthService = Pool().get('gnuhealth.health_service') + + hservice = [] + + service_data = {} + service_lines = [] + + # Add the labtest to the service document + + service_lines.append(('create', [{ + 'product': labtest.product_id.id, + 'desc': labtest.product_id.rec_name, + 'qty': 1 + }])) + + hservice.append(service) + service_data['service_line'] = service_lines + + HealthService.write(hservice, service_data) + def transition_request(self): PatientLabTest = Pool().get('gnuhealth.patient.lab.test') request_number = self.generate_code() @@ -71,7 +103,10 @@ if self.start.service: lab_test['service'] = self.start.service.id - + # Append the test directly to the health service document + # if the Ungroup flag is not set (default). + if not self.start.ungroup_tests: + self.append_services(test, self.start.service) lab_tests.append(lab_test) PatientLabTest.create(lab_tests)
