h-adminsim 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. h_adminsim/__init__.py +5 -0
  2. h_adminsim/admin_staff.py +280 -0
  3. h_adminsim/assets/configs/data4primary.yaml +47 -0
  4. h_adminsim/assets/configs/data4secondary.yaml +47 -0
  5. h_adminsim/assets/configs/data4tertiary.yaml +47 -0
  6. h_adminsim/assets/country/address.json +141859 -0
  7. h_adminsim/assets/country/country_code.json +244 -0
  8. h_adminsim/assets/departments/department.json +85 -0
  9. h_adminsim/assets/departments/symptom.json +4530 -0
  10. h_adminsim/assets/fhir.schema.json +75253 -0
  11. h_adminsim/assets/names/firstname.txt +1219 -0
  12. h_adminsim/assets/names/lastname.txt +88799 -0
  13. h_adminsim/assets/prompts/cancel_patient_system.txt +38 -0
  14. h_adminsim/assets/prompts/intake_staff_task_user.txt +16 -0
  15. h_adminsim/assets/prompts/intake_supervisor_system.txt +8 -0
  16. h_adminsim/assets/prompts/intake_supervisor_user.txt +31 -0
  17. h_adminsim/assets/prompts/reschedule_patient_system.txt +38 -0
  18. h_adminsim/assets/prompts/schedule_patient_rejected_system.txt +42 -0
  19. h_adminsim/assets/prompts/schedule_patient_system.txt +36 -0
  20. h_adminsim/assets/prompts/schedule_staff_reasoning.txt +57 -0
  21. h_adminsim/assets/prompts/schedule_staff_sc_tool_calling.txt +13 -0
  22. h_adminsim/assets/prompts/schedule_staff_system.txt +10 -0
  23. h_adminsim/assets/prompts/schedule_staff_tool_calling.txt +41 -0
  24. h_adminsim/client/__init__.py +3 -0
  25. h_adminsim/client/google_client.py +209 -0
  26. h_adminsim/client/openai_client.py +199 -0
  27. h_adminsim/client/vllm_client.py +160 -0
  28. h_adminsim/environment/__init__.py +1 -0
  29. h_adminsim/environment/hospital.py +462 -0
  30. h_adminsim/environment/op_scheduling_simulation.py +1126 -0
  31. h_adminsim/pipeline/__init__.py +3 -0
  32. h_adminsim/pipeline/data_generator.py +192 -0
  33. h_adminsim/pipeline/evaluator.py +33 -0
  34. h_adminsim/pipeline/simulation.py +231 -0
  35. h_adminsim/registry/__init__.py +5 -0
  36. h_adminsim/registry/errors.py +89 -0
  37. h_adminsim/registry/models.py +126 -0
  38. h_adminsim/registry/phrases.py +10 -0
  39. h_adminsim/registry/pydantic_models.py +21 -0
  40. h_adminsim/registry/variables.py +9 -0
  41. h_adminsim/supervisor.py +182 -0
  42. h_adminsim/task/agent_task.py +900 -0
  43. h_adminsim/task/fhir_manager.py +222 -0
  44. h_adminsim/task/schedule_assign.py +151 -0
  45. h_adminsim/tools/__init__.py +5 -0
  46. h_adminsim/tools/agent_data_builder.py +124 -0
  47. h_adminsim/tools/data_converter.py +536 -0
  48. h_adminsim/tools/data_synthesizer.py +365 -0
  49. h_adminsim/tools/evaluator.py +258 -0
  50. h_adminsim/tools/sanity_checker.py +216 -0
  51. h_adminsim/tools/scheduling_rule.py +420 -0
  52. h_adminsim/utils/__init__.py +136 -0
  53. h_adminsim/utils/common_utils.py +698 -0
  54. h_adminsim/utils/fhir_utils.py +190 -0
  55. h_adminsim/utils/filesys_utils.py +135 -0
  56. h_adminsim/utils/image_preprocess_utils.py +188 -0
  57. h_adminsim/utils/random_utils.py +358 -0
  58. h_adminsim/version.txt +1 -0
  59. h_adminsim-1.0.0.dist-info/LICENSE +30 -0
  60. h_adminsim-1.0.0.dist-info/METADATA +494 -0
  61. h_adminsim-1.0.0.dist-info/RECORD +62 -0
  62. h_adminsim-1.0.0.dist-info/WHEEL +4 -0
