Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Healthcare Service Unit fixes #27273

Merged
merged 3 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def on_update(self):
self.validate_one_root()

def set_service_unit_properties(self):
if self.is_group:
if cint(self.is_group):
self.allow_appointments = False
self.overlap_appointments = False
self.inpatient_occupancy = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import frappe
from frappe.model.document import Document
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 import _
import datetime
Expand Down Expand Up @@ -333,17 +333,13 @@ def check_employee_wise_availability(date, practitioner_doc):


def get_available_slots(practitioner_doc, date):
available_slots = []
slot_details = []
available_slots = slot_details = []
weekday = date.strftime('%A')
practitioner = practitioner_doc.name

for schedule_entry in practitioner_doc.practitioner_schedules:
if 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'))
validate_practitioner_schedules(schedule_entry, practitioner)
practitioner_schedule = frappe.get_doc('Practitioner Schedule', schedule_entry.schedule)

if practitioner_schedule:
available_slots = []
Expand Down Expand Up @@ -386,6 +382,19 @@ def get_available_slots(practitioner_doc, date):
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()
def update_status(appointment_id, status):
frappe.db.set_value('Patient Appointment', appointment_id, 'status', status)
Expand Down