fix: Healthcare Service Unit fixes (#27273)
* fix: validate service unit setup against practitioner schedule * fix: service unit properties getting overwritten
This commit is contained in:
parent
c1d986a0c6
commit
ef76f62bc1
@ -30,7 +30,7 @@ class HealthcareServiceUnit(NestedSet):
|
|||||||
self.validate_one_root()
|
self.validate_one_root()
|
||||||
|
|
||||||
def set_service_unit_properties(self):
|
def set_service_unit_properties(self):
|
||||||
if self.is_group:
|
if cint(self.is_group):
|
||||||
self.allow_appointments = False
|
self.allow_appointments = False
|
||||||
self.overlap_appointments = False
|
self.overlap_appointments = False
|
||||||
self.inpatient_occupancy = False
|
self.inpatient_occupancy = False
|
||||||
|
@ -6,7 +6,7 @@ from __future__ import unicode_literals
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
import json
|
import json
|
||||||
from frappe.utils import getdate, get_time, flt
|
from frappe.utils import getdate, get_time, flt, get_link_to_form
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe import _
|
from frappe import _
|
||||||
import datetime
|
import datetime
|
||||||
@ -333,17 +333,13 @@ def check_employee_wise_availability(date, practitioner_doc):
|
|||||||
|
|
||||||
|
|
||||||
def get_available_slots(practitioner_doc, date):
|
def get_available_slots(practitioner_doc, date):
|
||||||
available_slots = []
|
available_slots = slot_details = []
|
||||||
slot_details = []
|
|
||||||
weekday = date.strftime('%A')
|
weekday = date.strftime('%A')
|
||||||
practitioner = practitioner_doc.name
|
practitioner = practitioner_doc.name
|
||||||
|
|
||||||
for schedule_entry in practitioner_doc.practitioner_schedules:
|
for schedule_entry in practitioner_doc.practitioner_schedules:
|
||||||
if schedule_entry.schedule:
|
validate_practitioner_schedules(schedule_entry, practitioner)
|
||||||
practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule)
|
practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule)
|
||||||
else:
|
|
||||||
frappe.throw(_('{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner').format(
|
|
||||||
frappe.bold(practitioner)), title=_('Practitioner Schedule Not Found'))
|
|
||||||
|
|
||||||
if practitioner_schedule:
|
if practitioner_schedule:
|
||||||
available_slots = []
|
available_slots = []
|
||||||
@ -386,6 +382,19 @@ def get_available_slots(practitioner_doc, date):
|
|||||||
return slot_details
|
return slot_details
|
||||||
|
|
||||||
|
|
||||||
|
def validate_practitioner_schedules(schedule_entry, practitioner):
|
||||||
|
if schedule_entry.schedule:
|
||||||
|
if not schedule_entry.service_unit:
|
||||||
|
frappe.throw(_('Practitioner {0} does not have a Service Unit set against the Practitioner Schedule {1}.').format(
|
||||||
|
get_link_to_form('Healthcare Practitioner', practitioner), frappe.bold(schedule_entry.schedule)),
|
||||||
|
title=_('Service Unit Not Found'))
|
||||||
|
|
||||||
|
else:
|
||||||
|
frappe.throw(_('Practitioner {0} does not have a Practitioner Schedule assigned.').format(
|
||||||
|
get_link_to_form('Healthcare Practitioner', practitioner)),
|
||||||
|
title=_('Practitioner Schedule Not Found'))
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def update_status(appointment_id, status):
|
def update_status(appointment_id, status):
|
||||||
frappe.db.set_value('Patient Appointment', appointment_id, 'status', status)
|
frappe.db.set_value('Patient Appointment', appointment_id, 'status', status)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user