Skip to content

Commit

Permalink
fix: Sample Collection - move create observation function to long queue
Browse files Browse the repository at this point in the history
  • Loading branch information
akashkrishna619 committed Dec 15, 2023
1 parent f0e5ca5 commit 997d942
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
// For license information, please see license.txt

frappe.ui.form.on('Sample Collection', {
onload: function(frm) {
frappe.realtime.on("observation_creation_progress", (status) => {
if (status == "Completed") {
frm.reload_doc();
frappe.dom.unfreeze();
}
})
},
refresh: function(frm) {
frm.fields_dict.observation_sample_collection.grid.add_custom_button(__("Mark Collected"), () => {
selected_child = frm.fields_dict.observation_sample_collection.grid.get_selected_children()
if (selected_child.length > 0) {
frappe.confirm(__("Are you sure you want to mark selected samples as Collected"), function () {
frappe.dom.freeze(__('Creating Observations! Please Wait...'));
frappe.call({
"method": "healthcare.healthcare.doctype.sample_collection.sample_collection.create_observation",
args: {
Expand Down Expand Up @@ -224,6 +233,7 @@ frappe.ui.form.on("Observation Sample Collection", {
let selected_row = d.fields_dict.items.grid.get_selected_children();
if (selected_row.length > 0) {
frappe.confirm(__("Are you sure you want to mark selected samples as Collected"), function () {
frappe.dom.freeze(__('Creating Observations! Please Wait...'));
frappe.call({
"method": "healthcare.healthcare.doctype.sample_collection.sample_collection.create_observation",
args: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def validate(self):

@frappe.whitelist()
def create_observation(selected, sample_collection, component_observations=None, child_name=None):
frappe.enqueue(
"healthcare.healthcare.doctype.sample_collection.sample_collection.insert_observation",
selected=selected,
sample_collection=sample_collection,
component_observations=component_observations,
child_name=child_name,
queue="long",
timeout=3600,
)


def insert_observation(selected, sample_collection, component_observations=None, child_name=None):
sample_col_doc = frappe.db.get_value(
"Sample Collection",
sample_collection,
Expand Down Expand Up @@ -177,6 +189,13 @@ def create_observation(selected, sample_collection, component_observations=None,

frappe.db.set_value("Sample Collection", sample_collection, "status", set_status)

frappe.publish_realtime(
event="observation_creation_progress",
message="Completed",
doctype="Sample Collection",
docname=sample_collection,
)


def create_specimen(patient, selected, component_observations):
groups = {}
Expand Down

0 comments on commit 997d942

Please sign in to comment.