feat: fetch date field for custom doctypes
This commit is contained in:
parent
7201498801
commit
75a93d9057
@ -85,10 +85,33 @@ frappe.ui.form.on('Patient History Settings', {
|
||||
});
|
||||
|
||||
d.show();
|
||||
},
|
||||
|
||||
get_date_field_for_dt: function(frm, row) {
|
||||
frm.call({
|
||||
method: 'get_date_field_for_dt',
|
||||
doc: frm.doc,
|
||||
args: {
|
||||
document_type: row.document_type
|
||||
},
|
||||
callback: function(data) {
|
||||
if (data.message) {
|
||||
frappe.model.set_value('Patient History Custom Document Type',
|
||||
row.name, 'date_fieldname', data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on('Patient History Custom Document Type', {
|
||||
document_type: function(frm, cdt, cdn) {
|
||||
let row = locals[cdt][cdn];
|
||||
if (row.document_type) {
|
||||
frm.events.get_date_field_for_dt(frm, row);
|
||||
}
|
||||
},
|
||||
|
||||
add_edit_fields: function(frm, cdt, cdn) {
|
||||
let row = locals[cdt][cdn];
|
||||
if (row.document_type) {
|
||||
|
@ -49,6 +49,14 @@ class PatientHistorySettings(Document):
|
||||
|
||||
return multicheck_fields
|
||||
|
||||
def get_date_field_for_dt(self, document_type):
|
||||
meta = frappe.get_meta(document_type)
|
||||
date_fields = meta.get('fields', {
|
||||
'fieldtype': ['in', ['Date', 'Datetime']]
|
||||
})
|
||||
|
||||
if date_fields:
|
||||
return date_fields[0].get('fieldname')
|
||||
|
||||
def create_medical_record(doc, method=None):
|
||||
medical_record_required = validate_medical_record_required(doc)
|
||||
|
Loading…
x
Reference in New Issue
Block a user