Skip to content

Commit

Permalink
Merge pull request #878 from aakvatech/version-14-hotfix
Browse files Browse the repository at this point in the history
Version 14 hotfix
  • Loading branch information
aakvatech authored Jan 9, 2024
2 parents cc80f5b + 5fcf547 commit 5cfb29c
Show file tree
Hide file tree
Showing 30 changed files with 2,990 additions and 958 deletions.
2 changes: 1 addition & 1 deletion hms_tz/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

__version__ = "14.11.0"
__version__ = "14.12.0"
52 changes: 35 additions & 17 deletions hms_tz/hms_tz/doctype/lrpmt_returns/lrpmt_returns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,29 @@
import frappe
import json
from frappe import bold, _
from frappe.model.workflow import apply_workflow
from frappe.utils import nowdate, nowtime, flt, unique
from frappe.model.document import Document
from frappe.model.workflow import apply_workflow
from frappe.utils import nowdate, nowtime, flt, unique, get_fullname, get_url_to_form
from hms_tz.nhif.api.healthcare_utils import validate_nhif_patient_claim_status


class LRPMTReturns(Document):
def validate(self):
set_missing_values(self)

def before_insert(self):
validate_nhif_patient_claim_status(
"LRPMT Return", self.company, self.appointment
)

def before_submit(self):
if not self.approved_by:
self.approved_by = get_fullname()

validate_nhif_patient_claim_status(
"LRPMT Return", self.company, self.appointment
)

validate_reason(self)
validate_drug_row(self)
cancel_lrpt_doc(self)
Expand Down Expand Up @@ -54,7 +67,7 @@ def cancel_lrpt_doc(self):
doc.status = "Not Serviced"
doc.save(ignore_permissions=True)
doc.reload()

if (
doc.workflow_state == "Not Serviced"
or doc.workflow_state == "Submitted but Not Serviced"
Expand All @@ -75,6 +88,8 @@ def cancel_lrpt_doc(self):
frappe.bold(item.reference_docname),
)
)


def cancel_tharapy_plan_doc(patient, therapy_plan_id):
therapy_sessions = frappe.get_all(
"Therapy Session",
Expand All @@ -91,7 +106,7 @@ def cancel_tharapy_plan_doc(patient, therapy_plan_id):
therapy_session_doc.cancel()

therapy_plan_doc = frappe.get_doc("Therapy Plan", therapy_plan_id)

for entry in therapy_plan_doc.therapy_plan_details:
if entry.no_of_sessions:
entry.no_of_sessions = 0
Expand All @@ -103,7 +118,8 @@ def cancel_tharapy_plan_doc(patient, therapy_plan_id):
therapy_plan_doc.save(ignore_permissions=True)
therapy_plan_doc.reload()
return therapy_plan_doc.name



def return_or_cancel_drug_item(self):
if len(self.drug_items) == 0:
return
Expand All @@ -128,15 +144,11 @@ def return_or_cancel_drug_item(self):
except Exception:
frappe.log_error(
frappe.get_traceback(),
str(
"Error in creating return delivery note for {0}".format(
dn.delivery_note_no
)
),
str("Error in creating return delivery note for {0}".format(dn)),
)
frappe.throw(
"Error in creating return delivery note against delivery note: {0}".format(
frappe.bold(dn.delivery_note_no)
frappe.bold(dn)
)
)

Expand All @@ -157,7 +169,7 @@ def update_drug_description_for_draft_delivery_note(self, delivey_note):

if dn_doc.workflow_state != "Not Serviced":
apply_workflow(dn_doc, "Not Serviced")

if dn_doc.workflow_state == "Not Serviced":
for item in self.drug_items:
if item.delivery_note_no == delivey_note and item.status == "Draft":
Expand Down Expand Up @@ -195,7 +207,7 @@ def update_drug_prescription_for_submitted_delivery_note(item):
item_cancelled = 1
else:
item_cancelled = 0

frappe.db.set_value(
"Drug Prescription",
item.child_name,
Expand All @@ -206,6 +218,7 @@ def update_drug_prescription_for_submitted_delivery_note(item):
},
)


