Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 1 | from __future__ import unicode_literals |
| 2 | import frappe |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 3 | |
| 4 | from frappe import _ |
Manas Solanki | 966f141 | 2017-11-23 15:22:10 +0530 | [diff] [blame] | 5 | from erpnext.setup.utils import insert_record |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 6 | |
| 7 | def setup_healthcare(): |
Rushabh Mehta | bc4e2cd | 2017-10-17 12:30:34 +0530 | [diff] [blame] | 8 | if frappe.db.exists('Medical Department', 'Cardiology'): |
| 9 | # already setup |
| 10 | return |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 11 | create_medical_departments() |
| 12 | create_antibiotics() |
Jamsheer | c07e8e5 | 2018-09-18 10:54:03 +0530 | [diff] [blame] | 13 | create_lab_test_uom() |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 14 | create_duration() |
| 15 | create_dosage() |
| 16 | create_healthcare_item_groups() |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 17 | create_sensitivity() |
Jamsheer | 0cde6ae | 2018-05-16 10:54:00 +0530 | [diff] [blame] | 18 | add_healthcare_service_unit_tree_root() |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 19 | |
| 20 | def create_medical_departments(): |
mbauskar | ee9da67 | 2017-10-10 12:15:48 +0530 | [diff] [blame] | 21 | 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 Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 28 | mediacal_department = frappe.new_doc("Medical Department") |
mbauskar | ee9da67 | 2017-10-10 12:15:48 +0530 | [diff] [blame] | 29 | mediacal_department.department = _(department) |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 30 | try: |
| 31 | mediacal_department.save() |
| 32 | except frappe.DuplicateEntryError: |
| 33 | pass |
| 34 | |
| 35 | def create_antibiotics(): |
mbauskar | ee9da67 | 2017-10-10 12:15:48 +0530 | [diff] [blame] | 36 | 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 Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 68 | 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 | |
Jamsheer | c07e8e5 | 2018-09-18 10:54:03 +0530 | [diff] [blame] | 76 | def create_lab_test_uom(): |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 77 | records = [ |
Jamsheer | c07e8e5 | 2018-09-18 10:54:03 +0530 | [diff] [blame] | 78 | {"doctype": "Lab Test UOM", "name": "umol/L", "lab_test_uom": "umol/L", "uom_description": None }, |
| 79 | {"doctype": "Lab Test UOM", "name": "mg/L", "lab_test_uom": "mg/L", "uom_description": None }, |
| 80 | {"doctype": "Lab Test UOM", "name": "mg / dl", "lab_test_uom": "mg / dl", "uom_description": None }, |
| 81 | {"doctype": "Lab Test UOM", "name": "pg / ml", "lab_test_uom": "pg / ml", "uom_description": None }, |
| 82 | {"doctype": "Lab Test UOM", "name": "U/ml", "lab_test_uom": "U/ml", "uom_description": None }, |
| 83 | {"doctype": "Lab Test UOM", "name": "/HPF", "lab_test_uom": "/HPF", "uom_description": None }, |
| 84 | {"doctype": "Lab Test UOM", "name": "Million Cells / cumm", "lab_test_uom": "Million Cells / cumm", "uom_description": None }, |
| 85 | {"doctype": "Lab Test UOM", "name": "Lakhs Cells / cumm", "lab_test_uom": "Lakhs Cells / cumm", "uom_description": None }, |
| 86 | {"doctype": "Lab Test UOM", "name": "U / L", "lab_test_uom": "U / L", "uom_description": None }, |
| 87 | {"doctype": "Lab Test UOM", "name": "g / L", "lab_test_uom": "g / L", "uom_description": None }, |
| 88 | {"doctype": "Lab Test UOM", "name": "IU / ml", "lab_test_uom": "IU / ml", "uom_description": None }, |
| 89 | {"doctype": "Lab Test UOM", "name": "gm %", "lab_test_uom": "gm %", "uom_description": None }, |
| 90 | {"doctype": "Lab Test UOM", "name": "Microgram", "lab_test_uom": "Microgram", "uom_description": None }, |
| 91 | {"doctype": "Lab Test UOM", "name": "Micron", "lab_test_uom": "Micron", "uom_description": None }, |
| 92 | {"doctype": "Lab Test UOM", "name": "Cells / cumm", "lab_test_uom": "Cells / cumm", "uom_description": None }, |
| 93 | {"doctype": "Lab Test UOM", "name": "%", "lab_test_uom": "%", "uom_description": None }, |
| 94 | {"doctype": "Lab Test UOM", "name": "mm / dl", "lab_test_uom": "mm / dl", "uom_description": None }, |
| 95 | {"doctype": "Lab Test UOM", "name": "mm / hr", "lab_test_uom": "mm / hr", "uom_description": None }, |
| 96 | {"doctype": "Lab Test UOM", "name": "ulU / ml", "lab_test_uom": "ulU / ml", "uom_description": None }, |
| 97 | {"doctype": "Lab Test UOM", "name": "ng / ml", "lab_test_uom": "ng / ml", "uom_description": None }, |
| 98 | {"doctype": "Lab Test UOM", "name": "ng / dl", "lab_test_uom": "ng / dl", "uom_description": None }, |
| 99 | {"doctype": "Lab Test UOM", "name": "ug / dl", "lab_test_uom": "ug / dl", "uom_description": None } |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 100 | ] |
| 101 | |
| 102 | insert_record(records) |
| 103 | |
| 104 | def 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 | |
| 135 | def 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 | |
| 176 | def 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 | |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 185 | def create_sensitivity(): |
| 186 | records = [ |
mbauskar | ee9da67 | 2017-10-10 12:15:48 +0530 | [diff] [blame] | 187 | {"doctype": "Sensitivity", "sensitivity": _("Low Sensitivity")}, |
| 188 | {"doctype": "Sensitivity", "sensitivity": _("High Sensitivity")}, |
| 189 | {"doctype": "Sensitivity", "sensitivity": _("Moderate Sensitivity")}, |
| 190 | {"doctype": "Sensitivity", "sensitivity": _("Susceptible")}, |
| 191 | {"doctype": "Sensitivity", "sensitivity": _("Resistant")}, |
| 192 | {"doctype": "Sensitivity", "sensitivity": _("Intermediate")} |
Rushabh Mehta | f056974 | 2017-09-13 12:52:30 +0530 | [diff] [blame] | 193 | ] |
| 194 | insert_record(records) |
Jamsheer | 0cde6ae | 2018-05-16 10:54:00 +0530 | [diff] [blame] | 195 | |
| 196 | def add_healthcare_service_unit_tree_root(): |
| 197 | record = [ |
Rucha Mahabal | c52bbd7 | 2020-05-26 17:54:46 +0530 | [diff] [blame] | 198 | { |
| 199 | "doctype": "Healthcare Service Unit", |
| 200 | "healthcare_service_unit_name": "All Healthcare Service Units", |
| 201 | "is_group": 1, |
| 202 | "company": get_company() |
| 203 | } |
Jamsheer | 0cde6ae | 2018-05-16 10:54:00 +0530 | [diff] [blame] | 204 | ] |
| 205 | insert_record(record) |
Rucha Mahabal | c52bbd7 | 2020-05-26 17:54:46 +0530 | [diff] [blame] | 206 | |
| 207 | def get_company(): |
| 208 | company = frappe.defaults.get_defaults().company |
| 209 | if company: |
| 210 | return company |
| 211 | else: |
| 212 | company = frappe.get_list("Company", limit=1) |
| 213 | if company: |
| 214 | return company[0].name |
| 215 | return None |