fix: service unit create - set fields based on service unit type, added validations
This commit is contained in:
parent
c71e7eb56f
commit
6917849273
@ -12,7 +12,6 @@
|
|||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
"field_order": [
|
"field_order": [
|
||||||
"healthcare_service_unit_name",
|
"healthcare_service_unit_name",
|
||||||
"parent_healthcare_service_unit",
|
|
||||||
"is_group",
|
"is_group",
|
||||||
"service_unit_type",
|
"service_unit_type",
|
||||||
"allow_appointments",
|
"allow_appointments",
|
||||||
@ -20,8 +19,10 @@
|
|||||||
"inpatient_occupancy",
|
"inpatient_occupancy",
|
||||||
"occupancy_status",
|
"occupancy_status",
|
||||||
"column_break_9",
|
"column_break_9",
|
||||||
"warehouse",
|
|
||||||
"company",
|
"company",
|
||||||
|
"warehouse",
|
||||||
|
"tree_details_section",
|
||||||
|
"parent_healthcare_service_unit",
|
||||||
"lft",
|
"lft",
|
||||||
"rgt",
|
"rgt",
|
||||||
"old_parent"
|
"old_parent"
|
||||||
@ -51,7 +52,6 @@
|
|||||||
"depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
|
"depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
|
||||||
"fieldname": "is_group",
|
"fieldname": "is_group",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Is Group"
|
"label": "Is Group"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -63,12 +63,12 @@
|
|||||||
"options": "Healthcare Service Unit Type"
|
"options": "Healthcare Service Unit Type"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bold": 1,
|
|
||||||
"default": "0",
|
"default": "0",
|
||||||
"depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1",
|
"depends_on": "eval:doc.is_group != 1 && doc.inpatient_occupancy != 1",
|
||||||
"fetch_from": "service_unit_type.allow_appointments",
|
"fetch_from": "service_unit_type.allow_appointments",
|
||||||
"fieldname": "allow_appointments",
|
"fieldname": "allow_appointments",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Allow Appointments",
|
"label": "Allow Appointments",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
@ -90,6 +90,7 @@
|
|||||||
"fetch_from": "service_unit_type.inpatient_occupancy",
|
"fetch_from": "service_unit_type.inpatient_occupancy",
|
||||||
"fieldname": "inpatient_occupancy",
|
"fieldname": "inpatient_occupancy",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
"label": "Inpatient Occupancy",
|
"label": "Inpatient Occupancy",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@ -101,7 +102,7 @@
|
|||||||
"fieldtype": "Select",
|
"fieldtype": "Select",
|
||||||
"label": "Occupancy Status",
|
"label": "Occupancy Status",
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "\nVacant\nOccupied",
|
"options": "Vacant\nOccupied",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -157,10 +158,16 @@
|
|||||||
"options": "Healthcare Service Unit",
|
"options": "Healthcare Service Unit",
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"report_hide": 1
|
"report_hide": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"collapsible": 1,
|
||||||
|
"fieldname": "tree_details_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "Tree Details"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-03-26 16:13:08.675952",
|
"modified": "2020-05-20 18:26:56.065543",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Healthcare Service Unit",
|
"name": "Healthcare Service Unit",
|
||||||
|
@ -27,5 +27,11 @@ class HealthcareServiceUnit(NestedSet):
|
|||||||
self.allow_appointments = 0
|
self.allow_appointments = 0
|
||||||
self.overlap_appointments = 0
|
self.overlap_appointments = 0
|
||||||
self.inpatient_occupancy = 0
|
self.inpatient_occupancy = 0
|
||||||
elif not self.allow_appointments:
|
elif self.service_unit_type:
|
||||||
self.overlap_appointments = 0
|
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
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Service Unit Type",
|
"label": "Service Unit Type",
|
||||||
|
"no_copy": 1,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"unique": 1
|
"unique": 1
|
||||||
},
|
},
|
||||||
@ -40,8 +41,7 @@
|
|||||||
"depends_on": "eval:doc.inpatient_occupancy != 1",
|
"depends_on": "eval:doc.inpatient_occupancy != 1",
|
||||||
"fieldname": "allow_appointments",
|
"fieldname": "allow_appointments",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Allow Appointments",
|
"label": "Allow Appointments"
|
||||||
"no_copy": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bold": 1,
|
"bold": 1,
|
||||||
@ -49,8 +49,7 @@
|
|||||||
"depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
|
"depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
|
||||||
"fieldname": "overlap_appointments",
|
"fieldname": "overlap_appointments",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Allow Overlap",
|
"label": "Allow Overlap"
|
||||||
"no_copy": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bold": 1,
|
"bold": 1,
|
||||||
@ -58,8 +57,7 @@
|
|||||||
"depends_on": "eval:doc.allow_appointments != 1",
|
"depends_on": "eval:doc.allow_appointments != 1",
|
||||||
"fieldname": "inpatient_occupancy",
|
"fieldname": "inpatient_occupancy",
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"label": "Inpatient Occupancy",
|
"label": "Inpatient Occupancy"
|
||||||
"no_copy": 1
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"bold": 1,
|
"bold": 1,
|
||||||
@ -79,6 +77,7 @@
|
|||||||
"fieldname": "item",
|
"fieldname": "item",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"label": "Item",
|
"label": "Item",
|
||||||
|
"no_copy": 1,
|
||||||
"options": "Item",
|
"options": "Item",
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
@ -86,7 +85,8 @@
|
|||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"label": "Item Code",
|
"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",
|
"fieldname": "item_group",
|
||||||
@ -138,7 +138,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"links": [],
|
"links": [],
|
||||||
"modified": "2020-01-30 16:06:00.624496",
|
"modified": "2020-05-20 15:31:09.627516",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Healthcare",
|
"module": "Healthcare",
|
||||||
"name": "Healthcare Service Unit Type",
|
"name": "Healthcare Service Unit Type",
|
||||||
|
@ -10,6 +10,20 @@ from frappe.model.rename_doc import rename_doc
|
|||||||
|
|
||||||
class HealthcareServiceUnitType(Document):
|
class HealthcareServiceUnitType(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
|
if self.allow_appointments and self.inpatient_occupancy:
|
||||||
|
frappe.msgprint(
|
||||||
|
_('Healthcare Service Unit Type cannot be both <b>Allow Appointments</b> and <b>Inpatient Occupancy</b>'),
|
||||||
|
raise_exception=1, title=_('Validation Error'), indicator='red'
|
||||||
|
)
|
||||||
|
elif not self.allow_appointments and not self.inpatient_occupancy:
|
||||||
|
frappe.msgprint(
|
||||||
|
_('Healthcare Service Unit Type cannot be both <b>Allow Appointments</b> and <b>Inpatient Occupancy</b>'),
|
||||||
|
raise_exception=1, title=_('Validation Error'), indicator='red'
|
||||||
|
)
|
||||||
|
|
||||||
|
if not self.allow_appointments:
|
||||||
|
self.overlap_appointments = 0
|
||||||
|
|
||||||
if self.is_billable:
|
if self.is_billable:
|
||||||
if self.disabled:
|
if self.disabled:
|
||||||
frappe.db.set_value('Item', self.item, 'disabled', 1)
|
frappe.db.set_value('Item', self.item, 'disabled', 1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user