blob: 69a92b348ba9880a427d63a10099ecb90eec9188 [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 _
5
6def setup_healthcare():
Rushabh Mehtabc4e2cd2017-10-17 12:30:34 +05307 if frappe.db.exists('Medical Department', 'Cardiology'):
8 # already setup
9 return
Rushabh Mehtaf0569742017-09-13 12:52:30 +053010 create_medical_departments()
11 create_antibiotics()
12 create_test_uom()
13 create_duration()
14 create_dosage()
15 create_healthcare_item_groups()
16 create_lab_test_items()
17 create_lab_test_template()
18 create_sensitivity()
Rushabh Mehtaf0569742017-09-13 12:52:30 +053019
20def create_medical_departments():
mbauskaree9da672017-10-10 12:15:48 +053021 departments = [
22 "Accident And Emergency Care" ,"Anaesthetics", "Biochemistry", "Cardiology", "Dermatology",
23 "Diagnostic Imaging", "ENT", "Gastroenterology", "General Surgery", "Gynaecology",
24 "Haematology", "Maternity", "Microbiology", "Nephrology", "Neurology", "Oncology",
25 "Orthopaedics", "Pathology", "Physiotherapy", "Rheumatology", "Serology", "Urology"
26 ]
27 for department in departments:
Rushabh Mehtaf0569742017-09-13 12:52:30 +053028 mediacal_department = frappe.new_doc("Medical Department")
mbauskaree9da672017-10-10 12:15:48 +053029 mediacal_department.department = _(department)
Rushabh Mehtaf0569742017-09-13 12:52:30 +053030 try:
31 mediacal_department.save()
32 except frappe.DuplicateEntryError:
33 pass
34
35def create_antibiotics():
mbauskaree9da672017-10-10 12:15:48 +053036 abt = [
37 "Amoxicillin", "Ampicillin", "Bacampicillin", "Carbenicillin", "Cloxacillin", "Dicloxacillin",
38 "Flucloxacillin", "Mezlocillin", "Nafcillin", "Oxacillin", "Penicillin G", "Penicillin V",
39 "Piperacillin", "Pivampicillin", "Pivmecillinam", "Ticarcillin", "Cefacetrile (cephacetrile)",
40 "Cefadroxil (cefadroxyl)", "Cefalexin (cephalexin)", "Cefaloglycin (cephaloglycin)",
41 "Cefalonium (cephalonium)", "Cefaloridine (cephaloradine)", "Cefalotin (cephalothin)",
42 "Cefapirin (cephapirin)", "Cefatrizine", "Cefazaflur", "Cefazedone", "Cefazolin (cephazolin)",
43 "Cefradine (cephradine)", "Cefroxadine", "Ceftezole", "Cefaclor", "Cefamandole", "Cefmetazole",
44 "Cefonicid", "Cefotetan", "Cefoxitin", "Cefprozil (cefproxil)", "Cefuroxime", "Cefuzonam",
45 "Cefcapene", "Cefdaloxime", "Cefdinir", "Cefditoren", "Cefetamet", "Cefixime", "Cefmenoxime",
46 "Cefodizime", "Cefotaxime", "Cefpimizole", "Cefpodoxime", "Cefteram", "Ceftibuten", "Ceftiofur",
47 "Ceftiolene", "Ceftizoxime", "Ceftriaxone", "Cefoperazone", "Ceftazidime", "Cefclidine", "Cefepime",
48 "Cefluprenam", "Cefoselis", "Cefozopran", "Cefpirome", "Cefquinome", "Ceftobiprole", "Ceftaroline",
49 "Cefaclomezine","Cefaloram", "Cefaparole", "Cefcanel", "Cefedrolor", "Cefempidone", "Cefetrizole",
50 "Cefivitril", "Cefmatilen", "Cefmepidium", "Cefovecin", "Cefoxazole", "Cefrotil", "Cefsumide",
51 "Cefuracetime", "Ceftioxide", "Ceftazidime/Avibactam", "Ceftolozane/Tazobactam", "Aztreonam",
52 "Imipenem", "Imipenem/cilastatin", "Doripenem", "Meropenem", "Ertapenem", "Azithromycin",
53 "Erythromycin", "Clarithromycin", "Dirithromycin", "Roxithromycin", "Telithromycin", "Clindamycin",
54 "Lincomycin", "Pristinamycin", "Quinupristin/dalfopristin", "Amikacin", "Gentamicin", "Kanamycin",
55 "Neomycin", "Netilmicin", "Paromomycin", "Streptomycin", "Tobramycin", "Flumequine", "Nalidixic acid",
56 "Oxolinic acid", "Piromidic acid", "Pipemidic acid", "Rosoxacin", "Ciprofloxacin", "Enoxacin",
57 "Lomefloxacin", "Nadifloxacin", "Norfloxacin", "Ofloxacin", "Pefloxacin", "Rufloxacin", "Balofloxacin",
58 "Gatifloxacin", "Grepafloxacin", "Levofloxacin", "Moxifloxacin", "Pazufloxacin", "Sparfloxacin",
59 "Temafloxacin", "Tosufloxacin", "Besifloxacin", "Clinafloxacin", "Gemifloxacin",
60 "Sitafloxacin", "Trovafloxacin", "Prulifloxacin", "Sulfamethizole", "Sulfamethoxazole",
61 "Sulfisoxazole", "Trimethoprim-Sulfamethoxazole", "Demeclocycline", "Doxycycline", "Minocycline",
62 "Oxytetracycline", "Tetracycline", "Tigecycline", "Chloramphenicol", "Metronidazole",
63 "Tinidazole", "Nitrofurantoin", "Vancomycin", "Teicoplanin", "Telavancin", "Linezolid",
64 "Cycloserine 2", "Rifampin", "Rifabutin", "Rifapentine", "Rifalazil", "Bacitracin", "Polymyxin B",
65 "Viomycin", "Capreomycin"
66 ]
67
Rushabh Mehtaf0569742017-09-13 12:52:30 +053068 for a in abt:
69 antibiotic = frappe.new_doc("Antibiotic")
70 antibiotic.antibiotic_name = a
71 try:
72 antibiotic.save()
73 except frappe.DuplicateEntryError:
74 pass
75
76def create_test_uom():
77 records = [
78 {"doctype": "Lab Test UOM", "name": "umol/L", "test_uom": "umol/L", "uom_description": None },
79 {"doctype": "Lab Test UOM", "name": "mg/L", "test_uom": "mg/L", "uom_description": None },
80 {"doctype": "Lab Test UOM", "name": "mg / dl", "test_uom": "mg / dl", "uom_description": None },
81 {"doctype": "Lab Test UOM", "name": "pg / ml", "test_uom": "pg / ml", "uom_description": None },
82 {"doctype": "Lab Test UOM", "name": "U/ml", "test_uom": "U/ml", "uom_description": None },
83 {"doctype": "Lab Test UOM", "name": "/HPF", "test_uom": "/HPF", "uom_description": None },
84 {"doctype": "Lab Test UOM", "name": "Million Cells / cumm", "test_uom": "Million Cells / cumm", "uom_description": None },
85 {"doctype": "Lab Test UOM", "name": "Lakhs Cells / cumm", "test_uom": "Lakhs Cells / cumm", "uom_description": None },
86 {"doctype": "Lab Test UOM", "name": "U / L", "test_uom": "U / L", "uom_description": None },
87 {"doctype": "Lab Test UOM", "name": "g / L", "test_uom": "g / L", "uom_description": None },
88 {"doctype": "Lab Test UOM", "name": "IU / ml", "test_uom": "IU / ml", "uom_description": None },
89 {"doctype": "Lab Test UOM", "name": "gm %", "test_uom": "gm %", "uom_description": None },
90 {"doctype": "Lab Test UOM", "name": "Microgram", "test_uom": "Microgram", "uom_description": None },
91 {"doctype": "Lab Test UOM", "name": "Micron", "test_uom": "Micron", "uom_description": None },
92 {"doctype": "Lab Test UOM", "name": "Cells / cumm", "test_uom": "Cells / cumm", "uom_description": None },
93 {"doctype": "Lab Test UOM", "name": "%", "test_uom": "%", "uom_description": None },
94 {"doctype": "Lab Test UOM", "name": "mm / dl", "test_uom": "mm / dl", "uom_description": None },
95 {"doctype": "Lab Test UOM", "name": "mm / hr", "test_uom": "mm / hr", "uom_description": None },
96 {"doctype": "Lab Test UOM", "name": "ulU / ml", "test_uom": "ulU / ml", "uom_description": None },
97 {"doctype": "Lab Test UOM", "name": "ng / ml", "test_uom": "ng / ml", "uom_description": None },
98 {"doctype": "Lab Test UOM", "name": "ng / dl", "test_uom": "ng / dl", "uom_description": None },
99 {"doctype": "Lab Test UOM", "name": "ug / dl", "test_uom": "ug / dl", "uom_description": None }
100 ]
101
102 insert_record(records)
103
104def create_duration():
105 records = [
106 {"doctype": "Prescription Duration", "name": "3 Month", "number": "3", "period": "Month" },
107 {"doctype": "Prescription Duration", "name": "2 Month", "number": "2", "period": "Month" },
108 {"doctype": "Prescription Duration", "name": "1 Month", "number": "1", "period": "Month" },
109 {"doctype": "Prescription Duration", "name": "12 Hour", "number": "12", "period": "Hour" },
110 {"doctype": "Prescription Duration", "name": "11 Hour", "number": "11", "period": "Hour" },
111 {"doctype": "Prescription Duration", "name": "10 Hour", "number": "10", "period": "Hour" },
112 {"doctype": "Prescription Duration", "name": "9 Hour", "number": "9", "period": "Hour" },
113 {"doctype": "Prescription Duration", "name": "8 Hour", "number": "8", "period": "Hour" },
114 {"doctype": "Prescription Duration", "name": "7 Hour", "number": "7", "period": "Hour" },
115 {"doctype": "Prescription Duration", "name": "6 Hour", "number": "6", "period": "Hour" },
116 {"doctype": "Prescription Duration", "name": "5 Hour", "number": "5", "period": "Hour" },
117 {"doctype": "Prescription Duration", "name": "4 Hour", "number": "4", "period": "Hour" },
118 {"doctype": "Prescription Duration", "name": "3 Hour", "number": "3", "period": "Hour" },
119 {"doctype": "Prescription Duration", "name": "2 Hour", "number": "2", "period": "Hour" },
120 {"doctype": "Prescription Duration", "name": "1 Hour", "number": "1", "period": "Hour" },
121 {"doctype": "Prescription Duration", "name": "5 Week", "number": "5", "period": "Week" },
122 {"doctype": "Prescription Duration", "name": "4 Week", "number": "4", "period": "Week" },
123 {"doctype": "Prescription Duration", "name": "3 Week", "number": "3", "period": "Week" },
124 {"doctype": "Prescription Duration", "name": "2 Week", "number": "2", "period": "Week" },
125 {"doctype": "Prescription Duration", "name": "1 Week", "number": "1", "period": "Week" },
126 {"doctype": "Prescription Duration", "name": "6 Day", "number": "6", "period": "Day" },
127 {"doctype": "Prescription Duration", "name": "5 Day", "number": "5", "period": "Day" },
128 {"doctype": "Prescription Duration", "name": "4 Day", "number": "4", "period": "Day" },
129 {"doctype": "Prescription Duration", "name": "3 Day", "number": "3", "period": "Day" },
130 {"doctype": "Prescription Duration", "name": "2 Day", "number": "2", "period": "Day" },
131 {"doctype": "Prescription Duration", "name": "1 Day", "number": "1", "period": "Day" }
132 ]
133 insert_record(records)
134
135def create_dosage():
136 records = [
137 {"doctype": "Prescription Dosage", "name": "1-1-1-1", "dosage": "1-1-1-1","dosage_strength":
138 [{"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"}]
139 },
140 {"doctype": "Prescription Dosage", "name": "0-0-1", "dosage": "0-0-1","dosage_strength":
141 [{"strength": "1.0","strength_time": "21:00:00"}]
142 },
143 {"doctype": "Prescription Dosage", "name": "1-0-0", "dosage": "1-0-0","dosage_strength":
144 [{"strength": "1.0","strength_time": "9:00:00"}]
145 },
146 {"doctype": "Prescription Dosage", "name": "0-1-0", "dosage": "0-1-0","dosage_strength":
147 [{"strength": "1.0","strength_time": "14:00:00"}]
148 },
149 {"doctype": "Prescription Dosage", "name": "1-1-1", "dosage": "1-1-1","dosage_strength":
150 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "14:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
151 },
152 {"doctype": "Prescription Dosage", "name": "1-0-1", "dosage": "1-0-1","dosage_strength":
153 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "21:00:00"}]
154 },
155 {"doctype": "Prescription Dosage", "name": "Once Bedtime", "dosage": "Once Bedtime","dosage_strength":
156 [{"strength": "1.0","strength_time": "21:00:00"}]
157 },
158 {"doctype": "Prescription Dosage", "name": "5 times a day", "dosage": "5 times a day","dosage_strength":
159 [{"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"}]
160 },
161 {"doctype": "Prescription Dosage", "name": "QID", "dosage": "QID","dosage_strength":
162 [{"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"}]
163 },
164 {"doctype": "Prescription Dosage", "name": "TID", "dosage": "TID","dosage_strength":
165 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "14:00:00"},{"strength": "1.0","strength_time": "21:00:00"}]
166 },
167 {"doctype": "Prescription Dosage", "name": "BID", "dosage": "BID","dosage_strength":
168 [{"strength": "1.0","strength_time": "9:00:00"}, {"strength": "1.0","strength_time": "21:00:00"}]
169 },
170 {"doctype": "Prescription Dosage", "name": "Once Daily", "dosage": "Once Daily","dosage_strength":
171 [{"strength": "1.0","strength_time": "9:00:00"}]
172 }
173 ]
174 insert_record(records)
175
176def create_healthcare_item_groups():
177 records = [
178 {'doctype': 'Item Group', 'item_group_name': _('Laboratory'),
179 'is_group': 0, 'parent_item_group': _('All Item Groups') },
180 {'doctype': 'Item Group', 'item_group_name': _('Drug'),
181 'is_group': 0, 'parent_item_group': _('All Item Groups') }
182 ]
183 insert_record(records)
184
185def create_lab_test_items():
186 records = [
mbauskaree9da672017-10-10 12:15:48 +0530187 {"doctype": "Item", "item_code": "MCH", "item_name": "MCH", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530188 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530189 {"doctype": "Item", "item_code": "LDL", "item_name": "LDL", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530190 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530191 {"doctype": "Item", "item_code": "GTT", "item_name": "GTT", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530192 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530193 {"doctype": "Item", "item_code": "HDL", "item_name": "HDL", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530194 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530195 {"doctype": "Item", "item_code": "BILT", "item_name": "BILT", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530196 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530197 {"doctype": "Item", "item_code": "BILD", "item_name": "BILD", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530198 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530199 {"doctype": "Item", "item_code": "BP", "item_name": "BP", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530200 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1},
mbauskaree9da672017-10-10 12:15:48 +0530201 {"doctype": "Item", "item_code": "BS", "item_name": "BS", "item_group": _("Laboratory"),
Rushabh Mehtab9fe1462017-09-30 10:46:29 +0530202 "stock_uom": _("Unit"), "is_stock_item": 0, "is_purchase_item": 0, "is_sales_item": 1}
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530203 ]
204 insert_record(records)
205
206def create_lab_test_template():
207 records = [
208 {"doctype": "Lab Test Template", "name": "MCH","test_name": "MCH","test_code": "MCH",
mbauskaree9da672017-10-10 12:15:48 +0530209 "test_group": _("Laboratory"),"department": _("Haematology"),"item": "MCH",
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530210 "test_template_type": "Single","is_billable": 1,"test_rate": 0.0,"test_uom": "Microgram",
211 "test_normal_range": "27 - 32 Microgram",
212 "sensitivity": 0,"test_description": "Mean Corpuscular Hemoglobin"},
213 {"doctype": "Lab Test Template", "name": "LDL","test_name": "LDL (Serum)","test_code": "LDL",
mbauskaree9da672017-10-10 12:15:48 +0530214 "test_group": _("Laboratory"),"department": _("Biochemistry"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530215 "item": "LDL","test_template_type": "Single",
216 "is_billable": 1,"test_rate": 0.0,"test_uom": "mg / dl","test_normal_range": "70 - 160 mg/dlLow-density Lipoprotein (LDL)",
217 "sensitivity": 0,"test_description": "Low-density Lipoprotein (LDL)"},
218 {"doctype": "Lab Test Template", "name": "GTT","test_name": "GTT","test_code": "GTT",
mbauskaree9da672017-10-10 12:15:48 +0530219 "test_group": _("Laboratory"),"department": _("Haematology"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530220 "item": "GTT","test_template_type": "Single",
221 "is_billable": 1,"test_rate": 0.0,"test_uom": "mg / dl","test_normal_range": "Less than 85 mg/dl",
222 "sensitivity": 0,"test_description": "Glucose Tolerance Test"},
223 {"doctype": "Lab Test Template", "name": "HDL","test_name": "HDL (Serum)","test_code": "HDL",
mbauskaree9da672017-10-10 12:15:48 +0530224 "test_group": _("Laboratory"),"department": _("Biochemistry"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530225 "item": "HDL","test_template_type": "Single",
226 "is_billable": 1,"test_rate": 0.0,"test_uom": "mg / dl","test_normal_range": "35 - 65 mg/dl",
227 "sensitivity": 0,"test_description": "High-density Lipoprotein (HDL)"},
228 {"doctype": "Lab Test Template", "name": "BILT","test_name": "Bilirubin Total","test_code": "BILT",
mbauskaree9da672017-10-10 12:15:48 +0530229 "test_group": _("Laboratory"),"department": _("Biochemistry"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530230 "item": "BILT","test_template_type": "Single",
231 "is_billable": 1,"test_rate": 0.0,"test_uom": "mg / dl","test_normal_range": "0.2 - 1.2 mg / dl",
232 "sensitivity": 0,"test_description": "Bilirubin Total"},
233 {"doctype": "Lab Test Template", "name": "BILD","test_name": "Bilirubin Direct","test_code": "BILD",
mbauskaree9da672017-10-10 12:15:48 +0530234 "test_group": _("Laboratory"),"department": _("Biochemistry"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530235 "item": "BILD","test_template_type": "Single",
236 "is_billable": 1,"test_rate": 0.0,"test_uom": "mg / dl","test_normal_range": "0.4 mg / dl",
237 "sensitivity": 0,"test_description": "Bilirubin Direct"},
238
239 {"doctype": "Lab Test Template", "name": "BP","test_name": "Bile Pigment","test_code": "BP",
mbauskaree9da672017-10-10 12:15:48 +0530240 "test_group": _("Laboratory"),"department": _("Pathology"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530241 "item": "BP","test_template_type": "Single",
242 "is_billable": 1,"test_rate": 0.0,"test_uom": "","test_normal_range": "",
243 "sensitivity": 0,"test_description": "Bile Pigment"},
244 {"doctype": "Lab Test Template", "name": "BS","test_name": "Bile Salt","test_code": "BS",
mbauskaree9da672017-10-10 12:15:48 +0530245 "test_group": _("Laboratory"),"department": _("Pathology"),
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530246 "item": "BS","test_template_type": "Single",
247 "is_billable": 1,"test_rate": 0.0,"test_uom": "","test_normal_range": "",
248 "sensitivity": 0,"test_description": "Bile Salt"}
249 ]
250 insert_record(records)
251
252def create_sensitivity():
253 records = [
mbauskaree9da672017-10-10 12:15:48 +0530254 {"doctype": "Sensitivity", "sensitivity": _("Low Sensitivity")},
255 {"doctype": "Sensitivity", "sensitivity": _("High Sensitivity")},
256 {"doctype": "Sensitivity", "sensitivity": _("Moderate Sensitivity")},
257 {"doctype": "Sensitivity", "sensitivity": _("Susceptible")},
258 {"doctype": "Sensitivity", "sensitivity": _("Resistant")},
259 {"doctype": "Sensitivity", "sensitivity": _("Intermediate")}
Rushabh Mehtaf0569742017-09-13 12:52:30 +0530260 ]
261 insert_record(records)
262
263def insert_record(records):
264 for r in records:
265 doc = frappe.new_doc(r.get("doctype"))
266 doc.update(r)
267 try:
268 doc.insert(ignore_permissions=True)
269 except frappe.DuplicateEntryError, e:
270 # pass DuplicateEntryError and continue
271 if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
272 # make sure DuplicateEntryError is for the exact same doc and not a related doc
273 pass
274 else:
275 raise