@@ -0,0 +1,136 @@
1
+ import os
2
+ import logging.config
3
+ from importlib import resources
4
+
5
+
6
+
7
+ version_file_path = resources.files("h_adminsim").joinpath("version.txt")
8
+ LOGGING_NAME = f"H-AdminSim_{open(version_file_path).read().strip()}"
9
+ VERBOSE = True
10
+
11
+
12
+ def set_logging(name=LOGGING_NAME, verbose=True):
13
+ """Sets up logging for the given name."""
14
+ rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings
15
+ level = logging.INFO if verbose and rank in {-1, 0} else logging.ERROR
16
+
17
+ class ColorFormatter(logging.Formatter):
18
+ """Custom formatter to add colors to log messages using colorstr."""
19
+ def format(self, record):
20
+ if record.levelname == "ERROR":
21
+ record.msg = colorstr("red", record.msg)
22
+ elif record.levelname == "WARNING":
23
+ record.msg = colorstr("yellow", record.msg)
24
+ # elif record.levelname == "INFO":
25
+ # record.msg = colorstr("green", record.msg)
26
+ elif record.levelname == "DEBUG":
27
+ record.msg = colorstr("blue", record.msg)
28
+ return super().format(record)
29
+
30
+ logging.config.dictConfig({
31
+ 'version': 1,
32
+ 'disable_existing_loggers': False,
33
+ 'formatters': {
34
+ name: {
35
+ '()': ColorFormatter, # Use the custom formatter
36
+ 'format': '[%(asctime)s] [%(levelname)s] [%(name)s] %(message)s'
37
+ }
38
+ },
39
+ 'handlers': {
40
+ name: {
41
+ 'class': 'logging.StreamHandler',
42
+ 'formatter': name,
43
+ 'level': level
44
+ }
45
+ },
46
+ 'loggers': {
47
+ name: {
48
+ 'level': level,
49
+ 'handlers': [name],
50
+ 'propagate': False
51
+ }
52
+ }
53
+ })
54
+
55
+
56
+ set_logging(LOGGING_NAME, verbose=VERBOSE)
57
+ LOGGER = logging.getLogger(LOGGING_NAME)
58
+
59
+
60
+
61
+ def colorstr(*input):
62
+ """
63
+ Colors a string based on the provided color and style arguments. Utilizes ANSI escape codes.
64
+ See https://en.wikipedia.org/wiki/ANSI_escape_code for more details.
65
+
66
+ This function can be called in two ways:
67
+ - colorstr('color', 'style', 'your string')
68
+ - colorstr('your string')
69
+
70
+ In the second form, 'blue' and 'bold' will be applied by default.
71
+
72
+ Args:
73
+ *input (str): A sequence of strings where the first n-1 strings are color and style arguments,
74
+ and the last string is the one to be colored.
75
+
76
+ Supported Colors and Styles:
77
+ Basic Colors: 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
78
+ Bright Colors: 'bright_black', 'bright_red', 'bright_green', 'bright_yellow',
79
+ 'bright_blue', 'bright_magenta', 'bright_cyan', 'bright_white'
80
+ Misc: 'end', 'bold', 'underline'
81
+
82
+ Returns:
83
+ (str): The input string wrapped with ANSI escape codes for the specified color and style.
84
+
85
+ Examples:
86
+ >>> colorstr('blue', 'bold', 'hello world')
87
+ >>> '\033[34m\033[1mhello world\033[0m'
88
+ """
89
+ *args, string = input if len(input) > 1 else ('blue', 'bold', input[0]) # color arguments, string
90
+ colors = {
91
+ 'black': '\033[30m', # basic colors
92
+ 'red': '\033[31m',
93
+ 'green': '\033[32m',
94
+ 'yellow': '\033[33m',
95
+ 'blue': '\033[34m',
96
+ 'magenta': '\033[35m',
97
+ 'cyan': '\033[36m',
98
+ 'white': '\033[37m',
99
+ 'bright_black': '\033[90m', # bright colors
100
+ 'bright_red': '\033[91m',
101
+ 'bright_green': '\033[92m',
102
+ 'bright_yellow': '\033[93m',
103
+ 'bright_blue': '\033[94m',
104
+ 'bright_magenta': '\033[95m',
105
+ 'bright_cyan': '\033[96m',
106
+ 'bright_white': '\033[97m',
107
+ 'end': '\033[0m', # misc
108
+ 'bold': '\033[1m',
109
+ 'underline': '\033[4m'}
110
+ return ''.join(colors[x] for x in args) + f'{string}' + colors['end']
111
+
112
+
113
+
114
+ def log(message, level='info', color=False):
115
+ if level.lower() == 'warning':
116
+ LOGGER.warning(message)
117
+ elif level.lower() == 'error':
118
+ LOGGER.error(message)
119
+ else:
120
+ if color:
121
+ LOGGER.info(colorstr(message))
122
+ else:
123
+ LOGGER.info(message)
124
+
125
+
126
+
127
+ class Information:
128
+ def __init__(self, **kwargs):
129
+ self.__dict__.update(kwargs)
130
+
131
+ def __getitem__(self, key):
132
+ return self.__dict__[key]
133
+
134
+ def update(self, **kwargs):
135
+ self.__dict__.update(kwargs)
136
+ return self