incremented database counter for prior commit and removed trailing whitespacing
[openemr.git] / interface / forms / eye_mag / js / eye_base.php
blobdf128f8fa0b8dbca205d7bac2c2d5baeb8e17fd0
1 <?php
3 /**
4 * forms/eye_mag/js/eye_base.php
6 * JS Functions for eye_mag form(s), built with php features for run-time options and translations
8 * Copyright (C) 2016 Raymond Magauran <magauran@MedFetch.com>
10 * LICENSE: This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as
12 * published by the Free Software Foundation, either version 3 of the
13 * License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 * @package OpenEMR
24 * @author Ray Magauran <magauran@MedFetch.com>
25 * @link http://www.open-emr.org
29 include_once("../../../globals.php");
30 include_once("$srcdir/htmlspecialchars.inc.php");
31 include_once("$srcdir/acl.inc");
32 include_once("$srcdir/api.inc");
33 include_once("$srcdir/forms.inc");
34 include_once("$srcdir/patient.inc");
36 $providerID = $_REQUEST['providerID'];
39 var prior_field;
40 var prior_text;
41 var response = [];
42 var update_chart;
43 var obj= [];
44 var IMP_order = [];
45 var CODING_items=[];
46 var CPT_92060='';
47 var IMP_target ="0";
48 var detail_reached_exam ='0';
49 var detail_reached_HPI ='0';
50 var chronic_reached_HPI ='0';
51 //Coding Engine Defaults
52 var Code_group="Eyes";//options are Eyes - anything else and Coding Engine prefers E&M Codes
53 var digit_2="2"; //Eye Code
54 var digit_4="1"; //Established
55 var digit_5="4"; //Level 4
56 var visit_code;
57 var Code_new_est;
58 var config_byday;
59 var $root = $('html, body');
60 var scroll;
63 * Functions to add a quick pick selection to the correct fields on the form.
65 function fill_QP_2fields(PEZONE, ODOSOU, LOCATION_text, selection, fill_action, Code_to_process) {
66 var prefix = document.getElementById(PEZONE+'_prefix').value;
67 if (prefix > '' && prefix !='off') {prefix = prefix + " ";}
68 if ((prefix =='off')||(LOCATION_text =='')) { prefix=''; }
69 var saved_prefix = prefix;
70 if (ODOSOU =="OU") {
71 fill_QP_field(PEZONE, "OD", LOCATION_text, selection, fill_action, Code_to_process);
72 fill_QP_field(PEZONE, "OS", LOCATION_text, selection, fill_action, Code_to_process,saved_prefix);
73 } else if (ODOSOU =="B") {
74 fill_QP_field(PEZONE, "R", LOCATION_text, selection, fill_action, Code_to_process);
75 fill_QP_field(PEZONE, "L", LOCATION_text, selection, fill_action, Code_to_process,saved_prefix);
78 function fill_QP_field(PEZONE, ODOSOU, LOCATION_text, selection, fill_action, Code_to_process,saved_prefix) {
79 if (ODOSOU > '') {
80 var FIELDID = ODOSOU + LOCATION_text;
81 } else {
82 var FIELDID = document.getElementById(PEZONE+'_'+ODOSOU).value + LOCATION_text;
84 var bgcolor = $("#" +FIELDID).css("background-color");
86 if (saved_prefix) {
87 var prefix = saved_prefix;
88 } else {
89 var prefix = document.getElementById(PEZONE+'_prefix').value;
92 var Fvalue = document.getElementById(FIELDID).value;
93 if (prefix > '' && prefix !='off') {prefix = prefix + " ";}
94 if (prefix =='off') { prefix=''; }
95 if (fill_action =="REPLACE") {
96 $("#" +FIELDID).val(prefix +selection);
97 $("#" +FIELDID).css("background-color","#F0F8FF");
98 } else if (fill_action =="APPEND") {
99 $("#" +FIELDID).val(Fvalue+selection).css("background-color","#F0F8FF");
100 } else {
101 if (($("#" +FIELDID).css("background-color")=="rgb(245, 245, 220)") || (Fvalue =='')) {
102 //rgb(245, 245, 220) is beige - the field is untouched
103 $("#" +FIELDID).val(prefix+selection).css("background-color","#F0F8FF");
104 } else if (Fvalue.match(/x$/)) {
105 $("#" +FIELDID).val(Fvalue+selection).css("background-color","#F0F8FF");
106 } else {
107 if (Fvalue >'') prefix = ", "+prefix;
108 $("#" +FIELDID).val(Fvalue + prefix +selection).css("background-color","#F0F8FF");
111 submit_form(FIELDID);
112 $('#'+PEZONE+'_prefix').val('off').trigger('change');
116 * This is the core function of the form.
117 * It submits the data in the background via ajax.
118 * It is the reason we don't use a submit button.
119 * It is called often, perhaps too often for some installs because it uses bandwidth.
120 * It needs to be keenly looked at by developers as it will affect scalability.
121 * It return either "Code 400" or positive hits from the clinical data passed through the Coding engine.
122 * It ensures ownership of the form or provides background updates to READ-ONLY instances of the form.
123 * It doesn't unlock a form to change ownership/provide write privileges. This is done via the unlock() function.
125 function submit_form(action) {
126 var url = "../../forms/eye_mag/save.php?sub=1&mode=update&id=" + $("#form_id").val();
127 if ($("#COPY_SECTION").value == "READONLY") return;
128 formData = $("form#eye_mag").serialize();
129 $("#menustate").val('0');
130 top.restoreSession();
131 $.ajax({
132 type : 'POST',
133 url : url,
134 data : formData //, dataType: "json"
135 }).done(function(result) {
136 if (result == 'Code 400') {
137 code_400(); //Not the owner: read-only mode or take ownership
138 } else {
139 // ACTIVE chart.
140 // Coding engine returns any positive Clinical findings.
141 //List these findings in the IMP_PLAN Builder
142 populate_form(result);
148 * This function alerts the user that they have lost write privileges to another user.
149 * The form is locked (fields disabled) and they enter the READ-ONLY mode.
150 * In READ-ONLY mode the form is refreshed every 15 seconds showing changes made by the user with write privileges.
152 function code_400() {
153 //User lost ownership. Just watching now...
154 //now we should get every variable and update the form, every 15 seconds...
155 $("#active_flag").html(" READ-ONLY ");
156 toggle_active_flags("off");
157 alert("Another user has taken control of this form.\rEntering READ-ONLY mode.");
158 update_READONLY();
159 this_form_id = $("#form_id").val();
160 $("#COPY_SECTION").val("READONLY");
161 update_chart = setInterval(function() {
162 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
163 update_READONLY();
164 }, 15000);
168 * Convert the DB datetime values into date objects in JS
170 * "You should parse them to get a Date object, for that format I always use the following function:
171 * http://stackoverflow.com/questions/2627650/why-javascript-gettime-is-not-a-function"
174 function parseDate(input) {
175 var parts = input.match(/(\d+)/g);
176 // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
177 return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
180 * Function to check locked state
182 function check_lock(modify) {
183 var locked = $("#LOCKED").val();
184 var locked_by = $("#LOCKEDBY").val();
185 if ($("#LOCKEDDATE").val() > '') {
186 var locked_date = parseDate($("#LOCKEDDATE").val());
187 } else{
188 var locked_date= new Date('2000-01-01');
190 var uniqueID = $('#uniqueID').val();
192 var url = "../../forms/eye_mag/save.php?mode=update&id=" + $("#form_id").val();
193 clearInterval(update_chart);
194 //if the form was locked > 1 hour ago, tag we are it - we should auto-get ownership
195 //if not we have to physically take it.
196 var now =new Date();
197 now_time = now.getTime();
198 var interval = locked_date.setTime(locked_date.getTime() + (60*60*1000));//locked timestamp + 1 hour
199 if (modify=='1') {
200 if ($("#chart_status").val() == "on") {
201 unlock();
202 toggle_active_flags("off");
203 update_chart = setInterval(function() {
204 if ($("#chart_status").val() == "on") { clearInterval(update_chart);}
205 update_READONLY();
206 }, 15000);
207 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
208 } else {
209 top.restoreSession();
210 $.ajax({
211 type : 'POST',
212 url : url,
213 data : {
214 'acquire_lock' : '1',
215 'uniqueID' : uniqueID,
216 'form_id' : $("#form_id").val(),
217 'locked_by' : $("#LOCKEDBY").val()
219 }).done(function(d) {
220 $("#LOCKEDBY").val(uniqueID);
221 toggle_active_flags("on");
222 clearInterval(update_chart);
225 } else if (locked =='1' && (interval < now_time)) { //it was locked more than an hour ago, take ownership quietly
226 top.restoreSession();
227 $.ajax({
228 type : 'POST',
229 url : url,
230 data : {
231 'acquire_lock' : '1',
232 'uniqueID' : uniqueID, //this user is becoming the new owner
233 'locked_by' : locked_by, //this is the old owner
234 'form_id' : $("#form_id").val()
236 }).done(function(d) {
237 $("#LOCKEDBY").val(uniqueID);
238 $("#LOCKEDDATE").val(d);
239 toggle_active_flags("on");
242 } else if (locked =='1' && locked_by >'' && (uniqueID != locked_by)) {
243 //form is locked by someone else, less than an hour ago...
244 $("#active_flag").html(" READ-ONLY ");
245 if (confirm('\tLOCKED by another user:\t\n\tSelect OK to take ownership or\t\n\tCANCEL to enter READ-ONLY mode.\t')) {
246 top.restoreSession();
247 $.ajax({
248 type : 'POST',
249 url : url,
250 data : {
251 'acquire_lock' : '1',
252 'uniqueID' : uniqueID, //this user is becoming the new owner
253 'locked_by' : locked_by, //this is the old owner
254 'form_id' : $("#form_id").val()
256 }).done(function(d) {
257 $("#LOCKEDBY").val(uniqueID);
258 toggle_active_flags("on");
261 } else {
262 //User selected "Cancel" -- ie. doesn't want ownership. Just watching...
263 toggle_active_flags("off");
264 update_chart = setInterval(function() {
265 $("#COPY_SECTION").trigger('change');
266 if ($("#chart_status").val() == "on") { clearInterval(update_chart);}
267 update_READONLY();
268 }, 15000);
269 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
275 * Function to save a canvas by zone
277 function submit_canvas(zone) {
278 var id_here = document.getElementById('myCanvas_'+zone);
279 var dataURL = id_here.toDataURL('image/jpeg');
280 top.restoreSession();
281 $.ajax({
282 type: "POST",
283 url: "../../forms/eye_mag/save.php?canvas="+zone+"&id="+$("#form_id").val(),
284 data: {
285 imgBase64 : dataURL, //this contains the canvas + new strokes, the sketch.js foreground
286 'zone' : zone,
287 'visit_date' : $("#visit_date").val(),
288 'encounter' : $("#encounter").val(),
289 'pid' : $("#pid").val()
292 }).done(function(o) {
296 * Function to update the user's preferences
298 function update_PREFS() {
299 var url = "../../forms/eye_mag/save.php";
300 var formData = {
301 'AJAX_PREFS' : "1",
302 'PREFS_VA' : $('#PREFS_VA').val(),
303 'PREFS_W' : $('#PREFS_W').val(),
304 'PREFS_MR' : $('#PREFS_MR').val(),
305 'PREFS_W_width' : $('#PREFS_W_width').val(),
306 'PREFS_MR_width' : $('#PREFS_MR_width').val(),
307 'PREFS_CR' : $('#PREFS_CR').val(),
308 'PREFS_CTL' : $('#PREFS_CTL').val(),
309 'PREFS_ADDITIONAL' : $('#PREFS_ADDITIONAL').val(),
310 'PREFS_VAX' : $('#PREFS_VAX').val(),
311 'PREFS_IOP' : $('#PREFS_IOP').val(),
312 'PREFS_CLINICAL' : $('#PREFS_CLINICAL').val(),
313 'PREFS_EXAM' : $('#PREFS_EXAM').val(),
314 'PREFS_CYL' : $('#PREFS_CYL').val(),
315 'PREFS_EXT_VIEW' : $('#PREFS_EXT_VIEW').val(),
316 'PREFS_ANTSEG_VIEW' : $('#PREFS_ANTSEG_VIEW').val(),
317 'PREFS_RETINA_VIEW' : $('#PREFS_RETINA_VIEW').val(),
318 'PREFS_NEURO_VIEW' : $('#PREFS_NEURO_VIEW').val(),
319 'PREFS_ACT_VIEW' : $('#PREFS_ACT_VIEW').val(),
320 'PREFS_ACT_SHOW' : $('#PREFS_ACT_SHOW').val(),
321 'PREFS_HPI_RIGHT' : $('#PREFS_HPI_RIGHT').val(),
322 'PREFS_PMH_RIGHT' : $('#PREFS_PMH_RIGHT').val(),
323 'PREFS_EXT_RIGHT' : $('#PREFS_EXT_RIGHT').val(),
324 'PREFS_ANTSEG_RIGHT' : $('#PREFS_ANTSEG_RIGHT').val(),
325 'PREFS_RETINA_RIGHT' : $('#PREFS_RETINA_RIGHT').val(),
326 'PREFS_NEURO_RIGHT' : $('#PREFS_NEURO_RIGHT').val(),
327 'PREFS_PANEL_RIGHT' : $('#PREFS_PANEL_RIGHT').val(),
328 'PREFS_IMPPLAN_RIGHT' : $('#PREFS_IMPPLAN_DRAW').val(),
329 'PREFS_KB' : $('#PREFS_KB').val(),
330 'PREFS_TOOLTIPS' : $('#PREFS_TOOLTIPS').val()
332 top.restoreSession();
333 $.ajax({
334 type : 'POST',
335 url : url,
336 data : formData
340 * Function to unlock the form - remove temporary lock at DB level.
342 function unlock() {
343 var url = "../../forms/eye_mag/save.php?mode=update&id=" + $("#form_id").val();
344 var formData = {
345 'action' : "unlock",
346 'unlock' : "1",
347 'encounter' : $('#encounter').val(),
348 'pid' : $('#pid').val(),
349 'LOCKEDBY' : $('#LOCKEDBY').val(),
350 'form_id' : $("#form_id").val()
352 top.restoreSession();
353 $.ajax({
354 type : 'POST',
355 url : url,
356 data : formData }).done(function(o) {
357 $("#warning").removeClass("nodisplay");
358 $('#LOCKEDBY').val('');
359 $('#chart_status').val('off');
363 * Function to fax this visit report to someone.
365 function create_task(to_id,task,to_type) {
366 var url = "../../forms/eye_mag/taskman.php";
367 var formData = {
368 'action' : "make_task",
369 'from_id' : '<?php echo $providerID; ?>',
370 'to_id' : to_id,
371 'pid' : $('#pid').val(),
372 'doc_type' : task,
373 'enc' : $('#encounter').val(),
374 'form_id' : $('#form_id').val()
376 top.restoreSession();
377 $.ajax({
378 type : 'POST',
379 url : url,
380 data : formData
381 }).done(function(result) {
382 //OPTIONS to consider: we could return a status code from the server.
383 //maybe 1 = no doc, 2= doc made and queued, 3= sent
384 //maybe this is a checkbox. Check to create the task, uncheck to delete it.
385 //if the task is completed, checkbox is checked and disabled?
386 //return doc_id and display it in html for id='status_'+task+'_'+to_type
387 obj = JSON.parse(result);
388 if (obj.DOC_link) {
389 $('#status_'+task+'_'+to_type).html(obj.DOC_link);
391 if (obj.comments) alert(obj.comments);
392 //maybe change an icon to sent? Think.
398 * START OF PMSFH FUNCTIONS
400 function alter_issue2(issue_number,issue_type,index) {
401 if (!obj.PMSFH) { refresh_page(); }
402 if (typeof obj.PMSFH == "undefined") { submit_form(); }
403 var here = obj.PMSFH[issue_type][index];
404 window.frames[0].frameElement.contentWindow.newtype(issue_type);
405 if (issue_type !='SOCH' && issue_type !='FH' && issue_type !='ROS') {
406 $('iframe').contents().find('#delete_button').removeClass('nodisplay');
407 } else {
408 $('iframe').contents().find('#delete_button').addClass('nodisplay');
410 $('iframe').contents().find('#issue' ).val(issue_number);
411 if (typeof here !== "undefined") {
412 $('iframe').contents().find('#form_title' ).val(here.title);
413 $('iframe').contents().find('#form_diagnosis' ).val(here.diagnosis);
414 $('iframe').contents().find('#form_begin' ).val(here.begdate);
415 $('iframe').contents().find('#form_end' ).val(here.enddate);
416 $('iframe').contents().find('#form_reaction' ).val(here.reaction);
417 $('iframe').contents().find('#form_referredby' ).val(here.referredby);
418 $('iframe').contents().find('#form_classification' ).val(here.classification);
419 $('iframe').contents().find('#form_occur' ).val(here.occurrence);
420 $('iframe').contents().find('#form_comments' ).val(here.comments);
421 $('iframe').contents().find('#form_outcome' ).val(here.outcome);
422 $('iframe').contents().find('#form_destination' ).val(here.destination);
423 if (here.row_subtype =='eye') {
424 $('iframe').contents().find('#form_eye_subtype' ).prop("checked","checked");
425 } else {
426 $('iframe').contents().find('#form_eye_subtype' ).prop("checked",false);
428 if (here.enddate > '') {
429 $('iframe').contents().find('#form_active' ).prop("checked",true);
430 $('iframe').contents().find('#delete_button').addClass("nodisplay");
431 } else {
432 $('iframe').contents().find('#form_active' ).prop("checked",false);
435 var location = $("#PMH_left").offset().top -55;
436 $root.animate({scrollTop: location }, "slow");
438 function showArray(arr) {
439 var tS = new String();
440 for (var iI in arr) {
441 tS += "Index "+iI+", Type "+(typeof arr[iI])+", Value "+arr[iI]+"\n";
443 return tS;
447 * Function to delete an issue from server via ajax
448 * Ajax returns json obj.PMSFH
449 * Refresh displays (right_panel and QP_PMH panel)
451 function delete_issue2(issue_number,PMSFH_type) {
452 $('#form#theform issue').val(issue_number);
453 $('iframe').contents().find('#issue').val(issue_number);
454 $('form#theform form_type');
456 var url = '../../forms/eye_mag/a_issue.php';
457 var formData = {
458 'a_issue' : issue_number,
459 'deletion' : '1',
460 'PMSFH' : '1'
462 top.restoreSession();
463 $.ajax({
464 type : 'POST',
465 url : url,
466 data : formData,
467 success:(function(result) {
468 populate_PMSFH(result);
471 show_QP();
472 return false;
476 * Function to save the PMSFH array to the server.
477 * This can be removed in the future - save for now
479 function submit_PMSFH() {
480 var url = "../../forms/eye_mag/save.php?PMSFH_save=1&mode=update";
481 formData = $("[id^=f]").serialize();
482 var f = document.forms[0];
483 top.restoreSession();
484 $.ajax({
485 type : 'POST',
486 url : url,
487 data : formData
488 }).done(function(result){
489 f.form_title.value = '';
490 f.form_diagnosis.value = '';
491 f.form_begin.value ='';
492 f.form_end.value ='';
493 f.form_referredby.value ='';
494 f.form_reaction.value ='';
495 f.form_classification.value ='';
496 f.form_occur.value='';
497 f.form_comments.value ='';
498 f.form_outcome.value ='';
499 f.form_destination.value ='';
500 f.issue.value ='';
501 populate_form(result);
502 });}
505 * END OF PMSFH FUNCTIONS
509 * Function to refresh the issues, the panels and the Impression/coding areas.
511 function refresh_page() {
512 var url = '../../forms/eye_mag/view.php?display=PMSFH';
513 var formData = {
514 'action' : "refresh",
515 'id' : $('#form_id').val(),
516 'encounter' : $('#encounter').val(),
517 'pid' : $('#pid').val(),
518 'refresh' : 'page'
520 top.restoreSession();
521 $.ajax({
522 type : 'POST',
523 url : url,
524 data : formData,
525 success:(function(result) {
526 populate_form(result);
529 //Make the height of the panels equal if they grow really large
530 if ($('#PMH_right').height() > $('#PMH_left').height()) {
531 $('#PMH_left').height($('#PMH_right').height());
532 } else { $('#PMH_left').height($('#PMH_right').height()); }
533 return false;
537 * Function to refresh the Glaucoma Flow Sheet.
539 function refresh_GFS() {
540 if (typeof config_byday == "undefined") { return; }
542 var indexToUpdate = '0';
543 $.each(config_byday.data.labels, function(key,value) {
544 if (value == visit_date) {
545 indexToUpdate = key;
549 //var indexToUpdate = config_byday.data.labels.length-1;
550 var ODIOP=0;
551 var OSIOP=0;
552 if ( $('#ODIOPAP').val()) {
553 ODIOP = $('#ODIOPAP').val();
554 } else if ( $('#ODIOPTPN').val()) {
555 ODIOP = $('#ODIOPTPN').val();
558 if ( $('#OSIOPAP').val() >'0') {
559 OSIOP = $('#OSIOPAP').val();
560 } else if ( $('#OSIOPTPN').val() > '0') {
561 OSIOP = $('#OSIOPTPN').val();
564 config_byday.data.datasets[0].data[indexToUpdate] = $('#ODIOPTARGET').val();
565 config_byday.data.datasets[1].data[indexToUpdate] = ODIOP;
566 config_byday.data.datasets[2].data[indexToUpdate] = OSIOP;
567 myLine.update();
569 var time = $('#IOPTIME').val();
570 times = time.match(/^(\d{1,2}):(\d{2})/);
571 if (times[1] < 10) times[1] = "0"+''+times[1];
572 time = times[1]+':'+times[2];
573 //alert("time is "+time);
574 var indexToUpdate2 = '0';
575 $.each(config_byhour.data.labels, function(key,value) {
576 if (value == time) {
577 indexToUpdate2 = key;
580 config_byhour.data.datasets[0].data[indexToUpdate2] = ODIOP;
581 config_byhour.data.datasets[1].data[indexToUpdate2] = OSIOP;
582 myLine2.update();
583 // Update one of the points in the second dataset
584 // myLine.data.datasets[1].data[indexToUpdate].val($('#ODIOPAP').val());
585 //alert(config_byday.data.datasets[1].data[indexToUpdate].val()+' is ending _bydat val');
586 //myLine.update();
587 //ctx2.update();
588 return;
590 this should refresh locally and not go back to the server
591 the only things that would trigger a refresh are
592 a change in IOP
593 change in IOPTARGET
594 change in Eye Meds
595 change in GONIO fields
596 additional tests (VF/OCT) would not affect this in its live format
598 submit_form();
599 var url = '../../forms/eye_mag/view.php?display=GFS';
600 var formData = {
601 'action' : "refresh_GFS",
602 'id' : $('#form_id').val(),
603 'encounter' : $('#encounter').val(),
604 'pid' : $('#pid').val(),
605 'refresh' : 'GFS'
607 top.restoreSession();
608 $.ajax({
609 type : 'POST',
610 url : url,
611 data : formData,
612 success:(function(result) {
613 populate_GFS(result);
619 function populate_GFS(result) {
620 $("#LayerVision_IOP").html(result);
624 * Server returns a json encoding object: obj to update the page
625 * Here we refresh the PMSFH display panels,
626 * Rebuild the Impression/Plan Builder DX lists,
627 * the Impression Plan area
628 * and the CHRONIC fields.
630 function populate_form(result) {
631 obj = JSON.parse(result);
632 $("#QP_PMH").html(obj.PMH_panel);
633 if ($('#PMH_right').height() > $('#PMH_left').height()) {
634 $('#PMH_left').height($('#PMH_right').height());
635 } else { $('#PMH_left').height($('#PMH_right').height()); }
636 $("#right_panel_refresh").html(obj.right_panel);
637 build_IMPPLAN(obj.IMPPLAN_items);
638 build_Chronics(obj);
639 build_DX_list(obj); //build the list of DXs to show in the Impression/Plan Builder
642 * Function to auto-fill CHRONIC fields
643 * To reach a detailed E&M level of documentation the chart
644 * may comment on the status of 3 or more CHRONIC/Inactive problems.
645 * The user can type them into the CHRONIC fields manually, or
646 * we can do it programatically if the user does the following:
647 * 1. documenting a PMH diagnosis in the PMSFH area
648 * 2. listing it as "Chronic"
649 * 3. making a comment about it
650 * With these three steps completed, this build_CHRONIC function displays the changes
651 * in the CHRONIC1-3 textareas, if not already filled in, for today's visit.
652 * On subsequent visits, the CHRONIC1-3 fields are blank, unless the above steps
653 * were performed previously, then they are filled in automatically on loading of the new form.
655 function build_Chronics(obj) {
656 if (typeof obj.PMSFH === "undefined") return;
657 var CHRONICS = obj.PMSFH['CHRONIC'];
658 var chronic_value;
659 var local_comment;
660 var here_already;
661 $.each(CHRONICS, function(key, value) {
662 local_comment = CHRONICS[key].title+" "+CHRONICS[key].diagnosis+"\n"+CHRONICS[key].comments;
663 here_already ='0';
664 for (i=1; i < 4; i++) {
665 chronic_value = $('#CHRONIC'+i).val();
666 if (chronic_value == local_comment) {
667 here_already='1'; //this is here, move to next CHRONICS
668 break;
671 if (here_already !='1') {
672 for (i=1; i < 4; i++) {
673 chronic_value = $('#CHRONIC'+i).val();
674 if (chronic_value == '') { //if the CHRONIC1-3 field is empty, fill it.
675 $('textarea#CHRONIC'+i).val(local_comment);
676 break;
681 return false;
684 * Function to autocreate a PDF of this form as a document linked to this encounter.
685 * Each time it is runs it updates by replacing the encounter's PDF.
686 * This used to be fired often, but it is a server resource beast.
687 * Use it sparingly, and intentionally only.
688 * Currently only invoked via the bootstrap menu: Menu->File->Print/Store PDF
690 function store_PDF() {
691 var url = "../../forms/eye_mag/save.php?mode=update";
692 var formData = {
693 'action' : 'store_PDF',
694 'patient_id' : $('#pid').val(),
695 'pdf' : '1',
696 'printable' : '1',
697 'form_folder' : $('#form_folder').val(),
698 'form_id' : $('#form_id').val(),
699 'encounter' : $('#encounter').val(),
700 'uniqueID' : $('#uniqueID').val()
702 top.restoreSession();
703 $.ajax({
704 type : 'POST',
705 url : url,
706 data : formData
710 /* START Functions related to form VIEW */
712 * Function to blow out the form and display the right side of every section.
714 function show_right() {
715 $("#HPI_1").removeClass("size50").addClass("size100");
716 $("#PMH_1").removeClass("size50").addClass("size100");
717 $("#EXT_1").removeClass("size50").addClass("size100");
718 $("#ANTSEG_1").removeClass("size50").addClass("size100");
719 $("#NEURO_1").removeClass("size50").addClass("size100");
720 $("#RETINA_1").removeClass("size50").addClass("size100");
721 $("#IMPPLAN_1").removeClass("size50").addClass("size100");
722 $("#HPI_right").removeClass('nodisplay');
723 $("#PMH_right").removeClass('nodisplay');
724 $("#EXT_right").removeClass('nodisplay');
725 $("#ANTSEG_right").removeClass('nodisplay');
726 $("#NEURO_right").removeClass('nodisplay');
727 $("#RETINA_right").removeClass('nodisplay');
728 $("#IMPPLAN_right").removeClass('nodisplay');
729 $("#PMH_1").addClass("clear_both");
730 $("#ANTSEG_1").addClass("clear_both");
731 $("#RETINA_1").addClass("clear_both");
732 $("#NEURO_1").addClass("clear_both");
733 $("#IMPPLAN_1").addClass("clear_both");
734 hide_PRIORS();
737 * Function to implode the form and hide the right side of every section.
739 function hide_right() {
740 $("#HPI_1").removeClass("size100").addClass("size50");
741 $("#PMH_1").removeClass("size100").addClass("size50");
742 $("#EXT_1").removeClass("size100").addClass("size50");
743 $("#ANTSEG_1").removeClass("size100").addClass("size50");
744 $("#NEURO_1").removeClass("size100").addClass("size50");
745 $("#RETINA_1").removeClass("size100").addClass("size50");
746 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
747 $("#HPI_right").addClass('nodisplay');
748 $("#PMH_right").addClass('nodisplay');
749 $("#EXT_right").addClass('nodisplay');
750 $("#ANTSEG_right").addClass('nodisplay');
751 $("#NEURO_right").addClass('nodisplay');
752 $("#RETINA_right").addClass('nodisplay');
753 $("#PMH_1").removeClass("clear_both");
754 $("#ANTSEG_1").removeClass("clear_both");
755 $("#RETINA_1").removeClass("clear_both");
756 $("#NEURO_1").removeClass("clear_both");
757 update_PREFS();
760 * Function to explode the form and show the left side of every section.
762 function show_left() {
763 $("#HPI_1").removeClass("size100").addClass("size50");
764 $("#PMH_1").removeClass("size100").addClass("size50");
765 $("#EXT_1").removeClass("size100").addClass("size50");
766 $("#ANTSEG_1").removeClass("size100").addClass("size50");
767 $("#NEURO_1").removeClass("size100").addClass("size50");
768 $("#RETINA_1").removeClass("size100").addClass("size50");
769 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
770 $("#HPI_left").removeClass('nodisplay');
771 $("#PMH_left").removeClass('nodisplay');
772 $("#EXT_left").removeClass('nodisplay');
773 $("#ANTSEG_left").removeClass('nodisplay');
774 $("#RETINA_left").removeClass('nodisplay');
775 $("#NEURO_left").removeClass('nodisplay');
776 $("#IMPPLAN_left").removeClass('nodisplay');
777 $("[name$='_left']").removeClass('nodisplay');
780 * Function to implode the form and hide the left side of every section.
782 function hide_left() {
783 $("#HPI_1").removeClass("size100").addClass("size50");
784 $("#PMH_1").removeClass("size100").addClass("size50");
785 $("#EXT_1").removeClass("size100").addClass("size50");
786 $("#ANTSEG_1").removeClass("size100").addClass("size50");
787 $("#NEURO_1").removeClass("size100").addClass("size50");
788 $("#RETINA_1").removeClass("size100").addClass("size50");
789 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
790 $("#HPI_left").addClass('nodisplay');
791 $("#PMH_left").addClass('nodisplay');
792 $("#EXT_left").addClass('nodisplay');
793 $("#ANTSEG_left").addClass('nodisplay');
794 $("#RETINA_left").addClass('nodisplay');
795 $("#NEURO_left").addClass('nodisplay');
796 $("#IMPPLAN_left").addClass('nodisplay');
797 $("[name $='_left']").addClass('nodisplay');
800 * Function to display only the DRAW panels of every section.
801 * The technical section, between HPI and Clinical section is still viible.
803 function show_DRAW() {
804 hide_QP();
805 hide_TEXT();
806 hide_PRIORS();
807 hide_left();
808 hide_KB();
809 show_right();
811 $("#HPI_right").addClass('canvas');
812 $("#PMH_right").addClass('canvas');
813 $("#EXT_right").addClass('canvas');
814 $("#ANTSEG_right").addClass('canvas');
815 $("#RETINA_right").addClass('canvas');
816 $("#NEURO_right").addClass('canvas');
817 $("#IMPPLAN_right").addClass('canvas');
818 $(".Draw_class").removeClass('nodisplay');
819 if ($("#PREFS_CLINICAL").val() !='1') {
820 $("#PREFS_CLINICAL").val('1');
821 $("#PREFS_EXAM").val('DRAW');
823 update_PREFS();
826 * Function to display only the TEXT panels in every section.
828 function show_TEXT() {
829 $("#PMH_1").removeClass('nodisplay');
830 $("#NEURO_1").removeClass('nodisplay');
831 $("#IMPPLAN_1").removeClass('nodisplay');
832 $(".TEXT_class").removeClass('nodisplay');
833 show_left();
834 hide_right(); //this hides the right half
835 hide_QP();
836 hide_DRAW();
837 hide_PRIORS();
838 if ($("#PREFS_CLINICAL").val() !='1') {
839 // we want to show text_only which are found on left half
840 $("#PREFS_CLINICAL").val('1');
842 $("#PREFS_EXAM").val('TEXT');
843 $("#IMPPLAN_right").addClass('canvas').removeClass('nodisplay');
844 $("#QP_IMPPLAN").removeClass('nodisplay');
845 $("#DRAW_"+zone).addClass('nodisplay');
846 $("#IMPPLAN_1").removeClass('nodisplay');
847 $("#IMPPLAN_left").removeClass('nodisplay');
848 $("#PREFS_IMPPLAN_RIGHT").val('QP');
849 if (!scroll) scrollTo("HPI_left");
850 update_PREFS();
853 * Function to display the PRIORS panels in every right section.
855 function show_PRIORS() {
856 $("#NEURO_sections").removeClass('nodisplay');
857 hide_DRAW();
858 $("#EXT_right").addClass("PRIORS_color");
859 show_TEXT();
860 show_right();
861 hide_QP();
862 $("#QP_HPI").removeClass('nodisplay');
863 $("#QP_PMH").removeClass('nodisplay');
864 $("#HPI_right").addClass('canvas');
865 $("#PMH_right").addClass('canvas');
866 $("#IMPPLAN_right").addClass('canvas');
867 $("#EXT_right").addClass('canvas');
868 $("#ANTSEG_right").addClass('canvas');
869 $("#RETINA_right").addClass('canvas');
870 $("#NEURO_right").addClass('canvas');
871 $(".PRIORS_class").removeClass('nodisplay');
872 if ($("#PREFS_CLINICAL").val() !='1') {
873 // we want to show text_only which are found on left half now that PRIORS are visible.
874 $("#PREFS_CLINICAL").val('1');
876 $("#PREFS_EXAM").val('PRIORS');
877 update_PREFS();
880 * Function to show the Quick Picks panel on the right side of every section.
882 function show_QP() {
883 hide_DRAW();
884 hide_PRIORS();
885 hide_KB();
886 show_TEXT();
887 show_right();
888 show_left();
889 $("#HPI_right").addClass('canvas');
890 $("#PMH_right").addClass('canvas');
891 $("#EXT_right").addClass('canvas');
892 $("#ANTSEG_right").addClass('canvas');
893 $("#RETINA_right").addClass('canvas');
894 $("#NEURO_right").addClass('canvas');
895 $("#IMPPLAN_right").addClass('canvas');
896 $(".QP_class").removeClass('nodisplay');
897 $(".QP_class2").removeClass('nodisplay');
898 $("#PREFS_EXAM").val('QP');
899 update_PREFS();
902 * Function to display only one DRAW panel of one section.
904 function show_DRAW_section(zone) {
905 $("#QP_"+zone).addClass('nodisplay');
906 $("#"+zone+"_1").removeClass('nodisplay');
907 $("#"+zone+"_left").removeClass('nodisplay');
908 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
909 $("#Draw_"+zone).addClass('canvas');
910 $("#Draw_"+zone).removeClass('nodisplay');
911 $("#PREFS_"+zone+"_DRAW").val(1);
912 update_PREFS();
915 * Function to display only one PRIORS panel of one section.
917 function show_PRIORS_section(section,newValue) {
918 var url = "../../forms/eye_mag/save.php?mode=retrieve";
920 var formData = {
921 'PRIORS_query' : "1",
922 'zone' : section,
923 'id_to_show' : newValue,
924 'pid' : $('#pid').val(),
925 'orig_id' : $('#form_id').val()
927 top.restoreSession();
928 $.ajax({
929 type : 'POST',
930 url : url,
931 data : formData,
932 success : function(result) {
933 $("#PRIORS_" + section + "_left_text").html(result);
938 * Function to show one of the Quick Picks section on the right side of its section.
940 function show_QP_section(zone,scroll) {
941 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
942 $("#QP_"+zone).removeClass('nodisplay');
943 $("#DRAW_"+zone).addClass('nodisplay');
944 $("#"+zone+"_1").removeClass('nodisplay');
945 $("#"+zone+"_left").removeClass('nodisplay');
946 $("#PREFS_"+zone+"_RIGHT").val('QP');
947 if (!scroll) scrollTo(zone+"_left");
950 * Function to hide all the DRAW panels of every section.
952 function hide_DRAW() {
953 $(".Draw_class").addClass('nodisplay');
954 hide_right();
955 $("#LayerTechnical_sections").removeClass('nodisplay');
956 $("#REFRACTION_sections").removeClass('nodisplay');
957 $("#PMH_sections").removeClass('nodisplay');
958 $("#HPI_right").addClass('nodisplay');
959 $("#HPI_right").removeClass('canvas');
960 $("#EXT_right").removeClass('canvas');
961 $("#RETINA_right").removeClass('canvas');
962 $("#ANTSEG_right").removeClass('canvas');
965 * Function to hide all the Quick Pick panels of every section.
967 function hide_QP() {
968 $(".QP_class").addClass('nodisplay');
969 $(".QP_class2").addClass('nodisplay');
970 $("[name$='_right']").removeClass('canvas');
973 * Function to hide all the TEXT panels of every section.
975 function hide_TEXT() {
976 $(".TEXT_class").addClass('nodisplay');
979 * Function to hide all the PIORS panels of every section.
981 function hide_PRIORS() {
982 $("#EXT_right").removeClass("PRIORS_color");
983 $("#PRIORS_EXT_left_text").addClass('nodisplay');
984 $("#PRIORS_ANTSEG_left_text").addClass('nodisplay');
985 $("#PRIORS_RETINA_left_text").addClass('nodisplay');
986 $("#PRIORS_NEURO_left_text").addClass('nodisplay');
987 $(".PRIORS_class").addClass('nodisplay');
990 * Function to hide Shorthand/Keyboard Entry panel.
992 function hide_KB() {
993 $('.kb').addClass('nodisplay');
994 $('.kb_off').removeClass('nodisplay');
995 if ($("#PREFS_KB").val() > 0) {
996 $("#PREFS_KB").val('0');
1000 * Function to show the Shorthand/Keyboard panel.
1002 function show_KB() {
1003 $('.kb').toggleClass('nodisplay');
1004 $('.kb_off').toggleClass('nodisplay');
1005 if ($('#PREFS_EXAM').val() == 'DRAW') {
1006 show_TEXT();
1009 if ($("#PREFS_KB").val() > 0) {
1010 $("#PREFS_KB").val('0');
1011 } else {
1012 $("#PREFS_KB").val('1');
1014 update_PREFS();
1016 /* END Functions related to form VIEW */
1019 * Function contains menu commands specific to this form.
1021 function menu_select(zone,che) {
1022 $("#menu_"+zone).addClass('active');
1023 if (zone =='PREFERENCES') {
1024 window.parent.RTop.document.location.href = base+"interface/super/edit_globals.php";
1025 var url = base+"/interface/super/edit_globals.php";
1026 var formData = {
1027 'id' : $('#id').val(),
1028 'encounter' : $('#encounter').val(),
1029 'pid' : $('#pid').val(),
1031 top.restoreSession();
1032 $.ajax({
1033 type : 'GET',
1034 url : url,
1035 data : formData,
1036 success : function(result) {
1037 window.parent.RTop.document.result;
1041 if (zone =='PRIORS') $("#PRIORS_ALL_minus_one").trigger("click");
1042 if (zone =='QP') show_QP();
1043 if (zone =='KB') show_KB();
1044 if (zone =='DRAW') show_DRAW();
1045 if (zone =='TEXT') show_TEXT();
1046 if (zone =='IOP_graph') $("#LayerVision_IOP_lightswitch").trigger('click');
1047 if (zone == "HPI") scrollTo("HPI_left");
1048 if (zone == "PMH") scrollTo("PMH_left");
1049 if (zone == "EXT") scrollTo("EXT_left");
1050 if (zone == "ANTSEG") scrollTo("ANTSEG_left");
1051 if (zone == "POSTSEG") scrollTo("RETINA_left");
1052 if (zone == "NEURO") scrollTo("NEURO_left");
1057 * Function to test blowing up any section to fullscren - towards tablet functionality?
1058 * Currently not used.
1060 function show_Section(section) {
1061 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1062 show_right();
1063 $("div[name='_sections']").style.display= "none"; //
1064 $('#'+section+'_sections').style.display= "block";
1065 //.show().appendTo('form_container');
1068 * Function to display Chief Complaint 1-3
1070 function show_CC(CC_X) {
1071 $("[name^='CC_']").addClass('nodisplay');
1072 $("#CC_"+CC_X).removeClass('nodisplay');
1073 $("#CC_"+CC_X).index;
1076 /* START Functions related to CODING */
1079 * Function to determine if add on NeuroSensory(92060) code can be billed.
1081 function check_CPT_92060() {
1082 var neuro1='';
1083 var neuro2 ='';
1084 if ($("#STEREOPSIS").val() > '') (neuro1="1");
1085 $(".neurosens2").each(function(index) {
1086 if ($( this ).val() > '') {
1087 neuro2="1";
1090 if (neuro1 && neuro2){
1091 $("#neurosens_code").removeClass('nodisplay');
1092 CPT_92060 = 'here';
1093 } else {
1094 $("#neurosens_code").addClass('nodisplay');
1095 CPT_92060 = '';
1099 * Function to check documentation level for coding purposes
1100 * And make suggestions to end user.
1102 function check_exam_detail() {
1103 detail_reached_HPI='0';
1104 chronic_reached_HPI='0';
1105 $(".count_HPI").each(function(index) {
1106 if ($( this ).val() > '') detail_reached_HPI++;
1108 if (detail_reached_HPI > '3') {
1109 $(".detail_4_elements").css("color","red");
1110 $(".CODE_LOW").addClass("nodisplay");
1111 $(".CODE_HIGH").removeClass("nodisplay");
1112 $(".detailed_HPI").css("color","red");
1113 } else {
1114 $(".detail_4_elements").css("color","#876F6F");
1116 $(".chronic_HPI").each(function(index) {
1117 if ($( this ).val() > '') chronic_reached_HPI++;
1119 if (chronic_reached_HPI > '2') {
1120 $(".chronic_3_elements").css("color","red");
1121 $(".CODE_LOW").addClass("nodisplay");
1122 $(".CODE_HIGH").removeClass("nodisplay");
1123 $(".detailed_HPI").css("color","red");
1124 } else {
1125 $(".chronic_3_elements").css("color","#876F6F");
1127 if ((chronic_reached_HPI > '2')||(detail_reached_HPI > '3')) {
1128 $(".CODE_LOW").addClass("nodisplay");
1129 $(".CODE_HIGH").removeClass("nodisplay");
1130 $(".detailed_HPI").css("color","red");
1131 detail_reached_HPI = '1';
1132 } else {
1133 $(".CODE_LOW").removeClass("nodisplay");
1134 $(".CODE_HIGH").addClass("nodisplay");
1135 $(".detailed_HPI").css("color","#876F6F");
1136 detail_reached_HPI = '0';
1138 if ((($("#DIL_RISKS").is(':checked')) || ($(".dil_drug").is(':checked'))) && (($('#ODPERIPH').val() >'') || ($('#OSPERIPH').val() >''))) {
1139 $(".EXAM_LOW").addClass("nodisplay");
1140 $(".DIL_RISKS").removeClass("nodisplay");
1141 $("#DIL_RISKS").prop("checked","checked");
1142 detail_reached_exam = '1';
1143 } else {
1144 $(".EXAM_LOW").removeClass("nodisplay");
1145 $(".DIL_RISKS").addClass("nodisplay");
1146 detail_reached_exam = '0';
1148 Suggest_visit_code();
1151 /* END Functions related to CODING */
1153 /* START Functions related to IMPPLAN Builder */
1155 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1156 * Will use actual list from obj.IMPPLAN_items for coding.
1157 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1158 * available to build the Impression/Plan from.
1160 function build_DX_list(obj) {
1161 var out = "";
1162 var diagnosis;
1163 $( "#build_DX_list" ).empty();
1164 //add in inc_FIELDCODES culled from the datafields
1165 if (typeof obj.PMSFH === "undefined") return;
1166 if (typeof obj.Clinical === "undefined") submit_form('obj.clinical is undefined');
1167 if (!obj.PMSFH['POH'] && !obj.PMSFH['PMH'] && !obj.Clinical) {
1168 out = '<br /><span class="bold">The Past Ocular History (POH) and Past Medical History (PMH) are negative and no diagnosis was auto-generated from the clinical findings.</span><br /><br>Update the chart to activate the Builder.<br />';
1169 $( "#build_DX_list" ).html(out);
1170 return;
1172 build_IMPPLAN(obj.IMPPLAN_items);
1173 if ($('#inc_PE').is(':checked') && obj.Clinical) {
1174 $.each(obj.Clinical, function(key, value) {
1175 diagnosis='';
1176 if (obj.Clinical[key][0].diagnosis > '') { //so we are just showing this first item of each Dx (Eg bilateral, x4 pterygium, only first shows up)
1177 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.Clinical[key][0].code+"</code>";
1179 out += "<li class='ui-widget-content'><span name='DX_Clinical_"+key+"' id='DX_Clinical_"+key+"'>"+obj.Clinical[key][0].title+"</span> "+diagnosis+"</li> ";
1183 if ($('#inc_POH').is(':checked') && (obj.PMSFH['POH']||obj.PMSFH['POS'])) {
1184 $.each(obj.PMSFH['POH'], function(key, value) {
1185 diagnosis='';
1186 if (obj.PMSFH['POH'][key].diagnosis > '' ) {
1187 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['POH'][key].code+"</code>";
1189 out += "<li class='ui-widget-content'><span name='DX_POH_"+key+"' id='DX_POH_"+key+"'>"+obj.PMSFH['POH'][key].title+"</span> "+diagnosis+"</li>";
1191 $.each(obj.PMSFH['POS'], function(key, value) {
1192 diagnosis='';
1193 if (obj.PMSFH['POS'][key].diagnosis > '' ) {
1194 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['POS'][key].code+"</code>";
1196 out += "<li class='ui-widget-content'><span name='DX_POS_"+key+"' id='DX_POS_"+key+"'>"+obj.PMSFH['POS'][key].title+"</span> "+diagnosis+"</li>";
1199 if ($('#inc_PMH').is(':checked') && obj.PMSFH['PMH']) {
1200 $.each(obj.PMSFH['PMH'], function(key, value) {
1201 diagnosis='';
1202 if (obj.PMSFH['PMH'][key].diagnosis > '') {
1203 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['PMH'][key].code+"</code>";
1205 out += "<li class='ui-widget-content'><span name='DX_PMH_"+key+"' id='DX_PMH_"+key+"'>"+obj.PMSFH['PMH'][key].title+"</span>"+diagnosis+"</li> ";
1208 //add in inc_FIELDCODES culled from the datafields
1209 if (out !="") {
1210 rebuild_IMP($( "#build_DX_list" ));
1211 $( "#build_DX_list" )
1212 .html(out).sortable({ handle: ".handle",stop: function(event, ui){ rebuild_IMP($( "#build_DX_list" )) } })
1213 .selectable({ filter: "li", cancel: ".handle",stop: function(event, ui){ rebuild_IMP($( "#build_DX_list" )) } })
1214 .find( "li" )
1215 .addClass( "ui-corner-all ui-selected" )
1216 .dblclick(function(){
1217 rebuild_IMP($( "#build_DX_list" ));
1218 $('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1220 //this places the handle for the user to drag the item around.
1221 .prepend( "<div class='handle '><i class='fa fa-arrows fa-1'></i></div>" );
1222 } else {
1223 out = '<br /><span class="bold"><?php echo xlt("Build Your Plan")."."; ?></span><br /><br>';
1224 out += '<?php echo xlt('Suggestions for the Imp/Plan are built from the Exam, the Past Ocular History (POH and POS) and the Past Medical History (PMH)')."."; ?><br />';
1225 out += '<?php echo xlt('Update the chart to build this list')."."; ?><br />';
1226 $( "#build_DX_list" ).html(out);
1230 * Function: After the Builder DX list is built from all the available options,
1231 * the end user can select to use only certain Dxs and change their sort order of importance.
1232 * This function builds the list of DXs selected and in the order as the user sorted them,
1233 * so we know what to use to build the Impression/Plan area and in what order to display them.
1235 function rebuild_IMP(obj2) {
1236 var surface;
1237 IMP_order=[];
1238 k='0';
1239 $( ".ui-selected", obj2 ).each(function() {
1240 var index = $( "#build_DX_list li" ).index( this );
1241 if ($('#build_DX_list li span')[index].id.match(/DX_POH_(.*)/)) {
1242 surface = 'POH_' + $( "#build_DX_list li span" )[index].id.match(/DX_POH_(.*)/)[1];
1243 IMP_order[k] = surface;
1244 }else if ($('#build_DX_list li span')[index].id.match(/DX_POS_(.*)/)) {
1245 surface = 'POS_' + $( "#build_DX_list li span" )[index].id.match(/DX_POS_(.*)/)[1];
1246 IMP_order[k] = surface;
1247 } else if ($('#build_DX_list li span')[index].id.match(/DX_PMH_(.*)/)) {
1248 surface = 'PMH_' + $( "#build_DX_list li span" )[index].id.match(/DX_PMH_(.*)/)[1];
1249 IMP_order[k] = surface;
1250 } else if ($('#build_DX_list li span')[index].id.match(/DX_Clinical_(.*)/)) {
1251 surface = 'CLINICAL_' + $( "#build_DX_list li span" )[index].id.match(/DX_Clinical_(.*)/)[1];
1252 IMP_order[k] = surface;
1254 k++;
1258 * This function builds the Impression/Plan area using the object supplied: items
1259 * It appends "items" into the Impression Plan area, complete with:
1260 * contenteditable Titles (the Impression),
1261 * its code (if part of the item object),
1262 * Plan textareas (autofilled with the item/object's "comment")
1263 * for each member of "items".
1264 * Duplicates are removed by server.
1266 function build_IMPPLAN(items) {
1267 var contents_here;
1268 $('#IMPPLAN_zone').html("");
1269 $('#Coding_DX_Codes').html("");
1270 if ((items == null) || ((typeof items == "undefined")|| (items.length =='0'))) {
1271 items = [];
1272 $('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1273 $('#IMPPLAN_zone').addClass('nodisplay');
1274 } else {
1275 //ok we have at least one item, display them in order; hide the Builder instructions
1276 $('#IMPPLAN_text').addClass('nodisplay');
1277 $('#IMPPLAN_zone').removeClass('nodisplay');
1278 count_dx=0;
1279 $.each(items, function( index, value ) {
1280 if (!value.codetext) value.codetext="";
1281 if (!value.code) value.code="";
1282 if ((value.code==="") || (value.code.match(/Code/) || (value.code==null))) {
1283 value.code="<i class='fa fa-search-plus'></i>&nbsp;Code";
1284 } else {
1285 count_dx++;
1286 if (value.code.match(/\,/g)) {
1287 // If there is a comma in there, there is more than one code present for this item. Split them out.
1288 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1289 // PMSFH_link is only present when the Builder was used to make the entry.
1290 if ((typeof value.PMSFH_link !== "undefined") || (value.PMSFH_link !== null)) {
1291 //The Title should have the description.
1292 var CodeArr = value.code.split(",");
1293 var TitleArr = value.codedesc.split("\r");
1294 for (i=0;i < CodeArr.length;i++) {
1295 if (CodeArr.length == (TitleArr.length-1)) { //there is a trailing \r
1296 $('#Coding_DX_Codes').append(count_dx +'. '+CodeArr[i]+': '+TitleArr[i]+'<br />');
1297 } else {
1298 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1299 $('#Coding_DX_Codes').append(CodeArr[i]+': <?php echo xlt('Manually retrieve description on Fee Sheet'); ?> <br />');
1302 } else {
1303 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1304 if (value.PMSFH_link.match(/Clinical_(.*)/)) {
1305 if (typeof obj.Clinical !== "undefined") {
1306 var location = value.PMSFH_link.match(/Clinical_(.*)/)[1];
1307 if (obj.Clinical[location]!=null ) {
1308 for (i=0; i< obj.Clinical[location].length; i++) {
1309 $('#Coding_DX_Codes').append(count_dx +'. '+obj.Clinical[location][i].code+': '+obj.Clinical[location][i].codedesc+'<br />');
1311 } else {
1312 //item has a PMSFH_link but it is not from a Clinical field
1313 alert("Houston, we have a problem!");
1318 } else { //all is good, one code only
1319 $('#Coding_DX_Codes').append(count_dx +'. '+value.code+': '+value.codedesc+'<br />');
1322 var title2 = value.title.replace(/(\')/g, '');
1323 contents_here = ( index + 1 ) +
1324 ". <span contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+"'>" +
1325 value.title +"</span>"+
1326 "<span contenteditable class='pull-right' onclick='sel_diagnosis("+index+",\""+title2+"\");' title='"+value.codetext+"' id='CODE_"+index+"'>"+
1327 value.code + "</span>&nbsp;"+
1328 "<br /><textarea id='PLAN_"+index+"' name='PLAN_"+index+
1329 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1330 value.plan +"</textarea><br />";
1331 $('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+'" class="IMPPLAN_class">'+
1332 '<i class="pull-right fa fa-close" id="BUTTON_IMPPLAN_'+index+'"></i>'+
1333 contents_here+'</div>');
1334 $('#BUTTON_IMPPLAN_'+index).click(function() {//delete/close icon
1335 var item = this.id.match(/BUTTON_IMPPLAN_(.*)/)[1];
1336 obj.IMPPLAN_items.splice(item,1);
1337 build_IMPPLAN(obj.IMPPLAN_items);
1338 store_IMPPLAN(obj.IMPPLAN_items,'1');
1340 $('#PLAN_'+index).css("background-color","#F0F8FF");
1343 //end each
1345 // The IMPRESSION DXs are "contenteditable" spans.
1346 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1347 $('[id^=IMPRESSION_]').blur(function(e) {
1348 e.preventDefault();
1349 var item = this.id.match(/IMPRESSION_(.*)/)[1];
1350 var content = this.innerText || this.innerHTML;
1351 obj.IMPPLAN_items[item].title = content;
1352 store_IMPPLAN(obj.IMPPLAN_items,'1');
1353 //$(this).css('background-color','#F0F8FF');
1354 return false;
1356 $('[id^=CODE_]').blur(function() {
1357 var item = this.id.match(/CODE_(.*)/)[1];
1358 var new_code = this.innerText || this.innerHTML;
1359 obj.IMPPLAN_items[item].code = new_code;
1360 //obj.IMPPLAN_items[item].codetext = '';
1361 //obj.IMPPLAN_items[item].codedesc = '';
1362 $(this).css('background-color','#F0F8FF');
1363 store_IMPPLAN(obj.IMPPLAN_items,'1');
1366 $('[id^=PLAN_]').change(function() {
1367 var item = this.id.match(/PLAN_(.*)/)[1];
1368 obj.IMPPLAN_items[item].plan = $(this).val();
1369 store_IMPPLAN(obj.IMPPLAN_items,'1');
1370 $(this).css('background-color','#F0F8FF');
1373 $('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e){
1374 $(this).css('height', 'auto' );
1375 $(this).height( this.scrollHeight );
1377 $('#IMPPLAN_zone').find( 'textarea' ).keyup();
1378 obj.IMPPLAN_items = items;
1384 * This functions updates a PMSFH item's code on the server via its issue number
1386 function update_PMSFH_code(the_issue,new_code){
1387 var url = "../../forms/eye_mag/save.php?mode=update";
1388 top.restoreSession();
1389 $.ajax({
1390 type : 'POST',
1391 url : url,
1392 data : {
1393 action : 'code_PMSFH',
1394 pid : $('#pid').val(),
1395 form_id : $('#form_id').val(),
1396 encounter : $('#encounter').val(),
1397 uniqueID : $('#uniqueID').val(),
1398 issue : the_issue,
1399 code : new_code
1401 }).done(function(result) {
1402 if (result == 'Code 400') {
1403 code_400(); //the user does not have write privileges!
1404 return;
1411 * This function sends the obj.IMPPLAN_items to the server for storage
1413 function store_IMPPLAN(storage,nodisplay) {
1414 if (typeof storage !== "undefined") {
1415 var url = "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1416 var formData = JSON.stringify(storage);
1417 top.restoreSession();
1418 $.ajax({
1419 type : 'POST',
1420 url : url,
1421 dataType : 'json',
1422 data : {
1423 parameter : formData,
1424 action : 'store_IMPPLAN',
1425 pid : $('#pid').val(),
1426 form_id : $('#form_id').val(),
1427 encounter : $('#encounter').val(),
1428 uniqueID : $('#uniqueID').val()
1430 }).done(function(result) {
1431 if (result == "Code 400") {
1432 code_400(); //the user does not have write privileges!
1433 return;
1435 obj.IMPPLAN_items = result;
1436 if (typeof display === "undefined") {
1437 build_IMPPLAN(obj.IMPPLAN_items);
1445 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1448 function CODING_to_feesheet(CODING_items) {
1449 if (typeof CODING_items !== "undefined") {
1450 var url = "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1451 var formData = JSON.stringify(CODING_items);
1452 top.restoreSession();
1453 $.ajax({
1454 type : 'POST',
1455 url : url,
1456 data : {
1457 parameter : formData,
1458 action : 'code_visit',
1459 pid : $('#pid').val(),
1460 form_id : $('#form_id').val(),
1461 encounter : $('#encounter').val(),
1462 uniqueID : $('#uniqueID').val()
1464 }).done(function(result) {
1465 if (result == "Code 400") {
1466 code_400(); //the user does not have write privileges!
1467 return;
1468 } else {
1469 $("#goto_fee_sheet").removeClass('nodisplay');
1477 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1478 * This item is appended to the $('#IMPPLAN_zone').
1480 function dragto_IMPPLAN_zone(event, ui) {
1481 var findme = ui.draggable.find("span").attr("id");
1482 var group = findme.match(/DX_(.*)_(.*)/)[1];
1483 var location = findme.match(/DX_(.*)_(.*)/)[2];
1484 var the_code ='';
1485 var the_codedesc ='';
1486 var the_codetext ='';
1487 var the_plan ='';
1488 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];
1489 if (group =="Clinical") {
1490 //more than one field can contain this DX.
1491 //Group them into one IMPPLAN.
1492 for (i=0;i < obj.Clinical[location].length; i++) {
1493 the_code += obj.Clinical[location][i]['code']+',';
1494 the_codedesc = obj.Clinical[location][i]['codedesc'];
1495 the_codetext = obj.Clinical[location][i]['codetext'];
1496 the_plan += obj.Clinical[location][i]['codedesc'] + "\r";
1498 if (i > 0) the_code = the_code.slice(0, -1);
1499 obj.IMPPLAN_items.push({
1500 code: the_code,
1501 codedesc: the_codedesc,
1502 codetext: the_codetext,
1503 codetype: obj.Clinical[location][0]['codetype'],
1504 plan: the_plan,
1505 PMSFH_link: obj.Clinical[location][0]['PMSFH_link'],
1506 title: obj.Clinical[location][0]['title']
1509 } else {
1510 obj.IMPPLAN_items.push({
1511 code: obj.PMSFH[group][location]['code'],
1512 codedesc: obj.PMSFH[group][location]['codedesc'],
1513 codetext: obj.PMSFH[group][location]['codetext'],
1514 codetype: obj.PMSFH[group][location]['codetype'],
1515 plan: obj.PMSFH[group][location]['comments'],
1516 PMSFH_link: obj.PMSFH[group][location]['PMSFH_link'],
1517 title: obj.PMSFH[group][location]['title']
1521 store_IMPPLAN(obj.IMPPLAN_items,'1');
1524 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field $('#IMP') <-- New Dx textarea
1525 * The data is appended to the end of the text.
1526 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1528 function dragto_IMPPLAN(event, ui) {
1529 var findme = ui.draggable.find("span").attr("id");
1530 var group = findme.match(/DX_(.*)_(.*)/)[1];
1531 var location = findme.match(/DX_(.*)_(.*)/)[2];
1532 var draggable2 = ui.draggable;
1533 if (group =="Clinical") {
1534 $('#IMP').val(ui.draggable[0].textContent+"\n");
1535 } else {
1536 $('#IMP').val(ui.draggable[0].textContent+"\n"+obj.PMSFH[group][location]['comments']);
1539 /* END Functions related to IMPPLAN Builder */
1541 function Suggest_visit_code() {
1542 //assume Eyes and established patient
1543 (Code_group != 'Eyes') ? (digit_2 = '9') : digit_2 = '2'; //920XX or 990XX
1544 (Code_new_est == 'New') ? (digit_4 = '0') : digit_4 = '1'; //9X01X or 9X00X
1545 if (detail_reached_exam =='1' && (detail_reached_HPI =='1')) {
1546 (Code_group =='Eyes') ? (digit_5 = '4') : (digit_5='3'); //920X4 or 990X3
1547 detailed = "comprehensive";
1548 } else {
1549 digit_5 = '2'; //920X2
1550 detailed = "intermediate";
1552 visit_desc = Code_new_est +" "+ detailed +" "+digit_5;
1553 visit_code = "9"+digit_2+"0"+digit_4+digit_5;
1554 $('#visit_codes').val("CPT4|"+visit_code+"|").change();
1557 * This function builds the codes and populates the billing table for this encounter.
1559 function build_CODING_list() {
1560 CODING_items =[];
1561 /* the following things get billed:
1562 1. Visit code(s) including neurosensory if performed
1563 2. Tests performed
1564 3. Diagnostic codes
1566 //1. Visit Codes.
1567 CODING_items.push({
1568 code: visit_code,
1569 codedesc: visit_desc,
1570 codetext: '',
1571 codetype: 'CPT4',
1572 title: 'Visit Code'
1574 //neurosensory
1575 if (CPT_92060 == 'here') {
1576 CODING_items.push({
1577 code: '92060',
1578 codedesc: 'Sensorimotor exam',
1579 codetext: 'Sensorimotor exam (CPT4:92060)',
1580 codetype: 'CPT4',
1581 title: 'Neuro/Sensorimotor Code'
1584 //2. Tests/procedures performed to bill
1585 $('.TESTS').each(function(i, obj) {
1586 //test
1587 if ($(this).is(':checked')) {
1588 var codetype = obj.value.match(/(.*):(.*)/)[1];
1589 var code = obj.value.match(/(.*):(.*)/)[2];
1590 CODING_items.push({
1591 'code': code,
1592 codedesc: obj.title,
1593 codetext: obj.codetext,
1594 codetype: codetype,
1595 title: obj.title
1599 //3. Diagnostic Codes
1600 $.each(obj.IMPPLAN_items, function( index, value ) {
1601 if (value['codetype']) {
1602 if (value['code'].match(/\,/g)) {
1603 //physical finding found in more than one location, more than one code...
1604 //if there is a comma in there, there is more than one code present. Split them out.
1605 // And all those in one group have the same link out (PMSFH_link) value
1606 var location = value.PMSFH_link.match(/Clinical_(.*)/)[1];
1607 for (i=0; i< obj.Clinical[location].length; i++) {
1608 CODING_items.push({
1609 code: obj.Clinical[location][i]['code'],
1610 codedesc: obj.Clinical[location][i]['codedesc'],
1611 codetext: obj.Clinical[location][i]['codetext'],
1612 codetype: obj.Clinical[location][i]['codetype'],
1613 title: obj.Clinical[location][i]['title']
1616 } else {
1617 CODING_items.push({
1618 code: value['code'],
1619 codedesc: value['codedesc'],
1620 codetext: value['codetext'],
1621 codetype: value['codetype'],
1622 title: value['title']
1627 CODING_to_feesheet(CODING_items);
1631 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1633 function toggle_active_flags(new_state) {
1634 if (($("#chart_status").val() == "off") || (new_state == "on")) {
1635 // we are read-only and we want to go active.
1636 $("#chart_status").val("on");
1637 $("#active_flag").html(" Active Chart ");
1638 $("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1639 $("#warning").addClass("nodisplay");
1640 $('input, select, textarea, a').removeAttr('disabled');
1641 $('input, textarea').removeAttr('readonly');
1642 } else {
1643 //else clicking this means we want to go from active to read-only
1644 $("#chart_status").val("off");
1645 $("#active_flag").html(" READ-ONLY ");
1646 $("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1647 $("#warning").removeClass("nodisplay");
1648 //we should tell the form fields to be disabled. should already be...
1649 $('input, select, textarea, a').attr('disabled', 'disabled');
1650 $('input, textarea').attr('readonly', 'readonly');
1651 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1652 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1653 this_form_id = $("#form_id").val();
1654 $("#COPY_SECTION").val("READONLY-"+this_form_id);
1658 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1660 function update_READONLY() {
1661 var data = {
1662 'action' : 'retrieve',
1663 'copy' : 'READONLY',
1664 'zone' : 'READONLY',
1665 'copy_to' : $("#form_id").val(),
1666 'copy_from' : $("#form_id").val(),
1667 'pid' : $("#pid").val()
1669 //we are going to update the whole form
1670 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1671 //We are not ready to actively chart, just looking to see how far along our staff is...
1672 //or maybe just looking ahead to see the who's being worked up in the next room?
1673 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1674 // yet it is updating every 10-15 seconds if another user is making changes.
1675 top.restoreSession();
1676 $.ajax({
1677 type : 'POST',
1678 dataType : 'json',
1679 url : "../../forms/eye_mag/save.php?copy=READONLY",
1680 data : data,
1681 success : function(result) {
1682 $.map(result, function(valhere, keyhere) {
1683 if ($("#"+keyhere).val() != valhere) {
1684 $("#"+keyhere).val(valhere).css("background-color","#CCF");
1686 if (keyhere.match(/MOTILITY_/)) {
1687 // Copy forward ductions and versions visually
1688 // Make each blank, and rebuild them
1689 $("[name='"+keyhere+"_1']").html('');
1690 $("[name='"+keyhere+"_2']").html('');
1691 $("[name='"+keyhere+"_3']").html('');
1692 $("[name='"+keyhere+"_4']").html('');
1693 if (keyhere.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO)/)) {
1694 // Show a horizontal (minus) tag.
1695 hash_tag = '<i class="fa fa-minus"></i>';
1696 } else { //show vertical tag
1697 hash_tag = '<i class="fa fa-minus rotate-left"></i>';
1699 for (index =1; index <= valhere; ++index) {
1700 $("#"+keyhere+"_"+index).html(hash_tag);
1702 } else if (keyhere.match(/^(ODVF|OSVF)\d$/)) {
1703 if (valhere =='1') {
1704 $("#FieldsNormal").prop('checked', false);
1705 $("#"+keyhere).prop('checked', true);
1706 $("#"+keyhere).val('1');
1707 } else {
1708 $("#"+keyhere).val('0');
1709 $("#"+keyhere).prop('checked', false);
1711 } else if (keyhere.match(/AMSLERO(.)/)) {
1712 var sidehere = keyhere.match(/AMSLERO(.)/);
1713 if (valhere < '1') valhere ='0';
1714 $("#"+keyhere).val(valhere);
1715 var srcvalue="AmslerO"+sidehere[1];
1716 document.getElementById(srcvalue).src = document.getElementById(srcvalue).src.replace(/\_\d/g,"_"+valhere);
1717 $("#AmslerO"+sidehere[1]+"value").text(valhere);
1718 } else if (keyhere.match(/VA$/)) {
1719 $("#"+keyhere+"_copy").val(valhere).css("background-color","#F0F8FF");;
1720 $("#"+keyhere+"_copy_brd").val(valhere).css("background-color","#F0F8FF");;
1721 } else if (keyhere.match(/^O.VA_/)) {
1722 var side=keyhere.match(/(O.)VA_(.)/)[1];
1723 var rx_number=keyhere.match(/(O.)VA_(.)/)[2];
1724 if (rx_number == '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1725 $('#'+side+'VA_1_copy').val(valhere).css("background-color","#F0F8FF");;
1726 $('#'+side+'VA_1_copy_brd').val(valhere).css("background-color","#F0F8FF");;
1728 } else if (keyhere.match(/^RX_TYPE_\d$/)) {
1729 if (typeof $('input:radio[name='+keyhere+']')[valhere] !== "undefined") {
1730 $('input:radio[name='+keyhere+']')[valhere].checked = true;
1732 } else if (keyhere.match(/(alert|oriented|confused|PUPIL_NORMAL)/)) {
1733 if (valhere =='1') {
1734 $('#'+keyhere).val(valhere).prop('checked', true);
1735 } else {
1736 $('#'+keyhere).val(valhere).prop('checked', false);
1740 }});
1742 function dopopup(url) {
1743 window.open(url, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1745 function goto_url(url) {
1746 window.open(url);
1748 function openImage() {
1749 dlgopen(base+'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1752 * Keyboard shortcut commands.
1755 shortcut.add("Control+T",function() {
1756 show_TEXT();
1758 shortcut.add("Meta+T",function() {
1759 show_TEXT();
1761 shortcut.add("Control+D",function() {
1762 show_DRAW();
1764 shortcut.add("Meta+D",function() {
1765 show_DRAW();
1767 shortcut.add("Control+P",function() {
1768 $("#PRIOR_ALL").val($('#form_id').val()).trigger("change");
1770 shortcut.add("Meta+P",function() {
1771 show_PRIORS();
1772 $("#PRIOR_ALL").val($('#form_id').val()).trigger("change");
1774 shortcut.add("Control+B",function() {
1775 show_QP();
1777 shortcut.add("Meta+B",function() {
1778 show_QP();
1780 shortcut.add("Control+K",function() {
1781 show_KB();
1783 shortcut.add("Meta+K",function() {
1784 show_KB();
1786 $(function(){
1788 * this swallows backspace keys on the "rx" elements.
1789 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1791 var rx = /INPUT|SELECT|TEXTAREA|SPAN|DIV/i;
1793 $(document).bind("keydown keypress", function(e){
1794 if( e.which == 8 ){ // 8 == backspace
1795 if(!rx.test(e.target.tagName) || e.target.disabled || e.target.readOnly ){
1796 e.preventDefault();
1802 /* Undo feature
1803 * RIGHT NOW THIS WORKS PER FIELD ONLY in FF. In Chrome it works great. Not sure about IE at all.
1804 * In FF, you select a field and CTRL-Z reverses/Shift-Ctrl-Z forwards value
1805 * To get true Undo Redo, we will need to create two arrays, one with the command/field, prior value, next value to undo
1806 * and when undone, add this to the REDO array. When an Undo command is followed by anything other than Redo, it erases REDO array.
1807 * Ctrl-Z works without this extra code! Fuzzy on the details for specific browsers so TODO.
1812 * Function to update the PCP and referring person
1815 function update_DOCS() {
1816 var url = "../../forms/eye_mag/save.php?mode=update";
1817 top.restoreSession();
1818 $.ajax({
1819 type : 'POST',
1820 url : url,
1821 data : {
1822 action : 'docs',
1823 pid : $('#pid').val(),
1824 pcp : $('#form_PCP').val(),
1825 rDOC : $('#form_rDOC').val(),
1826 form_id : $('#form_id').val(),
1827 encounter : $('#encounter').val(),
1828 uniqueID : $('#uniqueID').val()
1830 }).done(function(result) {
1831 if (result == "Code 400") {
1832 code_400(); //the user does not have write privileges!
1833 return;
1839 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
1842 function reverse_cylinder(target) {
1843 //target can be revW1-5,AR,MR,CR,CTL,
1844 var prefix;
1845 var suffix;
1846 if (target.match(/^(AR|MR|CR|CTL)$/)) {
1847 prefix = target;
1848 suffix = '';
1850 if (target.match(/^revW[1-5]{1}$/)) { //matches on digit only, here 1-5
1851 target = target.replace("revW","");
1852 prefix = '';
1853 suffix = '_'+target;
1855 var Rsph = $('#'+prefix+'ODSPH'+suffix).val();
1856 var Rcyl = $('#'+prefix+'ODCYL'+suffix).val();
1857 var Raxis = $('#'+prefix+'ODAXIS'+suffix).val();
1858 var Lsph = $('#'+prefix+'OSSPH'+suffix).val();
1859 var Lcyl = $('#'+prefix+'OSCYL'+suffix).val();
1860 var Laxis = $('#'+prefix+'OSAXIS'+suffix).val();
1861 if (Rsph=='' && Rcyl =='' && Lsph=='' && lcyl =='') return;
1862 if ((!Rcyl.match(/SPH/i)) && (Rcyl >'')) {
1863 if (Rsph.match(/plano/i)) Rsph ='0';
1864 Rsph = Number(Rsph);
1865 Rcyl = Number(Rcyl);
1866 Rnewsph = Rsph + Rcyl;
1867 if (Rnewsph ==0) Rnewsph ="PLANO";
1868 Rnewcyl = Rcyl * -1;
1869 if (Rnewcyl > 0) Rnewcyl = "+"+Rnewcyl;
1870 if (parseInt(Raxis) < 90) {
1871 Rnewaxis = parseInt(Raxis) + 90;
1872 } else {
1873 Rnewaxis = parseInt(Raxis) - 90;
1875 if (Rnewcyl=='0') Rnewcyl = "SPH";
1876 if (Rnewsph =='0') {
1877 Rnewsph ="PLANO";
1878 if (Rnewcyl =="SPH") Rnewcyl = '';
1880 $('#'+prefix+'ODSPH'+suffix).val(Rnewsph);
1881 $('#'+prefix+'ODCYL'+suffix).val(Rnewcyl);
1882 $('#'+prefix+'ODAXIS'+suffix).val(Rnewaxis);
1883 $('#'+prefix+'ODAXIS'+suffix).trigger('blur');
1884 $('#'+prefix+'ODSPH'+suffix).trigger('blur');
1885 $('#'+prefix+'ODCYL'+suffix).trigger('blur');
1887 if ((!Lcyl.match(/SPH/i)) && (Lcyl >'')) {
1888 if (!Lsph.match(/\d/)) Lsph ='0';
1889 Lsph = Number(Lsph);
1890 Lcyl = Number(Lcyl);
1891 Lnewsph = Lsph + Lcyl;
1892 Lnewcyl = Lcyl * -1;
1893 if (Lnewcyl > 0) Lnewcyl = "+"+ Lnewcyl;
1894 if (parseInt(Laxis) < 90) {
1895 Lnewaxis = parseInt(Laxis) + 90;
1896 } else {
1897 Lnewaxis = parseInt(Laxis) - 90;
1900 if (Lnewcyl=='0') Lnewcyl = "SPH";
1901 if (Lnewsph =='0') {
1902 Lnewsph ="PLANO";
1903 if (Lnewcyl =="SPH") Lnewcyl = '';
1906 $('#'+prefix+'OSSPH'+suffix).val(Lnewsph);
1907 $('#'+prefix+'OSCYL'+suffix).val(Lnewcyl);
1908 $('#'+prefix+'OSAXIS'+suffix).val(Lnewaxis);
1909 $('#'+prefix+'OSAXIS'+suffix).trigger('blur');
1910 $('#'+prefix+'OSSPH'+suffix).trigger('blur');
1911 $('#'+prefix+'OSCYL'+suffix).trigger('blur');
1914 function scrollTo(target) {
1915 //if (scroll !== '1') return;
1916 var offset;
1917 var scrollSpeed = 2000;
1918 var wheight = $(window).height();
1919 offset = $("#"+target).offset().top - (wheight / 2)+200;
1920 if (offset > (window.pageYOffset +150)||offset < (window.pageYOffset -150)) {
1921 $('html, body').animate({scrollTop:offset}, scrollSpeed);
1925 $(document).ready(function() {
1926 check_lock();
1927 $('[title]').qtip({
1928 position: {
1929 my: 'top Right', // Position my top left...
1930 at: 'bottom Left', // at the bottom right of...
1931 target: 'mouse' // my target
1935 $('#form_PCP,#form_rDOC').change(function() {
1936 update_DOCS();
1938 $('#tooltips_status').html($('#PREFS_TOOLTIPS').val());
1939 if ($("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
1940 $('[title]').qtip('disable');
1942 $('#tooltips_toggle,#tooltips_status').click(function() {
1943 if ($("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
1944 $('#PREFS_TOOLTIPS').val('<?php echo xla('Off'); ?>');
1945 $("#tooltips_status").html('<?php echo xla('are off'); ?>');
1946 $('[title]').qtip('disable');
1947 } else {
1948 $('#PREFS_TOOLTIPS').val('<?php echo xla('On'); ?>');
1949 $('#tooltips_status').html('<?php echo xla('are on'); ?>');
1950 $('[title]').qtip('enable');
1952 update_PREFS();
1954 $('#toggle_drugs').click(function(){
1955 $('.hideme_drugs').toggleClass('nodisplay');
1956 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1957 return false;
1959 $('#toggle_VFs').click(function(){
1960 $('.hideme_VFs').toggleClass('nodisplay');
1961 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1962 return false;
1964 $('#toggle_OCTs').click(function(){
1965 $('.hideme_OCTs').toggleClass('nodisplay');
1966 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1967 return false;
1969 $('#toggle_cups').click(function(){
1970 $('.hideme_cups').toggleClass('nodisplay');
1971 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1972 return false;
1974 $('#toggle_gonios').click(function(){
1975 $('.hideme_gonios').toggleClass('nodisplay');
1976 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1977 return false;
1979 $('.close').click(function(){
1980 $('#GFS_accordion .hide').slideUp();
1982 $('#ODIOPTARGET').change(function() {
1983 $('#OSIOPTARGET').val($('#ODIOPTARGET').val());
1984 refresh_GFS();
1986 $('#ODIOPAP,#OSIOPAP,#ODIOPTARGET').change(function() {
1987 //this is failing if there is no config_by_day variable.
1988 refresh_GFS();
1990 if ($("#PREFS_KB").val() =='1') {
1991 $(".kb").removeClass('nodisplay');
1992 $(".kb_off").addClass('nodisplay');
1993 } else {
1994 $(".kb").addClass('nodisplay');
1995 $(".kb_off").removeClass('nodisplay');
1998 $("[name$='_kb']").click(function() {
1999 $('.kb').toggleClass('nodisplay');
2000 $('.kb_off').toggleClass('nodisplay');
2001 if ($('#PREFS_EXAM').val() == 'DRAW') {
2002 show_TEXT();
2005 if ($("#PREFS_KB").val() > 0) {
2006 $("#PREFS_KB").val('0');
2007 } else {
2008 $("#PREFS_KB").val('1');
2010 update_PREFS();
2012 $('.ke').mouseover(function() {
2013 $(this).toggleClass('yellow');
2015 $('.ke').mouseout(function() {
2016 $(this).toggleClass('yellow');
2018 $("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e) {
2019 //this is the Shorthand engine's ignition
2020 if (e.which == 13|| e.keyCode == 13||e.which == 9|| e.keyCode == 9) {
2021 e.preventDefault();
2022 var data_all = $(this).val();
2023 var data_seg = data_all.match(/([^;]*)/gm);
2024 var field2 ='';
2025 var appendix =".a";
2026 var zone;
2027 for (index=0; index < data_seg.length; ++index) {
2028 if (data_seg[index] =='') continue;
2029 data_seg[index] = data_seg[index].replace(/^[\n\v\f\r\x85\u2028\u2029\W]*/,'');
2030 data_seg[index] = data_seg[index].replace(/^[\s]*/,'');
2031 if (data_seg[index].match(/^D($|;)/i)) {
2032 $("#EXT_defaults").trigger("click");
2033 $("#ANTSEG_defaults").trigger("click");
2034 $("#RETINA_defaults").trigger("click");
2035 $("#NEURO_defaults").trigger("click");
2036 continue;
2038 if (data_seg[index].match(/^DEXT($|;)/i)) {
2039 $("#EXT_defaults").trigger("click");
2040 continue;
2042 if (data_seg[index].match(/^DANTSEG($|;)/i)) {
2043 $("#ANTSEG_defaults").trigger("click");
2044 continue;
2046 if (data_seg[index].match(/^DAS($|;)/i)) {
2047 $("#ANTSEG_defaults").trigger("click");
2048 continue;
2050 if (data_seg[index].match(/^DRETINA($|;)/i)) {
2051 $("#RETINA_defaults").trigger("click");
2052 continue;
2054 if (data_seg[index].match(/^DRET($|;)/i)) {
2055 $("#RETINA_defaults").trigger("click");
2056 continue;
2058 if (data_seg[index].match(/^DNEURO($|;)/i)) {
2059 $("#NEURO_defaults").trigger("click");
2060 continue;
2062 if ((data_seg[index].match(/^CLEAREXT($|;)/i))||
2063 (data_seg[index].match(/^CEXT($|;)/i))) {
2064 $(".EXT").val('');
2065 continue;
2067 if ((data_seg[index].match(/^CLEARAS($|;)/i))||
2068 (data_seg[index].match(/^CLEARANTSEG($|;)/i))||
2069 (data_seg[index].match(/^CANTSEG($|;)/i))||
2070 (data_seg[index].match(/^CANT($|;)/i))||
2071 (data_seg[index].match(/^CAS($|;)/i))) {
2072 $(".ANTSEG").val('');
2073 continue;
2075 if ((data_seg[index].match(/^CLEARRET($|;)/i))||
2076 (data_seg[index].match(/^CRET($|;)/i)) ||
2077 (data_seg[index].match(/^CLEARRETINA($|;)/i))||
2078 (data_seg[index].match(/^CRETINA($|;)/i))) {
2079 $(".RETINA").val('');
2080 continue;
2083 appendix=".a";
2084 var data = data_seg[index].match(/^(\w*)\:?(.*)/);
2085 (data[2].match(/\.a$/))?(data[2] = data[2].replace(/\.a$/,'')):(appendix = "nope");
2086 var field = data[1].toUpperCase();
2087 var text = data[2];
2088 text = expand_vocab(text);
2089 priors = process_kb(field,text,appendix,prior_field,prior_text);
2090 prior_field = priors['field'];
2091 prior_text = priors['prior_text'];
2094 submit_form('2');
2095 $(this).val('');
2099 $("[id^='sketch_tools_']").click(function() {
2100 var zone = this.id.match(/sketch_tools_(.*)_/)[1];
2101 $("[id^='sketch_tools_"+zone+"']").css("height","30px");
2102 $(this).css("height","50px");
2104 $("[id^='sketch_sizes_']").click(function() {
2105 var zone = this.id.match(/sketch_sizes_(.*)_/)[1];
2106 $("[id^='sketch_sizes_"+zone+"']").css("background","").css("border-bottom","");
2107 $(this).css("border-bottom","2pt solid black");
2110 // Here we get CC1 to show
2111 $(".tab_content").addClass('nodisplay');
2112 $("#tab1_CC_text").removeClass('nodisplay');
2113 $("#tab1_HPI_text").removeClass('nodisplay');
2114 $("[id$='_CC'],[id$='_HPI_tab']").click(function() {
2115 // First remove class "active" from currently active tabs
2116 $("[id$='_CC']").removeClass('active');
2117 $("[id$='_HPI_tab']").removeClass('active');
2118 // Hide all tab content
2119 $(".tab_content").addClass('nodisplay');
2120 // Here we get the href value of the selected tab
2121 var selected_tab = $(this).find("a").attr("href");
2122 // Now add class "active" to the selected/clicked tab and content
2123 $(selected_tab+"_CC").addClass('active');
2124 $(selected_tab+"_CC_text").removeClass('nodisplay');
2125 $(selected_tab+"_HPI_tab").addClass('active');
2126 $(selected_tab+"_HPI_text").removeClass('nodisplay');
2127 // At the end, we add return false so that the click on the link is not executed
2128 return false;
2130 $("[id^='CONSTRUCTION_']").toggleClass('nodisplay');
2131 $("input,textarea,text").css("background-color","#FFF8DC");
2132 $("#IOPTIME").css("background-color","#FFFFFF");
2133 $("#refraction_width").css("width","8.5in");
2134 $(".Draw_class").addClass('nodisplay');
2135 $(".PRIORS_class").addClass('nodisplay');
2136 hide_DRAW();
2137 hide_right();
2138 $(window).resize(function() {
2139 if (window.innerWidth >'900') {
2140 $("#refraction_width").css("width","900px");
2141 $("#LayerVision2").css("padding","4px");
2143 if (window.innerWidth >'1300') {
2144 $("#refraction_width").css("width","1300px");
2145 //$("#first").css("width","1300px");
2147 if (window.innerWidth >'1900') {
2148 $("#refraction_width").css("width","1600px");
2152 $(window).resize();
2154 var hash_tag = '<i class="fa fa-minus"></i>';
2155 var index;
2156 // display any stored MOTILITY values
2157 $("#MOTILITY_RS").value = parseInt($("#MOTILITY_RS").val());
2158 if ($("#MOTILITY_RS").val() > '0') {
2159 $("#MOTILITYNORMAL").removeAttr('checked');
2160 for (index =1; index <= ($("#MOTILITY_RS").val()); ++index) {
2161 $("#MOTILITY_RS_"+index).html(hash_tag);
2164 $("#MOTILITY_RI").value = parseInt($("#MOTILITY_RI").val());
2165 if ($("#MOTILITY_RI").val() > '0') {
2166 $("#MOTILITYNORMAL").removeAttr('checked');
2167 for (index =1; index <= ($("#MOTILITY_RI").val()); ++index) {
2168 $("#MOTILITY_RI_"+index).html(hash_tag);
2171 $("#MOTILITY_LS").value = parseInt($("#MOTILITY_LS").val());
2172 if ($("#MOTILITY_LS").val() > '0') {
2173 $("#MOTILITYNORMAL").removeAttr('checked');
2174 for (index =1; index <= ($("#MOTILITY_LS").val()); ++index) {
2175 $("#MOTILITY_LS_"+index).html(hash_tag);
2178 $("#MOTILITY_LI").value = parseInt($("#MOTILITY_LI").val());
2179 if ($("#MOTILITY_LI").val() > '0') {
2180 $("#MOTILITYNORMAL").removeAttr('checked');
2181 for (index =1; index <= ($("#MOTILITY_LI").val()); ++index) {
2182 $("#MOTILITY_LI_"+index).html(hash_tag);
2186 $("#MOTILITY_RRSO").value = parseInt($("#MOTILITY_RRSO").val());
2187 if ($("#MOTILITY_RRSO").val() > '0') {
2188 $("#MOTILITYNORMAL").removeAttr('checked');
2189 for (index =1; index <= ($("#MOTILITY_RRSO").val()); ++index) {
2190 $("#MOTILITY_RRSO_"+index).html(hash_tag);
2193 $("#MOTILITY_RRIO").value = parseInt($("#MOTILITY_RRIO").val());
2194 if ($("#MOTILITY_RRIO").val() > '0') {
2195 $("#MOTILITYNORMAL").removeAttr('checked');
2196 for (index =1; index <= ($("#MOTILITY_RRIO").val()); ++index) {
2197 $("#MOTILITY_RRIO_"+index).html(hash_tag);
2200 $("#MOTILITY_RLIO").value = parseInt($("#MOTILITY_RLIO").val());
2201 if ($("#MOTILITY_RLIO").val() > '0') {
2202 $("#MOTILITYNORMAL").removeAttr('checked');
2203 for (index =1; index <= ($("#MOTILITY_RLIO").val()); ++index) {
2204 $("#MOTILITY_RLIO_"+index).html(hash_tag);
2207 $("#MOTILITY_RLSO").value = parseInt($("#MOTILITY_RLSO").val());
2208 if ($("#MOTILITY_RLSO").val() > '0') {
2209 $("#MOTILITYNORMAL").removeAttr('checked');
2210 for (index =1; index <= ($("#MOTILITY_RLSO").val()); ++index) {
2211 $("#MOTILITY_RLSO_"+index).html(hash_tag);
2214 $("#MOTILITY_LRSO").value = parseInt($("#MOTILITY_LRSO").val());
2215 if ($("#MOTILITY_LRSO").val() > '0') {
2216 $("#MOTILITYNORMAL").removeAttr('checked');
2217 for (index =1; index <= ($("#MOTILITY_LRSO").val()); ++index) {
2218 $("#MOTILITY_LRSO_"+index).html(hash_tag);
2221 $("#MOTILITY_LRIO").value = parseInt($("#MOTILITY_LRIO").val());
2222 if ($("#MOTILITY_LRIO").val() > '0') {
2223 $("#MOTILITYNORMAL").removeAttr('checked');
2224 for (index =1; index <= ($("#MOTILITY_LRIO").val()); ++index) {
2225 $("#MOTILITY_LRIO_"+index).html(hash_tag);
2228 $("#MOTILITY_LLSO").value = parseInt($("#MOTILITY_LLSO").val());
2229 if ($("#MOTILITY_LLSO").val() > '0') {
2230 $("#MOTILITYNORMAL").removeAttr('checked');
2231 for (index =1; index <= ($("#MOTILITY_LLSO").val()); ++index) {
2232 $("#MOTILITY_LLSO_"+index).html(hash_tag);
2235 $("#MOTILITY_LLIO").value = parseInt($("#MOTILITY_LLIO").val());
2236 if ($("#MOTILITY_LLIO").val() > '0') {
2237 $("#MOTILITYNORMAL").removeAttr('checked');
2238 for (index =1; index <= ($("#MOTILITY_LLIO").val()); ++index) {
2239 $("#MOTILITY_LLIO_"+index).html(hash_tag);
2243 var hash_tag = '<i class="fa fa-minus rotate-left"></i>';
2244 $("#MOTILITY_LR").value = parseInt($("#MOTILITY_LR").val());
2245 if ($("#MOTILITY_LR").val() > '0') {
2246 $("#MOTILITYNORMAL").removeAttr('checked');
2247 for (index =1; index <= ($("#MOTILITY_LR").val()); ++index) {
2248 $("#MOTILITY_LR_"+index).html(hash_tag);
2251 $("#MOTILITY_LL").value = parseInt($("#MOTILITY_LL").val());
2252 if ($("#MOTILITY_LL").val() > '0') {
2253 $("#MOTILITYNORMAL").removeAttr('checked');
2254 for (index =1; index <= ($("#MOTILITY_LL").val()); ++index) {
2255 $("#MOTILITY_LL_"+index).html(hash_tag);
2258 $("#MOTILITY_RR").value = parseInt($("#MOTILITY_RR").val());
2259 if ($("#MOTILITY_RR").val() > '0') {
2260 $("#MOTILITYNORMAL").removeAttr('checked');
2261 for (index =1; index <= ($("#MOTILITY_RR").val()); ++index) {
2262 $("#MOTILITY_RR_"+index).html(hash_tag);
2265 $("#MOTILITY_RL").value = parseInt($("#MOTILITY_RL").val());
2266 if ($("#MOTILITY_RL").val() > '0') {
2267 $("#MOTILITYNORMAL").removeAttr('checked');
2268 for (index =1; index <= ($("#MOTILITY_RL").val()); ++index) {
2269 $("#MOTILITY_RL_"+index).html(hash_tag);
2273 $(".chronic_HPI,.count_HPI").blur(function() {
2274 check_exam_detail();
2276 // Dilation status
2277 $("#DIL_RISKS").change(function(o) {
2278 ($(this).is(':checked')) ? ($(".DIL_RISKS").removeClass("nodisplay")) : ($(".DIL_RISKS").addClass("nodisplay"));
2279 check_exam_detail();
2281 $(".dil_drug").change(function(o) {
2282 if ($(this).is(':checked')) {
2283 //($(".DIL_RISKS").removeClass("nodisplay"));
2284 $("#DIL_RISKS").prop("checked","checked");
2285 check_exam_detail();
2286 }});
2288 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2289 $(".neurosens,.neurosens2").blur(function() {
2290 check_CPT_92060();
2292 // END AUTO-CODING FEATURES
2294 // functions to improve flow of refraction input
2295 $("input[name$='PRISM'],input[class^='prism']").blur(function() {
2296 //make it all caps
2297 var str = $(this).val();
2298 str = str.toUpperCase();
2299 $(this).val(str);
2301 $('input[class^="sphere"],input[name$="SPH"]').blur(function() {
2302 var mid = $(this).val();
2303 if (mid.match(/PLANO/i)) {
2304 $(this).val('PLANO');
2305 return;
2307 if (mid.match(/^[\+\-]?\d{1}$/)) {
2308 mid = mid+".00";
2310 if (mid.match(/\.[27]$/)) {
2311 mid = mid + '5';
2313 if (mid.match(/\.\d$/)) {
2314 mid = mid + '0';
2316 //if near is +2. make it +2.00
2317 if (mid.match(/\.$/)) {
2318 mid= mid + '00';
2320 if ((!mid.match(/\./))&&(mid.match(00|25|50|75))) {
2321 var front = mid.match(/(\d{0,2})(00|25|50|75)/)[1];
2322 var back = mid.match(/(\d{0,2})(00|25|50|75)/)[2];
2323 if (front =='') front ='0';
2324 mid = front + "." + back;
2326 if (!mid.match(/\./)) {
2327 var front = mid.match(/([\+\-]?\d{0,2})(\d{2})/)[1];
2328 var back = mid.match(/(\d{0,2})(\d{2})/)[2];
2329 if (front =='') front ='0';
2330 if (front =='-') front ='-0';
2331 mid = front + "." + back;
2333 if (!mid.match(/^(\+|\-){1}/)) {
2334 mid = "+" + mid;
2336 $(this).val(mid);
2339 $("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").blur(function() {
2340 var add = $(this).val();
2341 add = add.replace(/=/g,"+");
2342 //if add is one digit, eg. 2, make it +2.00
2343 if (add.match(/^\d{1}$/)) {
2344 add = "+"+add+".00";
2346 //if add is '+'one digit, eg. +2, make it +2.00
2347 if (add.match(/^\+\d{1}$/)) {
2348 add = add+".00";
2350 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2351 if (add.match(/\.[05]$/)) {
2352 add = add + '0';
2354 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2355 if (add.match(/\.[27]$/)) {
2356 add = add + '5';
2358 //if add is +2. make it +2.00
2359 if (add.match(/\.$/)) {
2360 add = add + '00';
2362 if ((!add.match(/\./))&&(add.match(/(0|25|50|75)$/))) {
2363 var front = add.match(/([\+]?\d{0,1})(00|25|50|75)/)[1];
2364 var back = add.match(/([\+]?\d{0,1})(00|25|50|75)/)[2];
2365 if (front =='') front ='0';
2366 add = front + "." + back;
2368 if (!add.match(/^(\+)/) && (add.length > 0)) {
2369 add= "+" + add;
2371 $(this).val(add);
2372 if (this.id=="ODADD_1") $('#OSADD_1').val(add);
2373 if (this.id=="ODMIDADD_1") $('#OSMIDADD_1').val(add);
2374 if (this.id=="ODADD_2") $('#OSADD_2').val(add);
2375 if (this.id=="ODMIDADD_2") $('#OSMIDADD_2').val(add);
2376 if (this.id=="ODADD_3") $('#OSADD_3').val(add);
2377 if (this.id=="ODMIDADD_3") $('#OSMIDADD_3').val(add);
2378 if (this.id=="ODADD_4") $('#OSADD_4').val(add);
2379 if (this.id=="ODMIDADD_4") $('#OSMIDADD_4').val(add);
2380 if (this.id=="ODADD_5") $('#OSADD_5').val(add);
2381 if (this.id=="ODMIDADD_5") $('#OSMIDADD_5').val(add);
2382 if (this.id=="MRODADD") $('#MROSADD').val(add);
2383 if (this.id=="ARODADD") $('#AROSADD').val(add);
2384 if (this.id=="CTLODADD") $('#CTLOSADD').val(add);
2387 $("input[class^='axis'],input[name$='AXIS']").blur(function() {
2388 // Make this a 3 digit leading zeros number.
2389 // we are not translating text to numbers, just numbers to
2390 // a 3 digit format with leading zeroes as needed.
2391 // assume the end user KNOWS there are only numbers presented and
2392 // more than 3 digits is a mistake...
2393 // (although this may change with topography)
2394 var axis = $(this).val();
2395 var group = this.name.replace("AXIS", "CYL");;
2396 var cyl = $("#"+group).val();
2397 if ((cyl > '') && (cyl != 'SPH')) {
2398 if (!axis.match(/\d\d\d/)) {
2399 if (!axis.match(/\d\d/)) {
2400 if (!axis.match(/\d/)) {
2401 axis = '0';
2403 axis = '0' + axis;
2405 axis = '0' + axis;
2407 } else {
2408 axis = '';
2410 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2411 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2412 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2413 //the devices.
2414 $(this).val(axis);
2416 $("input[class^='cylinder'],input[name$='CYL']").blur(function() {
2417 var mid = $(this).val();
2418 var group = this.name.replace("CYL", "SPH");;
2419 var sphere = $("#"+group).val();
2420 if (((mid.length == 0) && (sphere.length > 0))||(mid.match(/sph/i))) {
2421 $(this).val('SPH');
2422 if (sphere.match(/plano/i)) $(this).val('');
2423 var axis = this.name.replace("CYL", "AXIS");
2424 $("#"+axis).val('');
2425 submit_form($(this));
2426 return;
2427 } else if (sphere.length > 0) {
2428 if (mid.match(/^[\+\-]?\d{1}$/)) {
2429 mid = mid+".00";
2431 if (mid.match(/^(\d)(\d)$/)) {
2432 mid = mid[0] + '.' +mid[1];
2435 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2436 if (mid.match(/\.[05]$/)) {
2437 mid = mid + '0';
2439 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2440 if (mid.match(/\.[27]$/)) {
2441 mid = mid + '5';
2443 //if mid is +2. make it +2.00
2444 if (mid.match(/\.$/)) {
2445 mid = mid + '00';
2447 if (mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)) {
2448 var front = mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)[1];
2449 var back = mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)[2];
2450 if (front =='') front ='0';
2451 mid = front + "." + back;
2453 if (!$('#PREFS_CYL').val()) {
2454 $('#PREFS_CYL').val('+');
2455 update_PREFS();
2457 if (!mid.match(/^(\+|\-){1}/) && (sphere.length > 0)) {
2458 //no +/- sign at the start of the field.
2459 //ok so there is a preference set
2460 //Since it doesn't start with + or - then give it the preference value
2461 mid = $('#PREFS_CYL').val() + mid;
2462 } else if (mid.match(/^(\+|\-){1}/)) {
2463 pref = mid.match(/^(\+|\-){1}/)[0];
2464 //so they used a value + or - at the start of the field.
2465 //The only reason to work on this is to change to cylinder preference
2466 if ($('#PREFS_CYL').val() != pref){
2467 //and that is what they are doing here
2468 $('#PREFS_CYL').val(pref);
2469 update_PREFS();
2472 $(this).val(mid);
2475 //bootstrap menu functions
2476 $("[class='dropdown-toggle']").hover(function(){
2477 $("[class='dropdown-toggle']").parent().removeClass('open');
2478 var menuitem = this.id.match(/(.*)/)[1];
2479 //if the menu is active through a prior click, show it
2480 // Have to override Bootstrap then
2481 if ($("#menustate").val() !="1") { //menu not active -> ignore
2482 $("#"+menuitem).css("background-color", "#C9DBF2");
2483 $("#"+menuitem).css("color","#000"); /*#262626;*/
2484 } else { //menu is active -> respond
2485 $("#"+menuitem).css("background-color", "#1C5ECF");
2486 $("#"+menuitem).css("color","#fff"); /*#262626;*/
2487 $("#"+menuitem).css("text-decoration","none");
2488 $("#"+menuitem).parent().addClass('open');
2490 },function() {
2491 var menuitem = this.id.match(/(.*)/)[1];
2492 $("#"+menuitem).css("color","#000"); /*#262626;*/
2493 $("#"+menuitem).css("background-color", "#C9DBF2");
2496 $("[class='dropdown-toggle']").click(function() {
2497 $("#menustate").val('1');
2498 var menuitem = this.id.match(/(.*)/)[1];
2499 $("#"+menuitem).css("background-color", "#1C5ECF");
2500 $("#"+menuitem).css("color","#fff"); /*#262626;*/
2501 $("#"+menuitem).css("text-decoration","none");
2503 $("#right-panel-link, #close-panel-bt,#right-panel-link_2").click(function() {
2504 if ($("#PREFS_PANEL_RIGHT").val() =='1') {
2505 $("#PREFS_PANEL_RIGHT").val('0');
2506 } else {
2507 $("#PREFS_PANEL_RIGHT").val('1');
2509 update_PREFS();
2511 $("[name^='menu_']").click(function() {
2512 $("[name^='menu_']").removeClass('active');
2513 var menuitem = this.id.match(/menu_(.*)/)[1];
2514 $(this).addClass('active');
2515 $("#menustate").val('1');
2516 menu_select(menuitem);
2518 // set display functions for Draw panel appearance
2519 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2520 var zones = ["PMH","HPI","EXT","ANTSEG","RETINA","NEURO","IMPPLAN"];
2521 for (index = '0'; index < zones.length; ++index) {
2522 if ($("#PREFS_"+zones[index]+"_RIGHT").val() =='DRAW') {
2523 show_DRAW_section(zones[index]);
2524 } else if ($("#PREFS_"+zones[index]+"_RIGHT").val() =='QP') {
2525 show_QP_section(zones[index]);
2528 $("body").on("click","[name$='_text_view']" , function() {
2529 var header = this.id.match(/(.*)_text_view$/)[1];
2530 $("#"+header+"_text_list").toggleClass('wide_textarea');
2531 $("#"+header+"_text_list").toggleClass('narrow_textarea');
2532 $(this).toggleClass('fa-plus-square-o');
2533 $(this).toggleClass('fa-minus-square-o');
2534 if (header != /PRIOR/) {
2535 var imagine = $("#PREFS_"+header+"_VIEW").val();
2536 imagine ^= true;
2537 $("#PREFS_"+header+"_VIEW").val(imagine);
2538 update_PREFS();
2540 return false;
2542 $("body").on("change", "select", function(e){
2543 if (this.name.match(/PRIOR_(.*)/)) {
2544 var new_section = this.name.match(/PRIOR_(.*)/);
2545 if (new_section[1] =='') return;
2546 if (new_section[1] == /\_/){
2547 return;
2549 var newValue = this.value;
2550 if (newValue == $("#form_id").val()) {
2551 if (new_section[1] =="ALL") {
2552 //click updates prefs too
2553 $('#EXAM_QP').trigger("click");
2554 } else {
2555 $('#BUTTON_QP_'+new_section[1]).trigger("click");
2557 return;
2559 //now go get the prior page via ajax
2560 var newValue = this.value;
2561 $("#PRIORS_"+ new_section[1] +"_left_text").removeClass('nodisplay');
2562 $("#DRAWS_" + new_section[1] + "_right").addClass('nodisplay');
2563 $("#QP_" + new_section[1]).addClass('nodisplay');
2565 if (new_section[1] =="ALL") {
2566 show_PRIORS();
2567 show_PRIORS_section("ALL",newValue);
2568 show_PRIORS_section("EXT",newValue);
2569 show_PRIORS_section("ANTSEG",newValue);
2570 show_PRIORS_section("RETINA",newValue);
2571 show_PRIORS_section("NEURO",newValue);
2572 show_PRIORS_section("IMPPLAN",newValue);
2573 } else {
2574 show_PRIORS_section(new_section[1],newValue);
2578 $("body").on("click","[id^='Close_PRIORS_']", function() {
2579 var new_section = this.id.match(/Close_PRIORS_(.*)$/)[1];
2580 $("#PRIORS_"+ new_section +"_left_text").addClass('nodisplay');
2581 $("#QP_" + new_section).removeClass('nodisplay');
2583 $("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").mouseover(function() {
2584 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2586 $("#pupils,#vision_tab,[name='CTL']").mouseout(function() {
2587 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline');
2589 $("#pupils").click(function(){
2590 if ($("#dim_pupils_panel").hasClass("nodisplay")) {
2591 $("#dim_pupils_panel").removeClass('nodisplay');
2592 } else {
2593 $("#dim_pupils_panel").fadeToggle();
2596 $("#vision_tab").click(function(){
2597 $("#REFRACTION_sections").toggleClass('nodisplay');
2598 ($("#PREFS_VA").val() =='1') ? ($("#PREFS_VA").val('0')) : $("#PREFS_VA").val('1');
2600 //set wearing to single vision or bifocal? Bifocal
2601 $(".WNEAR").removeClass('nodisplay');
2602 $("#WNEARODAXIS").addClass('nodisplay');
2603 $("#WNEARODCYL").addClass('nodisplay');
2604 $("#WNEARODPRISM").addClass('nodisplay');
2605 $("#WNEAROSAXIS").addClass('nodisplay');
2606 $("#WNEAROSCYL").addClass('nodisplay');
2607 $("#WNEAROSPRISM").addClass('nodisplay');
2608 $("#Single").click(function(){
2609 $("#WNEARODAXIS").addClass('nodisplay');
2610 $("#WNEARODCYL").addClass('nodisplay');
2611 $("#WNEARODPRISM").addClass('nodisplay');
2612 $("#WODADD2").addClass('nodisplay');
2613 $("#WOSADD2").addClass('nodisplay');
2614 $("#WNEAROSAXIS").addClass('nodisplay');
2615 $("#WNEAROSCYL").addClass('nodisplay');
2616 $("#WNEAROSPRISM").addClass('nodisplay');
2617 $(".WSPACER").removeClass('nodisplay');
2619 $("#Bifocal").click(function(){
2620 $(".WSPACER").addClass('nodisplay');
2621 $(".WNEAR").removeClass('nodisplay');
2622 $(".WMid").addClass('nodisplay');
2623 $(".WHIDECYL").removeClass('nodisplay');
2624 $("[name=RX]").val(["1"]);
2625 $("#WNEARODAXIS").addClass('nodisplay');
2626 $("#WNEARODCYL").addClass('nodisplay');
2627 $("#WNEARODPRISM").addClass('nodisplay');
2628 $("#WNEAROSAXIS").addClass('nodisplay');
2629 $("#WNEAROSCYL").addClass('nodisplay');
2630 $("#WNEAROSPRISM").addClass('nodisplay');
2631 $("#WODADD2").removeClass('nodisplay');
2632 $("#WOSADD2").removeClass('nodisplay');
2634 $("#Trifocal").click(function(){
2635 $(".WSPACER").addClass('nodisplay');
2636 $(".WNEAR").removeClass('nodisplay');
2637 $(".WMid").removeClass('nodisplay');
2638 $(".WHIDECYL").addClass('nodisplay');
2639 $("[name=RX]").val(["2"]);
2640 $("#WNEARODAXIS").addClass('nodisplay');
2641 $("#WNEARODCYL").addClass('nodisplay');
2642 $("#WNEARODPRISM").addClass('nodisplay');
2643 $("#WNEAROSAXIS").addClass('nodisplay');
2644 $("#WNEAROSCYL").addClass('nodisplay');
2645 $("#WNEAROSPRISM").addClass('nodisplay');
2646 $("#WODADD2").removeClass('nodisplay');
2647 $("#WOSADD2").removeClass('nodisplay');
2649 $("#Progressive").click(function(){
2650 $(".WSPACER").addClass('nodisplay');
2651 $(".WNEAR").removeClass('nodisplay');
2652 $(".WMid").addClass('nodisplay');
2653 $(".WHIDECYL").removeClass('nodisplay');
2654 $("[name=RX]").val(["3"]);
2655 $("#WNEARODAXIS").addClass('nodisplay');
2656 $("#WNEARODCYL").addClass('nodisplay');
2657 $("#WNEARODPRISM").addClass('nodisplay');
2658 $("#WNEAROSAXIS").addClass('nodisplay');
2659 $("#WNEAROSCYL").addClass('nodisplay');
2660 $("#WNEAROSPRISM").addClass('nodisplay');
2661 $("#WODADD2").removeClass('nodisplay');
2662 $("#WOSADD2").removeClass('nodisplay');
2664 $("[name=W_width_display]").click(function() {
2665 if ($("#PREFS_W_width").val() !="1") {
2666 $("#PREFS_W_width").val('1');
2667 //make each display W wide
2668 $("[name=currentRX]").addClass('refraction_wide');
2669 $("[name=W_wide]").removeClass('nodisplay');
2670 $("[name=W_wide2]").removeClass('nodisplay');
2671 } else {
2672 $("#PREFS_W_width").val('0');
2673 //make each display W narrow
2674 $("[name=currentRX]").removeClass('refraction_wide');
2675 $("[name=W_wide]").addClass('nodisplay');
2676 $("[name=W_wide2]").addClass('nodisplay');
2678 update_PREFS();
2681 if ($("#PREFS_W_width").val() == '1') {
2682 $("[name=W_wide]").removeClass('nodisplay');
2683 $("[name=W_wide2]").removeClass('nodisplay')
2684 } else {
2685 $("[name=W_wide]").addClass('nodisplay');
2686 $("[name=W_wide2]").addClass('nodisplay');
2688 $("#Amsler-Normal").change(function() {
2689 if ($(this).is(':checked')) {
2690 var number1 = document.getElementById("AmslerOD").src.match(/(Amsler_\d)/)[1];
2691 document.getElementById("AmslerOD").src = document.getElementById("AmslerOD").src.replace(number1,"Amsler_0");
2692 var number2 = document.getElementById("AmslerOS").src.match(/(Amsler_\d)/)[1];
2693 document.getElementById("AmslerOS").src = document.getElementById("AmslerOS").src.replace(number2,"Amsler_0");
2694 $("#AMSLEROD").val("0");
2695 $("#AMSLEROS").val("0");
2696 $("#AmslerODvalue").text("0");
2697 $("#AmslerOSvalue").text("0");
2698 submit_form("eye_mag");
2699 return;
2702 $("#PUPIL_NORMAL").change(function() {
2703 if ($(this).is(':checked')) {
2704 $("#ODPUPILSIZE1").val('3.0');
2705 $("#OSPUPILSIZE1").val('3.0');
2706 $("#ODPUPILSIZE2").val('2.0');
2707 $("#OSPUPILSIZE2").val('2.0');
2708 $("#ODPUPILREACTIVITY").val('+2');
2709 $("#OSPUPILREACTIVITY").val('+2');
2710 $("#ODAPD").val('0');
2711 $("#OSAPD").val('0');
2712 submit_form("eye_mag");
2713 return;
2716 $("[name$='PUPILREACTIVITY']").change(function() {
2717 var react = $(this).val();
2718 if (react.match(/^\d{1}$/)) {
2719 react = "+"+react;
2721 $(this).val(react);
2724 $("[name^='EXAM']").mouseover(function(){
2725 $(this).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
2727 $("[name^='EXAM']").mouseout(function(){
2728 $(this).toggleClass("borderShadow2");
2730 $("#AmslerOD, #AmslerOS").click(function() {
2731 if ($('#chart_status').val() !="on") return;
2732 var number1 = this.src.match(/Amsler_(\d)/)[1];
2733 var number2 = +number1 +1;
2734 this.src = this.src.replace('Amsler_'+number1,'Amsler_'+number2);
2735 this.src = this.src.replace('Amsler_6','Amsler_0');
2736 $("#Amsler-Normal").removeAttr('checked');
2737 var number3 = this.src.match(/Amsler_(\d)/)[1];
2738 this.html = number3;
2739 if (number3 =="6") {
2740 number3 = "0";
2742 if ($(this).attr("id")=="AmslerOD") {
2743 $("#AmslerODvalue").text(number3);
2744 $('#AMSLEROD').val(number3);
2745 } else {
2746 $('#AMSLEROS').val(number3);
2747 $("#AmslerOSvalue").text(number3);
2749 var title = "#"+$(this).attr("id")+"_tag";
2752 $("#AmslerOD, #AmslerOS").mouseout(function() {
2753 submit_form("eye_mag");
2755 $("[name^='ODVF'],[name^='OSVF']").click(function() {
2756 if ($(this).is(':checked') == true) {
2757 $("#FieldsNormal").prop('checked', false);
2758 $(this).val('1');
2759 }else{
2760 $(this).val('0');
2761 $(this).prop('checked', false);
2763 submit_form("eye_mag");
2765 $("#FieldsNormal").click(function() {
2766 if ($(this).is(':checked')) {
2767 $("#ODVF1").removeAttr('checked');
2768 $("#ODVF2").removeAttr('checked');
2769 $("#ODVF3").removeAttr('checked');
2770 $("#ODVF4").removeAttr('checked');
2771 $("#OSVF1").removeAttr('checked');
2772 $("#OSVF2").removeAttr('checked');
2773 $("#OSVF3").removeAttr('checked');
2774 $("#OSVF4").removeAttr('checked');
2777 $("[id^='EXT_prefix']").change(function() {
2778 var newValue =$('#EXT_prefix').val();
2779 newValue = newValue.replace('+', '');
2780 if (newValue =="off") {$(this).val('');}
2781 if (newValue =="clear") {
2782 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
2783 $(this).val('');
2784 $(".EXT").val('');
2786 } else {
2787 $("[name^='EXT_prefix_']").removeClass('eye_button_selected');
2788 $("#EXT_prefix_"+ newValue).addClass("eye_button_selected");
2791 $("#ANTSEG_prefix").change(function() {
2792 var newValue = $(this).val().replace('+', '');
2793 if ($(this).value =="off") {$(this).val('');}
2794 if (newValue =="clear") {
2795 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
2796 $(this).val('');
2797 $(".ANTSEG").val('');
2799 } else {
2800 $("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
2801 $("#ANTSEG_prefix_"+ newValue).addClass("eye_button_selected");
2804 $("#RETINA_prefix").change(function() {
2805 var newValue = $("#RETINA_prefix").val().replace('+', '');
2806 if ($(this).value =="off") {$(this).val('');}
2807 if (newValue =="clear") {
2808 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
2809 $(this).val('');
2810 $(".RETINA").val('');
2812 } else {
2813 $("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
2814 $("#RETINA_prefix_"+ newValue).addClass("eye_button_selected");
2817 $("#NEURO_ACT_zone").change(function() {
2818 var newValue = $(this).val();
2819 $("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
2820 $("#NEURO_ACT_zone_"+ newValue).addClass("eye_button_selected");
2821 $("#PREFS_ACT_SHOW").val(newValue);
2822 update_PREFS;
2823 $("#ACT_tab_"+newValue).trigger('click');
2825 $("#NEURO_side").change(function() {
2826 var newValue = $(this).val();
2827 $("[name^='NEURO_side']").removeClass('eye_button_selected');
2828 $("#NEURO_side_"+ newValue).addClass("eye_button_selected");
2830 $('.ACT').focus(function() {
2831 var id = this.id.match(/ACT(\d*)/);
2832 $('#NEURO_field').val(''+id[1]).trigger('change');
2834 $("#NEURO_field").change(function() {
2835 var newValue = $(this).val();
2836 $("[name^='NEURO_field']").removeClass('eye_button_selected');
2837 $("#NEURO_field_"+ newValue).addClass("eye_button_selected");
2838 $('.ACT').each(function(i){
2839 var color = $(this).css('background-color');
2840 if ((color == 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
2841 $(this).css("background-color","red");
2844 //change to highlight field in zone entry is for
2845 var zone = $("#NEURO_ACT_zone").val();
2846 $("#ACT"+newValue+zone).css("background-color","yellow");
2848 $("[name^='NEURO_ACT_strab']").click(function() {
2849 var newValue = $(this).val();
2850 $("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2851 $(this).addClass("eye_button_selected");
2853 $("#NEURO_value").change(function() {
2854 var newValue = $(this).val();
2855 $("[name^='NEURO_value']").removeClass('eye_button_selected');
2856 $("#NEURO_value_"+ newValue).addClass("eye_button_selected");
2857 if (newValue == "ortho") {
2858 $("#NEURO_ACT_strab").val('');
2859 $("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2860 $("#NEURO_side").val('');
2861 $("[name^='NEURO_side']").removeClass('eye_button_selected');
2864 $("#NEURO_RECORD").mouseover(function() {
2865 $("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
2867 $("#NEURO_RECORD").mouseout(function() {
2868 $("#NEURO_RECORD").removeClass('borderShadow2');
2870 $("#NEURO_RECORD").mousedown(function() {
2871 $("#NEURO_RECORD").removeClass('borderShadow2');
2872 $(this).toggleClass('button_over');
2874 $("#NEURO_RECORD").mouseup(function() {
2875 $("#NEURO_RECORD").removeClass('borderShadow2');
2876 $(this).toggleClass('button_over');
2878 $("#NEURO_RECORD").click(function() {
2879 //find out the field we are updating
2880 var number = $("#NEURO_field").val();
2881 var zone = $("#NEURO_ACT_zone").val();
2882 var strab = $("#NEURO_value").val() + ' '+ $("#NEURO_side").val() + $("#NEURO_ACT_strab").val();
2884 $("#ACT"+number+zone).val(strab).css("background-color","#F0F8FF");
2889 $("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseover(function(){
2890 $(this).addClass("borderShadow2");
2892 $("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseout(function(){
2893 $(this).removeClass("borderShadow2");
2895 $("[id$='_lightswitch']").click(function() {
2896 var section = "#"+this.id.match(/(.*)_lightswitch$/)[1];
2897 var section2 = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2898 var elem = document.getElementById("PREFS_"+section2);
2899 $("#PREFS_VA").val('0');
2900 if (section2 != "IOP")$("#REFRACTION_sections").removeClass('nodisplay');
2901 if (elem.value == "0" || elem.value =='') {
2902 elem.value='1';
2903 if (section2 =="ADDITIONAL") {
2904 $("#LayerVision_ADDITIONAL").removeClass('nodisplay');
2906 if (section2 =="IOP") {
2907 $("#LayerVision_IOP").removeClass('nodisplay');
2908 //plot_IOPs();
2910 $(section).removeClass('nodisplay');
2911 $(this).addClass("buttonRefraction_selected");
2912 } else {
2913 elem.value='0';
2914 $(section).addClass('nodisplay');
2915 if (section2 =="VAX") {
2916 $("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
2918 if (section2 =="IOP") {
2919 $("#LayerVision_IOP").addClass('nodisplay');
2921 $(this).removeClass("buttonRefraction_selected");
2923 $(this).css( 'cursor', 'pointer' );
2924 update_PREFS();
2927 $('[id$=_lightswitch]').mouseover(function() {
2928 $(this).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
2930 var section = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2931 if (section == 'IOP') {
2932 $("#LayerTension").addClass("borderShadow2");
2933 } else {
2934 $("#LayerVision").addClass("borderShadow2");
2937 $('[id$=_lightswitch]').mouseout(function() {
2938 var section2 = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2939 var elem = document.getElementById("PREFS_"+section2);
2941 if (elem.value != "1") {
2942 $(this).removeClass('buttonRefraction_selected');
2943 } else {
2944 $(this).addClass('buttonRefraction_selected');
2945 } });
2947 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
2948 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
2949 // "-" is still == "-"
2950 $("input[class^='jaeger'],input[name$='VA'],input[name$='VA_copy'],input[name$='VA_copy_brd'],input[name$='SPH'],input[name$='CYL'],input[name$='REACTIVITY'],input[name$='APD']").on('keyup', function(e) {
2951 if (e.keyCode=='61' || e.keyCode=='74') {
2952 now = $(this).val();
2953 now = now.replace(/=/g,"+").replace(/^j/g,"J");
2954 $(this).val(now);
2957 //useful to make all VA fields stay in sync
2958 $("input[name$='VA']").on('change',function() {
2959 var hereValue = $(this).val();
2960 var newValue = $(this).attr('name').replace('VA', 'VA_copy');
2961 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
2962 $("#" + newValue + "_brd").val(hereValue).css("background-color","#F0F8FF");;
2964 $("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
2965 var hereValue = $(this).val();
2966 hereValue = hereValue.replace(/=$/g,"+").replace(/^j/g,"J");
2967 $(this).val(hereValue);
2968 if (this.name.match(/_1$/)) {
2969 var newValue = $(this).attr('name').replace('VA_1', 'VA_1_copy');
2970 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
2971 $("#" + newValue + "_brd").val(hereValue).css("background-color","#F0F8FF");
2975 $("input[name$='_copy']").blur(function() {
2976 var hereValue = $(this).val();
2977 var newValue = $(this).attr('name').replace('_copy', '');
2978 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
2979 $("#" + newValue + "_copy_brd").val(hereValue).css("background-color","#F0F8FF");;
2981 $("input[name$='_copy_brd']").change(function() {
2982 var hereValue = $(this).val();
2983 var newValue = $(this).attr('name').replace('_copy_brd', '');
2984 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
2985 $("#" + newValue + "_copy").val(hereValue).css("background-color","#F0F8FF");;
2987 $("[name^='more_']").mouseout(function() {
2988 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline');
2990 $("[name^='more_']").click(function() {
2991 $("#Visions_A").toggleClass('nodisplay');
2992 $("#Visions_B").toggleClass('nodisplay');
2994 $("#EXAM_defaults").click(function() {
2995 <?php
2996 // This query is specific to the provider.
2997 $query = "select seq from list_options where option_id=?";
2998 $result = sqlStatement($query,array("Eye_defaults_$providerID"));
3000 $list = sqlFetchArray($result);
3001 $SEQ = $list['seq'];
3002 if (!$SEQ) {
3003 // If there is no list for this provider, we create it here.
3004 // Instead of the below code, we should be copying the Eye_Defaults_for_GENERAL
3005 // to Eye_defaults_$providerID
3006 // This list is part of the idea to create a way to add Eye_defaults_$providerID specific to the
3007 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3008 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3009 // Also, each field should be "display:none" if desired, via another user specific list.
3010 // This would be another list. Let's see if the public likes the form itself before
3011 // developing these features...
3012 $query = "SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'";
3013 $pres = sqlStatement($query);
3014 $maxseq = sqlFetchArray($pres);
3016 $seq=$maxseq['maxseq'];
3017 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`) VALUES
3018 ('lists', ?, ?, ?, '1', '0', '', '', '')";
3019 sqlStatement($query,array("Eye_defaults_$providerID","Eye Exam Defaults $providerNAME ",$seq));
3020 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`,`notes`,`seq`) VALUES
3021 ('Eye_defaults_".$providerID."','RUL','normal lids and lashes','EXT','10'),
3022 ('Eye_defaults_".$providerID."','LUL','normal lids and lashes','EXT','20'),
3023 ('Eye_defaults_".$providerID."','RLL','good tone','EXT','30'),
3024 ('Eye_defaults_".$providerID."','LLL','good tone','EXT','40'),
3025 ('Eye_defaults_".$providerID."','RBROW','no brow ptosis','EXT','50'),
3026 ('Eye_defaults_".$providerID."','LBROW','no brow ptosis','EXT','60'),
3027 ('Eye_defaults_".$providerID."','RMCT','no masses','EXT','70'),
3028 ('Eye_defaults_".$providerID."','LMCT','no masses','EXT','80'),
3029 ('Eye_defaults_".$providerID."','RADNEXA','normal lacrimal gland and orbit','EXT','90'),
3030 ('Eye_defaults_".$providerID."','LADNEXA','normal lacrimal gland and orbit','EXT','100'),
3031 ('Eye_defaults_".$providerID."','RMRD','+3','EXT','110'),
3032 ('Eye_defaults_".$providerID."','LMRD','+3','EXT','120'),
3033 ('Eye_defaults_".$providerID."','RLF','17','EXT','130'),
3034 ('Eye_defaults_".$providerID."','LLF','17','EXT','140'),
3035 ('Eye_defaults_".$providerID."','OSCONJ','quiet','ANTSEG','150'),
3036 ('Eye_defaults_".$providerID."','ODCONJ','quiet','ANTSEG','160'),
3037 ('Eye_defaults_".$providerID."','ODCORNEA','clear','ANTSEG','170'),
3038 ('Eye_defaults_".$providerID."','OSCORNEA','clear','ANTSEG','180'),
3039 ('Eye_defaults_".$providerID."','ODAC','deep and quiet','ANTSEG','190'),
3040 ('Eye_defaults_".$providerID."','OSAC','deep and quiet','ANTSEG','200'),
3041 ('Eye_defaults_".$providerID."','ODLENS','clear','ANTSEG','210'),
3042 ('Eye_defaults_".$providerID."','OSLENS','clear','ANTSEG','220'),
3043 ('Eye_defaults_".$providerID."','ODIRIS','round','ANTSEG','230'),
3044 ('Eye_defaults_".$providerID."','OSIRIS','round','ANTSEG','240'),
3045 ('Eye_defaults_".$providerID."','ODPUPILSIZE1','3','NEURO','250'),
3046 ('Eye_defaults_".$providerID."','ODPUPILSIZE2','2','NEURO','260'),
3047 ('Eye_defaults_".$providerID."','ODPUPILREACTIVITY','+2','NEURO','270'),
3048 ('Eye_defaults_".$providerID."','ODAPD','0','NEURO','280'),
3049 ('Eye_defaults_".$providerID."','OSPUPILSIZE1','3','NEURO','290'),
3050 ('Eye_defaults_".$providerID."','OSPUPILSIZE2','2','NEURO','300'),
3051 ('Eye_defaults_".$providerID."','OSPUPILREACTIVITY','+2','NEURO','310'),
3052 ('Eye_defaults_".$providerID."','OSAPD','0','NEURO','320'),
3053 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION1','0','NEURO','330'),
3054 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION2','0','NEURO','340'),
3055 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION3','0','NEURO','350'),
3056 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION4','0','NEURO','360'),
3057 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION5','0','NEURO','370'),
3058 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION1','0','NEURO','380'),
3059 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION2','0','NEURO','390'),
3060 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION3','0','NEURO','400'),
3061 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION4','0','NEURO','410'),
3062 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION5','0','NEURO','420'),
3063 ('Eye_defaults_".$providerID."','ODDISC','pink','RETINA','430'),
3064 ('Eye_defaults_".$providerID."','OSDISC','pink','RETINA','440'),
3065 ('Eye_defaults_".$providerID."','ODCUP','0.3','RETINA','450'),
3066 ('Eye_defaults_".$providerID."','OSCUP','0.3','RETINA','460'),
3067 ('Eye_defaults_".$providerID."','ODMACULA','flat','RETINA','470'),
3068 ('Eye_defaults_".$providerID."','OSMACULA','flat','RETINA','480'),
3069 ('Eye_defaults_".$providerID."','ODVESSELS','2:3','RETINA','490'),
3070 ('Eye_defaults_".$providerID."','OSVESSELS','2:3','RETINA','500'),
3071 ('Eye_defaults_".$providerID."','ODPERIPH','flat','RETINA','510'),
3072 ('Eye_defaults_".$providerID."','OSPERIPH','flat','RETINA','520')";
3073 sqlStatement($query);
3075 $query = "select * from list_options where list_id =? and activity='1' order by seq";
3077 $DEFAULT_data =sqlStatement($query,array("Eye_defaults_$providerID"));
3078 while ($row = sqlFetchArray($DEFAULT_data)) {
3079 //$row['notes'] is the clinical zone (EXT,ANTSEG,RETINA,NEURO)
3080 //$row['option_id'] is the field name
3081 //$row['title'] is the default value to use for this provider
3082 ${$row[notes]}[$row[option_id]] = $row[title]; //This builds each clinical section into its own array (used below)
3083 echo '$("#'.$row['option_id'].'").val("'.$row['title'].'").css("background-color","beige");
3087 submit_form("eye_mag");
3090 $("#EXT_defaults").click(function() {
3091 <?php
3092 foreach ($EXT as $item => $value) {
3093 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3097 submit_form("eye_mag");
3100 $("#ANTSEG_defaults").click(function() {
3101 <?php
3102 foreach ($ANTSEG as $item => $value) {
3103 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3107 submit_form("eye_mag");
3109 $("#RETINA_defaults").click(function() {
3110 <?php
3111 foreach ($RETINA as $item => $value) {
3112 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3116 submit_form("eye_mag");
3118 $("#NEURO_defaults").click(function() {
3119 <?php
3120 foreach ($NEURO as $item => $value) {
3121 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3125 submit_form("eye_mag");
3129 $("#MOTILITYNORMAL").click(function() {
3130 $("#MOTILITY_RS").val('0');
3131 $("#MOTILITY_RI").val('0');
3132 $("#MOTILITY_RR").val('0');
3133 $("#MOTILITY_RL").val('0');
3134 $("#MOTILITY_LS").val('0');
3135 $("#MOTILITY_LI").val('0');
3136 $("#MOTILITY_LR").val('0');
3137 $("#MOTILITY_LL").val('0');
3139 $("#MOTILITY_RRSO").val('0');
3140 $("#MOTILITY_RRIO").val('0');
3141 $("#MOTILITY_RLSO").val('0');
3142 $("#MOTILITY_RLIO").val('0');
3143 $("#MOTILITY_LRSO").val('0');
3144 $("#MOTILITY_LRIO").val('0');
3145 $("#MOTILITY_LLSO").val('0');
3146 $("#MOTILITY_LLIO").val('0');
3148 for (index = '0'; index < 5; ++index) {
3149 $("#MOTILITY_RS_"+index).html('');
3150 $("#MOTILITY_RI_"+index).html('');
3151 $("#MOTILITY_RR_"+index).html('');
3152 $("#MOTILITY_RL_"+index).html('');
3153 $("#MOTILITY_LS_"+index).html('');
3154 $("#MOTILITY_LI_"+index).html('');
3155 $("#MOTILITY_LR_"+index).html('');
3156 $("#MOTILITY_LL_"+index).html('');
3158 $("#MOTILITY_RRSO_"+index).html('');
3159 $("#MOTILITY_RRIO_"+index).html('');
3160 $("#MOTILITY_RLSO_"+index).html('');
3161 $("#MOTILITY_RLIO_"+index).html('');
3162 $("#MOTILITY_LRSO_"+index).html('');
3163 $("#MOTILITY_LRIO_"+index).html('');
3164 $("#MOTILITY_LLSO_"+index).html('');
3165 $("#MOTILITY_LLIO_"+index).html('');
3167 submit_form('eye_mag');
3170 $("[name^='MOTILITY_']").click(function() {
3171 $("#MOTILITYNORMAL").removeAttr('checked');
3173 if (this.id.match(/(MOTILITY_([A-Z]{4}))_(.)/)) {
3174 var zone = this.id.match(/(MOTILITY_([A-Z]{4}))_(.)/);
3175 var index = '0';
3176 var valued = isNaN($("#"+zone[1]).val());
3177 if ((zone[2] =='RLSO')||(zone[2] =='LLSO')||(zone[2] =='RRIO')||(zone[2] =='LRIO')) {
3178 //find or make a hash tage for "\"
3179 var hash_tag = '<i class="fa fa-minus"></i>';
3180 } else {
3181 //find or make a hash tage for "/"
3182 var hash_tag = '<i class="fa fa-minus"></i>';
3184 } else {
3185 var zone = this.id.match(/(MOTILITY_..)_(.)/);
3186 var section = this.id.match(/MOTILITY_(.)(.)_/);
3187 var section2 = section[2];
3188 var Eye = section[1];
3189 var SupInf = section2.search(/S|I/);
3190 var RorLside = section2.search(/R|L/);
3193 if (RorLside =='0') {
3194 var hash_tag = '<i class="fa fa-minus rotate-left"></i>';
3195 } else {
3196 var hash_tag = '<i class="fa fa-minus"></i>';
3199 if (valued != true && $("#"+zone[1]).val() <'4') {
3200 valued=$("#"+zone[1]).val();
3201 valued++;
3202 } else {
3203 valued = '0';
3204 $("#"+zone[1]).val('0');
3207 $("#"+zone[1]).val(valued);
3209 for (index = '0'; index < 5; ++index) {
3210 $("#"+zone[1]+"_"+index).html('');
3212 if (valued > '0') {
3213 for (index =1; index < (valued+1); ++index) {
3214 $("#"+zone[1]+"_"+index).html(hash_tag);
3218 submit_form('3');
3221 $("[name^='Close_']").click(function() {
3222 var section = this.id.match(/Close_(.*)$/)[1];
3223 if (this.id.match(/Close_W_(.*)$/) != null) {
3224 var W_section = this.id.match(/Close_W_(.*)$/)[1];
3225 if (W_section > '1') {
3226 $('#LayerVision_W_'+W_section).addClass('nodisplay');
3227 $('[name$=SPH_'+W_section+']').val('');
3228 $('[name$=CYL_'+W_section+']').val('');
3229 $('[name$=AXIS_'+W_section+']').val('');
3230 $('[name$=ADD_'+W_section+']').val('');
3231 $('[name$=PRISM_'+W_section+']').val('');
3232 $('[name$=VA_'+W_section+']').val('');
3233 $('#RX_TYPE_'+W_section).val('');
3234 $('#Add_Glasses').removeClass('nodisplay');
3235 $('#W_'+W_section).val('');
3236 submit_form('4');
3237 } else {
3238 $("#LayerVision_W_lightswitch").click();
3240 } else if (section =="ACTMAIN") {
3241 $("#ACTTRIGGER").trigger( "click" );
3242 } else {
3243 $("#LayerVision_"+section+"_lightswitch").click();
3248 $("#EXAM_DRAW, #BUTTON_DRAW_menu, #PANEL_DRAW").click(function() {
3249 if ($("#PREFS_CLINICAL").value !='0') {
3250 show_right();
3251 $("#PREFS_CLINICAL").val('0');
3252 update_PREFS();
3254 if ($("#PREFS_EXAM").val() != 'DRAW') {
3255 $("#PREFS_EXAM").val('DRAW');
3256 $("#EXAM_QP").removeClass('button_selected');
3257 $("#EXAM_DRAW").addClass('button_selected');
3258 $("#EXAM_TEXT").removeClass('button_selected');
3259 update_PREFS();
3261 show_DRAW();
3263 $("#EXAM_QP,#PANEL_QP").click(function() {
3264 if ($("#PREFS_CLINICAL").value !='0') {
3265 $("#PREFS_CLINICAL").val('0');
3266 update_PREFS();
3268 if ($("#PREFS_EXAM").value != 'QP') {
3269 $("#PREFS_EXAM").val('QP');
3270 $("#EXAM_QP").addClass('button_selected');
3271 $("#EXAM_DRAW").removeClass('button_selected');
3272 $("#EXAM_TEXT").removeClass('button_selected');
3273 update_PREFS();
3275 show_QP();
3276 scrollTo("EXT_left");
3279 $("#EXAM_TEXT,#PANEL_TEXT").click(function() {
3281 // also hide QP, DRAWs, and PRIORS
3282 hide_DRAW();
3283 hide_QP();
3284 hide_PRIORS();
3285 hide_right();
3286 show_TEXT();
3287 for (index = '0'; index < zones.length; ++index) {
3288 $("#PREFS_"+zones[index]+"_RIGHT").val(0);
3290 update_PREFS();
3292 $("#EXAM_DRAW").removeClass('button_selected');
3293 $("#EXAM_QP").removeClass('button_selected');
3294 $("#EXAM_TEXT").addClass('button_selected');
3295 scrollTo("EXT_left");
3297 $("[id^='BUTTON_TEXT_']").click(function() {
3298 var zone = this.id.match(/BUTTON_TEXT_(.*)/)[1];
3299 if (zone != "menu") {
3300 $("#"+zone+"_right").addClass('nodisplay');
3301 $("#"+zone+"_left").removeClass('display');
3302 $("#"+zone+"_left_text").removeClass('display');
3303 $("#PREFS_"+zone+"_RIGHT").val(0);
3304 update_PREFS();
3306 show_TEXT();
3307 scrollTo("EXT_left");
3309 $("[id^='BUTTON_TEXTD_']").click(function() {
3310 var zone = this.id.match(/BUTTON_TEXTD_(.*)/)[1];
3311 if (zone != "menu") {
3312 if ((zone =="PMH") || (zone == "HPI")) {
3313 $("#PMH_right").addClass('nodisplay');
3314 $("#PREFS_PMH_RIGHT").val(1);
3315 $("#HPI_right").addClass('nodisplay');
3316 $("#PREFS_HPI_RIGHT").val(1);
3317 var reset = $("#HPI_1").height();
3318 $("#PMH_1").height(reset);
3319 $("#PMH_left").height(reset-40);
3320 $("#LayerTechnical_sections_1").css("clear","both");
3321 } else {
3322 $("#"+zone+"_right").addClass('nodisplay');
3323 $("#PREFS_"+zone+"_RIGHT").val(1);
3325 scrollTo(zone+"_left");
3326 update_PREFS();
3331 $("#EXAM_TEXT").addClass('button_selected');
3332 if (($("#PREFS_CLINICAL").val() !='1')) {
3333 var actionQ = "#EXAM_"+$("#PREFS_EXAM").val();
3334 $(actionQ).trigger('click');
3335 } else {
3336 $("#EXAM_TEXT").addClass('button_selected');
3338 if ($("#ANTSEG_prefix").val() > '') {
3339 $("#ANTSEG_prefix_"+$("#ANTSEG_prefix").val()).addClass('button_selected');
3340 } else {
3341 $("#ANTSEG_prefix").val('off').trigger('change');
3343 $("[name^='ACT_tab_']").mouseover(function() {
3344 $(this).toggleClass('underline').css( 'cursor', 'pointer' );
3346 $("[name^='ACT_tab_']").mouseout(function() {
3347 $(this).toggleClass('underline');
3350 $("[name^='ACT_tab_']").click(function() {
3351 var section = this.id.match(/ACT_tab_(.*)/)[1];
3352 $("[name^='ACT_']").addClass('nodisplay');
3353 $("[name^='ACT_tab_']").removeClass('nodisplay').removeClass('ACT_selected').addClass('ACT_deselected');
3354 $("#ACT_tab_" + section).addClass('ACT_selected').removeClass('ACT_deselected');
3355 $("#ACT_" + section).removeClass('nodisplay');
3356 $("#PREFS_ACT_SHOW").val(section);
3357 //selection correct QP zone
3358 $("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3359 $("#NEURO_ACT_zone_"+ section).addClass("eye_button_selected");
3360 $("#NEURO_ACT_zone").val(section);
3361 update_PREFS();
3363 $("#ACTTRIGGER").mouseout(function() {
3364 $("#ACTTRIGGER").toggleClass('buttonRefraction_selected').toggleClass('underline');
3366 if ($("#PREFS_ACT_VIEW").val() == '1') {
3367 $("#ACTMAIN").toggleClass('nodisplay');
3368 $("#NPCNPA").toggleClass('nodisplay');
3369 $("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3370 $("#ACTTRIGGER").toggleClass('underline');
3371 var show = $("#PREFS_ACT_SHOW").val();
3372 $("#ACT_tab_"+show).trigger('click');
3374 $("#ACTTRIGGER").click(function() {
3375 $("#ACTMAIN").toggleClass('nodisplay').toggleClass('ACT_TEXT');
3376 $("#NPCNPA").toggleClass('nodisplay');
3377 $("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3378 $("#ACTTRIGGER").toggleClass('underline');
3379 if ($("#PREFS_ACT_VIEW").val()=='1') {
3380 $("#PREFS_ACT_VIEW").val('0');
3381 } else {
3382 $("#PREFS_ACT_VIEW").val('1');
3384 var show = $("#PREFS_ACT_SHOW").val();
3385 $("#ACT_tab_"+show).trigger('click');
3386 update_PREFS();
3388 $("#NEURO_COLOR").click(function() {
3389 $("#ODCOLOR").val("11/11");
3390 $("#OSCOLOR").val("11/11");
3391 submit_form("eye_mag");
3394 $("#NEURO_COINS").click(function() {
3395 $("#ODCOINS").val("1.00");
3396 //leave currency symbol out unless it is an openEMR defined option
3397 $("#OSCOINS").val("1.00");
3398 submit_form("eye_mag");
3401 $("#NEURO_REDDESAT").click(function() {
3402 $("#ODREDDESAT").val("100");
3403 $("#OSREDDESAT").val("100");
3404 submit_form("eye_mag");
3407 $("[id^='myCanvas_']").mouseout(function() {
3408 var zone = this.id.match(/myCanvas_(.*)/)[1];
3409 submit_canvas(zone);
3411 $("[id^='Undo_']").click(function() {
3412 var zone = this.id.match(/Undo_Canvas_(.*)/)[1];
3413 submit_canvas(zone);
3415 $("[id^='Redo_']").click(function() {
3416 var zone = this.id.match(/Redo_Canvas_(.*)/)[1];
3417 submit_canvas(zone);
3419 $("[id^='Clear_']").click(function() {
3420 var zone = this.id.match(/Clear_Canvas_(.*)/)[1];
3421 submit_canvas(zone);
3423 $("[id^='Base_']").click(function() { //not implemented yet
3424 var zone = this.id.match(/Base_Canvas_(.*)/)[1];
3425 //To change the base img
3426 //delete current image from server
3427 //re-ajax the canvas div
3428 var id_here = document.getElementById('myCanvas_'+zone);
3429 var dataURL = id_here.toDataURL();
3430 top.restoreSession();
3431 $.ajax({
3432 type: "POST",
3433 url: "../../forms/eye_mag/save.php?canvas="+zone+"&id="+$("#form_id").val(),
3434 data: {
3435 imgBase64 : dataURL, //this contains the new strokes, the sketch.js foreground
3436 'zone' : zone,
3437 'visit_date' : $("#visit_date").val(),
3438 'encounter' : $("#encounter").val(),
3439 'pid' : $("#pid").val()
3444 $("#url_"+zone).val("/interface/forms/eye_mag/images/OU_"+zone+"_BASE.png");
3445 canvas.renderAll();
3448 $("#COPY_SECTION").change(function() {
3449 var start = $("#COPY_SECTION").val();
3450 if (start =='') return;
3451 var value = start.match(/(\w*)-(\w*)/);
3452 var zone = value[1];
3453 var copy_from = value[2];
3454 if (zone =="READONLY") copy_from = $("#form_id").val();
3455 var count_changes='0';
3457 var data = {
3458 action : 'copy',
3459 copy : zone,
3460 zone : zone,
3461 copy_to : $("#form_id").val(),
3462 copy_from : copy_from,
3463 pid : $("#pid").val()
3465 if (zone =="READONLY") {
3466 //we are going to update the whole form
3467 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
3468 //We are not ready to actively chart, just looking to see how far along our staff is...
3469 //or maybe just looking ahead to see who's next in the next room?
3470 //Either way, we are looking at a record that at present will be disabled/we cannot change...
3471 // yet it is updating every 10 seconds if another user is making changes.
3473 // READONLY does not show IMPPLAN changes!!!!
3474 } else {
3475 //here we are retrieving an old record to copy forward to today's active chart.
3476 data = $("#"+zone+"_left_text").serialize() + "&" + $.param(data);
3478 top.restoreSession();
3479 $.ajax({
3480 type : 'POST',
3481 dataType : 'json',
3482 url : "../../forms/eye_mag/save.php",
3483 data : data,
3484 success : function(result) {
3485 //we have to process impplan differently
3486 if (zone =='IMPPLAN') {
3487 //we get a json result.IMPPLAN back from the prior visit
3488 //we need to add that to the current list? Replace for now.
3489 build_IMPPLAN(result.IMPPLAN);
3490 store_IMPPLAN(result.IMPPLAN);
3491 // need to make the Plan areas purple?
3492 } else {
3493 $.map(result, function(valhere, keyhere) {
3494 if ($("#"+keyhere).val() != valhere) {
3495 $("#"+keyhere).val(valhere).css("background-color","#CCF");
3496 } else if (keyhere.match(/MOTILITY_/)) {
3497 // Copy forward ductions and versions visually
3498 // Make each blank, and rebuild them
3499 $("[name='"+keyhere+"_1']").html('');
3500 $("[name='"+keyhere+"_2']").html('');
3501 $("[name='"+keyhere+"_3']").html('');
3502 $("[name='"+keyhere+"_4']").html('');
3503 if (keyhere.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO)/)) {
3504 // Show a horizontal (minus) tag. When "/" and "\" fa-icons are available will need to change.
3505 // Maybe just use small font "/" and "\" directly.
3506 hash_tag = '<i class="fa fa-minus"></i>';
3507 } else { //show vertical tag
3508 hash_tag = '<i class="fa fa-minus rotate-left"></i>';
3510 for (index =1; index <= valhere; ++index) {
3511 $("#"+keyhere+"_"+index).html(hash_tag);
3513 } else if (keyhere.match(/^(ODVF|OSVF)\d$/)) {
3514 if (valhere =='1') {
3515 $("#FieldsNormal").prop('checked', false);
3516 $("#"+keyhere).prop('checked', true);
3517 $("#"+keyhere).val('1');
3518 } else {
3519 $("#"+keyhere).val('0');
3520 $("#"+keyhere).prop('checked', false);
3522 } else if (keyhere.match(/AMSLERO(.)/)) {
3523 var sidehere = keyhere.match(/AMSLERO(.)/);
3524 if (valhere < '1') valhere ='0';
3525 $("#"+keyhere).val(valhere);
3526 var srcvalue="AmslerO"+sidehere[1];
3527 document.getElementById(srcvalue).src = document.getElementById(srcvalue).src.replace(/\_\d/g,"_"+valhere);
3528 $("#AmslerO"+sidehere[1]+"value").text(valhere);
3529 } else if (keyhere.match(/VA$/)) {
3530 $("#"+keyhere+"_copy").val(valhere).css("background-color","#F0F8FF");;
3531 $("#"+keyhere+"_copy_brd").val(valhere).css("background-color","#F0F8FF");;
3534 if (zone != "READONLY") { submit_form("eye_mag"); }
3536 }});
3538 $("[id^='BUTTON_DRAW_']").click(function() {
3539 var zone =this.id.match(/BUTTON_DRAW_(.*)$/)[1];
3540 if (zone =="ALL") {
3541 } else {
3542 if ($('#PREFS_'+zone+'_RIGHT').val() =="DRAW") {
3543 $('#BUTTON_TEXTD_'+zone).trigger("click");//closes draw
3544 //maybe this should revert to last right panel state (qp,text)
3545 return;
3547 $("#"+zone+"_1").removeClass('nodisplay');
3548 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
3549 $("#QP_"+zone).addClass('nodisplay');
3550 $("#PRIORS_"+zone+"_left_text").addClass('nodisplay');
3551 $("#Draw_"+zone).removeClass('nodisplay');
3552 $("#PREFS_"+zone+"_RIGHT").val('DRAW');
3553 scrollTo(zone+"_left");
3554 //alert("ok?");
3555 update_PREFS();
3558 $("[id^='BUTTON_QP_']").click(function() {
3559 var zone = this.id.match(/BUTTON_QP_(.*)$/)[1].replace(/_\d*/,'');
3560 if (zone =='IMPPLAN2') {
3561 $('#IMP_start_acc').slideDown();
3562 zone='IMPPLAN';
3564 if ($("#PREFS_"+zone+"_RIGHT").val() =='QP') {
3565 $('#BUTTON_TEXTD_'+zone).trigger("click");
3566 return;
3568 $("#PRIORS_"+zone+"_left_text").addClass('nodisplay');
3569 $("#Draw_"+zone).addClass('nodisplay');
3570 show_QP_section(zone);
3571 $("#PREFS_"+zone+"_RIGHT").val('QP');
3572 if ((zone != 'PMH')&&(zone != 'HPI')) {
3574 if (zone == 'PMH') {
3575 if($('#HPI_right').css('display') == 'none') {
3576 $("#PRIORS_HPI_left_text").addClass('nodisplay');
3577 $("#Draw_HPI").addClass('nodisplay');
3578 show_QP_section('HPI');
3579 $("#PREFS_HPI_RIGHT").val('QP');
3580 //$("html,body").animate({scrollTop: '400'}, "slow");
3582 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3583 $('#PMH_left').height($('#PMH_right').height());
3584 $('#PMH_1').height($('#PMH_right').height()+20);
3585 } else { $('#PMH_1').height($('#HPI_1').height()); }
3587 else if (zone == 'HPI') {
3588 if($('#PMH_right').css('display') == 'none') {
3589 $("#PRIORS_PMH_left_text").addClass('nodisplay');
3590 $("#Draw_PMH").addClass('nodisplay');
3591 show_QP_section('PMH','1');
3592 $("#PREFS_PMH_RIGHT").val('QP');
3594 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3595 $('#PMH_left').height($('#PMH_right').height());
3596 } else { $('#PMH_1').height($('#HPI_1').height()); }
3597 } else if (zone == 'menu') {
3598 show_QP();
3599 } else if (zone == 'IMPPLAN') {
3600 show_QP_section('IMPPLAN');
3601 update_PREFS();
3607 // set default to ccDist. Change as desired.
3608 $('#NEURO_ACT_zone').val('CCDIST').trigger('change');
3609 if ($("#RXStart").val() =="2") {
3610 $("#Trifocal").trigger('click');
3612 $("[id$='_loading']").addClass('nodisplay');
3613 $("[id$='_sections']").removeClass('nodisplay');
3615 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3616 $('#PMH_left').height($('#PMH_right').height());
3617 } else { $('#PMH_1').height($('#HPI_1').height()); }
3619 $('#left-panel').css("right","0px");
3620 $('#EXAM_KB').css({position: 'fixed', top: '29px'});
3621 $('#EXAM_KB').css('display', 'block');
3622 $('#EXAM_KB').draggable();
3623 $('#IMP').droppable({ drop: dragto_IMPPLAN } );
3624 $('#IMPPLAN_zone').droppable({ drop: dragto_IMPPLAN_zone } );
3625 $('#IMPPLAN_text').droppable({ drop: dragto_IMPPLAN_zone } );
3627 $('[id^="PLANS"]').draggable( { cursor: 'move', revert: true });
3628 $('[id^="PLAN_"]').height( $(this).scrollHeight );
3630 /* Sorting of diagnoses in IMP/PLAN right panel builds IMP_order[] array.
3631 Foreach index => value in IMP_order[order,PMSFH[type][i]]:
3632 retrieve PMSFH[type][value] and build the IMPRESSION/PLAN area
3633 openEMR ICD-10 seems to have newlines in codetext? strip them with replace.
3634 All the ISSUE_TYPES and their fields are available in obj.PMSFH:
3635 'title' => $disptitle,
3636 'status' => $statusCompute,
3637 'enddate' => $row['enddate'],
3638 'reaction' => $row['reaction'],
3639 'referredby' => $row['referredby'],
3640 'extrainfo' => $row['extrainfo'],
3641 'diagnosis' => $row['diagnosis'],
3642 'code' => $code,
3643 'codedesc' => $codedesc,
3644 'codetext' => $codetext,
3645 'codetype' => $codetype,
3646 'comments' => $row['comments'],
3647 'rowid' => $row['id'],
3648 'row_type' => $row['type']
3649 eg. obj.IMPPLAN_items[index] = code: obj.PMSFH['POH'][value]['code'],
3650 codedesc: obj.PMSFH['POH'][value]['codedesc'],
3651 codetype: obj.PMSFH['POH'][value]['codetype']
3654 $('#make_new_IMP').click(function() {
3655 var issue='';
3656 if (IMP_order.length ==0) rebuild_IMP($( "#build_DX_list" ));
3657 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];
3658 $.each(IMP_order, function( index, value ) {
3659 issue= value.match(/(.*)_(.*)/);
3660 if (issue[1] == "CLINICAL") {
3661 if (!$('#inc_PE').is(':checked')) { return; }
3663 var the_code='';
3664 var the_codedesc='';
3665 var the_codetext='';
3666 var the_plan='';
3667 for (i=0;i < obj.Clinical[issue[2]].length; i++) {
3668 if (i == 0) {
3669 the_code = obj.Clinical[issue[2]][i]['code'];
3670 } else if (i < obj.Clinical[issue[2]].length) {
3671 the_code += ', '+ obj.Clinical[issue[2]][i]['code'];
3673 the_codedesc += obj.Clinical[issue[2]][i]['codedesc'] + "\r";
3674 the_codetext += obj.Clinical[issue[2]][i]['codetext'] + "\r";
3675 the_plan += obj.Clinical[issue[2]][i]['codedesc'] + "\r";
3677 obj.IMPPLAN_items.push({
3678 title:obj.Clinical[issue[2]][0]['title'],
3679 code: the_code,
3680 codetype: obj.Clinical[issue[2]][0]['codetype'],
3681 codedesc: the_codedesc,
3682 codetext: the_codetext,
3683 plan: the_plan,
3684 PMSFH_link: obj.Clinical[issue[2]][0]['PMSFH_link']
3686 } else {
3687 if (issue[1] == "PMH") {
3688 if (!$('#inc_PMH').is(':checked')) { return; }
3689 } else if (issue[1] == "POH"){
3690 if (!$('#inc_POH').is(':checked')) { return; }
3691 } else if (issue[1] == "POS"){
3692 if (!$('#inc_POH').is(':checked')) { return; }
3694 obj.IMPPLAN_items.push({
3695 title: obj.PMSFH[issue[1]][issue[2]]['title'],
3696 code: obj.PMSFH[issue[1]][issue[2]]['code'],
3697 codetype: obj.PMSFH[issue[1]][issue[2]]['codetype'],
3698 codedesc: obj.PMSFH[issue[1]][issue[2]]['codedesc'],
3699 codetext: obj.PMSFH[issue[1]][issue[2]]['codetext'].replace(/(\r\n|\n|\r)/gm,""),
3700 plan: obj.PMSFH[issue[1]][issue[2]]['comments'],
3701 PMSFH_link: obj.PMSFH[issue[1]][issue[2]]['PMSFH_link']
3705 build_IMPPLAN(obj.IMPPLAN_items);
3706 store_IMPPLAN(obj.IMPPLAN_items,'1');
3710 var allPanels = $('.building_blocks > dd').hide();
3711 var allPanels2 = $('.building_blocks2 > dd').hide();
3713 $('.building_blocks > dt > span').click(function() {
3714 allPanels.slideUp();
3715 $(this).parent().next().slideDown();
3716 return false;
3718 $('.building_blocks2 > dt > span').click(function() {
3719 allPanels2.slideUp();
3720 $(this).parent().next().slideDown();
3721 return false;
3723 $('#IMP_start_acc').slideDown();
3724 $('[id^=inc_]').click(function() {
3725 build_DX_list(obj);
3728 $('#active_flag').click(function() { check_lock('1'); });
3729 $('#active_icon').click(function() { check_lock('1'); });
3731 $("input,textarea,text,checkbox").change(function(){
3732 $(this).css("background-color","#F0F8FF");
3733 submit_form($(this));
3735 $('#IMP').blur(function() {
3736 //add this DX to the obj.IMPPLAN_items array
3737 //take the first line as the impression and the rest as the plan
3738 var total_imp = $('#IMP').val();
3739 var local_plan = '';
3740 var local_code= '';
3741 if (total_imp.length < '2') return; //reject text under two letters?
3742 var re = /\r\n|[\n\v\f\r\x85\u2028\u2029]/; //official list of line delimiters for a regex
3743 //local_impression is first line only[1]
3744 var local_imp = total_imp.match(/^(.*)(?:\r\n|[\n\v\f\r\x85\u2028\u2029])(.*)/);
3745 if (local_imp == null || local_imp[1] == null) {
3746 local_imp = total_imp;
3747 } else {
3748 // If the first line was dropped in from the Builder via a draggable DX_list
3749 // it will include the IMPRESSION + CODE.
3750 // Consider stripping out the CODE
3751 var local_imp_code = local_imp[1].match(/(.*)(ICD.*)$/);
3752 if (local_imp_code) {
3753 local_imp = local_imp_code[1];
3754 local_code = local_imp_code[2];
3755 local_plan = total_imp.replace(local_imp_code[0],''); //plan is line 2+ if present, strip off first line
3756 local_plan = local_plan.replace(/^\r\n|[\n\v\f\r\x85\u2028\u2029]/,'');
3757 } else {
3758 local_imp = local_imp[1];
3759 local_code = '';
3760 local_plan = total_imp.replace(local_imp,''); //plan is line 2+ if present, strip off first line
3761 local_plan = local_plan.replace(/^\r\n|[\n\v\f\r\x85\u2028\u2029]/,'');
3764 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];//can't push if array does not exist
3765 obj.IMPPLAN_items.push({
3766 form_id: $('#form_id').val(),
3767 pid: $('#pid').val(),
3768 title: local_imp,
3769 plan: local_plan,
3770 code: local_code,
3771 codetext:'',
3772 codetype:'',
3773 codedesc:'',
3774 PMSFH_link: ''
3776 build_IMPPLAN(obj.IMPPLAN_items);
3777 store_IMPPLAN(obj.IMPPLAN_items,'1');
3778 $('#IMP').val('');//clear the box
3779 submit_form('1');//tell the server where we stand
3781 $('#Add_Glasses').click(function() {
3782 for (i=2; i <6; i++) { //come on, 5 current rx glasses should be enough...
3783 if ($('#W_'+i).val() != '1') {
3784 $('#W_'+i).val('1');
3785 $('#LayerVision_W_'+i).removeClass('nodisplay');
3786 if (i==5) { $('#Add_Glasses').addClass('nodisplay'); }
3787 break;
3791 $("[name='reverseme']").click(function() {
3792 var target = this.id;
3793 reverse_cylinder(target);
3796 $('#code_me_now').click(function(event) {
3797 event.preventDefault();
3798 build_CODING_list();
3800 $( ".widget a" ).button();
3802 $('#goto_fee_sheet2').click(function(event) {
3803 goto_url('<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/encounter/load_form.php?formname=fee_sheet');
3806 $( "button" ).button().click(function( event ) {
3807 event.preventDefault();
3809 refresh_page();
3810 // AUTO- CODING FEATURES
3811 check_CPT_92060();
3812 check_exam_detail();
3813 if ($("#PRIOR_ALL").value == "undefined") {
3814 var Code_new_est="New";
3815 } else {
3816 var Code_new_est="Est";
3818 Suggest_visit_code();
3819 $('#visit_codes').change(function() {
3820 var data_all = $(this).val();
3821 var data = data_all.match(/^(.*)\|(.*)\|/);
3822 visit_code = data[2];
3823 visit_type = data[1];
3825 show_QP_section('IMPPLAN','1');
3826 build_IMPPLAN(obj.IMPPLAN_items);
3827 scroll='1';
3828 <?php if ($GLOBALS['new_tabs_layout'] !=='1') { ?> $("[class='tabHide']").css("display","inline-block"); <?php } ?>
3829 $("input,textarea,text").focus(function(){
3830 $(this).css("background-color","#ffff99");
3832 $(window).bind('onbeforeunload', function(){
3833 if ($('#chart_status').val()=="on") {
3834 unlock(); }