ScrollTo optimization
[openemr.git] / interface / forms / eye_mag / js / eye_base.php
blobbdda634ab6601c2d27c0f579f42aa4df1f16be81
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
7 *
8 * Copyright (C) 2016 Raymond Magauran <magauran@MedFetch.com>
9 *
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;
66 * Functions to add a quick pick selection to the correct fields on the form.
68 function fill_QP_2fields(PEZONE, ODOSOU, LOCATION_text, selection, fill_action, Code_to_process) {
69 var prefix = document.getElementById(PEZONE+'_prefix').value;
70 if (prefix > '' && prefix !='off') {prefix = prefix + " ";}
71 if ((prefix =='off')||(LOCATION_text =='')) { prefix=''; }
72 var saved_prefix = prefix;
73 if (ODOSOU =="OU") {
74 fill_QP_field(PEZONE, "OD", LOCATION_text, selection, fill_action, Code_to_process);
75 fill_QP_field(PEZONE, "OS", LOCATION_text, selection, fill_action, Code_to_process,saved_prefix);
76 } else if (ODOSOU =="B") {
77 fill_QP_field(PEZONE, "R", LOCATION_text, selection, fill_action, Code_to_process);
78 fill_QP_field(PEZONE, "L", LOCATION_text, selection, fill_action, Code_to_process,saved_prefix);
81 function fill_QP_field(PEZONE, ODOSOU, LOCATION_text, selection, fill_action, Code_to_process,saved_prefix) {
82 if (ODOSOU > '') {
83 var FIELDID = ODOSOU + LOCATION_text;
84 } else {
85 var FIELDID = document.getElementById(PEZONE+'_'+ODOSOU).value + LOCATION_text;
87 var bgcolor = $("#" +FIELDID).css("background-color");
89 if (saved_prefix) {
90 var prefix = saved_prefix;
91 } else {
92 var prefix = document.getElementById(PEZONE+'_prefix').value;
95 var Fvalue = document.getElementById(FIELDID).value;
96 if (prefix > '' && prefix !='off') {prefix = prefix + " ";}
97 if (prefix =='off') { prefix=''; }
98 if (fill_action =="REPLACE") {
99 $("#" +FIELDID).val(prefix +selection);
100 $("#" +FIELDID).css("background-color","#F0F8FF");
101 } else if (fill_action =="APPEND") {
102 $("#" +FIELDID).val(Fvalue+selection).css("background-color","#F0F8FF");
103 } else {
104 if (($("#" +FIELDID).css("background-color")=="rgb(245, 245, 220)") || (Fvalue =='')) {
105 //rgb(245, 245, 220) is beige - the field is untouched
106 $("#" +FIELDID).val(prefix+selection).css("background-color","#F0F8FF");
107 } else if (Fvalue.match(/x$/)) {
108 $("#" +FIELDID).val(Fvalue+selection).css("background-color","#F0F8FF");
109 } else {
110 if (Fvalue >'') prefix = ", "+prefix;
111 $("#" +FIELDID).val(Fvalue + prefix +selection).css("background-color","#F0F8FF");
114 submit_form(FIELDID);
115 $('#'+PEZONE+'_prefix').val('off').trigger('change');
119 * This is the core function of the form.
120 * It submits the data in the background via ajax.
121 * It is the reason we don't use a submit button.
122 * It is called often, perhaps too often for some installs because it uses bandwidth.
123 * It needs to be keenly looked at by developers as it will affect scalability.
124 * It return either "Code 400" or positive hits from the clinical data passed through the Coding engine.
125 * It ensures ownership of the form or provides background updates to READ-ONLY instances of the form.
126 * It doesn't unlock a form to change ownership/provide write privileges. This is done via the unlock() function.
128 function submit_form(action) {
129 var url = "../../forms/eye_mag/save.php?sub=1&mode=update&id=" + $("#form_id").val();
130 if ($("#COPY_SECTION").value == "READONLY") return;
131 formData = $("form#eye_mag").serialize();
132 $("#menustate").val('0');
133 top.restoreSession();
134 $.ajax({
135 type : 'POST',
136 url : url,
137 data : formData //, dataType: "json"
138 }).done(function(result) {
139 if (result == 'Code 400') {
140 code_400(); //Not the owner: read-only mode or take ownership
141 } else {
142 // ACTIVE chart.
143 // Coding engine returns any positive Clinical findings.
144 //List these findings in the IMP_PLAN Builder
145 populate_form(result);
151 * This function alerts the user that they have lost write privileges to another user.
152 * The form is locked (fields disabled) and they enter the READ-ONLY mode.
153 * In READ-ONLY mode the form is refreshed every 15 seconds showing changes made by the user with write privileges.
155 function code_400() {
156 //User lost ownership. Just watching now...
157 //now we should get every variable and update the form, every 15 seconds...
158 $("#active_flag").html(" READ-ONLY ");
159 toggle_active_flags("off");
160 alert("Another user has taken control of this form.\rEntering READ-ONLY mode.");
161 update_READONLY();
162 this_form_id = $("#form_id").val();
163 $("#COPY_SECTION").val("READONLY");
164 update_chart = setInterval(function() {
165 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
166 update_READONLY();
167 }, 15000);
171 * Convert the DB datetime values into date objects in JS
173 * "You should parse them to get a Date object, for that format I always use the following function:
174 * http://stackoverflow.com/questions/2627650/why-javascript-gettime-is-not-a-function"
177 function parseDate(input) {
178 var parts = input.match(/(\d+)/g);
179 // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
180 return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
183 * Function to check locked state
185 function check_lock(modify) {
186 var locked = $("#LOCKED").val();
187 var locked_by = $("#LOCKEDBY").val();
188 if ($("#LOCKEDDATE").val() > '') {
189 var locked_date = parseDate($("#LOCKEDDATE").val());
190 } else{
191 var locked_date= new Date('2000-01-01');
193 var uniqueID = $('#uniqueID').val();
195 var url = "../../forms/eye_mag/save.php?mode=update&id=" + $("#form_id").val();
196 clearInterval(update_chart);
197 //if the form was locked > 1 hour ago, tag we are it - we should auto-get ownership
198 //if not we have to physically take it.
199 var now =new Date();
200 now_time = now.getTime();
201 var interval = locked_date.setTime(locked_date.getTime() + (60*60*1000));//locked timestamp + 1 hour
202 if (modify=='1') {
203 if ($("#chart_status").val() == "on") {
204 unlock();
205 toggle_active_flags("off");
206 update_chart = setInterval(function() {
207 if ($("#chart_status").val() == "on") { clearInterval(update_chart);}
208 update_READONLY();
209 }, 15000);
210 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
211 } else {
212 top.restoreSession();
213 $.ajax({
214 type : 'POST',
215 url : url,
216 data : {
217 'acquire_lock' : '1',
218 'uniqueID' : uniqueID,
219 'form_id' : $("#form_id").val(),
220 'locked_by' : $("#LOCKEDBY").val()
222 }).done(function(d) {
223 $("#LOCKEDBY").val(uniqueID);
224 toggle_active_flags("on");
225 clearInterval(update_chart);
228 } else if (locked =='1' && (interval < now_time)) { //it was locked more than an hour ago, take ownership quietly
229 top.restoreSession();
230 $.ajax({
231 type : 'POST',
232 url : url,
233 data : {
234 'acquire_lock' : '1',
235 'uniqueID' : uniqueID, //this user is becoming the new owner
236 'locked_by' : locked_by, //this is the old owner
237 'form_id' : $("#form_id").val()
239 }).done(function(d) {
240 $("#LOCKEDBY").val(uniqueID);
241 $("#LOCKEDDATE").val(d);
242 toggle_active_flags("on");
245 } else if (locked =='1' && locked_by >'' && (uniqueID != locked_by)) {
246 //form is locked by someone else, less than an hour ago...
247 $("#active_flag").html(" READ-ONLY ");
248 if (confirm('\tLOCKED by another user:\t\n\tSelect OK to take ownership or\t\n\tCANCEL to enter READ-ONLY mode.\t')) {
249 top.restoreSession();
250 $.ajax({
251 type : 'POST',
252 url : url,
253 data : {
254 'acquire_lock' : '1',
255 'uniqueID' : uniqueID, //this user is becoming the new owner
256 'locked_by' : locked_by, //this is the old owner
257 'form_id' : $("#form_id").val()
259 }).done(function(d) {
260 $("#LOCKEDBY").val(uniqueID);
261 toggle_active_flags("on");
264 } else {
265 //User selected "Cancel" -- ie. doesn't want ownership. Just watching...
266 toggle_active_flags("off");
267 update_chart = setInterval(function() {
268 $("#COPY_SECTION").trigger('change');
269 if ($("#chart_status").val() == "on") { clearInterval(update_chart);}
270 update_READONLY();
271 }, 15000);
272 if ($("#chart_status").value == "on") { clearInterval(update_chart); }
278 * Function to save a canvas by zone
280 function submit_canvas(zone) {
281 var id_here = document.getElementById('myCanvas_'+zone);
282 var dataURL = id_here.toDataURL('image/jpeg');
283 top.restoreSession();
284 $.ajax({
285 type: "POST",
286 url: "../../forms/eye_mag/save.php?canvas="+zone+"&id="+$("#form_id").val(),
287 data: {
288 imgBase64 : dataURL, //this contains the canvas + new strokes, the sketch.js foreground
289 'zone' : zone,
290 'visit_date' : $("#visit_date").val(),
291 'encounter' : $("#encounter").val(),
292 'pid' : $("#pid").val()
295 }).done(function(o) {
299 * Function to update the user's preferences
301 function update_PREFS() {
302 var url = "../../forms/eye_mag/save.php";
303 var formData = {
304 'AJAX_PREFS' : "1",
305 'PREFS_VA' : $('#PREFS_VA').val(),
306 'PREFS_W' : $('#PREFS_W').val(),
307 'PREFS_MR' : $('#PREFS_MR').val(),
308 'PREFS_W_width' : $('#PREFS_W_width').val(),
309 'PREFS_MR_width' : $('#PREFS_MR_width').val(),
310 'PREFS_CR' : $('#PREFS_CR').val(),
311 'PREFS_CTL' : $('#PREFS_CTL').val(),
312 'PREFS_ADDITIONAL' : $('#PREFS_ADDITIONAL').val(),
313 'PREFS_VAX' : $('#PREFS_VAX').val(),
314 'PREFS_IOP' : $('#PREFS_IOP').val(),
315 'PREFS_CLINICAL' : $('#PREFS_CLINICAL').val(),
316 'PREFS_EXAM' : $('#PREFS_EXAM').val(),
317 'PREFS_CYL' : $('#PREFS_CYL').val(),
318 'PREFS_EXT_VIEW' : $('#PREFS_EXT_VIEW').val(),
319 'PREFS_ANTSEG_VIEW' : $('#PREFS_ANTSEG_VIEW').val(),
320 'PREFS_RETINA_VIEW' : $('#PREFS_RETINA_VIEW').val(),
321 'PREFS_NEURO_VIEW' : $('#PREFS_NEURO_VIEW').val(),
322 'PREFS_ACT_VIEW' : $('#PREFS_ACT_VIEW').val(),
323 'PREFS_ACT_SHOW' : $('#PREFS_ACT_SHOW').val(),
324 'PREFS_HPI_RIGHT' : $('#PREFS_HPI_RIGHT').val(),
325 'PREFS_PMH_RIGHT' : $('#PREFS_PMH_RIGHT').val(),
326 'PREFS_EXT_RIGHT' : $('#PREFS_EXT_RIGHT').val(),
327 'PREFS_ANTSEG_RIGHT' : $('#PREFS_ANTSEG_RIGHT').val(),
328 'PREFS_RETINA_RIGHT' : $('#PREFS_RETINA_RIGHT').val(),
329 'PREFS_NEURO_RIGHT' : $('#PREFS_NEURO_RIGHT').val(),
330 'PREFS_PANEL_RIGHT' : $('#PREFS_PANEL_RIGHT').val(),
331 'PREFS_IMPPLAN_RIGHT' : $('#PREFS_IMPPLAN_DRAW').val(),
332 'PREFS_KB' : $('#PREFS_KB').val(),
333 'PREFS_TOOLTIPS' : $('#PREFS_TOOLTIPS').val()
335 top.restoreSession();
336 $.ajax({
337 type : 'POST',
338 url : url,
339 data : formData
343 * Function to unlock the form - remove temporary lock at DB level.
345 function unlock() {
346 var url = "../../forms/eye_mag/save.php?mode=update&id=" + $("#form_id").val();
347 var formData = {
348 'action' : "unlock",
349 'unlock' : "1",
350 'encounter' : $('#encounter').val(),
351 'pid' : $('#pid').val(),
352 'LOCKEDBY' : $('#LOCKEDBY').val(),
353 'form_id' : $("#form_id").val()
355 top.restoreSession();
356 $.ajax({
357 type : 'POST',
358 url : url,
359 data : formData }).done(function(o) {
360 $("#warning").removeClass("nodisplay");
361 $('#LOCKEDBY').val('');
362 $('#chart_status').val('off');
366 * Function to fax this visit report to someone.
368 function create_task(to_id,task,to_type) {
369 var url = "../../forms/eye_mag/taskman.php";
370 var formData = {
371 'action' : "make_task",
372 'from_id' : '<?php echo $providerID; ?>',
373 'to_id' : to_id,
374 'pid' : $('#pid').val(),
375 'doc_type' : task,
376 'enc' : $('#encounter').val(),
377 'form_id' : $('#form_id').val()
379 top.restoreSession();
380 $.ajax({
381 type : 'POST',
382 url : url,
383 data : formData
384 }).done(function(result) {
385 //OPTIONS to consider: we could return a status code from the server.
386 //maybe 1 = no doc, 2= doc made and queued, 3= sent
387 //maybe this is a checkbox. Check to create the task, uncheck to delete it.
388 //if the task is completed, checkbox is checked and disabled?
389 //return doc_id and display it in html for id='status_'+task+'_'+to_type
390 obj = JSON.parse(result);
391 if (obj.DOC_link) {
392 $('#status_'+task+'_'+to_type).html(obj.DOC_link);
394 if (obj.comments) alert(obj.comments);
395 //maybe change an icon to sent? Think.
401 * START OF PMSFH FUNCTIONS
403 function alter_issue2(issue_number,issue_type,index) {
404 if (!obj.PMSFH) { refresh_page(); }
405 if (typeof obj.PMSFH == "undefined") { submit_form(); }
406 var here = obj.PMSFH[issue_type][index];
407 window.frames[0].frameElement.contentWindow.newtype(issue_type);
408 if (issue_type !='SOCH' && issue_type !='FH' && issue_type !='ROS') {
409 $('iframe').contents().find('#delete_button').removeClass('nodisplay');
410 } else {
411 $('iframe').contents().find('#delete_button').addClass('nodisplay');
413 $('iframe').contents().find('#issue' ).val(issue_number);
414 if (typeof here !== "undefined") {
415 $('iframe').contents().find('#form_title' ).val(here.title);
416 $('iframe').contents().find('#form_diagnosis' ).val(here.diagnosis);
417 $('iframe').contents().find('#form_begin' ).val(here.begdate);
418 $('iframe').contents().find('#form_end' ).val(here.enddate);
419 $('iframe').contents().find('#form_reaction' ).val(here.reaction);
420 $('iframe').contents().find('#form_referredby' ).val(here.referredby);
421 $('iframe').contents().find('#form_classification' ).val(here.classification);
422 $('iframe').contents().find('#form_occur' ).val(here.occurrence);
423 $('iframe').contents().find('#form_comments' ).val(here.comments);
424 $('iframe').contents().find('#form_outcome' ).val(here.outcome);
425 $('iframe').contents().find('#form_destination' ).val(here.destination);
426 if (here.row_subtype =='eye') {
427 $('iframe').contents().find('#form_eye_subtype' ).prop("checked","checked");
428 } else {
429 $('iframe').contents().find('#form_eye_subtype' ).prop("checked",false);
431 if (here.enddate > '') {
432 $('iframe').contents().find('#form_active' ).prop("checked",true);
433 $('iframe').contents().find('#delete_button').addClass("nodisplay");
434 } else {
435 $('iframe').contents().find('#form_active' ).prop("checked",false);
438 var location = $("#PMH_left").offset().top -55;
439 $root.animate({scrollTop: location }, "slow");
441 function showArray(arr) {
442 var tS = new String();
443 for (var iI in arr) {
444 tS += "Index "+iI+", Type "+(typeof arr[iI])+", Value "+arr[iI]+"\n";
446 return tS;
450 * Function to delete an issue from server via ajax
451 * Ajax returns json obj.PMSFH
452 * Refresh displays (right_panel and QP_PMH panel)
454 function delete_issue2(issue_number,PMSFH_type) {
455 $('#form#theform issue').val(issue_number);
456 $('iframe').contents().find('#issue').val(issue_number);
457 $('form#theform form_type');
459 var url = '../../forms/eye_mag/a_issue.php';
460 var formData = {
461 'a_issue' : issue_number,
462 'deletion' : '1',
463 'PMSFH' : '1'
465 top.restoreSession();
466 $.ajax({
467 type : 'POST',
468 url : url,
469 data : formData,
470 success:(function(result) {
471 populate_PMSFH(result);
474 show_QP();
475 return false;
479 * Function to save the PMSFH array to the server.
480 * This can be removed in the future - save for now
482 function submit_PMSFH() {
483 var url = "../../forms/eye_mag/save.php?PMSFH_save=1&mode=update";
484 formData = $("[id^=f]").serialize();
485 var f = document.forms[0];
486 top.restoreSession();
487 $.ajax({
488 type : 'POST',
489 url : url,
490 data : formData
491 }).done(function(result){
492 f.form_title.value = '';
493 f.form_diagnosis.value = '';
494 f.form_begin.value ='';
495 f.form_end.value ='';
496 f.form_referredby.value ='';
497 f.form_reaction.value ='';
498 f.form_classification.value ='';
499 f.form_occur.value='';
500 f.form_comments.value ='';
501 f.form_outcome.value ='';
502 f.form_destination.value ='';
503 f.issue.value ='';
504 populate_form(result);
505 });}
507 /* If a clickoption title is selected, copy it to the title field.
508 * We also want to copy any other fields present in object.PMSFH_options
509 * We need to build this object first. The base install options will need ICD-10 codes attached
510 * to make this work.
512 function set_text() {
513 var f = document.forms[0];
514 f.form_title.value = f.form_titles.options[f.form_titles.selectedIndex].text;
515 f.form_titles.selectedIndex = -1;
518 * END OF PMSFH FUNCTIONS
522 * Function to refresh the issues, the panels and the Impression/coding areas.
524 function refresh_page() {
525 var url = '../../forms/eye_mag/view.php?display=PMSFH';
526 var formData = {
527 'action' : "refresh",
528 'id' : $('#form_id').val(),
529 'encounter' : $('#encounter').val(),
530 'pid' : $('#pid').val(),
531 'refresh' : 'page'
533 top.restoreSession();
534 $.ajax({
535 type : 'POST',
536 url : url,
537 data : formData,
538 success:(function(result) {
539 populate_form(result);
542 //Make the height of the panels equal if they grow really large
543 if ($('#PMH_right').height() > $('#PMH_left').height()) {
544 $('#PMH_left').height($('#PMH_right').height());
545 } else { $('#PMH_left').height($('#PMH_right').height()); }
546 return false;
550 * Function to refresh the Glaucoma Flow Sheet.
552 function refresh_GFS() {
553 if (typeof config_byday == "undefined") { return; }
555 var indexToUpdate = '0';
556 $.each(config_byday.data.labels, function(key,value) {
557 if (value == visit_date) {
558 indexToUpdate = key;
562 //var indexToUpdate = config_byday.data.labels.length-1;
563 var ODIOP=0;
564 var OSIOP=0;
565 if ( $('#ODIOPAP').val()) {
566 ODIOP = $('#ODIOPAP').val();
567 } else if ( $('#ODIOPTPN').val()) {
568 ODIOP = $('#ODIOPTPN').val();
571 if ( $('#OSIOPAP').val() >'0') {
572 OSIOP = $('#OSIOPAP').val();
573 } else if ( $('#OSIOPTPN').val() > '0') {
574 OSIOP = $('#OSIOPTPN').val();
577 config_byday.data.datasets[0].data[indexToUpdate] = $('#ODIOPTARGET').val();
578 config_byday.data.datasets[1].data[indexToUpdate] = ODIOP;
579 config_byday.data.datasets[2].data[indexToUpdate] = OSIOP;
580 myLine.update();
582 var time = $('#IOPTIME').val();
583 times = time.match(/^(\d{1,2}):(\d{2})/);
584 if (times[1] < 10) times[1] = "0"+''+times[1];
585 time = times[1]+':'+times[2];
586 //alert("time is "+time);
587 var indexToUpdate2 = '0';
588 $.each(config_byhour.data.labels, function(key,value) {
589 if (value == time) {
590 indexToUpdate2 = key;
593 config_byhour.data.datasets[0].data[indexToUpdate2] = ODIOP;
594 config_byhour.data.datasets[1].data[indexToUpdate2] = OSIOP;
595 myLine2.update();
596 // Update one of the points in the second dataset
597 // myLine.data.datasets[1].data[indexToUpdate].val($('#ODIOPAP').val());
598 //alert(config_byday.data.datasets[1].data[indexToUpdate].val()+' is ending _bydat val');
599 //myLine.update();
600 //ctx2.update();
601 return;
603 this should refresh locally and not go back to the server
604 the only things that would trigger a refresh are
605 a change in IOP
606 change in IOPTARGET
607 change in Eye Meds
608 change in GONIO fields
609 additional tests (VF/OCT) would not affect this in its live format
611 submit_form();
612 var url = '../../forms/eye_mag/view.php?display=GFS';
613 var formData = {
614 'action' : "refresh_GFS",
615 'id' : $('#form_id').val(),
616 'encounter' : $('#encounter').val(),
617 'pid' : $('#pid').val(),
618 'refresh' : 'GFS'
620 top.restoreSession();
621 $.ajax({
622 type : 'POST',
623 url : url,
624 data : formData,
625 success:(function(result) {
626 populate_GFS(result);
632 function populate_GFS(result) {
633 $("#LayerVision_IOP").html(result);
637 * Server returns a json encoding object: obj to update the page
638 * Here we refresh the PMSFH display panels,
639 * Rebuild the Impression/Plan Builder DX lists,
640 * the Impression Plan area
641 * and the CHRONIC fields.
643 function populate_form(result) {
644 obj = JSON.parse(result);
645 $("#QP_PMH").html(obj.PMH_panel);
646 if ($('#PMH_right').height() > $('#PMH_left').height()) {
647 $('#PMH_left').height($('#PMH_right').height());
648 } else { $('#PMH_left').height($('#PMH_right').height()); }
649 $("#right_panel_refresh").html(obj.right_panel);
650 build_IMPPLAN(obj.IMPPLAN_items);
651 build_Chronics(obj);
652 build_DX_list(obj); //build the list of DXs to show in the Impression/Plan Builder
655 * Function to auto-fill CHRONIC fields
656 * To reach a detailed E&M level of documentation the chart
657 * may comment on the status of 3 or more CHRONIC/Inactive problems.
658 * The user can type them into the CHRONIC fields manually, or
659 * we can do it programatically if the user does the following:
660 * 1. documenting a PMH diagnosis in the PMSFH area
661 * 2. listing it as "Chronic"
662 * 3. making a comment about it
663 * With these three steps completed, this build_CHRONIC function displays the changes
664 * in the CHRONIC1-3 textareas, if not already filled in, for today's visit.
665 * On subsequent visits, the CHRONIC1-3 fields are blank, unless the above steps
666 * were performed previously, then they are filled in automatically on loading of the new form.
668 function build_Chronics(obj) {
669 if (typeof obj.PMSFH === "undefined") return;
670 var CHRONICS = obj.PMSFH['CHRONIC'];
671 var chronic_value;
672 var local_comment;
673 var here_already;
674 $.each(CHRONICS, function(key, value) {
675 local_comment = CHRONICS[key].title+" "+CHRONICS[key].diagnosis+"\n"+CHRONICS[key].comments;
676 here_already ='0';
677 for (i=1; i < 4; i++) {
678 chronic_value = $('#CHRONIC'+i).val();
679 if (chronic_value == local_comment) {
680 here_already='1'; //this is here, move to next CHRONICS
681 break;
684 if (here_already !='1') {
685 for (i=1; i < 4; i++) {
686 chronic_value = $('#CHRONIC'+i).val();
687 if (chronic_value == '') { //if the CHRONIC1-3 field is empty, fill it.
688 $('textarea#CHRONIC'+i).val(local_comment);
689 break;
694 return false;
697 * Function to autocreate a PDF of this form as a document linked to this encounter.
698 * Each time it is runs it updates by replacing the encounter's PDF.
699 * This used to be fired often, but it is a server resource beast.
700 * Use it sparingly, and intentionally only.
701 * Currently only invoked via the bootstrap menu: Menu->File->Print/Store PDF
703 function store_PDF() {
704 var url = "../../forms/eye_mag/save.php?mode=update";
705 var formData = {
706 'action' : 'store_PDF',
707 'patient_id' : $('#pid').val(),
708 'pdf' : '1',
709 'printable' : '1',
710 'form_folder' : $('#form_folder').val(),
711 'form_id' : $('#form_id').val(),
712 'encounter' : $('#encounter').val(),
713 'uniqueID' : $('#uniqueID').val()
715 top.restoreSession();
716 $.ajax({
717 type : 'POST',
718 url : url,
719 data : formData
723 /* START Functions related to form VIEW */
725 * Function to blow out the form and display the right side of every section.
727 function show_right() {
728 $("#HPI_1").removeClass("size50").addClass("size100");
729 $("#PMH_1").removeClass("size50").addClass("size100");
730 $("#EXT_1").removeClass("size50").addClass("size100");
731 $("#ANTSEG_1").removeClass("size50").addClass("size100");
732 $("#NEURO_1").removeClass("size50").addClass("size100");
733 $("#RETINA_1").removeClass("size50").addClass("size100");
734 $("#IMPPLAN_1").removeClass("size50").addClass("size100");
735 $("#HPI_right").removeClass('nodisplay');
736 $("#PMH_right").removeClass('nodisplay');
737 $("#EXT_right").removeClass('nodisplay');
738 $("#ANTSEG_right").removeClass('nodisplay');
739 $("#NEURO_right").removeClass('nodisplay');
740 $("#RETINA_right").removeClass('nodisplay');
741 $("#IMPPLAN_right").removeClass('nodisplay');
742 $("#PMH_1").addClass("clear_both");
743 $("#ANTSEG_1").addClass("clear_both");
744 $("#RETINA_1").addClass("clear_both");
745 $("#NEURO_1").addClass("clear_both");
746 $("#IMPPLAN_1").addClass("clear_both");
747 hide_PRIORS();
750 * Function to implode the form and hide the right side of every section.
752 function hide_right() {
753 $("#HPI_1").removeClass("size100").addClass("size50");
754 $("#PMH_1").removeClass("size100").addClass("size50");
755 $("#EXT_1").removeClass("size100").addClass("size50");
756 $("#ANTSEG_1").removeClass("size100").addClass("size50");
757 $("#NEURO_1").removeClass("size100").addClass("size50");
758 $("#RETINA_1").removeClass("size100").addClass("size50");
759 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
760 $("#HPI_right").addClass('nodisplay');
761 $("#PMH_right").addClass('nodisplay');
762 $("#EXT_right").addClass('nodisplay');
763 $("#ANTSEG_right").addClass('nodisplay');
764 $("#NEURO_right").addClass('nodisplay');
765 $("#RETINA_right").addClass('nodisplay');
766 $("#PMH_1").removeClass("clear_both");
767 $("#ANTSEG_1").removeClass("clear_both");
768 $("#RETINA_1").removeClass("clear_both");
769 $("#NEURO_1").removeClass("clear_both");
770 update_PREFS();
773 * Function to explode the form and show the left side of every section.
775 function show_left() {
776 $("#HPI_1").removeClass("size100").addClass("size50");
777 $("#PMH_1").removeClass("size100").addClass("size50");
778 $("#EXT_1").removeClass("size100").addClass("size50");
779 $("#ANTSEG_1").removeClass("size100").addClass("size50");
780 $("#NEURO_1").removeClass("size100").addClass("size50");
781 $("#RETINA_1").removeClass("size100").addClass("size50");
782 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
783 $("#HPI_left").removeClass('nodisplay');
784 $("#PMH_left").removeClass('nodisplay');
785 $("#EXT_left").removeClass('nodisplay');
786 $("#ANTSEG_left").removeClass('nodisplay');
787 $("#RETINA_left").removeClass('nodisplay');
788 $("#NEURO_left").removeClass('nodisplay');
789 $("#IMPPLAN_left").removeClass('nodisplay');
790 $("[name$='_left']").removeClass('nodisplay');
793 * Function to implode the form and hide the left side of every section.
795 function hide_left() {
796 $("#HPI_1").removeClass("size100").addClass("size50");
797 $("#PMH_1").removeClass("size100").addClass("size50");
798 $("#EXT_1").removeClass("size100").addClass("size50");
799 $("#ANTSEG_1").removeClass("size100").addClass("size50");
800 $("#NEURO_1").removeClass("size100").addClass("size50");
801 $("#RETINA_1").removeClass("size100").addClass("size50");
802 $("#IMPPLAN_1").removeClass("size100").addClass("size50");
803 $("#HPI_left").addClass('nodisplay');
804 $("#PMH_left").addClass('nodisplay');
805 $("#EXT_left").addClass('nodisplay');
806 $("#ANTSEG_left").addClass('nodisplay');
807 $("#RETINA_left").addClass('nodisplay');
808 $("#NEURO_left").addClass('nodisplay');
809 $("#IMPPLAN_left").addClass('nodisplay');
810 $("[name $='_left']").addClass('nodisplay');
813 * Function to display only the DRAW panels of every section.
814 * The technical section, between HPI and Clinical section is still viible.
816 function show_DRAW() {
817 hide_QP();
818 hide_TEXT();
819 hide_PRIORS();
820 hide_left();
821 hide_KB();
822 show_right();
824 $("#HPI_right").addClass('canvas');
825 $("#PMH_right").addClass('canvas');
826 $("#EXT_right").addClass('canvas');
827 $("#ANTSEG_right").addClass('canvas');
828 $("#RETINA_right").addClass('canvas');
829 $("#NEURO_right").addClass('canvas');
830 $("#IMPPLAN_right").addClass('canvas');
831 $(".Draw_class").removeClass('nodisplay');
832 if ($("#PREFS_CLINICAL").val() !='1') {
833 $("#PREFS_CLINICAL").val('1');
834 $("#PREFS_EXAM").val('DRAW');
836 update_PREFS();
839 * Function to display only the TEXT panels in every section.
841 function show_TEXT() {
842 $("#PMH_1").removeClass('nodisplay');
843 $("#NEURO_1").removeClass('nodisplay');
844 $("#IMPPLAN_1").removeClass('nodisplay');
845 $(".TEXT_class").removeClass('nodisplay');
846 show_left();
847 hide_right(); //this hides the right half
848 hide_QP();
849 hide_DRAW();
850 hide_PRIORS();
851 if ($("#PREFS_CLINICAL").val() !='1') {
852 // we want to show text_only which are found on left half
853 $("#PREFS_CLINICAL").val('1');
855 $("#PREFS_EXAM").val('TEXT');
856 $("#IMPPLAN_right").addClass('canvas').removeClass('nodisplay');
857 $("#QP_IMPPLAN").removeClass('nodisplay');
858 $("#DRAW_"+zone).addClass('nodisplay');
859 $("#IMPPLAN_1").removeClass('nodisplay');
860 $("#IMPPLAN_left").removeClass('nodisplay');
861 $("#PREFS_IMPPLAN_RIGHT").val('QP');
862 if (!scroll) scrollTo("HPI_left");
863 update_PREFS();
866 * Function to display the PRIORS panels in every right section.
868 function show_PRIORS() {
869 $("#NEURO_sections").removeClass('nodisplay');
870 hide_DRAW();
871 $("#EXT_right").addClass("PRIORS_color");
872 show_TEXT();
873 show_right();
874 hide_QP();
875 $("#QP_HPI").removeClass('nodisplay');
876 $("#QP_PMH").removeClass('nodisplay');
877 $("#HPI_right").addClass('canvas');
878 $("#PMH_right").addClass('canvas');
879 $("#IMPPLAN_right").addClass('canvas');
880 $("#EXT_right").addClass('canvas');
881 $("#ANTSEG_right").addClass('canvas');
882 $("#RETINA_right").addClass('canvas');
883 $("#NEURO_right").addClass('canvas');
884 $(".PRIORS_class").removeClass('nodisplay');
885 if ($("#PREFS_CLINICAL").val() !='1') {
886 // we want to show text_only which are found on left half now that PRIORS are visible.
887 $("#PREFS_CLINICAL").val('1');
889 $("#PREFS_EXAM").val('PRIORS');
890 update_PREFS();
893 * Function to show the Quick Picks panel on the right side of every section.
895 function show_QP() {
896 hide_DRAW();
897 hide_PRIORS();
898 hide_KB();
899 show_TEXT();
900 show_right();
901 show_left();
902 $("#HPI_right").addClass('canvas');
903 $("#PMH_right").addClass('canvas');
904 $("#EXT_right").addClass('canvas');
905 $("#ANTSEG_right").addClass('canvas');
906 $("#RETINA_right").addClass('canvas');
907 $("#NEURO_right").addClass('canvas');
908 $("#IMPPLAN_right").addClass('canvas');
909 $(".QP_class").removeClass('nodisplay');
910 $(".QP_class2").removeClass('nodisplay');
911 $("#PREFS_EXAM").val('QP');
912 update_PREFS();
915 * Function to display only one DRAW panel of one section.
917 function show_DRAW_section(zone) {
918 $("#QP_"+zone).addClass('nodisplay');
919 $("#"+zone+"_1").removeClass('nodisplay');
920 $("#"+zone+"_left").removeClass('nodisplay');
921 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
922 $("#Draw_"+zone).addClass('canvas');
923 $("#Draw_"+zone).removeClass('nodisplay');
924 $("#PREFS_"+zone+"_DRAW").val(1);
925 update_PREFS();
928 * Function to display only one PRIORS panel of one section.
930 function show_PRIORS_section(section,newValue) {
931 var url = "../../forms/eye_mag/save.php?mode=retrieve";
933 var formData = {
934 'PRIORS_query' : "1",
935 'zone' : section,
936 'id_to_show' : newValue,
937 'pid' : $('#pid').val(),
938 'orig_id' : $('#form_id').val()
940 top.restoreSession();
941 $.ajax({
942 type : 'POST',
943 url : url,
944 data : formData,
945 success : function(result) {
946 $("#PRIORS_" + section + "_left_text").html(result);
951 * Function to show one of the Quick Picks section on the right side of its section.
953 function show_QP_section(zone,scroll) {
954 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
955 $("#QP_"+zone).removeClass('nodisplay');
956 $("#DRAW_"+zone).addClass('nodisplay');
957 $("#"+zone+"_1").removeClass('nodisplay');
958 $("#"+zone+"_left").removeClass('nodisplay');
959 $("#PREFS_"+zone+"_RIGHT").val('QP');
960 if (!scroll) scrollTo(zone+"_left");
963 * Function to hide all the DRAW panels of every section.
965 function hide_DRAW() {
966 $(".Draw_class").addClass('nodisplay');
967 hide_right();
968 $("#LayerTechnical_sections").removeClass('nodisplay');
969 $("#REFRACTION_sections").removeClass('nodisplay');
970 $("#PMH_sections").removeClass('nodisplay');
971 $("#HPI_right").addClass('nodisplay');
972 $("#HPI_right").removeClass('canvas');
973 $("#EXT_right").removeClass('canvas');
974 $("#RETINA_right").removeClass('canvas');
975 $("#ANTSEG_right").removeClass('canvas');
978 * Function to hide all the Quick Pick panels of every section.
980 function hide_QP() {
981 $(".QP_class").addClass('nodisplay');
982 $(".QP_class2").addClass('nodisplay');
983 $("[name$='_right']").removeClass('canvas');
986 * Function to hide all the TEXT panels of every section.
988 function hide_TEXT() {
989 $(".TEXT_class").addClass('nodisplay');
992 * Function to hide all the PIORS panels of every section.
994 function hide_PRIORS() {
995 $("#EXT_right").removeClass("PRIORS_color");
996 $("#PRIORS_EXT_left_text").addClass('nodisplay');
997 $("#PRIORS_ANTSEG_left_text").addClass('nodisplay');
998 $("#PRIORS_RETINA_left_text").addClass('nodisplay');
999 $("#PRIORS_NEURO_left_text").addClass('nodisplay');
1000 $(".PRIORS_class").addClass('nodisplay');
1003 * Function to hide Shorthand/Keyboard Entry panel.
1005 function hide_KB() {
1006 $('.kb').addClass('nodisplay');
1007 $('.kb_off').removeClass('nodisplay');
1008 if ($("#PREFS_KB").val() > 0) {
1009 $("#PREFS_KB").val('0');
1013 * Function to show the Shorthand/Keyboard panel.
1015 function show_KB() {
1016 $('.kb').toggleClass('nodisplay');
1017 $('.kb_off').toggleClass('nodisplay');
1018 if ($('#PREFS_EXAM').val() == 'DRAW') {
1019 show_TEXT();
1022 if ($("#PREFS_KB").val() > 0) {
1023 $("#PREFS_KB").val('0');
1024 } else {
1025 $("#PREFS_KB").val('1');
1027 update_PREFS();
1029 /* END Functions related to form VIEW */
1032 * Function contains menu commands specific to this form.
1034 function menu_select(zone,che) {
1035 $("#menu_"+zone).addClass('active');
1036 if (zone =='PREFERENCES') {
1037 window.parent.RTop.document.location.href = base+"interface/super/edit_globals.php";
1038 var url = base+"/interface/super/edit_globals.php";
1039 var formData = {
1040 'id' : $('#id').val(),
1041 'encounter' : $('#encounter').val(),
1042 'pid' : $('#pid').val(),
1044 top.restoreSession();
1045 $.ajax({
1046 type : 'GET',
1047 url : url,
1048 data : formData,
1049 success : function(result) {
1050 window.parent.RTop.document.result;
1054 if (zone =='PRIORS') $("#PRIORS_ALL_minus_one").trigger("click");
1055 if (zone =='QP') show_QP();
1056 if (zone =='KB') show_KB();
1057 if (zone =='DRAW') show_DRAW();
1058 if (zone =='TEXT') show_TEXT();
1059 if (zone =='IOP_graph') $("#LayerVision_IOP_lightswitch").trigger('click');
1060 if (zone == "HPI") scrollTo("HPI_left");
1061 if (zone == "PMH") scrollTo("PMH_left");
1062 if (zone == "EXT") scrollTo("EXT_left");
1063 if (zone == "ANTSEG") scrollTo("ANTSEG_left");
1064 if (zone == "POSTSEG") scrollTo("RETINA_left");
1065 if (zone == "NEURO") scrollTo("NEURO_left");
1070 * Function to test blowing up any section to fullscren - towards tablet functionality?
1071 * Currently not used.
1073 function show_Section(section) {
1074 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1075 show_right();
1076 $("div[name='_sections']").style.display= "none"; //
1077 $('#'+section+'_sections').style.display= "block";
1078 //.show().appendTo('form_container');
1081 * Function to display Chief Complaint 1-3
1083 function show_CC(CC_X) {
1084 $("[name^='CC_']").addClass('nodisplay');
1085 $("#CC_"+CC_X).removeClass('nodisplay');
1086 $("#CC_"+CC_X).index;
1089 /* START Functions related to CODING */
1092 * Function to determine if add on NeuroSensory(92060) code can be billed.
1094 function check_CPT_92060() {
1095 var neuro1='';
1096 var neuro2 ='';
1097 if ($("#STEREOPSIS").val() > '') (neuro1="1");
1098 $(".neurosens2").each(function(index) {
1099 if ($( this ).val() > '') {
1100 neuro2="1";
1103 if (neuro1 && neuro2){
1104 $("#neurosens_code").removeClass('nodisplay');
1105 CPT_92060 = 'here';
1106 } else {
1107 $("#neurosens_code").addClass('nodisplay');
1108 CPT_92060 = '';
1112 * Function to check documentation level for coding purposes
1113 * And make suggestions to end user.
1115 function check_exam_detail() {
1116 detail_reached_HPI='0';
1117 chronic_reached_HPI='0';
1118 $(".count_HPI").each(function(index) {
1119 if ($( this ).val() > '') detail_reached_HPI++;
1121 if (detail_reached_HPI > '3') {
1122 $(".detail_4_elements").css("color","red");
1123 $(".CODE_LOW").addClass("nodisplay");
1124 $(".CODE_HIGH").removeClass("nodisplay");
1125 $(".detailed_HPI").css("color","red");
1126 } else {
1127 $(".detail_4_elements").css("color","#876F6F");
1129 $(".chronic_HPI").each(function(index) {
1130 if ($( this ).val() > '') chronic_reached_HPI++;
1132 if (chronic_reached_HPI > '2') {
1133 $(".chronic_3_elements").css("color","red");
1134 $(".CODE_LOW").addClass("nodisplay");
1135 $(".CODE_HIGH").removeClass("nodisplay");
1136 $(".detailed_HPI").css("color","red");
1137 } else {
1138 $(".chronic_3_elements").css("color","#876F6F");
1140 if ((chronic_reached_HPI > '2')||(detail_reached_HPI > '3')) {
1141 $(".CODE_LOW").addClass("nodisplay");
1142 $(".CODE_HIGH").removeClass("nodisplay");
1143 $(".detailed_HPI").css("color","red");
1144 detail_reached_HPI = '1';
1145 } else {
1146 $(".CODE_LOW").removeClass("nodisplay");
1147 $(".CODE_HIGH").addClass("nodisplay");
1148 $(".detailed_HPI").css("color","#876F6F");
1149 detail_reached_HPI = '0';
1151 if ((($("#DIL_RISKS").is(':checked')) || ($(".dil_drug").is(':checked'))) && (($('#ODPERIPH').val() >'') || ($('#OSPERIPH').val() >''))) {
1152 $(".EXAM_LOW").addClass("nodisplay");
1153 $(".DIL_RISKS").removeClass("nodisplay");
1154 $("#DIL_RISKS").prop("checked","checked");
1155 detail_reached_exam = '1';
1156 } else {
1157 $(".EXAM_LOW").removeClass("nodisplay");
1158 $(".DIL_RISKS").addClass("nodisplay");
1159 detail_reached_exam = '0';
1161 Suggest_visit_code();
1164 /* END Functions related to CODING */
1166 /* START Functions related to IMPPLAN Builder */
1168 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1169 * Will use actual list from obj.IMPPLAN_items for coding.
1170 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1171 * available to build the Impression/Plan from.
1173 function build_DX_list(obj) {
1174 var out = "";
1175 var diagnosis;
1176 $( "#build_DX_list" ).empty();
1177 //add in inc_FIELDCODES culled from the datafields
1178 if (typeof obj.PMSFH === "undefined") return;
1179 if (typeof obj.Clinical === "undefined") submit_form('obj.clinical is undefined');
1180 if (!obj.PMSFH['POH'] && !obj.PMSFH['PMH'] && !obj.Clinical) {
1181 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 />';
1182 $( "#build_DX_list" ).html(out);
1183 return;
1185 build_IMPPLAN(obj.IMPPLAN_items);
1186 if ($('#inc_PE').is(':checked') && obj.Clinical) {
1187 $.each(obj.Clinical, function(key, value) {
1188 diagnosis='';
1189 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)
1190 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.Clinical[key][0].code+"</code>";
1192 out += "<li class='ui-widget-content'><span name='DX_Clinical_"+key+"' id='DX_Clinical_"+key+"'>"+obj.Clinical[key][0].title+"</span> "+diagnosis+"</li> ";
1196 if ($('#inc_POH').is(':checked') && (obj.PMSFH['POH']||obj.PMSFH['POS'])) {
1197 $.each(obj.PMSFH['POH'], function(key, value) {
1198 diagnosis='';
1199 if (obj.PMSFH['POH'][key].diagnosis > '' ) {
1200 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['POH'][key].code+"</code>";
1202 out += "<li class='ui-widget-content'><span name='DX_POH_"+key+"' id='DX_POH_"+key+"'>"+obj.PMSFH['POH'][key].title+"</span> "+diagnosis+"</li>";
1204 $.each(obj.PMSFH['POS'], function(key, value) {
1205 diagnosis='';
1206 if (obj.PMSFH['POS'][key].diagnosis > '' ) {
1207 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['POS'][key].code+"</code>";
1209 out += "<li class='ui-widget-content'><span name='DX_POS_"+key+"' id='DX_POS_"+key+"'>"+obj.PMSFH['POS'][key].title+"</span> "+diagnosis+"</li>";
1212 if ($('#inc_PMH').is(':checked') && obj.PMSFH['PMH']) {
1213 $.each(obj.PMSFH['PMH'], function(key, value) {
1214 diagnosis='';
1215 if (obj.PMSFH['PMH'][key].diagnosis > '') {
1216 diagnosis = "<code class='pull-right ICD_CODE'>"+obj.PMSFH['PMH'][key].code+"</code>";
1218 out += "<li class='ui-widget-content'><span name='DX_PMH_"+key+"' id='DX_PMH_"+key+"'>"+obj.PMSFH['PMH'][key].title+"</span>"+diagnosis+"</li> ";
1221 //add in inc_FIELDCODES culled from the datafields
1222 if (out !="") {
1223 rebuild_IMP($( "#build_DX_list" ));
1224 $( "#build_DX_list" )
1225 .html(out).sortable({ handle: ".handle",stop: function(event, ui){ rebuild_IMP($( "#build_DX_list" )) } })
1226 .selectable({ filter: "li", cancel: ".handle",stop: function(event, ui){ rebuild_IMP($( "#build_DX_list" )) } })
1227 .find( "li" )
1228 .addClass( "ui-corner-all ui-selected" )
1229 .dblclick(function(){
1230 rebuild_IMP($( "#build_DX_list" ));
1231 $('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1233 //this places the handle for the user to drag the item around.
1234 .prepend( "<div class='handle '><i class='fa fa-arrows fa-1'></i></div>" );
1235 } else {
1236 out = '<br /><span class="bold"><?php echo xlt("Build Your Plan")."."; ?></span><br /><br>';
1237 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 />';
1238 out += '<?php echo xlt('Update the chart to build this list')."."; ?><br />';
1239 $( "#build_DX_list" ).html(out);
1243 * Function: After the Builder DX list is built from all the available options,
1244 * the end user can select to use only certain Dxs and change their sort order of importance.
1245 * This function builds the list of DXs selected and in the order as the user sorted them,
1246 * so we know what to use to build the Impression/Plan area and in what order to display them.
1248 function rebuild_IMP(obj2) {
1249 var surface;
1250 IMP_order=[];
1251 k='0';
1252 $( ".ui-selected", obj2 ).each(function() {
1253 var index = $( "#build_DX_list li" ).index( this );
1254 if ($('#build_DX_list li span')[index].id.match(/DX_POH_(.*)/)) {
1255 surface = 'POH_' + $( "#build_DX_list li span" )[index].id.match(/DX_POH_(.*)/)[1];
1256 IMP_order[k] = surface;
1257 }else if ($('#build_DX_list li span')[index].id.match(/DX_POS_(.*)/)) {
1258 surface = 'POS_' + $( "#build_DX_list li span" )[index].id.match(/DX_POS_(.*)/)[1];
1259 IMP_order[k] = surface;
1260 } else if ($('#build_DX_list li span')[index].id.match(/DX_PMH_(.*)/)) {
1261 surface = 'PMH_' + $( "#build_DX_list li span" )[index].id.match(/DX_PMH_(.*)/)[1];
1262 IMP_order[k] = surface;
1263 } else if ($('#build_DX_list li span')[index].id.match(/DX_Clinical_(.*)/)) {
1264 surface = 'CLINICAL_' + $( "#build_DX_list li span" )[index].id.match(/DX_Clinical_(.*)/)[1];
1265 IMP_order[k] = surface;
1267 k++;
1271 * This function builds the Impression/Plan area using the object supplied: items
1272 * It appends "items" into the Impression Plan area, complete with:
1273 * contenteditable Titles (the Impression),
1274 * its code (if part of the item object),
1275 * Plan textareas (autofilled with the item/object's "comment")
1276 * for each member of "items".
1277 * Duplicates are removed by server.
1279 function build_IMPPLAN(items) {
1280 var contents_here;
1281 $('#IMPPLAN_zone').html("");
1282 $('#Coding_DX_Codes').html("");
1283 if ((items == null) || ((typeof items == "undefined")|| (items.length =='0'))) {
1284 items = [];
1285 $('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1286 $('#IMPPLAN_zone').addClass('nodisplay');
1287 } else {
1288 //ok we have at least one item, display them in order; hide the Builder instructions
1289 $('#IMPPLAN_text').addClass('nodisplay');
1290 $('#IMPPLAN_zone').removeClass('nodisplay');
1291 count_dx=0;
1292 $.each(items, function( index, value ) {
1293 if (!value.codetext) value.codetext="";
1294 if (!value.code) value.code="";
1295 if ((value.code==="") || (value.code.match(/Code/) || (value.code==null))) {
1296 value.code="<i class='fa fa-search-plus'></i>&nbsp;Code";
1297 } else {
1298 count_dx++;
1299 if (value.code.match(/\,/g)) {
1300 // If there is a comma in there, there is more than one code present for this item. Split them out.
1301 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1302 // PMSFH_link is only present when the Builder was used to make the entry.
1303 if ((typeof value.PMSFH_link !== "undefined") || (value.PMSFH_link !== null)) {
1304 //The Title should have the description.
1305 var CodeArr = value.code.split(",");
1306 var TitleArr = value.codedesc.split("\r");
1307 for (i=0;i < CodeArr.length;i++) {
1308 if (CodeArr.length == (TitleArr.length-1)) { //there is a trailing \r
1309 $('#Coding_DX_Codes').append(count_dx +'. '+CodeArr[i]+': '+TitleArr[i]+'<br />');
1310 } else {
1311 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1312 $('#Coding_DX_Codes').append(CodeArr[i]+': <?php echo xlt('Manually retrieve description on Fee Sheet'); ?> <br />');
1315 } else {
1316 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1317 if (value.PMSFH_link.match(/Clinical_(.*)/)) {
1318 if (typeof obj.Clinical !== "undefined") {
1319 var location = value.PMSFH_link.match(/Clinical_(.*)/)[1];
1320 if (obj.Clinical[location]!=null ) {
1321 for (i=0; i< obj.Clinical[location].length; i++) {
1322 $('#Coding_DX_Codes').append(count_dx +'. '+obj.Clinical[location][i].code+': '+obj.Clinical[location][i].codedesc+'<br />');
1324 } else {
1325 //item has a PMSFH_link but it is not from a Clinical field
1326 alert("Houston, we have a problem!");
1331 } else { //all is good, one code only
1332 $('#Coding_DX_Codes').append(count_dx +'. '+value.code+': '+value.codedesc+'<br />');
1335 var title2 = value.title.replace(/(\')/g, '');
1336 contents_here = ( index + 1 ) +
1337 ". <span contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+"'>" +
1338 value.title +"</span>"+
1339 "<span contenteditable class='pull-right' onclick='sel_diagnosis("+index+",\""+title2+"\");' title='"+value.codetext+"' id='CODE_"+index+"'>"+
1340 value.code + "</span>&nbsp;"+
1341 "<br /><textarea id='PLAN_"+index+"' name='PLAN_"+index+
1342 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1343 value.plan +"</textarea><br />";
1344 $('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+'" class="IMPPLAN_class">'+
1345 '<i class="pull-right fa fa-close" id="BUTTON_IMPPLAN_'+index+'"></i>'+
1346 contents_here+'</div>');
1347 $('#BUTTON_IMPPLAN_'+index).click(function() {//delete/close icon
1348 var item = this.id.match(/BUTTON_IMPPLAN_(.*)/)[1];
1349 obj.IMPPLAN_items.splice(item,1);
1350 build_IMPPLAN(obj.IMPPLAN_items);
1351 store_IMPPLAN(obj.IMPPLAN_items,'1');
1353 $('#PLAN_'+index).css("background-color","#F0F8FF");
1356 //end each
1358 // The IMPRESSION DXs are "contenteditable" spans.
1359 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1360 $('[id^=IMPRESSION_]').blur(function() {
1361 var item = this.id.match(/IMPRESSION_(.*)/)[1];
1362 var content = this.innerText || this.innerHTML;
1363 obj.IMPPLAN_items[item].title = content;
1364 store_IMPPLAN(obj.IMPPLAN_items,'1');
1365 //$(this).css('background-color','#F0F8FF');
1366 return false;
1368 $('[id^=CODE_]').blur(function() {
1369 var item = this.id.match(/CODE_(.*)/)[1];
1370 var new_code = this.innerText || this.innerHTML;
1371 obj.IMPPLAN_items[item].code = new_code;
1372 //obj.IMPPLAN_items[item].codetext = '';
1373 //obj.IMPPLAN_items[item].codedesc = '';
1374 $(this).css('background-color','#F0F8FF');
1375 store_IMPPLAN(obj.IMPPLAN_items,'1');
1378 $('[id^=PLAN_]').change(function() {
1379 var item = this.id.match(/PLAN_(.*)/)[1];
1380 obj.IMPPLAN_items[item].plan = $(this).val();
1381 store_IMPPLAN(obj.IMPPLAN_items,'1');
1382 $(this).css('background-color','#F0F8FF');
1385 $('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e){
1386 $(this).css('height', 'auto' );
1387 $(this).height( this.scrollHeight );
1389 $('#IMPPLAN_zone').find( 'textarea' ).keyup();
1390 obj.IMPPLAN_items = items;
1395 * Function to add a CODE to an IMPRESSION/PLAN item
1396 * This is for callback by the find-code popup in IMPPLAN area.
1397 * Appends to or erases the current list of diagnoses.
1399 function set_related(codetype, code, selector, codedesc) {
1400 //target is the index of IMPRESSION[index].code we are searching for.
1401 var span = document.getElementById('CODE_'+IMP_target);
1402 if ('textContent' in span) {
1403 span.textContent = code;
1404 } else {
1405 span.innerText = code;
1407 $('#CODE_'+IMP_target).attr('title',codetype + ':' + code + ' ('+codedesc+')');
1409 obj.IMPPLAN_items[IMP_target].code = code;
1410 obj.IMPPLAN_items[IMP_target].codetype = codetype;
1411 obj.IMPPLAN_items[IMP_target].codedesc = codedesc;
1412 obj.IMPPLAN_items[IMP_target].codetext = codetype + ':' + code + ' ('+codedesc+')';
1413 // This lists the text for the CODE at the top of the PLAN_
1414 // It is already there on mouseover the code itself and is printed in reports//faxes, so it was removed here
1415 // obj.IMPPLAN_items[IMP_target].plan = codedesc+"\r"+obj.IMPPLAN_items[IMP_target].plan;
1417 if (obj.IMPPLAN_items[IMP_target].PMSFH_link > '') {
1418 var data = obj.IMPPLAN_items[IMP_target].PMSFH_link.match(/(.*)_(.*)/);
1419 if ((data[1] == "POH")||(data[1] == "PMH")) {
1420 obj.PMSFH[data[1]][data[2]].code= code;
1421 obj.PMSFH[data[1]][data[2]].codetype = codetype;
1422 obj.PMSFH[data[1]][data[2]].codedesc = codedesc;
1423 obj.PMSFH[data[1]][data[2]].description = codedesc;
1424 obj.PMSFH[data[1]][data[2]].diagnosis = codetype + ':' + code;
1425 obj.PMSFH[data[1]][data[2]].codetext = codetype + ':' + code + ' ('+codedesc+')';
1426 build_DX_list(obj);
1427 update_PMSFH_code(obj.PMSFH[data[1]][data[2]].issue,codetype + ':' +code);
1430 store_IMPPLAN(obj.IMPPLAN_items,'1');
1433 * This functions updates a PMSFH item's code on the server via its issue number
1435 function update_PMSFH_code(the_issue,new_code){
1436 var url = "../../forms/eye_mag/save.php?mode=update";
1437 top.restoreSession();
1438 $.ajax({
1439 type : 'POST',
1440 url : url,
1441 data : {
1442 action : 'code_PMSFH',
1443 pid : $('#pid').val(),
1444 form_id : $('#form_id').val(),
1445 encounter : $('#encounter').val(),
1446 uniqueID : $('#uniqueID').val(),
1447 issue : the_issue,
1448 code : new_code
1450 }).done(function(result) {
1451 if (result == 'Code 400') {
1452 code_400(); //the user does not have write privileges!
1453 return;
1460 * This function sends the obj.IMPPLAN_items to the server for storage
1462 function store_IMPPLAN(storage,nodisplay) {
1463 if (typeof storage !== "undefined") {
1464 var url = "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1465 var formData = JSON.stringify(storage);
1466 top.restoreSession();
1467 $.ajax({
1468 type : 'POST',
1469 url : url,
1470 dataType : 'json',
1471 data : {
1472 parameter : formData,
1473 action : 'store_IMPPLAN',
1474 pid : $('#pid').val(),
1475 form_id : $('#form_id').val(),
1476 encounter : $('#encounter').val(),
1477 uniqueID : $('#uniqueID').val()
1479 }).done(function(result) {
1480 if (result == "Code 400") {
1481 code_400(); //the user does not have write privileges!
1482 return;
1484 obj.IMPPLAN_items = result;
1485 if (typeof display === "undefined") {
1486 build_IMPPLAN(obj.IMPPLAN_items);
1494 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1497 function CODING_to_feesheet(CODING_items) {
1498 if (typeof CODING_items !== "undefined") {
1499 var url = "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1500 var formData = JSON.stringify(CODING_items);
1501 top.restoreSession();
1502 $.ajax({
1503 type : 'POST',
1504 url : url,
1505 data : {
1506 parameter : formData,
1507 action : 'code_visit',
1508 pid : $('#pid').val(),
1509 form_id : $('#form_id').val(),
1510 encounter : $('#encounter').val(),
1511 uniqueID : $('#uniqueID').val()
1513 }).done(function(result) {
1514 if (result == "Code 400") {
1515 code_400(); //the user does not have write privileges!
1516 return;
1517 } else {
1518 $("#goto_fee_sheet").removeClass('nodisplay');
1526 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1527 * This item is appended to the $('#IMPPLAN_zone').
1529 function dragto_IMPPLAN_zone(event, ui) {
1530 var findme = ui.draggable.find("span").attr("id");
1531 var group = findme.match(/DX_(.*)_(.*)/)[1];
1532 var location = findme.match(/DX_(.*)_(.*)/)[2];
1533 var the_code ='';
1534 var the_codedesc ='';
1535 var the_codetext ='';
1536 var the_plan ='';
1537 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];
1538 if (group =="Clinical") {
1539 //more than one field can contain this DX.
1540 //Group them into one IMPPLAN.
1541 for (i=0;i < obj.Clinical[location].length; i++) {
1542 the_code += obj.Clinical[location][i]['code']+',';
1543 the_codedesc = obj.Clinical[location][i]['codedesc'];
1544 the_codetext = obj.Clinical[location][i]['codetext'];
1545 the_plan += obj.Clinical[location][i]['codedesc'] + "\r";
1547 if (i > 0) the_code = the_code.slice(0, -1);
1548 obj.IMPPLAN_items.push({
1549 code: the_code,
1550 codedesc: the_codedesc,
1551 codetext: the_codetext,
1552 codetype: obj.Clinical[location][0]['codetype'],
1553 plan: the_plan,
1554 PMSFH_link: obj.Clinical[location][0]['PMSFH_link'],
1555 title: obj.Clinical[location][0]['title']
1558 } else {
1559 obj.IMPPLAN_items.push({
1560 code: obj.PMSFH[group][location]['code'],
1561 codedesc: obj.PMSFH[group][location]['codedesc'],
1562 codetext: obj.PMSFH[group][location]['codetext'],
1563 codetype: obj.PMSFH[group][location]['codetype'],
1564 plan: obj.PMSFH[group][location]['comments'],
1565 PMSFH_link: obj.PMSFH[group][location]['PMSFH_link'],
1566 title: obj.PMSFH[group][location]['title']
1570 store_IMPPLAN(obj.IMPPLAN_items,'1');
1573 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field $('#IMP') <-- New Dx textarea
1574 * The data is appended to the end of the text.
1575 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1577 function dragto_IMPPLAN(event, ui) {
1578 var findme = ui.draggable.find("span").attr("id");
1579 var group = findme.match(/DX_(.*)_(.*)/)[1];
1580 var location = findme.match(/DX_(.*)_(.*)/)[2];
1581 var draggable2 = ui.draggable;
1582 if (group =="Clinical") {
1583 $('#IMP').val(ui.draggable[0].textContent+"\n");
1584 } else {
1585 $('#IMP').val(ui.draggable[0].textContent+"\n"+obj.PMSFH[group][location]['comments']);
1588 /* END Functions related to IMPPLAN Builder */
1590 function Suggest_visit_code() {
1591 //assume Eyes and established patient
1592 (Code_group != 'Eyes') ? (digit_2 = '9') : digit_2 = '2'; //920XX or 990XX
1593 (Code_new_est == 'New') ? (digit_4 = '0') : digit_4 = '1'; //9X01X or 9X00X
1594 if (detail_reached_exam =='1' && (detail_reached_HPI =='1')) {
1595 (Code_group =='Eyes') ? (digit_5 = '4') : (digit_5='3'); //920X4 or 990X3
1596 detailed = "comprehensive";
1597 } else {
1598 digit_5 = '2'; //920X2
1599 detailed = "intermediate";
1601 visit_desc = Code_new_est +" "+ detailed +" "+digit_5;
1602 visit_code = "9"+digit_2+"0"+digit_4+digit_5;
1603 $('#visit_codes').val("CPT4|"+visit_code+"|").change();
1606 * This function builds the codes and populates the billing table for this encounter.
1608 function build_CODING_list() {
1609 CODING_items =[];
1610 /* the following things get billed:
1611 1. Visit code(s) including neurosensory if performed
1612 2. Tests performed
1613 3. Diagnostic codes
1615 //1. Visit Codes.
1616 CODING_items.push({
1617 code: visit_code,
1618 codedesc: visit_desc,
1619 codetext: '',
1620 codetype: 'CPT4',
1621 title: 'Visit Code'
1623 //neurosensory
1624 if (CPT_92060 == 'here') {
1625 CODING_items.push({
1626 code: '92060',
1627 codedesc: 'Sensorimotor exam',
1628 codetext: 'Sensorimotor exam (CPT4:92060)',
1629 codetype: 'CPT4',
1630 title: 'Neuro/Sensorimotor Code'
1633 //2. Tests/procedures performed to bill
1634 $('.TESTS').each(function(i, obj) {
1635 //test
1636 if ($(this).is(':checked')) {
1637 var codetype = obj.value.match(/(.*):(.*)/)[1];
1638 var code = obj.value.match(/(.*):(.*)/)[2];
1639 CODING_items.push({
1640 'code': code,
1641 codedesc: obj.title,
1642 codetext: obj.codetext,
1643 codetype: codetype,
1644 title: obj.title
1648 //3. Diagnostic Codes
1649 $.each(obj.IMPPLAN_items, function( index, value ) {
1650 if (value['codetype']) {
1651 if (value['code'].match(/\,/g)) {
1652 //physical finding found in more than one location, more than one code...
1653 //if there is a comma in there, there is more than one code present. Split them out.
1654 // And all those in one group have the same link out (PMSFH_link) value
1655 var location = value.PMSFH_link.match(/Clinical_(.*)/)[1];
1656 for (i=0; i< obj.Clinical[location].length; i++) {
1657 CODING_items.push({
1658 code: obj.Clinical[location][i]['code'],
1659 codedesc: obj.Clinical[location][i]['codedesc'],
1660 codetext: obj.Clinical[location][i]['codetext'],
1661 codetype: obj.Clinical[location][i]['codetype'],
1662 title: obj.Clinical[location][i]['title']
1665 } else {
1666 CODING_items.push({
1667 code: value['code'],
1668 codedesc: value['codedesc'],
1669 codetext: value['codetext'],
1670 codetype: value['codetype'],
1671 title: value['title']
1676 CODING_to_feesheet(CODING_items);
1680 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1682 function toggle_active_flags(new_state) {
1683 if (($("#chart_status").val() == "off") || (new_state == "on")) {
1684 // we are read-only and we want to go active.
1685 $("#chart_status").val("on");
1686 $("#active_flag").html(" Active Chart ");
1687 $("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1688 $("#warning").addClass("nodisplay");
1689 $('input, select, textarea, a').removeAttr('disabled');
1690 $('input, textarea').removeAttr('readonly');
1691 } else {
1692 //else clicking this means we want to go from active to read-only
1693 $("#chart_status").val("off");
1694 $("#active_flag").html(" READ-ONLY ");
1695 $("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1696 $("#warning").removeClass("nodisplay");
1697 //we should tell the form fields to be disabled. should already be...
1698 $('input, select, textarea, a').attr('disabled', 'disabled');
1699 $('input, textarea').attr('readonly', 'readonly');
1700 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1701 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1702 this_form_id = $("#form_id").val();
1703 $("#COPY_SECTION").val("READONLY-"+this_form_id);
1707 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1709 function update_READONLY() {
1710 var data = {
1711 'action' : 'retrieve',
1712 'copy' : 'READONLY',
1713 'zone' : 'READONLY',
1714 'copy_to' : $("#form_id").val(),
1715 'copy_from' : $("#form_id").val(),
1716 'pid' : $("#pid").val()
1718 //we are going to update the whole form
1719 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1720 //We are not ready to actively chart, just looking to see how far along our staff is...
1721 //or maybe just looking ahead to see the who's being worked up in the next room?
1722 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1723 // yet it is updating every 10-15 seconds if another user is making changes.
1724 top.restoreSession();
1725 $.ajax({
1726 type : 'POST',
1727 dataType : 'json',
1728 url : "../../forms/eye_mag/save.php?copy=READONLY",
1729 data : data,
1730 success : function(result) {
1731 $.map(result, function(valhere, keyhere) {
1732 if ($("#"+keyhere).val() != valhere) {
1733 $("#"+keyhere).val(valhere).css("background-color","#CCF");
1735 if (keyhere.match(/MOTILITY_/)) {
1736 // Copy forward ductions and versions visually
1737 // Make each blank, and rebuild them
1738 $("[name='"+keyhere+"_1']").html('');
1739 $("[name='"+keyhere+"_2']").html('');
1740 $("[name='"+keyhere+"_3']").html('');
1741 $("[name='"+keyhere+"_4']").html('');
1742 if (keyhere.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO)/)) {
1743 // Show a horizontal (minus) tag.
1744 hash_tag = '<i class="fa fa-minus"></i>';
1745 } else { //show vertical tag
1746 hash_tag = '<i class="fa fa-minus rotate-left"></i>';
1748 for (index =1; index <= valhere; ++index) {
1749 $("#"+keyhere+"_"+index).html(hash_tag);
1751 } else if (keyhere.match(/^(ODVF|OSVF)\d$/)) {
1752 if (valhere =='1') {
1753 $("#FieldsNormal").prop('checked', false);
1754 $("#"+keyhere).prop('checked', true);
1755 $("#"+keyhere).val('1');
1756 } else {
1757 $("#"+keyhere).val('0');
1758 $("#"+keyhere).prop('checked', false);
1760 } else if (keyhere.match(/AMSLERO(.)/)) {
1761 var sidehere = keyhere.match(/AMSLERO(.)/);
1762 if (valhere < '1') valhere ='0';
1763 $("#"+keyhere).val(valhere);
1764 var srcvalue="AmslerO"+sidehere[1];
1765 document.getElementById(srcvalue).src = document.getElementById(srcvalue).src.replace(/\_\d/g,"_"+valhere);
1766 $("#AmslerO"+sidehere[1]+"value").text(valhere);
1767 } else if (keyhere.match(/VA$/)) {
1768 $("#"+keyhere+"_copy").val(valhere).css("background-color","#F0F8FF");;
1769 $("#"+keyhere+"_copy_brd").val(valhere).css("background-color","#F0F8FF");;
1770 } else if (keyhere.match(/^O.VA_/)) {
1771 var side=keyhere.match(/(O.)VA_(.)/)[1];
1772 var rx_number=keyhere.match(/(O.)VA_(.)/)[2];
1773 if (rx_number == '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1774 $('#'+side+'VA_1_copy').val(valhere).css("background-color","#F0F8FF");;
1775 $('#'+side+'VA_1_copy_brd').val(valhere).css("background-color","#F0F8FF");;
1777 } else if (keyhere.match(/^RX_TYPE_\d$/)) {
1778 if (typeof $('input:radio[name='+keyhere+']')[valhere] !== "undefined") {
1779 $('input:radio[name='+keyhere+']')[valhere].checked = true;
1781 } else if (keyhere.match(/(alert|oriented|confused|PUPIL_NORMAL)/)) {
1782 if (valhere =='1') {
1783 $('#'+keyhere).val(valhere).prop('checked', true);
1784 } else {
1785 $('#'+keyhere).val(valhere).prop('checked', false);
1789 }});
1791 function dopopup(url) {
1792 window.open(url, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1794 function goto_url(url) {
1795 window.open(url);
1797 function openImage() {
1798 dlgopen(base+'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1801 * Keyboard shortcut commands.
1804 shortcut.add("Ctrl+T",function() {
1805 show_TEXT();
1807 shortcut.add("Meta+T",function() {
1808 show_TEXT();
1810 shortcut.add("Ctrl+D",function() {
1811 show_DRAW();
1813 shortcut.add("Meta+D",function() {
1814 show_DRAW();
1816 shortcut.add("Control+P",function() {
1817 $("#PRIOR_ALL").val($('#form_id').val()).trigger("change");
1819 shortcut.add("Meta+P",function() {
1820 show_PRIORS();
1821 $("#PRIOR_ALL").val($('#form_id').val()).trigger("change");
1823 shortcut.add("Ctrl+B",function() {
1824 show_QP();
1826 shortcut.add("Meta+B",function() {
1827 show_QP();
1829 shortcut.add("Ctrl+K",function() {
1830 show_KB();
1832 shortcut.add("Meta+K",function() {
1833 show_KB();
1835 $(function(){
1837 * this swallows backspace keys on the "rx" elements.
1838 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1840 var rx = /INPUT|SELECT|TEXTAREA|SPAN|DIV/i;
1842 $(document).bind("keydown keypress", function(e){
1843 if( e.which == 8 ){ // 8 == backspace
1844 if(!rx.test(e.target.tagName) || e.target.disabled || e.target.readOnly ){
1845 e.preventDefault();
1851 /* Undo feature
1852 * RIGHT NOW THIS WORKS PER FIELD ONLY in FF. In Chrome it works great. Not sure about IE at all.
1853 * In FF, you select a field and CTRL-Z reverses/Shift-Ctrl-Z forwards value
1854 * To get true Undo Redo, we will need to create two arrays, one with the command/field, prior value, next value to undo
1855 * and when undone, add this to the REDO array. When an Undo command is followed by anything other than Redo, it erases REDO array.
1856 * Ctrl-Z works without this extra code! Fuzzy on the details for specific browsers so TODO.
1861 * Function to update the PCP and referring person
1864 function update_DOCS() {
1865 var url = "../../forms/eye_mag/save.php?mode=update";
1866 top.restoreSession();
1867 $.ajax({
1868 type : 'POST',
1869 url : url,
1870 data : {
1871 action : 'docs',
1872 pid : $('#pid').val(),
1873 pcp : $('#form_PCP').val(),
1874 rDOC : $('#form_rDOC').val(),
1875 form_id : $('#form_id').val(),
1876 encounter : $('#encounter').val(),
1877 uniqueID : $('#uniqueID').val()
1879 }).done(function(result) {
1880 if (result == "Code 400") {
1881 code_400(); //the user does not have write privileges!
1882 return;
1888 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
1891 function reverse_cylinder(target) {
1892 //target can be revW1-5,AR,MR,CR,CTL,
1893 var prefix;
1894 var suffix;
1895 if (target.match(/^(AR|MR|CR|CTL)$/)) {
1896 prefix = target;
1897 suffix = '';
1899 if (target.match(/^revW[1-5]{1}$/)) { //matches on digit only, here 1-5
1900 target = target.replace("revW","");
1901 prefix = '';
1902 suffix = '_'+target;
1904 var Rsph = $('#'+prefix+'ODSPH'+suffix).val();
1905 var Rcyl = $('#'+prefix+'ODCYL'+suffix).val();
1906 var Raxis = $('#'+prefix+'ODAXIS'+suffix).val();
1907 var Lsph = $('#'+prefix+'OSSPH'+suffix).val();
1908 var Lcyl = $('#'+prefix+'OSCYL'+suffix).val();
1909 var Laxis = $('#'+prefix+'OSAXIS'+suffix).val();
1910 if (Rsph=='' && Rcyl =='' && Lsph=='' && lcyl =='') return;
1911 if ((!Rcyl.match(/SPH/i)) && (Rcyl >'')) {
1912 if (Rsph.match(/plano/i)) Rsph ='0';
1913 Rsph = Number(Rsph);
1914 Rcyl = Number(Rcyl);
1915 Rnewsph = Rsph + Rcyl;
1916 if (Rnewsph ==0) Rnewsph ="PLANO";
1917 Rnewcyl = Rcyl * -1;
1918 if (Rnewcyl > 0) Rnewcyl = "+"+Rnewcyl;
1919 if (parseInt(Raxis) < 90) {
1920 Rnewaxis = parseInt(Raxis) + 90;
1921 } else {
1922 Rnewaxis = parseInt(Raxis) - 90;
1924 if (Rnewcyl=='0') Rnewcyl = "SPH";
1925 if (Rnewsph =='0') {
1926 Rnewsph ="PLANO";
1927 if (Rnewcyl =="SPH") Rnewcyl = '';
1929 $('#'+prefix+'ODSPH'+suffix).val(Rnewsph);
1930 $('#'+prefix+'ODCYL'+suffix).val(Rnewcyl);
1931 $('#'+prefix+'ODAXIS'+suffix).val(Rnewaxis);
1932 $('#'+prefix+'ODAXIS'+suffix).trigger('blur');
1933 $('#'+prefix+'ODSPH'+suffix).trigger('blur');
1934 $('#'+prefix+'ODCYL'+suffix).trigger('blur');
1936 if ((!Lcyl.match(/SPH/i)) && (Lcyl >'')) {
1937 if (!Lsph.match(/\d/)) Lsph ='0';
1938 Lsph = Number(Lsph);
1939 Lcyl = Number(Lcyl);
1940 Lnewsph = Lsph + Lcyl;
1941 Lnewcyl = Lcyl * -1;
1942 if (Lnewcyl > 0) Lnewcyl = "+"+ Lnewcyl;
1943 if (parseInt(Laxis) < 90) {
1944 Lnewaxis = parseInt(Laxis) + 90;
1945 } else {
1946 Lnewaxis = parseInt(Laxis) - 90;
1949 if (Lnewcyl=='0') Lnewcyl = "SPH";
1950 if (Lnewsph =='0') {
1951 Lnewsph ="PLANO";
1952 if (Lnewcyl =="SPH") Lnewcyl = '';
1955 $('#'+prefix+'OSSPH'+suffix).val(Lnewsph);
1956 $('#'+prefix+'OSCYL'+suffix).val(Lnewcyl);
1957 $('#'+prefix+'OSAXIS'+suffix).val(Lnewaxis);
1958 $('#'+prefix+'OSAXIS'+suffix).trigger('blur');
1959 $('#'+prefix+'OSSPH'+suffix).trigger('blur');
1960 $('#'+prefix+'OSCYL'+suffix).trigger('blur');
1963 function scrollTo(target) {
1964 //if (scroll !== '1') return;
1965 var offset;
1966 var scrollSpeed = 2000;
1967 var wheight = $(window).height();
1968 offset = $("#"+target).offset().top - (wheight / 2)+200;
1969 if (offset > (window.pageYOffset +150)||offset < (window.pageYOffset -150)) {
1970 $('html, body').animate({scrollTop:offset}, scrollSpeed);
1974 $(document).ready(function() {
1975 check_lock();
1976 $('[title]').qtip({
1977 position: {
1978 my: 'top Right', // Position my top left...
1979 at: 'bottom Left', // at the bottom right of...
1980 target: 'mouse' // my target
1984 $('#form_PCP,#form_rDOC').change(function() {
1985 update_DOCS();
1987 $('#tooltips_status').html($('#PREFS_TOOLTIPS').val());
1988 if ($("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
1989 $('[title]').qtip('disable');
1991 $('#tooltips_toggle,#tooltips_status').click(function() {
1992 if ($("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
1993 $('#PREFS_TOOLTIPS').val('<?php echo xla('Off'); ?>');
1994 $("#tooltips_status").html('<?php echo xla('are off'); ?>');
1995 $('[title]').qtip('disable');
1996 } else {
1997 $('#PREFS_TOOLTIPS').val('<?php echo xla('On'); ?>');
1998 $('#tooltips_status').html('<?php echo xla('are on'); ?>');
1999 $('[title]').qtip('enable');
2001 update_PREFS();
2003 $('#toggle_drugs').click(function(){
2004 $('.hideme_drugs').toggleClass('nodisplay');
2005 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2006 return false;
2008 $('#toggle_VFs').click(function(){
2009 $('.hideme_VFs').toggleClass('nodisplay');
2010 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2011 return false;
2013 $('#toggle_OCTs').click(function(){
2014 $('.hideme_OCTs').toggleClass('nodisplay');
2015 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2016 return false;
2018 $('#toggle_cups').click(function(){
2019 $('.hideme_cups').toggleClass('nodisplay');
2020 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2021 return false;
2023 $('#toggle_gonios').click(function(){
2024 $('.hideme_gonios').toggleClass('nodisplay');
2025 $(this).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2026 return false;
2028 $('.close').click(function(){
2029 $('#GFS_accordion .hide').slideUp();
2031 $('#ODIOPTARGET').change(function() {
2032 $('#OSIOPTARGET').val($('#ODIOPTARGET').val());
2033 refresh_GFS();
2035 $('#ODIOPAP,#OSIOPAP,#ODIOPTARGET').change(function() {
2036 //this is failing if there is no config_by_day variable.
2037 refresh_GFS();
2039 if ($("#PREFS_KB").val() =='1') {
2040 $(".kb").removeClass('nodisplay');
2041 $(".kb_off").addClass('nodisplay');
2042 } else {
2043 $(".kb").addClass('nodisplay');
2044 $(".kb_off").removeClass('nodisplay');
2047 $("[name$='_kb']").click(function() {
2048 $('.kb').toggleClass('nodisplay');
2049 $('.kb_off').toggleClass('nodisplay');
2050 if ($('#PREFS_EXAM').val() == 'DRAW') {
2051 show_TEXT();
2054 if ($("#PREFS_KB").val() > 0) {
2055 $("#PREFS_KB").val('0');
2056 } else {
2057 $("#PREFS_KB").val('1');
2059 update_PREFS();
2061 $('.ke').mouseover(function() {
2062 $(this).toggleClass('yellow');
2064 $('.ke').mouseout(function() {
2065 $(this).toggleClass('yellow');
2067 $("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e) {
2068 //this is the Shorthand engine's ignition
2069 if (e.which == 13|| e.keyCode == 13||e.which == 9|| e.keyCode == 9) {
2070 e.preventDefault();
2071 var data_all = $(this).val();
2072 var data_seg = data_all.match(/([^;]*)/gm);
2073 var field2 ='';
2074 var appendix =".a";
2075 var zone;
2076 for (index=0; index < data_seg.length; ++index) {
2077 if (data_seg[index] =='') continue;
2078 data_seg[index] = data_seg[index].replace(/^[\n\v\f\r\x85\u2028\u2029\W]*/,'');
2079 data_seg[index] = data_seg[index].replace(/^[\s]*/,'');
2080 if (data_seg[index].match(/^D($|;)/i)) {
2081 $("#EXT_defaults").trigger("click");
2082 $("#ANTSEG_defaults").trigger("click");
2083 $("#RETINA_defaults").trigger("click");
2084 $("#NEURO_defaults").trigger("click");
2085 continue;
2087 if (data_seg[index].match(/^DEXT($|;)/i)) {
2088 $("#EXT_defaults").trigger("click");
2089 continue;
2091 if (data_seg[index].match(/^DANTSEG($|;)/i)) {
2092 $("#ANTSEG_defaults").trigger("click");
2093 continue;
2095 if (data_seg[index].match(/^DAS($|;)/i)) {
2096 $("#ANTSEG_defaults").trigger("click");
2097 continue;
2099 if (data_seg[index].match(/^DRETINA($|;)/i)) {
2100 $("#RETINA_defaults").trigger("click");
2101 continue;
2103 if (data_seg[index].match(/^DRET($|;)/i)) {
2104 $("#RETINA_defaults").trigger("click");
2105 continue;
2107 if (data_seg[index].match(/^DNEURO($|;)/i)) {
2108 $("#NEURO_defaults").trigger("click");
2109 continue;
2111 if ((data_seg[index].match(/^CLEAREXT($|;)/i))||
2112 (data_seg[index].match(/^CEXT($|;)/i))) {
2113 $(".EXT").val('');
2114 continue;
2116 if ((data_seg[index].match(/^CLEARAS($|;)/i))||
2117 (data_seg[index].match(/^CLEARANTSEG($|;)/i))||
2118 (data_seg[index].match(/^CANTSEG($|;)/i))||
2119 (data_seg[index].match(/^CANT($|;)/i))||
2120 (data_seg[index].match(/^CAS($|;)/i))) {
2121 $(".ANTSEG").val('');
2122 continue;
2124 if ((data_seg[index].match(/^CLEARRET($|;)/i))||
2125 (data_seg[index].match(/^CRET($|;)/i)) ||
2126 (data_seg[index].match(/^CLEARRETINA($|;)/i))||
2127 (data_seg[index].match(/^CRETINA($|;)/i))) {
2128 $(".RETINA").val('');
2129 continue;
2132 appendix=".a";
2133 var data = data_seg[index].match(/^(\w*)\:?(.*)/);
2134 (data[2].match(/\.a$/))?(data[2] = data[2].replace(/\.a$/,'')):(appendix = "nope");
2135 var field = data[1].toUpperCase();
2136 var text = data[2];
2137 text = expand_vocab(text);
2138 priors = process_kb(field,text,appendix,prior_field,prior_text);
2139 prior_field = priors['field'];
2140 prior_text = priors['prior_text'];
2143 submit_form('2');
2144 $(this).val('');
2148 $("[id^='sketch_tools_']").click(function() {
2149 var zone = this.id.match(/sketch_tools_(.*)_/)[1];
2150 $("[id^='sketch_tools_"+zone+"']").css("height","30px");
2151 $(this).css("height","50px");
2153 $("[id^='sketch_sizes_']").click(function() {
2154 var zone = this.id.match(/sketch_sizes_(.*)_/)[1];
2155 $("[id^='sketch_sizes_"+zone+"']").css("background","").css("border-bottom","");
2156 $(this).css("border-bottom","2pt solid black");
2159 // Here we get CC1 to show
2160 $(".tab_content").addClass('nodisplay');
2161 $("#tab1_CC_text").removeClass('nodisplay');
2162 $("#tab1_HPI_text").removeClass('nodisplay');
2163 $("[id$='_CC'],[id$='_HPI_tab']").click(function() {
2164 // First remove class "active" from currently active tabs
2165 $("[id$='_CC']").removeClass('active');
2166 $("[id$='_HPI_tab']").removeClass('active');
2167 // Hide all tab content
2168 $(".tab_content").addClass('nodisplay');
2169 // Here we get the href value of the selected tab
2170 var selected_tab = $(this).find("a").attr("href");
2171 // Now add class "active" to the selected/clicked tab and content
2172 $(selected_tab+"_CC").addClass('active');
2173 $(selected_tab+"_CC_text").removeClass('nodisplay');
2174 $(selected_tab+"_HPI_tab").addClass('active');
2175 $(selected_tab+"_HPI_text").removeClass('nodisplay');
2176 // At the end, we add return false so that the click on the link is not executed
2177 return false;
2179 $("[id^='CONSTRUCTION_']").toggleClass('nodisplay');
2180 $("input,textarea,text").css("background-color","#FFF8DC");
2181 $("#IOPTIME").css("background-color","#FFFFFF");
2182 $("#refraction_width").css("width","8.5in");
2183 $(".Draw_class").addClass('nodisplay');
2184 $(".PRIORS_class").addClass('nodisplay');
2185 hide_DRAW();
2186 hide_right();
2187 $(window).resize(function() {
2188 if (window.innerWidth >'900') {
2189 $("#refraction_width").css("width","900px");
2190 $("#LayerVision2").css("padding","4px");
2192 if (window.innerWidth >'1300') {
2193 $("#refraction_width").css("width","1300px");
2194 //$("#first").css("width","1300px");
2196 if (window.innerWidth >'1900') {
2197 $("#refraction_width").css("width","1600px");
2201 $(window).resize();
2203 var hash_tag = '<i class="fa fa-minus"></i>';
2204 var index;
2205 // display any stored MOTILITY values
2206 $("#MOTILITY_RS").value = parseInt($("#MOTILITY_RS").val());
2207 if ($("#MOTILITY_RS").val() > '0') {
2208 $("#MOTILITYNORMAL").removeAttr('checked');
2209 for (index =1; index <= ($("#MOTILITY_RS").val()); ++index) {
2210 $("#MOTILITY_RS_"+index).html(hash_tag);
2213 $("#MOTILITY_RI").value = parseInt($("#MOTILITY_RI").val());
2214 if ($("#MOTILITY_RI").val() > '0') {
2215 $("#MOTILITYNORMAL").removeAttr('checked');
2216 for (index =1; index <= ($("#MOTILITY_RI").val()); ++index) {
2217 $("#MOTILITY_RI_"+index).html(hash_tag);
2220 $("#MOTILITY_LS").value = parseInt($("#MOTILITY_LS").val());
2221 if ($("#MOTILITY_LS").val() > '0') {
2222 $("#MOTILITYNORMAL").removeAttr('checked');
2223 for (index =1; index <= ($("#MOTILITY_LS").val()); ++index) {
2224 $("#MOTILITY_LS_"+index).html(hash_tag);
2227 $("#MOTILITY_LI").value = parseInt($("#MOTILITY_LI").val());
2228 if ($("#MOTILITY_LI").val() > '0') {
2229 $("#MOTILITYNORMAL").removeAttr('checked');
2230 for (index =1; index <= ($("#MOTILITY_LI").val()); ++index) {
2231 $("#MOTILITY_LI_"+index).html(hash_tag);
2235 $("#MOTILITY_RRSO").value = parseInt($("#MOTILITY_RRSO").val());
2236 if ($("#MOTILITY_RRSO").val() > '0') {
2237 $("#MOTILITYNORMAL").removeAttr('checked');
2238 for (index =1; index <= ($("#MOTILITY_RRSO").val()); ++index) {
2239 $("#MOTILITY_RRSO_"+index).html(hash_tag);
2242 $("#MOTILITY_RRIO").value = parseInt($("#MOTILITY_RRIO").val());
2243 if ($("#MOTILITY_RRIO").val() > '0') {
2244 $("#MOTILITYNORMAL").removeAttr('checked');
2245 for (index =1; index <= ($("#MOTILITY_RRIO").val()); ++index) {
2246 $("#MOTILITY_RRIO_"+index).html(hash_tag);
2249 $("#MOTILITY_RLIO").value = parseInt($("#MOTILITY_RLIO").val());
2250 if ($("#MOTILITY_RLIO").val() > '0') {
2251 $("#MOTILITYNORMAL").removeAttr('checked');
2252 for (index =1; index <= ($("#MOTILITY_RLIO").val()); ++index) {
2253 $("#MOTILITY_RLIO_"+index).html(hash_tag);
2256 $("#MOTILITY_RLSO").value = parseInt($("#MOTILITY_RLSO").val());
2257 if ($("#MOTILITY_RLSO").val() > '0') {
2258 $("#MOTILITYNORMAL").removeAttr('checked');
2259 for (index =1; index <= ($("#MOTILITY_RLSO").val()); ++index) {
2260 $("#MOTILITY_RLSO_"+index).html(hash_tag);
2263 $("#MOTILITY_LRSO").value = parseInt($("#MOTILITY_LRSO").val());
2264 if ($("#MOTILITY_LRSO").val() > '0') {
2265 $("#MOTILITYNORMAL").removeAttr('checked');
2266 for (index =1; index <= ($("#MOTILITY_LRSO").val()); ++index) {
2267 $("#MOTILITY_LRSO_"+index).html(hash_tag);
2270 $("#MOTILITY_LRIO").value = parseInt($("#MOTILITY_LRIO").val());
2271 if ($("#MOTILITY_LRIO").val() > '0') {
2272 $("#MOTILITYNORMAL").removeAttr('checked');
2273 for (index =1; index <= ($("#MOTILITY_LRIO").val()); ++index) {
2274 $("#MOTILITY_LRIO_"+index).html(hash_tag);
2277 $("#MOTILITY_LLSO").value = parseInt($("#MOTILITY_LLSO").val());
2278 if ($("#MOTILITY_LLSO").val() > '0') {
2279 $("#MOTILITYNORMAL").removeAttr('checked');
2280 for (index =1; index <= ($("#MOTILITY_LLSO").val()); ++index) {
2281 $("#MOTILITY_LLSO_"+index).html(hash_tag);
2284 $("#MOTILITY_LLIO").value = parseInt($("#MOTILITY_LLIO").val());
2285 if ($("#MOTILITY_LLIO").val() > '0') {
2286 $("#MOTILITYNORMAL").removeAttr('checked');
2287 for (index =1; index <= ($("#MOTILITY_LLIO").val()); ++index) {
2288 $("#MOTILITY_LLIO_"+index).html(hash_tag);
2292 var hash_tag = '<i class="fa fa-minus rotate-left"></i>';
2293 $("#MOTILITY_LR").value = parseInt($("#MOTILITY_LR").val());
2294 if ($("#MOTILITY_LR").val() > '0') {
2295 $("#MOTILITYNORMAL").removeAttr('checked');
2296 for (index =1; index <= ($("#MOTILITY_LR").val()); ++index) {
2297 $("#MOTILITY_LR_"+index).html(hash_tag);
2300 $("#MOTILITY_LL").value = parseInt($("#MOTILITY_LL").val());
2301 if ($("#MOTILITY_LL").val() > '0') {
2302 $("#MOTILITYNORMAL").removeAttr('checked');
2303 for (index =1; index <= ($("#MOTILITY_LL").val()); ++index) {
2304 $("#MOTILITY_LL_"+index).html(hash_tag);
2307 $("#MOTILITY_RR").value = parseInt($("#MOTILITY_RR").val());
2308 if ($("#MOTILITY_RR").val() > '0') {
2309 $("#MOTILITYNORMAL").removeAttr('checked');
2310 for (index =1; index <= ($("#MOTILITY_RR").val()); ++index) {
2311 $("#MOTILITY_RR_"+index).html(hash_tag);
2314 $("#MOTILITY_RL").value = parseInt($("#MOTILITY_RL").val());
2315 if ($("#MOTILITY_RL").val() > '0') {
2316 $("#MOTILITYNORMAL").removeAttr('checked');
2317 for (index =1; index <= ($("#MOTILITY_RL").val()); ++index) {
2318 $("#MOTILITY_RL_"+index).html(hash_tag);
2322 $(".chronic_HPI,.count_HPI").blur(function() {
2323 check_exam_detail();
2325 // Dilation status
2326 $("#DIL_RISKS").change(function(o) {
2327 ($(this).is(':checked')) ? ($(".DIL_RISKS").removeClass("nodisplay")) : ($(".DIL_RISKS").addClass("nodisplay"));
2328 check_exam_detail();
2330 $(".dil_drug").change(function(o) {
2331 if ($(this).is(':checked')) {
2332 //($(".DIL_RISKS").removeClass("nodisplay"));
2333 $("#DIL_RISKS").prop("checked","checked");
2334 check_exam_detail();
2335 }});
2337 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2338 $(".neurosens,.neurosens2").blur(function() {
2339 check_CPT_92060();
2341 // END AUTO-CODING FEATURES
2343 // functions to improve flow of refraction input
2344 $("input[name$='PRISM'],input[class^='prism']").blur(function() {
2345 //make it all caps
2346 var str = $(this).val();
2347 str = str.toUpperCase();
2348 $(this).val(str);
2350 $('input[class^="sphere"],input[name$="SPH"]').blur(function() {
2351 var mid = $(this).val();
2352 if (mid.match(/PLANO/i)) {
2353 $(this).val('PLANO');
2354 return;
2356 if (mid.match(/^[\+\-]?\d{1}$/)) {
2357 mid = mid+".00";
2359 if (mid.match(/\.[27]$/)) {
2360 mid = mid + '5';
2362 if (mid.match(/\.\d$/)) {
2363 mid = mid + '0';
2365 //if near is +2. make it +2.00
2366 if (mid.match(/\.$/)) {
2367 mid= mid + '00';
2369 if ((!mid.match(/\./))&&(mid.match(00|25|50|75))) {
2370 var front = mid.match(/(\d{0,2})(00|25|50|75)/)[1];
2371 var back = mid.match(/(\d{0,2})(00|25|50|75)/)[2];
2372 if (front =='') front ='0';
2373 mid = front + "." + back;
2375 if (!mid.match(/\./)) {
2376 var front = mid.match(/([\+\-]?\d{0,2})(\d{2})/)[1];
2377 var back = mid.match(/(\d{0,2})(\d{2})/)[2];
2378 if (front =='') front ='0';
2379 if (front =='-') front ='-0';
2380 mid = front + "." + back;
2382 if (!mid.match(/^(\+|\-){1}/)) {
2383 mid = "+" + mid;
2385 $(this).val(mid);
2388 $("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").blur(function() {
2389 var add = $(this).val();
2390 add = add.replace(/=/g,"+");
2391 //if add is one digit, eg. 2, make it +2.00
2392 if (add.match(/^\d{1}$/)) {
2393 add = "+"+add+".00";
2395 //if add is '+'one digit, eg. +2, make it +2.00
2396 if (add.match(/^\+\d{1}$/)) {
2397 add = add+".00";
2399 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2400 if (add.match(/\.[05]$/)) {
2401 add = add + '0';
2403 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2404 if (add.match(/\.[27]$/)) {
2405 add = add + '5';
2407 //if add is +2. make it +2.00
2408 if (add.match(/\.$/)) {
2409 add = add + '00';
2411 if ((!add.match(/\./))&&(add.match(/(0|25|50|75)$/))) {
2412 var front = add.match(/([\+]?\d{0,1})(00|25|50|75)/)[1];
2413 var back = add.match(/([\+]?\d{0,1})(00|25|50|75)/)[2];
2414 if (front =='') front ='0';
2415 add = front + "." + back;
2417 if (!add.match(/^(\+)/) && (add.length > 0)) {
2418 add= "+" + add;
2420 $(this).val(add);
2421 if (this.id=="ODADD_1") $('#OSADD_1').val(add);
2422 if (this.id=="ODMIDADD_1") $('#OSMIDADD_1').val(add);
2423 if (this.id=="ODADD_2") $('#OSADD_2').val(add);
2424 if (this.id=="ODMIDADD_2") $('#OSMIDADD_2').val(add);
2425 if (this.id=="ODADD_3") $('#OSADD_3').val(add);
2426 if (this.id=="ODMIDADD_3") $('#OSMIDADD_3').val(add);
2427 if (this.id=="ODADD_4") $('#OSADD_4').val(add);
2428 if (this.id=="ODMIDADD_4") $('#OSMIDADD_4').val(add);
2429 if (this.id=="ODADD_5") $('#OSADD_5').val(add);
2430 if (this.id=="ODMIDADD_5") $('#OSMIDADD_5').val(add);
2431 if (this.id=="MRODADD") $('#MROSADD').val(add);
2432 if (this.id=="ARODADD") $('#AROSADD').val(add);
2433 if (this.id=="CTLODADD") $('#CTLOSADD').val(add);
2436 $("input[class^='axis'],input[name$='AXIS']").blur(function() {
2437 // Make this a 3 digit leading zeros number.
2438 // we are not translating text to numbers, just numbers to
2439 // a 3 digit format with leading zeroes as needed.
2440 // assume the end user KNOWS there are only numbers presented and
2441 // more than 3 digits is a mistake...
2442 // (although this may change with topography)
2443 var axis = $(this).val();
2444 var group = this.name.replace("AXIS", "CYL");;
2445 var cyl = $("#"+group).val();
2446 if ((cyl > '') && (cyl != 'SPH')) {
2447 if (!axis.match(/\d\d\d/)) {
2448 if (!axis.match(/\d\d/)) {
2449 if (!axis.match(/\d/)) {
2450 axis = '0';
2452 axis = '0' + axis;
2454 axis = '0' + axis;
2456 } else {
2457 axis = '';
2459 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2460 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2461 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2462 //the devices.
2463 $(this).val(axis);
2465 $("input[class^='cylinder'],input[name$='CYL']").blur(function() {
2466 var mid = $(this).val();
2467 var group = this.name.replace("CYL", "SPH");;
2468 var sphere = $("#"+group).val();
2469 if (((mid.length == 0) && (sphere.length > 0))||(mid.match(/sph/i))) {
2470 $(this).val('SPH');
2471 if (sphere.match(/plano/i)) $(this).val('');
2472 var axis = this.name.replace("CYL", "AXIS");
2473 $("#"+axis).val('');
2474 submit_form($(this));
2475 return;
2476 } else if (sphere.length > 0) {
2477 if (mid.match(/^[\+\-]?\d{1}$/)) {
2478 mid = mid+".00";
2480 if (mid.match(/^(\d)(\d)$/)) {
2481 mid = mid[0] + '.' +mid[1];
2484 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2485 if (mid.match(/\.[05]$/)) {
2486 mid = mid + '0';
2488 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2489 if (mid.match(/\.[27]$/)) {
2490 mid = mid + '5';
2492 //if mid is +2. make it +2.00
2493 if (mid.match(/\.$/)) {
2494 mid = mid + '00';
2496 if (mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)) {
2497 var front = mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)[1];
2498 var back = mid.match(/([\+\-]?\d{0,2})\.?(00|25|50|75)/)[2];
2499 if (front =='') front ='0';
2500 mid = front + "." + back;
2502 if (!$('#PREFS_CYL').val()) {
2503 $('#PREFS_CYL').val('+');
2504 update_PREFS();
2506 if (!mid.match(/^(\+|\-){1}/) && (sphere.length > 0)) {
2507 //no +/- sign at the start of the field.
2508 //ok so there is a preference set
2509 //Since it doesn't start with + or - then give it the preference value
2510 mid = $('#PREFS_CYL').val() + mid;
2511 } else if (mid.match(/^(\+|\-){1}/)) {
2512 pref = mid.match(/^(\+|\-){1}/)[0];
2513 //so they used a value + or - at the start of the field.
2514 //The only reason to work on this is to change to cylinder preference
2515 if ($('#PREFS_CYL').val() != pref){
2516 //and that is what they are doing here
2517 $('#PREFS_CYL').val(pref);
2518 update_PREFS();
2521 $(this).val(mid);
2524 //bootstrap menu functions
2525 $("[class='dropdown-toggle']").hover(function(){
2526 $("[class='dropdown-toggle']").parent().removeClass('open');
2527 var menuitem = this.id.match(/(.*)/)[1];
2528 //if the menu is active through a prior click, show it
2529 // Have to override Bootstrap then
2530 if ($("#menustate").val() !="1") { //menu not active -> ignore
2531 $("#"+menuitem).css("background-color", "#C9DBF2");
2532 $("#"+menuitem).css("color","#000"); /*#262626;*/
2533 } else { //menu is active -> respond
2534 $("#"+menuitem).css("background-color", "#1C5ECF");
2535 $("#"+menuitem).css("color","#fff"); /*#262626;*/
2536 $("#"+menuitem).css("text-decoration","none");
2537 $("#"+menuitem).parent().addClass('open');
2539 },function() {
2540 var menuitem = this.id.match(/(.*)/)[1];
2541 $("#"+menuitem).css("color","#000"); /*#262626;*/
2542 $("#"+menuitem).css("background-color", "#C9DBF2");
2545 $("[class='dropdown-toggle']").click(function() {
2546 $("#menustate").val('1');
2547 var menuitem = this.id.match(/(.*)/)[1];
2548 $("#"+menuitem).css("background-color", "#1C5ECF");
2549 $("#"+menuitem).css("color","#fff"); /*#262626;*/
2550 $("#"+menuitem).css("text-decoration","none");
2552 $("#right-panel-link, #close-panel-bt,#right-panel-link_2").click(function() {
2553 if ($("#PREFS_PANEL_RIGHT").val() =='1') {
2554 $("#PREFS_PANEL_RIGHT").val('0');
2555 } else {
2556 $("#PREFS_PANEL_RIGHT").val('1');
2558 update_PREFS();
2560 $("[name^='menu_']").click(function() {
2561 $("[name^='menu_']").removeClass('active');
2562 var menuitem = this.id.match(/menu_(.*)/)[1];
2563 $(this).addClass('active');
2564 $("#menustate").val('1');
2565 menu_select(menuitem);
2567 // set display functions for Draw panel appearance
2568 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2569 var zones = ["PMH","HPI","EXT","ANTSEG","RETINA","NEURO","IMPPLAN"];
2570 for (index = '0'; index < zones.length; ++index) {
2571 if ($("#PREFS_"+zones[index]+"_RIGHT").val() =='DRAW') {
2572 show_DRAW_section(zones[index]);
2573 } else if ($("#PREFS_"+zones[index]+"_RIGHT").val() =='QP') {
2574 show_QP_section(zones[index]);
2577 $("body").on("click","[name$='_text_view']" , function() {
2578 var header = this.id.match(/(.*)_text_view$/)[1];
2579 $("#"+header+"_text_list").toggleClass('wide_textarea');
2580 $("#"+header+"_text_list").toggleClass('narrow_textarea');
2581 $(this).toggleClass('fa-plus-square-o');
2582 $(this).toggleClass('fa-minus-square-o');
2583 if (header != /PRIOR/) {
2584 var imagine = $("#PREFS_"+header+"_VIEW").val();
2585 imagine ^= true;
2586 $("#PREFS_"+header+"_VIEW").val(imagine);
2587 update_PREFS();
2589 return false;
2591 $("body").on("change", "select", function(e){
2592 if (this.name.match(/PRIOR_(.*)/)) {
2593 var new_section = this.name.match(/PRIOR_(.*)/);
2594 if (new_section[1] =='') return;
2595 if (new_section[1] == /\_/){
2596 return;
2598 var newValue = this.value;
2599 if (newValue == $("#form_id").val()) {
2600 if (new_section[1] =="ALL") {
2601 //click updates prefs too
2602 $('#EXAM_QP').trigger("click");
2603 } else {
2604 $('#BUTTON_QP_'+new_section[1]).trigger("click");
2606 return;
2608 //now go get the prior page via ajax
2609 var newValue = this.value;
2610 $("#PRIORS_"+ new_section[1] +"_left_text").removeClass('nodisplay');
2611 $("#DRAWS_" + new_section[1] + "_right").addClass('nodisplay');
2612 $("#QP_" + new_section[1]).addClass('nodisplay');
2614 if (new_section[1] =="ALL") {
2615 show_PRIORS();
2616 show_PRIORS_section("ALL",newValue);
2617 show_PRIORS_section("EXT",newValue);
2618 show_PRIORS_section("ANTSEG",newValue);
2619 show_PRIORS_section("RETINA",newValue);
2620 show_PRIORS_section("NEURO",newValue);
2621 show_PRIORS_section("IMPPLAN",newValue);
2622 } else {
2623 show_PRIORS_section(new_section[1],newValue);
2627 $("body").on("click","[id^='Close_PRIORS_']", function() {
2628 var new_section = this.id.match(/Close_PRIORS_(.*)$/)[1];
2629 $("#PRIORS_"+ new_section +"_left_text").addClass('nodisplay');
2630 $("#QP_" + new_section).removeClass('nodisplay');
2632 $("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").mouseover(function() {
2633 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2635 $("#pupils,#vision_tab,[name='CTL']").mouseout(function() {
2636 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline');
2638 $("#pupils").click(function(){
2639 if ($("#dim_pupils_panel").hasClass("nodisplay")) {
2640 $("#dim_pupils_panel").removeClass('nodisplay');
2641 } else {
2642 $("#dim_pupils_panel").fadeToggle();
2645 $("#vision_tab").click(function(){
2646 $("#REFRACTION_sections").toggleClass('nodisplay');
2647 ($("#PREFS_VA").val() =='1') ? ($("#PREFS_VA").val('0')) : $("#PREFS_VA").val('1');
2649 //set wearing to single vision or bifocal? Bifocal
2650 $(".WNEAR").removeClass('nodisplay');
2651 $("#WNEARODAXIS").addClass('nodisplay');
2652 $("#WNEARODCYL").addClass('nodisplay');
2653 $("#WNEARODPRISM").addClass('nodisplay');
2654 $("#WNEAROSAXIS").addClass('nodisplay');
2655 $("#WNEAROSCYL").addClass('nodisplay');
2656 $("#WNEAROSPRISM").addClass('nodisplay');
2657 $("#Single").click(function(){
2658 $("#WNEARODAXIS").addClass('nodisplay');
2659 $("#WNEARODCYL").addClass('nodisplay');
2660 $("#WNEARODPRISM").addClass('nodisplay');
2661 $("#WODADD2").addClass('nodisplay');
2662 $("#WOSADD2").addClass('nodisplay');
2663 $("#WNEAROSAXIS").addClass('nodisplay');
2664 $("#WNEAROSCYL").addClass('nodisplay');
2665 $("#WNEAROSPRISM").addClass('nodisplay');
2666 $(".WSPACER").removeClass('nodisplay');
2668 $("#Bifocal").click(function(){
2669 $(".WSPACER").addClass('nodisplay');
2670 $(".WNEAR").removeClass('nodisplay');
2671 $(".WMid").addClass('nodisplay');
2672 $(".WHIDECYL").removeClass('nodisplay');
2673 $("[name=RX]").val(["1"]);
2674 $("#WNEARODAXIS").addClass('nodisplay');
2675 $("#WNEARODCYL").addClass('nodisplay');
2676 $("#WNEARODPRISM").addClass('nodisplay');
2677 $("#WNEAROSAXIS").addClass('nodisplay');
2678 $("#WNEAROSCYL").addClass('nodisplay');
2679 $("#WNEAROSPRISM").addClass('nodisplay');
2680 $("#WODADD2").removeClass('nodisplay');
2681 $("#WOSADD2").removeClass('nodisplay');
2683 $("#Trifocal").click(function(){
2684 $(".WSPACER").addClass('nodisplay');
2685 $(".WNEAR").removeClass('nodisplay');
2686 $(".WMid").removeClass('nodisplay');
2687 $(".WHIDECYL").addClass('nodisplay');
2688 $("[name=RX]").val(["2"]);
2689 $("#WNEARODAXIS").addClass('nodisplay');
2690 $("#WNEARODCYL").addClass('nodisplay');
2691 $("#WNEARODPRISM").addClass('nodisplay');
2692 $("#WNEAROSAXIS").addClass('nodisplay');
2693 $("#WNEAROSCYL").addClass('nodisplay');
2694 $("#WNEAROSPRISM").addClass('nodisplay');
2695 $("#WODADD2").removeClass('nodisplay');
2696 $("#WOSADD2").removeClass('nodisplay');
2698 $("#Progressive").click(function(){
2699 $(".WSPACER").addClass('nodisplay');
2700 $(".WNEAR").removeClass('nodisplay');
2701 $(".WMid").addClass('nodisplay');
2702 $(".WHIDECYL").removeClass('nodisplay');
2703 $("[name=RX]").val(["3"]);
2704 $("#WNEARODAXIS").addClass('nodisplay');
2705 $("#WNEARODCYL").addClass('nodisplay');
2706 $("#WNEARODPRISM").addClass('nodisplay');
2707 $("#WNEAROSAXIS").addClass('nodisplay');
2708 $("#WNEAROSCYL").addClass('nodisplay');
2709 $("#WNEAROSPRISM").addClass('nodisplay');
2710 $("#WODADD2").removeClass('nodisplay');
2711 $("#WOSADD2").removeClass('nodisplay');
2713 $("[name=W_width_display]").click(function() {
2714 if ($("#PREFS_W_width").val() !="1") {
2715 $("#PREFS_W_width").val('1');
2716 //make each display W wide
2717 $("[name=currentRX]").addClass('refraction_wide');
2718 $("[name=W_wide]").removeClass('nodisplay');
2719 $("[name=W_wide2]").removeClass('nodisplay');
2720 } else {
2721 $("#PREFS_W_width").val('0');
2722 //make each display W narrow
2723 $("[name=currentRX]").removeClass('refraction_wide');
2724 $("[name=W_wide]").addClass('nodisplay');
2725 $("[name=W_wide2]").addClass('nodisplay');
2727 update_PREFS();
2730 if ($("#PREFS_W_width").val() == '1') {
2731 $("[name=W_wide]").removeClass('nodisplay');
2732 $("[name=W_wide2]").removeClass('nodisplay')
2733 } else {
2734 $("[name=W_wide]").addClass('nodisplay');
2735 $("[name=W_wide2]").addClass('nodisplay');
2737 $("#Amsler-Normal").change(function() {
2738 if ($(this).is(':checked')) {
2739 var number1 = document.getElementById("AmslerOD").src.match(/(Amsler_\d)/)[1];
2740 document.getElementById("AmslerOD").src = document.getElementById("AmslerOD").src.replace(number1,"Amsler_0");
2741 var number2 = document.getElementById("AmslerOS").src.match(/(Amsler_\d)/)[1];
2742 document.getElementById("AmslerOS").src = document.getElementById("AmslerOS").src.replace(number2,"Amsler_0");
2743 $("#AMSLEROD").val("0");
2744 $("#AMSLEROS").val("0");
2745 $("#AmslerODvalue").text("0");
2746 $("#AmslerOSvalue").text("0");
2747 submit_form("eye_mag");
2748 return;
2751 $("#PUPIL_NORMAL").change(function() {
2752 if ($(this).is(':checked')) {
2753 $("#ODPUPILSIZE1").val('3.0');
2754 $("#OSPUPILSIZE1").val('3.0');
2755 $("#ODPUPILSIZE2").val('2.0');
2756 $("#OSPUPILSIZE2").val('2.0');
2757 $("#ODPUPILREACTIVITY").val('+2');
2758 $("#OSPUPILREACTIVITY").val('+2');
2759 $("#ODAPD").val('0');
2760 $("#OSAPD").val('0');
2761 submit_form("eye_mag");
2762 return;
2765 $("[name$='PUPILREACTIVITY']").change(function() {
2766 var react = $(this).val();
2767 if (react.match(/^\d{1}$/)) {
2768 react = "+"+react;
2770 $(this).val(react);
2773 $("[name^='EXAM']").mouseover(function(){
2774 $(this).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
2776 $("[name^='EXAM']").mouseout(function(){
2777 $(this).toggleClass("borderShadow2");
2779 $("#AmslerOD, #AmslerOS").click(function() {
2780 if ($('#chart_status').val() !="on") return;
2781 var number1 = this.src.match(/Amsler_(\d)/)[1];
2782 var number2 = +number1 +1;
2783 this.src = this.src.replace('Amsler_'+number1,'Amsler_'+number2);
2784 this.src = this.src.replace('Amsler_6','Amsler_0');
2785 $("#Amsler-Normal").removeAttr('checked');
2786 var number3 = this.src.match(/Amsler_(\d)/)[1];
2787 this.html = number3;
2788 if (number3 =="6") {
2789 number3 = "0";
2791 if ($(this).attr("id")=="AmslerOD") {
2792 $("#AmslerODvalue").text(number3);
2793 $('#AMSLEROD').val(number3);
2794 } else {
2795 $('#AMSLEROS').val(number3);
2796 $("#AmslerOSvalue").text(number3);
2798 var title = "#"+$(this).attr("id")+"_tag";
2801 $("#AmslerOD, #AmslerOS").mouseout(function() {
2802 submit_form("eye_mag");
2804 $("[name^='ODVF'],[name^='OSVF']").click(function() {
2805 if ($(this).is(':checked') == true) {
2806 $("#FieldsNormal").prop('checked', false);
2807 $(this).val('1');
2808 }else{
2809 $(this).val('0');
2810 $(this).prop('checked', false);
2812 submit_form("eye_mag");
2814 $("#FieldsNormal").click(function() {
2815 if ($(this).is(':checked')) {
2816 $("#ODVF1").removeAttr('checked');
2817 $("#ODVF2").removeAttr('checked');
2818 $("#ODVF3").removeAttr('checked');
2819 $("#ODVF4").removeAttr('checked');
2820 $("#OSVF1").removeAttr('checked');
2821 $("#OSVF2").removeAttr('checked');
2822 $("#OSVF3").removeAttr('checked');
2823 $("#OSVF4").removeAttr('checked');
2826 $("[id^='EXT_prefix']").change(function() {
2827 var newValue =$('#EXT_prefix').val();
2828 newValue = newValue.replace('+', '');
2829 if (newValue =="off") {$(this).val('');}
2830 if (newValue =="clear") {
2831 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
2832 $(this).val('');
2833 $(".EXT").val('');
2835 } else {
2836 $("[name^='EXT_prefix_']").removeClass('eye_button_selected');
2837 $("#EXT_prefix_"+ newValue).addClass("eye_button_selected");
2840 $("#ANTSEG_prefix").change(function() {
2841 var newValue = $(this).val().replace('+', '');
2842 if ($(this).value =="off") {$(this).val('');}
2843 if (newValue =="clear") {
2844 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
2845 $(this).val('');
2846 $(".ANTSEG").val('');
2848 } else {
2849 $("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
2850 $("#ANTSEG_prefix_"+ newValue).addClass("eye_button_selected");
2853 $("#RETINA_prefix").change(function() {
2854 var newValue = $("#RETINA_prefix").val().replace('+', '');
2855 if ($(this).value =="off") {$(this).val('');}
2856 if (newValue =="clear") {
2857 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
2858 $(this).val('');
2859 $(".RETINA").val('');
2861 } else {
2862 $("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
2863 $("#RETINA_prefix_"+ newValue).addClass("eye_button_selected");
2866 $("#NEURO_ACT_zone").change(function() {
2867 var newValue = $(this).val();
2868 $("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
2869 $("#NEURO_ACT_zone_"+ newValue).addClass("eye_button_selected");
2870 $("#PREFS_ACT_SHOW").val(newValue);
2871 update_PREFS;
2872 $("#ACT_tab_"+newValue).trigger('click');
2874 $("#NEURO_side").change(function() {
2875 var newValue = $(this).val();
2876 $("[name^='NEURO_side']").removeClass('eye_button_selected');
2877 $("#NEURO_side_"+ newValue).addClass("eye_button_selected");
2879 $('.ACT').focus(function() {
2880 var id = this.id.match(/ACT(\d*)/);
2881 $('#NEURO_field').val(''+id[1]).trigger('change');
2883 $("#NEURO_field").change(function() {
2884 var newValue = $(this).val();
2885 $("[name^='NEURO_field']").removeClass('eye_button_selected');
2886 $("#NEURO_field_"+ newValue).addClass("eye_button_selected");
2887 $('.ACT').each(function(i){
2888 var color = $(this).css('background-color');
2889 if ((color == 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
2890 $(this).css("background-color","red");
2893 //change to highlight field in zone entry is for
2894 var zone = $("#NEURO_ACT_zone").val();
2895 $("#ACT"+newValue+zone).css("background-color","yellow");
2897 $("[name^='NEURO_ACT_strab']").click(function() {
2898 var newValue = $(this).val();
2899 $("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2900 $(this).addClass("eye_button_selected");
2902 $("#NEURO_value").change(function() {
2903 var newValue = $(this).val();
2904 $("[name^='NEURO_value']").removeClass('eye_button_selected');
2905 $("#NEURO_value_"+ newValue).addClass("eye_button_selected");
2906 if (newValue == "ortho") {
2907 $("#NEURO_ACT_strab").val('');
2908 $("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2909 $("#NEURO_side").val('');
2910 $("[name^='NEURO_side']").removeClass('eye_button_selected');
2913 $("#NEURO_RECORD").mouseover(function() {
2914 $("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
2916 $("#NEURO_RECORD").mouseout(function() {
2917 $("#NEURO_RECORD").removeClass('borderShadow2');
2919 $("#NEURO_RECORD").mousedown(function() {
2920 $("#NEURO_RECORD").removeClass('borderShadow2');
2921 $(this).toggleClass('button_over');
2923 $("#NEURO_RECORD").mouseup(function() {
2924 $("#NEURO_RECORD").removeClass('borderShadow2');
2925 $(this).toggleClass('button_over');
2927 $("#NEURO_RECORD").click(function() {
2928 //find out the field we are updating
2929 var number = $("#NEURO_field").val();
2930 var zone = $("#NEURO_ACT_zone").val();
2931 var strab = $("#NEURO_value").val() + ' '+ $("#NEURO_side").val() + $("#NEURO_ACT_strab").val();
2933 $("#ACT"+number+zone).val(strab).css("background-color","#F0F8FF");
2938 $("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseover(function(){
2939 $(this).addClass("borderShadow2");
2941 $("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseout(function(){
2942 $(this).removeClass("borderShadow2");
2944 $("[id$='_lightswitch']").click(function() {
2945 var section = "#"+this.id.match(/(.*)_lightswitch$/)[1];
2946 var section2 = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2947 var elem = document.getElementById("PREFS_"+section2);
2948 $("#PREFS_VA").val('0');
2949 if (section2 != "IOP")$("#REFRACTION_sections").removeClass('nodisplay');
2950 if (elem.value == "0" || elem.value =='') {
2951 elem.value='1';
2952 if (section2 =="ADDITIONAL") {
2953 $("#LayerVision_ADDITIONAL").removeClass('nodisplay');
2955 if (section2 =="IOP") {
2956 $("#LayerVision_IOP").removeClass('nodisplay');
2957 //plot_IOPs();
2959 $(section).removeClass('nodisplay');
2960 $(this).addClass("buttonRefraction_selected");
2961 } else {
2962 elem.value='0';
2963 $(section).addClass('nodisplay');
2964 if (section2 =="VAX") {
2965 $("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
2967 if (section2 =="IOP") {
2968 $("#LayerVision_IOP").addClass('nodisplay');
2970 $(this).removeClass("buttonRefraction_selected");
2972 $(this).css( 'cursor', 'pointer' );
2973 update_PREFS();
2976 $('[id$=_lightswitch]').mouseover(function() {
2977 $(this).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
2979 var section = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2980 if (section == 'IOP') {
2981 $("#LayerTension").addClass("borderShadow2");
2982 } else {
2983 $("#LayerVision").addClass("borderShadow2");
2986 $('[id$=_lightswitch]').mouseout(function() {
2987 var section2 = this.id.match(/(.*)_(.*)_lightswitch$/)[2];
2988 var elem = document.getElementById("PREFS_"+section2);
2990 if (elem.value != "1") {
2991 $(this).removeClass('buttonRefraction_selected');
2992 } else {
2993 $(this).addClass('buttonRefraction_selected');
2994 } });
2996 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
2997 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
2998 // "-" is still == "-"
2999 $("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) {
3000 if (e.keyCode=='61' || e.keyCode=='74') {
3001 now = $(this).val();
3002 now = now.replace(/=/g,"+").replace(/^j/g,"J");
3003 $(this).val(now);
3006 //useful to make all VA fields stay in sync
3007 $("input[name$='VA']").on('change',function() {
3008 var hereValue = $(this).val();
3009 var newValue = $(this).attr('name').replace('VA', 'VA_copy');
3010 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
3011 $("#" + newValue + "_brd").val(hereValue).css("background-color","#F0F8FF");;
3013 $("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
3014 var hereValue = $(this).val();
3015 hereValue = hereValue.replace(/=$/g,"+").replace(/^j/g,"J");
3016 $(this).val(hereValue);
3017 if (this.name.match(/_1$/)) {
3018 var newValue = $(this).attr('name').replace('VA_1', 'VA_1_copy');
3019 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
3020 $("#" + newValue + "_brd").val(hereValue).css("background-color","#F0F8FF");
3024 $("input[name$='_copy']").blur(function() {
3025 var hereValue = $(this).val();
3026 var newValue = $(this).attr('name').replace('_copy', '');
3027 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
3028 $("#" + newValue + "_copy_brd").val(hereValue).css("background-color","#F0F8FF");;
3030 $("input[name$='_copy_brd']").change(function() {
3031 var hereValue = $(this).val();
3032 var newValue = $(this).attr('name').replace('_copy_brd', '');
3033 $("#" + newValue).val(hereValue).css("background-color","#F0F8FF");;
3034 $("#" + newValue + "_copy").val(hereValue).css("background-color","#F0F8FF");;
3036 $("[name^='more_']").mouseout(function() {
3037 $(this).toggleClass('buttonRefraction_selected').toggleClass('underline');
3039 $("[name^='more_']").click(function() {
3040 $("#Visions_A").toggleClass('nodisplay');
3041 $("#Visions_B").toggleClass('nodisplay');
3043 $("#EXAM_defaults").click(function() {
3044 <?php
3045 // This query is specific to the provider.
3046 $query = "select seq from list_options where option_id=?";
3047 $result = sqlStatement($query,array("Eye_defaults_$providerID"));
3049 $list = sqlFetchArray($result);
3050 $SEQ = $list['seq'];
3051 if (!$SEQ) {
3052 // If there is no list for this provider, we create it here.
3053 // Instead of the below code, we should be copying the Eye_Defaults_for_GENERAL
3054 // to Eye_defaults_$providerID
3055 // This list is part of the idea to create a way to add Eye_defaults_$providerID specific to the
3056 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3057 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3058 // Also, each field should be "display:none" if desired, via another user specific list.
3059 // This would be another list. Let's see if the public likes the form itself before
3060 // developing these features...
3061 $query = "SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'";
3062 $pres = sqlStatement($query);
3063 $maxseq = sqlFetchArray($pres);
3065 $seq=$maxseq['maxseq'];
3066 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`) VALUES
3067 ('lists', ?, ?, ?, '1', '0', '', '', '')";
3068 sqlStatement($query,array("Eye_defaults_$providerID","Eye Exam Defaults $providerNAME ",$seq));
3069 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`,`notes`,`seq`) VALUES
3070 ('Eye_defaults_".$providerID."','RUL','normal lids and lashes','EXT','10'),
3071 ('Eye_defaults_".$providerID."','LUL','normal lids and lashes','EXT','20'),
3072 ('Eye_defaults_".$providerID."','RLL','good tone','EXT','30'),
3073 ('Eye_defaults_".$providerID."','LLL','good tone','EXT','40'),
3074 ('Eye_defaults_".$providerID."','RBROW','no brow ptosis','EXT','50'),
3075 ('Eye_defaults_".$providerID."','LBROW','no brow ptosis','EXT','60'),
3076 ('Eye_defaults_".$providerID."','RMCT','no masses','EXT','70'),
3077 ('Eye_defaults_".$providerID."','LMCT','no masses','EXT','80'),
3078 ('Eye_defaults_".$providerID."','RADNEXA','normal lacrimal gland and orbit','EXT','90'),
3079 ('Eye_defaults_".$providerID."','LADNEXA','normal lacrimal gland and orbit','EXT','100'),
3080 ('Eye_defaults_".$providerID."','RMRD','+3','EXT','110'),
3081 ('Eye_defaults_".$providerID."','LMRD','+3','EXT','120'),
3082 ('Eye_defaults_".$providerID."','RLF','17','EXT','130'),
3083 ('Eye_defaults_".$providerID."','LLF','17','EXT','140'),
3084 ('Eye_defaults_".$providerID."','OSCONJ','quiet','ANTSEG','150'),
3085 ('Eye_defaults_".$providerID."','ODCONJ','quiet','ANTSEG','160'),
3086 ('Eye_defaults_".$providerID."','ODCORNEA','clear','ANTSEG','170'),
3087 ('Eye_defaults_".$providerID."','OSCORNEA','clear','ANTSEG','180'),
3088 ('Eye_defaults_".$providerID."','ODAC','deep and quiet','ANTSEG','190'),
3089 ('Eye_defaults_".$providerID."','OSAC','deep and quiet','ANTSEG','200'),
3090 ('Eye_defaults_".$providerID."','ODLENS','clear','ANTSEG','210'),
3091 ('Eye_defaults_".$providerID."','OSLENS','clear','ANTSEG','220'),
3092 ('Eye_defaults_".$providerID."','ODIRIS','round','ANTSEG','230'),
3093 ('Eye_defaults_".$providerID."','OSIRIS','round','ANTSEG','240'),
3094 ('Eye_defaults_".$providerID."','ODPUPILSIZE1','3','NEURO','250'),
3095 ('Eye_defaults_".$providerID."','ODPUPILSIZE2','2','NEURO','260'),
3096 ('Eye_defaults_".$providerID."','ODPUPILREACTIVITY','+2','NEURO','270'),
3097 ('Eye_defaults_".$providerID."','ODAPD','0','NEURO','280'),
3098 ('Eye_defaults_".$providerID."','OSPUPILSIZE1','3','NEURO','290'),
3099 ('Eye_defaults_".$providerID."','OSPUPILSIZE2','2','NEURO','300'),
3100 ('Eye_defaults_".$providerID."','OSPUPILREACTIVITY','+2','NEURO','310'),
3101 ('Eye_defaults_".$providerID."','OSAPD','0','NEURO','320'),
3102 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION1','0','NEURO','330'),
3103 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION2','0','NEURO','340'),
3104 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION3','0','NEURO','350'),
3105 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION4','0','NEURO','360'),
3106 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION5','0','NEURO','370'),
3107 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION1','0','NEURO','380'),
3108 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION2','0','NEURO','390'),
3109 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION3','0','NEURO','400'),
3110 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION4','0','NEURO','410'),
3111 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION5','0','NEURO','420'),
3112 ('Eye_defaults_".$providerID."','ODDISC','pink','RETINA','430'),
3113 ('Eye_defaults_".$providerID."','OSDISC','pink','RETINA','440'),
3114 ('Eye_defaults_".$providerID."','ODCUP','0.3','RETINA','450'),
3115 ('Eye_defaults_".$providerID."','OSCUP','0.3','RETINA','460'),
3116 ('Eye_defaults_".$providerID."','ODMACULA','flat','RETINA','470'),
3117 ('Eye_defaults_".$providerID."','OSMACULA','flat','RETINA','480'),
3118 ('Eye_defaults_".$providerID."','ODVESSELS','2:3','RETINA','490'),
3119 ('Eye_defaults_".$providerID."','OSVESSELS','2:3','RETINA','500'),
3120 ('Eye_defaults_".$providerID."','ODPERIPH','flat','RETINA','510'),
3121 ('Eye_defaults_".$providerID."','OSPERIPH','flat','RETINA','520')";
3122 sqlStatement($query);
3124 $query = "select * from list_options where list_id =? and activity='1' order by seq";
3126 $DEFAULT_data =sqlStatement($query,array("Eye_defaults_$providerID"));
3127 while ($row = sqlFetchArray($DEFAULT_data)) {
3128 //$row['notes'] is the clinical zone (EXT,ANTSEG,RETINA,NEURO)
3129 //$row['option_id'] is the field name
3130 //$row['title'] is the default value to use for this provider
3131 ${$row[notes]}[$row[option_id]] = $row[title]; //This builds each clinical section into its own array (used below)
3132 echo '$("#'.$row['option_id'].'").val("'.$row['title'].'").css("background-color","beige");
3136 submit_form("eye_mag");
3139 $("#EXT_defaults").click(function() {
3140 <?php
3141 foreach ($EXT as $item => $value) {
3142 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3146 submit_form("eye_mag");
3149 $("#ANTSEG_defaults").click(function() {
3150 <?php
3151 foreach ($ANTSEG as $item => $value) {
3152 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3156 submit_form("eye_mag");
3158 $("#RETINA_defaults").click(function() {
3159 <?php
3160 foreach ($RETINA as $item => $value) {
3161 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3165 submit_form("eye_mag");
3167 $("#NEURO_defaults").click(function() {
3168 <?php
3169 foreach ($NEURO as $item => $value) {
3170 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3174 submit_form("eye_mag");
3178 $("#MOTILITYNORMAL").click(function() {
3179 $("#MOTILITY_RS").val('0');
3180 $("#MOTILITY_RI").val('0');
3181 $("#MOTILITY_RR").val('0');
3182 $("#MOTILITY_RL").val('0');
3183 $("#MOTILITY_LS").val('0');
3184 $("#MOTILITY_LI").val('0');
3185 $("#MOTILITY_LR").val('0');
3186 $("#MOTILITY_LL").val('0');
3188 $("#MOTILITY_RRSO").val('0');
3189 $("#MOTILITY_RRIO").val('0');
3190 $("#MOTILITY_RLSO").val('0');
3191 $("#MOTILITY_RLIO").val('0');
3192 $("#MOTILITY_LRSO").val('0');
3193 $("#MOTILITY_LRIO").val('0');
3194 $("#MOTILITY_LLSO").val('0');
3195 $("#MOTILITY_LLIO").val('0');
3197 for (index = '0'; index < 5; ++index) {
3198 $("#MOTILITY_RS_"+index).html('');
3199 $("#MOTILITY_RI_"+index).html('');
3200 $("#MOTILITY_RR_"+index).html('');
3201 $("#MOTILITY_RL_"+index).html('');
3202 $("#MOTILITY_LS_"+index).html('');
3203 $("#MOTILITY_LI_"+index).html('');
3204 $("#MOTILITY_LR_"+index).html('');
3205 $("#MOTILITY_LL_"+index).html('');
3207 $("#MOTILITY_RRSO_"+index).html('');
3208 $("#MOTILITY_RRIO_"+index).html('');
3209 $("#MOTILITY_RLSO_"+index).html('');
3210 $("#MOTILITY_RLIO_"+index).html('');
3211 $("#MOTILITY_LRSO_"+index).html('');
3212 $("#MOTILITY_LRIO_"+index).html('');
3213 $("#MOTILITY_LLSO_"+index).html('');
3214 $("#MOTILITY_LLIO_"+index).html('');
3216 submit_form('eye_mag');
3219 $("[name^='MOTILITY_']").click(function() {
3220 $("#MOTILITYNORMAL").removeAttr('checked');
3222 if (this.id.match(/(MOTILITY_([A-Z]{4}))_(.)/)) {
3223 var zone = this.id.match(/(MOTILITY_([A-Z]{4}))_(.)/);
3224 var index = '0';
3225 var valued = isNaN($("#"+zone[1]).val());
3226 if ((zone[2] =='RLSO')||(zone[2] =='LLSO')||(zone[2] =='RRIO')||(zone[2] =='LRIO')) {
3227 //find or make a hash tage for "\"
3228 var hash_tag = '<i class="fa fa-minus"></i>';
3229 } else {
3230 //find or make a hash tage for "/"
3231 var hash_tag = '<i class="fa fa-minus"></i>';
3233 } else {
3234 var zone = this.id.match(/(MOTILITY_..)_(.)/);
3235 var section = this.id.match(/MOTILITY_(.)(.)_/);
3236 var section2 = section[2];
3237 var Eye = section[1];
3238 var SupInf = section2.search(/S|I/);
3239 var RorLside = section2.search(/R|L/);
3242 if (RorLside =='0') {
3243 var hash_tag = '<i class="fa fa-minus rotate-left"></i>';
3244 } else {
3245 var hash_tag = '<i class="fa fa-minus"></i>';
3248 if (valued != true && $("#"+zone[1]).val() <'4') {
3249 valued=$("#"+zone[1]).val();
3250 valued++;
3251 } else {
3252 valued = '0';
3253 $("#"+zone[1]).val('0');
3256 $("#"+zone[1]).val(valued);
3258 for (index = '0'; index < 5; ++index) {
3259 $("#"+zone[1]+"_"+index).html('');
3261 if (valued > '0') {
3262 for (index =1; index < (valued+1); ++index) {
3263 $("#"+zone[1]+"_"+index).html(hash_tag);
3267 submit_form('3');
3270 $("[name^='Close_']").click(function() {
3271 var section = this.id.match(/Close_(.*)$/)[1];
3272 if (this.id.match(/Close_W_(.*)$/) != null) {
3273 var W_section = this.id.match(/Close_W_(.*)$/)[1];
3274 if (W_section > '1') {
3275 $('#LayerVision_W_'+W_section).addClass('nodisplay');
3276 $('[name$=SPH_'+W_section+']').val('');
3277 $('[name$=CYL_'+W_section+']').val('');
3278 $('[name$=AXIS_'+W_section+']').val('');
3279 $('[name$=ADD_'+W_section+']').val('');
3280 $('[name$=PRISM_'+W_section+']').val('');
3281 $('[name$=VA_'+W_section+']').val('');
3282 $('#RX_TYPE_'+W_section).val('');
3283 $('#Add_Glasses').removeClass('nodisplay');
3284 $('#W_'+W_section).val('');
3285 submit_form('4');
3286 } else {
3287 $("#LayerVision_W_lightswitch").click();
3289 } else if (section =="ACTMAIN") {
3290 $("#ACTTRIGGER").trigger( "click" );
3291 } else {
3292 $("#LayerVision_"+section+"_lightswitch").click();
3297 $("#EXAM_DRAW, #BUTTON_DRAW_menu, #PANEL_DRAW").click(function() {
3298 if ($("#PREFS_CLINICAL").value !='0') {
3299 show_right();
3300 $("#PREFS_CLINICAL").val('0');
3301 update_PREFS();
3303 if ($("#PREFS_EXAM").val() != 'DRAW') {
3304 $("#PREFS_EXAM").val('DRAW');
3305 $("#EXAM_QP").removeClass('button_selected');
3306 $("#EXAM_DRAW").addClass('button_selected');
3307 $("#EXAM_TEXT").removeClass('button_selected');
3308 update_PREFS();
3310 show_DRAW();
3312 $("#EXAM_QP,#PANEL_QP").click(function() {
3313 if ($("#PREFS_CLINICAL").value !='0') {
3314 $("#PREFS_CLINICAL").val('0');
3315 update_PREFS();
3317 if ($("#PREFS_EXAM").value != 'QP') {
3318 $("#PREFS_EXAM").val('QP');
3319 $("#EXAM_QP").addClass('button_selected');
3320 $("#EXAM_DRAW").removeClass('button_selected');
3321 $("#EXAM_TEXT").removeClass('button_selected');
3322 update_PREFS();
3324 show_QP();
3327 $("#EXAM_TEXT,#PANEL_TEXT").click(function() {
3329 // also hide QP, DRAWs, and PRIORS
3330 hide_DRAW();
3331 hide_QP();
3332 hide_PRIORS();
3333 hide_right();
3334 show_TEXT();
3335 for (index = '0'; index < zones.length; ++index) {
3336 $("#PREFS_"+zones[index]+"_RIGHT").val(0);
3338 update_PREFS();
3340 $("#EXAM_DRAW").removeClass('button_selected');
3341 $("#EXAM_QP").removeClass('button_selected');
3342 $("#EXAM_TEXT").addClass('button_selected');
3344 $("[id^='BUTTON_TEXT_']").click(function() {
3345 var zone = this.id.match(/BUTTON_TEXT_(.*)/)[1];
3346 if (zone != "menu") {
3347 $("#"+zone+"_right").addClass('nodisplay');
3348 $("#"+zone+"_left").removeClass('display');
3349 $("#"+zone+"_left_text").removeClass('display');
3350 $("#PREFS_"+zone+"_RIGHT").val(0);
3351 update_PREFS();
3353 show_TEXT();
3355 $("[id^='BUTTON_TEXTD_']").click(function() {
3356 var zone = this.id.match(/BUTTON_TEXTD_(.*)/)[1];
3357 if (zone != "menu") {
3358 if ((zone =="PMH") || (zone == "HPI")) {
3359 $("#PMH_right").addClass('nodisplay');
3360 $("#PREFS_PMH_RIGHT").val(1);
3361 $("#HPI_right").addClass('nodisplay');
3362 $("#PREFS_HPI_RIGHT").val(1);
3363 var reset = $("#HPI_1").height();
3364 $("#PMH_1").height(reset);
3365 $("#PMH_left").height(reset-40);
3366 $("#LayerTechnical_sections_1").css("clear","both");
3367 } else {
3368 $("#"+zone+"_right").addClass('nodisplay');
3369 $("#PREFS_"+zone+"_RIGHT").val(1);
3371 scrollTo(zone+"_left");
3372 update_PREFS();
3377 $("#EXAM_TEXT").addClass('button_selected');
3378 if (($("#PREFS_CLINICAL").val() !='1')) {
3379 var actionQ = "#EXAM_"+$("#PREFS_EXAM").val();
3380 $(actionQ).trigger('click');
3381 } else {
3382 $("#EXAM_TEXT").addClass('button_selected');
3384 if ($("#ANTSEG_prefix").val() > '') {
3385 $("#ANTSEG_prefix_"+$("#ANTSEG_prefix").val()).addClass('button_selected');
3386 } else {
3387 $("#ANTSEG_prefix").val('off').trigger('change');
3389 $("[name^='ACT_tab_']").mouseover(function() {
3390 $(this).toggleClass('underline').css( 'cursor', 'pointer' );
3392 $("[name^='ACT_tab_']").mouseout(function() {
3393 $(this).toggleClass('underline');
3396 $("[name^='ACT_tab_']").click(function() {
3397 var section = this.id.match(/ACT_tab_(.*)/)[1];
3398 $("[name^='ACT_']").addClass('nodisplay');
3399 $("[name^='ACT_tab_']").removeClass('nodisplay').removeClass('ACT_selected').addClass('ACT_deselected');
3400 $("#ACT_tab_" + section).addClass('ACT_selected').removeClass('ACT_deselected');
3401 $("#ACT_" + section).removeClass('nodisplay');
3402 $("#PREFS_ACT_SHOW").val(section);
3403 //selection correct QP zone
3404 $("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3405 $("#NEURO_ACT_zone_"+ section).addClass("eye_button_selected");
3406 $("#NEURO_ACT_zone").val(section);
3407 update_PREFS();
3409 $("#ACTTRIGGER").mouseout(function() {
3410 $("#ACTTRIGGER").toggleClass('buttonRefraction_selected').toggleClass('underline');
3412 if ($("#PREFS_ACT_VIEW").val() == '1') {
3413 $("#ACTMAIN").toggleClass('nodisplay');
3414 $("#NPCNPA").toggleClass('nodisplay');
3415 $("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3416 $("#ACTTRIGGER").toggleClass('underline');
3417 var show = $("#PREFS_ACT_SHOW").val();
3418 $("#ACT_tab_"+show).trigger('click');
3420 $("#ACTTRIGGER").click(function() {
3421 $("#ACTMAIN").toggleClass('nodisplay').toggleClass('ACT_TEXT');
3422 $("#NPCNPA").toggleClass('nodisplay');
3423 $("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3424 $("#ACTTRIGGER").toggleClass('underline');
3425 if ($("#PREFS_ACT_VIEW").val()=='1') {
3426 $("#PREFS_ACT_VIEW").val('0');
3427 } else {
3428 $("#PREFS_ACT_VIEW").val('1');
3430 var show = $("#PREFS_ACT_SHOW").val();
3431 $("#ACT_tab_"+show).trigger('click');
3432 update_PREFS();
3434 $("#NEURO_COLOR").click(function() {
3435 $("#ODCOLOR").val("11/11");
3436 $("#OSCOLOR").val("11/11");
3437 submit_form("eye_mag");
3440 $("#NEURO_COINS").click(function() {
3441 $("#ODCOINS").val("1.00");
3442 //leave currency symbol out unless it is an openEMR defined option
3443 $("#OSCOINS").val("1.00");
3444 submit_form("eye_mag");
3447 $("#NEURO_REDDESAT").click(function() {
3448 $("#ODREDDESAT").val("100");
3449 $("#OSREDDESAT").val("100");
3450 submit_form("eye_mag");
3453 $("[id^='myCanvas_']").mouseout(function() {
3454 var zone = this.id.match(/myCanvas_(.*)/)[1];
3455 submit_canvas(zone);
3457 $("[id^='Undo_']").click(function() {
3458 var zone = this.id.match(/Undo_Canvas_(.*)/)[1];
3459 submit_canvas(zone);
3461 $("[id^='Redo_']").click(function() {
3462 var zone = this.id.match(/Redo_Canvas_(.*)/)[1];
3463 submit_canvas(zone);
3465 $("[id^='Clear_']").click(function() {
3466 var zone = this.id.match(/Clear_Canvas_(.*)/)[1];
3467 submit_canvas(zone);
3469 $("[id^='Base_']").click(function() { //not implemented yet
3470 var zone = this.id.match(/Base_Canvas_(.*)/)[1];
3471 //To change the base img
3472 //delete current image from server
3473 //re-ajax the canvas div
3474 var id_here = document.getElementById('myCanvas_'+zone);
3475 var dataURL = id_here.toDataURL();
3476 top.restoreSession();
3477 $.ajax({
3478 type: "POST",
3479 url: "../../forms/eye_mag/save.php?canvas="+zone+"&id="+$("#form_id").val(),
3480 data: {
3481 imgBase64 : dataURL, //this contains the new strokes, the sketch.js foreground
3482 'zone' : zone,
3483 'visit_date' : $("#visit_date").val(),
3484 'encounter' : $("#encounter").val(),
3485 'pid' : $("#pid").val()
3490 $("#url_"+zone).val("/interface/forms/eye_mag/images/OU_"+zone+"_BASE.png");
3491 canvas.renderAll();
3494 $("#COPY_SECTION").change(function() {
3495 var start = $("#COPY_SECTION").val();
3496 if (start =='') return;
3497 var value = start.match(/(\w*)-(\w*)/);
3498 var zone = value[1];
3499 var copy_from = value[2];
3500 if (zone =="READONLY") copy_from = $("#form_id").val();
3501 var count_changes='0';
3503 var data = {
3504 action : 'copy',
3505 copy : zone,
3506 zone : zone,
3507 copy_to : $("#form_id").val(),
3508 copy_from : copy_from,
3509 pid : $("#pid").val()
3511 if (zone =="READONLY") {
3512 //we are going to update the whole form
3513 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
3514 //We are not ready to actively chart, just looking to see how far along our staff is...
3515 //or maybe just looking ahead to see who's next in the next room?
3516 //Either way, we are looking at a record that at present will be disabled/we cannot change...
3517 // yet it is updating every 10 seconds if another user is making changes.
3519 // READONLY does not show IMPPLAN changes!!!!
3520 } else {
3521 //here we are retrieving an old record to copy forward to today's active chart.
3522 data = $("#"+zone+"_left_text").serialize() + "&" + $.param(data);
3524 top.restoreSession();
3525 $.ajax({
3526 type : 'POST',
3527 dataType : 'json',
3528 url : "../../forms/eye_mag/save.php",
3529 data : data,
3530 success : function(result) {
3531 //we have to process impplan differently
3532 if (zone =='IMPPLAN') {
3533 //we get a json result.IMPPLAN back from the prior visit
3534 //we need to add that to the current list? Replace for now.
3535 build_IMPPLAN(result.IMPPLAN);
3536 store_IMPPLAN(result.IMPPLAN);
3537 // need to make the Plan areas purple?
3538 } else {
3539 $.map(result, function(valhere, keyhere) {
3540 if ($("#"+keyhere).val() != valhere) {
3541 $("#"+keyhere).val(valhere).css("background-color","#CCF");
3542 } else if (keyhere.match(/MOTILITY_/)) {
3543 // Copy forward ductions and versions visually
3544 // Make each blank, and rebuild them
3545 $("[name='"+keyhere+"_1']").html('');
3546 $("[name='"+keyhere+"_2']").html('');
3547 $("[name='"+keyhere+"_3']").html('');
3548 $("[name='"+keyhere+"_4']").html('');
3549 if (keyhere.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO)/)) {
3550 // Show a horizontal (minus) tag. When "/" and "\" fa-icons are available will need to change.
3551 // Maybe just use small font "/" and "\" directly.
3552 hash_tag = '<i class="fa fa-minus"></i>';
3553 } else { //show vertical tag
3554 hash_tag = '<i class="fa fa-minus rotate-left"></i>';
3556 for (index =1; index <= valhere; ++index) {
3557 $("#"+keyhere+"_"+index).html(hash_tag);
3559 } else if (keyhere.match(/^(ODVF|OSVF)\d$/)) {
3560 if (valhere =='1') {
3561 $("#FieldsNormal").prop('checked', false);
3562 $("#"+keyhere).prop('checked', true);
3563 $("#"+keyhere).val('1');
3564 } else {
3565 $("#"+keyhere).val('0');
3566 $("#"+keyhere).prop('checked', false);
3568 } else if (keyhere.match(/AMSLERO(.)/)) {
3569 var sidehere = keyhere.match(/AMSLERO(.)/);
3570 if (valhere < '1') valhere ='0';
3571 $("#"+keyhere).val(valhere);
3572 var srcvalue="AmslerO"+sidehere[1];
3573 document.getElementById(srcvalue).src = document.getElementById(srcvalue).src.replace(/\_\d/g,"_"+valhere);
3574 $("#AmslerO"+sidehere[1]+"value").text(valhere);
3575 } else if (keyhere.match(/VA$/)) {
3576 $("#"+keyhere+"_copy").val(valhere).css("background-color","#F0F8FF");;
3577 $("#"+keyhere+"_copy_brd").val(valhere).css("background-color","#F0F8FF");;
3580 if (zone != "READONLY") { submit_form("eye_mag"); }
3582 }});
3584 $("[id^='BUTTON_DRAW_']").click(function() {
3585 var zone =this.id.match(/BUTTON_DRAW_(.*)$/)[1];
3586 if (zone =="ALL") {
3587 } else {
3588 if ($('#PREFS_'+zone+'_RIGHT').val() =="DRAW") {
3589 $('#BUTTON_TEXTD_'+zone).trigger("click");//closes draw
3590 //maybe this should revert to last right panel state (qp,text)
3591 return;
3593 $("#"+zone+"_1").removeClass('nodisplay');
3594 $("#"+zone+"_right").addClass('canvas').removeClass('nodisplay');
3595 $("#QP_"+zone).addClass('nodisplay');
3596 $("#PRIORS_"+zone+"_left_text").addClass('nodisplay');
3597 $("#Draw_"+zone).removeClass('nodisplay');
3598 $("#PREFS_"+zone+"_RIGHT").val('DRAW');
3599 scrollTo(zone+"_left");
3600 //alert("ok?");
3601 update_PREFS();
3604 $("[id^='BUTTON_QP_']").click(function() {
3605 var zone = this.id.match(/BUTTON_QP_(.*)$/)[1].replace(/_\d*/,'');
3606 if (zone =='IMPPLAN2') {
3607 $('#IMP_start_acc').slideDown();
3608 zone='IMPPLAN';
3610 if ($("#PREFS_"+zone+"_RIGHT").val() =='QP') {
3611 $('#BUTTON_TEXTD_'+zone).trigger("click");
3612 return;
3614 $("#PRIORS_"+zone+"_left_text").addClass('nodisplay');
3615 $("#Draw_"+zone).addClass('nodisplay');
3616 show_QP_section(zone);
3617 $("#PREFS_"+zone+"_RIGHT").val('QP');
3618 if ((zone != 'PMH')&&(zone != 'HPI')) {
3620 if (zone == 'PMH') {
3621 if($('#HPI_right').css('display') == 'none') {
3622 $("#PRIORS_HPI_left_text").addClass('nodisplay');
3623 $("#Draw_HPI").addClass('nodisplay');
3624 show_QP_section('HPI');
3625 $("#PREFS_HPI_RIGHT").val('QP');
3626 //$("html,body").animate({scrollTop: '400'}, "slow");
3628 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3629 $('#PMH_left').height($('#PMH_right').height());
3630 $('#PMH_1').height($('#PMH_right').height()+20);
3631 } else { $('#PMH_1').height($('#HPI_1').height()); }
3633 else if (zone == 'HPI') {
3634 if($('#PMH_right').css('display') == 'none') {
3635 $("#PRIORS_PMH_left_text").addClass('nodisplay');
3636 $("#Draw_PMH").addClass('nodisplay');
3637 show_QP_section('PMH','1');
3638 $("#PREFS_PMH_RIGHT").val('QP');
3640 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3641 $('#PMH_left').height($('#PMH_right').height());
3642 } else { $('#PMH_1').height($('#HPI_1').height()); }
3643 } else if (zone == 'menu') {
3644 show_QP();
3645 } else if (zone == 'IMPPLAN') {
3646 show_QP_section('IMPPLAN');
3647 update_PREFS();
3653 // set default to ccDist. Change as desired.
3654 $('#NEURO_ACT_zone').val('CCDIST').trigger('change');
3655 if ($("#RXStart").val() =="2") {
3656 $("#Trifocal").trigger('click');
3658 $("[id$='_loading']").addClass('nodisplay');
3659 $("[id$='_sections']").removeClass('nodisplay');
3661 if ($('#PMH_right').height() > $('#PMH_left').height()) {
3662 $('#PMH_left').height($('#PMH_right').height());
3663 } else { $('#PMH_1').height($('#HPI_1').height()); }
3665 $('#left-panel').css("right","0px");
3666 $('#EXAM_KB').css({position: 'fixed', top: '29px'});
3667 $('#EXAM_KB').css('display', 'block');
3668 $('#EXAM_KB').draggable();
3669 $('#IMP').droppable({ drop: dragto_IMPPLAN } );
3670 $('#IMPPLAN_zone').droppable({ drop: dragto_IMPPLAN_zone } );
3671 $('#IMPPLAN_text').droppable({ drop: dragto_IMPPLAN_zone } );
3673 $('[id^="PLANS"]').draggable( { cursor: 'move', revert: true });
3674 $('[id^="PLAN_"]').height( $(this).scrollHeight );
3676 /* Sorting of diagnoses in IMP/PLAN right panel builds IMP_order[] array.
3677 Foreach index => value in IMP_order[order,PMSFH[type][i]]:
3678 retrieve PMSFH[type][value] and build the IMPRESSION/PLAN area
3679 openEMR ICD-10 seems to have newlines in codetext? strip them with replace.
3680 All the ISSUE_TYPES and their fields are available in obj.PMSFH:
3681 'title' => $disptitle,
3682 'status' => $statusCompute,
3683 'enddate' => $row['enddate'],
3684 'reaction' => $row['reaction'],
3685 'referredby' => $row['referredby'],
3686 'extrainfo' => $row['extrainfo'],
3687 'diagnosis' => $row['diagnosis'],
3688 'code' => $code,
3689 'codedesc' => $codedesc,
3690 'codetext' => $codetext,
3691 'codetype' => $codetype,
3692 'comments' => $row['comments'],
3693 'rowid' => $row['id'],
3694 'row_type' => $row['type']
3695 eg. obj.IMPPLAN_items[index] = code: obj.PMSFH['POH'][value]['code'],
3696 codedesc: obj.PMSFH['POH'][value]['codedesc'],
3697 codetype: obj.PMSFH['POH'][value]['codetype']
3700 $('#make_new_IMP').click(function() {
3701 var issue='';
3702 if (IMP_order.length ==0) rebuild_IMP($( "#build_DX_list" ));
3703 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];
3704 $.each(IMP_order, function( index, value ) {
3705 issue= value.match(/(.*)_(.*)/);
3706 if (issue[1] == "CLINICAL") {
3707 if (!$('#inc_PE').is(':checked')) { return; }
3709 var the_code='';
3710 var the_codedesc='';
3711 var the_codetext='';
3712 var the_plan='';
3713 for (i=0;i < obj.Clinical[issue[2]].length; i++) {
3714 if (i == 0) {
3715 the_code = obj.Clinical[issue[2]][i]['code'];
3716 } else if (i < obj.Clinical[issue[2]].length) {
3717 the_code += ', '+ obj.Clinical[issue[2]][i]['code'];
3719 the_codedesc += obj.Clinical[issue[2]][i]['codedesc'] + "\r";
3720 the_codetext += obj.Clinical[issue[2]][i]['codetext'] + "\r";
3721 the_plan += obj.Clinical[issue[2]][i]['codedesc'] + "\r";
3723 obj.IMPPLAN_items.push({
3724 title:obj.Clinical[issue[2]][0]['title'],
3725 code: the_code,
3726 codetype: obj.Clinical[issue[2]][0]['codetype'],
3727 codedesc: the_codedesc,
3728 codetext: the_codetext,
3729 plan: the_plan,
3730 PMSFH_link: obj.Clinical[issue[2]][0]['PMSFH_link']
3732 } else {
3733 if (issue[1] == "PMH") {
3734 if (!$('#inc_PMH').is(':checked')) { return; }
3735 } else if (issue[1] == "POH"){
3736 if (!$('#inc_POH').is(':checked')) { return; }
3737 } else if (issue[1] == "POS"){
3738 if (!$('#inc_POH').is(':checked')) { return; }
3740 obj.IMPPLAN_items.push({
3741 title: obj.PMSFH[issue[1]][issue[2]]['title'],
3742 code: obj.PMSFH[issue[1]][issue[2]]['code'],
3743 codetype: obj.PMSFH[issue[1]][issue[2]]['codetype'],
3744 codedesc: obj.PMSFH[issue[1]][issue[2]]['codedesc'],
3745 codetext: obj.PMSFH[issue[1]][issue[2]]['codetext'].replace(/(\r\n|\n|\r)/gm,""),
3746 plan: obj.PMSFH[issue[1]][issue[2]]['comments'],
3747 PMSFH_link: obj.PMSFH[issue[1]][issue[2]]['PMSFH_link']
3751 build_IMPPLAN(obj.IMPPLAN_items);
3752 store_IMPPLAN(obj.IMPPLAN_items,'1');
3756 var allPanels = $('.building_blocks > dd').hide();
3757 var allPanels2 = $('.building_blocks2 > dd').hide();
3759 $('.building_blocks > dt > span').click(function() {
3760 allPanels.slideUp();
3761 $(this).parent().next().slideDown();
3762 return false;
3764 $('.building_blocks2 > dt > span').click(function() {
3765 allPanels2.slideUp();
3766 $(this).parent().next().slideDown();
3767 return false;
3769 $('#IMP_start_acc').slideDown();
3770 $('[id^=inc_]').click(function() {
3771 build_DX_list(obj);
3774 $('#active_flag').click(function() { check_lock('1'); });
3775 $('#active_icon').click(function() { check_lock('1'); });
3777 $("input,textarea,text,checkbox").change(function(){
3778 $(this).css("background-color","#F0F8FF");
3779 submit_form($(this));
3781 $('#IMP').blur(function() {
3782 //add this DX to the obj.IMPPLAN_items array
3783 //take the first line as the impression and the rest as the plan
3784 var total_imp = $('#IMP').val();
3785 var local_plan = '';
3786 var local_code= '';
3787 if (total_imp.length < '2') return; //reject text under two letters?
3788 var re = /\r\n|[\n\v\f\r\x85\u2028\u2029]/; //official list of line delimiters for a regex
3789 //local_impression is first line only[1]
3790 var local_imp = total_imp.match(/^(.*)(?:\r\n|[\n\v\f\r\x85\u2028\u2029])(.*)/);
3791 if (local_imp == null || local_imp[1] == null) {
3792 local_imp = total_imp;
3793 } else {
3794 // If the first line was dropped in from the Builder via a draggable DX_list
3795 // it will include the IMPRESSION + CODE.
3796 // Consider stripping out the CODE
3797 var local_imp_code = local_imp[1].match(/(.*)(ICD.*)$/);
3798 if (local_imp_code) {
3799 local_imp = local_imp_code[1];
3800 local_code = local_imp_code[2];
3801 local_plan = total_imp.replace(local_imp_code[0],''); //plan is line 2+ if present, strip off first line
3802 local_plan = local_plan.replace(/^\r\n|[\n\v\f\r\x85\u2028\u2029]/,'');
3803 } else {
3804 local_imp = local_imp[1];
3805 local_code = '';
3806 local_plan = total_imp.replace(local_imp,''); //plan is line 2+ if present, strip off first line
3807 local_plan = local_plan.replace(/^\r\n|[\n\v\f\r\x85\u2028\u2029]/,'');
3810 if (obj.IMPPLAN_items ==null) obj.IMPPLAN_items = [];//can't push if array does not exist
3811 obj.IMPPLAN_items.push({
3812 form_id: $('#form_id').val(),
3813 pid: $('#pid').val(),
3814 title: local_imp,
3815 plan: local_plan,
3816 code: local_code,
3817 codetext:'',
3818 codetype:'',
3819 codedesc:'',
3820 PMSFH_link: ''
3822 build_IMPPLAN(obj.IMPPLAN_items);
3823 store_IMPPLAN(obj.IMPPLAN_items,'1');
3824 $('#IMP').val('');//clear the box
3825 submit_form('1');//tell the server where we stand
3827 $('#Add_Glasses').click(function() {
3828 for (i=2; i <6; i++) { //come on, 5 current rx glasses should be enough...
3829 if ($('#W_'+i).val() != '1') {
3830 $('#W_'+i).val('1');
3831 $('#LayerVision_W_'+i).removeClass('nodisplay');
3832 if (i==5) { $('#Add_Glasses').addClass('nodisplay'); }
3833 break;
3837 $("[name='reverseme']").click(function() {
3838 var target = this.id;
3839 reverse_cylinder(target);
3842 $('#code_me_now').click(function(event) {
3843 event.preventDefault();
3844 build_CODING_list();
3846 $( ".widget a" ).button();
3848 $('#goto_fee_sheet2').click(function(event) {
3849 goto_url('<?php echo $GLOBALS['webroot']; ?>/interface/patient_file/encounter/load_form.php?formname=fee_sheet');
3852 $( "button" ).button().click(function( event ) {
3853 event.preventDefault();
3855 refresh_page();
3856 // AUTO- CODING FEATURES
3857 check_CPT_92060();
3858 check_exam_detail();
3859 if ($("#PRIOR_ALL").value == "undefined") {
3860 var Code_new_est="New";
3861 } else {
3862 var Code_new_est="Est";
3864 Suggest_visit_code();
3865 $('#visit_codes').change(function() {
3866 var data_all = $(this).val();
3867 var data = data_all.match(/^(.*)\|(.*)\|/);
3868 visit_code = data[2];
3869 visit_type = data[1];
3871 show_QP_section('IMPPLAN','1');
3872 build_IMPPLAN(obj.IMPPLAN_items);
3873 scroll='1';
3874 <?php if ($GLOBALS['new_tabs_layout'] !=='1') { ?> $("[class='tabHide']").css("display","inline-block"); <?php } ?>
3875 $("input,textarea,text").focus(function(){
3876 $(this).css("background-color","#ffff99");
3878 $(window).bind('onbeforeunload', function(){
3879 if ($('#chart_status').val()=="on") {
3880 unlock(); }