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