fix: field order, minor fixes -
patient - update customer, releated fields
patient appointment - send message
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
index 80157e1..2d30e90 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.js
@@ -87,8 +87,8 @@
 												['<a class="bold" href="#Form/Stock Entry/'+ r.message + '">' + r.message + '</a>']),
 											indicator: 'green'
 										});
-										frm.reload_doc();
 									}
+									frm.reload_doc();
 								}
 							});
 						}
@@ -156,11 +156,13 @@
 							age = __('{0} as on {1}', [age, data.message.age_as_on]);
 						}
 					}
+					frm.set_value('patient_name', data.message.patient_name);
 					frm.set_value('patient_age', age);
 					frm.set_value('patient_sex', data.message.sex);
 				}
 			});
 		} else {
+			frm.set_value('patient_name', '');
 			frm.set_value('patient_age', '');
 			frm.set_value('patient_sex', '');
 		}
@@ -179,6 +181,7 @@
 						'patient':data.message.patient,
 						'procedure_template': data.message.procedure_template,
 						'medical_department': data.message.department,
+						'practitioner': data.message.practitioner,
 						'start_date': data.message.appointment_date,
 						'start_time': data.message.appointment_time,
 						'notes': data.message.notes,
@@ -188,8 +191,7 @@
 					frm.set_value(values);
 				}
 			});
-		}
-		else{
+		} else {
 			let values = {
 				'patient': '',
 				'patient_name': '',
@@ -252,9 +254,11 @@
 					name: frm.doc.practitioner
 				},
 				callback: function (data) {
-					frappe.model.set_value(frm.doctype,frm.docname, 'medical_department',data.message.department);
+					frappe.model.set_value(frm.doctype,frm.docname, 'practitioner_name', data.message.practitioner_name);
 				}
 			});
+		} else {
+			frappe.model.set_value(frm.doctype,frm.docname, 'practitioner_name', '');
 		}
 	},
 
@@ -302,14 +306,6 @@
 
 });
 
