From f4e7bd44b8903f9392c97c92e304e6c5e0ade654 Mon Sep 17 00:00:00 2001 From: pgwanz Date: Fri, 9 Oct 2015 13:35:52 +0100 Subject: [PATCH 1/5] feature/OE-5667 Changed the popup to be in line with other OE popups --- assets/js/defaultprescription.js | 86 +++++++++++++++++++++++++++++++- 1 file changed, 85 insertions(+), 1 deletion(-) diff --git a/assets/js/defaultprescription.js b/assets/js/defaultprescription.js index c3c22d5..00ea49e 100644 --- a/assets/js/defaultprescription.js +++ b/assets/js/defaultprescription.js @@ -103,7 +103,7 @@ $('#prescription_items').delegate('a.taperItem:not(.processing)', 'click', funct // Insert taper row var odd_even = (row.hasClass('odd')) ? 'odd' : 'even'; var new_row = $(''); - new_row.append($('then'), $('').append(dose_input), $(''), $('').append(frequency_input), $('').append(duration_input), $('Remove')); + new_row.append($('then'), $('').append(dose_input), $(''), $('').append(frequency_input), $('').append(duration_input), $('Remove')); last_row.after(new_row); return false; @@ -258,3 +258,87 @@ function getNextKey() { return (last_item.attr('data-key')) ? parseInt(last_item.attr('data-key')) + 1 : 0; } + +// Check for existing prescriptions for today - warn if creating only +$(document).ready(function() { + if(window.location.href.indexOf("/update/") > -1) return; + + var today = $.datepicker.formatDate('dd-M-yy', new Date()); + var show_warning = false; + var ol_list = $("body").find("ol.events"); + var prescription_count = 0; + ol_list.each(function(idx, ol) + { + var li_list = $(ol).find("li"); + li_list.each(function(idx, li) + { + + if($(li).html().indexOf("OphDrPrescription/default/view") > 0) + { + var p_day = $(li).find("span.day").first().html(); + + if(p_day.length < 2) + { + p_day = '0' + p_day; + } + var prescription_date = + p_day + '-' + + $(li).find("span.mth").first().html() + '-' + + $(li).find("span.yr").html(); + + if (today == prescription_date) + { + show_warning = true; + prescription_count += 1; + + } + } + }) + }) + + if(show_warning) + { + var warning_message = 'Prescriptions have already been created for this patient today.'; + if(prescription_count == 1) + { + warning_message = 'A Prescription has already been created for this patient today.'; + } + + + var dialog_msg = '