blob: bf4df7e4c88fde699b6385e3bd832e99bcc0b083 [file] [log] [blame]
Rushabh Mehtaf0569742017-09-13 12:52:30 +05301from __future__ import unicode_literals
2import frappe
Rushabh Mehtaf0569742017-09-13 12:52:30 +05303
4from frappe import _
Manas Solanki966f1412017-11-23 15:22:10 +05305from erpnext.setup.utils import insert_record
Rushabh Mehtaf0569742017-09-13 12:52:30 +05306
7def setup_healthcare():
Rushabh Mehtabc4e2cd2017-10-17 12:30:34 +05308 if frappe.db.exists('Medical Department', 'Cardiology'):
9 # already setup
10 return
Rushabh Mehtaf0569742017-09-13 12:52:30 +053011 create_medical_departments()
12 create_antibiotics()
Jamsheerc07e8e52018-09-18 10:54:03 +053013 create_lab_test_uom()
Rushabh Mehtaf0569742017-09-13 12:52:30 +053014 create_duration()
15 create_dosage()
16 create_healthcare_item_groups()
Rushabh Mehtaf0569742017-09-13 12:52:30 +053017 create_sensitivity()
Jamsheer0cde6ae2018-05-16 10:54:00 +053018 add_healthcare_service_unit_tree_root()
Rucha Mahabalf3df5c92020-11-30 12:16:28 +053019 setup_patient_history_settings()
Rushabh Mehtaf0569742017-09-13 12:52:30 +053020
21def create_medical_departments():
mbauskaree9da672017-10-10 12:15:48 +053022 departments = [
23 "Accident And Emergency Care" ,"Anaesthetics", "Biochemistry", "Cardiology", "Dermatology",
24 "Diagnostic Imaging", "ENT", "Gastroenterology", "General Surgery", "Gynaecology",
25 "Haematology", "Maternity", "Microbiology", "Nephrology", "Neurology", "Oncology",
26 "Orthopaedics", "Pathology", "Physiotherapy", "Rheumatology", "Serology", "Urology"
27 ]
28 for department in departments:
Rushabh Mehtaf0569742017-09-13 12:52:30 +053029 mediacal_department = frappe.new_doc("Medical Department")
mbauskaree9da672017-10-10 12:15:48 +053030 mediacal_department.department = _(department)
Rushabh Mehtaf0569742017-09-13 12:52:30 +053031 try:
32 mediacal_department.save()
33 except frappe.DuplicateEntryError:
34 pass
35
36def create_antibiotics():
mbauskaree9da672017-10-10 12:15:48 +053037 abt = [
38 "Amoxicillin", "Ampicillin", "Bacampicillin", "Carbenicillin", "Cloxacillin", "Dicloxacillin",
39 "Flucloxacillin", "Mezlocillin", "Nafcillin", "Oxacillin", "Penicillin G", "Penicillin V",
40 "Piperacillin", "Pivampicillin", "Pivmecillinam", "Ticarcillin", "Cefacetrile (cephacetrile)",
41 "Cefadroxil (cefadroxyl)", "Cefalexin (cephalexin)", "Cefaloglycin (cephaloglycin)",
42 "Cefalonium (cephalonium)", "Cefaloridine (cephaloradine)", "Cefalotin (cephalothin)",
43 "Cefapirin (cephapirin)", "Cefatrizine", "Cefazaflur", "Cefazedone", "Cefazolin (cephazolin)",
44 "Cefradine (cephradine)", "Cefroxadine", "Ceftezole", "Cefaclor", "Cefamandole", "Cefmetazole",
45 "Cefonicid", "Cefotetan", "Cefoxitin", "Cefprozil (cefproxil)", "Cefuroxime", "Cefuzonam",
46 "Cefcapene", "Cefdaloxime", "Cefdinir", "Cefditoren", "Cefetamet", "Cefixime", "Cefmenoxime",
47 "Cefodizime", "Cefotaxime", "Cefpimizole", "Cefpodoxime", "Cefteram", "Ceftibuten", "Ceftiofur",
48 "Ceftiolene", "Ceftizoxime", "Ceftriaxone", "Cefoperazone", "Ceftazidime", "Cefclidine", "Cefepime",
49 "Cefluprenam", "Cefoselis", "Cefozopran", "Cefpirome", "Cefquinome", "Ceftobiprole", "Ceftaroline",
50 "Cefaclomezine","Cefaloram", "Cefaparole", "Cefcanel", "Cefedrolor", "Cefempidone", "Cefetrizole",
51 "Cefivitril", "Cefmatilen", "Cefmepidium", "Cefovecin", "Cefoxazole", "Cefrotil", "Cefsumide",
52 "Cefuracetime", "Ceftioxide", "Ceftazidime/Avibactam", "Ceftolozane/Tazobactam", "Aztreonam",
53 "Imipenem", "Imipenem/cilastatin", "Doripenem", "Meropenem", "Ertapenem", "Azithromycin",
54 "Erythromycin", "Clarithromycin", "Dirithromycin", "Roxithromycin", "Telithromycin", "Clindamycin",
55 "Lincomycin", "Pristinamycin", "Quinupristin/dalfopristin", "Amikacin", "Gentamicin", "Kanamycin",
56 "Neomycin", "Netilmicin", "Paromomycin", "Streptomycin", "Tobramycin", "Flumequine", "Nalidixic acid",
57 "Oxolinic acid", "Piromidic acid", "Pipemidic acid", "Rosoxacin", "Ciprofloxacin", "Enoxacin",
58 "Lomefloxacin", "Nadifloxacin", "Norfloxacin", "Ofloxacin", "Pefloxacin", "Rufloxacin", "Balofloxacin",
59 "Gatifloxacin", "Grepafloxacin", "Levofloxacin", "Moxifloxacin", "Pazufloxacin", "Sparfloxacin",
60 "Temafloxacin", "Tosufloxacin", "Besifloxacin", "Clinafloxacin", "Gemifloxacin",
61 "Sitafloxacin", "Trovafloxacin", "Prulifloxacin", "Sulfamethizole", "Sulfamethoxazole",
62 "Sulfisoxazole", "Trimethoprim-Sulfamethoxazole", "Demeclocycline", "Doxycycline", "Minocycline",
63 "Oxytetracycline", "Tetracycline", "Tigecycline", "Chloramphenicol", "Metronidazole",
64 "Tinidazole", "Nitrofurantoin", "Vancomycin", "Teicoplanin", "Telavancin", "Linezolid",
65 "Cycloserine 2", "Rifampin", "Rifabutin", "Rifapentine", "Rifalazil", "Bacitracin", "Polymyxin B",
66 "Viomycin", "Capreomycin"
67 ]
68
Rushabh Mehtaf0569742017-09-13 12:52:30 +053069 for a in abt:
70 antibiotic = frappe.new_doc("Antibiotic")
71 antibiotic.antibiotic_name = a
72 try:
73 antibiotic.save()
74 except frappe.DuplicateEntryError:
75 pass
76
Jamsheerc07e8e52018-09-18 10:54:03 +053077def create_lab_test_uom():
Rushabh Mehtaf0569742017-09-13 12:52:30 +053078 records = [
Jamsheerc07e8e52018-09-18 10:54:03 +053079 {"doctype": "Lab Test UOM", "name": "umol/L", "lab_test_uom": "umol/L", "uom_description": None },
80 {"doctype": "Lab Test UOM", "name": "mg/L", "lab_test_uom": "mg/L", "uom_description": None },
81 {"doctype": "Lab Test UOM", "name": "mg / dl", "lab_test_uom": "mg / dl", "uom_description": None },
82 {"doctype": "Lab Test UOM", "name": "pg / ml", "lab_test_uom": "pg / ml", "uom_description": None },
83 {"doctype": "Lab Test UOM", "name": "U/ml", "lab_test_uom": "U/ml", "uom_description": None },
84 {"doctype": "Lab Test UOM", "name": "/HPF", "lab_test_uom": "/HPF", "uom_description": None },
85 {"doctype": "Lab Test UOM", "name": "Million Cells / cumm", "lab_test_uom": "Million Cells / cumm", "uom_description": None },
86 {"doctype": "Lab Test UOM", "name": "Lakhs Cells / cumm", "lab_test_uom": "Lakhs Cells / cumm", "uom_description": None },
87 {"doctype": "Lab Test UOM", "name": "U / L", "lab_test_uom": "U / L", "uom_description": None },
88 {"doctype": "Lab Test UOM", "name": "g / L", "lab_test_uom": "g / L", "uom_description": None },
89 {"doctype": "Lab Test UOM", "name": "IU / ml", "lab_test_uom": "IU / ml", "uom_description": None },
90 {"doctype": "Lab Test UOM", "name": "gm %", "lab_test_uom": "gm %", "uom_description": None },
91 {"doctype": "Lab Test UOM", "name": "Microgram", "lab_test_uom": "Microgram", "uom_description": None },
92 {"doctype": "Lab Test UOM", "name": "Micron", "lab_test_uom": "Micron", "uom_description": None },
93 {"doctype": "Lab Test UOM", "name": "Cells / cumm", "lab_test_uom": "Cells / cumm", "uom_description": None },
94 {"doctype": "Lab Test UOM", "name": "%", "lab_test_uom": "%", "uom_description": None },
95 {"doctype": "Lab Test UOM", "name": "mm / dl", "lab_test_uom": "mm / dl", "uom_description": None },
96 {"doctype": "Lab Test UOM", "name": "mm / hr", "lab_test_uom": "mm / hr", "uom_description": None },
97 {"doctype": "Lab Test UOM", "name": "ulU / ml", "lab_test_uom": "ulU / ml", "uom_description": None },
98 {"doctype": "Lab Test UOM", "name": "ng / ml", "lab_test_uom": "ng / ml", "uom_description": None },
99 {"doctype": "Lab Test UOM", "name": "ng / dl", "lab_test_uom": "ng / dl", "uom_description": None },
100 {"doctype": "Lab Test UOM", "name": "ug / dl", "lab_test_uom": "ug / dl", "uom_description": None }
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530101 ]
102
103 insert_record(records)
104
105def create_duration():
106 records = [
107 {"doctype": "Prescription Duration", "name": "3 Month", "number": "3", "period": "Month" },
108 {"doctype": "Prescription Duration", "name": "2 Month", "number": "2", "period": "Month" },
109 {"doctype": "Prescription Duration", "name": "1 Month", "number": "1", "period": "Month" },
110 {"doctype": "Prescription Duration", "name": "12 Hour", "number": "12", "period": "Hour" },
111 {"doctype": "Prescription Duration", "name": "11 Hour", "number": "11", "period": "Hour" },
112 {"doctype": "Prescription Duration", "name": "10 Hour", "number": "10", "period": "Hour" },
113 {"doctype": "Prescription Duration", "name": "9 Hour", "number": "9", "period": "Hour" },
114 {"doctype": "Prescription Duration", "name": "8 Hour", "number": "8", "period": "Hour" },
115 {"doctype": "Prescription Duration", "name": "7 Hour", "number": "7", "period": "Hour" },
116 {"doctype": "Prescription Duration", "name": "6 Hour", "number": "6", "period": "Hour" },
117 {"doctype": "Prescription Duration", "name": "5 Hour", "number": "5", "period": "Hour" },
118 {"doctype": "Prescription Duration", "name": "4 Hour", "number": "4", "period": "Hour" },
119 {"doctype": "Prescription Duration", "name": "3 Hour", "number": "3", "period": "Hour" },
120 {"doctype": "Prescription Duration", "name": "2 Hour", "number": "2", "period": "Hour" },
121 {"doctype": "Prescription Duration", "name": "1 Hour", "number": "1", "period": "Hour" },
122 {"doctype": "Prescription Duration", "name": "5 Week", "number": "5", "period": "Week" },
123 {"doctype": "Prescription Duration", "name": "4 Week", "number": "4", "period": "Week" },
124 {"doctype": "Prescription Duration", "name": "3 Week", "number": "3", "period": "Week" },
125 {"doctype": "Prescription Duration", "name": "2 Week", "number": "2", "period": "Week" },
126 {"doctype": "Prescription Duration", "name": "1 Week", "number": "1", "period": "Week" },
127 {"doctype": "Prescription Duration", "name": "6 Day", "number": "6", "period": "Day" },
128 {"doctype": "Prescription Duration", "name": "5 Day", "number": "5", "period": "Day" },
129 {"doctype": "Prescription Duration", "name": "4 Day", "number": "4", "period": "Day" },
130 {"doctype": "Prescription Duration", "name": "3 Day", "number": "3", "period": "Day" },
131 {"doctype": "Prescription Duration", "name": "2 Day", "number": "2", "period": "Day" },
132 {"doctype": "Prescription Duration", "name": "1 Day", "number": "1", "period": "Day" }
133 ]
134 insert_record(records)
135
136def create_dosage():
137 records = [
138 {"doctype": "Prescription Dosage", "name": "1-1-1-1", "dosage": "1-1-1-1","dosage_strength":
139 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "13:00:00"},{"strength": "1.0","strength_time": "17:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
140 },
141 {"doctype": "Prescription Dosage", "name": "0-0-1", "dosage": "0-0-1","dosage_strength":
142 [{"strength": "1.0","strength_time": "21:00:00"}]
143 },
144 {"doctype": "Prescription Dosage", "name": "1-0-0", "dosage": "1-0-0","dosage_strength":
145 [{"strength": "1.0","strength_time": "9:00:00"}]
146 },
147 {"doctype": "Prescription Dosage", "name": "0-1-0", "dosage": "0-1-0","dosage_strength":
148 [{"strength": "1.0","strength_time": "14:00:00"}]
149 },
150 {"doctype": "Prescription Dosage", "name": "1-1-1", "dosage": "1-1-1","dosage_strength":
151 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "14:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
152 },
153 {"doctype": "Prescription Dosage", "name": "1-0-1", "dosage": "1-0-1","dosage_strength":
154 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "21:00:00"}]
155 },
156 {"doctype": "Prescription Dosage", "name": "Once Bedtime", "dosage": "Once Bedtime","dosage_strength":
157 [{"strength": "1.0","strength_time": "21:00:00"}]
158 },
159 {"doctype": "Prescription Dosage", "name": "5 times a day", "dosage": "5 times a day","dosage_strength":
160 [{"strength": "1.0","strength_time": "5:00:00"}, {"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "13:00:00"},{"strength": "1.0","strength_time": "17:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
161 },
162 {"doctype": "Prescription Dosage", "name": "QID", "dosage": "QID","dosage_strength":
163 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "13:00:00"},{"strength": "1.0","strength_time": "17:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
164 },
165 {"doctype": "Prescription Dosage", "name": "TID", "dosage": "TID","dosage_strength":
166 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "14:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
167 },
168 {"doctype": "Prescription Dosage", "name": "BID", "dosage": "BID","dosage_strength":
169 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "21:00:00"}]
170 },
171 {"doctype": "Prescription Dosage", "name": "Once Daily", "dosage": "Once Daily","dosage_strength":
172 [{"strength": "1.0","strength_time": "9:00:00"}]
173 }
174 ]
175 insert_record(records)
176
177def create_healthcare_item_groups():
178 records = [
179 {'doctype': 'Item Group', 'item_group_name': _('Laboratory'),
180 'is_group': 0, 'parent_item_group': _('All Item Groups') },
181 {'doctype': 'Item Group', 'item_group_name': _('Drug'),
182 'is_group': 0, 'parent_item_group': _('All Item Groups') }
183 ]
184 insert_record(records)
185
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530186def create_sensitivity():
187 records = [
mbauskaree9da672017-10-10 12:15:48 +0530188 {"doctype": "Sensitivity", "sensitivity": _("Low Sensitivity")},
189 {"doctype": "Sensitivity", "sensitivity": _("High Sensitivity")},
190 {"doctype": "Sensitivity", "sensitivity": _("Moderate Sensitivity")},
191 {"doctype": "Sensitivity", "sensitivity": _("Susceptible")},
192 {"doctype": "Sensitivity", "sensitivity": _("Resistant")},
193 {"doctype": "Sensitivity", "sensitivity": _("Intermediate")}
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530194 ]
195 insert_record(records)
Jamsheer0cde6ae2018-05-16 10:54:00 +0530196
197def add_healthcare_service_unit_tree_root():
198 record = [
Rucha Mahabalc52bbd72020-05-26 17:54:46 +0530199 {
200 "doctype": "Healthcare Service Unit",
201 "healthcare_service_unit_name": "All Healthcare Service Units",
202 "is_group": 1,
203 "company": get_company()
204 }
Jamsheer0cde6ae2018-05-16 10:54:00 +0530205 ]
206 insert_record(record)
Rucha Mahabalc52bbd72020-05-26 17:54:46 +0530207
208def get_company():
209 company = frappe.defaults.get_defaults().company
210 if company:
211 return company
212 else:
213 company = frappe.get_list("Company", limit=1)
214 if company:
215 return company[0].name
216 return None
Rucha Mahabalf3df5c92020-11-30 12:16:28 +0530217
218def setup_patient_history_settings():
219 import json
220
221 settings = frappe.get_single('Patient History Settings')
222 configuration = get_patient_history_config()
223 for dt, config in configuration.items():
224 settings.append("standard_doctypes", {
225 "document_type": dt,
226 "date_fieldname": config[0],
227 "selected_fields": json.dumps(config[1])
228 })
229 settings.save()
230
231def get_patient_history_config():
232 return {
233 "Patient Encounter": ("encounter_date", [
234 {"label": "Healthcare Practitioner", "fieldname": "practitioner", "fieldtype": "Link"},
235 {"label": "Symptoms", "fieldname": "symptoms", "fieldtype": "Table Multiselect"},
236 {"label": "Diagnosis", "fieldname": "diagnosis", "fieldtype": "Table Multiselect"},
237 {"label": "Drug Prescription", "fieldname": "drug_prescription", "fieldtype": "Table"},
238 {"label": "Lab Tests", "fieldname": "lab_test_prescription", "fieldtype": "Table"},
239 {"label": "Clinical Procedures", "fieldname": "procedure_prescription", "fieldtype": "Table"},
240 {"label": "Therapies", "fieldname": "therapies", "fieldtype": "Table"},
241 {"label": "Review Details", "fieldname": "encounter_comment", "fieldtype": "Small Text"}
242 ]),
243 "Clinical Procedure": ("start_date", [
244 {"label": "Procedure Template", "fieldname": "procedure_template", "fieldtype": "Link"},
245 {"label": "Healthcare Practitioner", "fieldname": "practitioner", "fieldtype": "Link"},
246 {"label": "Notes", "fieldname": "notes", "fieldtype": "Small Text"},
247 {"label": "Service Unit", "fieldname": "service_unit", "fieldtype": "Healthcare Service Unit"},
248 {"label": "Start Time", "fieldname": "start_time", "fieldtype": "Time"},
249 {"label": "Sample", "fieldname": "sample", "fieldtype": "Link"}
250 ]),
251 "Lab Test": ("result_date", [
252 {"label": "Test Template", "fieldname": "template", "fieldtype": "Link"},
253 {"label": "Healthcare Practitioner", "fieldname": "practitioner", "fieldtype": "Link"},
254 {"label": "Test Name", "fieldname": "lab_test_name", "fieldtype": "Data"},
255 {"label": "Lab Technician Name", "fieldname": "employee_name", "fieldtype": "Data"},
256 {"label": "Sample ID", "fieldname": "sample", "fieldtype": "Link"},
257 {"label": "Normal Test Result", "fieldname": "normal_test_items", "fieldtype": "Table"},
258 {"label": "Descriptive Test Result", "fieldname": "descriptive_test_items", "fieldtype": "Table"},
259 {"label": "Organism Test Result", "fieldname": "organism_test_items", "fieldtype": "Table"},
260 {"label": "Sensitivity Test Result", "fieldname": "sensitivity_test_items", "fieldtype": "Table"},
261 {"label": "Comments", "fieldname": "lab_test_comment", "fieldtype": "Table"}
262 ]),
263 "Therapy Session": ("start_date", [
264 {"label": "Therapy Type", "fieldname": "therapy_type", "fieldtype": "Link"},
265 {"label": "Healthcare Practitioner", "fieldname": "practitioner", "fieldtype": "Link"},
266 {"label": "Therapy Plan", "fieldname": "therapy_plan", "fieldtype": "Link"},
267 {"label": "Duration", "fieldname": "duration", "fieldtype": "Int"},
268 {"label": "Location", "fieldname": "location", "fieldtype": "Link"},
269 {"label": "Healthcare Service Unit", "fieldname": "service_unit", "fieldtype": "Link"},
270 {"label": "Start Time", "fieldname": "start_time", "fieldtype": "Time"},
271 {"label": "Exercises", "fieldname": "exercises", "fieldtype": "Table"},
272 {"label": "Total Counts Targeted", "fieldname": "total_counts_targeted", "fieldtype": "Int"},
273 {"label": "Total Counts Completed", "fieldname": "total_counts_completed", "fieldtype": "Int"}
274 ]),
275 "Vital Signs": ("signs_date", [
276 {"label": "Body Temperature", "fieldname": "temperature", "fieldtype": "Data"},
277 {"label": "Heart Rate / Pulse", "fieldname": "pulse", "fieldtype": "Data"},
278 {"label": "Respiratory rate", "fieldname": "respiratory_rate", "fieldtype": "Data"},
279 {"label": "Tongue", "fieldname": "tongue", "fieldtype": "Select"},
280 {"label": "Abdomen", "fieldname": "abdomen", "fieldtype": "Select"},
281 {"label": "Reflexes", "fieldname": "reflexes", "fieldtype": "Select"},
282 {"label": "Blood Pressure", "fieldname": "bp", "fieldtype": "Data"},
283 {"label": "Notes", "fieldname": "vital_signs_note", "fieldtype": "Small Text"},
284 {"label": "Height (In Meter)", "fieldname": "height", "fieldtype": "Float"},
285 {"label": "Weight (In Kilogram)", "fieldname": "weight", "fieldtype": "Float"},
286 {"label": "BMI", "fieldname": "bmi", "fieldtype": "Float"}
287 ]),
288 "Inpatient Medication Order": ("start_date", [
289 {"label": "Healthcare Practitioner", "fieldname": "practitioner", "fieldtype": "Link"},
290 {"label": "Start Date", "fieldname": "start_date", "fieldtype": "Date"},
291 {"label": "End Date", "fieldname": "end_date", "fieldtype": "Date"},
292 {"label": "Medication Orders", "fieldname": "medication_orders", "fieldtype": "Table"},
293 {"label": "Total Orders", "fieldname": "total_orders", "fieldtype": "Float"}
294 ])
295 }