-cur_frm.set_query('procedure_template', function(doc) {
-	return {
-		filters: {
-			'medical_department': doc.medical_department
-		}
-	};
-});
-
 frappe.ui.form.on('Clinical Procedure Item', {
 	qty: function(frm, cdt, cdn) {
 		let d = locals[cdt][cdn];
diff --git a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
index 59a87ec..7c4b9a3 100644
--- a/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
+++ b/erpnext/healthcare/doctype/clinical_procedure/clinical_procedure.json
@@ -9,27 +9,29 @@
  "field_order": [
   "naming_series",
   "appointment",
-  "column_break_30",
   "procedure_template",
+  "column_break_30",
+  "company",
+  "invoiced",
   "section_break_6",
   "patient",
   "patient_name",
   "patient_sex",
   "patient_age",
-  "medical_department",
-  "practitioner",
-  "practitioner_name",
+  "inpatient_record",
+  "notes",
   "column_break_7",
   "status",
+  "practitioner",
+  "practitioner_name",
+  "medical_department",
   "service_unit",
-  "warehouse",
   "start_date",
   "start_time",
   "sample",
-  "invoiced",
-  "notes",
   "consumables_section",
   "consume_stock",
+  "warehouse",
   "items",
   "section_break_24",
   "invoice_separately_as_consumables",
@@ -38,8 +40,6 @@
   "column_break_27",
   "consumption_details",
   "sb_refs",
-  "inpatient_record",
-  "company",
   "column_break_34",
   "prescription",
   "amended_from"
@@ -64,10 +64,10 @@
    "fieldtype": "Link",
    "in_standard_filter": 1,
    "label": "Appointment",
-   "options": "Patient Appointment"
+   "options": "Patient Appointment",
+   "set_only_once": 1
   },
   {
-   "fetch_from": "inpatient_record.patient",
    "fieldname": "patient",
    "fieldtype": "Link",
    "in_standard_filter": 1,
@@ -217,6 +217,7 @@
    "read_only": 1
   },
   {
+   "depends_on": "eval:!doc.__islocal",
    "fieldname": "status",
    "fieldtype": "Select",
    "in_list_view": 1,
@@ -235,6 +236,8 @@
    "read_only": 1
   },
   {
+   "collapsible": 1,
+   "collapsible_depends_on": "consume_stock",
    "fieldname": "consumables_section",
    "fieldtype": "Section Break",
    "label": "Consumables"
@@ -261,14 +264,12 @@
    "fieldtype": "Section Break"
   },
   {
-   "fetch_from": "patient.patient_name",
    "fieldname": "patient_name",
    "fieldtype": "Data",
    "label": "Patient Name",
    "read_only": 1
   },
   {
-   "fetch_from": "practitioner.practitioner_name",
    "fieldname": "practitioner_name",
    "fieldtype": "Data",
    "in_list_view": 1,
@@ -282,7 +283,7 @@
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2020-04-03 23:06:04.009856",
+ "modified": "2020-04-24 22:53:13.156901",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Clinical Procedure",
@@ -298,6 +299,21 @@
    "report": 1,
    "role": "Nursing User",
    "share": 1,
+   "submit": 1,
+   "write": 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
   }
  ],
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.js b/erpnext/healthcare/doctype/lab_test/lab_test.js
index e7e44dc..bf1ecc8 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.js
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.js
@@ -137,13 +137,13 @@
 		});
 	}
 	else{
-		frappe.msgprint(__("Please select a Patient to get Lab Orders"));
+		frappe.msgprint(__("Please select a Patient to get Lab Tests"));
 	}
 };
 
 var show_lab_tests = function(frm, result){
 	var d = new frappe.ui.Dialog({
-		title: __("Lab Test Prescriptions"),
+		title: __("Lab Tests"),
 		fields: [
 			{
 				fieldtype: "HTML", fieldname: "lab_test"
@@ -161,7 +161,7 @@
 		<div class="col-xs-1">\
 		<a data-name="%(name)s" data-lab-test="%(lab_test)s"\
 		data-encounter="%(encounter)s" data-practitioner="%(practitioner)s"\
-		data-invoiced="%(invoiced)s" href="#"><button class="btn btn-default btn-xs">Get Lab Test\
+		data-invoiced="%(invoiced)s" href="#"><button class="btn btn-default btn-xs">Get Lab Tests\
 		</button></a></div></div>', {name:y[0], lab_test: y[1], encounter:y[2], invoiced:y[3], practitioner:y[4], date:y[5]})).appendTo(html_field);
 		row.find("a").click(function() {
 			frm.doc.template = $(this).attr("data-lab-test");
@@ -181,7 +181,7 @@
 		});
 	});
 	if(!result.length){
-		var msg = "No Lab Orders found for patient <b>" + frm.doc.patient_name + "</b>";
+		var msg = __("No Lab Tests found for the Patient {0}", [frm.doc.patient_name.bold()]);
 		html_field.empty();
 		$(repl('<div class="col-xs-12" style="padding-top:0px;" >%(msg)s</div>', {msg: msg})).appendTo(html_field);
 	}
diff --git a/erpnext/healthcare/doctype/lab_test/lab_test.py b/erpnext/healthcare/doctype/lab_test/lab_test.py
index e49429e..298d293 100644
--- a/erpnext/healthcare/doctype/lab_test/lab_test.py
+++ b/erpnext/healthcare/doctype/lab_test/lab_test.py
@@ -69,7 +69,7 @@
 		lab_test_created = create_lab_test_from_encounter(docname)
 
 	if lab_test_created:
-		frappe.msgprint(_("Lab Test(s) " + lab_test_created + " created."))
+		frappe.msgprint(_("Lab Test(s) {0} created".format(lab_test_created)))
 	else:
 		frappe.msgprint(_("No Lab Tests created"))
 
@@ -111,7 +111,7 @@
 			if lab_test_created != 1:
 				template = get_lab_test_template(item.item_code)
 				if template:
-					lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template, company, invoice.company)
+					lab_test = create_lab_test_doc(True, invoice.ref_practitioner, patient, template, invoice.company)
 					if item.reference_dt == "Lab Prescription":
 						lab_test.prescription = item.reference_dn
 					lab_test.save(ignore_permissions = True)
diff --git a/erpnext/healthcare/doctype/patient/patient.js b/erpnext/healthcare/doctype/patient/patient.js
index a11faf5..490f247 100644
--- a/erpnext/healthcare/doctype/patient/patient.js
+++ b/erpnext/healthcare/doctype/patient/patient.js
@@ -10,6 +10,8 @@
 				]
 			};
 		});
