fix: conflicts
diff --git a/erpnext/healthcare/doctype/appointment_type/appointment_type.json b/erpnext/healthcare/doctype/appointment_type/appointment_type.json
index ceabce2..58753bb 100644
--- a/erpnext/healthcare/doctype/appointment_type/appointment_type.json
+++ b/erpnext/healthcare/doctype/appointment_type/appointment_type.json
@@ -1,213 +1,94 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "field:appointment_type", 
- "beta": 1, 
- "creation": "2016-07-22 11:52:34.953019", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Setup", 
- "editable_grid": 0, 
+ "actions": [],
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:appointment_type",
+ "beta": 1,
+ "creation": "2016-07-22 11:52:34.953019",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "engine": "InnoDB",
+ "field_order": [
+  "appointment_type",
+  "ip",
+  "default_duration",
+  "color"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 1, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "appointment_type", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 1, 
+   "allow_in_quick_entry": 1,
+   "fieldname": "appointment_type",
+   "fieldtype": "Data",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Type",
+   "reqd": 1,
+   "translatable": 1,
    "unique": 1
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "ip", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Is Inpatient", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "bold": 1,
+   "default": "0",
+   "fieldname": "ip",
+   "fieldtype": "Check",
+   "label": "Is Inpatient",
+   "print_hide": 1,
+   "report_hide": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 1, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "description": "In Minutes", 
-   "fieldname": "default_duration", 
-   "fieldtype": "Int", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 1, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Default Duration", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "allow_in_quick_entry": 1,
+   "bold": 1,
+   "fieldname": "default_duration",
+   "fieldtype": "Int",
+   "in_filter": 1,
+   "in_list_view": 1,
+   "label": "Default Duration (In Minutes)"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 1, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "color", 
-   "fieldtype": "Color", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Color", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "allow_in_quick_entry": 1,
+   "fieldname": "color",
+   "fieldtype": "Color",
+   "in_list_view": 1,
+   "label": "Color",
+   "no_copy": 1,
+   "report_hide": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-08-08 12:57:54.544216", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Appointment Type", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "links": [],
+ "modified": "2020-02-03 21:06:05.833050",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Appointment Type",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Healthcare Administrator", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Healthcare Administrator",
+   "share": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Physician", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Physician",
+   "share": 1,
    "write": 1
   }
- ], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "search_fields": "appointment_type", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "quick_entry": 1,
+ "restrict_to_domain": "Healthcare",
+ "search_fields": "appointment_type",
+ "sort_field": "modified",
+ "sort_order": "DESC"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py b/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py
new file mode 100644
index 0000000..845e446
--- /dev/null
+++ b/erpnext/healthcare/doctype/appointment_type/appointment_type_dashboard.py
@@ -0,0 +1,13 @@
+from __future__ import unicode_literals
+from frappe import _
+
+def get_data():
+	return {
+		'fieldname': 'appointment_type',
+		'transactions': [
+			{
+				'label': _('Patient Appointments'),
+				'items': ['Patient Appointment']
+			},
+		]
+	}
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
index fa91884..7551083 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
@@ -29,7 +29,7 @@
 	refresh: function(frm) {
 		frm.set_query("patient", function () {
 			return {
-				filters: {"disabled": 0}
+				filters: {"status": ["!=", "Disabled"]}
 			};
 		});
 		frm.set_query("appointment", function () {
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
index 7c6f4d5..510849f 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.py
@@ -174,35 +174,42 @@
 	stock_entry.insert(ignore_permissions = True)
 	stock_entry.submit()
 
-@frappe.whitelist()
-def create_procedure(appointment):
-	appointment = frappe.get_doc("Patient Appointment",appointment)
-	procedure = frappe.new_doc("Clinical Procedure")
-	procedure.appointment = appointment.name
-	procedure.patient = appointment.patient
-	procedure.patient_age = appointment.patient_age
-	procedure.patient_sex = appointment.patient_sex
-	procedure.procedure_template = appointment.procedure_template
-	procedure.prescription = appointment.procedure_prescription
-	procedure.practitioner = appointment.practitioner
-	procedure.invoiced = appointment.invoiced
-	procedure.medical_department = appointment.department
-	procedure.start_date = appointment.appointment_date
-	procedure.start_time = appointment.appointment_time
-	procedure.notes = appointment.notes
-	procedure.service_unit = appointment.service_unit
-	procedure.company = appointment.company
-	consume_stock = frappe.db.get_value("Clinical Procedure Template", appointment.procedure_template, "consume_stock")
-	if consume_stock == 1:
-		procedure.consume_stock = True
-		warehouse = False
-		if appointment.service_unit:
-			warehouse = frappe.db.get_value("Healthcare Service Unit", appointment.service_unit, "warehouse")
-		if not warehouse:
-			warehouse = frappe.db.get_value("Stock Settings", None, "default_warehouse")
-		if warehouse:
-			procedure.warehouse = warehouse
-	return procedure.as_dict()
+def make_procedure(source_name, target_doc=None):
+	def set_missing_values(source, target):
+		consume_stock = frappe.db.get_value("Clinical Procedure Template", source.procedure_template, "consume_stock")
+		if consume_stock:
+			target.consume_stock = 1
+			warehouse = None
+			if source.service_unit:
+				warehouse = frappe.db.get_value("Healthcare Service Unit", source.service_unit, "warehouse")
+			if not warehouse:
+				warehouse = frappe.db.get_value("Stock Settings", None, "default_warehouse")
+			if warehouse:
+				target.warehouse = warehouse
+
+	doc = get_mapped_doc('Patient Appointment', source_name, {
+			'Patient Appointment': {
+				'doctype': 'Clinical Procedure',
+				'field_map': [
+					['appointment', 'name'],
+					['patient', 'patient'],
+					['patient_age', 'patient_age'],
+					['patient_sex', 'patient_sex'],
+					['procedure_template', 'procedure_template'],
+					['prescription', 'procedure_prescription'],
+					['practitioner', 'practitioner'],
+					['medical_department', 'department'],
+					['start_date', 'appointment_date'],
+					['start_time', 'appointment_time'],
+					['notes', 'notes'],
+					['service_unit', 'service_unit'],
+					['company', 'company'],
+					['invoiced', 'invoiced']
+				]
+			}
+		}, target_doc, set_missing_values)
+
+	return doc
 
 def insert_clinical_procedure_to_medical_record(doc):
 	subject = cstr(doc.procedure_template)
diff --git a/erpnext/healthcare/doctype/codification_table/codification_table.json b/erpnext/healthcare/doctype/codification_table/codification_table.json
index e65ae77..9a917b4 100644
--- a/erpnext/healthcare/doctype/codification_table/codification_table.json
+++ b/erpnext/healthcare/doctype/codification_table/codification_table.json
@@ -1,140 +1,56 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 1, 
- "creation": "2017-06-22 13:09:23.159579", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_copy": 1,
+ "beta": 1,
+ "creation": "2017-06-22 13:09:23.159579",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "medical_code",
+  "code",
+  "description"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "medical_code", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Medical Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Medical Code", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0,
-   "unique": 0
-  }, 
+   "fieldname": "medical_code",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Medical Code",
+   "options": "Medical Code",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fetch_from": "medical_code.code",
-   "fieldname": "code", 
-   "fieldtype": "Read Only", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0,
-   "unique": 0
-  }, 
+   "fieldname": "code",
+   "fieldtype": "Data",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Code",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fetch_from": "medical_code.description",
-   "fieldname": "description", 
-   "fieldtype": "Read Only", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0,
-   "unique": 0
+   "fieldname": "description",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Description",
+   "read_only": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2018-05-16 22:43:27.047479",
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Codification Table", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 13:17:49.016293",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Codification Table",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.json b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.json
index 5647d3c..5e4d59c 100644
--- a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.json
+++ b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.json
@@ -1,381 +1,116 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 1, 
- "creation": "2016-09-16 16:41:45.533374", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_copy": 1,
+ "beta": 1,
+ "creation": "2016-09-16 16:41:45.533374",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "drug_code",
+  "drug_name",
+  "dosage",
+  "period",
+  "dosage_form",
+  "column_break_7",
+  "comment",
+  "usage_interval",
+  "interval",
+  "interval_uom",
+  "update_schedule"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "drug_code", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Drug Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "drug_code",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Drug",
+   "options": "Item",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "drug_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Description/Strength", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "drug_code.item_name",
+   "fieldname": "drug_name",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Drug Name / Description"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "dosage", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Dosage", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Prescription Dosage", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "dosage",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Dosage",
+   "options": "Prescription Dosage"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "period", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Period", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Prescription Duration", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "period",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Period",
+   "options": "Prescription Duration"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "dosage_form", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Dosage Form", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Dosage Form", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "dosage_form",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "label": "Dosage Form",
+   "options": "Dosage Form"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_7", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_7",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "comment", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Comment", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "comment",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Comment"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "use_interval", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Dosage by time interval", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "depends_on": "use_interval",
+   "fieldname": "interval",
+   "fieldtype": "Int",
+   "in_list_view": 1,
+   "label": "Interval"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "use_interval", 
-   "fieldname": "interval", 
-   "fieldtype": "Int", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Interval", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "default": "1",
+   "fieldname": "update_schedule",
+   "fieldtype": "Check",
+   "hidden": 1,
+   "label": "Update Schedule",
+   "print_hide": 1,
+   "report_hide": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "use_interval", 
-   "fieldname": "in_every", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Interval UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nHour\nDay", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "depends_on": "use_interval",
+   "fieldname": "interval_uom",
+   "fieldtype": "Select",
+   "in_list_view": 1,
+   "label": "Interval UOM",
+   "options": "\nHour\nDay"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "1", 
-   "fieldname": "update_schedule", 
-   "fieldtype": "Check", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Update Schedule", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
+   "default": "0",
+   "fieldname": "usage_interval",
+   "fieldtype": "Check",
+   "label": "Dosage by Time Interval"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2017-10-04 17:09:54.998517", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Drug Prescription", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 17:02:42.741338",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Drug Prescription",
+ "owner": "Administrator",
+ "permissions": [],
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py
index 0d99198..68a2dc5 100755
--- a/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py
+++ b/erpnext/healthcare/doctype/drug_prescription/drug_prescription.py
@@ -12,21 +12,21 @@
 		dosage = None
 		period = None
 
-		if(self.dosage):
-			dosage = frappe.get_doc("Prescription Dosage",self.dosage)
+		if self.dosage:
+			dosage = frappe.get_doc('Prescription Dosage', self.dosage)
 			for item in dosage.dosage_strength:
 				quantity += item.strength
-			if(self.period and self.interval):
-				period = frappe.get_doc("Prescription Duration",self.period)
-				if(self.interval < period.get_days()):
-					quantity = quantity*(period.get_days()/self.interval)
+			if self.period and self.interval:
+				period = frappe.get_doc('Prescription Duration', self.period)
+				if self.interval < period.get_days():
+					quantity = quantity * (period.get_days()/self.interval)
 
-		elif(self.interval and self.in_every and self.period):
-			period = frappe.get_doc("Prescription Duration",self.period)
-			interval_in = self.in_every
-			if(interval_in == 'Day' and (self.interval < period.get_days())):
+		elif self.interval and self.interval_uom and self.period:
+			period = frappe.get_doc('Prescription Duration', self.period)
+			interval_in = self.interval_uom
+			if interval_in == 'Day' and self.interval < period.get_days():
 				quantity = period.get_days()/self.interval
-			elif(interval_in == 'Hour' and (self.interval < period.get_hours())):
+			elif interval_in == 'Hour' and self.interval < period.get_hours():
 				quantity = period.get_hours()/self.interval
 		if quantity > 0:
 			return quantity
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
index efca484..4ab3b6e 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.js
@@ -4,7 +4,7 @@
 frappe.ui.form.on('Healthcare Practitioner', {
 	setup: function(frm) {
 		frm.set_query('account', 'accounts', function(doc, cdt, cdn) {
-			var d	= locals[cdt][cdn];
+			let d = locals[cdt][cdn];
 			return {
 				filters: {
 					'root_type': 'Income',
@@ -16,23 +16,28 @@
 	},
 	refresh: function(frm) {
 		frappe.dynamic_link = {doc: frm.doc, fieldname: 'name', doctype: 'Healthcare Practitioner'};
-		if(!frm.is_new()) {
+
+		if (!frm.is_new()) {
 			frappe.contacts.render_address_and_contact(frm);
+		} else {
+			frappe.contacts.clear_address_and_contact(frm);
 		}
-		frm.set_query("service_unit", "practitioner_schedules", function(){
+
+		frm.set_query('service_unit', 'practitioner_schedules', function(){
 			return {
 				filters: {
-					"is_group": false,
-					"allow_appointments": true
+					'is_group': false,
+					'allow_appointments': true
 				}
 			};
 		});
+
 		set_query_service_item(frm, 'inpatient_visit_charge_item');
 		set_query_service_item(frm, 'op_consulting_charge_item');
 	}
 });
 
-var set_query_service_item = function(frm, service_item_field) {
+let set_query_service_item = function(frm, service_item_field) {
 	frm.set_query(service_item_field, function() {
 		return {
 			filters: {
@@ -43,62 +48,62 @@
 	});
 };
 
-frappe.ui.form.on("Healthcare Practitioner", "user_id",function(frm) {
-	if(frm.doc.user_id){
+frappe.ui.form.on('Healthcare Practitioner', 'user_id',function(frm) {
+	if (frm.doc.user_id) {
 		frappe.call({
-			"method": "frappe.client.get",
+			'method': 'frappe.client.get',
 			args: {
-				doctype: "User",
+				doctype: 'User',
 				name: frm.doc.user_id
 			},
 			callback: function (data) {
 
 				frappe.model.get_value('Employee', {'user_id': frm.doc.user_id}, 'name',
 					function(data) {
-						if(data){
-							if(!frm.doc.employee || frm.doc.employee != data.name)
-								frappe.model.set_value(frm.doctype,frm.docname, "employee", data.name);
-						}else{
-							frappe.model.set_value(frm.doctype,frm.docname, "employee", "");
+						if (data) {
+							if (!frm.doc.employee || frm.doc.employee != data.name)
+								frappe.model.set_value(frm.doctype, frm.docname, 'employee', data.name);
+						} else {
+							frappe.model.set_value(frm.doctype, frm.docname, 'employee', '');
 						}
 					}
 				);
 
-				if(!frm.doc.first_name || frm.doc.first_name != data.message.first_name)
-					frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.first_name);
-				if(!frm.doc.middle_name || frm.doc.middle_name != data.message.middle_name)
-					frappe.model.set_value(frm.doctype,frm.docname, "middle_name", data.message.middle_name);
-				if(!frm.doc.last_name || frm.doc.last_name != data.message.last_name)
-					frappe.model.set_value(frm.doctype,frm.docname, "last_name", data.message.last_name);
-				if(!frm.doc.mobile_phone || frm.doc.mobile_phone != data.message.mobile_no)
-					frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.mobile_no);
+				if (!frm.doc.first_name || frm.doc.first_name != data.message.first_name)
+					frappe.model.set_value(frm.doctype,frm.docname, 'first_name', data.message.first_name);
+				if (!frm.doc.middle_name || frm.doc.middle_name != data.message.middle_name)
+					frappe.model.set_value(frm.doctype,frm.docname, 'middle_name', data.message.middle_name);
+				if (!frm.doc.last_name || frm.doc.last_name != data.message.last_name)
+					frappe.model.set_value(frm.doctype,frm.docname, 'last_name', data.message.last_name);
+				if (!frm.doc.mobile_phone || frm.doc.mobile_phone != data.message.mobile_no)
+					frappe.model.set_value(frm.doctype,frm.docname, 'mobile_phone', data.message.mobile_no);
 			}
 		});
 	}
 });
 
-frappe.ui.form.on("Healthcare Practitioner", "employee", function(frm) {
-	if(frm.doc.employee){
+frappe.ui.form.on('Healthcare Practitioner', 'employee', function(frm) {
+	if (frm.doc.employee){
 		frappe.call({
-			"method": "frappe.client.get",
+			'method': 'frappe.client.get',
 			args: {
-				doctype: "Employee",
+				doctype: 'Employee',
 				name: frm.doc.employee
 			},
 			callback: function (data) {
-				if(!frm.doc.user_id || frm.doc.user_id != data.message.user_id)
-					frm.set_value("user_id", data.message.user_id);
-				if(!frm.doc.designation || frm.doc.designation != data.message.designation)
-					frappe.model.set_value(frm.doctype,frm.docname, "designation", data.message.designation);
-				if(!frm.doc.first_name || !frm.doc.user_id){
-					frappe.model.set_value(frm.doctype,frm.docname, "first_name", data.message.employee_name);
-					frappe.model.set_value(frm.doctype,frm.docname, "middle_name", "");
-					frappe.model.set_value(frm.doctype,frm.docname, "last_name", "");
+				if (!frm.doc.user_id || frm.doc.user_id != data.message.user_id)
+					frm.set_value('user_id', data.message.user_id);
+				if (!frm.doc.designation || frm.doc.designation != data.message.designation)
+					frappe.model.set_value(frm.doctype,frm.docname, 'designation', data.message.designation);
+				if (!frm.doc.first_name || !frm.doc.user_id){
+					frappe.model.set_value(frm.doctype,frm.docname, 'first_name', data.message.first_name);
+					frappe.model.set_value(frm.doctype,frm.docname, 'middle_name', '');
+					frappe.model.set_value(frm.doctype,frm.docname, 'last_name', data.message.last_name);
 				}
-				if(!frm.doc.mobile_phone || !frm.doc.user_id)
-					frappe.model.set_value(frm.doctype,frm.docname, "mobile_phone", data.message.cell_number);
-				if(!frm.doc.address || frm.doc.address != data.message.current_address)
-					frappe.model.set_value(frm.doctype,frm.docname, "address", data.message.current_address);
+				if (!frm.doc.mobile_phone || !frm.doc.user_id)
+					frappe.model.set_value(frm.doctype,frm.docname, 'mobile_phone', data.message.cell_number);
+				if (!frm.doc.address || frm.doc.address != data.message.current_address)
+					frappe.model.set_value(frm.doctype,frm.docname, 'address', data.message.current_address);
 			}
 		});
 	}
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
index 4a848a0..51db233 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.json
@@ -1,1041 +1,329 @@
 {
+ "actions": [],
  "allow_copy": 1,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
  "allow_import": 1,
  "allow_rename": 1,
- "autoname": "",
+ "autoname": "naming_series:",
  "beta": 1,
  "creation": "2016-02-23 11:20:53.565119",
- "custom": 0,
- "docstatus": 0,
  "doctype": "DocType",
  "document_type": "Setup",
- "editable_grid": 0,
+ "engine": "InnoDB",
+ "field_order": [
+  "basic_details_section",
+  "naming_series",
+  "first_name",
+  "middle_name",
+  "last_name",
+  "practitioner_name",
+  "gender",
+  "image",
+  "column_break_7",
+  "status",
+  "mobile_phone",
+  "residence_phone",
+  "office_phone",
+  "employee_and_user_details_section",
+  "employee",
+  "department",
+  "designation",
+  "column_break_17",
+  "user_id",
+  "hospital",
+  "appointments",
+  "practitioner_schedules",
+  "charges",
+  "op_consulting_charge_item",
+  "op_consulting_charge",
+  "column_break_18",
+  "inpatient_visit_charge_item",
+  "inpatient_visit_charge",
+  "address_and_contacts_section",
+  "address_html",
+  "column_break_19",
+  "contact_html",
+  "account_details",
+  "accounts",
+  "default_currency"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "first_name",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 1,
    "label": "First Name",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "middle_name",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Middle Name (Optional)",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Middle Name (Optional)"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "last_name",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Last Name",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "reqd": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "image",
    "fieldtype": "Attach Image",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Image",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "print_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "employee",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Employee",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Employee",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Employee"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "user_id",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "User",
-   "length": 0,
-   "no_copy": 0,
    "options": "User",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "fetch_from": "employee",
    "fieldname": "designation",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Designation",
-   "length": 0,
-   "no_copy": 0,
    "options": "Designation",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "department",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
    "in_standard_filter": 1,
-   "label": "Department",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Medical Department",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Medical Department",
+   "options": "Medical Department"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_7",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "hospital",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Hospital",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Hospital"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "mobile_phone",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Mobile",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Mobile"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "residence_phone",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Phone (R)",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Phone (R)"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "office_phone",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Phone (Office)",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Phone (Office)"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "1",
-   "fieldname": "active",
-   "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Active",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
-  },
-  {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "collapsible": 1,
    "fieldname": "appointments",
    "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Appointments",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Appointments"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "practitioner_schedules",
    "fieldtype": "Table",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Practitioner Schedules",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Practitioner Service Unit Schedule",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Practitioner Service Unit Schedule"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "collapsible": 1,
    "fieldname": "charges",
    "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Charges",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Charges"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "op_consulting_charge_item",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Out Patient Consulting Charge Item",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Item",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Item"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "op_consulting_charge",
    "fieldtype": "Currency",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "OP Consulting Charge",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Currency",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Out Patient Consulting Charge",
+   "options": "Currency"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_18",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "inpatient_visit_charge_item",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Inpatient Visit Charge Item",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Item",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Item"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "inpatient_visit_charge",
    "fieldtype": "Currency",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Inpatient Visit Charge",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Inpatient Visit Charge"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "contacts_and_address",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Contacts and Address",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
-  },
-  {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "depends_on": "eval: !doc.__islocal",
    "fieldname": "address_html",
    "fieldtype": "HTML",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Address HTML",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_19",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "depends_on": "eval: !doc.__islocal",
    "fieldname": "contact_html",
    "fieldtype": "HTML",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Contact HTML",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "collapsible": 1,
    "fieldname": "account_details",
    "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Account Details",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Account Details"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "accounts",
    "fieldtype": "Table",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Income Account",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Party Account",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Party Account"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "default_currency",
    "fieldtype": "Link",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Default Currency",
-   "length": 0,
    "no_copy": 1,
    "options": "Currency",
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
+   "report_hide": 1
+  },
+  {
+   "bold": 1,
+   "fieldname": "practitioner_name",
+   "fieldtype": "Data",
+   "in_global_search": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Full Name",
+   "read_only": 1,
+   "search_index": 1
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "options": "HLC-PRAC-.YYYY.-",
    "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
+  },
+  {
+   "fieldname": "gender",
+   "fieldtype": "Link",
+   "label": "Gender",
+   "options": "Gender",
+   "reqd": 1
+  },
+  {
+   "fieldname": "employee_and_user_details_section",
+   "fieldtype": "Section Break",
+   "label": "Employee and User Details"
+  },
+  {
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break"
+  },
+  {
+   "default": "Active",
+   "fieldname": "status",
+   "fieldtype": "Select",
+   "in_list_view": 1,
+   "label": "Status",
+   "options": "\nActive\nDisabled",
+   "reqd": 1
+  },
+  {
+   "fieldname": "basic_details_section",
+   "fieldtype": "Section Break",
+   "label": "Basic Details"
+  },
+  {
+   "collapsible": 1,
+   "depends_on": "eval: !doc.__islocal",
+   "fieldname": "address_and_contacts_section",
+   "fieldtype": "Section Break",
+   "label": "Address and Contacts"
   }
  ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
  "image_field": "image",
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-11-23 08:54:51.442105",
+ "links": [],
+ "modified": "2020-02-01 00:39:49.455988",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Healthcare Practitioner",
- "name_case": "",
  "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
-   "delete": 0,
    "email": 1,
-   "export": 0,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Laboratory User",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Physician",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Nursing User",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   }
  ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
  "restrict_to_domain": "Healthcare",
- "search_fields": "first_name,mobile_phone,office_phone",
+ "search_fields": "practitioner_name, mobile_phone, office_phone",
  "show_name_in_global_search": 1,
  "sort_field": "modified",
  "sort_order": "DESC",
- "title_field": "first_name",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ "title_field": "practitioner_name",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py
index ad32e94..a5a675f 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner.py
@@ -9,6 +9,7 @@
 from frappe.utils import cstr
 from erpnext.accounts.party import validate_party_accounts
 from frappe.contacts.address_and_contact import load_address_and_contact, delete_contact_and_address
+from frappe.model.naming import append_number_if_name_exists
 from frappe.desk.reportview import build_match_conditions, get_filters_cond
 
 class HealthcarePractitioner(Document):
@@ -16,63 +17,63 @@
 		load_address_and_contact(self)
 
 	def autoname(self):
-		# practitioner first_name and last_name
-		self.name = " ".join(filter(None,
-			[cstr(self.get(f)).strip() for f in ["first_name","middle_name","last_name"]]))
+		# concat first and last name
+		self.name = self.practitioner_name
+
+		if frappe.db.exists('Healthcare Practitioner', self.name):
+			self.name = append_number_if_name_exists('Contact', self.name)
 
 	def validate(self):
+		self.set_full_name()
 		validate_party_accounts(self)
 		if self.inpatient_visit_charge_item:
-			validate_service_item(self.inpatient_visit_charge_item, "Configure a service Item for Inpatient Visit Charge Item")
+			validate_service_item(self.inpatient_visit_charge_item, 'Configure a service Item for Inpatient Consulting Charge Item')
 		if self.op_consulting_charge_item:
-			validate_service_item(self.op_consulting_charge_item, "Configure a service Item for Out Patient Consulting Charge Item")
+			validate_service_item(self.op_consulting_charge_item, 'Configure a service Item for Out Patient Consulting Charge Item')
 
 		if self.user_id:
-			self.validate_for_enabled_user_id()
-			self.validate_duplicate_user_id()
-			existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id")
-			if self.user_id != existing_user_id:
-				frappe.permissions.remove_user_permission(
-					"Healthcare Practitioner", self.name, existing_user_id)
-
+			self.validate_user_id()
 		else:
-			existing_user_id = frappe.db.get_value("Healthcare Practitioner", self.name, "user_id")
+			existing_user_id = frappe.db.get_value('Healthcare Practitioner', self.name, 'user_id')
 			if existing_user_id:
 				frappe.permissions.remove_user_permission(
-					"Healthcare Practitioner", self.name, existing_user_id)
+					'Healthcare Practitioner', self.name, existing_user_id)
 
 	def on_update(self):
 		if self.user_id:
-			frappe.permissions.add_user_permission("Healthcare Practitioner", self.name, self.user_id)
+			frappe.permissions.add_user_permission('Healthcare Practitioner', self.name, self.user_id)
 
+	def set_full_name(self):
+		self.practitioner_name = ' '.join(filter(None, [self.first_name, self.last_name]))
 
-	def validate_for_enabled_user_id(self):
-		enabled = frappe.db.get_value("User", self.user_id, "enabled")
-		if enabled is None:
-			frappe.throw(_("User {0} does not exist").format(self.user_id))
-		if enabled == 0:
-			frappe.throw(_("User {0} is disabled").format(self.user_id))
+	def validate_user_id(self):
+		if not frappe.db.exists('User', self.user_id):
+			frappe.throw(_('User {0} does not exist').format(self.user_id))
+		elif not frappe.db.exists('User', self.user_id, 'enabled'):
+			frappe.throw(_('User {0} is disabled').format(self.user_id))
 
-	def validate_duplicate_user_id(self):
-		practitioner = frappe.db.sql_list("""select name from `tabHealthcare Practitioner` where
-			user_id=%s and name!=%s""", (self.user_id, self.name))
+		# check duplicate
+		practitioner = frappe.db.exists('Healthcare Practitioner', {
+			'user_id': self.user_id,
+			'name': ('!=', self.name)
+		})
 		if practitioner:
-			throw(_("User {0} is already assigned to Healthcare Practitioner {1}").format(
-				self.user_id, practitioner[0]), frappe.DuplicateEntryError)
+			frappe.throw(_('User {0} is already assigned to Healthcare Practitioner {1}').format(
+				self.user_id, practitioner))
 
 	def on_trash(self):
 		delete_contact_and_address('Healthcare Practitioner', self.name)
 
 def validate_service_item(item, msg):
-	if frappe.db.get_value("Item", item, "is_stock_item") == 1:
+	if frappe.db.get_value('Item', item, 'is_stock_item'):
 		frappe.throw(_(msg))
 
 def get_practitioner_list(doctype, txt, searchfield, start, page_len, filters=None):
-	fields = ["name", "first_name", "mobile_phone"]
+	fields = ['name', 'practitioner_name', 'mobile_phone']
 
 	filters = {
-		'name': ("like", "%%%s%%" % txt)
+		'name': ('like', '%%%s%%' % txt)
 	}
 
-	return frappe.get_all("Healthcare Practitioner", fields = fields,
-		filters = filters, start=start, page_length=page_len, order_by="name, first_name", as_list=1)
+	return frappe.get_all('Healthcare Practitioner', fields = fields,
+		filters = filters, start=start, page_length=page_len, order_by='name, practitioner_name', as_list=1)
diff --git a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py
index 70c0b3c..bcee444 100644
--- a/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py
+++ b/erpnext/healthcare/doctype/healthcare_practitioner/healthcare_practitioner_dashboard.py
@@ -9,7 +9,11 @@
 		'transactions': [
 			{
 				'label': _('Appointments and Patient Encounters'),
-				'items': ['Patient Appointment', 'Patient Encounter']
+				'items': ['Patient Appointment', 'Patient Encounter', 'Fee Validity']
+			},
+			{
+				'label': _('Consultation'),
+				'items': ['Clinical Procedure', 'Lab Test']
 			}
 		]
 	}
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js
index 8480a52..2cdd550 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.js
@@ -3,7 +3,7 @@
 
 frappe.ui.form.on('Healthcare Service Unit', {
 	onload: function(frm) {
-		frm.list_route = "Tree/Healthcare Service Unit";
+		frm.list_route = 'Tree/Healthcare Service Unit';
 
 		// get query select healthcare service unit
 		frm.fields_dict['parent_healthcare_service_unit'].get_query = function(doc) {
@@ -16,32 +16,32 @@
 		};
 	},
 	refresh: function(frm) {
-		frm.trigger("set_root_readonly");
-		frm.set_df_property("service_unit_type", "reqd", 1);
-		frm.add_custom_button(__("Healthcare Service Unit Tree"), function() {
-			frappe.set_route("Tree", "Healthcare Service Unit");
+		frm.trigger('set_root_readonly');
+		frm.set_df_property('service_unit_type', 'reqd', 1);
+		frm.add_custom_button(__('Healthcare Service Unit Tree'), function() {
+			frappe.set_route('Tree', 'Healthcare Service Unit');
 		});
 	},
 	set_root_readonly: function(frm) {
 		// read-only for root healthcare service unit
-		frm.set_intro("");
-		if(!frm.doc.parent_healthcare_service_unit) {
+		frm.set_intro('');
+		if (!frm.doc.parent_healthcare_service_unit) {
 			frm.set_read_only();
-			frm.set_intro(__("This is a root healthcare service unit and cannot be edited."), true);
+			frm.set_intro(__('This is a root healthcare service unit and cannot be edited.'), true);
 		}
 	},
 	allow_appointments: function(frm) {
-		if(!frm.doc.allow_appointments){
-			frm.set_value("overlap_appointments", false);
+		if (!frm.doc.allow_appointments) {
+			frm.set_value('overlap_appointments', false);
 		}
 	},
 	is_group: function(frm) {
-		if(frm.doc.is_group == 1){
-			frm.set_value("allow_appointments", false);
-			frm.set_df_property("service_unit_type", "reqd", 0);
+		if (frm.doc.is_group == 1) {
+			frm.set_value('allow_appointments', false);
+			frm.set_df_property('service_unit_type', 'reqd', 0);
 		}
-		else{
-			frm.set_df_property("service_unit_type", "reqd", 1);
+		else {
+			frm.set_df_property('service_unit_type', 'reqd', 1);
 		}
 	}
 });
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
index 6e92455..56f05c6 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.json
@@ -1,542 +1,209 @@
 {
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
+ "actions": [],
  "allow_import": 1,
  "allow_rename": 1,
  "autoname": "field:healthcare_service_unit_name",
  "beta": 1,
  "creation": "2016-09-21 13:48:14.731437",
- "custom": 0,
  "description": "Healthcare Service Unit",
- "docstatus": 0,
  "doctype": "DocType",
  "document_type": "Setup",
  "editable_grid": 1,
+ "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",
+  "lft",
+  "rgt",
+  "old_parent"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "healthcare_service_unit_name",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
    "in_global_search": 1,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Service Unit",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
    "reqd": 1,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
    "unique": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "parent_healthcare_service_unit",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Parent Service Unit",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Healthcare Service Unit",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Healthcare Service Unit"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
    "depends_on": "eval:doc.inpatient_occupancy != 1 && doc.allow_appointments != 1",
    "fieldname": "is_group",
    "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
-   "label": "Is Group",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Is Group"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "depends_on": "eval:doc.is_group != 1",
    "fieldname": "service_unit_type",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Service Unit Type",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Healthcare Service Unit Type",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Healthcare Service Unit Type"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "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",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Allow Appointments",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
    "depends_on": "eval:doc.is_group != 1 && doc.allow_appointments == 1 && doc.inpatient_occupany != 1",
    "fetch_from": "service_unit_type.overlap_appointments",
    "fieldname": "overlap_appointments",
    "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Allow Overlap",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
    "depends_on": "eval:doc.allow_appointments != 1 && doc.is_group != 1",
    "fetch_from": "service_unit_type.inpatient_occupancy",
    "fieldname": "inpatient_occupancy",
    "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Inpatient Occupancy",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "",
    "depends_on": "eval:doc.inpatient_occupancy == 1",
    "fieldname": "occupancy_status",
    "fieldtype": "Select",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Occupancy Status",
-   "length": 0,
    "no_copy": 1,
    "options": "Vacant\nOccupied",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
    "bold": 1,
-   "collapsible": 0,
-   "columns": 0,
    "depends_on": "eval:doc.is_group != 1",
    "fieldname": "warehouse",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Warehouse",
-   "length": 0,
    "no_copy": 1,
-   "options": "Warehouse",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Warehouse"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "company",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Company",
-   "length": 0,
-   "no_copy": 0,
    "options": "Company",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
    "remember_last_selected_value": 1,
-   "report_hide": 0,
    "reqd": 1,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "lft",
    "fieldtype": "Int",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "lft",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "rgt",
    "fieldtype": "Int",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "rgt",
-   "length": 0,
    "no_copy": 1,
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "old_parent",
    "fieldtype": "Link",
    "hidden": 1,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Old Parent",
-   "length": 0,
    "no_copy": 1,
    "options": "Healthcare Service Unit",
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
+  },
+  {
+   "fieldname": "column_break_9",
+   "fieldtype": "Column Break"
   }
  ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-10-04 21:09:52.261882",
+ "links": [],
+ "modified": "2020-01-30 18:03:29.031351",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Healthcare Service Unit",
- "name_case": "",
  "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0,
-   "cancel": 0,
-   "create": 0,
-   "delete": 0,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Nursing User",
-   "set_user_permissions": 0,
-   "share": 1,
-   "submit": 0,
-   "write": 0
+   "share": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Healthcare Administrator",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
-   "delete": 0,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Physician",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   }
  ],
  "quick_entry": 1,
- "read_only": 0,
- "read_only_onload": 0,
  "restrict_to_domain": "Healthcare",
  "search_fields": "healthcare_service_unit_name",
- "show_name_in_global_search": 0,
  "sort_field": "modified",
  "sort_order": "DESC",
  "title_field": "healthcare_service_unit_name",
- "track_changes": 1,
- "track_seen": 0,
- "track_views": 0
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
index b408693..13cc43d 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
+++ b/erpnext/healthcare/doctype/healthcare_service_unit/healthcare_service_unit.py
@@ -23,9 +23,9 @@
 		self.validate_one_root()
 
 	def validate(self):
-		if self.is_group == 1:
+		if self.is_group:
 			self.allow_appointments = 0
 			self.overlap_appointments = 0
 			self.inpatient_occupancy = 0
-		elif self.allow_appointments != 1:
+		elif not self.allow_appointments:
 			self.overlap_appointments = 0
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js
index 288ebc4..f5e8a6f 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js
+++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.js
@@ -2,118 +2,84 @@
 // For license information, please see license.txt
 
 frappe.ui.form.on('Healthcare Service Unit Type', {
+	refresh: function(frm) {
+		frm.set_df_property('item_code', 'read_only', frm.doc.__islocal ? 0 : 1);
+		if (!frm.doc.__islocal) {
+			frm.add_custom_button(__('Change Item Code'), function() {
+				change_item_code(cur_frm, frm.doc);
+			});
+		}
+	},
+
 	service_unit_type: function(frm) {
 		set_item_details(frm);
-		if(!frm.doc.__islocal){
+
+		if (!frm.doc.__islocal) {
 			frm.doc.change_in_item = 1;
 		}
 	},
+
 	is_billable: function(frm) {
 		set_item_details(frm);
 	},
-	refresh: function(frm) {
-		frm.set_df_property("item_code", "read_only", frm.doc.__islocal ? 0 : 1);
-		if(!frm.doc.__islocal) {
-			frm.add_custom_button(__('Change Item Code'), function() {
-				change_item_code(cur_frm,frm.doc);
-			} );
-			if(frm.doc.disabled == 1){
-				frm.add_custom_button(__('Enable'), function() {
-					enable(cur_frm);
-				} );
-			}
-			else{
-				frm.add_custom_button(__('Disable'), function() {
-					disable(cur_frm);
-				} );
-			}
-		}
-	},
+
 	rate: function(frm) {
-		if(!frm.doc.__islocal){
+		if (!frm.doc.__islocal) {
 			frm.doc.change_in_item = 1;
 		}
 	},
 	item_group: function(frm) {
-		if(!frm.doc.__islocal){
+		if (!frm.doc.__islocal) {
 			frm.doc.change_in_item = 1;
 		}
 	},
 	description: function(frm) {
-		if(!frm.doc.__islocal){
+		if (!frm.doc.__islocal) {
 			frm.doc.change_in_item = 1;
 		}
 	}
 });
 
-var disable = function(frm){
-	var doc = frm.doc;
-	frappe.call({
-		method: "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.disable_enable",
-		args: {status: 1, doc_name: doc.name, item: doc.item, is_billable: doc.is_billable},
-		callback: function(){
-			cur_frm.reload_doc();
-		}
-	});
+let set_item_details = function(frm) {
+	if (frm.doc.service_unit_type && frm.doc.is_billable) {
+		if (!frm.doc.item_code)
+			frm.set_value('item_code', frm.doc.service_unit_type);
+		if (!frm.doc.description)
+			frm.set_value('description', frm.doc.service_unit_type);
+		if (!frm.doc.item_group)
+			frm.set_value('item_group', 'Services');
+	}
 };
 
-var enable = function(frm){
-	var doc = frm.doc;
-	frappe.call({
-		method: "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.disable_enable",
-		args: {status: 0, doc_name: doc.name, item: doc.item, is_billable: doc.is_billable},
-		callback: function(){
-			cur_frm.reload_doc();
-		}
-	});
-};
-
-var change_item_code = function(frm, doc){
-	var d = new frappe.ui.Dialog({
-		title:__("Change Item Code"),
-		fields:[
+let change_item_code = function(frm, doc) {
+	let d = new frappe.ui.Dialog({
+		title: __('Change Item Code'),
+		fields: [
 			{
-				"fieldtype": "Data",
-				"label": "Item Code",
-				"fieldname": "Item Code",
-				reqd:1
-			},
-			{
-				"fieldtype": "Button",
-				"label": __("Change Code"),
-				click: function() {
-					var values = d.get_values();
-					if(!values)
-						return;
-					change_item_code_from_unit_type(values["Item Code"], doc);
-					d.hide();
-				}
+				'fieldtype': 'Data',
+				'label': 'Item Code',
+				'fieldname': 'item_code',
+				reqd: 1
 			}
-		]
+		],
+		primary_action: function() {
+			let values = d.get_values();
+			if (values) {
+				frappe.call({
+					"method": "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.change_item_code",
+					"args": {item: doc.item, item_code: values['item_code'], doc_name: doc.name},
+					callback: function () {
+						frm.reload_doc();
+					}
+				});
+			}
+			d.hide();
+		},
+		primary_action_label: __("Change Template Code")
 	});
+
 	d.show();
 	d.set_values({
 		'Item Code': frm.doc.item_code
 	});
-
-	var change_item_code_from_unit_type = function(item_code, doc){
-		frappe.call({
-			"method": "erpnext.healthcare.doctype.healthcare_service_unit_type.healthcare_service_unit_type.change_item_code",
-			"args": {item: doc.item, item_code: item_code, doc_name: doc.name},
-			callback: function () {
-				frm.reload_doc();
-			}
-		});
-	};
-};
-
-var set_item_details = function(frm) {
-	if(frm.doc.service_unit_type && frm.doc.is_billable == 1){
-		if(!frm.doc.item_code)
-			frm.set_value("item_code", frm.doc.service_unit_type);
-		if(!frm.doc.description)
-			frm.set_value("description", frm.doc.service_unit_type);
-		if(!frm.doc.item_group)
-			frm.set_value("item_group", 'Services');
-	}
 };
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
index 40681e9..5fa47d9 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
+++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.json
@@ -1,588 +1,164 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "field:service_unit_type", 
- "beta": 0, 
- "creation": "2018-07-11 16:47:51.414675", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:service_unit_type",
+ "creation": "2018-07-11 16:47:51.414675",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "disabled",
+  "service_unit_type",
+  "allow_appointments",
+  "overlap_appointments",
+  "inpatient_occupancy",
+  "is_billable",
+  "item_details",
+  "item",
+  "item_code",
+  "item_group",
+  "uom",
+  "no_of_hours",
+  "column_break_11",
+  "rate",
+  "description",
+  "change_in_item"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "service_unit_type", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Service Unit Type", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
+   "fieldname": "service_unit_type",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Service Unit Type",
+   "reqd": 1,
    "unique": 1
-  }, 
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "depends_on": "eval:doc.inpatient_occupancy != 1", 
-   "fieldname": "allow_appointments", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Allow Appointments", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "bold": 1,
+   "default": "0",
+   "depends_on": "eval:doc.inpatient_occupancy != 1",
+   "fieldname": "allow_appointments",
+   "fieldtype": "Check",
+   "label": "Allow Appointments",
+   "no_copy": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "depends_on": "eval:doc.allow_appointments == 1 && doc.inpatient_occupany != 1", 
-   "fieldname": "overlap_appointments", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Allow Overlap", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "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
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "depends_on": "eval:doc.allow_appointments != 1", 
-   "fieldname": "inpatient_occupancy", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Inpatient Occupancy", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "bold": 1,
+   "default": "0",
+   "depends_on": "eval:doc.allow_appointments != 1",
+   "fieldname": "inpatient_occupancy",
+   "fieldtype": "Check",
+   "label": "Inpatient Occupancy",
+   "no_copy": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "eval:doc.inpatient_occupancy == 1 && doc.allow_appointments != 1", 
-   "fieldname": "is_billable", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Is Billable", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "bold": 1,
+   "default": "0",
+   "depends_on": "eval:doc.inpatient_occupancy == 1 && doc.allow_appointments != 1",
+   "fieldname": "is_billable",
+   "fieldtype": "Check",
+   "label": "Is Billable"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "is_billable", 
-   "fieldname": "item_details", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Item Details", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "depends_on": "is_billable",
+   "fieldname": "item_details",
+   "fieldtype": "Section Break",
+   "label": "Item Details"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Item", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item",
+   "fieldtype": "Link",
+   "label": "Item",
+   "options": "Item",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item_code", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Item Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item_code",
+   "fieldtype": "Data",
+   "label": "Item Code",
+   "mandatory_depends_on": "eval: doc.is_billable == 1"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "item_group", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Item Group", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Item Group", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "item_group",
+   "fieldtype": "Link",
+   "label": "Item Group",
+   "mandatory_depends_on": "eval: doc.is_billable == 1",
+   "options": "Item Group"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "uom", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "UOM", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "uom",
+   "fieldtype": "Link",
+   "label": "UOM",
+   "mandatory_depends_on": "eval: doc.is_billable == 1",
+   "options": "UOM"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "no_of_hours", 
-   "fieldtype": "Int", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "UOM Conversion in Hours", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "no_of_hours",
+   "fieldtype": "Int",
+   "label": "UOM Conversion in Hours",
+   "mandatory_depends_on": "eval: doc.is_billable == 1"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_11", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_11",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "rate", 
-   "fieldtype": "Currency", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Rate / UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "rate",
+   "fieldtype": "Currency",
+   "label": "Rate / UOM"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "disabled", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Disabled", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "disabled",
+   "fieldtype": "Check",
+   "label": "Disabled",
+   "no_copy": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "description", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "description",
+   "fieldtype": "Small Text",
+   "label": "Description"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "change_in_item", 
-   "fieldtype": "Check", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Change in Item", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "default": "0",
+   "fieldname": "change_in_item",
+   "fieldtype": "Check",
+   "hidden": 1,
+   "label": "Change in Item"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-08-08 13:00:23.751635", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Healthcare Service Unit Type", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "links": [],
+ "modified": "2020-01-30 16:06:00.624496",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Healthcare Service Unit Type",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Healthcare Administrator", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Healthcare Administrator",
+   "share": 1,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "service_unit_type", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "service_unit_type"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py
index 43f01c8..49d06d5 100644
--- a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py
+++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type.py
@@ -10,109 +10,107 @@
 
 class HealthcareServiceUnitType(Document):
 	def validate(self):
-		if self.is_billable == 1:
-			if not self.uom or not self.item_group or not self.description or not self.no_of_hours > 0:
-				frappe.throw(_("Configure Item Fields like UOM, Item Group, Description and No of Hours."))
+		if self.is_billable:
+			if self.disabled:
+				frappe.db.set_value('Item', self.item, 'disabled', 1)
+			else:
+				frappe.db.set_value('Item', self.item, 'disabled', 0)
 
 	def after_insert(self):
 		if self.inpatient_occupancy and self.is_billable:
 			create_item(self)
 
 	def on_trash(self):
-		if(self.item):
+		if self.item:
 			try:
-				frappe.delete_doc("Item",self.item)
+				frappe.delete_doc('Item', self.item)
 			except Exception:
-				frappe.throw(_("""Not permitted. Please disable the Service Unit Type"""))
+				frappe.throw(_('Not permitted. Please disable the Service Unit Type'))
 
 	def on_update(self):
-		if(self.change_in_item and self.is_billable == 1 and self.item):
-			updating_item(self)
-			item_price = item_price_exist(self)
-			if not item_price:
-				if(self.rate != 0.0):
-					price_list_name = frappe.db.get_value("Price List", {"selling": 1})
-					if(self.rate):
-						make_item_price(self.item_code, price_list_name, self.rate)
-					else:
-						make_item_price(self.item_code, price_list_name, 0.0)
-			else:
-				frappe.db.set_value("Item Price", item_price, "price_list_rate", self.rate)
+		if self.change_in_item and self.is_billable and self.item:
+			update_item(self)
 
-			frappe.db.set_value(self.doctype,self.name,"change_in_item",0)
-		elif(self.is_billable == 0 and self.item):
-			frappe.db.set_value("Item",self.item,"disabled",1)
+			item_price = item_price_exists(self)
+
+			if not item_price:
+				price_list_name = frappe.db.get_value('Price List', {'selling': 1})
+				if self.rate:
+					make_item_price(self.item_code, price_list_name, self.rate)
+				else:
+					make_item_price(self.item_code, price_list_name, 0.0)
+			else:
+				frappe.db.set_value('Item Price', item_price, 'price_list_rate', self.rate)
+
+			frappe.db.set_value(self.doctype, self.name, 'change_in_item',0)
+		elif not self.is_billable and self.item:
+			frappe.db.set_value('Item', self.item, 'disabled', 1)
 		self.reload()
 
-def item_price_exist(doc):
-	item_price = frappe.db.exists({
-	"doctype": "Item Price",
-	"item_code": doc.item_code})
-	if(item_price):
-		return item_price[0][0]
-	else:
-		return False
 
-def updating_item(doc):
-	frappe.db.sql("""update `tabItem` set item_name=%s, item_group=%s, disabled=0, standard_rate=%s,
-		description=%s, modified=NOW() where item_code=%s""",
-		(doc.service_unit_type, doc.item_group , doc.rate, doc.description, doc.item))
+def item_price_exists(doc):
+	if frappe.db.exists({'doctype': 'Item Price', 'item_code': doc.item_code}):
+		return item_price[0][0]
+	return False
 
 def create_item(doc):
-	#insert item
+	# insert item
 	item =  frappe.get_doc({
-	"doctype": "Item",
-	"item_code": doc.item_code,
-	"item_name":doc.service_unit_type,
-	"item_group": doc.item_group,
-	"description":doc.description,
-	"is_sales_item": 1,
-	"is_service_item": 1,
-	"is_purchase_item": 0,
-	"is_stock_item": 0,
-	"show_in_website": 0,
-	"is_pro_applicable": 0,
-	"disabled": 0,
-	"stock_uom": doc.uom
+		'doctype': 'Item',
+		'item_code': doc.item_code,
+		'item_name': doc.service_unit_type,
+		'item_group': doc.item_group,
+		'description': doc.description or doc.item_code,
+		'is_sales_item': 1,
+		'is_service_item': 1,
+		'is_purchase_item': 0,
+		'is_stock_item': 0,
+		'show_in_website': 0,
+		'is_pro_applicable': 0,
+		'disabled': 0,
+		'stock_uom': doc.uom
 	}).insert(ignore_permissions=True)
 
-	#insert item price
-	#get item price list to insert item price
-	if(doc.rate != 0.0):
-		price_list_name = frappe.db.get_value("Price List", {"selling": 1})
-		if(doc.rate):
-			make_item_price(item.name, price_list_name, doc.rate)
-			item.standard_rate = doc.rate
-		else:
-			make_item_price(item.name, price_list_name, 0.0)
-			item.standard_rate = 0.0
-	item.save(ignore_permissions = True)
-	#Set item to the Doc
-	frappe.db.set_value("Healthcare Service Unit Type", doc.name, "item", item.name)
+	# insert item price
+	# get item price list to insert item price
+	price_list_name = frappe.db.get_value('Price List', {'selling': 1})
+	if doc.rate:
+		make_item_price(item.name, price_list_name, doc.rate)
+		item.standard_rate = doc.rate
+	else:
+		make_item_price(item.name, price_list_name, 0.0)
+		item.standard_rate = 0.0
 
-	doc.reload() #refresh the doc after insert.
+	item.save(ignore_permissions=True)
+	# Set item in the doc
+	frappe.db.set_value('Healthcare Service Unit Type', doc.name, 'item', item.name)
+
+	doc.reload()
 
 def make_item_price(item, price_list_name, item_price):
 	frappe.get_doc({
-		"doctype": "Item Price",
-		"price_list": price_list_name,
-		"item_code": item,
-		"price_list_rate": item_price
+		'doctype': 'Item Price',
+		'price_list': price_list_name,
+		'item_code': item,
+		'price_list_rate': item_price
 	}).insert(ignore_permissions=True)
 
+def update_item(doc):
+	item = frappe.get_doc("Item", doc.item)
+	if item:
+		item.update({
+			"item_name": doc.service_unit_type,
+			"item_group": doc.item_group,
+			"disabled": 0,
+			"standard_rate": doc.rate,
+			"description": doc.description
+		})
+		item.save()
+
 @frappe.whitelist()
 def change_item_code(item, item_code, doc_name):
-	item_exist = frappe.db.exists({
-		"doctype": "Item",
-		"item_code": item_code})
-	if(item_exist):
-		frappe.throw(_("Code {0} already exist").format(item_code))
+	if frappe.db.exists({'doctype': 'Item', 'item_code': item_code}):
+		frappe.throw(_('Item with Item Code {0} already exists').format(item_code))
 	else:
-		rename_doc("Item", item, item_code, ignore_permissions=True)
-		frappe.db.set_value("Healthcare Service Unit Type", doc_name, "item_code", item_code)
-
-@frappe.whitelist()
-def disable_enable(status, doc_name, item=None,  is_billable=None):
-	frappe.db.set_value("Healthcare Service Unit Type", doc_name, "disabled", status)
-	if(is_billable == 1):
-		frappe.db.set_value("Item", item, "disabled", status)
+		rename_doc('Item', item, item_code, ignore_permissions=True)
+		frappe.db.set_value('Healthcare Service Unit Type', doc_name, 'item_code', item_code)
diff --git a/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py
new file mode 100644
index 0000000..0ac548b
--- /dev/null
+++ b/erpnext/healthcare/doctype/healthcare_service_unit_type/healthcare_service_unit_type_dashboard.py
@@ -0,0 +1,13 @@
+from __future__ import unicode_literals
+from frappe import _
+
+def get_data():
+	return {
+		'fieldname': 'service_unit_type',
+		'transactions': [
+			{
+				'label': _('Healthcare Service Units'),
+				'items': ['Healthcare Service Unit']
+			},
+		]
+	}
diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
index 95d9e44..fafec22 100644
--- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
+++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.json
@@ -7,13 +7,13 @@
  "engine": "InnoDB",
  "field_order": [
   "sb_op_settings",
-  "patient_master_name",
-  "manage_customer",
+  "patient_name_by",
+  "link_customer_to_patient",
   "default_medical_code_standard",
   "column_break_9",
   "collect_registration_fee",
   "registration_fee",
-  "manage_appointment_invoice_automatically",
+  "automate_appointment_invoicing",
   "max_visit",
   "valid_days",
   "healthcare_service_items",
@@ -21,27 +21,26 @@
   "op_consulting_charge_item",
   "column_break_13",
   "clinical_procedure_consumable_item",
-  "out_patient_sms_alerts",
-  "reg_sms",
-  "reg_msg",
-  "app_con",
-  "app_con_msg",
-  "no_con",
-  "column_break_16",
-  "app_rem",
-  "app_rem_msg",
-  "rem_before",
   "sb_in_ac",
   "income_account",
-  "sb_r_ac",
   "receivable_account",
   "sb_lab_settings",
-  "create_test_on_si_submit",
-  "require_sample_collection",
-  "require_test_result_approval",
+  "create_lab_test_on_si_submit",
+  "create_sample_collection_for_lab_test",
   "column_break_34",
   "employee_name_and_designation_in_print",
+  "lab_test_approval_required",
   "custom_signature_in_print",
+  "out_patient_sms_alerts",
+  "send_registration_msg",
+  "registration_msg",
+  "send_appointment_confirmation",
+  "appointment_confirmation_msg",
+  "avoid_confirmation",
+  "column_break_16",
+  "send_appointment_reminder",
+  "appointment_reminder_msg",
+  "remind_before",
   "laboratory_sms_alerts",
   "sms_printed",
   "column_break_28",
@@ -54,19 +53,6 @@
    "label": "Out Patient Settings"
   },
   {
-   "fieldname": "patient_master_name",
-   "fieldtype": "Select",
-   "label": "Patient Name By",
-   "options": "Patient Name\nNaming Series"
-  },
-  {
-   "default": "1",
-   "description": "If checked, a customer will be created, mapped to Patient.\nPatient Invoices will be created against this Customer. You can also select existing Customer while creating Patient.",
-   "fieldname": "manage_customer",
-   "fieldtype": "Check",
-   "label": "Manage Customer"
-  },
-  {
    "fieldname": "default_medical_code_standard",
    "fieldtype": "Link",
    "label": "Default Medical Code Standard",
@@ -78,6 +64,7 @@
   },
   {
    "default": "0",
+   "description": "Checking this will create new Patients with a Disabled status by default and will only be enabled after invoicing the Registration Fee.",
    "fieldname": "collect_registration_fee",
    "fieldtype": "Check",
    "label": "Collect Fee for Patient Registration"
@@ -91,27 +78,23 @@
    "options": "Currency"
   },
   {
-   "default": "0",
-   "description": "Manage Appointment Invoice submit and cancel automatically for Patient Encounter",
-   "fieldname": "manage_appointment_invoice_automatically",
-   "fieldtype": "Check",
-   "label": "Invoice Appointments Automatically"
-  },
-  {
+   "description": "The number of free follow ups (Patient Encounters in valid days) allowed",
    "fieldname": "max_visit",
    "fieldtype": "Int",
    "label": "Patient Encounters in valid days"
   },
   {
+   "description": "Time period (Valid number of days) for free consultations",
    "fieldname": "valid_days",
    "fieldtype": "Int",
    "label": "Valid number of days"
   },
   {
    "collapsible": 1,
+   "description": "You can configure default Items for billing consultation charges, procedure consumption items and inpatient visits",
    "fieldname": "healthcare_service_items",
    "fieldtype": "Section Break",
-   "label": "Healthcare Service Items"
+   "label": "Default Healthcare Service Items"
   },
   {
    "fieldname": "inpatient_visit_charge_item",
@@ -142,86 +125,24 @@
    "label": "Out Patient SMS Alerts"
   },
   {
-   "default": "0",
-   "fieldname": "reg_sms",
-   "fieldtype": "Check",
-   "label": "Patient Registration"
-  },
-  {
-   "default": "Hello {{doc.patient}}, Thank you for registering with  {{doc.company}}. Your ID is {{doc.id}} . Please note this ID for future reference. \nThank You, Get well soon!",
-   "depends_on": "reg_sms",
-   "fieldname": "reg_msg",
-   "fieldtype": "Small Text",
-   "ignore_xss_filter": 1,
-   "label": "Registration Message"
-  },
-  {
-   "default": "0",
-   "fieldname": "app_con",
-   "fieldtype": "Check",
-   "label": "Appointment Confirmation"
-  },
-  {
-   "default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.practitioner}} by {{doc.start_dt}} at  {{doc.company}}.\nThank you, Good day!",
-   "depends_on": "app_con",
-   "fieldname": "app_con_msg",
-   "fieldtype": "Small Text",
-   "ignore_xss_filter": 1,
-   "label": "Confirmation Message"
-  },
-  {
-   "default": "0",
-   "depends_on": "app_con",
-   "description": "Do not confirm if appointment is created for the same day",
-   "fieldname": "no_con",
-   "fieldtype": "Check",
-   "label": "Avoid Confirmation"
-  },
-  {
    "fieldname": "column_break_16",
    "fieldtype": "Column Break"
   },
   {
-   "default": "0",
-   "fieldname": "app_rem",
-   "fieldtype": "Check",
-   "label": "Appointment Reminder"
-  },
-  {
-   "default": "Hello {{doc.patient}}, You have an appointment with {{doc.practitioner}} by {{doc.appointment_time}} at  {{doc.company}}.\nThank you, Good day!\n",
-   "depends_on": "app_rem",
-   "fieldname": "app_rem_msg",
-   "fieldtype": "Small Text",
-   "ignore_xss_filter": 1,
-   "label": "Reminder Message"
-  },
-  {
-   "depends_on": "app_rem",
-   "fieldname": "rem_before",
-   "fieldtype": "Time",
-   "label": "Remind Before"
-  },
-  {
    "collapsible": 1,
-   "description": "Default income accounts to be used if not set in Healthcare Practitioner to book Appointment charges.",
    "fieldname": "sb_in_ac",
    "fieldtype": "Section Break",
-   "label": "Income Account"
+   "label": "Default Accounts"
   },
   {
+   "description": "Default income accounts to be used if not set in Healthcare Practitioner to book Appointment charges.",
    "fieldname": "income_account",
    "fieldtype": "Table",
    "label": "Income Account",
    "options": "Party Account"
   },
   {
-   "collapsible": 1,
-   "description": "Default receivable accounts to be used if not set in Patient to book Appointment charges.",
-   "fieldname": "sb_r_ac",
-   "fieldtype": "Section Break",
-   "label": "Receivable Account"
-  },
-  {
+   "description": "Default receivable accounts to be used to book Appointment charges.",
    "fieldname": "receivable_account",
    "fieldtype": "Table",
    "label": "Receivable Account",
@@ -234,30 +155,12 @@
    "label": "Laboratory Settings"
   },
   {
-   "default": "0",
-   "fieldname": "create_test_on_si_submit",
-   "fieldtype": "Check",
-   "label": "Create Lab Test(s) on Sales Invoice Submit"
-  },
-  {
-   "default": "0",
-   "description": "Create documents for sample collection",
-   "fieldname": "require_sample_collection",
-   "fieldtype": "Check",
-   "label": "Manage Sample Collection"
-  },
-  {
-   "default": "0",
-   "fieldname": "require_test_result_approval",
-   "fieldtype": "Check",
-   "label": "Require Lab Test Approval"
-  },
-  {
    "fieldname": "column_break_34",
    "fieldtype": "Column Break"
   },
   {
    "default": "1",
+   "description": "Check this if you want the Name and Designation of the Employee associated with the User who submits the document to be printed in the Lab Test Report.",
    "fieldname": "employee_name_and_designation_in_print",
    "fieldtype": "Check",
    "label": "Employee name and designation in print"
@@ -279,7 +182,7 @@
    "fieldname": "sms_printed",
    "fieldtype": "Small Text",
    "ignore_xss_filter": 1,
-   "label": "Result Printed"
+   "label": "Result Printed Message"
   },
   {
    "fieldname": "column_break_28",
@@ -290,12 +193,109 @@
    "fieldname": "sms_emailed",
    "fieldtype": "Small Text",
    "ignore_xss_filter": 1,
-   "label": "Result Emailed"
+   "label": "Result Emailed Message"
+  },
+  {
+   "default": "0",
+   "description": "Checking this will restrict printing and emailing of Lab Test documents unless they have the status as Approved.",
+   "fieldname": "lab_test_approval_required",
+   "fieldtype": "Check",
+   "label": "Do not print or email Lab Tests without Approval"
+  },
+  {
+   "default": "1",
+   "description": "If checked, a customer will be created, mapped to Patient.\nPatient Invoices will be created against this Customer. You can also select existing Customer while creating Patient.",
+   "fieldname": "link_customer_to_patient",
+   "fieldtype": "Check",
+   "label": "Link Customer to Patient"
+  },
+  {
+   "default": "0",
+   "description": "Checking this will create Lab Test(s) specified in the Sales Invoice on submission.",
+   "fieldname": "create_lab_test_on_si_submit",
+   "fieldtype": "Check",
+   "label": "Create Lab Test(s) on Sales Invoice Submission"
+  },
+  {
+   "default": "0",
+   "description": "Checking this will create a Sample Collection document  every time you create a Lab Test",
+   "fieldname": "create_sample_collection_for_lab_test",
+   "fieldtype": "Check",
+   "label": "Create Sample Collection document for Lab Test"
+  },
+  {
+   "fieldname": "patient_name_by",
+   "fieldtype": "Select",
+   "label": "Patient Name By",
+   "options": "Patient Name\nNaming Series"
+  },
+  {
+   "default": "0",
+   "description": "Manage Appointment Invoice submit and cancel automatically for Patient Encounter",
+   "fieldname": "automate_appointment_invoicing",
+   "fieldtype": "Check",
+   "label": "Automate Appointment Invoicing"
+  },
+  {
+   "default": "0",
+   "fieldname": "send_registration_msg",
+   "fieldtype": "Check",
+   "label": "Patient Registration"
+  },
+  {
+   "default": "Hello {{doc.patient}}, Thank you for registering with  {{doc.company}}. Your ID is {{doc.id}} . Please note this ID for future reference. \nThank You, Get well soon!",
+   "depends_on": "send_registration_msg",
+   "fieldname": "registration_msg",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "label": "Registration Message"
+  },
+  {
+   "default": "0",
+   "fieldname": "send_appointment_confirmation",
+   "fieldtype": "Check",
+   "label": "Appointment Confirmation"
+  },
+  {
+   "default": "Hello {{doc.patient}}, You have scheduled an appointment with {{doc.practitioner}} by {{doc.start_dt}} at  {{doc.company}}.\nThank you, Good day!",
+   "depends_on": "send_appointment_confirmation",
+   "fieldname": "appointment_confirmation_msg",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "label": "Confirmation Message"
+  },
+  {
+   "default": "0",
+   "depends_on": "send_appointment_confirmation",
+   "description": "Do not confirm if appointment is created for the same day",
+   "fieldname": "avoid_confirmation",
+   "fieldtype": "Check",
+   "label": "Avoid Confirmation"
+  },
+  {
+   "default": "0",
+   "fieldname": "send_appointment_reminder",
+   "fieldtype": "Check",
+   "label": "Appointment Reminder"
+  },
+  {
+   "default": "Hello {{doc.patient}}, You have an appointment with {{doc.practitioner}} by {{doc.appointment_time}} at  {{doc.company}}.\nThank you, Good day!\n",
+   "depends_on": "send_appointment_reminder",
+   "fieldname": "appointment_reminder_msg",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "label": "Reminder Message"
+  },
+  {
+   "depends_on": "send_appointment_reminder",
+   "fieldname": "remind_before",
+   "fieldtype": "Time",
+   "label": "Remind Before"
   }
  ],
  "issingle": 1,
  "links": [],
- "modified": "2020-01-23 13:31:43.699711",
+ "modified": "2020-02-24 10:51:23.015896",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Healthcare Settings",
diff --git a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py
index 8555e80..a16fceb 100644
--- a/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py
+++ b/erpnext/healthcare/doctype/healthcare_settings/healthcare_settings.py
@@ -11,69 +11,80 @@
 
 class HealthcareSettings(Document):
 	def validate(self):
-		for key in ["collect_registration_fee","manage_customer","patient_master_name",
-		"require_test_result_approval","require_sample_collection", "default_medical_code_standard"]:
+		for key in ['collect_registration_fee', 'link_customer_to_patient', 'patient_name_by',
+		'lab_test_approval_required', 'create_sample_collection_for_lab_test', 'default_medical_code_standard']:
 			frappe.db.set_default(key, self.get(key, ""))
-		if(self.collect_registration_fee):
-			if self.registration_fee <= 0 :
-				frappe.throw(_("Registration fee can not be Zero"))
+
+		if self.collect_registration_fee:
+			if self.registration_fee <= 0:
+				frappe.throw(_('Registration Fee cannot be negative or zero'))
+
 		if self.inpatient_visit_charge_item:
-			validate_service_item(self.inpatient_visit_charge_item, "Configure a service Item for Inpatient Visit Charge Item")
+			validate_service_item(self.inpatient_visit_charge_item)
 		if self.op_consulting_charge_item:
-			validate_service_item(self.op_consulting_charge_item, "Configure a service Item for Out Patient Consulting Charge Item")
+			validate_service_item(self.op_consulting_charge_item)
 		if self.clinical_procedure_consumable_item:
-			validate_service_item(self.clinical_procedure_consumable_item, "Configure a service Item for Clinical Procedure Consumable Item")
+			validate_service_item(self.clinical_procedure_consumable_item)
+
+
+def validate_service_item(item):
+	if frappe.db.get_value('Item', item, 'is_stock_item'):
+		frappe.throw(_('Configure a service Item for {0}').format(item))
 
 @frappe.whitelist()
 def get_sms_text(doc):
-    sms_text = {}
-    doc = frappe.get_doc("Lab Test",doc)
-    #doc = json.loads(doc)
-    context = {"doc": doc, "alert": doc, "comments": None}
-    emailed = frappe.db.get_value("Healthcare Settings", None, "sms_emailed")
-    sms_text['emailed'] = frappe.render_template(emailed, context)
-    printed = frappe.db.get_value("Healthcare Settings", None, "sms_printed")
-    sms_text['printed'] = frappe.render_template(printed, context)
-    return sms_text
+	sms_text = {}
+	doc = frappe.get_doc('Lab Test', doc)
+	context = {'doc': doc, 'alert': doc, 'comments': None}
+
+	emailed = frappe.db.get_value('Healthcare Settings', None, 'sms_emailed')
+	sms_text['emailed'] = frappe.render_template(emailed, context)
+
+	printed = frappe.db.get_value('Healthcare Settings', None, 'sms_printed')
+	sms_text['printed'] = frappe.render_template(printed, context)
+
+	return sms_text
 
 def send_registration_sms(doc):
-    if (frappe.db.get_value("Healthcare Settings", None, "reg_sms")=='1'):
-        if doc.mobile:
-            context = {"doc": doc, "alert": doc, "comments": None}
-            if doc.get("_comments"):
-                context["comments"] = json.loads(doc.get("_comments"))
-            messages = frappe.db.get_value("Healthcare Settings", None, "reg_msg")
-            messages = frappe.render_template(messages, context)
-            number = [doc.mobile]
-            send_sms(number,messages)
-        else:
-            frappe.msgprint(doc.name + " Has no mobile number to send registration SMS", alert=True)
-
+	if frappe.db.get_single_value('Healthcare Settings', 'send_registration_msg'):
+		if doc.mobile:
+			context = {'doc': doc, 'alert': doc, 'comments': None}
+			if doc.get('_comments'):
+				context['comments'] = json.loads(doc.get('_comments'))
+			messages = frappe.db.get_single_value('Healthcare Settings', 'registration_msg')
+			messages = frappe.render_template(messages, context)
+			number = [doc.mobile]
+			send_sms(number,messages)
+		else:
+			frappe.msgprint(doc.name + ' has no mobile number to send registration SMS', alert=True)
 
 def get_receivable_account(company):
-    receivable_account = get_account(None, "receivable_account", "Healthcare Settings", company)
-    if receivable_account:
-        return receivable_account
-    return frappe.get_cached_value('Company',  company,  "default_receivable_account")
+	receivable_account = get_account(None, 'receivable_account', 'Healthcare Settings', company)
+	if receivable_account:
+		return receivable_account
+
+	return frappe.get_cached_value('Company', company, 'default_receivable_account')
 
 def get_income_account(practitioner, company):
-    if(practitioner):
-        income_account = get_account("Healthcare Practitioner", None, practitioner, company)
-        if income_account:
-            return income_account
-    income_account = get_account(None, "income_account", "Healthcare Settings", company)
-    if income_account:
-        return income_account
-    return frappe.get_cached_value('Company',  company,  "default_income_account")
+	# check income account in Healthcare Practitioner
+	if practitioner:
+		income_account = get_account('Healthcare Practitioner', None, practitioner, company)
+		if income_account:
+			return income_account
+
+	# else check income account in Healthcare Settings
+	income_account = get_account(None, 'income_account', 'Healthcare Settings', company)
+	if income_account:
+		return income_account
+
+	# else return default income account of company
+	return frappe.get_cached_value('Company', company, 'default_income_account')
 
 def get_account(parent_type, parent_field, parent, company):
-    if(parent_type):
-        return frappe.db.get_value("Party Account",
-            {"parenttype": parent_type, "parent": parent, "company": company}, "account")
-    if(parent_field):
-        return frappe.db.get_value("Party Account",
-            {"parentfield": parent_field, "parent": parent, "company": company}, "account")
+	if parent_type:
+		return frappe.db.get_value('Party Account',
+			{'parenttype': parent_type, 'parent': parent, 'company': company}, 'account')
 
-def validate_service_item(item, msg):
-	if frappe.db.get_value("Item", item, "is_stock_item") == 1:
-		frappe.throw(_(msg))
+	if parent_field:
+		return frappe.db.get_value('Party Account',
+			{'parentfield': parent_field, 'parent': parent, 'company': company}, 'account')
diff --git a/erpnext/healthcare/doctype/lab_prescription/lab_prescription.json b/erpnext/healthcare/doctype/lab_prescription/lab_prescription.json
index d6691d4..0720bb4 100644
--- a/erpnext/healthcare/doctype/lab_prescription/lab_prescription.json
+++ b/erpnext/healthcare/doctype/lab_prescription/lab_prescription.json
@@ -1,238 +1,78 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 1, 
- "creation": "2016-09-16 16:53:06.882970", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 1, 
+ "actions": [],
+ "allow_copy": 1,
+ "beta": 1,
+ "creation": "2016-09-16 16:53:06.882970",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "lab_test_code",
+  "lab_test_name",
+  "invoiced",
+  "column_break_4",
+  "lab_test_comment",
+  "lab_test_created"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "lab_test_code", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Test Code", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Lab Test Template", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "lab_test_code",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Lab Test",
+   "options": "Lab Test Template",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "lab_test_code.lab_test_name", 
-   "fieldname": "lab_test_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Test", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "lab_test_code.lab_test_name",
+   "fieldname": "lab_test_name",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Lab Test Name"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "invoiced", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Invoiced", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "invoiced",
+   "fieldtype": "Check",
+   "label": "Invoiced",
+   "no_copy": 1,
+   "read_only": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_4", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_4",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "lab_test_comment", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Comments", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "lab_test_comment",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Comments"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "lab_test_created", 
-   "fieldtype": "Check", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Test Created", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "default": "0",
+   "fieldname": "lab_test_created",
+   "fieldtype": "Check",
+   "hidden": 1,
+   "label": "Test Created",
+   "no_copy": 1,
+   "print_hide": 1,
+   "report_hide": 1,
+   "search_index": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2018-09-04 09:02:18.592637", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Lab Prescription", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 0, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 17:03:00.255560",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Lab Prescription",
+ "owner": "Administrator",
+ "permissions": [],
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.js b/erpnext/healthcare/doctype/lab_test/lab_test.js
index b60e70f..5b3f4c7 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.js
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.js
@@ -29,7 +29,7 @@
 				get_lab_test_prescribed(frm);
 			});
 		}
-		if(frm.doc.docstatus==1	&&	frm.doc.status!='Approved'	&&	frm.doc.status!='Rejected'	&&	frappe.defaults.get_default("require_test_result_approval")	&&	frappe.user.has_role("LabTest Approver")){
+		if(frm.doc.docstatus==1	&&	frm.doc.status!='Approved'	&&	frm.doc.status!='Rejected'	&&	frappe.defaults.get_default("lab_test_approval_required")	&&	frappe.user.has_role("LabTest Approver")){
 			frm.add_custom_button(__('Approve'), function() {
 				status_update(1,frm);
 			});
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index 8609489..1a05f1e 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -224,7 +224,7 @@
 		return sample_collection
 
 def create_sample_collection(lab_test, template, patient, invoice):
-	if(frappe.db.get_value("Healthcare Settings", None, "require_sample_collection") == "1"):
+	if(frappe.db.get_value("Healthcare Settings", None, "create_sample_collection_for_lab_test") == "1"):
 		sample_collection = create_sample_doc(template, patient, invoice)
 		if(sample_collection):
 			lab_test.sample = sample_collection.name
diff --git a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json
index 46c04c6..2830038 100644
--- a/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json
+++ b/erpnext/healthcare/doctype/lab_test_sample/lab_test_sample.json
@@ -1,145 +1,68 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "field:sample", 
- "beta": 1, 
- "creation": "2016-04-04 17:35:44.823951", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Setup", 
- "editable_grid": 0, 
+ "actions": [],
+ "allow_copy": 1,
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:sample",
+ "beta": 1,
+ "creation": "2016-04-04 17:35:44.823951",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "engine": "InnoDB",
+ "field_order": [
+  "sample",
+  "sample_uom"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sample", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Sample", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sample",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Sample",
+   "reqd": 1,
+   "unique": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 1, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sample_uom", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "UOM", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
+   "bold": 1,
+   "fieldname": "sample_uom",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "UOM",
+   "options": "Lab Test UOM"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2017-08-31 13:46:22.508908", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Lab Test Sample", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "links": [],
+ "modified": "2020-01-29 23:02:02.249839",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Lab Test Sample",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 0, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Healthcare Administrator", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Healthcare Administrator",
+   "share": 1,
    "write": 1
-  }, 
+  },
   {
-   "amend": 0, 
-   "apply_user_permissions": 0, 
-   "cancel": 0, 
-   "create": 0, 
-   "delete": 0, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Laboratory User", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
-   "write": 0
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Laboratory User",
+   "share": 1
   }
- ], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "sample", 
- "track_changes": 1, 
- "track_seen": 0
+ ],
+ "quick_entry": 1,
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "sample",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js
index 1a34fe8..d5df956 100644
--- a/erpnext/healthcare/doctype/patient/patient.js
+++ b/erpnext/healthcare/doctype/patient/patient.js
@@ -3,128 +3,77 @@
 
 frappe.ui.form.on('Patient', {
 	refresh: function (frm) {
-		frm.set_query("patient", "patient_relation", function () {
+		frm.set_query('patient', 'patient_relation', function () {
 			return {
 				filters: [
-					["Patient", "name", "!=", frm.doc.name]
+					['Patient', 'name', '!=', frm.doc.name]
 				]
 			};
 		});
-		if (frappe.defaults.get_default("patient_master_name") != "Naming Series") {
-			frm.toggle_display("naming_series", false);
+
+		if (frappe.defaults.get_default('patient_name_by') != 'Naming Series') {
+			frm.toggle_display('naming_series', false);
 		} else {
 			erpnext.toggle_naming_series();
 		}
-		if (frappe.defaults.get_default("collect_registration_fee") && frm.doc.disabled == 1) {
+
+		if (frappe.defaults.get_default('collect_registration_fee') && frm.doc.status == 'Disabled') {
 			frm.add_custom_button(__('Invoice Patient Registration'), function () {
-				btn_invoice_registration(frm);
+				invoice_registration(frm);
 			});
 		}
-		if (frm.doc.patient_name && frappe.user.has_role("Physician")) {
-			frm.add_custom_button(__('Patient History'), function () {
-				frappe.route_options = { "patient": frm.doc.name };
-				frappe.set_route("patient_history");
-			},"View");
+
+		if (frm.doc.patient_name && frappe.user.has_role('Physician')) {
+			frm.add_custom_button(__('Patient History'), function() {
+				frappe.route_options = {'patient': frm.doc.name};
+				frappe.set_route('patient_history');
+			},'View');
 		}
-		if (!frm.doc.__islocal && (frappe.user.has_role("Nursing User") || frappe.user.has_role("Physician"))) {
+
+		if (!frm.doc.__islocal && (frappe.user.has_role('Nursing User') || frappe.user.has_role('Physician'))) {
 			frm.add_custom_button(__('Vital Signs'), function () {
-				btn_create_vital_signs(frm);
-			}, "Create");
+				create_vital_signs(frm);
+			}, 'Create');
 			frm.add_custom_button(__('Medical Record'), function () {
 				create_medical_record(frm);
-			}, "Create");
+			}, 'Create');
 			frm.add_custom_button(__('Patient Encounter'), function () {
-				btn_create_encounter(frm);
-			}, "Create");
+				create_encounter(frm);
+			}, 'Create');
 		}
 	},
 	onload: function (frm) {
 		if(!frm.doc.dob){
-			$(frm.fields_dict['age_html'].wrapper).html("");
+			$(frm.fields_dict['age_html'].wrapper).html('');
 		}
 		if(frm.doc.dob){
-			$(frm.fields_dict['age_html'].wrapper).html("AGE : " + get_age(frm.doc.dob));
+			$(frm.fields_dict['age_html'].wrapper).html('AGE : ' + get_age(frm.doc.dob));
 		}
 	}
 });
 
-frappe.ui.form.on("Patient", "dob", function(frm) {
-	if(frm.doc.dob) {
-		var today = new Date();
-		var birthDate = new Date(frm.doc.dob);
-		if(today < birthDate){
-			frappe.msgprint(__("Please select a valid Date"));
-			frappe.model.set_value(frm.doctype,frm.docname, "dob", "");
+frappe.ui.form.on('Patient', 'dob', function(frm) {
+	if (frm.doc.dob) {
+		let today = new Date();
+		let birthDate = new Date(frm.doc.dob);
+		if (today < birthDate){
+			frappe.msgprint(__('Please select a valid Date'));
+			frappe.model.set_value(frm.doctype,frm.docname, 'dob', '');
 		}
-		else{
-			var age_str = get_age(frm.doc.dob);
-			$(frm.fields_dict['age_html'].wrapper).html("AGE : " + age_str);
+		else {
+			let age_str = get_age(frm.doc.dob);
+			$(frm.fields_dict['age_html'].wrapper).html('AGE : ' + age_str);
 		}
 	}
 	else {
-		$(frm.fields_dict['age_html'].wrapper).html("");
+		$(frm.fields_dict['age_html'].wrapper).html('');
 	}
 });
 
-var create_medical_record = function (frm) {
-	frappe.route_options = {
-		"patient": frm.doc.name,
-		"status": "Open",
-		"reference_doctype": "Patient Medical Record",
-		"reference_owner": frm.doc.owner
-	};
-	frappe.new_doc("Patient Medical Record");
-};
-
-var get_age = function (birth) {
-	var ageMS = Date.parse(Date()) - Date.parse(birth);
-	var age = new Date();
-	age.setTime(ageMS);
-	var years = age.getFullYear() - 1970;
-	return years + " Year(s) " + age.getMonth() + " Month(s) " + age.getDate() + " Day(s)";
-};
-
-var btn_create_vital_signs = function (frm) {
-	if (!frm.doc.name) {
-		frappe.throw(__("Please save the patient first"));
-	}
-	frappe.route_options = {
-		"patient": frm.doc.name,
-	};
-	frappe.new_doc("Vital Signs");
-};
-
-var btn_create_encounter = function (frm) {
-	if (!frm.doc.name) {
-		frappe.throw(__("Please save the patient first"));
-	}
-	frappe.route_options = {
-		"patient": frm.doc.name,
-	};
-	frappe.new_doc("Patient Encounter");
-};
-
-var btn_invoice_registration = function (frm) {
-	frappe.call({
-		doc: frm.doc,
-		method: "invoice_patient_registration",
-		callback: function(data){
-			if(!data.exc){
-				if(data.message.invoice){
-					/* frappe.show_alert(__('Sales Invoice {0} created',
-					['<a href="#Form/Sales Invoice/'+data.message.invoice+'">' + data.message.invoice+ '</a>'])); */
-					frappe.set_route("Form", "Sales Invoice", data.message.invoice);
-				}
-				cur_frm.reload_doc();
-			}
-		}
-	});
-};
-
 frappe.ui.form.on('Patient Relation', {
 	patient_relation_add: function(frm){
 		frm.fields_dict['patient_relation'].grid.get_field('patient').get_query = function(doc){
-			var patient_list = [];
+			let patient_list = [];
 			if(!doc.__islocal) patient_list.push(doc.name);
 			$.each(doc.patient_relation, function(idx, val){
 				if (val.patient) patient_list.push(val.patient);
@@ -133,3 +82,56 @@
 		};
 	}
 });
+
+let create_medical_record = function (frm) {
+	frappe.route_options = {
+		'patient': frm.doc.name,
+		'status': 'Open',
+		'reference_doctype': 'Patient Medical Record',
+		'reference_owner': frm.doc.owner
+	};
+	frappe.new_doc('Patient Medical Record');
+};
+
+let get_age = function (birth) {
+	let ageMS = Date.parse(Date()) - Date.parse(birth);
+	let age = new Date();
+	age.setTime(ageMS);
+	let years = age.getFullYear() - 1970;
+	return years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
+};
+
+let create_vital_signs = function (frm) {
+	if (!frm.doc.name) {
+		frappe.throw(__('Please save the patient first'));
+	}
+	frappe.route_options = {
+		'patient': frm.doc.name,
+	};
+	frappe.new_doc('Vital Signs');
+};
+
+let create_encounter = function (frm) {
+	if (!frm.doc.name) {
+		frappe.throw(__('Please save the patient first'));
+	}
+	frappe.route_options = {
+		'patient': frm.doc.name,
+	};
+	frappe.new_doc('Patient Encounter');
+};
+
+let invoice_registration = function (frm) {
+	frappe.call({
+		doc: frm.doc,
+		method: 'invoice_patient_registration',
+		callback: function(data) {
+			if (!data.exc) {
+				if (data.message.invoice) {
+					frappe.set_route('Form', 'Sales Invoice', data.message.invoice);
+				}
+				cur_frm.reload_doc();
+			}
+		}
+	});
+};
diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json
index 0136f72..45a1379 100644
--- a/erpnext/healthcare/doctype/patient/patient.json
+++ b/erpnext/healthcare/doctype/patient/patient.json
@@ -1,4 +1,5 @@
 {
+ "actions": [],
  "allow_copy": 1,
  "allow_import": 1,
  "allow_rename": 1,
@@ -11,23 +12,29 @@
  "engine": "InnoDB",
  "field_order": [
   "basic_info",
-  "inpatient_status",
-  "inpatient_record",
   "naming_series",
+  "first_name",
+  "middle_name",
+  "last_name",
   "patient_name",
   "sex",
   "blood_group",
   "dob",
   "age_html",
-  "status",
   "image",
   "column_break_14",
+  "status",
+  "inpatient_status",
+  "inpatient_record",
   "customer",
-  "report_preference",
   "mobile",
   "email",
   "phone",
-  "disabled",
+  "report_preference",
+  "personal_and_social_history",
+  "occupation",
+  "column_break_25",
+  "marital_status",
   "sb_relation",
   "patient_relation",
   "allergy_medical_and_surgical_history",
@@ -36,10 +43,6 @@
   "column_break_20",
   "medical_history",
   "surgical_history",
-  "personal_and_social_history",
-  "occupation",
-  "column_break_25",
-  "marital_status",
   "risk_factors",
   "tobacco_past_use",
   "tobacco_current_use",
@@ -78,28 +81,28 @@
   {
    "fieldname": "naming_series",
    "fieldtype": "Select",
-   "label": "Patient ID",
+   "label": "Series",
    "options": "HLC-PAT-.YYYY.-",
    "print_hide": 1,
-   "report_hide": 1
+   "report_hide": 1,
+   "set_only_once": 1
   },
   {
    "bold": 1,
    "fieldname": "patient_name",
    "fieldtype": "Data",
-   "in_filter": 1,
+   "in_global_search": 1,
+   "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Full Name",
-   "no_copy": 1,
-   "oldfieldtype": "Data",
-   "reqd": 1,
+   "read_only": 1,
    "search_index": 1
   },
   {
    "fieldname": "sex",
-   "fieldtype": "Select",
+   "fieldtype": "Link",
    "label": "Gender",
-   "options": "\nMale\nFemale\nOther",
+   "options": "Gender",
    "reqd": 1
   },
   {
@@ -125,15 +128,15 @@
    "report_hide": 1
   },
   {
-   "default": "Active",
    "fieldname": "status",
    "fieldtype": "Select",
-   "hidden": 1,
+   "in_filter": 1,
+   "in_list_view": 1,
    "label": "Status",
    "no_copy": 1,
-   "options": "Active\nDormant\nOpen",
+   "options": "Active\nDisabled",
    "print_hide": 1,
-   "report_hide": 1
+   "read_only": 1
   },
   {
    "fieldname": "image",
@@ -149,12 +152,12 @@
    "fieldtype": "Column Break"
   },
   {
+   "description": "If \"Link Customer to Patient\" is checked in Healthcare Settings and an existing Customer is not selected then, a Customer will be created for this Patient for recording transactions in Accounts module.",
    "fieldname": "customer",
    "fieldtype": "Link",
    "ignore_user_permissions": 1,
    "label": "Customer",
-   "options": "Customer",
-   "set_only_once": 1
+   "options": "Customer"
   },
   {
    "fieldname": "report_preference",
@@ -183,20 +186,9 @@
    "fieldname": "phone",
    "fieldtype": "Data",
    "in_filter": 1,
-   "in_list_view": 1,
    "label": "Phone"
   },
   {
-   "default": "0",
-   "fieldname": "disabled",
-   "fieldtype": "Check",
-   "hidden": 1,
-   "label": "Disabled",
-   "no_copy": 1,
-   "print_hide": 1,
-   "report_hide": 1
-  },
-  {
    "collapsible": 1,
    "fieldname": "sb_relation",
    "fieldtype": "Section Break",
@@ -274,27 +266,31 @@
   },
   {
    "fieldname": "tobacco_past_use",
-   "fieldtype": "Data",
+   "fieldtype": "Select",
    "ignore_xss_filter": 1,
-   "label": "Tobacco Past Use"
+   "label": "Tobacco Consumption (Past)",
+   "options": "\nYes\nNo"
   },
   {
    "fieldname": "tobacco_current_use",
-   "fieldtype": "Data",
+   "fieldtype": "Select",
    "ignore_xss_filter": 1,
-   "label": "Tobacco Current Use"
+   "label": "Tobacco Consumption (Present)",
+   "options": "\nYes\nNo"
   },
   {
    "fieldname": "alcohol_past_use",
-   "fieldtype": "Data",
+   "fieldtype": "Select",
    "ignore_xss_filter": 1,
-   "label": "Alcohol Past Use"
+   "label": "Alcohol Consumption (Past)",
+   "options": "\nYes\nNo"
   },
   {
    "fieldname": "alcohol_current_use",
-   "fieldtype": "Data",
+   "fieldtype": "Select",
    "ignore_user_permissions": 1,
-   "label": "Alcohol Current Use"
+   "label": "Alcohol Consumption (Present)",
+   "options": "\nYes\nNo"
   },
   {
    "fieldname": "column_break_32",
@@ -342,12 +338,31 @@
    "label": "Default Currency",
    "options": "Currency",
    "print_hide": 1
+  },
+  {
+   "fieldname": "last_name",
+   "fieldtype": "Data",
+   "label": "Last Name",
+   "reqd": 1
+  },
+  {
+   "fieldname": "first_name",
+   "fieldtype": "Data",
+   "label": "First Name",
+   "oldfieldtype": "Data",
+   "reqd": 1
+  },
+  {
+   "fieldname": "middle_name",
+   "fieldtype": "Data",
+   "label": "Middle Name (optional)"
   }
  ],
  "icon": "fa fa-user",
  "image_field": "image",
+ "links": [],
  "max_attachments": 50,
- "modified": "2019-09-25 23:30:49.905893",
+ "modified": "2020-02-25 17:56:46.351080",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient",
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index e3eea96..e957a3f 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -9,43 +9,49 @@
 from frappe.utils import cint, cstr, getdate, flt
 import dateutil
 from frappe.model.naming import set_name_by_naming_series
-from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account,send_registration_sms
+from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account, send_registration_sms
 
 class Patient(Document):
-	def after_insert(self):
-		if(frappe.db.get_value("Healthcare Settings", None, "manage_customer") == '1' and not self.customer):
-			create_customer(self)
-		if(frappe.db.get_value("Healthcare Settings", None, "collect_registration_fee") == '1'):
-			frappe.db.set_value("Patient", self.name, "disabled", 1)
-		else:
-			send_registration_sms(self)
-		self.reload()
-
-	def on_update(self):
+	def validate(self):
+		self.set_full_name()
 		self.add_as_website_user()
 
+	def after_insert(self):
+		if frappe.db.get_value('Healthcare Settings', None, 'link_customer_to_patient') and not self.customer:
+			create_customer(self)
+		if frappe.db.get_single_value('Healthcare Settings', 'collect_registration_fee'):
+			frappe.db.set_value('Patient', self.name, 'status', 'Disabled')
+		else:
+			send_registration_sms(self)
+		self.add_as_website_user()
+		self.reload()
+
+	def set_full_name(self):
+		self.patient_name = ' '.join(filter(None, [self.first_name, self.last_name]))
+
 	def add_as_website_user(self):
-		if(self.email):
-			if not frappe.db.exists ("User", self.email):
+		if self.email:
+			if not frappe.db.exists ('User', self.email):
 				user = frappe.get_doc({
-					"doctype": "User",
-					"first_name": self.patient_name,
-					"email": self.email,
-					"user_type": "Website User"
+					'doctype': 'User',
+					'first_name': self.first_name,
+					'last_name': self.last_name,
+					'email': self.email,
+					'user_type': 'Website User'
 				})
 				user.flags.ignore_permissions = True
-				user.add_roles("Patient")
+				user.add_roles('Patient')
 
 	def autoname(self):
-		patient_master_name = frappe.defaults.get_global_default('patient_master_name')
-		if patient_master_name == 'Patient Name':
+		patient_name_by = frappe.db.get_single_value('Healthcare Settings', 'patient_name_by')
+		if patient_name_by == 'Patient Name':
 			self.name = self.get_patient_name()
 		else:
 			set_name_by_naming_series(self)
 
 	def get_patient_name(self):
 		name = self.patient_name
-		if frappe.db.get_value("Patient", name):
+		if frappe.db.get_value('Patient', name):
 			count = frappe.db.sql("""select ifnull(MAX(CAST(SUBSTRING_INDEX(name, ' ', -1) AS UNSIGNED)), 0) from tabPatient
 				 where name like %s""", "%{0} - %".format(name), as_list=1)[0][0]
 			count = cint(count) + 1
@@ -54,56 +60,59 @@
 		return name
 
 	def get_age(self):
-		age_str = ""
+		age_str = ''
 		if self.dob:
-			born = getdate(self.dob)
-			age = dateutil.relativedelta.relativedelta(getdate(), born)
-			age_str = str(age.years) + " year(s) " + str(age.months) + " month(s) " + str(age.days) + " day(s)"
+			dob = getdate(self.dob)
+			age = dateutil.relativedelta.relativedelta(getdate(), dob)
+			age_str = str(age.years) + ' year(s) ' + str(age.months) + ' month(s) ' + str(age.days) + ' day(s)'
 		return age_str
 
 	def invoice_patient_registration(self):
-		frappe.db.set_value("Patient", self.name, "disabled", 0)
-		send_registration_sms(self)
-		if(flt(frappe.get_value("Healthcare Settings", None, "registration_fee"))>0):
+		if frappe.db.get_single_value('Healthcare Settings', 'registration_fee'):
 			company = frappe.defaults.get_user_default('company')
 			if not company:
-				company = frappe.db.get_value("Global Defaults", None, "default_company")
+				company = frappe.db.get_single_value('Global Defaults', 'default_company')
+
 			sales_invoice = make_invoice(self.name, company)
 			sales_invoice.save(ignore_permissions=True)
+			frappe.db.set_value('Patient', self.name, 'status', 'Active')
+			send_registration_sms(self)
+
 			return {'invoice': sales_invoice.name}
 
 def create_customer(doc):
-	customer_group = frappe.get_value("Selling Settings", None, "customer_group")
-	territory = frappe.get_value("Selling Settings", None, "territory")
+	customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group')
+	territory = frappe.db.get_single_value('Selling Settings', 'territory')
 	if not (customer_group and territory):
-		customer_group = "Commercial"
-		territory = "Rest Of The World"
-		frappe.msgprint(_("Please set default customer group and territory in Selling Settings"), alert=True)
-	customer = frappe.get_doc({"doctype": "Customer",
-	"customer_name": doc.patient_name,
-	"customer_group": customer_group,
-	"territory" : territory,
-	"customer_type": "Individual"
+		customer_group = 'All Customer Groups'
+		territory = 'All Territories'
+		frappe.msgprint(_('Please set default customer group and territory in Selling Settings'), alert=True)
+	customer = frappe.get_doc({
+		'doctype': 'Customer',
+		'customer_name': doc.patient_name,
+		'customer_group': customer_group,
+		'territory' : territory,
+		'customer_type': 'Individual'
 	}).insert(ignore_permissions=True)
-	frappe.db.set_value("Patient", doc.name, "customer", customer.name)
-	frappe.msgprint(_("Customer {0} is created.").format(customer.name), alert=True)
+	frappe.db.set_value('Patient', doc.name, 'customer', customer.name)
+	frappe.msgprint(_('Customer {0} is created.').format(customer.name), alert=True)
 
 def make_invoice(patient, company):
-	sales_invoice = frappe.new_doc("Sales Invoice")
-	sales_invoice.customer = frappe.get_value("Patient", patient, "customer")
+	sales_invoice = frappe.new_doc('Sales Invoice')
+	sales_invoice.customer = frappe.get_value('Patient', patient, 'customer')
 	sales_invoice.due_date = getdate()
 	sales_invoice.company = company
-	sales_invoice.is_pos = '0'
+	sales_invoice.is_pos = 0
 	sales_invoice.debit_to = get_receivable_account(company)
 
-	item_line = sales_invoice.append("items")
-	item_line.item_name = "Registeration Fee"
-	item_line.description = "Registeration Fee"
+	item_line = sales_invoice.append('items')
+	item_line.item_name = 'Registeration Fee'
+	item_line.description = 'Registeration Fee'
 	item_line.qty = 1
-	item_line.uom = "Nos"
+	item_line.uom = 'Nos'
 	item_line.conversion_factor = 1
 	item_line.income_account = get_income_account(None, company)
-	item_line.rate = frappe.get_value("Healthcare Settings", None, "registration_fee")
+	item_line.rate = frappe.db.get_single_value('Healthcare Settings', 'registration_fee')
 	item_line.amount = item_line.rate
 	sales_invoice.set_missing_values()
 	return sales_invoice
@@ -112,7 +121,7 @@
 def get_patient_detail(patient):
 	patient_dict = frappe.db.sql("""select * from tabPatient where name=%s""", (patient), as_dict=1)
 	if not patient_dict:
-		frappe.throw(_("Patient not found"))
+		frappe.throw(_('Patient not found'))
 	vital_sign = frappe.db.sql("""select * from `tabVital Signs` where patient=%s
 		order by signs_date desc limit 1""", (patient), as_dict=1)
 
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index 858145e..133fee1 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -1,6 +1,6 @@
 // Copyright (c) 2016, ESS LLP and contributors
 // For license information, please see license.txt
-frappe.provide("erpnext.queries");
+frappe.provide('erpnext.queries');
 frappe.ui.form.on('Patient Appointment', {
 	setup: function(frm) {
 		frm.custom_make_buttons = {
@@ -8,151 +8,165 @@
 			'Patient Encounter': 'Patient Encounter'
 		};
 	},
+
+	onload: function(frm) {
+		if (frm.is_new()) {
+			frm.set_value('appointment_time', null);
+			frm.disable_save();
+		}
+	},
+
 	refresh: function(frm) {
-		frm.set_query("patient", function () {
+		frm.set_query('patient', function () {
 			return {
-				filters: {"disabled": 0}
+				filters: {'status': 'Active'}
 			};
 		});
-		frm.set_query("practitioner", function() {
+		frm.set_query('practitioner', function() {
 			return {
 				filters: {
 					'department': frm.doc.department
 				}
 			};
 		});
-		frm.set_query("service_unit", function(){
+		frm.set_query('service_unit', function(){
 			return {
 				filters: {
-					"is_group": false,
-					"allow_appointments": true
+					'is_group': 0,
+					'allow_appointments': 1
 				}
 			};
 		});
-		if(frm.doc.patient){
+
+		if (frm.is_new()) {
+			frm.page.set_primary_action(__('Check Availability'), function() {
+				frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'automate_appointment_invoicing', (settings) => {
+					if (settings.automate_appointment_invoicing) {
+						if (!frm.doc.mode_of_payment) {
+							frappe.msgprint({
+								title: __('Not Allowed'),
+								message: __('Please select a Mode of Payment first'),
+								indicator: 'red'
+							});
+						}
+						if (!frm.doc.paid_amount) {
+							frappe.msgprint({
+								title: __('Not Allowed'),
+								message: __('Please set the Paid Amount first'),
+								indicator: 'red'
+							});
+						}
+					}
+				});
+				if (!frm.doc.patient) {
+					frappe.msgprint({
+						title: __('Not Allowed'),
+						message: __('Please select Patient first'),
+						indicator: 'red'
+					});
+				} else {
+					check_and_set_availability(frm);
+				}
+			});
+		} else {
+			frm.page.set_primary_action(__('Save'), () => frm.save());
+		}
+
+		if (frm.doc.patient) {
 			frm.add_custom_button(__('Patient History'), function() {
-				frappe.route_options = {"patient": frm.doc.patient};
-				frappe.set_route("patient_history");
-			},__("View"));
+				frappe.route_options = {'patient': frm.doc.patient};
+				frappe.set_route('patient_history');
+			}, __('View'));
 		}
-		if(frm.doc.status == "Open"){
+
+		if (frm.doc.status == 'Open' || (frm.doc.status == 'Scheduled' && !frm.doc.__islocal)) {
 			frm.add_custom_button(__('Cancel'), function() {
-				btn_update_status(frm, "Cancelled");
+				update_status(frm, 'Cancelled');
 			});
 			frm.add_custom_button(__('Reschedule'), function() {
 				check_and_set_availability(frm);
 			});
-			if(frm.doc.procedure_template){
-				frm.add_custom_button(__("Procedure"),function(){
-					btn_create_procedure(frm);
-				},"Create");
-			}
-			else{
-				frm.add_custom_button(__("Patient Encounter"),function(){
-					btn_create_encounter(frm);
-				},"Create");
+
+			if (frm.doc.procedure_template) {
+				frm.add_custom_button(__('Clinical Procedure'), function(){
+					frappe.model.open_mapped_doc({
+						method: 'erpnext.healthcare.doctype.clinical_procedure.clinical_procedure.create_procedure',
+						frm: frm,
+					});
+				}, __('Create'));
+			} else {
+				frm.add_custom_button(__('Patient Encounter'), function() {
+					frappe.model.open_mapped_doc({
+						method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.make_encounter',
+						frm: frm,
+					});
+				}, __('Create'));
 			}
 
 			frm.add_custom_button(__('Vital Signs'), function() {
-				btn_create_vital_signs(frm);
-			},"Create");
+				create_vital_signs(frm);
+			}, __('Create'));
 		}
-		if(frm.doc.status == "Scheduled" && !frm.doc.__islocal){
-			frm.add_custom_button(__('Cancel'), function() {
-				btn_update_status(frm, "Cancelled");
-			});
-			frm.add_custom_button(__('Reschedule'), function() {
-				check_and_set_availability(frm);
-			});
-			if(frm.doc.procedure_template){
-				frm.add_custom_button(__("Procedure"),function(){
-					btn_create_procedure(frm);
-				},"Create");
-			}
-			else{
-				frm.add_custom_button(__("Patient Encounter"),function(){
-					btn_create_encounter(frm);
-				},"Create");
-			}
 
-			frm.add_custom_button(__('Vital Signs'), function() {
-				btn_create_vital_signs(frm);
-			},"Create");
-		}
-		if(frm.doc.status == "Pending"){
-			frm.add_custom_button(__('Set Open'), function() {
-				btn_update_status(frm, "Open");
-			});
-			frm.add_custom_button(__('Cancel'), function() {
-				btn_update_status(frm, "Cancelled");
-			});
-		}
-		frm.set_df_property("get_procedure_from_encounter", "read_only", frm.doc.__islocal ? 0 : 1);
-		frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'manage_appointment_invoice_automatically', (r) => {
-			if(r.manage_appointment_invoice_automatically == 1){
-				frm.set_df_property("mode_of_payment", "hidden", 0);
-				frm.set_df_property("paid_amount", "hidden", 0);
-				frm.set_df_property("mode_of_payment", "reqd", 1);
-				frm.set_df_property("paid_amount", "reqd", 1);
-			}
-			else{
-				frm.set_df_property("mode_of_payment", "hidden", 1);
-				frm.set_df_property("paid_amount", "hidden", 1);
-				frm.set_df_property("mode_of_payment", "reqd", 0);
-				frm.set_df_property("paid_amount", "reqd", 0);
+		frappe.db.get_value('Healthcare Settings', {name: 'Healthcare Settings'}, 'automate_appointment_invoicing', (settings) => {
+			if (settings.automate_appointment_invoicing) {
+				frm.set_df_property('mode_of_payment', 'hidden', 0);
+				frm.set_df_property('paid_amount', 'hidden', 0);
+				frm.set_df_property('mode_of_payment', 'reqd', 1);
+				frm.set_df_property('paid_amount', 'reqd', 1);
+			} else {
+				frm.set_df_property('mode_of_payment', 'hidden', 1);
+				frm.set_df_property('paid_amount', 'hidden', 1);
+				frm.set_df_property('mode_of_payment', 'reqd', 0);
+				frm.set_df_property('paid_amount', 'reqd', 0);
 			}
 		});
 	},
-	check_availability: function(frm) {
-		check_and_set_availability(frm);
-	},
-	onload:function(frm){
-		if(frm.is_new()) {
-			frm.set_value("appointment_time", null);
-			frm.disable_save();
-		}
-	},
+
 	get_procedure_from_encounter: function(frm) {
-		get_procedure_prescribed(frm);
+		get_prescribed_procedure(frm);
 	}
 });
 
-var check_and_set_availability = function(frm) {
-	var selected_slot = null;
-	var service_unit = null;
-	var duration = null;
+let check_and_set_availability = function(frm) {
+	let selected_slot = null;
+	let service_unit = null;
+	let duration = null;
 
 	show_availability();
 
 	function show_empty_state(practitioner, appointment_date) {
 		frappe.msgprint({
 			title: __('Not Available'),
-			message: __("Healthcare Practitioner {0} not available on {1}", [practitioner.bold(), appointment_date.bold()]),
+			message: __('Healthcare Practitioner {0} not available on {1}', [practitioner.bold(), appointment_date.bold()]),
 			indicator: 'red'
 		});
 	}
 
 	function show_availability() {
 		let selected_practitioner = '';
-		var d = new frappe.ui.Dialog({
-			title: __("Available slots"),
+		let d = new frappe.ui.Dialog({
+			title: __('Available slots'),
 			fields: [
-				{ fieldtype: 'Link', options: 'Medical Department', reqd:1, fieldname: 'department', label: 'Medical Department'},
+				{ fieldtype: 'Link', options: 'Medical Department', reqd: 1, fieldname: 'department', label: 'Medical Department'},
 				{ fieldtype: 'Column Break'},
-				{ fieldtype: 'Link', options: 'Healthcare Practitioner', reqd:1, fieldname: 'practitioner', label: 'Healthcare Practitioner'},
+				{ fieldtype: 'Link', options: 'Healthcare Practitioner', reqd: 1, fieldname: 'practitioner', label: 'Healthcare Practitioner'},
 				{ fieldtype: 'Column Break'},
-				{ fieldtype: 'Date', reqd:1, fieldname: 'appointment_date', label: 'Date'},
+				{ fieldtype: 'Date', reqd: 1, fieldname: 'appointment_date', label: 'Date'},
 				{ fieldtype: 'Section Break'},
 				{ fieldtype: 'HTML', fieldname: 'available_slots'}
+
 			],
-			primary_action_label: __("Book"),
+			primary_action_label: __('Book'),
 			primary_action: function() {
 				frm.set_value('appointment_time', selected_slot);
-				frm.set_value('service_unit', service_unit || '');
 				frm.set_value('duration', duration);
 				frm.set_value('practitioner', d.get_value('practitioner'));
 				frm.set_value('department', d.get_value('department'));
 				frm.set_value('appointment_date', d.get_value('appointment_date'));
+				if (service_unit) {
+					frm.set_value('service_unit', service_unit);
+				}
 				d.hide();
 				frm.enable_save();
 				frm.save();
@@ -167,16 +181,16 @@
 			'appointment_date': frm.doc.appointment_date
 		});
 
-		d.fields_dict["department"].df.onchange = () => {
+		d.fields_dict['department'].df.onchange = () => {
 			d.set_values({
 				'practitioner': ''
 			});
-			var department = d.get_value('department');
-			if(department){
+			let department = d.get_value('department');
+			if (department) {
 				d.fields_dict.practitioner.get_query = function() {
 					return {
 						filters: {
-							"department": department
+							'department': department
 						}
 					};
 				};
@@ -188,13 +202,13 @@
 
 		// Field Change Handler
 
-		var fd = d.fields_dict;
+		let fd = d.fields_dict;
 
-		d.fields_dict["appointment_date"].df.onchange = () => {
+		d.fields_dict['appointment_date'].df.onchange = () => {
 			show_slots(d, fd);
 		};
-		d.fields_dict["practitioner"].df.onchange = () => {
-			if(d.get_value('practitioner') && d.get_value('practitioner') != selected_practitioner){
+		d.fields_dict['practitioner'].df.onchange = () => {
+			if (d.get_value('practitioner') && d.get_value('practitioner') != selected_practitioner) {
 				selected_practitioner = d.get_value('practitioner');
 				show_slots(d, fd);
 			}
@@ -203,8 +217,8 @@
 	}
 
 	function show_slots(d, fd) {
-		if (d.get_value('appointment_date') && d.get_value('practitioner')){
-			fd.available_slots.html("");
+		if (d.get_value('appointment_date') && d.get_value('practitioner')) {
+			fd.available_slots.html('');
 			frappe.call({
 				method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_availability_data',
 				args: {
@@ -212,13 +226,13 @@
 					date: d.get_value('appointment_date')
 				},
 				callback: (r) => {
-					var data = r.message;
-					if(data.slot_details.length > 0) {
-						var $wrapper = d.fields_dict.available_slots.$wrapper;
+					let data = r.message;
+					if (data.slot_details.length > 0) {
+						let $wrapper = d.fields_dict.available_slots.$wrapper;
 
 						// make buttons for each slot
-						var slot_details = data.slot_details;
-						var slot_html = "";
+						let slot_details = data.slot_details;
+						let slot_html = '';
 						for (let i = 0; i < slot_details.length; i++) {
 							slot_html = slot_html + `<label>${slot_details[i].slot_name}</label>`;
 							slot_html = slot_html + `<br/>` + slot_details[i].avail_slot.map(slot => {
@@ -232,14 +246,14 @@
 									let booked_moment = moment(booked.appointment_time, 'HH:mm:ss');
 									let end_time = booked_moment.clone().add(booked.duration, 'minutes');
 									// Deal with 0 duration appointments
-									if(booked_moment.isSame(slot_start_time) || booked_moment.isBetween(slot_start_time, slot_to_time)){
+									if (booked_moment.isSame(slot_start_time) || booked_moment.isBetween(slot_start_time, slot_to_time)) {
 										if(booked.duration == 0){
 											disabled = 'disabled="disabled"';
 											return false;
 										}
 									}
 									// Check for overlaps considering appointment duration
-									if(slot_start_time.isBefore(end_time) && slot_to_time.isAfter(booked_moment)){
+									if (slot_start_time.isBefore(end_time) && slot_to_time.isAfter(booked_moment)) {
 										// There is an overlap
 										disabled = 'disabled="disabled"';
 										return false;
@@ -263,7 +277,7 @@
 
 						// blue button when clicked
 						$wrapper.on('click', 'button', function() {
-							var $btn = $(this);
+							let $btn = $(this);
 							$wrapper.find('button').removeClass('btn-primary');
 							$btn.addClass('btn-primary');
 							selected_slot = $btn.attr('data-name');
@@ -273,48 +287,57 @@
 							d.get_primary_btn().attr('disabled', null);
 						});
 
-					}else {
-						//	fd.available_slots.html("Please select a valid date.".bold())
+					} else {
+						//	fd.available_slots.html('Please select a valid date.'.bold())
 						show_empty_state(d.get_value('practitioner'), d.get_value('appointment_date'));
 					}
 				},
 				freeze: true,
-				freeze_message: __("Fetching records......")
+				freeze_message: __('Fetching records......')
 			});
-		}else{
-			fd.available_slots.html("Appointment date and Healthcare Practitioner are Mandatory".bold());
+		} else {
+			fd.available_slots.html('Appointment date and Healthcare Practitioner are Mandatory'.bold());
 		}
 	}
 };
 
-var get_procedure_prescribed = function(frm){
-	if(frm.doc.patient){
+let get_prescribed_procedure = function(frm) {
+	if (frm.doc.patient) {
 		frappe.call({
-			method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed",
+			method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.get_procedure_prescribed',
 			args: {patient: frm.doc.patient},
-			callback: function(r){
-				show_procedure_templates(frm, r.message);
+			callback: function(r) {
+				if (r.message && r.message.length) {
+					show_procedure_templates(frm, r.message);
+				} else {
+					frappe.msgprint({
+						title: __('Not Found'),
+						message: __('No Prescribed Procedures found for the selected Patient')
+					});
+				}
 			}
 		});
-	}
-	else{
-		frappe.msgprint(__("Please select Patient to get prescribed procedure"));
+	} else {
+		frappe.msgprint({
+			title: __('Not Allowed'),
+			message: __('Please select a Patient first')
+		});
 	}
 };
 
-var show_procedure_templates = function(frm, result){
-	var d = new frappe.ui.Dialog({
-		title: __("Prescribed Procedures"),
+let show_procedure_templates = function(frm, result){
+	let d = new frappe.ui.Dialog({
+		title: __('Prescribed Procedures'),
 		fields: [
 			{
-				fieldtype: "HTML", fieldname: "procedure_template"
+				fieldtype: 'HTML', fieldname: 'procedure_template'
 			}
 		]
 	});
-	var html_field = d.fields_dict.procedure_template.$wrapper;
+	let html_field = d.fields_dict.procedure_template.$wrapper;
 	html_field.empty();
-	$.each(result, function(x, y){
-		var row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
+	$.each(result, function(x, y) {
+		let row = $(repl('<div class="col-xs-12" style="padding-top:12px; text-align:center;" >\
 		<div class="col-xs-5"> %(encounter)s <br> %(consulting_practitioner)s <br> %(encounter_date)s </div>\
 		<div class="col-xs-5"> %(procedure_template)s <br>%(practitioner)s  <br> %(date)s</div>\
 		<div class="col-xs-2">\
@@ -326,76 +349,47 @@
 				encounter:y[2], consulting_practitioner:y[3], encounter_date:y[4],
 				practitioner:y[5]? y[5]:'', date: y[6]? y[6]:'', department: y[7]? y[7]:''})).appendTo(html_field);
 		row.find("a").click(function() {
-			frm.doc.procedure_template = $(this).attr("data-procedure-template");
-			frm.doc.procedure_prescription = $(this).attr("data-name");
-			frm.doc.practitioner = $(this).attr("data-practitioner");
-			frm.doc.appointment_date = $(this).attr("data-date");
-			frm.doc.department = $(this).attr("data-department");
-			refresh_field("procedure_template");
-			refresh_field("procedure_prescription");
-			refresh_field("appointment_date");
-			refresh_field("practitioner");
-			refresh_field("department");
+			frm.doc.procedure_template = $(this).attr('data-procedure-template');
+			frm.doc.procedure_prescription = $(this).attr('data-name');
+			frm.doc.practitioner = $(this).attr('data-practitioner');
+			frm.doc.appointment_date = $(this).attr('data-date');
+			frm.doc.department = $(this).attr('data-department');
+			refresh_field('procedure_template');
+			refresh_field('procedure_prescription');
+			refresh_field('appointment_date');
+			refresh_field('practitioner');
+			refresh_field('department');
 			d.hide();
 			return false;
 		});
 	});
-	if(!result){
-		var msg = "There are no procedure prescribed for "+frm.doc.patient;
+	if (!result) {
+		let msg = 'There are no procedure prescribed for '+frm.doc.patient;
 		$(repl('<div class="col-xs-12" style="padding-top:20px;" >%(msg)s</div></div>', {msg: msg})).appendTo(html_field);
 	}
 	d.show();
 };
 
-var btn_create_procedure = function(frm){
-	var doc = frm.doc;
-	frappe.call({
-		method:"erpnext.healthcare.doctype.clinical_procedure.clinical_procedure.create_procedure",
-		args: {appointment: doc.name},
-		callback: function(data){
-			if(!data.exc){
-				var doclist = frappe.model.sync(data.message);
-				frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
-			}
-		}
-	});
-};
-
-var btn_create_encounter = function(frm){
-	var doc = frm.doc;
-	frappe.call({
-		method:"erpnext.healthcare.doctype.patient_appointment.patient_appointment.create_encounter",
-		args: {appointment: doc.name},
-		callback: function(data){
-			if(!data.exc){
-				var doclist = frappe.model.sync(data.message);
-				frappe.set_route("Form", doclist[0].doctype, doclist[0].name);
-			}
-		}
-	});
-};
-
-var btn_create_vital_signs = function (frm) {
-	if(!frm.doc.patient){
-		frappe.throw(__("Please select patient"));
+let create_vital_signs = function(frm) {
+	if (!frm.doc.patient) {
+		frappe.throw(__('Please select patient'));
 	}
 	frappe.route_options = {
-		"patient": frm.doc.patient,
-		"appointment": frm.doc.name,
+		'patient': frm.doc.patient,
+		'appointment': frm.doc.name,
 	};
-	frappe.new_doc("Vital Signs");
+	frappe.new_doc('Vital Signs');
 };
 
-var btn_update_status = function(frm, status){
-	var doc = frm.doc;
+let update_status = function(frm, status){
+	let doc = frm.doc;
 	frappe.confirm(__('Are you sure you want to cancel this appointment?'),
 		function() {
 			frappe.call({
-				method:
-				"erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_status",
+				method: 'erpnext.healthcare.doctype.patient_appointment.patient_appointment.update_status',
 				args: {appointment_id: doc.name, status:status},
-				callback: function(data){
-					if(!data.exc){
+				callback: function(data) {
+					if (!data.exc) {
 						frm.reload_doc();
 					}
 				}
@@ -404,60 +398,60 @@
 	);
 };
 
-frappe.ui.form.on("Patient Appointment", "practitioner", function(frm) {
-	if(frm.doc.practitioner){
+frappe.ui.form.on('Patient Appointment', 'practitioner', function(frm) {
+	if (frm.doc.practitioner) {
 		frappe.call({
-			"method": "frappe.client.get",
+			method: 'frappe.client.get',
 			args: {
-				doctype: "Healthcare Practitioner",
+				doctype: 'Healthcare Practitioner',
 				name: frm.doc.practitioner
 			},
 			callback: function (data) {
-				frappe.model.set_value(frm.doctype,frm.docname, "department",data.message.department);
-				frappe.model.set_value(frm.doctype,frm.docname, "paid_amount",data.message.op_consulting_charge);
+				frappe.model.set_value(frm.doctype, frm.docname, 'department', data.message.department);
+				frappe.model.set_value(frm.doctype, frm.docname, 'paid_amount', data.message.op_consulting_charge);
 			}
 		});
 	}
 });
 
-frappe.ui.form.on("Patient Appointment", "patient", function(frm) {
-	if(frm.doc.patient){
+frappe.ui.form.on('Patient Appointment', 'patient', function(frm) {
+	if (frm.doc.patient) {
 		frappe.call({
-			"method": "frappe.client.get",
+			method: 'frappe.client.get',
 			args: {
-				doctype: "Patient",
+				doctype: 'Patient',
 				name: frm.doc.patient
 			},
 			callback: function (data) {
-				var age = null;
-				if(data.message.dob){
+				let age = null;
+				if (data.message.dob) {
 					age = calculate_age(data.message.dob);
 				}
-				frappe.model.set_value(frm.doctype,frm.docname, "patient_age", age);
+				frappe.model.set_value(frm.doctype,frm.docname, 'patient_age', age);
 			}
 		});
 	}
 });
 
-frappe.ui.form.on("Patient Appointment", "appointment_type", function(frm) {
-	if(frm.doc.appointment_type) {
+frappe.ui.form.on('Patient Appointment', 'appointment_type', function(frm) {
+	if (frm.doc.appointment_type) {
 		frappe.call({
-			"method": "frappe.client.get",
+			method: 'frappe.client.get',
 			args: {
-				doctype: "Appointment Type",
+				doctype: 'Appointment Type',
 				name: frm.doc.appointment_type
 			},
-			callback: function (data) {
-				frappe.model.set_value(frm.doctype,frm.docname, "duration",data.message.default_duration);
+			callback: function(data) {
+				frappe.model.set_value(frm.doctype,frm.docname, 'duration',data.message.default_duration);
 			}
 		});
 	}
 });
 
-var calculate_age = function(birth) {
-	var ageMS = Date.parse(Date()) - Date.parse(birth);
-	var age = new Date();
+let calculate_age = function(birth) {
+	let ageMS = Date.parse(Date()) - Date.parse(birth);
+	let age = new Date();
 	age.setTime(ageMS);
-	var years =  age.getFullYear() - 1970;
-	return  years + " Year(s) " + age.getMonth() + " Month(s) " + age.getDate() + " Day(s)";
+	let years =  age.getFullYear() - 1970;
+	return  years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
 };
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
index ee9f013..be43184 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
@@ -1,1177 +1,334 @@
 {
+ "actions": [],
  "allow_copy": 1,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
  "allow_import": 1,
- "allow_rename": 0,
- "autoname": "OP-.######",
+ "autoname": "naming_series:",
  "beta": 1,
  "creation": "2017-05-04 11:52:40.941507",
- "custom": 0,
- "docstatus": 0,
  "doctype": "DocType",
  "document_type": "Document",
- "editable_grid": 0,
  "engine": "InnoDB",
+ "field_order": [
+  "naming_series",
+  "patient",
+  "patient_name",
+  "patient_sex",
+  "patient_age",
+  "inpatient_record",
+  "column_break_1",
+  "status",
+  "procedure_template",
+  "get_procedure_from_encounter",
+  "procedure_prescription",
+  "service_unit",
+  "section_break_12",
+  "practitioner",
+  "department",
+  "appointment_type",
+  "column_break_17",
+  "appointment_date",
+  "appointment_time",
+  "appointment_datetime",
+  "duration",
+  "section_break_16",
+  "mode_of_payment",
+  "paid_amount",
+  "company",
+  "column_break_2",
+  "invoiced",
+  "ref_sales_invoice",
+  "section_break_3",
+  "notes",
+  "referring_practitioner",
+  "reminded"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "patient.inpatient_record",
    "fieldname": "inpatient_record",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Inpatient Record",
-   "length": 0,
-   "no_copy": 0,
    "options": "Inpatient Record",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "inpatient_record.patient",
    "fieldname": "patient",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Patient",
-   "length": 0,
-   "no_copy": 0,
    "options": "Patient",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
    "reqd": 1,
    "search_index": 1,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "appointment_type",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Appointment Type",
-   "length": 0,
-   "no_copy": 0,
    "options": "Appointment Type",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "description": "In Minutes",
    "fieldname": "duration",
    "fieldtype": "Int",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
    "in_filter": 1,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Duration",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Duration (In Minutes)"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_1",
    "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "default": "Scheduled",
    "depends_on": "eval:!doc.__islocal",
    "fieldname": "status",
    "fieldtype": "Select",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
    "in_filter": 1,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
+   "in_list_view": 1,
    "label": "Status",
-   "length": 0,
-   "no_copy": 0,
-   "options": "\nScheduled\nOpen\nClosed\nPending\nCancelled",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
+   "options": "\nScheduled\nOpen\nClosed\nExpired\nCancelled",
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "procedure_template",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Procedure",
-   "length": 0,
-   "no_copy": 0,
+   "label": "Clinical Procedure Template",
    "options": "Clinical Procedure Template",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
+   "depends_on": "eval:doc.__islocal && doc.patient",
    "fieldname": "get_procedure_from_encounter",
    "fieldtype": "Button",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Get prescribed procedures",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Get Prescribed Clinical Procedures"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "procedure_prescription",
    "fieldtype": "Link",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Procedure Prescription",
-   "length": 0,
    "no_copy": 1,
    "options": "Procedure Prescription",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "print_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "service_unit",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Service Unit",
-   "length": 0,
-   "no_copy": 0,
    "options": "Healthcare Service Unit",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "eval:doc.__islocal",
-   "fieldname": "check_availability",
-   "fieldtype": "Button",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Check availability",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
-  },
-  {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "section_break_12",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Section Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "practitioner",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
    "in_standard_filter": 1,
    "label": "Healthcare Practitioner",
-   "length": 0,
-   "no_copy": 0,
    "options": "Healthcare Practitioner",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
    "reqd": 1,
    "search_index": 1,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "department",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Department",
-   "length": 0,
-   "no_copy": 0,
    "options": "Medical Department",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
    "search_index": 1,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "set_only_once": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_17",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "appointment_date",
    "fieldtype": "Date",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
    "in_standard_filter": 1,
    "label": "Date",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
    "reqd": 1,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "appointment_time",
    "fieldtype": "Time",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
    "in_list_view": 1,
-   "in_standard_filter": 0,
    "label": "Time",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "section_break_16",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Section Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "",
    "fetch_from": "patient.patient_name",
    "fieldname": "patient_name",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Patient Name",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fetch_from": "patient.sex",
    "fieldname": "patient_sex",
-   "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
+   "fieldtype": "Link",
    "label": "Gender",
-   "length": 0,
    "no_copy": 1,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
+   "options": "Gender",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
    "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "fieldname": "column_break_21",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
-  },
-  {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "patient_age",
    "fieldtype": "Data",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Patient Age",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
-   "depends_on": "",
-   "fieldname": "section_break_1",
-   "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
-  },
-  {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "appointment_datetime",
    "fieldtype": "Datetime",
-   "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Date TIme",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
+   "label": "Appointment Datetime",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
+   "read_only": 1,
    "report_hide": 1,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "search_index": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "mode_of_payment",
    "fieldtype": "Link",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Mode of Payment",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Mode of Payment",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "options": "Mode of Payment"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "paid_amount",
    "fieldtype": "Currency",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Paid Amount",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Paid Amount"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "column_break_2",
-   "fieldtype": "Column Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "fieldtype": "Column Break"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
    "fieldname": "invoiced",
    "fieldtype": "Check",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
+   "in_list_view": 1,
    "label": "Invoiced",
-   "length": 0,
-   "no_copy": 0,
-   "options": "",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 1,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 1,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "read_only": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "company",
    "fieldtype": "Link",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Company",
-   "length": 0,
    "no_copy": 1,
    "options": "Company",
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
    "collapsible": 1,
-   "columns": 0,
    "fieldname": "section_break_3",
    "fieldtype": "Section Break",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "More Info",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "More Info"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "notes",
    "fieldtype": "Small Text",
-   "hidden": 0,
-   "ignore_user_permissions": 0,
    "ignore_xss_filter": 1,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
-   "label": "Notes",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "label": "Notes"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "fieldname": "referring_practitioner",
    "fieldtype": "Link",
-   "hidden": 0,
    "ignore_user_permissions": 1,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Referring Practitioner",
-   "length": 0,
-   "no_copy": 0,
-   "options": "Healthcare Practitioner",
-   "permlevel": 0,
-   "precision": "",
-   "print_hide": 0,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 0,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 1,
-   "translatable": 0,
-   "unique": 0
+   "options": "Healthcare Practitioner"
   },
   {
-   "allow_bulk_edit": 0,
-   "allow_in_quick_entry": 0,
-   "allow_on_submit": 0,
-   "bold": 0,
-   "collapsible": 0,
-   "columns": 0,
    "default": "0",
    "fieldname": "reminded",
    "fieldtype": "Check",
    "hidden": 1,
-   "ignore_user_permissions": 0,
-   "ignore_xss_filter": 0,
-   "in_filter": 0,
-   "in_global_search": 0,
-   "in_list_view": 0,
-   "in_standard_filter": 0,
    "label": "Reminded",
-   "length": 0,
-   "no_copy": 0,
-   "permlevel": 0,
-   "precision": "",
    "print_hide": 1,
-   "print_hide_if_no_value": 0,
-   "read_only": 0,
-   "remember_last_selected_value": 0,
-   "report_hide": 1,
-   "reqd": 0,
-   "search_index": 0,
-   "set_only_once": 0,
-   "translatable": 0,
-   "unique": 0
+   "report_hide": 1
+  },
+  {
+   "fieldname": "ref_sales_invoice",
+   "fieldtype": "Link",
+   "label": "Reference Sales Invoice",
+   "options": "Sales Invoice",
+   "read_only": 1
+  },
+  {
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "options": "HLC-APP-.YYYY.-",
+   "set_only_once": 1
   }
  ],
- "has_web_view": 0,
- "hide_heading": 0,
- "hide_toolbar": 0,
- "idx": 0,
- "image_view": 0,
- "in_create": 0,
- "is_submittable": 0,
- "issingle": 0,
- "istable": 0,
- "max_attachments": 0,
- "modified": "2018-11-14 13:24:01.529536",
+ "links": [],
+ "modified": "2020-02-25 17:57:56.971064",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient Appointment",
- "name_case": "",
  "owner": "Administrator",
  "permissions": [
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Healthcare Administrator",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Physician",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   },
   {
-   "amend": 0,
-   "cancel": 0,
    "create": 1,
    "delete": 1,
    "email": 1,
    "export": 1,
-   "if_owner": 0,
-   "import": 0,
-   "permlevel": 0,
    "print": 1,
    "read": 1,
    "report": 1,
    "role": "Nursing User",
-   "set_user_permissions": 0,
    "share": 1,
-   "submit": 0,
    "write": 1
   }
  ],
- "quick_entry": 0,
- "read_only": 0,
- "read_only_onload": 0,
  "restrict_to_domain": "Healthcare",
  "search_fields": "patient, practitioner, department, appointment_date, appointment_time",
  "show_name_in_global_search": 1,
@@ -1179,6 +336,5 @@
  "sort_order": "DESC",
  "title_field": "patient",
  "track_changes": 1,
- "track_seen": 1,
- "track_views": 0
-}
+ "track_seen": 1
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index d562245..a88355a 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -7,25 +7,43 @@
 from frappe.model.document import Document
 import json
 from frappe.utils import getdate, add_days, get_time
+from frappe.model.mapper import get_mapped_doc
 from frappe import _
 import datetime
 from frappe.core.doctype.sms_settings.sms_settings import send_sms
 from erpnext.hr.doctype.employee.employee import is_holiday
-from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account,get_income_account
-from erpnext.healthcare.utils import validity_exists, service_item_and_practitioner_charge
+from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account
+from erpnext.healthcare.utils import check_validity_exists, get_service_item_and_practitioner_charge
 
 class PatientAppointment(Document):
-	def on_update(self):
-		today = datetime.date.today()
+	def validate(self):
+		self.validate_overlaps()
+		self.set_appointment_datetime()
+		self.validate_customer_created()
+		self.set_status()
+
+	def after_insert(self):
+		invoice_appointment(self)
+		self.update_prescription_details()
+		self.check_fee_validity()
+		send_confirmation_msg(self)
+
+	def set_status(self):
+		today = getdate()
 		appointment_date = getdate(self.appointment_date)
 
-		# If appointment created for today set as open
-		if today == appointment_date:
-			frappe.db.set_value("Patient Appointment", self.name, "status", "Open")
-			self.reload()
+		# If appointment is created for today set status as Open else Scheduled
+		if appointment_date == today:
+			self.status = 'Open'
+		elif appointment_date > today:
+			self.status = 'Scheduled'
+		elif appointment_date < today:
+			self.status = 'Expired'
 
-	def validate(self):
-		end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) + datetime.timedelta(minutes=float(self.duration))
+	def validate_overlaps(self):
+		end_time = datetime.datetime.combine(getdate(self.appointment_date), get_time(self.appointment_time)) \
+			 + datetime.timedelta(minutes=float(self.duration))
+
 		overlaps = frappe.db.sql("""
 		select
 			name, practitioner, patient, appointment_time, duration
@@ -41,135 +59,165 @@
 		self.appointment_time, end_time.time(), self.appointment_time, end_time.time(), self.appointment_time))
 
 		if overlaps:
-			frappe.throw(_("""Appointment overlaps with {0}.<br> {1} has appointment scheduled
-			with {2} at {3} having {4} minute(s) duration.""").format(overlaps[0][0], overlaps[0][1], overlaps[0][2], overlaps[0][3], overlaps[0][4]))
+			overlapping_details = _('Appointment overlaps with {0}').format(overlaps[0][0])
+			overlapping_details += '<br>'
+			overlapping_details += _('{0} has appointment scheduled with {1} at {2} having {3} minute(s) duration.').format(
+				overlaps[0][1], overlaps[0][2], overlaps[0][3], overlaps[0][4])
+			frappe.throw(overlapping_details, title=_('Appointments Overlapping'))
 
-	def after_insert(self):
+	def set_appointment_datetime(self):
+		self.appointment_datetime = "%s %s" % (self.appointment_date, self.appointment_time or "00:00:00")
+
+	def validate_customer_created(self):
+		if frappe.db.get_single_value('Healthcare Settings', 'automate_appointment_invoicing'):
+			if not frappe.db.get_value('Patient', self.patient, 'customer'):
+				msg = _("Please create a Customer linked to the Patient")
+				msg +=  " <b><a href='#Form/Patient/{0}'>{0}</a></b>".format(self.patient)
+				frappe.throw(msg, title=_('Customer Not Found'))
+
+	def update_prescription_details(self):
 		if self.procedure_prescription:
-			frappe.db.set_value("Procedure Prescription", self.procedure_prescription, "appointment_booked", True)
+			frappe.db.set_value('Procedure Prescription', self.procedure_prescription, 'appointment_booked', 1)
 			if self.procedure_template:
-				comments = frappe.db.get_value("Procedure Prescription", self.procedure_prescription, "comments")
+				comments = frappe.db.get_value('Procedure Prescription', self.procedure_prescription, 'comments')
 				if comments:
-					frappe.db.set_value("Patient Appointment", self.name, "notes", comments)
+					frappe.db.set_value('Patient Appointment', self.name, 'notes', comments)
+
+	def check_fee_validity(self):
 		# Check fee validity exists
-		appointment = self
-		validity_exist = validity_exists(appointment.practitioner, appointment.patient)
-		if validity_exist:
-			fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
+		validity_exists = check_validity_exists(self.practitioner, self.patient)
+		if validity_exists:
+			fee_validity = frappe.get_doc('Fee Validity', validity_exists[0][0])
 
 			# Check if the validity is valid
-			appointment_date = getdate(appointment.appointment_date)
+			appointment_date = getdate(self.appointment_date)
 			if (fee_validity.valid_till >= appointment_date) and (fee_validity.visited < fee_validity.max_visit):
 				visited = fee_validity.visited + 1
-				frappe.db.set_value("Fee Validity", fee_validity.name, "visited", visited)
+				frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
 				if fee_validity.ref_invoice:
-					frappe.db.set_value("Patient Appointment", appointment.name, "invoiced", True)
-				frappe.msgprint(_("{0} has fee validity till {1}").format(appointment.patient, fee_validity.valid_till))
-		confirm_sms(self)
+					frappe.db.set_value('Patient Appointment', self.name, 'invoiced', True)
+					frappe.db.set_value('Patient Appointment', self.name, 'ref_sales_invoice', fee_validity.ref_invoice)
+				frappe.msgprint(_('{0} has fee validity till {1}').format(self.patient, fee_validity.valid_till))
 
-		if frappe.db.get_value("Healthcare Settings", None, "manage_appointment_invoice_automatically") == '1' and \
-			frappe.db.get_value("Patient Appointment", self.name, "invoiced") != 1:
-			invoice_appointment(self)
 
-@frappe.whitelist()
 def invoice_appointment(appointment_doc):
 	if not appointment_doc.name:
-		return False
-	sales_invoice = frappe.new_doc("Sales Invoice")
-	sales_invoice.customer = frappe.get_value("Patient", appointment_doc.patient, "customer")
-	sales_invoice.appointment = appointment_doc.name
-	sales_invoice.due_date = getdate()
-	sales_invoice.is_pos = True
-	sales_invoice.company = appointment_doc.company
-	sales_invoice.debit_to = get_receivable_account(appointment_doc.company)
+		return
 
-	item_line = sales_invoice.append("items")
-	service_item, practitioner_charge = service_item_and_practitioner_charge(appointment_doc)
-	item_line.item_code = service_item
-	item_line.description = "Consulting Charges:  " + appointment_doc.practitioner
-	item_line.income_account = get_income_account(appointment_doc.practitioner, appointment_doc.company)
-	item_line.rate = practitioner_charge
-	item_line.amount = practitioner_charge
-	item_line.qty = 1
-	item_line.reference_dt = "Patient Appointment"
-	item_line.reference_dn = appointment_doc.name
+	if frappe.db.get_single_value('Healthcare Settings', 'automate_appointment_invoicing') and \
+			not frappe.db.get_value('Patient Appointment', appointment_doc.name, 'invoiced'):
+		sales_invoice = frappe.new_doc('Sales Invoice')
+		sales_invoice.customer = frappe.get_value('Patient', appointment_doc.patient, 'customer')
+		sales_invoice.appointment = appointment_doc.name
+		sales_invoice.due_date = getdate()
+		sales_invoice.is_pos = True
+		sales_invoice.company = appointment_doc.company
+		sales_invoice.debit_to = get_receivable_account(appointment_doc.company)
 
-	payments_line = sales_invoice.append("payments")
-	payments_line.mode_of_payment = appointment_doc.mode_of_payment
-	payments_line.amount = appointment_doc.paid_amount
+		item = sales_invoice.append('items', {})
+		item = get_appointment_item(appointment_doc, item)
 
-	sales_invoice.set_missing_values(for_validate = True)
+		payment = sales_invoice.append('payments', {})
+		payment.mode_of_payment = appointment_doc.mode_of_payment
+		payment.amount = appointment_doc.paid_amount
 
-	sales_invoice.save(ignore_permissions=True)
-	sales_invoice.submit()
-	frappe.msgprint(_("Sales Invoice {0} created as paid").format(sales_invoice.name), alert=True)
+		sales_invoice.set_missing_values(for_validate=True)
+		frappe.as_json('Sales Invoice')
+		sales_invoice.save(ignore_permissions=True)
+		sales_invoice.submit()
+		frappe.msgprint(_('Sales Invoice {0} created as paid'.format(sales_invoice.name)), alert=True)
+		frappe.db.set_value('Patient Appointment', appointment_doc.name, 'invoiced', True)
+		frappe.db.set_value('Patient Appointment', appointment_doc.name, 'ref_sales_invoice', sales_invoice.name)
 
-def appointment_cancel(appointment_id):
-	appointment = frappe.get_doc("Patient Appointment", appointment_id)
-	# If invoiced --> fee_validity update with -1 visit
+
+def get_appointment_item(appointment_doc, item):
+	service_item, practitioner_charge = get_service_item_and_practitioner_charge(appointment_doc)
+	item.item_code = service_item
+	item.description = _('Consulting Charges: {0}').format(appointment_doc.practitioner)
+	item.income_account = get_income_account(appointment_doc.practitioner, appointment_doc.company)
+	item.rate = practitioner_charge
+	item.amount = practitioner_charge
+	item.qty = 1
+	item.reference_dt = 'Patient Appointment'
+	item.reference_dn = appointment_doc.name
+	return item
+
+
+def cancel_appointment(appointment_id):
+	appointment = frappe.get_doc('Patient Appointment', appointment_id)
+	# If invoiced --> fee_validity update visit as -1
 	if appointment.invoiced:
-		sales_invoice = exists_sales_invoice(appointment)
+		sales_invoice = check_sales_invoice_exists(appointment)
 		if sales_invoice and cancel_sales_invoice(sales_invoice):
 			frappe.msgprint(
-				_("Appointment {0} and Sales Invoice {1} cancelled").format(appointment.name, sales_invoice.name)
+				_('Appointment {0} and Sales Invoice {1} cancelled'.format(appointment.name, sales_invoice.name))
 			)
 		else:
-			validity = validity_exists(appointment.practitioner, appointment.patient)
+			validity = check_validity_exists(appointment.practitioner, appointment.patient)
 			if validity:
-				fee_validity = frappe.get_doc("Fee Validity", validity[0][0])
-				if appointment_valid_in_fee_validity(appointment, fee_validity.valid_till, True, fee_validity.ref_invoice):
+				fee_validity = frappe.get_doc('Fee Validity', validity)
+				if validate_appointment_in_fee_validity(appointment, fee_validity.valid_till, fee_validity.ref_invoice):
 					visited = fee_validity.visited - 1
-					frappe.db.set_value("Fee Validity", fee_validity.name, "visited", visited)
+					frappe.db.set_value('Fee Validity', fee_validity.name, 'visited', visited)
 					frappe.msgprint(
-						_("Appointment cancelled, Please review and cancel the invoice {0}").format(fee_validity.ref_invoice)
+						_('Appointment cancelled. Please review and cancel the invoice {0}'.format(fee_validity.ref_invoice))
 					)
 				else:
-					frappe.msgprint(_("Appointment cancelled"))
+					frappe.msgprint(_('Appointment Cancelled'))
 			else:
-				frappe.msgprint(_("Appointment cancelled"))
+				frappe.msgprint(_('Appointment Cancelled'))
 	else:
-		frappe.msgprint(_("Appointment cancelled"))
+		frappe.msgprint(_('Appointment Cancelled'))
 
-def appointment_valid_in_fee_validity(appointment, valid_end_date, invoiced, ref_invoice):
-	valid_days = frappe.db.get_value("Healthcare Settings", None, "valid_days")
-	max_visit = frappe.db.get_value("Healthcare Settings", None, "max_visit")
+
+def validate_appointment_in_fee_validity(appointment, valid_end_date, ref_invoice):
+	valid_days = frappe.db.get_single_value('Healthcare Settings', 'valid_days')
+	max_visit = frappe.db.get_single_value('Healthcare Settings', 'max_visit')
 	valid_start_date = add_days(getdate(valid_end_date), -int(valid_days))
 
-	# Appointments which has same fee validity range with the appointment
-	appointments = frappe.get_list("Patient Appointment",{'patient': appointment.patient, 'invoiced': invoiced,
-	'appointment_date':("<=", getdate(valid_end_date)), 'appointment_date':(">=", getdate(valid_start_date)),
-	'practitioner': appointment.practitioner}, order_by="appointment_date desc", limit=int(max_visit))
+	# Appointments which have same fee validity range with the appointment
+	appointments = frappe.get_list('Patient Appointment', {
+		'patient': appointment.patient,
+		'invoiced': True,
+		'appointment_date': ('<=', getdate(valid_end_date)),
+		'appointment_date':('>=', getdate(valid_start_date)),
+		'practitioner': appointment.practitioner
+		}, order_by='appointment_date desc', limit=int(max_visit))
 
 	if appointments and len(appointments) > 0:
 		appointment_obj = appointments[len(appointments)-1]
-		sales_invoice = exists_sales_invoice(appointment_obj)
+		sales_invoice = check_sales_invoice_exists(appointment_obj)
 		if sales_invoice.name == ref_invoice:
 			return True
 	return False
 
+
 def cancel_sales_invoice(sales_invoice):
-	if frappe.db.get_value("Healthcare Settings", None, "manage_appointment_invoice_automatically") == '1':
+	if frappe.db.get_single_value('Healthcare Settings', 'automate_appointment_invoicing'):
 		if len(sales_invoice.items) == 1:
 			sales_invoice.cancel()
 			return True
 	return False
 
-def exists_sales_invoice_item(appointment):
+
+def check_si_item_exists(appointment):
 	return frappe.db.exists(
-		"Sales Invoice Item",
+		'Sales Invoice Item',
 		{
-			"reference_dt": "Patient Appointment",
-			"reference_dn": appointment.name
+			'reference_dt': 'Patient Appointment',
+			'reference_dn': appointment.name
 		}
 	)
 
-def exists_sales_invoice(appointment):
-	sales_item_exist = exists_sales_invoice_item(appointment)
-	if sales_item_exist:
-		sales_invoice = frappe.get_doc("Sales Invoice", frappe.db.get_value("Sales Invoice Item", sales_item_exist, "parent"))
+
+def check_sales_invoice_exists(appointment):
+	si_item = check_si_item_exists(appointment)
+	if si_item:
+		sales_invoice = frappe.get_doc('Sales Invoice', frappe.db.get_value('Sales Invoice Item', si_item, 'parent'))
 		return sales_invoice
 	return False
 
+
 @frappe.whitelist()
 def get_availability_data(date, practitioner):
 	"""
@@ -180,169 +228,163 @@
 	"""
 
 	date = getdate(date)
-	weekday = date.strftime("%A")
+	weekday = date.strftime('%A')
 
-	available_slots = []
-	slot_details = []
-	practitioner_schedule = None
+	practitioner_doc = frappe.get_doc('Healthcare Practitioner', practitioner)
 
+	check_employee_wise_availability(date, practitioner_doc)
+
+	if practitioner_doc.practitioner_schedules:
+		slot_details = get_available_slots(practitioner_doc.practitioner_schedules, date)
+	else:
+		frappe.throw(_('{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner master').format(
+			practitioner), title=_('Practitioner Schedule Not Found'))
+
+
+	if not slot_details:
+		# TODO: return available slots in nearby dates
+		frappe.throw(_('Healthcare Practitioner not available on {0}').format(weekday), title=_('Not Available'))
+
+	return {'slot_details': slot_details}
+
+
+def check_employee_wise_availability(date, practitioner_doc):
 	employee = None
-
-	practitioner_obj = frappe.get_doc("Healthcare Practitioner", practitioner)
-
-	# Get practitioner employee relation
-	if practitioner_obj.employee:
-		employee = practitioner_obj.employee
-	elif practitioner_obj.user_id:
-		if frappe.db.exists({
-			"doctype": "Employee",
-			"user_id": practitioner_obj.user_id
-			}):
-			employee = frappe.get_doc("Employee", {"user_id": practitioner_obj.user_id}).name
+	if practitioner_doc.employee:
+		employee = practitioner_doc.employee
+	elif practitioner_doc.user_id:
+		employee = frappe.db.get_value('Employee', {'user_id': practitioner_doc.user_id}, 'name')
 
 	if employee:
-		# Check if it is Holiday
+		# check holiday
 		if is_holiday(employee, date):
-			frappe.throw(_("{0} is a company holiday").format(date))
+			frappe.throw(_('{0} is a holiday'.format(date)), title=_('Not Available'))
 
-		# Check if He/She on Leave
+		# check leave status
 		leave_record = frappe.db.sql("""select half_day from `tabLeave Application`
 			where employee = %s and %s between from_date and to_date
 			and docstatus = 1""", (employee, date), as_dict=True)
 		if leave_record:
 			if leave_record[0].half_day:
-				frappe.throw(_("{0} on Half day Leave on {1}").format(practitioner, date))
+				frappe.throw(_('{0} is on a Half day Leave on {1}').format(practitioner_doc.name, date), title=_('Not Available'))
 			else:
-				frappe.throw(_("{0} on Leave on {1}").format(practitioner, date))
+				frappe.throw(_('{0} is on Leave on {1}').format(practitioner_doc.name, date), title=_('Not Available'))
 
-	# get practitioners schedule
-	if practitioner_obj.practitioner_schedules:
-		for schedule in practitioner_obj.practitioner_schedules:
-			if schedule.schedule:
-				practitioner_schedule = frappe.get_doc("Practitioner Schedule", schedule.schedule)
-			else:
-				frappe.throw(_("{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner master").format(practitioner))
 
-			if practitioner_schedule:
-				available_slots = []
-				for t in practitioner_schedule.time_slots:
-					if weekday == t.day:
-						available_slots.append(t)
+def get_available_slots(practitioner_schedules, date):
+	available_slots = []
+	slot_details = []
+	weekday = date.strftime('%A')
+	practitioner = None
 
-				if available_slots:
-					appointments = []
+	for schedule_entry in 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'))
 
-					if schedule.service_unit:
-						slot_name  = schedule.schedule+" - "+schedule.service_unit
-						allow_overlap = frappe.get_value('Healthcare Service Unit', schedule.service_unit, 'overlap_appointments')
-						if allow_overlap:
-							# fetch all appointments to practitioner by service unit
-							appointments = frappe.get_all(
-								"Patient Appointment",
-								filters={"practitioner": practitioner, "service_unit": schedule.service_unit, "appointment_date": date, "status": ["not in",["Cancelled"]]},
-								fields=["name", "appointment_time", "duration", "status"])
-						else:
-							# fetch all appointments to service unit
-							appointments = frappe.get_all(
-								"Patient Appointment",
-								filters={"service_unit": schedule.service_unit, "appointment_date": date, "status": ["not in",["Cancelled"]]},
-								fields=["name", "appointment_time", "duration", "status"])
-					else:
-						slot_name = schedule.schedule
-						# fetch all appointments to practitioner without service unit
-						appointments = frappe.get_all(
-							"Patient Appointment",
-							filters={"practitioner": practitioner, "service_unit": '', "appointment_date": date, "status": ["not in",["Cancelled"]]},
-							fields=["name", "appointment_time", "duration", "status"])
+		if practitioner_schedule:
+			available_slots = []
+			for time_slot in practitioner_schedule.time_slots:
+				if weekday == time_slot.day:
+					available_slots.append(time_slot)
 
-					slot_details.append({"slot_name":slot_name, "service_unit":schedule.service_unit,
-						"avail_slot":available_slots, 'appointments': appointments})
+			if available_slots:
+				appointments = []
+				# fetch all appointments to practitioner by service unit
+				filters = {
+					'practitioner': practitioner,
+					'service_unit': schedule_entry.service_unit,
+					'appointment_date': date,
+					'status': ['not in',['Cancelled']]
+				}
 
-	else:
-		frappe.throw(_("{0} does not have a Healthcare Practitioner Schedule. Add it in Healthcare Practitioner master").format(practitioner))
+				if schedule_entry.service_unit:
+					slot_name  = schedule_entry.schedule + ' - ' + schedule_entry.service_unit
+					allow_overlap = frappe.get_value('Healthcare Service Unit', schedule_entry.service_unit, 'overlap_appointments')
+					if not allow_overlap:
+						# fetch all appointments to service unit
+						filters.pop('practitioner')
+				else:
+					slot_name = schedule_entry.schedule
+					# fetch all appointments to practitioner without service unit
+					filters['practitioner'] = practitioner
+					filters['service_unit'] = ''
 
-	if not available_slots and not slot_details:
-		# TODO: return available slots in nearby dates
-		frappe.throw(_("Healthcare Practitioner not available on {0}").format(weekday))
+				appointments = frappe.get_all(
+					'Patient Appointment',
+					filters=filters,
+					fields=['name', 'appointment_time', 'duration', 'status'])
 
-	return {
-		"slot_details": slot_details
-	}
+				slot_details.append({'slot_name':slot_name, 'service_unit':schedule_entry.service_unit,
+					'avail_slot':available_slots, 'appointments': appointments})
+
+	return slot_details
 
 
 @frappe.whitelist()
 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)
 	appointment_booked = True
-	if status == "Cancelled":
+	if status == 'Cancelled':
 		appointment_booked = False
-		appointment_cancel(appointment_id)
+		cancel_appointment(appointment_id)
 
-	procedure_prescription = frappe.db.get_value("Patient Appointment", appointment_id, "procedure_prescription")
+	procedure_prescription = frappe.db.get_value('Patient Appointment', appointment_id, 'procedure_prescription')
 	if procedure_prescription:
-		frappe.db.set_value("Procedure Prescription", procedure_prescription, "appointment_booked", appointment_booked)
+		frappe.db.set_value('Procedure Prescription', procedure_prescription, 'appointment_booked', appointment_booked)
 
 
-@frappe.whitelist()
-def set_open_appointments():
-	today = getdate()
-	frappe.db.sql(
-		"update `tabPatient Appointment` set status='Open' where status = 'Scheduled'"
-		" and appointment_date = %s", today)
-
-
-@frappe.whitelist()
-def set_pending_appointments():
-	today = getdate()
-	frappe.db.sql(
-		"update `tabPatient Appointment` set status='Pending' where status in "
-		"('Scheduled','Open') and appointment_date < %s", today)
-
-
-def confirm_sms(doc):
-	if frappe.db.get_value("Healthcare Settings", None, "app_con") == '1':
-		message = frappe.db.get_value("Healthcare Settings", None, "app_con_msg")
+def send_confirmation_msg(doc):
+	if frappe.db.get_single_value('Healthcare Settings', 'send_appointment_confirmation'):
+		message = frappe.db.get_single_value('Healthcare Settings', 'appointment_confirmation_msg')
 		send_message(doc, message)
 
+
 @frappe.whitelist()
-def create_encounter(appointment):
-	appointment = frappe.get_doc("Patient Appointment", appointment)
-	encounter = frappe.new_doc("Patient Encounter")
-	encounter.appointment = appointment.name
-	encounter.patient = appointment.patient
-	encounter.practitioner = appointment.practitioner
-	encounter.visit_department = appointment.department
-	encounter.patient_sex = appointment.patient_sex
-	encounter.encounter_date = appointment.appointment_date
-	if appointment.invoiced:
-		encounter.invoiced = True
-	return encounter.as_dict()
+def make_encounter(source_name, target_doc=None):
+	doc = get_mapped_doc('Patient Appointment', source_name, {
+		'Patient Appointment': {
+			'doctype': 'Patient Encounter',
+			'field_map': [
+				['appointment', 'name'],
+				['patient', 'patient'],
+				['practitioner', 'practitioner'],
+				['medical_department', 'department'],
+				['patient_sex', 'patient_sex'],
+				['encounter_date', 'appointment_date'],
+				['invoiced', 'invoiced']
+			]
+		}
+	}, target_doc)
+	return doc
 
 
-def remind_appointment():
-	if frappe.db.get_value("Healthcare Settings", None, "app_rem") == '1':
-		rem_before = datetime.datetime.strptime(frappe.get_value("Healthcare Settings", None, "rem_before"), "%H:%M:%S")
-		rem_dt = datetime.datetime.now() + datetime.timedelta(
-			hours=rem_before.hour, minutes=rem_before.minute, seconds=rem_before.second)
+def send_appointment_reminder():
+	if frappe.db.get_single_value('Healthcare Settings', 'send_appointment_reminder'):
+		remind_before = datetime.datetime.strptime(frappe.db.get_single_value('Healthcare Settings', 'remind_before'), '%H:%M:%S')
+		reminder_dt = datetime.datetime.now() + datetime.timedelta(
+			hours=remind_before.hour, minutes=remind_before.minute, seconds=remind_before.second)
 
-		appointment_list = frappe.db.sql(
-			"select name from `tabPatient Appointment` where start_dt between %s and %s and reminded = 0 ",
-			(datetime.datetime.now(), rem_dt)
-		)
+		appointment_list = frappe.db.get_all('Patient Appointment', {
+			'appointment_datetime': ['between', (datetime.datetime.now(), reminder_dt)],
+			'reminded': 0,
+			'status': ['!=', 'Cancelled']
+		})
 
-		for i in range(0, len(appointment_list)):
-			doc = frappe.get_doc("Patient Appointment", appointment_list[i][0])
-			message = frappe.db.get_value("Healthcare Settings", None, "app_rem_msg")
+		for appointment in appointment_list:
+			doc = frappe.get_doc('Patient Appointment', appointment.name)
+			message = frappe.db.get_single_value('Healthcare Settings', 'appointment_reminder_msg')
 			send_message(doc, message)
-			frappe.db.set_value("Patient Appointment", doc.name, "reminded",1)
-
+			frappe.db.set_value('Patient Appointment', doc.name, 'reminded', 1)
 
 def send_message(doc, message):
-	patient = frappe.get_doc("Patient", doc.patient)
+	patient = frappe.get_doc('Patient', doc.patient)
 	if patient.mobile:
-		context = {"doc": doc, "alert": doc, "comments": None}
-		if doc.get("_comments"):
-			context["comments"] = json.loads(doc.get("_comments"))
+		context = {'doc': doc, 'alert': doc, 'comments': None}
+		if doc.get('_comments'):
+			context['comments'] = json.loads(doc.get('_comments'))
 
 		# jinja to string convertion happens here
 		message = frappe.render_template(message, context)
@@ -359,7 +401,7 @@
 	:param filters: Filters (JSON).
 	"""
 	from frappe.desk.calendar import get_event_conditions
-	conditions = get_event_conditions("Patient Appointment", filters)
+	conditions = get_event_conditions('Patient Appointment', filters)
 
 	data = frappe.db.sql("""
 		select
@@ -381,6 +423,7 @@
 
 	return data
 
+
 @frappe.whitelist()
 def get_procedure_prescribed(patient):
 	return frappe.db.sql("""select pp.name, pp.procedure, pp.parent, ct.practitioner,
@@ -388,3 +431,12 @@
 	from `tabPatient Encounter` ct, `tabProcedure Prescription` pp
 	where ct.patient='{0}' and pp.parent=ct.name and pp.appointment_booked=0
 	order by ct.creation desc""".format(patient))
+
+def update_appointment_status():
+	# update the status of appointments daily
+
+	frappe.db.sql("""update `tabPatient Appointment` set status = 'Open'
+		where appointment_date = CURDATE() and status = 'Scheduled'""")
+
+	frappe.db.sql("""update `tabPatient Appointment` set status = 'Expired'
+		where appointment_date < CURDATE() and status NOT IN ('Closed', 'Cancelled')""")
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment_list.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment_list.js
index 701cb69..721887b 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment_list.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment_list.js
@@ -3,4 +3,14 @@
 */
 frappe.listview_settings['Patient Appointment'] = {
 	filters: [["status", "=", "Open"]],
+	get_indicator: function(doc) {
+		var colors = {
+			"Open": "orange",
+			"Scheduled": "yellow",
+			"Closed": "green",
+			"Cancelled": "red",
+			"Expired": "grey"
+		};
+		return [__(doc.status), colors[doc.status], "status,=," + doc.status];
+	}
 };
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
index 088bc81..944986a 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
@@ -19,297 +19,229 @@
 	refresh: function(frm) {
 		refresh_field('drug_prescription');
 		refresh_field('lab_test_prescription');
-		if (!frm.doc.__islocal){
-			frappe.call({
-				method: 'frappe.client.get_value',
-				args: {
-					doctype: 'Patient',
-					fieldname: 'inpatient_status',
-					filters: {name: frm.doc.patient}
-				},
-				callback: function(data) {
-					if(data.message && data.message.inpatient_status == "Admission Scheduled" || data.message.inpatient_status == "Admitted"){
-						frm.add_custom_button(__('Schedule Discharge'), function() {
-							schedule_discharge(frm);
-						});
-					}
-					else if(data.message.inpatient_status != "Discharge Scheduled"){
-						frm.add_custom_button(__('Schedule Admission'), function() {
-							schedule_inpatient(frm);
-						});
-					}
-				}
-			});
-		}
-		frm.add_custom_button(__('Patient History'), function() {
-			if (frm.doc.patient) {
-				frappe.route_options = {"patient": frm.doc.patient};
-				frappe.set_route("patient_history");
-			} else {
-				frappe.msgprint(__("Please select Patient"));
+
+		if (!frm.doc.__islocal) {
+
+			if (frm.doc.inpatient_status == 'Admission Scheduled' || frm.doc.inpatient_status == 'Admitted') {
+				frm.add_custom_button(__('Schedule Discharge'), function() {
+					schedule_discharge(frm);
+				});
+			} else if (frm.doc.inpatient_status != 'Discharge Scheduled') {
+				frm.add_custom_button(__('Schedule Admission'), function() {
+					schedule_inpatient(frm);
+				});
 			}
-		},"View");
-		frm.add_custom_button(__('Vital Signs'), function() {
-			btn_create_vital_signs(frm);
-		},"Create");
-		frm.add_custom_button(__('Medical Record'), function() {
-			create_medical_record(frm);
-		},"Create");
 
-		frm.add_custom_button(__("Procedure"),function(){
-			btn_create_procedure(frm);
-		},"Create");
+			frm.add_custom_button(__('Patient History'), function() {
+				if (frm.doc.patient) {
+					frappe.route_options = {'patient': frm.doc.patient};
+					frappe.set_route('patient_history');
+				} else {
+					frappe.msgprint(__('Please select Patient'));
+				}
+			},'View');
 
-		frm.set_query("patient", function () {
+			frm.add_custom_button(__('Vital Signs'), function() {
+				create_vital_signs(frm);
+			},'Create');
+
+			frm.add_custom_button(__('Medical Record'), function() {
+				create_medical_record(frm);
+			},'Create');
+
+			frm.add_custom_button(__('Clinical Procedure'), function() {
+				create_procedure(frm);
+			},'Create');
+
+		}
+
+		frm.set_query('patient', function() {
 			return {
-				filters: {"disabled": 0}
+				filters: {'status': 'Active'}
 			};
 		});
-		frm.set_query("drug_code", "drug_prescription", function() {
+
+		frm.set_query('drug_code', 'drug_prescription', function() {
 			return {
 				filters: {
-					is_stock_item:'1'
+					is_stock_item: 1
 				}
 			};
 		});
-		frm.set_query("lab_test_code", "lab_test_prescription", function() {
+
+		frm.set_query('lab_test_code', 'lab_test_prescription', function() {
 			return {
 				filters: {
-					is_billable:'1'
+					is_billable: 1
 				}
 			};
 		});
-		frm.set_query("medical_code", "codification_table", function() {
-			return {
-				filters: {
-					medical_code_standard: frappe.defaults.get_default("default_medical_code_standard")
-				}
-			};
-		});
-		frm.set_query("appointment", function() {
+
+		frm.set_query('appointment', function() {
 			return {
 				filters: {
 					//	Scheduled filter for demo ...
-					status:['in',["Open","Scheduled"]]
+					status:['in',['Open','Scheduled']]
 				}
 			};
 		});
-		frm.set_df_property("appointment", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("patient", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("patient_age", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("patient_sex", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("type", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("practitioner", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("visit_department", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("encounter_date", "read_only", frm.doc.__islocal ? 0:1);
-		frm.set_df_property("encounter_time", "read_only", frm.doc.__islocal ? 0:1);
-	}
-});
 
-var schedule_inpatient = function(frm) {
-	frappe.call({
-		method: "erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_inpatient",
-		args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
-		callback: function(data) {
-			if(!data.exc){
-				frm.reload_doc();
-			}
-		},
-		freeze: true,
-		freeze_message: "Process Inpatient Scheduling"
-	});
-};
+		frm.set_df_property('patient', 'read_only', frm.doc.appointment ? 1 : 0);
+	},
 
-var schedule_discharge = function(frm) {
-	frappe.call({
-		method: "erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_discharge",
-		args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
-		callback: function(data) {
-			if(!data.exc){
-				frm.reload_doc();
-			}
-		},
-		freeze: true,
-		freeze_message: "Process Discharge"
-	});
-};
+	appointment: function(frm) {
+		frm.events.set_appointment_fields(frm);
+	},
 
-var create_medical_record = function (frm) {
-	if(!frm.doc.patient){
-		frappe.throw(__("Please select patient"));
-	}
-	frappe.route_options = {
-		"patient": frm.doc.patient,
-		"status": "Open",
-		"reference_doctype": "Patient Medical Record",
-		"reference_owner": frm.doc.owner
-	};
-	frappe.new_doc("Patient Medical Record");
-};
+	patient: function(frm) {
+		frm.events.set_patient_info(frm);
+	},
 
-var btn_create_vital_signs = function (frm) {
-	if(!frm.doc.patient){
-		frappe.throw(__("Please select patient"));
-	}
-	frappe.route_options = {
-		"patient": frm.doc.patient,
-		"appointment": frm.doc.appointment
-	};
-	frappe.new_doc("Vital Signs");
-};
-
-var btn_create_procedure = function (frm) {
-	if(!frm.doc.patient){
-		frappe.throw(__("Please select patient"));
-	}
-	frappe.route_options = {
-		"patient": frm.doc.patient,
-		"medical_department": frm.doc.visit_department
-	};
-	frappe.new_doc("Clinical Procedure");
-};
-
-frappe.ui.form.on("Patient Encounter", "appointment", function(frm){
-	if(frm.doc.appointment){
-		frappe.call({
-			"method": "frappe.client.get",
-			args: {
-				doctype: "Patient Appointment",
-				name: frm.doc.appointment
-			},
-			callback: function (data) {
-				frappe.model.set_value(frm.doctype,frm.docname, "patient", data.message.patient);
-				frappe.model.set_value(frm.doctype,frm.docname, "type", data.message.appointment_type);
-				frappe.model.set_value(frm.doctype,frm.docname, "practitioner", data.message.practitioner);
-				frappe.model.set_value(frm.doctype,frm.docname, "invoiced", data.message.invoiced);
-			}
-		});
-	}
-	else{
-		frappe.model.set_value(frm.doctype,frm.docname, "patient", "");
-		frappe.model.set_value(frm.doctype,frm.docname, "type", "");
-		frappe.model.set_value(frm.doctype,frm.docname, "practitioner", "");
-		frappe.model.set_value(frm.doctype,frm.docname, "invoiced", 0);
-	}
-});
-
-frappe.ui.form.on("Patient Encounter", "practitioner", function(frm) {
-	if(frm.doc.practitioner){
-		frappe.call({
-			"method": "frappe.client.get",
-			args: {
-				doctype: "Healthcare Practitioner",
-				name: frm.doc.practitioner
-			},
-			callback: function (data) {
-				frappe.model.set_value(frm.doctype,frm.docname, "visit_department",data.message.department);
-			}
-		});
-	}
-});
-
-frappe.ui.form.on("Patient Encounter", "symptoms_select", function(frm) {
-	if(frm.doc.symptoms_select){
-		var symptoms = null;
-		if(frm.doc.symptoms)
-			symptoms = frm.doc.symptoms + "\n" +frm.doc.symptoms_select;
-		else
-			symptoms = frm.doc.symptoms_select;
-		frappe.model.set_value(frm.doctype,frm.docname, "symptoms", symptoms);
-		frappe.model.set_value(frm.doctype,frm.docname, "symptoms_select", null);
-	}
-});
-frappe.ui.form.on("Patient Encounter", "diagnosis_select", function(frm) {
-	if(frm.doc.diagnosis_select){
-		var diagnosis = null;
-		if(frm.doc.diagnosis)
-			diagnosis = frm.doc.diagnosis + "\n" +frm.doc.diagnosis_select;
-		else
-			diagnosis = frm.doc.diagnosis_select;
-		frappe.model.set_value(frm.doctype,frm.docname, "diagnosis", diagnosis);
-		frappe.model.set_value(frm.doctype,frm.docname, "diagnosis_select", null);
-	}
-});
-
-frappe.ui.form.on("Patient Encounter", "patient", function(frm) {
-	if(frm.doc.patient){
-		frappe.call({
-			"method": "erpnext.healthcare.doctype.patient.patient.get_patient_detail",
-			args: {
-				patient: frm.doc.patient
-			},
-			callback: function (data) {
-				var age = "";
-				if(data.message.dob){
-					age = calculate_age(data.message.dob);
-				}
-				frappe.model.set_value(frm.doctype,frm.docname, "patient_age", age);
-				frappe.model.set_value(frm.doctype,frm.docname, "patient_sex", data.message.sex);
-			}
-		});
-	}
-});
-
-frappe.ui.form.on("Drug Prescription", {
-	drug_code:  function(frm, cdt, cdn) {
-		var child = locals[cdt][cdn];
-		if(child.drug_code){
+	set_appointment_fields: function(frm) {
+		if (frm.doc.appointment) {
 			frappe.call({
-				"method": "frappe.client.get",
+				method: 'frappe.client.get',
 				args: {
-					doctype: "Item",
-					name: child.drug_code,
+					doctype: 'Patient Appointment',
+					name: frm.doc.appointment
 				},
-				callback: function (data) {
-					frappe.model.set_value(cdt, cdn, 'drug_name',data.message.item_name);
+				callback: function(data) {
+					frappe.model.set_value(frm.doctype, frm.docname, 'patient', data.message.patient);
+					frappe.model.set_value(frm.doctype, frm.docname, 'type', data.message.appointment_type);
+					frappe.model.set_value(frm.doctype, frm.docname, 'practitioner', data.message.practitioner);
+					frappe.model.set_value(frm.doctype, frm.docname, 'invoiced', data.message.invoiced);
 				}
 			});
 		}
+		else {
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'type', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'practitioner', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'invoiced', 0);
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
+		}
 	},
+
+	set_patient_info: function(frm) {
+		if (frm.doc.patient) {
+			frappe.call({
+				method: 'erpnext.healthcare.doctype.patient.patient.get_patient_detail',
+				args: {
+					patient: frm.doc.patient
+				},
+				callback: function(data) {
+					let age = '';
+					if (data.message.dob) {
+						age = calculate_age(data.message.dob);
+					}
+					frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', age);
+					frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', data.message.sex);
+					if (data.message.inpatient_record) {
+						frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', data.message.inpatient_record);
+						frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', data.message.inpatient_status);
+					}
+				}
+			});
+		} else {
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient_sex', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient_age', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_record', '');
+			frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
+		}
+	}
+});
+
+let schedule_inpatient = function(frm) {
+	frappe.call({
+		method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_inpatient',
+		args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
+		callback: function(data) {
+			if (!data.exc) {
+				frm.reload_doc();
+			}
+		},
+		freeze: true,
+		freeze_message: 'Process Inpatient Scheduling'
+	});
+};
+
+let schedule_discharge = function(frm) {
+	frappe.call({
+		method: 'erpnext.healthcare.doctype.inpatient_record.inpatient_record.schedule_discharge',
+		args: {patient: frm.doc.patient, encounter_id: frm.doc.name, practitioner: frm.doc.practitioner},
+		callback: function(data) {
+			if (!data.exc) {
+				frm.reload_doc();
+			}
+		},
+		freeze: true,
+		freeze_message: 'Process Discharge'
+	});
+};
+
+let create_medical_record = function (frm) {
+	if (!frm.doc.patient) {
+		frappe.throw(__('Please select patient'));
+	}
+	frappe.route_options = {
+		'patient': frm.doc.patient,
+		'status': 'Open',
+		'reference_doctype': 'Patient Medical Record',
+		'reference_owner': frm.doc.owner
+	};
+	frappe.new_doc('Patient Medical Record');
+};
+
+let create_vital_signs = function (frm) {
+	if (!frm.doc.patient) {
+		frappe.throw(__('Please select patient'));
+	}
+	frappe.route_options = {
+		'patient': frm.doc.patient,
+		'appointment': frm.doc.appointment
+	};
+	frappe.new_doc('Vital Signs');
+};
+
+let create_procedure = function (frm) {
+	if (!frm.doc.patient) {
+		frappe.throw(__('Please select patient'));
+	}
+	frappe.route_options = {
+		'patient': frm.doc.patient,
+		'medical_department': frm.doc.medical_department
+	};
+	frappe.new_doc('Clinical Procedure');
+};
+
+frappe.ui.form.on('Drug Prescription', {
 	dosage: function(frm, cdt, cdn){
 		frappe.model.set_value(cdt, cdn, 'update_schedule', 1);
-		var child = locals[cdt][cdn];
-		if(child.dosage){
-			frappe.model.set_value(cdt, cdn, 'in_every', 'Day');
+		let child = locals[cdt][cdn];
+		if (child.dosage) {
+			frappe.model.set_value(cdt, cdn, 'interval_uom', 'Day');
 			frappe.model.set_value(cdt, cdn, 'interval', 1);
 		}
 	},
-	period: function(frm, cdt, cdn){
+	period: function(frm, cdt, cdn) {
 		frappe.model.set_value(cdt, cdn, 'update_schedule', 1);
 	},
-	in_every: function(frm, cdt, cdn){
+	interval_uom: function(frm, cdt, cdn) {
 		frappe.model.set_value(cdt, cdn, 'update_schedule', 1);
-		var child = locals[cdt][cdn];
-		if(child.in_every == "Hour"){
+		let child = locals[cdt][cdn];
+		if (child.interval_uom == 'Hour') {
 			frappe.model.set_value(cdt, cdn, 'dosage', null);
 		}
 	}
 });
 
-frappe.ui.form.on("Procedure Prescription", {
-	procedure:  function(frm, cdt, cdn) {
-		var child = locals[cdt][cdn];
-		if(child.procedure){
-			frappe.call({
-				"method": "frappe.client.get_value",
-				args: {
-					doctype: "Clinical Procedure Template",
-					fieldname: "medical_department",
-					filters: {name: child.procedure}
-				},
-				callback: function (data) {
-					frappe.model.set_value(cdt, cdn, 'department',data.message.medical_department);
-				}
-			});
-		}
-	}
-});
-
-
-var calculate_age = function(birth) {
-	var ageMS = Date.parse(Date()) - Date.parse(birth);
-	var age = new Date();
+let calculate_age = function(birth) {
+	let ageMS = Date.parse(Date()) - Date.parse(birth);
+	let age = new Date();
 	age.setTime(ageMS);
-	var years =  age.getFullYear() - 1970;
-	return  years + " Year(s) " + age.getMonth() + " Month(s) " + age.getDate() + " Day(s)";
+	let years =  age.getFullYear() - 1970;
+	return  years + ' Year(s) ' + age.getMonth() + ' Month(s) ' + age.getDate() + ' Day(s)';
 };
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
index 91c9d7b..d00e7bc 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
@@ -1,1183 +1,324 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 0, 
- "autoname": "naming_series:", 
- "beta": 1, 
- "creation": "2016-04-21 10:53:44.637684", 
- "custom": 0, 
- "default_print_format": "", 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "Document", 
- "editable_grid": 1, 
+ "actions": [],
+ "allow_copy": 1,
+ "allow_import": 1,
+ "autoname": "naming_series:",
+ "beta": 1,
+ "creation": "2016-04-21 10:53:44.637684",
+ "doctype": "DocType",
+ "document_type": "Document",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "naming_series",
+  "appointment",
+  "appointment_type",
+  "patient",
+  "patient_name",
+  "patient_sex",
+  "patient_age",
+  "company",
+  "column_break_6",
+  "practitioner",
+  "medical_department",
+  "encounter_date",
+  "encounter_time",
+  "invoiced",
+  "section_break_1",
+  "inpatient_record",
+  "column_break_17",
+  "inpatient_status",
+  "sb_symptoms",
+  "symptoms",
+  "symptoms_in_print",
+  "physical_examination",
+  "diagnosis",
+  "diagnosis_in_print",
+  "codification",
+  "codification_table",
+  "sb_drug_prescription",
+  "drug_prescription",
+  "sb_test_prescription",
+  "lab_test_prescription",
+  "sb_procedures",
+  "procedure_prescription",
+  "encounter_comment",
+  "amended_from"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "patient.inpatient_record", 
-   "fieldname": "inpatient_record", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Inpatient Record", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Inpatient Record", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "inpatient_record",
+   "fieldtype": "Link",
+   "label": "Inpatient Record",
+   "options": "Inpatient Record",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_1", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "collapsible": 1,
+   "fieldname": "section_break_1",
+   "fieldtype": "Section Break",
+   "label": "Inpatient Details"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "", 
-   "fieldname": "naming_series", 
-   "fieldtype": "Select", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Series", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "HLC-ENC-.YYYY.-", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "naming_series",
+   "fieldtype": "Select",
+   "label": "Series",
+   "no_copy": 1,
+   "options": "HLC-ENC-.YYYY.-",
+   "set_only_once": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "appointment", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Appointment", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Patient Appointment", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "appointment",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "label": "Appointment",
+   "options": "Patient Appointment",
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "type", 
-   "fieldtype": "Link", 
-   "hidden": 1, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Type", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Appointment Type", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "inpatient_record.patient",
+   "fieldname": "patient",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Patient",
+   "options": "Patient",
+   "reqd": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "inpatient_record.patient", 
-   "fieldname": "patient", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Patient", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Patient", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "patient.patient_name",
+   "fieldname": "patient_name",
+   "fieldtype": "Data",
+   "label": "Patient Name",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "", 
-   "fetch_from": "patient.patient_name", 
-   "fieldname": "patient_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Patient Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "patient_age",
+   "fieldtype": "Data",
+   "label": "Age",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "patient_age", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Age", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "patient_sex",
+   "fieldtype": "Link",
+   "label": "Gender",
+   "options": "Gender",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "patient_sex", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Gender", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nMale\nFemale\nOther", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "company",
+   "fieldtype": "Link",
+   "hidden": 1,
+   "label": "Company",
+   "options": "Company"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "company", 
-   "fieldtype": "Link", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Company", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Company", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "column_break_6",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "column_break_6", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "practitioner",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Healthcare Practitioner",
+   "options": "Healthcare Practitioner",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "practitioner", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Healthcare Practitioner", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Healthcare Practitioner", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "Today",
+   "fieldname": "encounter_date",
+   "fieldtype": "Date",
+   "in_list_view": 1,
+   "label": "Encounter Date",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "visit_department", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 1, 
-   "label": "Department", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Medical Department", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "encounter_time",
+   "fieldtype": "Time",
+   "label": "Encounter Time",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "Today", 
-   "fieldname": "encounter_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Encounter Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "invoiced",
+   "fieldtype": "Check",
+   "label": "Invoiced",
+   "no_copy": 1,
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "", 
-   "fieldname": "encounter_time", 
-   "fieldtype": "Time", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Encounter Time", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sb_symptoms",
+   "fieldtype": "Section Break",
+   "label": "Encounter Impression"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "invoiced", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Invoiced", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "symptoms",
+   "fieldtype": "Table MultiSelect",
+   "ignore_xss_filter": 1,
+   "label": "Symptoms",
+   "no_copy": 1,
+   "options": "Patient Encounter Symptom"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 1, 
-   "columns": 0, 
-   "fieldname": "sb_symptoms", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Encounter Impression", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "depends_on": "eval: doc.symptoms != ''",
+   "fieldname": "symptoms_in_print",
+   "fieldtype": "Check",
+   "label": "In print",
+   "no_copy": 1,
+   "print_hide": 1,
+   "report_hide": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "symptoms_select", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Complaints", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Complaint", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "physical_examination",
+   "fieldtype": "Column Break"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "symptoms", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "diagnosis",
+   "fieldtype": "Table MultiSelect",
+   "ignore_xss_filter": 1,
+   "label": "Diagnosis",
+   "no_copy": 1,
+   "options": "Patient Encounter Diagnosis"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "symptoms_in_print", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "In print", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "1",
+   "depends_on": "eval: doc.diagnosis != ''",
+   "fieldname": "diagnosis_in_print",
+   "fieldtype": "Check",
+   "label": "In print",
+   "no_copy": 1,
+   "print_hide": 1,
+   "report_hide": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "physical_examination", 
-   "fieldtype": "Column Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "collapsible": 1,
+   "fieldname": "codification",
+   "fieldtype": "Section Break",
+   "label": "Medical Coding"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "diagnosis_select", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Diagnosis", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Diagnosis", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "codification_table",
+   "fieldtype": "Table",
+   "label": "Medical Coding",
+   "options": "Codification Table"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "depends_on": "", 
-   "fieldname": "diagnosis", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sb_drug_prescription",
+   "fieldtype": "Section Break",
+   "label": "Medication"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "1", 
-   "depends_on": "", 
-   "fieldname": "diagnosis_in_print", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "In print", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "drug_prescription",
+   "fieldtype": "Table",
+   "label": "Drug Prescription",
+   "options": "Drug Prescription"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 1, 
-   "columns": 0, 
-   "fieldname": "codification", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Medical Coding", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sb_test_prescription",
+   "fieldtype": "Section Break",
+   "label": "Investigation"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "codification_table", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Medical Coding", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Codification Table", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "lab_test_prescription",
+   "fieldtype": "Table",
+   "label": "Lab Prescription",
+   "options": "Lab Prescription"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sb_drug_prescription", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Medication", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "sb_procedures",
+   "fieldtype": "Section Break",
+   "label": "Procedures"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "drug_prescription", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Medication", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Drug Prescription", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "procedure_prescription",
+   "fieldtype": "Table",
+   "label": "Procedure Prescription",
+   "no_copy": 1,
+   "options": "Procedure Prescription"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sb_test_prescription", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Investigations", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "encounter_comment",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "label": "Review Details",
+   "no_copy": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "lab_test_prescription", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Investigations", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Lab Prescription", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "amended_from",
+   "fieldtype": "Link",
+   "label": "Amended From",
+   "no_copy": 1,
+   "options": "Patient Encounter",
+   "print_hide": 1,
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "sb_procedures", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Procedures", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "appointment_type",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "label": "Appointment Type",
+   "no_copy": 1,
+   "options": "Appointment Type",
+   "print_hide": 1,
+   "read_only": 1,
+   "report_hide": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "procedure_prescription", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Procedures", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Procedure Prescription", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "practitioner.department",
+   "fieldname": "medical_department",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "in_standard_filter": 1,
+   "label": "Department",
+   "options": "Medical Department",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "encounter_comment", 
-   "fieldtype": "Small Text", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Review Details", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "inpatient_status",
+   "fieldtype": "Data",
+   "label": "Inpatient Status",
+   "read_only": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "amended_from", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Amended From", 
-   "length": 0, 
-   "no_copy": 1, 
-   "options": "Patient Encounter", 
-   "permlevel": 0, 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "fieldname": "column_break_17",
+   "fieldtype": "Column Break"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 1, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-09-04 11:50:52.217175", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Patient Encounter", 
- "name_case": "", 
- "owner": "Administrator", 
+ ],
+ "is_submittable": 1,
+ "links": [],
+ "modified": "2020-02-27 12:42:21.751964",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Patient Encounter",
+ "owner": "Administrator",
  "permissions": [
   {
-   "amend": 1, 
-   "cancel": 1, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Physician", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 1, 
+   "amend": 1,
+   "cancel": 1,
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Physician",
+   "share": 1,
+   "submit": 1,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "search_fields": "patient, practitioner, visit_department, encounter_date, encounter_time", 
- "show_name_in_global_search": 1, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "title_field": "patient", 
- "track_changes": 1, 
- "track_seen": 1, 
- "track_views": 0
+ ],
+ "restrict_to_domain": "Healthcare",
+ "search_fields": "patient, practitioner, medical_department, encounter_date, encounter_time",
+ "show_name_in_global_search": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "title_field": "patient",
+ "track_changes": 1,
+ "track_seen": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
index fe7ac8e..2aea072 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.py
@@ -9,56 +9,59 @@
 
 class PatientEncounter(Document):
 	def on_update(self):
-		if(self.appointment):
-			frappe.db.set_value("Patient Appointment", self.appointment, "status", "Closed")
-		update_encounter_to_medical_record(self)
+		if self.appointment:
+			frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Closed')
+		update_encounter_medical_record(self)
 
 	def after_insert(self):
-		insert_encounter_to_medical_record(self)
+		insert_encounter_medical_record(self)
 
 	def on_cancel(self):
-		if(self.appointment):
-			frappe.db.set_value("Patient Appointment", self.appointment, "status", "Open")
+		if self.appointment:
+			frappe.db.set_value('Patient Appointment', self.appointment, 'status', 'Open')
 		delete_medical_record(self)
 
-def insert_encounter_to_medical_record(doc):
+def insert_encounter_medical_record(doc):
 	subject = set_subject_field(doc)
-	medical_record = frappe.new_doc("Patient Medical Record")
+	medical_record = frappe.new_doc('Patient Medical Record')
 	medical_record.patient = doc.patient
 	medical_record.subject = subject
-	medical_record.status = "Open"
+	medical_record.status = 'Open'
 	medical_record.communication_date = doc.encounter_date
-	medical_record.reference_doctype = "Patient Encounter"
+	medical_record.reference_doctype = 'Patient Encounter'
 	medical_record.reference_name = doc.name
 	medical_record.reference_owner = doc.owner
 	medical_record.save(ignore_permissions=True)
 
-def update_encounter_to_medical_record(encounter):
-	medical_record_id = frappe.db.sql("select name from `tabPatient Medical Record` where reference_name=%s", (encounter.name))
+def update_encounter_medical_record(encounter):
+	medical_record_id = frappe.db.exists('Patient Medical Record', {'reference_name': encounter.name})
+
 	if medical_record_id and medical_record_id[0][0]:
 		subject = set_subject_field(encounter)
-		frappe.db.set_value("Patient Medical Record", medical_record_id[0][0], "subject", subject)
+		frappe.db.set_value('Patient Medical Record', medical_record_id[0][0], 'subject', subject)
 	else:
 		insert_encounter_to_medical_record(encounter)
 
 def delete_medical_record(encounter):
-	frappe.db.sql("""delete from `tabPatient Medical Record` where reference_name = %s""", (encounter.name))
+	frappe.db.delete_doc_if_exists('Patient Medical Record', 'reference_name', encounter.name)
 
 def set_subject_field(encounter):
-	subject = encounter.practitioner+"<br/>"
-	if(encounter.symptoms):
-		subject += "Symptoms: "+ cstr(encounter.symptoms)+".<br/>"
+	subject = encounter.practitioner + '\n'
+	if encounter.symptoms:
+		subject += 'Symptoms: '+ cstr(encounter.symptoms) + '\n'
 	else:
-		subject += "No Symptoms <br/>"
-	if(encounter.diagnosis):
-		subject += "Diagnosis: "+ cstr(encounter.diagnosis)+".<br/>"
+		subject += 'No Symptoms \n'
+
+	if encounter.diagnosis:
+		subject += 'Diagnosis: '+ cstr(encounter.diagnosis) + '\n'
 	else:
-		subject += "No Diagnosis <br/>"
-	if(encounter.drug_prescription):
-		subject +="\nDrug(s) Prescribed. "
-	if(encounter.lab_test_prescription):
-		subject += "\nTest(s) Prescribed."
-	if(encounter.procedure_prescription):
-		subject += "\nProcedure(s) Prescribed."
+		subject += 'No Diagnosis \n'
+
+	if encounter.drug_prescription:
+		subject += '\nDrug(s) Prescribed.'
+	if encounter.lab_test_prescription:
+		subject += '\nTest(s) Prescribed.'
+	if encounter.procedure_prescription:
+		subject += '\nProcedure(s) Prescribed.'
 
 	return subject
diff --git a/erpnext/healthcare/doctype/patient_encounter_diagnosis/__init__.py b/erpnext/healthcare/doctype/patient_encounter_diagnosis/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_diagnosis/__init__.py
diff --git a/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.json b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.json
new file mode 100644
index 0000000..00ca309
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.json
@@ -0,0 +1,33 @@
+{
+ "actions": [],
+ "beta": 1,
+ "creation": "2020-02-26 16:48:16.835105",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "diagnosis"
+ ],
+ "fields": [
+  {
+   "fieldname": "diagnosis",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Diagnosis",
+   "options": "Diagnosis",
+   "reqd": 1
+  }
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 16:58:16.480583",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Patient Encounter Diagnosis",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py
new file mode 100644
index 0000000..34b0cf8
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_diagnosis/patient_encounter_diagnosis.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+# import frappe
+from frappe.model.document import Document
+
+class PatientEncounterDiagnosis(Document):
+	pass
diff --git a/erpnext/healthcare/doctype/patient_encounter_symptom/__init__.py b/erpnext/healthcare/doctype/patient_encounter_symptom/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_symptom/__init__.py
diff --git a/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.json b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.json
new file mode 100644
index 0000000..bc92145
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.json
@@ -0,0 +1,33 @@
+{
+ "actions": [],
+ "beta": 1,
+ "creation": "2020-02-26 16:47:00.525657",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "complaint"
+ ],
+ "fields": [
+  {
+   "fieldname": "complaint",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Complaint",
+   "options": "Complaint",
+   "reqd": 1
+  }
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 16:57:37.997481",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Patient Encounter Symptom",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
+}
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py
new file mode 100644
index 0000000..bdb7bb2
--- /dev/null
+++ b/erpnext/healthcare/doctype/patient_encounter_symptom/patient_encounter_symptom.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
+# For license information, please see license.txt
+
+from __future__ import unicode_literals
+# import frappe
+from frappe.model.document import Document
+
+class PatientEncounterSymptom(Document):
+	pass
diff --git a/erpnext/healthcare/doctype/patient_relation/patient_relation.json b/erpnext/healthcare/doctype/patient_relation/patient_relation.json
index 209a374..376f7f7 100644
--- a/erpnext/healthcare/doctype/patient_relation/patient_relation.json
+++ b/erpnext/healthcare/doctype/patient_relation/patient_relation.json
@@ -1,134 +1,52 @@
 {
- "allow_copy": 1, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 1, 
- "creation": "2017-04-26 15:40:11.561855", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_copy": 1,
+ "beta": 1,
+ "creation": "2017-04-26 15:40:11.561855",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "patient",
+  "relation",
+  "description"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "relation", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Relation", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nFather\nMother\nSpouse\nSiblings\nFamily", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "relation",
+   "fieldtype": "Select",
+   "in_list_view": 1,
+   "label": "Relation",
+   "options": "\nFather\nMother\nSpouse\nSiblings\nFamily\nOther",
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "patient", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 1, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Patient", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Patient", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "patient",
+   "fieldtype": "Link",
+   "ignore_user_permissions": 1,
+   "in_list_view": 1,
+   "label": "Patient",
+   "options": "Patient",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "description", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Description", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
+   "fieldname": "description",
+   "fieldtype": "Small Text",
+   "ignore_xss_filter": 1,
+   "label": "Description"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2017-10-04 16:12:45.485333", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Patient Relation", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 1, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-01-29 12:45:40.081899",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Patient Relation",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js
index f247856..7cb7c4b 100644
--- a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js
+++ b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.js
@@ -5,9 +5,9 @@
 	refresh: function(frm) {
 		cur_frm.fields_dict["time_slots"].grid.wrapper.find('.grid-add-row').hide();
 		cur_frm.fields_dict["time_slots"].grid.add_custom_button(__('Add Time Slots'), () => {
-			var d = new frappe.ui.Dialog({
+			let d = new frappe.ui.Dialog({
 				fields: [
-					{fieldname: 'days', label: __('Select Days'), fieldtype:'MultiSelect',
+					{fieldname: 'days', label: __('Select Days'), fieldtype: 'MultiSelect',
 						options:[
 							{value:'Sunday', label:__('Sunday')},
 							{value:'Monday', label:__('Monday')},
@@ -17,40 +17,41 @@
 							{value:'Friday', label:__('Friday')},
 							{value:'Saturday', label:__('Saturday')},
 						], reqd: 1},
-					{fieldname: 'from_time', label:__('From'), fieldtype:'Time',
+					{fieldname: 'from_time', label: __('From'), fieldtype: 'Time',
 						'default': '09:00:00', reqd: 1},
-					{fieldname: 'to_time', label:__('To'), fieldtype:'Time',
+					{fieldname: 'to_time', label: __('To'), fieldtype: 'Time',
 						'default': '12:00:00', reqd: 1},
-					{fieldname: 'duration', label:__('Appointment Duration (mins)'),
+					{fieldname: 'duration', label: __('Appointment Duration (mins)'),
 						fieldtype:'Int', 'default': 15, reqd: 1},
 				],
 				primary_action_label: __('Add Timeslots'),
 				primary_action: () => {
-					var values = d.get_values();
-					if(values) {
+					let values = d.get_values();
+					if (values) {
 						let slot_added = false;
 						values.days.split(',').forEach(function(day){
 							day = $.trim(day);
-							if(['Sunday', 'Monday', 'Tuesday', 'Wednesday',
+							if (['Sunday', 'Monday', 'Tuesday', 'Wednesday',
 							'Thursday', 'Friday', 'Saturday'].includes(day)){
 								add_slots(day);
 							}
 						});
+
 						function check_overlap_or_add_slot(week_day, cur_time, end_time, add_slots_to_child){
 							let overlap = false;
-							while(cur_time < end_time) {
+							while (cur_time < end_time) {
 								let add_to_child = true;
 								let to_time = cur_time.clone().add(values.duration, 'minutes');
-								if(to_time <= end_time) {
-									if(frm.doc.time_slots){
+								if (to_time <= end_time) {
+									if (frm.doc.time_slots){
 										frm.doc.time_slots.forEach(function(slot) {
-											if(slot.day == week_day){
+											if (slot.day == week_day){
 												let slot_from_moment = moment(slot.from_time, 'HH:mm:ss');
 												let slot_to_moment = moment(slot.to_time, 'HH:mm:ss');
-												if(cur_time.isSame(slot_from_moment)	||	cur_time.isBetween(slot_from_moment, slot_to_moment)	||
-												to_time.isSame(slot_to_moment)	||	to_time.isBetween(slot_from_moment, slot_to_moment)){
+												if (cur_time.isSame(slot_from_moment)	||	cur_time.isBetween(slot_from_moment, slot_to_moment)	||
+												to_time.isSame(slot_to_moment)	||	to_time.isBetween(slot_from_moment, slot_to_moment)) {
 													overlap = true;
-													if(add_slots_to_child){
+													if (add_slots_to_child) {
 														frappe.show_alert({
 															message:__('Time slot skiped, the slot {0} to {1} overlap exisiting slot {2} to {3}',
 																[cur_time.format('HH:mm:ss'),	to_time.format('HH:mm:ss'),	slot.from_time,	slot.to_time]),
@@ -63,7 +64,7 @@
 										});
 									}
 									// add a new timeslot
-									if(add_to_child && add_slots_to_child){
+									if (add_to_child && add_slots_to_child) {
 										frm.add_child('time_slots', {
 											from_time: cur_time.format('HH:mm:ss'),
 											to_time: to_time.format('HH:mm:ss'),
@@ -76,10 +77,11 @@
 							}
 							return overlap;
 						}
-						function add_slots(week_day){
+
+						function add_slots(week_day) {
 							let cur_time = moment(values.from_time, 'HH:mm:ss');
 							let end_time = moment(values.to_time, 'HH:mm:ss');
-							if(check_overlap_or_add_slot(week_day, cur_time, end_time, false)){
+							if (check_overlap_or_add_slot(week_day, cur_time, end_time, false)) {
 								frappe.confirm(__('Schedules for {0} overlaps, do you want to proceed after skiping overlaped slots ?',	[week_day]),
 									function() {
 										// if Yes
@@ -88,21 +90,22 @@
 									function() {
 										// if No
 										frappe.show_alert({
-											message:__('Slots for {0} are not added to the schedule',	[week_day]),
-											indicator:'red'
+											message: __('Slots for {0} are not added to the schedule',	[week_day]),
+											indicator: 'red'
 										});
 									}
 								);
-							}
-							else{
+							} else {
 								check_overlap_or_add_slot(week_day, cur_time, end_time, true);
 							}
 						}
+
 						frm.refresh_field('time_slots');
-						if(slot_added){
+
+						if (slot_added) {
 							frappe.show_alert({
-								message:__('Time slots added'),
-								indicator:'green'
+								message: __('Time slots added'),
+								indicator: 'green'
 							});
 						}
 					}
diff --git a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.json b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.json
index 08a1b86..cff100c 100644
--- a/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.json
+++ b/erpnext/healthcare/doctype/practitioner_schedule/practitioner_schedule.json
@@ -1,160 +1,71 @@
 {
- "allow_copy": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 1, 
- "allow_rename": 1, 
- "autoname": "field:schedule_name", 
- "beta": 1, 
- "creation": "2017-05-03 17:28:03.926787", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_import": 1,
+ "allow_rename": 1,
+ "autoname": "field:schedule_name",
+ "beta": 1,
+ "creation": "2017-05-03 17:28:03.926787",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "disabled",
+  "schedule_details_section",
+  "schedule_name",
+  "time_slots"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "schedule_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 1, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Schedule Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "schedule_name",
+   "fieldtype": "Data",
+   "ignore_xss_filter": 1,
+   "in_list_view": 1,
+   "label": "Schedule Name",
+   "reqd": 1,
+   "unique": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "time_slots", 
-   "fieldtype": "Table", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Time Slots", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Healthcare Schedule Time Slot", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "time_slots",
+   "fieldtype": "Table",
+   "label": "Time Slots",
+   "options": "Healthcare Schedule Time Slot"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "disabled", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Disabled", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 1, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 1, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "default": "0",
+   "fieldname": "disabled",
+   "fieldtype": "Check",
+   "label": "Disabled",
+   "print_hide": 1
+  },
+  {
+   "fieldname": "schedule_details_section",
+   "fieldtype": "Section Break",
+   "label": "Schedule Details"
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 0, 
- "max_attachments": 0, 
- "modified": "2018-06-29 14:55:34.795995", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Practitioner Schedule", 
- "name_case": "", 
- "owner": "rmehta@gmail.com", 
+ ],
+ "links": [],
+ "modified": "2020-01-31 12:21:45.975488",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Practitioner Schedule",
+ "owner": "rmehta@gmail.com",
  "permissions": [
   {
-   "amend": 0, 
-   "cancel": 0, 
-   "create": 1, 
-   "delete": 1, 
-   "email": 1, 
-   "export": 1, 
-   "if_owner": 0, 
-   "import": 0, 
-   "permlevel": 0, 
-   "print": 1, 
-   "read": 1, 
-   "report": 1, 
-   "role": "Healthcare Administrator", 
-   "set_user_permissions": 0, 
-   "share": 1, 
-   "submit": 0, 
+   "create": 1,
+   "delete": 1,
+   "email": 1,
+   "export": 1,
+   "print": 1,
+   "read": 1,
+   "report": 1,
+   "role": "Healthcare Administrator",
+   "share": 1,
    "write": 1
   }
- ], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 1, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0
+ ],
+ "restrict_to_domain": "Healthcare",
+ "show_name_in_global_search": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.json b/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.json
index 236c2b8..e4c01d7 100644
--- a/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.json
+++ b/erpnext/healthcare/doctype/procedure_prescription/procedure_prescription.json
@@ -1,338 +1,99 @@
 {
- "allow_copy": 1, 
- "allow_events_in_timeline": 0, 
- "allow_guest_to_view": 0, 
- "allow_import": 0, 
- "allow_rename": 0, 
- "beta": 1, 
- "creation": "2017-11-17 15:52:48.324157", 
- "custom": 0, 
- "docstatus": 0, 
- "doctype": "DocType", 
- "document_type": "", 
- "editable_grid": 1, 
- "engine": "InnoDB", 
+ "actions": [],
+ "allow_copy": 1,
+ "beta": 1,
+ "creation": "2017-11-17 15:52:48.324157",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+  "procedure",
+  "procedure_name",
+  "department",
+  "practitioner",
+  "date",
+  "comments",
+  "appointment_booked",
+  "procedure_created",
+  "invoiced"
+ ],
  "fields": [
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "procedure", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Procedure", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Clinical Procedure Template", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "procedure",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Clinical Procedure",
+   "options": "Clinical Procedure Template",
+   "reqd": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fetch_from": "procedure.template", 
-   "fieldname": "procedure_name", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Procedure Name", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "procedure.template",
+   "fieldname": "procedure_name",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Procedure Name"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "department", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Department", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Medical Department", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fetch_from": "procedure.medical_department",
+   "fieldname": "department",
+   "fieldtype": "Link",
+   "label": "Department",
+   "options": "Medical Department"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "practitioner", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Referral", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Healthcare Practitioner", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "practitioner",
+   "fieldtype": "Link",
+   "in_list_view": 1,
+   "label": "Referring Practitioner",
+   "options": "Healthcare Practitioner"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "date",
+   "fieldtype": "Date",
+   "in_list_view": 1,
+   "label": "Date"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "comments", 
-   "fieldtype": "Data", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Comments", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "fieldname": "comments",
+   "fieldtype": "Data",
+   "label": "Comments"
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "appointment_booked", 
-   "fieldtype": "Check", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Appointment Booked", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "appointment_booked",
+   "fieldtype": "Check",
+   "hidden": 1,
+   "label": "Appointment Booked",
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "procedure_created", 
-   "fieldtype": "Check", 
-   "hidden": 1, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Procedure Created", 
-   "length": 0, 
-   "no_copy": 1, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
-  }, 
+   "default": "0",
+   "fieldname": "procedure_created",
+   "fieldtype": "Check",
+   "hidden": 1,
+   "label": "Procedure Created",
+   "no_copy": 1,
+   "search_index": 1
+  },
   {
-   "allow_bulk_edit": 0, 
-   "allow_in_quick_entry": 0, 
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "default": "0", 
-   "fieldname": "invoiced", 
-   "fieldtype": "Check", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_global_search": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Invoiced", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 1, 
-   "set_only_once": 0, 
-   "translatable": 0, 
-   "unique": 0
+   "default": "0",
+   "fieldname": "invoiced",
+   "fieldtype": "Check",
+   "label": "Invoiced",
+   "read_only": 1,
+   "search_index": 1
   }
- ], 
- "has_web_view": 0, 
- "hide_heading": 0, 
- "hide_toolbar": 0, 
- "idx": 0, 
- "image_view": 0, 
- "in_create": 0, 
- "is_submittable": 0, 
- "issingle": 0, 
- "istable": 1, 
- "max_attachments": 0, 
- "modified": "2018-11-04 03:33:35.939816", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Procedure Prescription", 
- "name_case": "", 
- "owner": "Administrator", 
- "permissions": [], 
- "quick_entry": 0, 
- "read_only": 0, 
- "read_only_onload": 0, 
- "restrict_to_domain": "Healthcare", 
- "show_name_in_global_search": 0, 
- "sort_field": "modified", 
- "sort_order": "DESC", 
- "track_changes": 1, 
- "track_seen": 0, 
- "track_views": 0
+ ],
+ "istable": 1,
+ "links": [],
+ "modified": "2020-02-26 15:42:33.988081",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Procedure Prescription",
+ "owner": "Administrator",
+ "permissions": [],
+ "restrict_to_domain": "Healthcare",
+ "sort_field": "modified",
+ "sort_order": "DESC",
+ "track_changes": 1
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/sample_collection/sample_collection.js b/erpnext/healthcare/doctype/sample_collection/sample_collection.js
index 9934ce4..2f5278b 100644
--- a/erpnext/healthcare/doctype/sample_collection/sample_collection.js
+++ b/erpnext/healthcare/doctype/sample_collection/sample_collection.js
@@ -3,7 +3,7 @@
 
 frappe.ui.form.on('Sample Collection', {
 	refresh: function(frm) {
-		if(frappe.defaults.get_default("require_sample_collection")){
+		if(frappe.defaults.get_default("create_sample_collection_for_lab_test")){
 			frm.add_custom_button(__("View Lab Tests"), function() {
 				frappe.route_options = {"sample": frm.doc.name};
 				frappe.set_route("List", "Lab Test");
diff --git a/erpnext/healthcare/print_format/encounter_print/encounter_print.json b/erpnext/healthcare/print_format/encounter_print/encounter_print.json
index 20e44b7..ec1e0f2 100644
--- a/erpnext/healthcare/print_format/encounter_print/encounter_print.json
+++ b/erpnext/healthcare/print_format/encounter_print/encounter_print.json
@@ -1,22 +1,22 @@
 {
- "align_labels_right": 0, 
- "creation": "2017-04-10 14:05:53.355863", 
- "custom_format": 1, 
- "disabled": 0, 
- "doc_type": "Patient Encounter", 
- "docstatus": 0, 
- "doctype": "Print Format", 
- "font": "Default", 
- "html": "<div >\n    {% if letter_head and not no_letterhead -%}\n    <div class=\"letter-head\">{{ letter_head }}</div>\n    <hr>\n    {% else %}\n    <div align=\"right\">\n      <h1>{{doc.name}}</h1>\n    </div>\n    {%- endif %}\n    <div class=\"row section-break\">\n        <div class=\"col-xs-6 column-break\">\n                {% if doc.appointment %}\n\t        <div class=\"row\">\n\t\t\t<div class=\"col-xs-4 text-left\">\n\t\t\t<label>Appointment</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t<strong>: </strong>{{doc.appointment}}\n\t\t\t</div>\n\t\t</div>\n\t\t{%- endif -%}\n\n                <div class=\"row\">\n\t\t      <div class=\"col-xs-4 text-left\">\n\t\t\t <label>Patient</label>\n\t\t      </div>\n                     {% if doc.patient %}\n\t\t      <div class=\"col-xs-7  value\">\n\t\t\t  <strong>: </strong>{{doc.patient}}\n\t\t      </div>\n                     {% else %}\n                     <div class=\"col-xs-7  value\">\n\t\t\t <strong>: </strong><em>Patient Name</em>\n\t\t     </div>\n                     {%- endif -%}\n\t\t</div>\n\t        <div class=\"row\">\n\t\t\t<div class=\"col-xs-4 text-left\">\n\t\t\t\t<label>Age</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t     <strong>: </strong> {{doc.patient_age}}\n\t\t\t</div>\n\t\t</div>\n\n                <div class=\"row\">\n                        <div class=\"col-xs-4 text-left\">\n\t\t\t\t<label>Gender</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t     <strong>: </strong> {{doc.patient_sex}}\n\t\t\t</div>\n                </div>\n\n        </div>\n        <div class=\"col-xs-6 column-break\">\n\n          <div class=\"row\">\n\t      <div class=\"col-xs-4 text-left\">\n\t\t    <label>Healthcare Practitioner</label>\n\t      </div>\n              {% if doc.practitioner %}\n\t      <div class=\"col-xs-7  text-left value\">\n\t\t\t<strong>: </strong>{{doc.practitioner}}\n\t      </div>\n              {%- endif -%}\n\t</div>\n\n          {% if doc.encounter_date %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Date</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.encounter_date}}\n\t\t</div>\n          </div>\n\t  {%- endif -%}\n          {% if doc.encounter_time %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Time</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.encounter_time}}\n\t\t</div>\n          </div>\n\t  {%- endif -%}\n          {% if doc.visit_department %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Department</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.visit_department}}\n\t\t</div>\n          </div>\n          {%- endif -%}\n        </div>\n\n   </div>\n\n</div>\n<div>\n     <hr>\n     {% if doc.symptoms_in_print%}\n       {% if doc.symptoms %}\n         Complaints:\n         <strong>{{doc.symptoms}}</strong>\n  \t   <br>\n       {%- endif -%}\n     {%- endif -%}\n\n     {% if doc.diagnosis_in_print%}\n       {% if doc.diagnosis %}\n  \t     Diagnosis:\n         <strong>{{doc.diagnosis}}</strong>\n         <br>\n       {%- endif -%}\n     {%- endif -%}\n\n</div>\n\n<div>\n      {% if doc.drug_prescription %}\n      <br>\n      Rx,\n      <table class=\"table\">\n        <tbody>\n            <!--<tr>\n                <th>Drug</th>\n                <th class=\"text-left\">Dosage</th>\n                <th class=\"text-left\">Period</th>\n                <th>Remark</th>\n            </tr>-->\n\n            {%- for row in doc.drug_prescription -%}\n            <tr>\n              <td style=\"width: 30%;border:none;\">\n                {%- if row.drug_name -%}<b>{{ row.drug_name }}</b>{%- endif -%}\n              </td>\n            \t<td style=\"width: 20%;text-align: left;border:none;\">\n                {%- if row.dosage -%}{{ row.dosage }}{%- endif -%}\n              </td>\n            \t<td style=\"width: 20%;text-align: left;border:none;\">\n                {%- if row.period -%}{{ row.period }}{%- endif -%}\n\t\t          </td>\n              <td style=\"width: 30%;text-align: left;border:none;\">\n\t\t\t             <div style=\"border: 0px;\">\n                      {%- if row.comment -%}{{ row.comment }}{%- endif -%}\n                   </div>\n\t\t           </td>\n            </tr>\n\t          {%- endfor -%}\n       </tbody>\n      </table>\n\n\n      {%- endif -%}\n</div>\n\n\n<div>\n      {% if doc.lab_test_prescription %}\n      Investigations,\n      <table class=\"table\">\n        <tbody>\n            <!--<tr>\n                <th>Test</th>\n                <th>Remark</th>\n            </tr>-->\n\n            {%- for row in doc.lab_test_prescription -%}\n            <tr>\n              <td style=\"width: 30%;border:none;\">\n                {%- if row.lab_test_name -%}<b>{{ row.lab_test_name }}</b>{%- endif -%}\n              </td>\n              <td style=\"width: 30%;text-align: left;border:none;\">\n\t\t\t           <div style=\"border: 0px;\">\n                   {%- if row.lab_test_comment -%}{{ row.lab_test_comment }}{%- endif -%}\n                 </div>\n\t\t          </td>\n             </tr>\n\n\t           {%- endfor -%}\n       </tbody>\n      </table>\n\n\n      {%- endif -%}\n</div>\n<div>\n    {% if doc.encounter_comment %}\n      <br>\n      {{doc.encounter_comment}}\n     {%- endif -%}\n</div>\n", 
- "idx": 0, 
- "line_breaks": 0, 
- "modified": "2018-09-04 11:52:54.473702", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Encounter Print", 
- "owner": "Administrator", 
- "print_format_builder": 0, 
- "print_format_type": "Server", 
- "show_section_headings": 0, 
+ "align_labels_right": 0,
+ "creation": "2017-04-10 14:05:53.355863",
+ "custom_format": 1,
+ "disabled": 0,
+ "doc_type": "Patient Encounter",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font": "Default",
+ "html": "<div >\n    {% if letter_head and not no_letterhead -%}\n    <div class=\"letter-head\">{{ letter_head }}</div>\n    <hr>\n    {% else %}\n    <div align=\"right\">\n      <h1>{{doc.name}}</h1>\n    </div>\n    {%- endif %}\n    <div class=\"row section-break\">\n        <div class=\"col-xs-6 column-break\">\n                {% if doc.appointment %}\n\t        <div class=\"row\">\n\t\t\t<div class=\"col-xs-4 text-left\">\n\t\t\t<label>Appointment</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t<strong>: </strong>{{doc.appointment}}\n\t\t\t</div>\n\t\t</div>\n\t\t{%- endif -%}\n\n                <div class=\"row\">\n\t\t      <div class=\"col-xs-4 text-left\">\n\t\t\t <label>Patient</label>\n\t\t      </div>\n                     {% if doc.patient %}\n\t\t      <div class=\"col-xs-7  value\">\n\t\t\t  <strong>: </strong>{{doc.patient}}\n\t\t      </div>\n                     {% else %}\n                     <div class=\"col-xs-7  value\">\n\t\t\t <strong>: </strong><em>Patient Name</em>\n\t\t     </div>\n                     {%- endif -%}\n\t\t</div>\n\t        <div class=\"row\">\n\t\t\t<div class=\"col-xs-4 text-left\">\n\t\t\t\t<label>Age</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t     <strong>: </strong> {{doc.patient_age}}\n\t\t\t</div>\n\t\t</div>\n\n                <div class=\"row\">\n                        <div class=\"col-xs-4 text-left\">\n\t\t\t\t<label>Gender</label>\n\t\t\t</div>\n\t\t\t<div class=\"col-xs-7  value\">\n\t\t\t     <strong>: </strong> {{doc.patient_sex}}\n\t\t\t</div>\n                </div>\n\n        </div>\n        <div class=\"col-xs-6 column-break\">\n\n          <div class=\"row\">\n\t      <div class=\"col-xs-4 text-left\">\n\t\t    <label>Healthcare Practitioner</label>\n\t      </div>\n              {% if doc.practitioner %}\n\t      <div class=\"col-xs-7  text-left value\">\n\t\t\t<strong>: </strong>{{doc.practitioner}}\n\t      </div>\n              {%- endif -%}\n\t</div>\n\n          {% if doc.encounter_date %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Date</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.encounter_date}}\n\t\t</div>\n          </div>\n\t  {%- endif -%}\n          {% if doc.encounter_time %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Time</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.encounter_time}}\n\t\t</div>\n          </div>\n\t  {%- endif -%}\n          {% if doc.medical_department %}\n\t  <div class=\"row\">\n\t\t<div class=\"col-xs-4 text-left\">\n\t\t<label>Department</label>\n\t\t</div>\n\t\t<div class=\"col-xs-7 text-left value\">\n\t\t<strong>: </strong>{{doc.visit_department}}\n\t\t</div>\n          </div>\n          {%- endif -%}\n        </div>\n\n   </div>\n\n</div>\n<div>\n     <hr>\n     {% if doc.symptoms_in_print%}\n       {% if doc.symptoms %}\n         Complaints:\n         <strong>{{doc.symptoms}}</strong>\n  \t   <br>\n       {%- endif -%}\n     {%- endif -%}\n\n     {% if doc.diagnosis_in_print%}\n       {% if doc.diagnosis %}\n  \t     Diagnosis:\n         <strong>{{doc.diagnosis}}</strong>\n         <br>\n       {%- endif -%}\n     {%- endif -%}\n\n</div>\n\n<div>\n      {% if doc.drug_prescription %}\n      <br>\n      Rx,\n      <table class=\"table\">\n        <tbody>\n            <!--<tr>\n                <th>Drug</th>\n                <th class=\"text-left\">Dosage</th>\n                <th class=\"text-left\">Period</th>\n                <th>Remark</th>\n            </tr>-->\n\n            {%- for row in doc.drug_prescription -%}\n            <tr>\n              <td style=\"width: 30%;border:none;\">\n                {%- if row.drug_name -%}<b>{{ row.drug_name }}</b>{%- endif -%}\n              </td>\n            \t<td style=\"width: 20%;text-align: left;border:none;\">\n                {%- if row.dosage -%}{{ row.dosage }}{%- endif -%}\n              </td>\n            \t<td style=\"width: 20%;text-align: left;border:none;\">\n                {%- if row.period -%}{{ row.period }}{%- endif -%}\n\t\t          </td>\n              <td style=\"width: 30%;text-align: left;border:none;\">\n\t\t\t             <div style=\"border: 0px;\">\n                      {%- if row.comment -%}{{ row.comment }}{%- endif -%}\n                   </div>\n\t\t           </td>\n            </tr>\n\t          {%- endfor -%}\n       </tbody>\n      </table>\n\n\n      {%- endif -%}\n</div>\n\n\n<div>\n      {% if doc.lab_test_prescription %}\n      Investigations,\n      <table class=\"table\">\n        <tbody>\n            <!--<tr>\n                <th>Test</th>\n                <th>Remark</th>\n            </tr>-->\n\n            {%- for row in doc.lab_test_prescription -%}\n            <tr>\n              <td style=\"width: 30%;border:none;\">\n                {%- if row.lab_test_name -%}<b>{{ row.lab_test_name }}</b>{%- endif -%}\n              </td>\n              <td style=\"width: 30%;text-align: left;border:none;\">\n\t\t\t           <div style=\"border: 0px;\">\n                   {%- if row.lab_test_comment -%}{{ row.lab_test_comment }}{%- endif -%}\n                 </div>\n\t\t          </td>\n             </tr>\n\n\t           {%- endfor -%}\n       </tbody>\n      </table>\n\n\n      {%- endif -%}\n</div>\n<div>\n    {% if doc.encounter_comment %}\n      <br>\n      {{doc.encounter_comment}}\n     {%- endif -%}\n</div>\n",
+ "idx": 0,
+ "line_breaks": 0,
+ "modified": "2018-09-04 11:52:54.473702",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Encounter Print",
+ "owner": "Administrator",
+ "print_format_builder": 0,
+ "print_format_type": "Server",
+ "show_section_headings": 0,
  "standard": "Yes"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/print_format/lab_test_print/lab_test_print.json b/erpnext/healthcare/print_format/lab_test_print/lab_test_print.json
index 6badc6f..e8e95d8 100644
--- a/erpnext/healthcare/print_format/lab_test_print/lab_test_print.json
+++ b/erpnext/healthcare/print_format/lab_test_print/lab_test_print.json
@@ -1,22 +1,22 @@
 {
- "align_labels_right": 0, 
- "creation": "2017-04-24 15:38:45.332473", 
- "custom_format": 1, 
- "disabled": 0, 
- "doc_type": "Lab Test", 
- "docstatus": 0, 
- "doctype": "Print Format", 
- "font": "Default", 
- "html": "<div >\n  {% if letter_head and not no_letterhead -%}\n    <div class=\"letter-head\">{{ letter_head }}</div>\n    <hr>\n  {%- endif %}\n\n  {% if (doc.docstatus != 1) %}\n  <b>Lab Tests have to be Submitted for Print .. !</b>\n  {% elif (frappe.db.get_value(\"Healthcare Settings\", \"None\", \"require_test_result_approval\") == '1' and doc.approval_status != \"Approved\") %}\n  <b>Lab Tests have to be Approved for Print .. !</b>\n  {%- else -%}\n  <div class=\"row section-break\">\n    <div class=\"col-xs-6 column-break\">\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Patient</label>\n        </div>\n        {% if doc.patient %}\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong>{{doc.patient}}\n        </div>\n        {% else %}\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong><em>Patient Name</em>\n        </div>\n        {%- endif -%}\n      </div>\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Age</label>\n        </div>\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong> {{doc.patient_age}}\n        </div>\n      </div>\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Gender</label>\n        </div>\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong> {{doc.patient_sex}}\n        </div>\n      </div>\n\n    </div>\n\n    <div class=\"col-xs-6 column-break\">\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Practitioner</label>\n        </div>\n        {% if doc.practitioner %}\n        <div class=\"col-xs-7  text-left value\">\n          <strong>: </strong>{{doc.practitioner}}\n        </div>\n        {%- endif -%}\n      </div>\n\n      {% if doc.sample_date %}\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Sample Date</label>\n        </div>\n        <div class=\"col-xs-7 text-left value\">\n          <strong>: </strong>{{doc.sample_date}}\n        </div>\n      </div>\n      {%- endif -%}\n\n      {% if doc.result_date %}\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Result Date</label>\n        </div>\n        <div class=\"col-xs-7 text-left value\">\n          <strong>: </strong>{{doc.result_date}}\n        </div>\n      </div>\n      {%- endif -%}\n\n    </div>\n\n  </div>\n\n  <div align=\"center\">\n    <hr><h4 class=\"text-uppercase\"><b><u>Department of {{doc.department}}</u></b></h4>\n  </div>\n\n  <table class=\"table\">\n    <tbody>\n      {%- if doc.normal_test_items -%}\n      <tr>\n        <th>Name of Test</th>\n        <th class=\"text-left\">Result</th>\n        <th class=\"text-right\">Normal Range</th>\n      </tr>\n\n      {%- if doc.normal_test_items|length > 1 %}\n      <tr><td style=\"width: 40%;\"> <b>{{ doc.lab_test_name }}</b> </td><td></td></tr>\n      {%- endif -%}\n\n      {%- for row in doc.normal_test_items -%}\n      <tr>\n        <td style=\"width: 40%;border:none;\">\n          {%- if doc.normal_test_items|length > 1 %}&emsp;&emsp;{%- endif -%}\n          {%- if row.lab_test_name -%}<b>{{ row.lab_test_name }}</b>\n          {%- else -%}&emsp;&emsp;&emsp;{%- endif -%}\n          {%- if row.lab_test_event -%} &emsp;&emsp;{{ row.lab_test_event }}{%- endif -%}\n        </td>\n\n        <td style=\"width: 20%;text-align: left;border:none;\">\n          {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}&emsp;\n          {%- if row.lab_test_uom -%}{{ row.lab_test_uom }}{%- endif -%}\n        </td>\n\n        <td style=\"width: 30%;text-align: right;border:none;\">\n          <div style=\"border: 0px;\">\n            {%- if row.normal_range -%}{{ row.normal_range }}{%- endif -%}\n          </div>\n        </td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n    </tbody>\n  </table>\n\n  <table class=\"table\">\n    <tbody>\n      {%- if doc.special_test_items -%}\n      <tr>\n        <th>Name of Test</th>\n        <th class=\"text-left\">Result</th>\n      </tr>\n      <tr><td style=\"width: 30%;border:none;\"> <b>{{ doc.lab_test_name }}</b> </td><td></td></tr>\n      {%- for row in doc.special_test_items -%}\n      <tr>\n        <td style=\"width: 30%;border:none;\"> &emsp;&emsp;{{ row.lab_test_particulars }} </td>\n        <td style=\"width: 70%;text-align: left;border:none;\">\n          {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}\n        </td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n\n      {%- if doc.sensitivity_test_items -%}\n      <tr>\n        <th>Antibiotic</th>\n        <th class=\"text-left\">Sensitivity</th>\n      </tr>\n      {%- for row in doc.sensitivity_test_items -%}\n      <tr>\n        <td style=\"width: 30%;border:none;\"> {{ row.antibiotic }} </td>\n        <td style=\"width: 70%;text-align: left;border:none;\">{{ row.antibiotic_sensitivity }}</td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n\n    </tbody>\n  </table>\n  {%- endif -%}\n\n  <div align=\"right\">\n    {%- if (frappe.db.get_value(\"Healthcare Settings\", \"None\", \"employee_name_and_designation_in_print\") == '1') -%}\n    <h6 class=\"text-uppercase\"><b>{{doc.employee_name}}</b></h6>\n    <h6 class=\"text-uppercase\"><b>{{doc.employee_designation}}</b></h6>\n    {%- else -%}\n    <h6 ><b>{{frappe.db.get_value(\"Healthcare Settings\", \"None\", \"custom_signature_in_print\") }}</b></h6>\n    {%- endif -%}\n  </div>\n</div>\n", 
- "idx": 0, 
- "line_breaks": 0, 
- "modified": "2018-09-04 12:03:47.066918", 
- "modified_by": "Administrator", 
- "module": "Healthcare", 
- "name": "Lab Test Print", 
- "owner": "Administrator", 
- "print_format_builder": 0, 
- "print_format_type": "Server", 
- "show_section_headings": 0, 
+ "align_labels_right": 0,
+ "creation": "2017-04-24 15:38:45.332473",
+ "custom_format": 1,
+ "disabled": 0,
+ "doc_type": "Lab Test",
+ "docstatus": 0,
+ "doctype": "Print Format",
+ "font": "Default",
+ "html": "<div >\n  {% if letter_head and not no_letterhead -%}\n    <div class=\"letter-head\">{{ letter_head }}</div>\n    <hr>\n  {%- endif %}\n\n  {% if (doc.docstatus != 1) %}\n  <b>Lab Tests have to be Submitted for Print .. !</b>\n  {% elif (frappe.db.get_value(\"Healthcare Settings\", \"None\", \"lab_test_approval_required\") == '1' and doc.approval_status != \"Approved\") %}\n  <b>Lab Tests have to be Approved for Print .. !</b>\n  {%- else -%}\n  <div class=\"row section-break\">\n    <div class=\"col-xs-6 column-break\">\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Patient</label>\n        </div>\n        {% if doc.patient %}\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong>{{doc.patient}}\n        </div>\n        {% else %}\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong><em>Patient Name</em>\n        </div>\n        {%- endif -%}\n      </div>\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Age</label>\n        </div>\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong> {{doc.patient_age}}\n        </div>\n      </div>\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Gender</label>\n        </div>\n        <div class=\"col-xs-7  value\">\n          <strong>: </strong> {{doc.patient_sex}}\n        </div>\n      </div>\n\n    </div>\n\n    <div class=\"col-xs-6 column-break\">\n\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Practitioner</label>\n        </div>\n        {% if doc.practitioner %}\n        <div class=\"col-xs-7  text-left value\">\n          <strong>: </strong>{{doc.practitioner}}\n        </div>\n        {%- endif -%}\n      </div>\n\n      {% if doc.sample_date %}\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Sample Date</label>\n        </div>\n        <div class=\"col-xs-7 text-left value\">\n          <strong>: </strong>{{doc.sample_date}}\n        </div>\n      </div>\n      {%- endif -%}\n\n      {% if doc.result_date %}\n      <div class=\"row\">\n        <div class=\"col-xs-4 text-left\">\n          <label>Result Date</label>\n        </div>\n        <div class=\"col-xs-7 text-left value\">\n          <strong>: </strong>{{doc.result_date}}\n        </div>\n      </div>\n      {%- endif -%}\n\n    </div>\n\n  </div>\n\n  <div align=\"center\">\n    <hr><h4 class=\"text-uppercase\"><b><u>Department of {{doc.department}}</u></b></h4>\n  </div>\n\n  <table class=\"table\">\n    <tbody>\n      {%- if doc.normal_test_items -%}\n      <tr>\n        <th>Name of Test</th>\n        <th class=\"text-left\">Result</th>\n        <th class=\"text-right\">Normal Range</th>\n      </tr>\n\n      {%- if doc.normal_test_items|length > 1 %}\n      <tr><td style=\"width: 40%;\"> <b>{{ doc.lab_test_name }}</b> </td><td></td></tr>\n      {%- endif -%}\n\n      {%- for row in doc.normal_test_items -%}\n      <tr>\n        <td style=\"width: 40%;border:none;\">\n          {%- if doc.normal_test_items|length > 1 %}&emsp;&emsp;{%- endif -%}\n          {%- if row.lab_test_name -%}<b>{{ row.lab_test_name }}</b>\n          {%- else -%}&emsp;&emsp;&emsp;{%- endif -%}\n          {%- if row.lab_test_event -%} &emsp;&emsp;{{ row.lab_test_event }}{%- endif -%}\n        </td>\n\n        <td style=\"width: 20%;text-align: left;border:none;\">\n          {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}&emsp;\n          {%- if row.lab_test_uom -%}{{ row.lab_test_uom }}{%- endif -%}\n        </td>\n\n        <td style=\"width: 30%;text-align: right;border:none;\">\n          <div style=\"border: 0px;\">\n            {%- if row.normal_range -%}{{ row.normal_range }}{%- endif -%}\n          </div>\n        </td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n    </tbody>\n  </table>\n\n  <table class=\"table\">\n    <tbody>\n      {%- if doc.special_test_items -%}\n      <tr>\n        <th>Name of Test</th>\n        <th class=\"text-left\">Result</th>\n      </tr>\n      <tr><td style=\"width: 30%;border:none;\"> <b>{{ doc.lab_test_name }}</b> </td><td></td></tr>\n      {%- for row in doc.special_test_items -%}\n      <tr>\n        <td style=\"width: 30%;border:none;\"> &emsp;&emsp;{{ row.lab_test_particulars }} </td>\n        <td style=\"width: 70%;text-align: left;border:none;\">\n          {%- if row.result_value -%}{{ row.result_value }}{%- endif -%}\n        </td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n\n      {%- if doc.sensitivity_test_items -%}\n      <tr>\n        <th>Antibiotic</th>\n        <th class=\"text-left\">Sensitivity</th>\n      </tr>\n      {%- for row in doc.sensitivity_test_items -%}\n      <tr>\n        <td style=\"width: 30%;border:none;\"> {{ row.antibiotic }} </td>\n        <td style=\"width: 70%;text-align: left;border:none;\">{{ row.antibiotic_sensitivity }}</td>\n      </tr>\n\n      {%- endfor -%}\n      {%- endif -%}\n\n    </tbody>\n  </table>\n  {%- endif -%}\n\n  <div align=\"right\">\n    {%- if (frappe.db.get_value(\"Healthcare Settings\", \"None\", \"employee_name_and_designation_in_print\") == '1') -%}\n    <h6 class=\"text-uppercase\"><b>{{doc.employee_name}}</b></h6>\n    <h6 class=\"text-uppercase\"><b>{{doc.employee_designation}}</b></h6>\n    {%- else -%}\n    <h6 ><b>{{frappe.db.get_value(\"Healthcare Settings\", \"None\", \"custom_signature_in_print\") }}</b></h6>\n    {%- endif -%}\n  </div>\n</div>\n",
+ "idx": 0,
+ "line_breaks": 0,
+ "modified": "2018-09-04 12:03:47.066918",
+ "modified_by": "Administrator",
+ "module": "Healthcare",
+ "name": "Lab Test Print",
+ "owner": "Administrator",
+ "print_format_builder": 0,
+ "print_format_type": "Server",
+ "show_section_headings": 0,
  "standard": "Yes"
 }
\ No newline at end of file
diff --git a/erpnext/healthcare/utils.py b/erpnext/healthcare/utils.py
index 97bb98f..3a08e33 100644
--- a/erpnext/healthcare/utils.py
+++ b/erpnext/healthcare/utils.py
@@ -47,7 +47,7 @@
 						if not practitioner_exist_in_list:
 							valid_till = patient_appointment_obj.appointment_date + datetime.timedelta(days=int(valid_days))
 							visits = 0
-							validity_exist = validity_exists(patient_appointment_obj.practitioner, patient_appointment_obj.patient)
+							validity_exist = check_validity_exists(patient_appointment_obj.practitioner, patient_appointment_obj.patient)
 							if validity_exist:
 								fee_validity = frappe.get_doc("Fee Validity", validity_exist[0][0])
 								valid_till = fee_validity.valid_till
@@ -60,7 +60,7 @@
 							income_account = None
 							service_item = None
 							if patient_appointment_obj.practitioner:
-								service_item, practitioner_charge = service_item_and_practitioner_charge(patient_appointment_obj)
+								service_item, practitioner_charge = get_service_item_and_practitioner_charge(patient_appointment_obj)
 								income_account = get_income_account(patient_appointment_obj.practitioner, patient_appointment_obj.company)
 							item_to_invoice.append({'reference_type': 'Patient Appointment', 'reference_name': patient_appointment_obj.name,
 							'service': service_item, 'rate': practitioner_charge,
@@ -75,7 +75,7 @@
 						income_account = None
 						service_item = None
 						if encounter_obj.practitioner:
-							service_item, practitioner_charge = service_item_and_practitioner_charge(encounter_obj)
+							service_item, practitioner_charge = get_service_item_and_practitioner_charge(encounter_obj)
 							income_account = get_income_account(encounter_obj.practitioner, encounter_obj.company)
 
 						item_to_invoice.append({'reference_type': 'Patient Encounter', 'reference_name': encounter_obj.name,
@@ -159,9 +159,9 @@
 		else:
 			frappe.throw(_("The Patient {0} do not have customer refrence to invoice").format(patient.name))
 
-def service_item_and_practitioner_charge(doc):
-	is_ip = doc_is_ip(doc)
-	if is_ip:
+def get_service_item_and_practitioner_charge(doc):
+	is_inpatient = doc_is_inpatient(doc)
+	if is_inpatient:
 		service_item = get_practitioner_service_item(doc.practitioner, "inpatient_visit_charge_item")
 		if not service_item:
 			service_item = get_healthcare_service_item("inpatient_visit_charge_item")
@@ -170,26 +170,26 @@
 		if not service_item:
 			service_item = get_healthcare_service_item("op_consulting_charge_item")
 	if not service_item:
-		throw_config_service_item(is_ip)
+		throw_config_service_item(is_inpatient)
 
-	practitioner_charge = get_practitioner_charge(doc.practitioner, is_ip)
+	practitioner_charge = get_practitioner_charge(doc.practitioner, is_inpatient)
 	if not practitioner_charge:
-		throw_config_practitioner_charge(is_ip, doc.practitioner)
+		throw_config_practitioner_charge(is_inpatient, doc.practitioner)
 
 	return service_item, practitioner_charge
 
-def throw_config_service_item(is_ip):
+def throw_config_service_item(is_inpatient):
 	service_item_lable = "Out Patient Consulting Charge Item"
-	if is_ip:
+	if is_inpatient:
 		service_item_lable = "Inpatient Visit Charge Item"
 
 	msg = _(("Please Configure {0} in ").format(service_item_lable) \
 		+ """<b><a href="#Form/Healthcare Settings">Healthcare Settings</a></b>""")
 	frappe.throw(msg)
 
-def throw_config_practitioner_charge(is_ip, practitioner):
+def throw_config_practitioner_charge(is_inpatient, practitioner):
 	charge_name = "OP Consulting Charge"
-	if is_ip:
+	if is_inpatient:
 		charge_name = "Inpatient Visit Charge"
 
 	msg = _(("Please Configure {0} for Healthcare Practitioner").format(charge_name) \
@@ -202,14 +202,14 @@
 def get_healthcare_service_item(service_item_field):
 	return frappe.db.get_value("Healthcare Settings", None, service_item_field)
 
-def doc_is_ip(doc):
-	is_ip = False
+def doc_is_inpatient(doc):
+	is_inpatient = False
 	if doc.inpatient_record:
-		is_ip = True
-	return is_ip
+		is_inpatient = True
+	return is_inpatient
 
-def get_practitioner_charge(practitioner, is_ip):
-	if is_ip:
+def get_practitioner_charge(practitioner, is_inpatient):
+	if is_inpatient:
 		practitioner_charge = frappe.db.get_value("Healthcare Practitioner", practitioner, "inpatient_visit_charge")
 	else:
 		practitioner_charge = frappe.db.get_value("Healthcare Practitioner", practitioner, "op_consulting_charge")
@@ -224,7 +224,7 @@
 				if frappe.get_meta(item.reference_dt).has_field("invoiced"):
 					set_invoiced(item, method, doc.name)
 
-	if method=="on_submit" and frappe.db.get_value("Healthcare Settings", None, "create_test_on_si_submit") == '1':
+	if method=="on_submit" and frappe.db.get_value("Healthcare Settings", None, "create_lab_test_on_si_submit") == '1':
 		create_multiple("Sales Invoice", doc.name)
 
 def set_invoiced(item, method, ref_invoice=None):
@@ -271,7 +271,7 @@
 		doc_created = frappe.db.get_value(dt, {'prescription': ref_dn})
 		frappe.db.set_value(dt, doc_created, 'invoiced', invoiced)
 
-def validity_exists(practitioner, patient):
+def check_validity_exists(practitioner, patient):
 	return frappe.db.exists({
 			"doctype": "Fee Validity",
 			"practitioner": practitioner,
@@ -279,7 +279,7 @@
 
 def manage_fee_validity(appointment_name, method, ref_invoice=None):
 	appointment_doc = frappe.get_doc("Patient Appointment", appointment_name)
-	validity_exist = validity_exists(appointment_doc.practitioner, appointment_doc.patient)
+	validity_exist = check_validity_exists(appointment_doc.practitioner, appointment_doc.patient)
 	do_not_update = False
 	visited = 0
 	if validity_exist:
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 54f1a1e..a674144 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -273,7 +273,8 @@
 
 scheduler_events = {
 	"all": [
-		"erpnext.projects.doctype.project.project.project_status_update_reminder"
+		"erpnext.projects.doctype.project.project.project_status_update_reminder",
+		"erpnext.healthcare_healthcare.doctype.patient_appointment.patient_appointment.send_appointment_reminder"
 	],
 	"hourly": [
 		'erpnext.hr.doctype.daily_work_summary_group.daily_work_summary_group.trigger_emails',
@@ -308,7 +309,8 @@
 		"erpnext.support.doctype.service_level_agreement.service_level_agreement.check_agreement_status",
 		"erpnext.crm.doctype.email_campaign.email_campaign.send_email_to_leads_or_contacts",
 		"erpnext.crm.doctype.email_campaign.email_campaign.set_email_campaign_status",
-		"erpnext.selling.doctype.quotation.quotation.set_expired_status"
+		"erpnext.selling.doctype.quotation.quotation.set_expired_status",
+		"erpnext.healthcare_healthcare.doctype.patient_appointment.patient_appointment.update_appointment_status"
 	],
 	"daily_long": [
 		"erpnext.setup.doctype.email_digest.email_digest.send",
diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js
index 7d153d4..c21d4b8 100755
--- a/erpnext/hr/doctype/employee/employee.js
+++ b/erpnext/hr/doctype/employee/employee.js
@@ -55,8 +55,8 @@
 			};
 		});
 	},
-	prefered_contact_email:function(frm){		
-		frm.events.update_contact(frm)		
+	prefered_contact_email:function(frm){
+		frm.events.update_contact(frm)
 	},
 	personal_email:function(frm){
 		frm.events.update_contact(frm)