Mercurial > hgweb > health
changeset 3226:7e2c77dac653
Task #15167: Add url links
| author | Chris Zimmerman <chris@teffalump.com> |
|---|---|
| date | Sat, 23 Feb 2019 21:52:52 -0800 |
| parents | 797737d12d6c |
| children | 502b0728a4e2 |
| files | tryton/health_orthanc/health_orthanc.py tryton/health_orthanc/view/config_form.xml tryton/health_orthanc/view/config_tree.xml tryton/health_orthanc/view/patient_form.xml tryton/health_orthanc/view/patient_tree.xml tryton/health_orthanc/view/study_form.xml tryton/health_orthanc/view/study_tree.xml |
| diffstat | 7 files changed, 44 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tryton/health_orthanc/health_orthanc.py +++ b/tryton/health_orthanc/health_orthanc.py @@ -25,6 +25,7 @@ from requests.auth import HTTPBasicAuth as auth from requests.exceptions import HTTPError, ConnectionError from datetime import datetime +from urllib.parse import urljoin import logging import pendulum @@ -66,6 +67,14 @@ ) patients = fields.One2Many("gnuhealth.orthanc.patient", "server", "Patients") studies = fields.One2Many("gnuhealth.orthanc.study", "server", "Studies") + link = fields.Function( + fields.Char("URL", help="Link to server in Orthanc Explorer"), "get_link" + ) + + def get_link(self, name): + pre = "".join([self.domain.rstrip("/"), "/"]) + add = "app/explorer.html" + return urljoin(pre, add) @classmethod def __setup__(cls): @@ -202,13 +211,25 @@ "gnuhealth.orthanc.study", "patient", "Studies", readonly=True ) server = fields.Many2One("gnuhealth.orthanc.config", "Server", readonly=True) + link = fields.Function( + fields.Char("URL", help="Link to patient in Orthanc Explorer"), "get_link" + ) + + def get_link(self, name): + pre = "".join([self.server.domain.rstrip("/"), "/"]) + add = "app/explorer.html#patient?uuid={}".format(self.uuid) + return urljoin(pre, add) @classmethod def __setup__(cls): super().__setup__() t = cls.__table__() cls._sql_constraints = [ - ("uuid_unique", Unique(t, t.server, t.uuid), "UUID must be unique for a given server") + ( + "uuid_unique", + Unique(t, t.server, t.uuid), + "UUID must be unique for a given server", + ) ] @staticmethod @@ -302,13 +323,25 @@ ref_phys = fields.Char("Referring Physician", readonly=True) req_phys = fields.Char("Requesting Physician", readonly=True) server = fields.Many2One("gnuhealth.orthanc.config", "Server", readonly=True) + link = fields.Function( + fields.Char("URL", help="Link to study in Orthanc Explorer"), "get_link" + ) + + def get_link(self, name): + pre = "".join([self.server.domain.rstrip("/"), "/"]) + add = "app/explorer.html#study?uuid={}".format(self.uuid) + return urljoin(pre, add) @classmethod def __setup__(cls): super().__setup__() t = cls.__table__() cls._sql_constraints = [ - ("uuid_unique", Unique(t, t.server, t.uuid), "UUID must be unique for a given server") + ( + "uuid_unique", + Unique(t, t.server, t.uuid), + "UUID must be unique for a given server", + ) ] def get_rec_name(self, name):
--- a/tryton/health_orthanc/view/config_form.xml +++ b/tryton/health_orthanc/view/config_form.xml @@ -14,6 +14,8 @@ <field name="last"/> <label name="validated"/> <field name="validated" readonly="1"/> + <label name="link"/> + <field name="link" widget="url"/> </group> <group string="User" yfill="1"> <label name="user"/>
--- a/tryton/health_orthanc/view/config_tree.xml +++ b/tryton/health_orthanc/view/config_tree.xml @@ -3,6 +3,7 @@ <field name="label" expand="1"/> <field name="since_sync_readable" expand="1"/> <field name="domain" expand="1"/> + <field name="link" widget="url"/> <field name="validated"/> </tree>
--- a/tryton/health_orthanc/view/patient_form.xml +++ b/tryton/health_orthanc/view/patient_form.xml @@ -12,6 +12,8 @@ <field name="ident"/> <label name="uuid"/> <field name="uuid"/> + <label name="link"/> + <field name="link" widget="url"/> <label name="server"/> <field name="server"/> </page>
--- a/tryton/health_orthanc/view/patient_tree.xml +++ b/tryton/health_orthanc/view/patient_tree.xml @@ -3,4 +3,5 @@ <field name="patient" string="Local patient" expand="1"/> <field name="name" string="Orthanc patient" expand="1"/> <field name="ident" string="Orthanc PatientID" expand="1"/> + <field name="link" widget="url"/> </tree>
