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

refactor(Healthcare): IP Admission and Discharge, Minor fixes #21817

Merged
merged 10 commits into from
May 21, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@
"engine": "InnoDB",
"field_order": [
"healthcare_service_unit_name",
"parent_healthcare_service_unit",
"is_group",
"service_unit_type",
"allow_appointments",
"overlap_appointments",
"inpatient_occupancy",
"occupancy_status",
"column_break_9",
"warehouse",
"company",
"warehouse",
"tree_details_section",
"parent_healthcare_service_unit",
"lft",
"rgt",
"old_parent"
Expand Down Expand Up @@ -51,7 +52,6 @@
"depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
"fieldname": "is_group",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Is Group"
},
{
Expand All @@ -63,12 +63,12 @@
"options": "Healthcare Service Unit Type"
},
{
"bold": 1,
"default": "0",
"depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1",
"fetch_from": "service_unit_type.allow_appointments",
"fieldname": "allow_appointments",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Allow Appointments",
"no_copy": 1,
"read_only": 1
Expand All @@ -90,6 +90,7 @@
"fetch_from": "service_unit_type.inpatient_occupancy",
"fieldname": "inpatient_occupancy",
"fieldtype": "Check",
"in_list_view": 1,
"label": "Inpatient Occupancy",
"no_copy": 1,
"read_only": 1,
Expand All @@ -101,7 +102,7 @@
"fieldtype": "Select",
"label": "Occupancy Status",
"no_copy": 1,
"options": "\nVacant\nOccupied",
"options": "Vacant\nOccupied",
"read_only": 1
},
{
Expand Down Expand Up @@ -157,10 +158,16 @@
"options": "Healthcare Service Unit",
"print_hide": 1,
"report_hide": 1
},
{
"collapsible": 1,
"fieldname": "tree_details_section",
"fieldtype": "Section Break",
"label": "Tree Details"
}
],
"links": [],
"modified": "2020-03-26 16:13:08.675952",
"modified": "2020-05-20 18:26:56.065543",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Service Unit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ def on_update(self):
super(HealthcareServiceUnit, self).on_update()
self.validate_one_root()

def validate(self):
def after_insert(self):
if self.is_group:
self.allow_appointments = 0
self.overlap_appointments = 0
self.inpatient_occupancy = 0
elif not self.allow_appointments:
self.overlap_appointments = 0
elif self.service_unit_type:
service_unit_type = frappe.get_doc('Healthcare Service Unit Type', self.service_unit_type)
self.allow_appointments = service_unit_type.allow_appointments
self.overlap_appointments = service_unit_type.overlap_appointments
self.inpatient_occupancy = service_unit_type.inpatient_occupancy
if self.inpatient_occupancy:
self.occupancy_status = 'Vacant'
self.overlap_appointments = 0
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"fieldtype": "Data",
"in_list_view": 1,
"label": "Service Unit Type",
"no_copy": 1,
"reqd": 1,
"unique": 1
},
Expand All @@ -40,26 +41,23 @@
"depends_on": "eval:doc.inpatient_occupancy != 1",
"fieldname": "allow_appointments",
"fieldtype": "Check",
"label": "Allow Appointments",
"no_copy": 1
"label": "Allow Appointments"
},
{
"bold": 1,
"default": "0",
"depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
"fieldname": "overlap_appointments",
"fieldtype": "Check",
"label": "Allow Overlap",
"no_copy": 1
"label": "Allow Overlap"
},
{
"bold": 1,
"default": "0",
"depends_on": "eval:doc.allow_appointments != 1",
"fieldname": "inpatient_occupancy",
"fieldtype": "Check",
"label": "Inpatient Occupancy",
"no_copy": 1
"label": "Inpatient Occupancy"
},
{
"bold": 1,
Expand All @@ -79,14 +77,16 @@
"fieldname": "item",
"fieldtype": "Link",
"label": "Item",
"no_copy": 1,
"options": "Item",
"read_only": 1
},
{
"fieldname": "item_code",
"fieldtype": "Data",
"label": "Item Code",
"mandatory_depends_on": "eval: doc.is_billable == 1"
"mandatory_depends_on": "eval: doc.is_billable == 1",
"no_copy": 1
},
{
"fieldname": "item_group",
Expand Down Expand Up @@ -138,7 +138,7 @@
}
],
"links": [],
"modified": "2020-01-30 16:06:00.624496",
"modified": "2020-05-20 15:31:09.627516",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Healthcare Service Unit Type",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@

class HealthcareServiceUnitType(Document):
def validate(self):
if self.allow_appointments and self.inpatient_occupancy:
frappe.msgprint(
_('Healthcare Service Unit Type cannot have both {0} and {1}').format(
frappe.bold('Allow Appointments'), frappe.bold('Inpatient Occupancy')),
raise_exception=1, title=_('Validation Error'), indicator='red'
)
elif not self.allow_appointments and not self.inpatient_occupancy:
frappe.msgprint(
_('Healthcare Service Unit Type must allow atleast one among {0} and {1}').format(
frappe.bold('Allow Appointments'), frappe.bold('Inpatient Occupancy')),
raise_exception=1, title=_('Validation Error'), indicator='red'
)

if not self.allow_appointments:
self.overlap_appointments = 0

if self.is_billable:
if self.disabled:
frappe.db.set_value('Item', self.item, 'disabled', 1)
Expand Down
Loading