Skip to content

Commit

Permalink
feat: Observation, Diagnostic Report (earthians#302)
Browse files Browse the repository at this point in the history
* feat: Observation Template

* fix: Observation Template - reference field changes

* feat: FHIR Value Set

* fix: Medical Department in Observation Template and Sample Type in Lab Test sample

* feat: Observation

* fix: Observation - widget

* feat: color coding for lab test sample
option to set color in Lab Test Sample
option to override color in Observation Template

* fix: Observation Reference - field changes

* fix: observation Reference - make each row for a type

* fix: Observation Template - billable item

* fix: Observation Template - table multiselect to table

* fix: fhir value set - quick entry

* fix: Sample Collection - on invoicing and from encounter

* fix: Observation - set result select options

* fix: Sample Collection - create specimen on collection

* fix: Diagnostic Report - widget

* fix: Diagnostic Report - widget change

* fix: Observation Creation from sales invoice minor fix

* fix: fix: Diagnostic Report - add remarks in widget

* fix: Diagnostic Report widget - select input field, input text field

* fix: Insert Diagnostic Report on Sample Collection after insert
Diagnostic Report widget - remarks addition issue

* fix: Sample Collection - change status Completed to Collected

* fix: Observation Template - sample collection required check

* fix: Diagnostic Report widget - order_by creation

* fix: Sample Collection - order components by idx

* fix: Observation Template - Sample Collection required check change

* fix: Sample Colleciton , Observation Component - field changes

* fix: Diagnostic Report - widget remark div adaptive color

* fix: age range fields not showing in ref ranges table
defaul All to applies to field

* fix: validate if all samples are marked as collected

* fix: confirm before Mark as Collected
add referring practitioner field
show sampel details only if ob samples are not present

* fix: sample collect listview fields

* fix: add patient age to diagnostic report

* fix: Observation Template
- options for boolean result, validate number of options
Observation
- set options for boolean result
- reorder fields, fix display depends on
- add medical department, company
- set observation category, description from observation template, set status, time of result
- rename field remarks to note
- linter issues

* refactor: rename field sample_id to specimen

* fix: remove height for observation note

* fix: Create Sample Collection/Observation on Invoice Submit

* fix: Diagnostic Report widget background-color for has_component

* fix: set invoice status in Diagnostic Report and Observation

* fix: Diagnostic Report - change age field from data to int

* fix: Observation - add method field and fetch from Template

* fix: Observation - add relevant reference from observation template

* fix: Diagnostic Report Widget - add observation_idx field to have order same as in grouped template

* fix: wrong parameter, specimen status and time fetch to observation

* fix: Observation Widget - select result input icon

* fix: Observation Widget - input text field size to normal

* fix: Observation Widget - zero coming in result as previous fields were float

* fix: Observation Widget - validate non numeric input

* fix: add Service Unit, Practitioner and Department custom field in Sales Invoice Item

* fix: Observation Widget - validate non numeric input - issue fix

* fix: Diagnostic Report - set practitioner from Sales Invoice

* fix: Diagnostic Report widget - set specimen link, change layout, set time references

* fix: Speciment - naming with yymmdd#####

* fix: Diagnostic Report Widget - background color and field visibility issue

* fix: Observation - validate numerical value except <>

* fix: Diagnostic Report - widget change - note button to above and text field 100%

* fix: Diagnostic Report - add print data to jenv

* fix: Diagnostic Report - add company field

* fix: Diagnostic Report - Print format design change

* fix: Diagnostic Report - widget reference range change

* fix: Diagnostic Report - non numeric validation include decimal

* fix: set list view fieds, filters
set title for Diagnostic Report

* feat: add abbr to observation template
validate abbr
abbr applicable only if not has_component and category is Laboratory

* fix: interpretation template for imaging observation templates

* fix: patient link, sample type in specimen

* fix: calculate age method in patient - set in Diagnostic Report and Observation

* fix: Sample Type in Specimen

* fix: ignore permission for Diagnostic Report creation

* fix: age issue in observation reference

* fix: Diagnostic Report - user can create

* fix: Diagnostic Report widget - field missing issue

* fix: remove unused patches

* fix: Diagnostic Report Widget - Change in reference fetching
change in saving result
Imaging included in Observation Template

* fix: Imaging in Diagnostic Report Widget

* fix: Observation Template - create item and rate on checking is_billable

* fix: Observation Template - make permitted_data_type not reqd if has_component is checked

* fix: Patient Age - dob missing issue

* fix: track changes in doctypes

* fix: Diagnostic Report - move widget loading to refresh

* fix: make observation submittable, allow import
remove unsued variable, imports

* fix: fetch observationr reference if conditions not set

* fix: reference range text bug, string concat twice

* fix: Observation - add fields from Observation Template to Observation

* fix: Sample Collection - freeze message on marking collected

* fix: Observation Template - show unit for result type Text

* fix: Specimen - generate barcode

* fix: Sample Collection - specimen creation duplicate issue

* fix: Observation Template - diagnosis conditions

* fix: Inpatient Record - remove encounter with appointment reference from pending services on dicharge

* fix: Diagnostic Report Widget - result text parapgraph rendering issue

* fix: Observation - setting result time issue from widget

* fix: Diagnostic Report widget - make input field readonly if submitted or cancelled

* fix: Diagnostic Report Widget - change WIP

* fix: Get Observation query - include approved status for Diagnostic Print format

* fix: Diagnostic Report - submit observations on approving

* fix: Diagnostic Report - include imaging in widget
result missing issue

* fix: Diagnostic Report Widget - make text non mandatory in dialog

* fix: Diagnostic Report - grouped action issue

* fix: pass Referring Practitioner from invoice to Observation and Sample Collection

* fix: Widget - add static to dialog to restrict hiding on touch

* fix: Issue - diagnostic report gets created for normal Sales Invoices

* fix: Issue - link sample collection in Diagnostic Report

* fix: Observation - posting date and status readonly depends

* fix: Sample Collection - status color in list view

* fix: Sample Collection - set child table status Collected - Partly Collected

* fix: Diagnostic Report  - set status approved from observation

* fix: Diagnostic Report Widget approve btn label change

* fix: Service Request - sample collection creation - observation template issue

* fix: Service Request - create observation and sample collection from service request

* fix: Observation, Sample Collection for patient in Sales Invoice child table

* fix: Diagnostic Report creation issue on Sales Invoice Submit

* fix: Observation - ignore_permission on creation

* fix: Diagnostic Report - up, down, enter key input field navigation

* fix: Create Observation and Sample Collection - from Sales Invoice for Service Request

* fix: Create Observation and Sample Collection - from Service Reqeust

* fix: Diagnostic Report - fetch with Encounter reference

* fix: Diagnostic Report Default Print Format
Specimen barcode print format
Observation minor fix

* fix: Observation Template - remove Item Group mandatory

* fix: Observation Prescription table in Patient Encounter
Direct Invoicing of Observation

* fix: create_observation_on_si_submit check in Healthcare Settings

* test: Observation, Observation Template

* fix: Treatment Plan Template - include Observation

* fix: ci and linter errors

* refactor: code cleanup, optimisation

---------

Co-authored-by: Anoop Kurungadam <anoop@earthianslive.com>
Co-authored-by: Sajin SR <sajin@earthianslive.com>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent 5e88e4e commit 59f8be4
Show file tree
Hide file tree
Showing 71 changed files with 6,003 additions and 64 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 59f8be4

Please sign in to comment.