Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | # Copyright (c) 2018, earthians and contributors |
| 3 | # For license information, please see license.txt |
| 4 | |
| 5 | from __future__ import unicode_literals |
| 6 | import frappe |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 7 | from frappe import _ |
Jamsheer | 25dda3a | 2018-07-30 14:50:16 +0530 | [diff] [blame] | 8 | import math |
Rucha Mahabal | 197165f | 2020-03-26 17:29:50 +0530 | [diff] [blame] | 9 | from frappe.utils import time_diff_in_hours, rounded |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 10 | from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_income_account |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 11 | from erpnext.healthcare.doctype.fee_validity.fee_validity import create_fee_validity |
Jamsheer | 0ae100b | 2018-08-01 14:29:43 +0530 | [diff] [blame] | 12 | from erpnext.healthcare.doctype.lab_test.lab_test import create_multiple |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 13 | |
| 14 | @frappe.whitelist() |
| 15 | def get_healthcare_services_to_invoice(patient): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 16 | patient = frappe.get_doc('Patient', patient) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 17 | if patient: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 18 | validate_customer_created(patient) |
| 19 | items_to_invoice = [] |
| 20 | patient_appointments = frappe.get_list( |
| 21 | 'Patient Appointment', |
| 22 | fields='*', |
Rucha Mahabal | 2d785b7 | 2020-03-17 20:18:16 +0530 | [diff] [blame] | 23 | filters={'patient': patient.name, 'invoiced': 0}, |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 24 | order_by='appointment_date' |
| 25 | ) |
| 26 | if patient_appointments: |
| 27 | items_to_invoice = get_fee_validity(patient_appointments) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 28 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 29 | encounters = get_encounters_to_invoice(patient) |
| 30 | lab_tests = get_lab_tests_to_invoice(patient) |
| 31 | clinical_procedures = get_clinical_procedures_to_invoice(patient) |
| 32 | inpatient_services = get_inpatient_services_to_invoice(patient) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 33 | |
Rucha Mahabal | 2d785b7 | 2020-03-17 20:18:16 +0530 | [diff] [blame] | 34 | items_to_invoice += encounters + lab_tests + clinical_procedures + inpatient_services |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 35 | return items_to_invoice |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 36 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 37 | def validate_customer_created(patient): |
| 38 | if not frappe.db.get_value('Patient', patient.name, 'customer'): |
| 39 | msg = _("Please set a Customer linked to the Patient") |
| 40 | msg += " <b><a href='#Form/Patient/{0}'>{0}</a></b>".format(patient.name) |
| 41 | frappe.throw(msg, title=_('Customer Not Found')) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 42 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 43 | def get_fee_validity(patient_appointments): |
Rucha Mahabal | f2574dd | 2020-03-17 19:28:18 +0530 | [diff] [blame] | 44 | if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'): |
| 45 | return |
| 46 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 47 | items_to_invoice = [] |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 48 | for appointment in patient_appointments: |
| 49 | if appointment.procedure_template: |
| 50 | if frappe.db.get_value('Clinical Procedure Template', appointment.procedure_template, 'is_billable'): |
| 51 | items_to_invoice.append({ |
| 52 | 'reference_type': 'Patient Appointment', |
| 53 | 'reference_name': appointment.name, |
| 54 | 'service': appointment.procedure_template |
| 55 | }) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 56 | else: |
Rucha Mahabal | 2d785b7 | 2020-03-17 20:18:16 +0530 | [diff] [blame] | 57 | fee_validity = frappe.db.exists('Fee Validity Reference', {'appointment': appointment.name}) |
| 58 | if not fee_validity: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 59 | practitioner_charge = 0 |
| 60 | income_account = None |
| 61 | service_item = None |
| 62 | if appointment.practitioner: |
| 63 | service_item, practitioner_charge = get_service_item_and_practitioner_charge(appointment) |
| 64 | income_account = get_income_account(appointment.practitioner, appointment.company) |
Rucha Mahabal | 2d785b7 | 2020-03-17 20:18:16 +0530 | [diff] [blame] | 65 | items_to_invoice.append({ |
| 66 | 'reference_type': 'Patient Appointment', |
| 67 | 'reference_name': appointment.name, |
| 68 | 'service': service_item, |
| 69 | 'rate': practitioner_charge, |
| 70 | 'income_account': income_account |
| 71 | }) |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 72 | |
| 73 | return items_to_invoice |
| 74 | |
| 75 | |
| 76 | def get_encounters_to_invoice(patient): |
| 77 | encounters_to_invoice = [] |
| 78 | encounters = frappe.get_list( |
| 79 | 'Patient Encounter', |
| 80 | fields=['*'], |
| 81 | filters={'patient': patient.name, 'invoiced': False, 'docstatus': 1} |
| 82 | ) |
| 83 | if encounters: |
| 84 | for encounter in encounters: |
| 85 | if not encounter.appointment: |
| 86 | practitioner_charge = 0 |
| 87 | income_account = None |
| 88 | service_item = None |
| 89 | if encounter.practitioner: |
| 90 | service_item, practitioner_charge = get_service_item_and_practitioner_charge(encounter) |
| 91 | income_account = get_income_account(encounter.practitioner, encounter.company) |
| 92 | |
| 93 | encounters_to_invoice.append({ |
| 94 | 'reference_type': 'Patient Encounter', |
| 95 | 'reference_name': encounter.name, |
| 96 | 'service': service_item, |
| 97 | 'rate': practitioner_charge, |
| 98 | 'income_account': income_account |
| 99 | }) |
| 100 | |
| 101 | return encounters_to_invoice |
| 102 | |
| 103 | |
| 104 | def get_lab_tests_to_invoice(patient): |
| 105 | lab_tests_to_invoice = [] |
| 106 | lab_tests = frappe.get_list( |
| 107 | 'Lab Test', |
| 108 | fields=['name', 'template'], |
| 109 | filters={'patient': patient.name, 'invoiced': False, 'docstatus': 1} |
| 110 | ) |
| 111 | for lab_test in lab_tests: |
| 112 | if frappe.db.get_value('Lab Test Template', lab_test.template, 'is_billable'): |
| 113 | lab_tests_to_invoice.append({ |
| 114 | 'reference_type': 'Lab Test', |
| 115 | 'reference_name': lab_test.name, |
| 116 | 'service': frappe.db.get_value('Lab Test Template', lab_test.template, 'item') |
| 117 | }) |
| 118 | |
| 119 | lab_prescriptions = frappe.db.sql('''select lp.name, lp.lab_test_code from `tabPatient Encounter` et, `tabLab Prescription` lp |
| 120 | where et.patient=%s and lp.parent=et.name and lp.lab_test_created=0 and lp.invoiced=0''', (patient.name), as_dict=1) |
| 121 | |
| 122 | for prescription in lab_prescriptions: |
| 123 | if prescription.lab_test_code and frappe.db.get_value('Lab Test Template', prescription.lab_test_code, 'is_billable'): |
| 124 | lab_tests_to_invoice.append({ |
| 125 | 'reference_type': 'Lab Prescription', |
| 126 | 'reference_name': prescription.name, |
| 127 | 'service': frappe.db.get_value('Lab Test Template', prescription.lab_test_code, 'item') |
| 128 | }) |
| 129 | |
| 130 | return lab_tests_to_invoice |
| 131 | |
| 132 | |
| 133 | def get_clinical_procedures_to_invoice(patient): |
| 134 | clinical_procedures_to_invoice = [] |
| 135 | procedures = frappe.get_list( |
| 136 | 'Clinical Procedure', |
| 137 | fields='*', |
| 138 | filters={'patient': patient.name, 'invoiced': False} |
| 139 | ) |
| 140 | for procedure in procedures: |
| 141 | if not procedure.appointment: |
| 142 | if procedure.procedure_template and frappe.db.get_value('Clinical Procedure Template', procedure.procedure_template, 'is_billable'): |
| 143 | clinical_procedures_to_invoice.append({ |
| 144 | 'reference_type': 'Clinical Procedure', |
| 145 | 'reference_name': procedure.name, |
| 146 | 'service': frappe.db.get_value('Clinical Procedure Template', procedure.procedure_template, 'item') |
| 147 | }) |
| 148 | |
| 149 | # consumables |
| 150 | if procedure.invoice_separately_as_consumables and procedure.consume_stock \ |
| 151 | and procedure.status == 'Completed' and not procedure.consumption_invoiced: |
| 152 | |
| 153 | service_item = get_healthcare_service_item('clinical_procedure_consumable_item') |
| 154 | if not service_item: |
| 155 | msg = _('Please Configure Clinical Procedure Consumable Item in ') |
| 156 | msg += '''<b><a href='#Form/Healthcare Settings'>Healthcare Settings</a></b>''' |
| 157 | frappe.throw(msg, title=_('Missing Configuration')) |
| 158 | |
| 159 | clinical_procedures_to_invoice.append({ |
| 160 | 'reference_type': 'Clinical Procedure', |
| 161 | 'reference_name': procedure.name, |
| 162 | 'service': service_item, |
| 163 | 'rate': procedure.consumable_total_amount, |
| 164 | 'description': procedure.consumption_details |
| 165 | }) |
| 166 | |
| 167 | procedure_prescriptions = frappe.db.sql('''select pp.name, pp.procedure from `tabPatient Encounter` et, |
| 168 | `tabProcedure Prescription` pp where et.patient=%s and pp.parent=et.name and |
| 169 | pp.procedure_created=0 and pp.invoiced=0 and pp.appointment_booked=0''', (patient.name), as_dict=1) |
| 170 | |
| 171 | for prescription in procedure_prescriptions: |
| 172 | if frappe.db.get_value('Clinical Procedure Template', prescription.procedure, 'is_billable'): |
Rucha Mahabal | 197165f | 2020-03-26 17:29:50 +0530 | [diff] [blame] | 173 | clinical_procedures_to_invoice.append({ |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 174 | 'reference_type': 'Procedure Prescription', |
| 175 | 'reference_name': prescription.name, |
| 176 | 'service': frappe.db.get_value('Clinical Procedure Template', prescription.procedure, 'item') |
| 177 | }) |
| 178 | |
| 179 | return clinical_procedures_to_invoice |
| 180 | |
| 181 | |
| 182 | def get_inpatient_services_to_invoice(patient): |
| 183 | services_to_invoice = [] |
| 184 | inpatient_services = frappe.db.sql('''select io.* from `tabInpatient Record` ip, |
| 185 | `tabInpatient Occupancy` io where ip.patient=%s and io.parent=ip.name and |
| 186 | io.left=1 and io.invoiced=0''', (patient.name), as_dict=1) |
| 187 | |
| 188 | for inpatient_occupancy in inpatient_services: |
| 189 | service_unit_type = frappe.db.get_value('Healthcare Service Unit', inpatient_occupancy.service_unit, 'service_unit_type') |
| 190 | service_unit_type = frappe.get_doc('Healthcare Service Unit Type', service_unit_type) |
| 191 | if service_unit_type and service_unit_type.is_billable: |
| 192 | hours_occupied = time_diff_in_hours(inpatient_occupancy.check_out, inpatient_occupancy.check_in) |
| 193 | qty = 0.5 |
| 194 | if hours_occupied > 0: |
| 195 | actual_qty = hours_occupied / service_unit_type.no_of_hours |
| 196 | floor = math.floor(actual_qty) |
| 197 | decimal_part = actual_qty - floor |
| 198 | if decimal_part > 0.5: |
| 199 | qty = rounded(floor + 1, 1) |
| 200 | elif decimal_part < 0.5 and decimal_part > 0: |
| 201 | qty = rounded(floor + 0.5, 1) |
| 202 | if qty <= 0: |
| 203 | qty = 0.5 |
| 204 | services_to_invoice.append({ |
| 205 | 'reference_type': 'Inpatient Occupancy', |
| 206 | 'reference_name': inpatient_occupancy.name, |
| 207 | 'service': service_unit_type.item, 'qty': qty |
| 208 | }) |
| 209 | |
| 210 | return services_to_invoice |
| 211 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 212 | |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 213 | def get_service_item_and_practitioner_charge(doc): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 214 | is_inpatient = doc.inpatient_record |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 215 | if is_inpatient: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 216 | service_item = get_practitioner_service_item(doc.practitioner, 'inpatient_visit_charge_item') |
Jamsheer | ee5f9c7 | 2018-07-30 12:42:06 +0530 | [diff] [blame] | 217 | if not service_item: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 218 | service_item = get_healthcare_service_item('inpatient_visit_charge_item') |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 219 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 220 | service_item = get_practitioner_service_item(doc.practitioner, 'op_consulting_charge_item') |
Jamsheer | ee5f9c7 | 2018-07-30 12:42:06 +0530 | [diff] [blame] | 221 | if not service_item: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 222 | service_item = get_healthcare_service_item('op_consulting_charge_item') |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 223 | if not service_item: |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 224 | throw_config_service_item(is_inpatient) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 225 | |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 226 | practitioner_charge = get_practitioner_charge(doc.practitioner, is_inpatient) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 227 | if not practitioner_charge: |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 228 | throw_config_practitioner_charge(is_inpatient, doc.practitioner) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 229 | |
| 230 | return service_item, practitioner_charge |
| 231 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 232 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 233 | def throw_config_service_item(is_inpatient): |
Rucha Mahabal | 4f9a147 | 2020-03-23 10:40:39 +0530 | [diff] [blame] | 234 | service_item_label = 'Out Patient Consulting Charge Item' |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 235 | if is_inpatient: |
Rucha Mahabal | 4f9a147 | 2020-03-23 10:40:39 +0530 | [diff] [blame] | 236 | service_item_label = 'Inpatient Visit Charge Item' |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 237 | |
Rucha Mahabal | 4f9a147 | 2020-03-23 10:40:39 +0530 | [diff] [blame] | 238 | msg = _(('Please Configure {0} in ').format(service_item_label) \ |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 239 | + '''<b><a href='#Form/Healthcare Settings'>Healthcare Settings</a></b>''') |
| 240 | frappe.throw(msg, title=_('Missing Configuration')) |
| 241 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 242 | |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 243 | def throw_config_practitioner_charge(is_inpatient, practitioner): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 244 | charge_name = 'OP Consulting Charge' |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 245 | if is_inpatient: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 246 | charge_name = 'Inpatient Visit Charge' |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 247 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 248 | msg = _(('Please Configure {0} for Healthcare Practitioner').format(charge_name) \ |
| 249 | + ''' <b><a href='#Form/Healthcare Practitioner/{0}'>{0}</a></b>'''.format(practitioner)) |
| 250 | frappe.throw(msg, title=_('Missing Configuration')) |
| 251 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 252 | |
Jamsheer | ee5f9c7 | 2018-07-30 12:42:06 +0530 | [diff] [blame] | 253 | def get_practitioner_service_item(practitioner, service_item_field): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 254 | return frappe.db.get_value('Healthcare Practitioner', practitioner, service_item_field) |
| 255 | |
Jamsheer | ee5f9c7 | 2018-07-30 12:42:06 +0530 | [diff] [blame] | 256 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 257 | def get_healthcare_service_item(service_item_field): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 258 | return frappe.db.get_single_value('Healthcare Settings', service_item_field) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 259 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 260 | |
Rucha Mahabal | 24055e1 | 2020-02-24 19:09:50 +0530 | [diff] [blame] | 261 | def get_practitioner_charge(practitioner, is_inpatient): |
| 262 | if is_inpatient: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 263 | practitioner_charge = frappe.db.get_value('Healthcare Practitioner', practitioner, 'inpatient_visit_charge') |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 264 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 265 | practitioner_charge = frappe.db.get_value('Healthcare Practitioner', practitioner, 'op_consulting_charge') |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 266 | if practitioner_charge: |
| 267 | return practitioner_charge |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 268 | return False |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 269 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 270 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 271 | def manage_invoice_submit_cancel(doc, method): |
| 272 | if doc.items: |
| 273 | for item in doc.items: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 274 | if item.get('reference_dt') and item.get('reference_dn'): |
| 275 | if frappe.get_meta(item.reference_dt).has_field('invoiced'): |
Jamsheer | 146683b | 2018-07-25 11:30:30 +0530 | [diff] [blame] | 276 | set_invoiced(item, method, doc.name) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 277 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 278 | if method=='on_submit' and frappe.db.get_single_value('Healthcare Settings', 'create_lab_test_on_si_submit'): |
| 279 | create_multiple('Sales Invoice', doc.name) |
| 280 | |
Jamsheer | 0ae100b | 2018-08-01 14:29:43 +0530 | [diff] [blame] | 281 | |
Jamsheer | 146683b | 2018-07-25 11:30:30 +0530 | [diff] [blame] | 282 | def set_invoiced(item, method, ref_invoice=None): |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 283 | invoiced = False |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 284 | if method=='on_submit': |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 285 | validate_invoiced_on_submit(item) |
| 286 | invoiced = True |
| 287 | |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 288 | if item.reference_dt == 'Clinical Procedure': |
| 289 | if get_healthcare_service_item('clinical_procedure_consumable_item') == item.item_code: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 290 | frappe.db.set_value(item.reference_dt, item.reference_dn, 'consumption_invoiced', invoiced) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 291 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 292 | frappe.db.set_value(item.reference_dt, item.reference_dn, 'invoiced', invoiced) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 293 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 294 | frappe.db.set_value(item.reference_dt, item.reference_dn, 'invoiced', invoiced) |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 295 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 296 | if item.reference_dt == 'Patient Appointment': |
| 297 | if frappe.db.get_value('Patient Appointment', item.reference_dn, 'procedure_template'): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 298 | dt_from_appointment = 'Clinical Procedure' |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 299 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 300 | dt_from_appointment = 'Patient Encounter' |
Rucha Mahabal | 06d1b04 | 2020-03-12 12:16:23 +0530 | [diff] [blame] | 301 | manage_doc_for_appointment(dt_from_appointment, item.reference_dn, invoiced) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 302 | |
| 303 | elif item.reference_dt == 'Lab Prescription': |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 304 | manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, 'Lab Test', 'lab_test_created') |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 305 | |
| 306 | elif item.reference_dt == 'Procedure Prescription': |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 307 | manage_prescriptions(invoiced, item.reference_dt, item.reference_dn, 'Clinical Procedure', 'procedure_created') |
| 308 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 309 | |
| 310 | def validate_invoiced_on_submit(item): |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 311 | if item.reference_dt == 'Clinical Procedure' and get_healthcare_service_item('clinical_procedure_consumable_item') == item.item_code: |
Rucha Mahabal | 06d1b04 | 2020-03-12 12:16:23 +0530 | [diff] [blame] | 312 | is_invoiced = frappe.db.get_value(item.reference_dt, item.reference_dn, 'consumption_invoiced') |
Jamsheer | 8da6f4e | 2018-07-26 21:03:17 +0530 | [diff] [blame] | 313 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 314 | is_invoiced = frappe.db.get_value(item.reference_dt, item.reference_dn, 'invoiced') |
| 315 | if is_invoiced: |
| 316 | frappe.throw(_('The item referenced by {0} - {1} is already invoiced'\ |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 317 | ).format(item.reference_dt, item.reference_dn)) |
| 318 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 319 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 320 | def manage_prescriptions(invoiced, ref_dt, ref_dn, dt, created_check_field): |
| 321 | created = frappe.db.get_value(ref_dt, ref_dn, created_check_field) |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 322 | if created: |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 323 | # Fetch the doc created for the prescription |
Jamsheer | eafb046 | 2018-07-25 13:15:12 +0530 | [diff] [blame] | 324 | doc_created = frappe.db.get_value(dt, {'prescription': ref_dn}) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 325 | frappe.db.set_value(dt, doc_created, 'invoiced', invoiced) |
| 326 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 327 | |
Rucha Mahabal | cd31996 | 2020-03-13 15:39:31 +0530 | [diff] [blame] | 328 | def check_fee_validity(appointment): |
Rucha Mahabal | f2574dd | 2020-03-17 19:28:18 +0530 | [diff] [blame] | 329 | if not frappe.db.get_single_value('Healthcare Settings', 'enable_free_follow_ups'): |
| 330 | return |
| 331 | |
Rucha Mahabal | cd31996 | 2020-03-13 15:39:31 +0530 | [diff] [blame] | 332 | validity = frappe.db.exists('Fee Validity', { |
| 333 | 'practitioner': appointment.practitioner, |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 334 | 'patient': appointment.patient, |
Rucha Mahabal | f2574dd | 2020-03-17 19:28:18 +0530 | [diff] [blame] | 335 | 'valid_till': ('>=', appointment.appointment_date) |
Rucha Mahabal | cd31996 | 2020-03-13 15:39:31 +0530 | [diff] [blame] | 336 | }) |
| 337 | if not validity: |
| 338 | return |
| 339 | |
Rucha Mahabal | f2574dd | 2020-03-17 19:28:18 +0530 | [diff] [blame] | 340 | validity = frappe.get_doc('Fee Validity', validity) |
| 341 | return validity |
| 342 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 343 | |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 344 | def manage_fee_validity(appointment): |
| 345 | fee_validity = check_fee_validity(appointment) |
Rucha Mahabal | cd31996 | 2020-03-13 15:39:31 +0530 | [diff] [blame] | 346 | if fee_validity: |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 347 | if appointment.status == 'Cancelled' and fee_validity.visited > 0: |
| 348 | fee_validity.visited -= 1 |
| 349 | frappe.db.delete('Fee Validity Reference', {'appointment': appointment.name}) |
Rucha Mahabal | 2cec6bd | 2020-03-26 14:38:12 +0530 | [diff] [blame] | 350 | elif fee_validity.status == 'Completed': |
| 351 | return |
Rucha Mahabal | cd31996 | 2020-03-13 15:39:31 +0530 | [diff] [blame] | 352 | else: |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 353 | fee_validity.visited += 1 |
| 354 | fee_validity.append('ref_appointments', { |
| 355 | 'appointment': appointment.name |
| 356 | }) |
| 357 | fee_validity.save(ignore_permissions=True) |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 358 | else: |
Rucha Mahabal | 2f2c09b | 2020-03-17 18:10:39 +0530 | [diff] [blame] | 359 | fee_validity = create_fee_validity(appointment) |
| 360 | return fee_validity |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 361 | |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 362 | |
Rucha Mahabal | 06d1b04 | 2020-03-12 12:16:23 +0530 | [diff] [blame] | 363 | def manage_doc_for_appointment(dt_from_appointment, appointment, invoiced): |
Rucha Mahabal | c4b2dce | 2020-03-09 23:57:00 +0530 | [diff] [blame] | 364 | dn_from_appointment = frappe.db.get_value( |
| 365 | dt_from_appointment, |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 366 | filters={'appointment': appointment} |
Jamsheer | ba11972 | 2018-07-06 15:58:13 +0530 | [diff] [blame] | 367 | ) |
| 368 | if dn_from_appointment: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 369 | frappe.db.set_value(dt_from_appointment, dn_from_appointment, 'invoiced', invoiced) |
| 370 | |
Jamsheer | e82f27a | 2018-07-30 11:28:37 +0530 | [diff] [blame] | 371 | |
| 372 | @frappe.whitelist() |
| 373 | def get_drugs_to_invoice(encounter): |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 374 | encounter = frappe.get_doc('Patient Encounter', encounter) |
Jamsheer | e82f27a | 2018-07-30 11:28:37 +0530 | [diff] [blame] | 375 | if encounter: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 376 | patient = frappe.get_doc('Patient', encounter.patient) |
| 377 | if patient: |
| 378 | if patient.customer: |
| 379 | items_to_invoice = [] |
Jamsheer | e82f27a | 2018-07-30 11:28:37 +0530 | [diff] [blame] | 380 | for drug_line in encounter.drug_prescription: |
| 381 | if drug_line.drug_code: |
| 382 | qty = 1 |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 383 | if frappe.db.get_value('Item', drug_line.drug_code, 'stock_uom') == 'Nos': |
Jamsheer | e82f27a | 2018-07-30 11:28:37 +0530 | [diff] [blame] | 384 | qty = drug_line.get_quantity() |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 385 | |
| 386 | description = '' |
| 387 | if drug_line.dosage and drug_line.period: |
| 388 | description = _('{0} for {1}').format(drug_line.dosage, drug_line.period) |
| 389 | |
| 390 | items_to_invoice.append({ |
| 391 | 'drug_code': drug_line.drug_code, |
| 392 | 'quantity': qty, |
| 393 | 'description': description |
| 394 | }) |
| 395 | return items_to_invoice |
| 396 | else: |
| 397 | validate_customer_created(patient) |
| 398 | |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 399 | |
| 400 | @frappe.whitelist() |
| 401 | def get_children(doctype, parent, company, is_root=False): |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 402 | parent_fieldname = "parent_" + doctype.lower().replace(" ", "_") |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 403 | fields = [ |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 404 | "name as value", |
| 405 | "is_group as expandable", |
| 406 | "lft", |
| 407 | "rgt" |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 408 | ] |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 409 | # fields = [ "name", "is_group", "lft", "rgt" ] |
| 410 | filters = [["ifnull(`{0}`,'')".format(parent_fieldname), "=", "" if is_root else parent]] |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 411 | |
| 412 | if is_root: |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 413 | fields += ["service_unit_type"] if doctype == "Healthcare Service Unit" else [] |
| 414 | filters.append(["company", "=", company]) |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 415 | |
| 416 | else: |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 417 | fields += ["service_unit_type", "allow_appointments", "inpatient_occupancy", "occupancy_status"] if doctype == "Healthcare Service Unit" else [] |
| 418 | fields += [parent_fieldname + " as parent"] |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 419 | |
| 420 | hc_service_units = frappe.get_list(doctype, fields=fields, filters=filters) |
| 421 | |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 422 | if doctype == "Healthcare Service Unit": |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 423 | for each in hc_service_units: |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 424 | occupancy_msg = "" |
| 425 | if each["expandable"] == 1: |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 426 | occupied = False |
| 427 | vacant = False |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 428 | child_list = frappe.db.sql(""" |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 429 | select name, occupancy_status from `tabHealthcare Service Unit` |
| 430 | where inpatient_occupancy = 1 and |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 431 | lft > %s and rgt < %s""", |
| 432 | (each["lft"], each["rgt"])) |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 433 | for child in child_list: |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 434 | if not occupied: |
| 435 | occupied = 0 |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 436 | if child[1] == "Occupied": |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 437 | occupied += 1 |
| 438 | if not vacant: |
| 439 | vacant = 0 |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 440 | if child[1] == "Vacant": |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 441 | vacant += 1 |
| 442 | if vacant and occupied: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 443 | occupancy_total = vacant + occupied |
Rucha Mahabal | 05853ef | 2020-03-12 17:44:46 +0530 | [diff] [blame] | 444 | occupancy_msg = str(occupied) + " Occupied out of " + str(occupancy_total) |
| 445 | each["occupied_out_of_vacant"] = occupancy_msg |
Jamsheer | 4371c7e | 2018-08-01 18:40:05 +0530 | [diff] [blame] | 446 | return hc_service_units |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 447 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 448 | |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 449 | @frappe.whitelist() |
| 450 | def get_patient_vitals(patient, from_date=None, to_date=None): |
| 451 | if not patient: return |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 452 | |
| 453 | vitals = frappe.db.get_all('Vital Signs', { |
| 454 | 'docstatus': 1, |
| 455 | 'patient': patient |
Rucha Mahabal | 06d1b04 | 2020-03-12 12:16:23 +0530 | [diff] [blame] | 456 | }, order_by='signs_date, signs_time') |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 457 | |
| 458 | if len(vitals): |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 459 | return vitals |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 460 | return False |
| 461 | |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 462 | |
| 463 | @frappe.whitelist() |
| 464 | def render_docs_as_html(docs): |
| 465 | # docs key value pair {doctype: docname} |
| 466 | docs_html = "<div class='col-md-12 col-sm-12 text-muted'>" |
| 467 | for doc in docs: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 468 | docs_html += render_doc_as_html(doc['doctype'], doc['docname'])['html'] + '<br/>' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 469 | return {'html': docs_html} |
| 470 | |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 471 | |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 472 | @frappe.whitelist() |
| 473 | def render_doc_as_html(doctype, docname, exclude_fields = []): |
| 474 | #render document as html, three column layout will break |
| 475 | doc = frappe.get_doc(doctype, docname) |
| 476 | meta = frappe.get_meta(doctype) |
| 477 | doc_html = "<div class='col-md-12 col-sm-12'>" |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 478 | section_html = '' |
| 479 | section_label = '' |
| 480 | html = '' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 481 | sec_on = False |
| 482 | col_on = 0 |
| 483 | has_data = False |
| 484 | for df in meta.fields: |
| 485 | #on section break append append previous section and html to doc html |
| 486 | if df.fieldtype == "Section Break": |
| 487 | if has_data and col_on and sec_on: |
| 488 | doc_html += section_html + html + "</div>" |
| 489 | elif has_data and not col_on and sec_on: |
| 490 | doc_html += "<div class='col-md-12 col-sm-12'\ |
| 491 | ><div class='col-md-12 col-sm-12'>" \ |
| 492 | + section_html + html +"</div></div>" |
| 493 | while col_on: |
| 494 | doc_html += "</div>" |
| 495 | col_on -= 1 |
| 496 | sec_on = True |
| 497 | has_data= False |
| 498 | col_on = 0 |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 499 | section_html = '' |
| 500 | html = '' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 501 | if df.label: |
| 502 | section_label = df.label |
| 503 | continue |
| 504 | #on column break append html to section html or doc html |
| 505 | if df.fieldtype == "Column Break": |
| 506 | if sec_on and has_data: |
| 507 | section_html += "<div class='col-md-12 col-sm-12'\ |
| 508 | ><div class='col-md-6 col\ |
| 509 | -sm-6'><b>" + section_label + "</b>" + html + "</div><div \ |
| 510 | class='col-md-6 col-sm-6'>" |
| 511 | elif has_data: |
| 512 | doc_html += "<div class='col-md-12 col-sm-12'><div class='col-m\ |
| 513 | d-6 col-sm-6'>" + html + "</div><div class='col-md-6 col-sm-6'>" |
| 514 | elif sec_on and not col_on: |
| 515 | section_html += "<div class='col-md-6 col-sm-6'>" |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 516 | html = '' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 517 | col_on += 1 |
| 518 | if df.label: |
| 519 | html += '<br>' + df.label |
| 520 | continue |
| 521 | #on table iterate in items and create table based on in_list_view, append to section html or doc html |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 522 | if df.fieldtype == 'Table': |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 523 | items = doc.get(df.fieldname) |
| 524 | if not items: continue |
| 525 | child_meta = frappe.get_meta(df.options) |
| 526 | if not has_data : has_data = True |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 527 | table_head = '' |
| 528 | table_row = '' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 529 | create_head = True |
| 530 | for item in items: |
| 531 | table_row += '<tr>' |
| 532 | for cdf in child_meta.fields: |
| 533 | if cdf.in_list_view: |
| 534 | if create_head: |
| 535 | table_head += '<th>' + cdf.label + '</th>' |
| 536 | if item.get(cdf.fieldname): |
| 537 | table_row += '<td>' + str(item.get(cdf.fieldname)) \ |
| 538 | + '</td>' |
| 539 | else: |
| 540 | table_row += '<td></td>' |
| 541 | create_head = False |
| 542 | table_row += '</tr>' |
| 543 | if sec_on: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 544 | section_html += "<table class='table table-condensed \ |
| 545 | bordered'>" + table_head + table_row + '</table>' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 546 | else: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 547 | html += "<table class='table table-condensed table-bordered'>" \ |
| 548 | + table_head + table_row + "</table>" |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 549 | continue |
| 550 | #on other field types add label and value to html |
| 551 | if not df.hidden and not df.print_hide and doc.get(df.fieldname) and df.fieldname not in exclude_fields: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 552 | html += '<br>{0} : {1}'.format(df.label or df.fieldname, \ |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 553 | doc.get(df.fieldname)) |
| 554 | if not has_data : has_data = True |
| 555 | if sec_on and col_on and has_data: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 556 | doc_html += section_html + html + '</div></div>' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 557 | elif sec_on and not col_on and has_data: |
| 558 | doc_html += "<div class='col-md-12 col-sm-12'\ |
| 559 | ><div class='col-md-12 col-sm-12'>" \ |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 560 | + section_html + html +'</div></div>' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 561 | if doc_html: |
Rucha Mahabal | 27512c8 | 2020-03-09 17:29:23 +0530 | [diff] [blame] | 562 | doc_html = "<div class='small'><div class='col-md-12 text-right'><a class='btn btn-default btn-xs' href='#Form/%s/%s'></a></div>" %(doctype, docname) + doc_html + '</div>' |
Jamsheer | 5073ac4 | 2019-07-12 12:28:34 +0530 | [diff] [blame] | 563 | |
| 564 | return {'html': doc_html} |