+		frm.set_query('customer_group', {'is_group': 0});
+		frm.set_query('default_price_list', { 'selling': 1});
 
 		if (frappe.defaults.get_default('patient_name_by') != 'Naming Series') {
 			frm.toggle_display('naming_series', false);
diff --git a/erpnext/healthcare/doctype/patient/patient.json b/erpnext/healthcare/doctype/patient/patient.json
index 2c701fb..8af1a9c 100644
--- a/erpnext/healthcare/doctype/patient/patient.json
+++ b/erpnext/healthcare/doctype/patient/patient.json
@@ -72,6 +72,7 @@
   {
    "fieldname": "inpatient_status",
    "fieldtype": "Select",
+   "in_preview": 1,
    "label": "Inpatient Status",
    "options": "\nAdmission Scheduled\nAdmitted\nDischarge Scheduled",
    "read_only": 1
@@ -106,6 +107,7 @@
   {
    "fieldname": "sex",
    "fieldtype": "Link",
+   "in_preview": 1,
    "label": "Gender",
    "options": "Gender",
    "reqd": 1
@@ -114,6 +116,7 @@
    "bold": 1,
    "fieldname": "blood_group",
    "fieldtype": "Select",
+   "in_preview": 1,
    "label": "Blood Group",
    "options": "\nA Positive\nA Negative\nAB Positive\nAB Negative\nB Positive\nB Negative\nO Positive\nO Negative"
   },
@@ -121,6 +124,7 @@
    "bold": 1,
    "fieldname": "dob",
    "fieldtype": "Date",
+   "in_preview": 1,
    "label": "Date of birth"
   },
   {
@@ -147,6 +151,7 @@
    "fieldname": "image",
    "fieldtype": "Attach Image",
    "hidden": 1,
+   "in_preview": 1,
    "label": "Image",
    "no_copy": 1,
    "print_hide": 1,
@@ -161,9 +166,9 @@
    "fieldname": "customer",
    "fieldtype": "Link",
    "ignore_user_permissions": 1,
-   "in_preview": 1,
    "label": "Customer",
-   "options": "Customer"
+   "options": "Customer",
+   "set_only_once": 1
   },
   {
    "fieldname": "report_preference",
@@ -390,7 +395,7 @@
  "image_field": "image",
  "links": [],
  "max_attachments": 50,
- "modified": "2020-04-11 14:53:48.767245",
+ "modified": "2020-04-25 17:24:32.146415",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient",
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index f83fac0..6349aec 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -10,6 +10,7 @@
 import dateutil
 from frappe.model.naming import set_name_by_naming_series
 from frappe.utils.nestedset import get_root_of
+from erpnext import get_default_currency
 from erpnext.healthcare.doctype.healthcare_settings.healthcare_settings import get_receivable_account, get_income_account, send_registration_sms
 
 class Patient(Document):
@@ -17,6 +18,9 @@
 		self.set_full_name()
 		self.add_as_website_user()
 
+	def before_insert(self):
+		self.set_missing_customer_details()
+
 	def after_insert(self):
 		self.add_as_website_user()
 		self.reload()
@@ -28,12 +32,44 @@
 			send_registration_sms(self)
 		self.reload() # self.notify_update()
 
+	def on_update(self):
+		if self.customer:
+			customer = frappe.get_doc('Customer', self.customer)
+			if self.customer_group:
+				customer.customer_group = self.customer_group
+			if self.territory:
+				customer.territory = self.territory
+
+			customer.default_price_list = self.default_price_list
+			customer.default_currency = self.default_currency
+			customer.language = self.language
+			customer.save(ignore_permissions=True)
+		else:
+			if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+				create_customer(self)
+
 	def set_full_name(self):
 		if self.last_name:
 			self.patient_name = ' '.join(filter(None, [self.first_name, self.last_name]))
 		else:
 			self.patient_name = self.first_name
 
+	def set_missing_customer_details(self):
+		if not self.customer_group:
+			self.customer_group = frappe.db.get_single_value('Selling Settings', 'customer_group') or get_root_of('Customer Group')
+		if not self.territory:
+			self.territory = frappe.db.get_single_value('Selling Settings', 'territory') or get_root_of('Territory')
+		if not self.default_price_list:
+			self.default_price_list = frappe.db.get_single_value('Selling Settings', 'selling_price_list')
+
+		if not self.customer_group or not self.territory or not self.default_price_list:
+			frappe.msgprint(_('Please set defaults for Customer Group, Territory and Selling Price List in Selling Settings'), alert=True)
+
+		if not self.default_currency:
+			self.default_currency = get_default_currency()
+		if not self.language:
+			self.language = frappe.db.get_single_value('System Settings', 'language')
+
 	def add_as_website_user(self):
 		if self.email:
 			if not frappe.db.exists ('User', self.email):
@@ -87,21 +123,14 @@
 			return {'invoice': sales_invoice.name}
 
 def create_customer(doc):
-	customer_group = doc.customer_group or frappe.db.get_single_value('Selling Settings', 'customer_group')
-	territory = doc.territory or frappe.db.get_single_value('Selling Settings', 'territory')
-	if not (customer_group and territory):
-		customer_group = get_root_of('Customer Group')
-		territory = get_root_of('Territory')
-		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_group': doc.customer_group or frappe.db.get_single_value('Selling Settings', 'customer_group'),
+		'territory' : doc.territory or frappe.db.get_single_value('Selling Settings', 'territory'),
 		'customer_type': 'Individual',
 		'default_currency': doc.default_currency,
-		'default_price_ist': doc.default_price_list,
+		'default_price_list': doc.default_price_list,
 		'language': doc.language
 	}).insert(ignore_permissions=True, ignore_mandatory=True)
 
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
index 28db7ff..488abc2 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.js
@@ -127,6 +127,11 @@
 	patient: function(frm) {
 		if (frm.doc.patient) {
 			frm.trigger('toggle_payment_fields');
+		} else {
+			frm.set_value('patient_name', '');
+			frm.set_value('patient_sex', '');
+			frm.set_value('patient_age', '');
+			frm.set_value('inpatient_record', '');
 		}
 	},
 
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
index 6e889c2..2b0bf21 100644
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.json
@@ -10,33 +10,30 @@
  "engine": "InnoDB",
  "field_order": [
   "naming_series",
+  "status",
   "patient",
   "patient_name",
   "patient_sex",
   "patient_age",
-  "column_break_1",
   "inpatient_record",
+  "column_break_1",
   "company",
   "service_unit",
-  "status",
-  "section_break_11",
-  "get_procedure_from_encounter",
-  "column_break_13",
   "procedure_template",
+  "get_procedure_from_encounter",
   "procedure_prescription",
   "therapy_type",
   "get_prescribed_therapies",
   "therapy_plan",
-  "service_unit",
-  "section_break_12",
   "practitioner",
   "department",
+  "section_break_12",
   "appointment_type",
+  "duration",
   "column_break_17",
   "appointment_date",
   "appointment_time",
   "appointment_datetime",
-  "duration",
   "section_break_16",
   "mode_of_payment",
   "billing_item",
@@ -45,9 +42,10 @@
   "invoiced",
   "ref_sales_invoice",
   "section_break_3",
-  "notes",
   "referring_practitioner",
-  "reminded"
+  "reminded",
+  "column_break_36",
+  "notes"
  ],
  "fields": [
   {
@@ -59,7 +57,6 @@
    "read_only": 1
   },
   {
-   "fetch_from": "inpatient_record.patient",
    "fieldname": "patient",
    "fieldtype": "Link",
    "ignore_user_permissions": 1,
@@ -83,7 +80,8 @@
    "fieldname": "duration",
    "fieldtype": "Int",
    "in_filter": 1,
-   "label": "Duration (In Minutes)"
+   "label": "Duration (In Minutes)",
+   "set_only_once": 1
   },
   {
    "fieldname": "column_break_1",
@@ -102,6 +100,7 @@
    "search_index": 1
   },
   {
+   "depends_on": "eval:doc.patient;",
    "fieldname": "procedure_template",
    "fieldtype": "Link",
    "label": "Clinical Procedure Template",
@@ -133,7 +132,8 @@
   },
   {
    "fieldname": "section_break_12",
-   "fieldtype": "Section Break"
+   "fieldtype": "Section Break",
+   "label": "Appointment Details"
   },
   {
    "fieldname": "practitioner",
@@ -179,11 +179,13 @@
    "fieldtype": "Time",
    "in_list_view": 1,
    "label": "Time",
-   "read_only": 1
+   "read_only": 1,
+   "reqd": 1
   },
   {
    "fieldname": "section_break_16",
-   "fieldtype": "Section Break"
+   "fieldtype": "Section Break",
+   "label": "Payments"
   },
   {
    "fetch_from": "patient.patient_name",
@@ -212,6 +214,7 @@
   {
    "fieldname": "appointment_datetime",
    "fieldtype": "Datetime",
+   "hidden": 1,
    "label": "Appointment Datetime",
    "print_hide": 1,
    "read_only": 1,
@@ -243,9 +246,12 @@
   {
    "fieldname": "company",
    "fieldtype": "Link",
+   "in_standard_filter": 1,
    "label": "Company",
    "no_copy": 1,
-   "options": "Company"
+   "options": "Company",
+   "reqd": 1,
+   "set_only_once": 1
   },
   {
    "collapsible": 1,
@@ -312,23 +318,19 @@
    "set_only_once": 1
   },
   {
-   "fieldname": "section_break_11",
-   "fieldtype": "Section Break"
-  },
-  {
-   "fieldname": "column_break_13",
-   "fieldtype": "Column Break"
-  },
-  {
    "fieldname": "billing_item",
    "fieldtype": "Link",
    "label": "Billing Item",
    "options": "Item",
    "read_only": 1
+  },
+  {
+   "fieldname": "column_break_36",
+   "fieldtype": "Column Break"
   }
  ],
  "links": [],
- "modified": "2020-04-23 11:16:34.981240",
+ "modified": "2020-04-25 17:23:49.841975",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient Appointment",
diff --git a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
index 67fd82d..a0e3de6 100755
--- a/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
+++ b/erpnext/healthcare/doctype/patient_appointment/patient_appointment.py
@@ -369,17 +369,19 @@
 			frappe.db.set_value('Patient Appointment', doc.name, 'reminded', 1)
 
 def send_message(doc, message):
-	patient = frappe.get_doc('Patient', doc.patient)
-	if patient.mobile:
+	patient_mobile = frappe.db.get_value("Patient", doc.patient, "mobile")
+	if patient_mobile:
 		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)
-		number = [patient.mobile]
-		send_sms(number, message)
-
+		number = [patient_mobile]
+		try:
+			send_sms(number, message)
+		except Exception as e:
+			frappe.msgprint(_("SMS not sent, please check SMS Settings"), alert=True)
 
 @frappe.whitelist()
 def get_events(start, end, filters=None):
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
index 7600900..b2911d4 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.js
@@ -25,15 +25,16 @@
 		refresh_field('lab_test_prescription');
 
 		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);
