Mercurial > hgweb > health
changeset 5143:626f36f83990
health_services_imaging: New functionality to include directly the Dx imaing tests on the health service document
| author | Luis Falcon <falcon@gnuhealth.org> |
|---|---|
| date | Wed, 11 May 2022 17:28:14 +0100 |
| parents | b44efd712deb |
| children | a787c13f3717 bfafb37a7063 |
| files | tryton/health_services_imaging/view/gnuhealth_imaging_start_request.xml tryton/health_services_imaging/wizard/wizard_health_services.py |
| diffstat | 2 files changed, 41 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_services_imaging/view/gnuhealth_imaging_start_request.xml +++ b/tryton/health_services_imaging/view/gnuhealth_imaging_start_request.xml @@ -3,6 +3,8 @@ <xpath expr="//field[@name="tests"]" position="after"> <newline/> <group id="group_imaging_services" colspan="4"> + <label name="ungroup_tests"/> + <field name="ungroup_tests"/> <label name="service"/> <field name="service"/> </group>
--- a/tryton/health_services_imaging/wizard/wizard_health_services.py +++ b/tryton/health_services_imaging/wizard/wizard_health_services.py @@ -21,11 +21,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## -import datetime from trytond.model import ModelView, fields -from trytond.pyson import Eval, Not, Bool, PYSONEncoder, Equal, And, Or, If -from trytond.wizard import Wizard, StateTransition, StateView, Button -from trytond.transaction import Transaction +from trytond.pyson import Eval, Equal +from trytond.wizard import Wizard from trytond.pool import Pool @@ -37,10 +35,19 @@ 'Request Patient Imaging Test Start' __name__ = 'gnuhealth.patient.imaging.test.request.start' + ungroup_tests = fields.Boolean( + 'Ungroup', + help="Check if you DO NOT want to include each individual Dx" + " imaging 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'], - states = {'readonly': Equal(Eval('state'), 'done')}, + states={'readonly': Equal(Eval('state'), 'done')}, help="Service document associated to this Imaging Request") @@ -56,6 +63,29 @@ if sequence: return sequence.get() + def append_services(self, imgtest, service): + """ If the ungroup flag is not set, append the img test + to the associated health service + """ + HealthService = Pool().get('gnuhealth.health_service') + + hservice = [] + + service_data = {} + service_lines = [] + + # Add the imgtest to the service document + + service_lines.append(('create', [{ + 'product': imgtest.product.id, + 'desc': imgtest.product.rec_name, + 'qty': 1 + }])) + + hservice.append(service) + service_data['service_line'] = service_lines + + HealthService.write(hservice, service_data) def transition_request(self): ImagingTestRequest = Pool().get('gnuhealth.imaging.test.request') @@ -74,6 +104,10 @@ imaging_test['urgent'] = self.start.urgent if self.start.service: imaging_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) imaging_tests.append(imaging_test) ImagingTestRequest.create(imaging_tests)
