Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.

Commit 129dc46

Browse files
authored
Autodetect suitable client in Doctor's edit view (#108)
* Autodetect the client a Doctor can be assigned to * Update Changelog
1 parent dec0ad0 commit 129dc46

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

CHANGES.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Changelog
66

77
**Added**
88

9-
- #102 Add Primary Referrer column in Doctor listings
10-
- #85 Allow client contact to list/add/edit Batches from its own Client
119
- #102 Add Primary Referrer column in Doctor listings
1210
- #85 Allow client contact to list/add/edit Cases from its own Client
1311
- #83 Allow client contact to create and edit Doctors
@@ -21,6 +19,7 @@ Changelog
2119

2220
**Fixed**
2321

22+
- #108 Autodetect suitable client in Doctor's edit view
2423
- #109 Traceback `bika_widgets/remarks does not exist for`
2524
- #107 DateTime validator fires even if DateOfBirth is non-mandatory
2625
- #106 Fields from Patient's additional tabs are not displayed

bika/health/content/doctor.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,24 @@ def get_clients_vocabulary(self):
9494
# Allow to change the client if there are no ARs associated
9595
client = self.getPrimaryReferrer()
9696
if not client:
97-
return DisplayList([('', '')])
97+
# Maybe all Batches and ARs assigned to this Doctor belong to
98+
# the same Client.. If so, just assign this client by default
99+
client_uids = map(lambda ar: ar.getClientUID,
100+
self.getAnalysisRequests())
101+
client_uids = list(set(client_uids))
102+
if len(client_uids) > 1:
103+
# More than one client assigned!
104+
return DisplayList([('', '')])
105+
clients = map(lambda batch: batch.getClient(),
106+
self.getBatches(full_objects=True))
107+
client_uids += map(lambda client: api.get_uid(client), clients)
108+
client_uids = list(set(client_uids))
109+
if len(client_uids) > 1:
110+
# More than one client assigned!
111+
return DisplayList([('', '')])
112+
113+
client = api.get_object_by_uid(client_uids[0])
114+
98115
return DisplayList([(api.get_uid(client), client.Title())])
99116

100117
# If the current user is a client contact, do not display other clients

0 commit comments

Comments
 (0)