-				});
+			if (frm.doc.docstatus == 1) {
+				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);
+					});
+				}
 			}
 
 			frm.add_custom_button(__('Patient History'), function() {
@@ -101,6 +102,11 @@
 		frm.events.set_patient_info(frm);
 	},
 
+	practitioner: function(frm) {
+		if(!frm.doc.practitioner) {
+			frm.set_value('practitioner_name', '');
+		}
+	},
 	set_appointment_fields: function(frm) {
 		if (frm.doc.appointment) {
 			frappe.call({
@@ -118,6 +124,7 @@
 						'company': data.message.company
 					};
 					frm.set_value(values);
+					frm.set_df_property('patient', 'read_only', 1);
 				}
 			});
 		}
@@ -134,6 +141,7 @@
 				'inpatient_status': ''
 			};
 			frm.set_value(values);
+			frm.set_df_property('patient', 'read_only', 0);
 		}
 	},
 
@@ -149,15 +157,20 @@
 					if (data.message.dob) {
 						age = calculate_age(data.message.dob);
 					}
+					frappe.model.set_value(frm.doctype, frm.docname, 'patient_mame', data.message.patient_mame);
 					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, 'inpatient_record', '');
+						frappe.model.set_value(frm.doctype, frm.docname, 'inpatient_status', '');
 					}
 				}
 			});
 		} else {
+			frappe.model.set_value(frm.doctype, frm.docname, 'patient_mame', '');
 			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', '');
diff --git a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
index ff7ecc9..f1831ad 100644
--- a/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
+++ b/erpnext/healthcare/doctype/patient_encounter/patient_encounter.json
@@ -17,17 +17,16 @@
   "patient_name",
   "patient_sex",
   "patient_age",
+  "inpatient_record",
+  "inpatient_status",
   "column_break_6",
+  "company",
+  "encounter_date",
+  "encounter_time",
   "practitioner",
   "practitioner_name",
   "medical_department",
-  "encounter_date",
-  "encounter_time",
   "invoiced",
-  "section_break_1",
-  "inpatient_record",
-  "column_break_17",
-  "inpatient_status",
   "sb_symptoms",
   "symptoms",
   "symptoms_in_print",
@@ -48,7 +47,6 @@
   "section_break_33",
   "encounter_comment",
   "sb_refs",
-  "company",
   "amended_from"
  ],
  "fields": [
@@ -60,12 +58,6 @@
    "read_only": 1
   },
   {
-   "collapsible": 1,
-   "fieldname": "section_break_1",
-   "fieldtype": "Section Break",
-   "label": "Inpatient Details"
-  },
-  {
    "fieldname": "naming_series",
    "fieldtype": "Select",
    "label": "Series",
@@ -79,10 +71,10 @@
    "ignore_user_permissions": 1,
    "label": "Appointment",
    "options": "Patient Appointment",
-   "search_index": 1
+   "search_index": 1,
+   "set_only_once": 1
   },
   {
-   "fetch_from": "inpatient_record.patient",
    "fieldname": "patient",
    "fieldtype": "Link",
    "ignore_user_permissions": 1,
@@ -93,7 +85,6 @@
    "search_index": 1
   },
   {
-   "fetch_from": "patient.patient_name",
    "fieldname": "patient_name",
    "fieldtype": "Data",
    "label": "Patient Name",
@@ -206,29 +197,29 @@
   {
    "fieldname": "codification_table",
    "fieldtype": "Table",
-   "label": "Medical Coding",
+   "label": "Medical Codes",
    "options": "Codification Table"
   },
   {
    "fieldname": "sb_drug_prescription",
    "fieldtype": "Section Break",
-   "label": "Medication"
+   "label": "Medications"
   },
   {
    "fieldname": "drug_prescription",
    "fieldtype": "Table",
-   "label": "Drug Prescription",
+   "label": "Items",
    "options": "Drug Prescription"
   },
   {
    "fieldname": "sb_test_prescription",
    "fieldtype": "Section Break",
-   "label": "Investigation"
+   "label": "Investigations"
   },
   {
    "fieldname": "lab_test_prescription",
    "fieldtype": "Table",
-   "label": "Lab Prescription",
+   "label": "Lab Tests",
    "options": "Lab Prescription"
   },
   {
@@ -239,7 +230,7 @@
   {
    "fieldname": "procedure_prescription",
    "fieldtype": "Table",
-   "label": "Procedure Prescription",
+   "label": "Clinical Procedures",
    "no_copy": 1,
    "options": "Procedure Prescription"
   },
@@ -310,10 +301,6 @@
    "read_only": 1
   },
   {
-   "fieldname": "column_break_17",
-   "fieldtype": "Column Break"
-  },
-  {
    "fieldname": "sb_refs",
    "fieldtype": "Section Break"
   },
@@ -328,7 +315,7 @@
  ],
  "is_submittable": 1,
  "links": [],
- "modified": "2020-04-23 23:06:16.348846",
+ "modified": "2020-04-27 18:59:25.713887",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient Encounter",