def return_drug_quantity_to_stock(self, source_doc):
target_doc = frappe.new_doc("Delivery Note")
target_doc.customer = source_doc.customer
Expand Down Expand Up @@ -388,17 +401,19 @@ def validate_drug_row(self):

if msg:
frappe.throw(title="Notification", msg=msg, exc="Frappe.ValidationError")



def get_unique_delivery_notes(self, status):
return unique([d.delivery_note_no for d in self.drug_items if d.status == status])


@frappe.whitelist()
def get_lrpt_item_list(patient, appointment, company):
item_list = []
child_list = get_lrpt_map()

encounter_list = get_patient_encounters(patient, appointment, company)

for child in child_list:
items = frappe.get_all(
child["doctype"],
Expand Down Expand Up @@ -549,7 +564,7 @@ def get_refdoc(doctype, childname, template, encounter):
"field": "procedure_template",
},
]

for refd in ref_docs:
if refd.get("table") == doctype:
docname = frappe.get_value(
Expand All @@ -566,6 +581,9 @@ def get_refdoc(doctype, childname, template, encounter):


def set_missing_values(doc):
if not doc.requested_by:
doc.requested_by = get_fullname()

appointment_list = frappe.get_all(
"Patient Appointment",
filters={"patient": doc.patient, "status": "Closed"},
Expand Down Expand Up @@ -806,7 +824,7 @@ def get_drugs(patient, appointment, company):
"dn_detail",
],
)

for drug in drugs:
drug.update(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<td>
<table class="table table-hover table-bordered table-sm" style="width: 100%; border-collapse: collapse; border: 1px solid #ccc;">
<colgroup>
<col style="width: 33%" />
<col style="width: 34%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
Expand Down
26 changes: 19 additions & 7 deletions hms_tz/hms_tz/report/ipd_billing_report/ipd_billing_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ def get_summarized_data(args):
date_list = []
single_transaction_per_day = []
mult_transaction_per_day = []

transactions = get_transaction_data(args)
if len(transactions) == 0:
frappe.msgprint(
f"No Record found for the Fitlters: Patient: {frappe.bold(args.patient)}, Appointment: {frappe.bold(args.appointment_no)},\
f"No Record found for the Fitlters: Patient: {frappe.bold(args.patient)}, Appointment: {frappe.bold(args.appointment_no)},\
Patient Type: {frappe.bold(args.patient_type)} From Date: {frappe.bold(args.from_date)} and To Date: {frappe.bold(args.to_date)}\
you specified..., Please change your filters and try again..!!"
)
)
return [], []

