Hide keyboard shortcuts

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 

2 

3""" 

4camcops_server/cc_modules/cc_nhs.py 

5 

6=============================================================================== 

7 

8 Copyright (C) 2012-2020 Rudolf Cardinal (rudolf@pobox.com). 

9 

10 This file is part of CamCOPS. 

11 

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. 

16 

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. 

21 

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/>. 

24 

25=============================================================================== 

26 

27**NHS constants.** 

28 

29""" 

30 

31from typing import Dict, Optional, TYPE_CHECKING 

32 

33from camcops_server.cc_modules.cc_string import AS 

34 

35if TYPE_CHECKING: 

36 from camcops_server.cc_modules.cc_request import CamcopsRequest 

37 

38 

39# ============================================================================= 

40# Permitted values in fields and corresponding dictionaries 

41# ============================================================================= 

42 

43# Do not use wappstring in the module-level code; the strings file is only 

44# initialized later. However, PV* fields are used at table creation. 

45 

46PV_NHS_MARITAL_STATUS = ['S', 'M', 'D', 'W', 'P', 'N'] 

47PV_NHS_ETHNIC_CATEGORY = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 

48 'L', 'M', 'N', 'P', 'R', 'S', 'Z'] 

49 

50 

51def get_nhs_dd_person_marital_status( 

52 req: "CamcopsRequest") -> Dict[Optional[str], Optional[str]]: 

53 """ 

54 Returns a dictionary mapping NHS marital status codes to descriptive 

55 strings. 

56 """ 

57 return { 

58 None: None, 

59 "S": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_S), 

60 "M": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_M), 

61 "D": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_D), 

62 "W": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_W), 

63 "P": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_P), 

64 "N": req.wappstring(AS.NHS_PERSON_MARITAL_STATUS_CODE_N), 

65 } 

66 

67 

68def get_nhs_dd_ethnic_category_code( 

69 req: "CamcopsRequest") -> Dict[Optional[str], Optional[str]]: 

70 """ 

71 Returns a dictionary mapping NHS ethnicity codes to descriptive 

72 strings. 

73 """ 

74 return { 

75 None: None, 

76 "A": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_A), 

77 "B": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_B), 

78 "C": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_C), 

79 "D": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_D), 

80 "E": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_E), 

81 "F": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_F), 

82 "G": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_G), 

83 "H": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_H), 

84 "J": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_J), 

85 "K": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_K), 

86 "L": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_L), 

87 "M": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_M), 

88 "N": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_N), 

89 "P": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_P), 

90 "R": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_R), 

91 "S": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_S), 

92 "Z": req.wappstring(AS.NHS_ETHNIC_CATEGORY_CODE_Z), 

93 }