feat: Patient History Settings

This commit is contained in:
Rucha Mahabal 2020-11-27 15:05:28 +05:30
parent 6b57cf3285
commit 2c114053ad
11 changed files with 273 additions and 0 deletions

View File

@ -0,0 +1,46 @@
{
"actions": [],
"creation": "2020-11-25 13:40:23.054469",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"document_type",
"select_fields",
"selected_fields"
],
"fields": [
{
"fieldname": "document_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type",
"options": "DocType",
"reqd": 1
},
{
"fieldname": "select_fields",
"fieldtype": "Button",
"in_list_view": 1,
"label": "Select Fields"
},
{
"fieldname": "selected_fields",
"fieldtype": "Code",
"label": "selected_fields"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2020-11-25 14:19:33.637543",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient History Custom Document Type",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@ -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 PatientHistoryCustomDocumentType(Document):
pass

View File

@ -0,0 +1,85 @@
// Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Patient History Settings', {
refresh: function(frm) {
frm.set_query('document_type', 'custom_doctypes', () => {
return {
filters: {
custom: 1,
module: 'Healthcare'
}
};
});
},
field_selector: function(frm, doc) {
let document_fields = (JSON.parse(doc.selected_fields)).map(f => f.fieldname);
let d = new frappe.ui.Dialog({
title: __('{0} Fields', [__(doc.document_type)]),
fields: [
{
label: __('Select Fields'),
fieldtype: 'MultiCheck',
fieldname: 'fields',
options: frm.events.get_doctype_fields(frm, doc.document_type, document_fields),
columns: 2
}
]
});
d.set_primary_action(__('Save'), () => {
let values = d.get_values().fields;
let selected_fields = [];
for (let idx in values) {
let value = values[idx];
let field = frappe.meta.get_docfield(doc.document_type, value);
if (field) {
selected_fields.push({
label: field.label,
fieldname: field.fieldname
});
}
}
frappe.model.set_value('Patient History Custom Document Type', doc.name, 'selected_fields', JSON.stringify(selected_fields));
d.hide();
});
d.show();
},
get_doctype_fields(frm, document_type, fields) {
let multiselect_fields = [];
frappe.model.with_doctype(document_type, () => {
// get doctype fields
frappe.get_doc('DocType', document_type).fields.forEach(field => {
if (!in_list(frappe.model.no_value_type, field.fieldtype) && !field.hidden) {
multiselect_fields.push({
label: field.label,
value: field.fieldname,
checked: in_list(fields, field.fieldname)
});
}
});
});
return multiselect_fields;
}
});
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);
}
});

View File

@ -0,0 +1,55 @@
{
"actions": [],
"creation": "2020-11-25 13:41:37.675518",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"standard_doctypes",
"section_break_2",
"custom_doctypes"
],
"fields": [
{
"fieldname": "section_break_2",
"fieldtype": "Section Break"
},
{
"fieldname": "custom_doctypes",
"fieldtype": "Table",
"label": "Custom Document Types",
"options": "Patient History Custom Document Type"
},
{
"fieldname": "standard_doctypes",
"fieldtype": "Table",
"label": "Standard Document Types",
"options": "Patient History Standard Document Type",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"issingle": 1,
"links": [],
"modified": "2020-11-25 13:43:38.511771",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient History Settings",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@ -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 PatientHistorySettings(Document):
pass

View File

@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest
class TestPatientHistorySettings(unittest.TestCase):
pass

View File

@ -0,0 +1,47 @@
{
"actions": [],
"creation": "2020-11-25 13:39:36.014814",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"document_type",
"select_fields",
"selected_fields"
],
"fields": [
{
"fieldname": "document_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type",
"options": "DocType",
"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"
}
],
"index_web_pages_for_search": 1,
"istable": 1,
"links": [],
"modified": "2020-11-25 14:19:53.708991",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Patient History Standard Document Type",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View File

@ -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 PatientHistoryStandardDocumentType(Document):
pass