for record in transactions:
total_amount = (
flt(record["bed_charges"])
Expand Down Expand Up @@ -331,6 +331,9 @@ def get_transaction_data(args):

def get_report_summary(args, summary_data, is_summary=False):
customer = frappe.get_value("Patient", {"name": args.patient}, ["customer"])
cash_limit = frappe.get_value(
"Inpatient Record", args.inpatient_record, "cash_limit"
)

deposit_balance = get_balance_on(
party_type="Customer", party=customer, company=args.company
Expand Down Expand Up @@ -412,23 +415,32 @@ def get_report_summary(args, summary_data, is_summary=False):
currency = frappe.get_cached_value("Company", args.company, "default_currency")

return sorted_data, [
{
"value": cash_limit,
"label": _("Current Cash Limit"),
"datatype": "Currency",
"currency": currency,
},
{
"value": total_deposited_amount,
"label": _("Total Deposited Amount"),
"datatype": "Currency",
"currency": currency,
"color": "blue",
},
{
"value": total_amount_used,
"label": _("Total Amount Used"),
"datatype": "Currency",
"currency": currency,
"color": "blue",
},
{
"value": current_balance,
"label": _("Current Balance"),
"datatype": "Currency",
"currency": currency,
"color": "blue",
},
]

Expand All @@ -439,11 +451,11 @@ def get_data(args):
if args.get("patient_type") == "In-Patient":
cash_lrpmt_data = get_cash_lrpmt_transaction(args)
if len(cash_lrpmt_data) > 0:
data += cash_lrpmt_data
data += cash_lrpmt_data

# insurance_lrpmt_data = get_insurance_lrpmt_transaction(args)
# if insurance_lrpmt_data: data += insurance_lrpmt_data

ipd_beds = get_ipd_occupancy_transactions(args)
if len(ipd_beds) > 0:
data += ipd_beds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
vertical-align: top !important;
padding: 1px !important;
}
.print-format th {
font-weight: bold;
color: black;
}

hr {
margin-top: 10px;
Expand All @@ -42,6 +46,10 @@
vertical-align: top !important;
padding: 1px !important;
}
.print-format th {
font-weight: bold;
color: black;
}

hr {
margin-top: 10px;
Expand Down Expand Up @@ -177,6 +185,65 @@
</table>
</td>
</tr>
{% for(var d=0, h=data.length; d<h; d++) { %}
{% if (data[d].limit_exceeded_items) { %}
{% var exceeded_items = data[d].limit_exceeded_items %}
{% if (exceeded_items.length > 0) { %}
<tr>
<td>
<br>
<hr>
<h5 style="justify-content: center;">{%= __("Daily Limit Exceeded Items:") %}</h5>
<table class="table table-bordered">
<colgroup>
<col style="width: 5%" />
<col style="width: 12%" />
<col style="width: 27%" />
<col style="width: 26%" />
<col style="width: 8%" />
<col style="width: 11%" />
<col style="width: 11%" />
</colgroup>
<thead>
<tr>
<th style="text-align:center">{%= __("SrNo") %}</th>
<th style="text-align:center">{%= __("Date") %}</th>
<th style="text-align:left">{%= __("Category") %}</th>
<th style="text-align:left">{%= __("Description") %}</th>
<th style="text-align:center">{%= __("Quantity") %}</th>
<th style="text-align:center">{%= __("Rate") %}</th>
<th style="text-align:center">{%= __("Amount") %}</th>
</tr>
</thead>
<tbody>
{% for(var i=0, l=exceeded_items.length; i<l; i++) { %}
<tr>
<td style="text-align: center; ">{%= i+1 %}</td>
<td style="text-align: left; ">{%= exceeded_items[i].date %}</td>
<td style="text-align: left; ">{%= exceeded_items[i].category %}</td>
<td style="text-align: left; ">{%= exceeded_items[i].description %}</td>
<td style="text-align: center; ">{%= exceeded_items[i].quantity %}</td>
<td style="text-align: right; ">{%= exceeded_items[i][("rate")].toLocaleString(undefined,
{minimumFractionDigits: 2, maximumFractionDigits: 2}) %}</td>
<td style="text-align: right; ">{%= exceeded_items[i][("amount")].toLocaleString(undefined,
{minimumFractionDigits: 2, maximumFractionDigits: 2}) %}</td>

</tr>
{% } %}
</tbody>
<tfoot>
<tr>
<th style="text-align: left; " colspan="6">Total</th>
<th style="text-align: right; ">{%= data[d].total_limit_exceeded_amount.toLocaleString(undefined, {minimumFractionDigits: 2,
maximumFractionDigits: 2}) %}</th>
</tr>
</tfoot>
</table>
</td>
</tr>
{% } %}
{% } %}
{% } %}
<tr>
<td>
<div style="padding-bottom: 3px; margin-top: 0px; margin-bottom: 0px; border: 0;">
Expand Down
Loading

0 comments on commit 5cfb29c

Please sign in to comment.