-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
healthcare/healthcare/doctype/medication/medication_item_preview.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<div style="padding: 15px;"> | ||
<div class="row mb-5"> | ||
<div class="col-md-4" style="max-height: 500px"> | ||
{% if data.image && !["undefined", "''"].includes(data.image) %} | ||
<div class="border image-field " style="overflow: hidden;border-color:#e6e6e6"> | ||
<img class="responsive" src={{ data.image }}> | ||
</div> | ||
{% endif %} | ||
</div> | ||
<div class="col-md-8 h-500"> | ||
{% if data.value && data.value != "Medication" %} | ||
<h4> | ||
{{ __("Medication Details") }} | ||
</h4> | ||
<div style="padding-top: 10px;"> | ||
<p>Class : {{ data.medication_class ? data.medication_class : "" }}</p> | ||
<p>Strength : {{ data.strength ? data.strength : "" }}</p> | ||
<p>UOM : {{ data.uom ? data.uom : "" }}</p> | ||
</div> | ||
{% endif %} | ||
{% if data.item_code %} | ||
<h4> | ||
{{ __("Description") }} | ||
</h4> | ||
<div style="padding-top: 10px;"> | ||
{{ data.description }} | ||
</div> | ||
{% endif %} | ||
<hr style="margin: 15px -15px;"> | ||
<p> | ||
{% if data.value && data.value != "Medication" %} | ||
<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="/app/medication/{{ data.value }}"> | ||
{{ __("Open Medication {0}", [data.value.bold()]) }}</a> | ||
{% endif %} | ||
{% if data.item_code %} | ||
<a style="margin-right: 7px; margin-bottom: 7px" class="btn btn-default btn-xs" href="/app/item/{{ data.item_code }}"> | ||
{{ __("Open Item {0}", [data.item_code.bold()]) }}</a> | ||
{% endif %} | ||
</p> | ||
</div> | ||
</div> | ||
</div> |
72 changes: 72 additions & 0 deletions
72
healthcare/healthcare/doctype/medication/medication_tree.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
frappe.treeview_settings["Medication"] = { | ||
get_tree_nodes: "healthcare.healthcare.doctype.medication.medication.get_children", | ||
filters: [ | ||
{ | ||
fieldname: "medication", | ||
fieldtype: "Link", | ||
options: "Medication", | ||
label: __("Medication"), | ||
}, | ||
], | ||
title: "Medication", | ||
breadcrumb: "Healthcare", | ||
disable_add_node: true, | ||
root_label: "Medication", //fieldname from filters | ||
get_tree_root: false, | ||
show_expand_all: false, | ||
get_label: function (node) { | ||
return node.data.item_code || node.data.value; | ||
}, | ||
onload: function (me) { | ||
var label = frappe.get_route()[0] + "/" + frappe.get_route()[1]; | ||
|
||
if (frappe.pages[label]) { | ||
delete frappe.pages[label]; | ||
} | ||
|
||
var filter = me.opts.filters[0]; | ||
if (frappe.route_options && frappe.route_options[filter.fieldname]) { | ||
var val = frappe.route_options[filter.fieldname]; | ||
delete frappe.route_options[filter.fieldname]; | ||
filter.default = ""; | ||
me.args[filter.fieldname] = val; | ||
me.root_label = val; | ||
me.page.set_title(val); | ||
} | ||
me.make_tree(); | ||
}, | ||
toolbar: [ | ||
{ toggle_btn: true }, | ||
{ | ||
label: __("Edit"), | ||
condition: function (node) { | ||
return node.expandable; | ||
}, | ||
click: function (node) { | ||
frappe.set_route("Form", "Medication", node.data.value); | ||
}, | ||
}, | ||
], | ||
menu_items: [ | ||
{ | ||
label: __("New Medication"), | ||
action: function () { | ||
frappe.new_doc("Medication", true); | ||
}, | ||
condition: 'frappe.boot.user.can_create.indexOf("Medication") !== -1', | ||
}, | ||
], | ||
onrender: function (node) { | ||
if (node.is_root && node.data.value != "Medication") { | ||
frappe.model.with_doc("Medication", node.data.value, function () { | ||
var medication = frappe.model.get_doc("Medication", node.data.value); | ||
node.data.image = escape(medication.image) || ""; | ||
node.data.strength = medication.strength || ""; | ||
node.data.item_code = medication.item || ""; | ||
node.data.uom = medication.strength_uom || ""; | ||
node.data.medication_class = medication.medication_class || ""; | ||
}); | ||
} | ||
}, | ||
view_template: "medication_item_preview", | ||
}; |