Skip to content

Commit

Permalink
Merge branch 'develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
akurungadam authored Oct 31, 2023
2 parents a677e0d + 5063a5f commit 48c79af
Show file tree
Hide file tree
Showing 73 changed files with 6,030 additions and 66 deletions.
Empty file.
135 changes: 135 additions & 0 deletions healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright (c) 2023, healthcare and contributors
// For license information, please see license.txt

frappe.ui.form.on("Diagnostic Report", {
refresh: function(frm) {
show_diagnostic_report(frm);
if (!frm.is_new()) {
frm.add_custom_button(__(`Get PDF`), function () {
generate_pdf_with_print_format(frm)
})
}
},
before_save: function(frm) {
if (!frm.doc.is_new() && frm.is_dirty()) {
this.diagnostic_report.save_action("save")
}
},
after_workflow_action: function(frm) {
frappe.call({
"method": "healthcare.healthcare.doctype.diagnostic_report.diagnostic_report.set_observation_status",
args: {
docname: frm.doc.name
},
})
}
});

var show_diagnostic_report = function(frm) {
frm.fields_dict.observation.html("");
if (frm.doc.patient) {
this.diagnostic_report = new healthcare.Diagnostic.DiagnosticReport({
frm: frm,
observation_wrapper: $(frm.fields_dict.observation.wrapper),
create_observation: false,
});
this.diagnostic_report.refresh();
}
}

var generate_pdf_with_print_format = function(frm) {
const letterheads = get_letterhead_options();
const dialog = new frappe.ui.Dialog({
title: __('Print {0}', [frm.doc.name]),
fields: [
{
fieldtype: "Select",
label: __("Letter Head"),
fieldname: "letter_sel",
options: letterheads,
default: letterheads[0],
},
{
fieldtype: "Select",
label: __("Print Format"),
fieldname: "print_sel",
options: frappe.meta.get_print_formats(frm.doc.doctype),
default: frappe.get_meta(frm.doc.doctype).default_print_format,
}
],
});

dialog.set_primary_action(__("Print"), (args) => {
if (!args) return;
const default_print_format = frappe.get_meta(frm.doc.doctype).default_print_format;
const with_letterhead = args.letter_sel == __("No Letterhead") ? 0 : 1;
const print_format = args.print_sel ? args.print_sel : default_print_format;
const doc_names = JSON.stringify([
frm.doc.name,
]);
const letterhead = args.letter_sel;

let pdf_options = JSON.stringify({
"page-size": "A4",
"margin-top": "60mm",
"margin-bottom": "60mm",
"margin-left": "0mm",
"margin-right": "0mm",
});

if (letterhead == __("No Letterhead")) {
pdf_options = JSON.stringify({
"page-size": "A4",
"margin-top": "5mm",
"margin-bottom": "5mm",
"margin-left": "0mm",
"margin-right": "0mm",
});
}

const w = window.open(
"/api/method/frappe.utils.print_format.download_multi_pdf?" +
"doctype=" +
encodeURIComponent(frm.doc.doctype) +
"&name=" +
encodeURIComponent(doc_names) +
"&format=" +
encodeURIComponent(print_format) +
"&no_letterhead=" +
(with_letterhead ? "0" : "1") +
"&letterhead=" +
encodeURIComponent(letterhead) +
"&options=" +
encodeURIComponent(pdf_options)
);

if (!w) {
frappe.msgprint(__("Please enable pop-ups"));
return;
}
});

dialog.show();
}

var get_letterhead_options = () => {
const letterhead_options = [__("No Letterhead")];
frappe.call({
method: "frappe.client.get_list",
args: {
doctype: "Letter Head",
fields: ["name", "is_default"],
filters: { disabled: 0 },
limit_page_length: 0,
},
async: false,
callback(r) {
if (r.message) {
r.message.forEach((letterhead) => {
letterhead_options.push(letterhead.name);
});
}
},
});
return letterhead_options;
};
202 changes: 202 additions & 0 deletions healthcare/healthcare/doctype/diagnostic_report/diagnostic_report.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "naming_series:",
"creation": "2023-06-24 10:55:17.218952",
"default_view": "List",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"patient",
"patient_name",
"gender",
"age",
"practitioner",
"practitioner_name",
"column_break_v6l1",
"company",
"status",
"naming_series",
"ref_doctype",
"docname",
"sales_invoice_status",
"reference_posting_date",
"sample_collection",
"section_break_wtn1",
"observation",
"amended_from",
"title"
],
"fields": [
{
"fieldname": "patient",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Patient",
"options": "Patient",
"read_only": 1
},
{
"fetch_from": "patient.patient_name",
"fieldname": "patient_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Patient Name",
"read_only": 1
},
{
"fieldname": "column_break_v6l1",
"fieldtype": "Column Break"
},
{
"fieldname": "ref_doctype",
"fieldtype": "Link",
"hidden": 1,
"in_standard_filter": 1,
"label": "Ref DocType",
"options": "DocType",
"read_only": 1
},
{
"fieldname": "docname",
"fieldtype": "Dynamic Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Ref DocName",
"options": "ref_doctype",
"read_only": 1
},
{
"fieldname": "section_break_wtn1",
"fieldtype": "Section Break"
},
{
"fieldname": "observation",
"fieldtype": "HTML",
"label": "Observation"
},
{
"fetch_from": "patient.sex",
"fieldname": "gender",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Gender",
"options": "Gender",
"read_only": 1
},
{
"fieldname": "naming_series",
"fieldtype": "Select",
"label": "Series",
"options": "DIA-RPT-.YYYY.-"
},
{
"fieldname": "sample_collection",
"fieldtype": "Link",
"hidden": 1,
"label": "Sample Collection",
"options": "Sample Collection"
},
{
"fieldname": "amended_from",
"fieldtype": "Link",
"label": "Amended From",
"no_copy": 1,
"options": "Diagnostic Report",
"print_hide": 1,
"read_only": 1
},
{
"fieldname": "age",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Age",
"read_only": 1
},
{
"fieldname": "sales_invoice_status",
"fieldtype": "Data",
"label": "Sales Invoice Status",
"read_only": 1
},
{
"fieldname": "practitioner",
"fieldtype": "Link",
"in_list_view": 1,
"in_standard_filter": 1,
"label": "Practitioner",
"options": "Healthcare Practitioner",
"read_only": 1
},
{
"fetch_from": "practitioner.practitioner_name",
"fieldname": "practitioner_name",
"fieldtype": "Data",
"label": "Practitioner Name",
"read_only": 1
},
{
"fieldname": "company",
"fieldtype": "Link",
"in_standard_filter": 1,
"label": "Company",
"options": "Company",
"read_only": 1
},
{
"fieldname": "title",
"fieldtype": "Data",
"hidden": 1,
"label": "Title",
"read_only": 1
},
{
"fieldname": "reference_posting_date",
"fieldtype": "Date",
"label": "Reference Posting Date",
"read_only": 1
},
{
"allow_on_submit": 1,
"fieldname": "status",
"fieldtype": "Select",
"label": "Status",
"options": "Open\nPending Review\nPartially Approved\nApproved\nDisapproved",
"read_only": 1
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-10-16 17:53:14.702170",
"modified_by": "Administrator",
"module": "Healthcare",
"name": "Diagnostic Report",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [
{
"color": "Orange",
"title": "Open"
}
],
"title_field": "title",
"track_changes": 1
}
Loading

0 comments on commit 48c79af

Please sign in to comment.