feat: set date field in Settings for Patient Medical Record

This commit is contained in:
Rucha Mahabal 2020-11-28 19:19:58 +05:30
parent 2c114053ad
commit f2932d7208
4 changed files with 44 additions and 26 deletions

View File

@ -6,7 +6,8 @@
"engine": "InnoDB",
"field_order": [
"document_type",
"select_fields",
"date_fieldname",
"add_edit_fields",
"selected_fields"
],
"fields": [
@ -18,22 +19,29 @@
"options": "DocType",
"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",

View File

@ -73,13 +73,10 @@ frappe.ui.form.on('Patient History Settings', {
});
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);
}
}
});

View File

@ -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)))

View File

@ -6,7 +6,7 @@
"engine": "InnoDB",
"field_order": [
"document_type",
"select_fields",
"add_edit_fields",
"selected_fields"
],
"fields": [
@ -19,22 +19,22 @@
"read_only": 1,
"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",