1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# |
3
|
|
|
# This file is part of SENAITE.HEALTH. |
4
|
|
|
# |
5
|
|
|
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it |
6
|
|
|
# under the terms of the GNU General Public License as published by the Free |
7
|
|
|
# Software Foundation, version 2. |
8
|
|
|
# |
9
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT |
10
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
11
|
|
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
12
|
|
|
# details. |
13
|
|
|
# |
14
|
|
|
# You should have received a copy of the GNU General Public License along with |
15
|
|
|
# this program; if not, write to the Free Software Foundation, Inc., 51 |
16
|
|
|
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17
|
|
|
# |
18
|
|
|
# Copyright 2018-2019 by it's authors. |
19
|
|
|
# Some rights reserved, see README and LICENSE. |
20
|
|
|
|
21
|
|
|
import json |
22
|
|
|
|
23
|
|
|
import plone |
24
|
|
|
|
25
|
|
|
from bika.health.catalog import CATALOG_PATIENTS |
26
|
|
|
from bika.lims import api |
27
|
|
|
from bika.lims.browser import BrowserView |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
class ajaxGetPatientInfo(BrowserView): |
31
|
|
|
""" Grab details of newly created patient (#420) |
32
|
|
|
""" |
33
|
|
|
def __call__(self): |
34
|
|
|
plone.protect.CheckAuthenticator(self.request) |
35
|
|
|
ret = {'PatientID': '', |
36
|
|
|
'PatientUID': '', |
37
|
|
|
'ClientPatientID': '', |
38
|
|
|
'ClientID': '', |
39
|
|
|
'ClientUID': '', |
40
|
|
|
'ClientTitle': '', |
41
|
|
|
'ClientSysID': '', |
42
|
|
|
'PatientFullname': '', |
43
|
|
|
'PatientBirthDate': '', |
44
|
|
|
'PatientGender': 'dk', |
45
|
|
|
'PatientMenstrualStatus': ''} |
46
|
|
|
|
47
|
|
|
uid = self.request.get('PatientUID', '') |
48
|
|
|
if not uid: |
49
|
|
|
return json.dumps(ret) |
50
|
|
|
|
51
|
|
|
brains = api.search({"UID": uid}, CATALOG_PATIENTS) |
52
|
|
|
if brains: |
53
|
|
|
patient = brains[0] |
54
|
|
|
ret = { |
55
|
|
|
'PatientID': patient.getPatientID, |
56
|
|
|
'PatientUID': patient.UID, |
57
|
|
|
'ClientPatientID': patient.getClientPatientID, |
58
|
|
|
'ClientUID': patient.getPrimaryReferrerUID, |
59
|
|
|
'ClientTitle': patient.getPrimaryReferrerTitle, |
60
|
|
|
'ClientSysID': patient.getPrimaryReferrerID, |
61
|
|
|
'PatientFullname': patient.Title, |
62
|
|
|
'PatientBirthDate': self.ulocalized_time(patient.getBirthDate), |
63
|
|
|
'PatientGender': patient.getGender, |
64
|
|
|
'PatientMenstrualStatus': patient.getMenstrualStatus |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return json.dumps(ret) |
68
|
|
|
|