feat: set date field in Settings for Patient Medical Record
diff --git a/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.json b/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.json
index a158075..7986e48 100644
--- a/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.json
+++ b/erpnext/healthcare/doctype/patient_history_custom_document_type/patient_history_custom_document_type.json
@@ -6,7 +6,8 @@
  "engine": "InnoDB",
  "field_order": [
   "document_type",
-  "select_fields",
+  "date_fieldname",
+  "add_edit_fields",
   "selected_fields"
  ],
  "fields": [
@@ -19,21 +20,28 @@
    "reqd": 1
   },
   {
-   "fieldname": "select_fields",
-   "fieldtype": "Button",
-   "in_list_view": 1,
-   "label": "Select Fields"
-  },
-  {
    "fieldname": "selected_fields",
    "fieldtype": "Code",
    "label": "selected_fields"
+  },
+  {
+   "fieldname": "add_edit_fields",
+   "fieldtype": "Button",
+   "in_list_view": 1,
+   "label": "Add / Edit Fields"
+  },
+  {
+   "fieldname": "date_fieldname",
+   "fieldtype": "Data",
+   "in_list_view": 1,
+   "label": "Date Fieldname",
+   "reqd": 1
   }
  ],
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2020-11-25 14:19:33.637543",
+ "modified": "2020-11-28 19:04:48.323164",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient History Custom Document Type",
diff --git a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.js b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.js
index 155476e..ca2707f 100644
--- a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.js
+++ b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.js
@@ -73,13 +73,10 @@
 });
 
 frappe.ui.form.on('Patient History Custom Document Type', {
-	select_fields: function(frm) {
-		let doc = frm.selected_doc;
-
-		if (!doc.document_type)
-			frappe.throw(__('Select the Document Type first.'))
-
-		frm.events.field_selector(frm, doc);
+	add_edit_fields: function(frm, cdt, cdn) {
+		let row = locals[cdt][cdn];
+		if (row.document_type) {
+			frm.events.field_selector(frm, row);
+		}
 	}
-
 });
diff --git a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py
index 27cbf2f..9e876e8 100644
--- a/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py
+++ b/erpnext/healthcare/doctype/patient_history_settings/patient_history_settings.py
@@ -3,8 +3,21 @@
 # For license information, please see license.txt
 
 from __future__ import unicode_literals
-# import frappe
+import frappe
+from frappe import _
 from frappe.model.document import Document
 
 class PatientHistorySettings(Document):
-	pass
+	def validate(self):
+		self.validate_date_fieldnames()
+
+	def validate_date_fieldnames(self):
+		for entry in self.custom_doctypes:
+			field = frappe.get_meta(entry.document_type).get_field(entry.date_fieldname)
+			if not field:
+				frappe.throw(_('Row #{0}: No such Field named {1} found in the Document Type {2}.').format(
+					entry.idx, frappe.bold(entry.date_fieldname), frappe.bold(entry.document_type)))
+
+			if field.fieldtype not in ['Date', 'Datetime']:
+				frappe.throw(_('Row #{0}: Field {1} in Document Type {2} is not a Date / Datetime field.').format(
+					entry.idx, frappe.bold(entry.date_fieldname), frappe.bold(entry.document_type)))
\ No newline at end of file
diff --git a/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.json b/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.json
index ec40d89..ef4fc2b 100644
--- a/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.json
+++ b/erpnext/healthcare/doctype/patient_history_standard_document_type/patient_history_standard_document_type.json
@@ -6,7 +6,7 @@
  "engine": "InnoDB",
  "field_order": [
   "document_type",
-  "select_fields",
+  "add_edit_fields",
   "selected_fields"
  ],
  "fields": [
@@ -20,21 +20,21 @@
    "reqd": 1
   },
   {
-   "fieldname": "select_fields",
-   "fieldtype": "Button",
-   "in_list_view": 1,
-   "label": "Select Fields"
-  },
-  {
    "fieldname": "selected_fields",
    "fieldtype": "Code",
    "label": "Selected Fields"
+  },
+  {
+   "fieldname": "add_edit_fields",
+   "fieldtype": "Button",
+   "in_list_view": 1,
+   "label": "Add / Edit Fields"
   }
  ],
  "index_web_pages_for_search": 1,
  "istable": 1,
  "links": [],
- "modified": "2020-11-25 14:19:53.708991",
+ "modified": "2020-11-28 18:57:30.446348",
  "modified_by": "Administrator",
  "module": "Healthcare",
  "name": "Patient History Standard Document Type",