Coverage for cc_modules/cc_text.py : 37%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python
3"""
4camcops_server/cc_modules/cc_text.py
6===============================================================================
8 Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com).
10 This file is part of CamCOPS.
12 CamCOPS is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 CamCOPS is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with CamCOPS. If not, see <https://www.gnu.org/licenses/>.
25===============================================================================
27**Text used by the server, and translated.**
29"""
31from enum import auto, Enum, unique
32from typing import TYPE_CHECKING
34from pendulum import Date
36if TYPE_CHECKING:
37 from camcops_server.cc_modules.cc_request import CamcopsRequest
40TERMS_CONDITIONS_UPDATE_DATE = Date(2020, 6, 29)
43@unique
44class SS(Enum):
45 """
46 Server string enumeration. All elements have type ``<enum 'SS'>`` and
47 ``isinstance(SS.ANSWER, SS)`` is true.
48 """
49 ABNORMAL = auto()
50 ABSENT = auto()
51 ABSENT_OR_MILD = auto()
52 ANONYMOUS_TASK = auto()
53 ANSWER = auto()
54 AUDITORY = auto()
56 CATEGORY = auto()
58 DISCLAIMER_TITLE = auto()
59 DISCLAIMER_SUBTITLE = auto()
60 DISCLAIMER_CONTENT = auto()
61 DISCLAIMER_AGREE = auto()
63 EVENT = auto()
65 FALSE = auto()
66 FEMALE = auto()
68 GENERAL = auto()
70 IF_APPLICABLE = auto()
72 LOCATION = auto()
74 MALE = auto()
75 MEETS_CRITERIA = auto()
76 MILD = auto()
77 MILD_TO_MODERATE = auto()
78 MODERATE = auto()
79 MODERATELY_SEVERE = auto()
80 MODERATE_TO_SEVERE = auto()
82 NA = auto()
83 NO = auto()
84 NONE = auto()
85 NORMAL = auto()
86 NOTE = auto()
88 PRESENT = auto()
90 QUESTION = auto()
92 SEVERE = auto()
93 SEX = auto()
95 TOTAL_SCORE = auto()
96 TRUE = auto()
98 UNKNOWN = auto()
100 VERY_SEVERE = auto()
101 VISUAL = auto()
102 VOLUME_0_TO_1 = auto()
104 YES = auto()
107def server_string(req: "CamcopsRequest", w: SS) -> str:
108 """
109 Returns a translated server string.
111 Use this mechanism when the same string is re-used in several places in
112 the server (but not by the client).
114 Args:
115 req:
116 a :class:`camcops_server.cc_modules.cc_request.CamcopsRequest`
117 w:
118 which string? A :class:`camcops_server.cc_modules.cc_text.SS`
119 enumeration value
121 Returns:
122 the translated string
124 """
125 _ = req.gettext
127 if w == SS.ABNORMAL:
128 return _("Abnormal")
129 elif w == SS.ABSENT:
130 return _("Absent")
131 elif w == SS.ABSENT_OR_MILD:
132 return _("Absent or mild")
133 elif w == SS.ANONYMOUS_TASK:
134 return _("Anonymous task")
135 elif w == SS.ANSWER:
136 return _("Answer")
137 elif w == SS.AUDITORY:
138 return _("Auditory")
140 elif w == SS.CATEGORY:
141 return _("Category")
143 elif w == SS.DISCLAIMER_TITLE:
144 return _("TERMS AND CONDITIONS OF USE")
145 elif w == SS.DISCLAIMER_SUBTITLE:
146 return _("You must agree to the following terms and conditions in "
147 "order to use CamCOPS.")
148 elif w == SS.DISCLAIMER_CONTENT:
149 return _(
150 "1. By using the Cambridge Cognitive and Psychiatric Assessment "
151 "Kit application or web interface (“CamCOPS”), you are agreeing "
152 "in full to these Terms and Conditions of Use. If you do not "
153 "agree to these terms, do not use the software.\n"
154 "\n"
155 "2. Content that is original to CamCOPS is licensed as follows.\n"
156 "\n"
157 "CamCOPS is free software: you can redistribute it and/or modify "
158 "it under the terms of the GNU General Public License as "
159 "published by the Free Software Foundation, either version 3 of "
160 "the License, or (at your option) any later version.\n"
161 "\n"
162 "CamCOPS is distributed in the hope that it will be useful, but "
163 "WITHOUT ANY WARRANTY; without even the implied warranty of "
164 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
165 "GNU General Public License for more details.\n"
166 "\n"
167 "You should have received a copy of the GNU General Public "
168 "License along with CamCOPS. If not, see "
169 "https://www.gnu.org/licenses/.\n"
170 "\n"
171 "3. Content created by others and distributed with CamCOPS may be "
172 "in the public domain, or distributed under other licenses or "
173 "permissions. THERE MAY BE CRITERIA THAT APPLY TO YOU THAT MEAN "
174 "YOU ARE NOT PERMITTED TO USE SPECIFIC TASKS. IT IS YOUR "
175 "RESPONSIBILITY TO CHECK THAT YOU ARE LEGALLY ENTITLED TO USE "
176 "EACH TASK. You agree that the authors of CamCOPS are not "
177 "responsible for any consequences that arise from your use of an "
178 "unauthorized task.\n\n 4. While efforts have been made to ensure "
179 "that CamCOPS is reliable and accurate, you agree that the "
180 "authors and distributors of CamCOPS are not responsible for "
181 "errors, omissions, or defects in the content, nor liable for any "
182 "direct, indirect, incidental, special and/or consequential "
183 "damages, in whole or in part, resulting from your use or any "
184 "user’s use of or reliance upon its content.\n"
185 "\n"
186 "5. Content contained in or accessed through CamCOPS should not "
187 "be relied upon for medical purposes in any way. This software is "
188 "not designed for use by the general public. If medical advice is "
189 "required you should seek expert medical assistance. You agree "
190 "that you will not rely on this software for any medical "
191 "purpose.\n"
192 "\n"
193 "6. Regarding the European Union Council Directive 93/42/EEC of "
194 "14 June 1993 concerning medical devices (amended by further "
195 "directives up to and including Directive 2007/47/EC of 5 "
196 "September 2007) (“Medical Devices Directive”): CamCOPS is not "
197 "intended for the diagnosis and/or monitoring of human disease. "
198 "If it is used for such purposes, it must be used EXCLUSIVELY FOR "
199 "CLINICAL INVESTIGATIONS in an appropriate setting by persons "
200 "professionally qualified to do so. It has NOT undergone a "
201 "conformity assessment under the Medical Devices Directive, and "
202 "thus cannot be marketed or put into service as a medical device. "
203 "You agree that you will not use it as a medical device.\n"
204 "\n"
205 "7. THIS SOFTWARE IS DESIGNED FOR USE BY QUALIFIED CLINICIANS "
206 "ONLY. BY CONTINUING TO USE THIS SOFTWARE YOU ARE CONFIRMING THAT "
207 "YOU ARE A QUALIFIED CLINICIAN, AND THAT YOU RETAIN "
208 "RESPONSIBILITY FOR DIAGNOSIS AND MANAGEMENT.\n"
209 "\n"
210 "8. The CamCOPS server uses a single secure cookie for session "
211 "authentication. The cookie is not used for any other purpose. "
212 "It is deleted when you finish your session (it is a session cookie). " # noqa
213 "By using a CamCOPS server, you agree to this use of cookies.\n"
214 "\n"
215 "These terms and conditions were last revised on 2020-10-12."
216 )
217 # ... should match textconst::TERMS_CONDITIONS in the C++ app.
218 #
219 # ENSURE YOU ALSO UPDATE TERMS_CONDITIONS_UPDATE_DATE (above).
220 #
221 # [OLD CONSTRAINT: ... but don't include hyperlinks; they break the XML
222 # reader]
223 elif w == SS.DISCLAIMER_AGREE:
224 return _("I agree to these terms and conditions")
226 elif w == SS.EVENT:
227 return _("Event")
229 elif w == SS.FALSE:
230 return _("False")
231 elif w == SS.FEMALE:
232 return _("Female")
234 elif w == SS.GENERAL:
235 return _("General")
237 elif w == SS.IF_APPLICABLE:
238 return _("If applicable")
240 elif w == SS.LOCATION:
241 return _("Location")
243 elif w == SS.MALE:
244 return _("Male")
245 elif w == SS.MEETS_CRITERIA:
246 return _("Meets criteria?")
247 elif w == SS.MILD:
248 return _("Mild")
249 elif w == SS.MILD_TO_MODERATE:
250 return _("Mild to moderate")
251 elif w == SS.MODERATE:
252 return _("Moderate")
253 elif w == SS.MODERATELY_SEVERE:
254 return _("Moderately severe")
255 elif w == SS.MODERATE_TO_SEVERE:
256 return _("Moderate to severe")
258 elif w == SS.NA:
259 return _("N/A")
260 elif w == SS.NO:
261 return _("No")
262 elif w == SS.NONE:
263 return _("None")
264 elif w == SS.NORMAL:
265 return _("Normal")
266 elif w == SS.NOTE:
267 return _("Note")
269 elif w == SS.PRESENT:
270 return _("Present")
272 elif w == SS.QUESTION:
273 return _("Question")
275 elif w == SS.SEVERE:
276 return _("Severe")
277 elif w == SS.SEX:
278 return _("Sex")
280 elif w == SS.TOTAL_SCORE:
281 return _("Total score")
282 elif w == SS.TRUE:
283 return _("True")
285 elif w == SS.UNKNOWN:
286 return _("Unknown")
288 elif w == SS.VERY_SEVERE:
289 return _("Very severe")
290 elif w == SS.VISUAL:
291 return _("Visual")
292 elif w == SS.VOLUME_0_TO_1:
293 return _("Volume (0–1)")
295 elif w == SS.YES:
296 return _("Yes")
298 raise ValueError("Bad value passed to server_string")