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