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
9 * @link https://www.open-emr.org
10 * @author Ray Magauran <rmagauran@gmail.com>
11 * @copyright Copyright (c) 2016- Raymond Magauran <rmagauran@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../../../globals.php");
16 require_once("$srcdir/api.inc.php");
17 require_once("$srcdir/forms.inc.php");
18 require_once("$srcdir/patient.inc.php");
20 $providerID = $_REQUEST['providerID'];
32 var detail_reached_exam
='0';
33 var detail_reached_HPI
='0';
34 var chronic_reached_HPI
='0';
35 //Coding Engine Defaults
36 var Code_group
="Eyes";//options are Eyes - anything else and Coding Engine prefers E&M Codes
37 var digit_2
="2"; //Eye Code
38 var digit_4
="1"; //Established
39 var digit_5
="4"; //Level 4
42 var $root = $
('html, body');
44 var visit_modifier
=[];
45 var visit_justifier
=[];
46 if (typeof Code_new_est
=== 'undefined') {
47 var Code_new_est
= 'New';
52 * Functions to add a quick pick selection to the correct fields on the form.
54 function fill_QP_2fields(PEZONE
, ODOSOU
, LOCATION_text
, selection
, fill_action
, Code_to_process
) {
55 var prefix
= document
.getElementById(PEZONE+
'_prefix').value
;
56 if (prefix
> '' && prefix
!='off') {prefix
= prefix +
" ";}
57 if ((prefix
=='off')||
(LOCATION_text
=='')) { prefix
=''; }
58 var saved_prefix
= prefix
;
60 fill_QP_field(PEZONE
, "OD", LOCATION_text
, selection
, fill_action
, Code_to_process
);
61 fill_QP_field(PEZONE
, "OS", LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
);
62 } else if (ODOSOU
=="B") {
63 fill_QP_field(PEZONE
, "R", LOCATION_text
, selection
, fill_action
, Code_to_process
);
64 fill_QP_field(PEZONE
, "L", LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
);
67 function fill_QP_field(PEZONE
, ODOSOU
, LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
) {
69 var FIELDID
= ODOSOU + LOCATION_text
;
71 var FIELDID
= document
.getElementById(PEZONE+
'_'+ODOSOU
).value + LOCATION_text
;
73 var bgcolor
= $
("#" +FIELDID
).css("background-color");
76 var prefix
= saved_prefix
;
78 var prefix
= document
.getElementById(PEZONE+
'_prefix').value
;
81 var Fvalue
= document
.getElementById(FIELDID
).value
;
82 if (prefix
> '' && prefix
!='off') {prefix
= prefix +
" ";}
83 if (prefix
=='off') { prefix
=''; }
84 if (fill_action
=="REPLACE") {
85 $
("#" +FIELDID
).val(prefix +selection
);
86 $
("#" +FIELDID
).css("background-color","#F0F8FF");
87 } else if (fill_action
=="APPEND") {
88 $
("#" +FIELDID
).val(Fvalue+selection
).css("background-color","#F0F8FF");
90 if (($
("#" +FIELDID
).css("background-color")=="rgb(245, 245, 220)") ||
(Fvalue
=='')) {
91 //rgb(245, 245, 220) is beige - the field is untouched
92 $
("#" +FIELDID
).val(prefix+selection
).css("background-color","#F0F8FF");
93 } else if (Fvalue
.match(/x$
/)) {
94 $
("#" +FIELDID
).val(Fvalue+selection
).css("background-color","#F0F8FF");
96 if (Fvalue
>'') prefix
= ", "+prefix
;
97 $
("#" +FIELDID
).val(Fvalue + prefix +selection
).css("background-color","#F0F8FF");
100 submit_form(FIELDID
);
101 $
('#'+PEZONE+
'_prefix').val('off').trigger('change');
105 * This is the core function of the form.
106 * It submits the data in the background via ajax.
107 * It is the reason we don't use a submit button.
108 * It is called often, perhaps too often for some installs because it uses bandwidth.
109 * It needs to be keenly looked at by developers as it will affect scalability.
110 * It returns either "Code 400" or positive hits from the clinical data passed through the Coding engine.
111 * It ensures ownership of the form or provides background updates to READ-ONLY instances of the form.
112 * It doesn't unlock a form to change ownership/provide write privileges. This is done via the unlock() function.
114 function submit_form(action
) {
115 var url
= "../../forms/eye_mag/save.php?sub=1&mode=update&id=" + $
("#form_id").val();
116 if ($
("#COPY_SECTION").value
== "READONLY") return;
117 formData
= $
("form#eye_mag").serialize();
118 if (formData
=='') return;
119 $
("#menustate").val('0');
120 top
.restoreSession();
124 data
: formData
//, dataType: "json"
125 }).done(function(result
) {
126 if (result
== 'Code 400') {
127 code_400(); //Not the owner: read-only mode or take ownership
130 // Coding engine returns any positive Clinical findings.
131 //List these findings in the IMP_PLAN Builder
132 if (action
!='1') {populate_form(result
);}
138 * This function alerts the user that they have lost write privileges to another user.
139 * The form is locked (fields disabled) and they enter the READ-ONLY mode.
140 * In READ-ONLY mode the form is refreshed every 15 seconds showing changes made by the user with write privileges.
142 function code_400() {
143 //User lost ownership. Just watching now...
144 //now we should get every variable and update the form, every 15 seconds...
145 $
("#active_flag").html(" READ-ONLY ");
146 toggle_active_flags("off");
147 alert("Another user has taken control of this form.\rEntering READ-ONLY mode.");
149 this_form_id
= $
("#form_id").val();
150 $
("#COPY_SECTION").val("READONLY");
151 update_chart
= setInterval(function() {
152 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
158 * Convert the DB datetime values into date objects in JS
160 * "You should parse them to get a Date object, for that format I always use the following function:
161 * http://stackoverflow.com/questions/2627650/why-javascript-gettime-is-not-a-function"
164 function parseDate(input
) {
165 var parts
= input
.match(/(\d+
)/g
);
166 // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
167 return new Date(parts
[0], parts
[1]-1, parts
[2]); // months are 0-based
170 * Function to check locked state
172 function check_lock(modify
) {
173 var locked
= $
("#LOCKED").val();
174 var locked_by
= $
("#LOCKEDBY").val();
175 if ($
("#LOCKEDDATE").val() > '') {
176 var locked_date
= parseDate($
("#LOCKEDDATE").val());
178 var locked_date
= new Date('2000-01-01');
180 var uniqueID
= $
('#uniqueID').val();
182 var url
= "../../forms/eye_mag/save.php?mode=update&id=" + $
("#form_id").val();
183 clearInterval(update_chart
);
184 //if the form was locked > 1 hour ago, tag we are it - we should auto-get ownership
185 //if not we have to physically take it.
187 now_time
= now
.getTime();
188 var interval
= locked_date
.setTime(locked_date
.getTime() +
(60*60*1000));//locked timestamp + 1 hour
190 if ($
("#chart_status").val() == "on") {
192 toggle_active_flags("off");
193 update_chart
= setInterval(function() {
194 if ($
("#chart_status").val() == "on") { clearInterval(update_chart
);}
197 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
199 top
.restoreSession();
204 'acquire_lock' : '1',
205 'uniqueID' : uniqueID
,
206 'form_id' : $
("#form_id").val(),
207 'locked_by' : $
("#LOCKEDBY").val()
209 }).done(function(d
) {
210 $
("#LOCKEDBY").val(uniqueID
);
211 toggle_active_flags("on");
212 clearInterval(update_chart
);
215 } else if (locked
=='1' && (interval
< now_time
)) { //it was locked more than an hour ago, take ownership quietly
216 top
.restoreSession();
221 'acquire_lock' : '1',
222 'uniqueID' : uniqueID
, //this user is becoming the new owner
223 'locked_by' : locked_by
, //this is the old owner
224 'form_id' : $
("#form_id").val()
226 }).done(function(d
) {
227 $
("#LOCKEDBY").val(uniqueID
);
228 $
("#LOCKEDDATE").val(d
);
229 toggle_active_flags("on");
232 } else if (locked
=='1' && locked_by
>'' && (uniqueID
!= locked_by
)) {
233 //form is locked by someone else, less than an hour ago...
234 $
("#active_flag").html(" READ-ONLY ");
235 if (confirm('\tLOCKED by another user:\t\n\tSelect OK to take ownership or\t\n\tCANCEL to enter READ-ONLY mode.\t')) {
236 top
.restoreSession();
241 'acquire_lock' : '1',
242 'uniqueID' : uniqueID
, //this user is becoming the new owner
243 'locked_by' : locked_by
, //this is the old owner
244 'form_id' : $
("#form_id").val()
246 }).done(function(d
) {
247 $
("#LOCKEDBY").val(uniqueID
);
248 toggle_active_flags("on");
252 //User selected "Cancel" -- ie. doesn't want ownership. Just watching...
253 toggle_active_flags("off");
254 update_chart
= setInterval(function() {
255 $
("#COPY_SECTION").trigger('change');
256 if ($
("#chart_status").val() == "on") { clearInterval(update_chart
);}
259 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
265 * Function to save a canvas by zone
267 function submit_canvas(zone
) {
268 var id_here
= document
.getElementById('myCanvas_'+zone
);
269 var dataURL
= id_here
.toDataURL('image/jpeg');
270 top
.restoreSession();
273 url
: "../../forms/eye_mag/save.php?canvas="+zone+
"&id="+$
("#form_id").val(),
275 imgBase64
: dataURL
, //this contains the canvas + new strokes, the sketch.js foreground
277 'visit_date' : $
("#visit_date").val(),
278 'encounter' : $
("#encounter").val(),
279 'pid' : $
("#pid").val()
282 }).done(function(o
) {
286 * Function to update the user's preferences
288 function update_PREFS() {
289 var checker
= $
('#PREFS_TOOLTIPS').val();
291 var url
= "../../forms/eye_mag/save.php";
294 'PREFS_VA' : $
('#PREFS_VA').val(),
295 'PREFS_W' : $
('#PREFS_W').val(),
296 'PREFS_MR' : $
('#PREFS_MR').val(),
297 'PREFS_W_width' : $
('#PREFS_W_width').val(),
298 'PREFS_MR_width' : $
('#PREFS_MR_width').val(),
299 'PREFS_CR' : $
('#PREFS_CR').val(),
300 'PREFS_CTL' : $
('#PREFS_CTL').val(),
301 'PREFS_ADDITIONAL' : $
('#PREFS_ADDITIONAL').val(),
302 'PREFS_VAX' : $
('#PREFS_VAX').val(),
303 'PREFS_RXHX' : $
('#PREFS_RXHX').val(),
304 'PREFS_IOP' : $
('#PREFS_IOP').val(),
305 'PREFS_CLINICAL' : $
('#PREFS_CLINICAL').val(),
306 'PREFS_EXAM' : $
('#PREFS_EXAM').val(),
307 'PREFS_CYL' : $
('#PREFS_CYL').val(),
308 'PREFS_EXT_VIEW' : $
('#PREFS_EXT_VIEW').val(),
309 'PREFS_ANTSEG_VIEW' : $
('#PREFS_ANTSEG_VIEW').val(),
310 'PREFS_RETINA_VIEW' : $
('#PREFS_RETINA_VIEW').val(),
311 'PREFS_NEURO_VIEW' : $
('#PREFS_NEURO_VIEW').val(),
312 'PREFS_ACT_VIEW' : $
('#PREFS_ACT_VIEW').val(),
313 'PREFS_ACT_SHOW' : $
('#PREFS_ACT_SHOW').val(),
314 'PREFS_HPI_RIGHT' : $
('#PREFS_HPI_RIGHT').val(),
315 'PREFS_PMH_RIGHT' : $
('#PREFS_PMH_RIGHT').val(),
316 'PREFS_EXT_RIGHT' : $
('#PREFS_EXT_RIGHT').val(),
317 'PREFS_ANTSEG_RIGHT' : $
('#PREFS_ANTSEG_RIGHT').val(),
318 'PREFS_RETINA_RIGHT' : $
('#PREFS_RETINA_RIGHT').val(),
319 'PREFS_NEURO_RIGHT' : $
('#PREFS_NEURO_RIGHT').val(),
320 'PREFS_PANEL_RIGHT' : $
('#PREFS_PANEL_RIGHT').val(),
321 'PREFS_IMPPLAN_RIGHT' : $
('#PREFS_IMPPLAN_DRAW').val(),
322 'PREFS_KB' : $
('#PREFS_KB').val(),
323 'PREFS_TOOLTIPS' : $
('#PREFS_TOOLTIPS').val(),
324 'setting_tabs_left' : $
('#setting_tabs_left').val(),
325 'setting_HPI' : $
('#setting_HPI').val(),
326 'setting_PMH' : $
('#setting_PMH').val(),
327 'setting_EXT' : $
('#setting_EXT').val(),
328 'setting_ANTSEG' : $
('#setting_ANTSEG').val(),
329 'setting_POSTSEG' : $
('#setting_POSTSEG').val(),
330 'setting_NEURO' : $
('#setting_NEURO').val(),
331 'setting_IMPPLAN' : $
('#setting_IMPPLAN').val(),
333 top
.restoreSession();
342 * Function to unlock the form - remove temporary lock at DB level.
345 var url
= "../../forms/eye_mag/save.php?mode=update&id=" + $
("#form_id").val();
349 'encounter' : $
('#encounter').val(),
350 'pid' : $
('#pid').val(),
351 'LOCKEDBY' : $
('#LOCKEDBY').val(),
352 'form_id' : $
("#form_id").val()
354 top
.restoreSession();
358 data
: formData
}).done(function(o
) {
359 $
("#warning").removeClass("nodisplay");
360 $
('#LOCKEDBY').val('');
361 $
('#chart_status').val('off');
365 * Function to fax this visit report to someone.
367 function create_task(to_id
,task
,to_type
) {
368 $
(this
).addClass('fa-spin');
369 var url
= "../../forms/eye_mag/taskman.php";
371 'action' : "make_task",
372 'from_id' : <?php
echo attr_js((int) $providerID); ?
>,
374 'pid' : $
('#pid').val(),
376 'enc' : $
('#encounter').val(),
377 'form_id' : $
('#form_id').val()
379 top
.restoreSession();
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
);
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');
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");
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");
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";
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';
461 'a_issue' : issue_number
,
465 top
.restoreSession();
470 success
:(function(result
) {
471 populate_PMSFH(result
);
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();
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
='';
504 populate_form(result
);
508 * END OF PMSFH FUNCTIONS
512 * Function to refresh the issues, the panels and the Impression/coding areas.
514 function refresh_page() {
515 var url
= '../../forms/eye_mag/view.php?display=PMSFH';
517 'action' : "refresh",
518 'id' : $
('#form_id').val(),
519 'encounter' : $
('#encounter').val(),
520 'pid' : $
('#pid').val(),
523 top
.restoreSession();
528 success
:(function(result
) {
529 populate_form(result
);
532 //Make the height of the panels equal if they grow really large
533 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
534 $
('#PMH_left').height($
('#PMH_right').height());
535 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
540 * Function to refresh the Glaucoma Flow Sheet.
542 function refresh_GFS() {
543 if (typeof config_byday
== "undefined") { return; }
545 var indexToUpdate
= '0';
546 $
.each(config_byday
.data
.labels
, function(key
,value
) {
547 if (value
== visit_date
) {
552 //var indexToUpdate = config_byday.data.labels.length-1;
555 if ( $
('#ODIOPAP').val()) {
556 ODIOP
= $
('#ODIOPAP').val();
557 } else if ( $
('#ODIOPTPN').val()) {
558 ODIOP
= $
('#ODIOPTPN').val();
561 if ( $
('#OSIOPAP').val() >'0') {
562 OSIOP
= $
('#OSIOPAP').val();
563 } else if ( $
('#OSIOPTPN').val() > '0') {
564 OSIOP
= $
('#OSIOPTPN').val();
567 config_byday
.data
.datasets
[0].data
[indexToUpdate
] = $
('#ODIOPTARGET').val();
568 config_byday
.data
.datasets
[1].data
[indexToUpdate
] = ODIOP
;
569 config_byday
.data
.datasets
[2].data
[indexToUpdate
] = OSIOP
;
572 var time
= $
('#IOPTIME').val();
573 times
= time
.match(/^
(\d
{1,2}):(\d
{2})/);
574 if (times
[1] < 10) times
[1] = "0"+
''+times
[1];
575 time
= times
[1]+
':'+times
[2];
576 var indexToUpdate2
= '0';
577 $
.each(config_byhour
.data
.labels
, function(key
,value
) {
579 indexToUpdate2
= key
;
582 config_byhour
.data
.datasets
[0].data
[indexToUpdate2
] = ODIOP
;
583 config_byhour
.data
.datasets
[1].data
[indexToUpdate2
] = OSIOP
;
585 // Update one of the points in the second dataset
586 // myLine.data.datasets[1].data[indexToUpdate].val($('#ODIOPAP').val());
587 //alert(config_byday.data.datasets[1].data[indexToUpdate].val()+' is ending _bydat val');
592 this should refresh locally and not go back to the server
593 the only things that would trigger a refresh are
597 change in GONIO fields
598 additional tests (VF/OCT) would not affect this in its live format
603 function populate_GFS(result
) {
604 $
("#LayerVision_IOP").html(result
);
608 * Server returns a json encoding object: obj to update the page
609 * Here we refresh the PMSFH display panels,
610 * Rebuild the Impression/Plan Builder DX lists,
611 * the Impression Plan area
612 * and the CHRONIC fields.
614 function populate_form(result
) {
615 obj
= JSON
.parse(result
);
616 $
("#QP_PMH").html(obj
.PMH_panel
);
617 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
618 $
('#PMH_left').height($
('#PMH_right').height());
619 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
620 $
("#right_panel_refresh").html(obj
.right_panel
);
621 build_IMPPLAN(obj
.IMPPLAN_items
);
623 build_DX_list(obj
); //build the list of DXs to show in the Impression/Plan Builder
626 * Function to auto-fill CHRONIC fields
627 * To reach a detailed E&M level of documentation the chart
628 * may comment on the status of 3 or more CHRONIC/Inactive problems.
629 * The user can type them into the CHRONIC fields manually, or
630 * we can do it programatically if the user does the following:
631 * 1. documenting a PMH diagnosis in the PMSFH area
632 * 2. listing it as "Chronic"
633 * 3. making a comment about it
634 * With these three steps completed, this build_CHRONIC function displays the changes
635 * in the CHRONIC1-3 textareas, if not already filled in, for today's visit.
636 * On subsequent visits, the CHRONIC1-3 fields are blank, unless the above steps
637 * were performed previously, then they are filled in automatically on loading of the new form.
639 function build_Chronics(obj
) {
640 if (typeof obj
.PMSFH
=== "undefined") return;
641 var CHRONICS
= obj
.PMSFH
['CHRONIC'];
645 $
.each(CHRONICS
, function(key
, value
) {
646 local_comment
= CHRONICS
[key
].title+
" "+CHRONICS
[key
].diagnosis+
"\n"+CHRONICS
[key
].comments
;
648 for (i
=1; i
< 4; i++
) {
649 chronic_value
= $
('#CHRONIC'+i
).val();
650 if (chronic_value
== local_comment
) {
651 here_already
='1'; //this is here, move to next CHRONICS
655 if (here_already
!='1') {
656 for (i
=1; i
< 4; i++
) {
657 chronic_value
= $
('#CHRONIC'+i
).val();
658 if (chronic_value
== '') { //if the CHRONIC1-3 field is empty, fill it.
659 $
('textarea#CHRONIC'+i
).val(local_comment
);
668 * Function to autocreate a PDF of this form as a document linked to this encounter.
669 * Each time it is runs it updates by replacing the encounter's PDF.
670 * This used to be fired often, but it is a server resource beast.
671 * Use it sparingly, and intentionally only.
672 * Currently only invoked via the bootstrap menu: Menu->File->Print/Store PDF
674 function store_PDF() {
675 var url
= "../../forms/eye_mag/save.php?mode=update";
677 'action' : 'store_PDF',
678 'patient_id' : $
('#pid').val(),
681 'form_folder' : $
('#form_folder').val(),
682 'form_id' : $
('#form_id').val(),
683 'encounter' : $
('#encounter').val(),
684 'uniqueID' : $
('#uniqueID').val()
686 top
.restoreSession();
694 /* START Functions related to form VIEW */
696 * Function to blow out the form and display the right side of every section.
698 function show_right() {
699 $
("#HPI_1").removeClass("size50").addClass("size100");
700 $
("#PMH_1").removeClass("size50").addClass("size100");
701 $
("#EXT_1").removeClass("size50").addClass("size100");
702 $
("#ANTSEG_1").removeClass("size50").addClass("size100");
703 $
("#NEURO_1").removeClass("size50").addClass("size100");
704 $
("#POSTSEG_1").removeClass("size50").addClass("size100");
705 $
("#IMPPLAN_1").removeClass("size50").addClass("size100");
706 $
("#HPI_right").removeClass('nodisplay');
707 $
("#PMH_right").removeClass('nodisplay');
708 $
("#EXT_right").removeClass('nodisplay');
709 $
("#ANTSEG_right").removeClass('nodisplay');
710 $
("#NEURO_right").removeClass('nodisplay');
711 $
("#RETINA_right").removeClass('nodisplay');
712 $
("#IMPPLAN_right").removeClass('nodisplay');
713 $
("#PMH_1").addClass("clear_both");
714 $
("#ANTSEG_1").addClass("clear_both");
715 $
("#POSTSEG_1").addClass("clear_both");
716 $
("#NEURO_1").addClass("clear_both");
717 $
("#IMPPLAN_1").addClass("clear_both");
721 * Function to implode the form and hide the right side of every section.
723 function hide_right() {
724 $
("#HPI_1").removeClass("size100").addClass("size50");
725 $
("#PMH_1").removeClass("size100").addClass("size50");
726 $
("#EXT_1").removeClass("size100").addClass("size50");
727 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
728 $
("#NEURO_1").removeClass("size100").addClass("size50");
729 $
("#RETINA_1").removeClass("size100").addClass("size50");
730 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
731 $
("#HPI_right").addClass('nodisplay');
732 $
("#PMH_right").addClass('nodisplay');
733 $
("#EXT_right").addClass('nodisplay');
734 $
("#ANTSEG_right").addClass('nodisplay');
735 $
("#NEURO_right").addClass('nodisplay');
736 $
("#RETINA_right").addClass('nodisplay');
737 $
("#PMH_1").removeClass("clear_both");
738 $
("#ANTSEG_1").removeClass("clear_both");
739 $
("#POSTSEG_1").removeClass("clear_both");
740 $
("#NEURO_1").removeClass("clear_both");
744 * Function to explode the form and show the left side of every section.
746 function show_left() {
747 $
("#HPI_1").removeClass("size100").addClass("size50");
748 $
("#PMH_1").removeClass("size100").addClass("size50");
749 $
("#EXT_1").removeClass("size100").addClass("size50");
750 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
751 $
("#NEURO_1").removeClass("size100").addClass("size50");
752 $
("#POSTSEG_1").removeClass("size100").addClass("size50");
753 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
754 $
("#HPI_left").removeClass('nodisplay');
755 $
("#PMH_left").removeClass('nodisplay');
756 $
("#EXT_left").removeClass('nodisplay');
757 $
("#ANTSEG_left").removeClass('nodisplay');
758 $
("#RETINA_left").removeClass('nodisplay');
759 $
("#NEURO_left").removeClass('nodisplay');
760 $
("#IMPPLAN_left").removeClass('nodisplay');
761 $
("[name$='_left']").removeClass('nodisplay');
764 * Function to implode the form and hide the left side of every section.
766 function hide_left() {
767 $
("#HPI_1").removeClass("size100").addClass("size50");
768 $
("#PMH_1").removeClass("size100").addClass("size50");
769 $
("#EXT_1").removeClass("size100").addClass("size50");
770 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
771 $
("#NEURO_1").removeClass("size100").addClass("size50");
772 $
("#POSTSEG_1").removeClass("size100").addClass("size50");
773 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
774 $
("#HPI_left").addClass('nodisplay');
775 $
("#PMH_left").addClass('nodisplay');
776 $
("#EXT_left").addClass('nodisplay');
777 $
("#ANTSEG_left").addClass('nodisplay');
778 $
("#RETINA_left").addClass('nodisplay');
779 $
("#NEURO_left").addClass('nodisplay');
780 $
("#IMPPLAN_left").addClass('nodisplay');
781 $
("[name $='_left']").addClass('nodisplay');
784 * Function to display only the DRAW panels of every section.
785 * The technical section, between HPI and Clinical section is still visible.
787 function show_DRAW() {
795 $
("#HPI_right").addClass('canvas');
796 $
("#PMH_right").addClass('canvas');
797 $
("#EXT_right").addClass('canvas');
798 $
("#ANTSEG_right").addClass('canvas');
799 $
("#RETINA_right").addClass('canvas');
800 $
("#NEURO_right").addClass('canvas');
801 $
("#IMPPLAN_right").addClass('canvas');
802 $
(".Draw_class").removeClass('nodisplay');
803 if ($
("#PREFS_CLINICAL").val() !='1') {
804 $
("#PREFS_CLINICAL").val('1');
805 $
("#PREFS_EXAM").val('DRAW');
810 * Function to display only the TEXT panels in every section.
812 function show_TEXT() {
813 $
(".TEXT_class").removeClass('nodisplay');
815 hide_right(); //this hides the right half
819 if ($
("#PREFS_CLINICAL").val() !='1') {
820 // we want to show text_only which are found on left half
821 $
("#PREFS_CLINICAL").val('1');
823 $
("#PREFS_EXAM").val('TEXT');
824 $
("#IMPPLAN_right").addClass('canvas').removeClass('nodisplay');
825 $
("#QP_IMPPLAN").removeClass('nodisplay');
826 $
("#DRAW_"+zone
).addClass('nodisplay');
827 $
("#IMPPLAN_left").removeClass('nodisplay');
828 $
("#PREFS_IMPPLAN_RIGHT").val('QP');
832 * Function to display the PRIORS panels in every right section.
834 function show_PRIORS() {
835 $
("#NEURO_sections").removeClass('nodisplay');
837 $
("#EXT_right").addClass("PRIORS_color");
841 $
("#QP_HPI").removeClass('nodisplay');
842 $
("#QP_PMH").removeClass('nodisplay');
843 $
("#HPI_right").addClass('canvas');
844 $
("#PMH_right").addClass('canvas');
845 $
("#IMPPLAN_right").addClass('canvas');
846 $
("#EXT_right").addClass('canvas');
847 $
("#ANTSEG_right").addClass('canvas');
848 $
("#RETINA_right").addClass('canvas');
849 $
("#NEURO_right").addClass('canvas');
850 $
(".PRIORS_class").removeClass('nodisplay');
851 if ($
("#PREFS_CLINICAL").val() !='1') {
852 // we want to show text_only which are found on left half now that PRIORS are visible.
853 $
("#PREFS_CLINICAL").val('1');
855 $
("#PREFS_EXAM").val('PRIORS');
859 * Function to show the Quick Picks panel on the right side of every section.
868 $
("#HPI_right").addClass('canvas');
869 $
("#PMH_right").addClass('canvas');
870 $
("#EXT_right").addClass('canvas');
871 $
("#ANTSEG_right").addClass('canvas');
872 $
("#RETINA_right").addClass('canvas');
873 $
("#NEURO_right").addClass('canvas');
874 $
("#IMPPLAN_right").addClass('canvas');
875 $
(".QP_class").removeClass('nodisplay');
876 $
(".QP_class2").removeClass('nodisplay');
877 $
("#PREFS_EXAM").val('QP');
881 * Function to display only one DRAW panel of one section.
883 function show_DRAW_section(zone
) {
884 $
("#QP_"+zone
).addClass('nodisplay');
885 $
("#"+zone+
"_left").removeClass('nodisplay');
886 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
887 $
("#Draw_"+zone
).addClass('canvas');
888 $
("#Draw_"+zone
).removeClass('nodisplay');
889 $
("#PREFS_"+zone+
"_DRAW").val(1);
893 * Function to display only one PRIORS panel of one section.
895 function show_PRIORS_section(section
,newValue
) {
896 var url
= "../../forms/eye_mag/save.php?mode=retrieve";
899 'PRIORS_query' : "1",
901 'id_to_show' : newValue
,
902 'pid' : $
('#pid').val(),
903 'orig_id' : $
('#form_id').val()
905 top
.restoreSession();
910 success
: function(result
) {
911 $
("#PRIORS_" + section +
"_left_text").html(result
);
916 * Function to display a canvas/drawing from a prior visit.
919 function show_PRIOR_CANVAS_section(section
, newValue
) {
920 var pid
= $
('#pid').val();
922 var result
= base+
'/controller.php?document&retrieve&patient_id='+pid+
'&document_id='+newValue+
'&as_file=false';
923 var cp_forward
= '<button onclick="replace_CANVAS(\''+zone+
'\',\''+result+
'\'); return false;" id="Replace_Canvas_ANTSEG" class="ui-button ui-corner-all ui-widget"><?php echo xlt('Use this image
'); ?></button>';
924 var filler
= "<div class='tools text-info'><?php echo xlt('Previous Encounter Drawings'); ?>: "+cp_forward+
"</div><div class='borderShadow'><img src='"+result+
"' alt='<?php echo xla("Loading prior image
");?>...'></div>";
926 $
("#"+zone+
"_canvas").addClass('nodisplay');
927 $
("#"+zone+
"_olddrawing").html(filler
);
928 $
("#"+zone+
"_olddrawing").removeClass('nodisplay');
931 function replace_CANVAS(zone
, url
) {
932 $
("#url_"+zone
).val(url
);
934 $
("#SELECT_CANVAS_"+zone
).val('current');
935 $
("#"+zone+
"_canvas").removeClass('nodisplay');
936 $
("#"+zone+
"_olddrawing").addClass('nodisplay');
939 * Function to show one of the Quick Picks section on the right side of its section.
941 function show_QP_section(zone
,scroll
) {
942 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
943 $
("#QP_"+zone
).removeClass('nodisplay');
944 $
("#DRAW_"+zone
).addClass('nodisplay');
945 $
("#"+zone+
"_left").removeClass('nodisplay');
946 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
949 scrollTo(zone+
"_left");
953 * Function to hide all the DRAW panels of every section.
955 function hide_DRAW() {
956 $
(".Draw_class").addClass('nodisplay');
958 $
("#LayerTechnical_sections").removeClass('nodisplay');
959 $
("#REFRACTION_sections").removeClass('nodisplay');
960 $
("#PMH_sections").removeClass('nodisplay');
961 $
("#HPI_right").addClass('nodisplay');
962 $
("#HPI_right").removeClass('canvas');
963 $
("#EXT_right").removeClass('canvas');
964 $
("#RETINA_right").removeClass('canvas');
965 $
("#ANTSEG_right").removeClass('canvas');
968 * Function to hide all the Quick Pick panels of every section.
971 $
(".QP_class").addClass('nodisplay');
972 $
(".QP_class2").addClass('nodisplay');
973 $
("[name$='_right']").removeClass('canvas');
976 * Function to hide all the TEXT panels of every section.
978 function hide_TEXT() {
979 $
(".TEXT_class").addClass('nodisplay');
982 * Function to hide all the PIORS panels of every section.
984 function hide_PRIORS() {
985 $
("#EXT_right").removeClass("PRIORS_color");
986 $
("#PRIORS_EXT_left_text").addClass('nodisplay');
987 $
("#PRIORS_ANTSEG_left_text").addClass('nodisplay');
988 $
("#PRIORS_RETINA_left_text").addClass('nodisplay');
989 $
("#PRIORS_NEURO_left_text").addClass('nodisplay');
990 $
(".PRIORS_class").addClass('nodisplay');
993 * Function to hide Shorthand/Keyboard Entry panel.
996 $
('.kb').addClass('nodisplay');
997 $
('.kb_off').removeClass('nodisplay');
998 if ($
("#PREFS_KB").val() > 0) {
999 $
("#PREFS_KB").val('0');
1003 * Function to show the Shorthand/Keyboard panel.
1005 function show_KB() {
1006 $
('.kb').toggleClass('nodisplay');
1007 $
('.kb_off').toggleClass('nodisplay');
1008 $
('.copier').toggleClass('nodisplay');
1009 if ($
('#PREFS_EXAM').val() == 'DRAW') {
1013 if ($
("#PREFS_KB").val() > 0) {
1014 $
("#PREFS_KB").val('0');
1016 $
("#PREFS_KB").val('1');
1021 function editScripts(url
) {
1022 var pid
= $
('#pid').val();
1023 var AddScript
= function () {
1024 var iam
= top
.frames
.editScripts
;
1025 iam
.location
.href
= base +
"/controller.php?prescription&edit&id=&pid="+
encodeURIComponent(pid
)
1027 var ListScripts
= function () {
1028 var iam
= top
.frames
.editScripts
;
1029 iam
.location
.href
= base +
"/controller.php?prescription&list&id="+
encodeURIComponent(pid
)
1032 let title
= 'Prescriptions';
1036 dlgopen(url
, 'editScripts', w
, 300, '', '', {
1038 {text
: 'Add', close
: false, style
: 'primary btn-sm', click
: AddScript
},
1039 {text
: 'List', close
: false, style
: 'primary btn-sm', click
: ListScripts
},
1040 {text
: 'Done', close
: true, style
: 'default btn-sm'}
1042 onClosed
: 'refreshme',
1045 dialogId
: 'editscripts',
1050 /* END Functions related to form VIEW */
1053 * Function contains menu commands specific to this form.
1055 function menu_select(zone
) {
1056 $
("#menu_"+zone
).addClass('active');
1057 if (zone
=='PREFERENCES') {
1058 window
.parent
.RTop
.document
.location
.href
= base+
"interface/super/edit_globals.php";
1059 var url
= base+
"/interface/super/edit_globals.php";
1061 'id' : $
('#id').val(),
1062 'encounter' : $
('#encounter').val(),
1063 'pid' : $
('#pid').val(),
1065 top
.restoreSession();
1070 success
: function(result
) {
1071 window
.parent
.RTop
.document
.result
;
1075 if (zone
=='Left_Panel') $
("#left-panel-link").trigger('click');
1076 if (zone
=='Right_Panel') $
("#right-panel-link").trigger('click');
1077 if (zone
=='PRIORS') $
("#PRIORS_ALL_minus_one").trigger("click");
1078 if (zone
=='QP') show_QP();
1079 if (zone
=='KB') show_KB();
1080 if (zone
=='DRAW') show_DRAW();
1081 if (zone
=='TEXT') show_TEXT();
1082 if (zone
=='IOP_graph') $
("#LayerVision_IOP_lightswitch").trigger('click');
1083 if (zone
== "HPI") scrollTo("HPI_left");
1084 if (zone
== "PMH") scrollTo("PMH_left");
1085 if (zone
== "EXT") scrollTo("EXT_left");
1086 if (zone
== "ANTSEG") scrollTo("ANTSEG_left");
1087 if (zone
== "POSTSEG") scrollTo("RETINA_left");
1088 if (zone
== "NEURO") scrollTo("NEURO_left");
1089 if (zone
== "IMPPLAN") scrollTo("IMPPLAN_left");
1094 * Function to test blowing up any section to fullscren - towards tablet functionality?
1095 * Currently not used.
1097 function show_Section(section
) {
1098 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1100 $
("div[name='_sections']").style
.display
= "none"; //
1101 $
('#'+section+
'_sections').style
.display
= "block";
1102 //.show().appendTo('form_container');
1105 * Function to display Chief Complaint 1-3
1107 function show_CC(CC_X
) {
1108 $
("[name^='CC_']").addClass('nodisplay');
1109 $
("#CC_"+CC_X
).removeClass('nodisplay');
1110 $
("#CC_"+CC_X
).index
;
1113 /* START Functions related to CODING */
1116 * Function to determine if add on NeuroSensory(92060) code can be billed.
1118 function check_CPT_92060() {
1121 if ($
("#STEREOPSIS").val() > '') (neuro1
="1");
1122 $
(".neurosens2").each(function(index
) {
1123 if ($
( this
).val() > '') {
1127 if (neuro1
&& neuro2
){
1128 $
("#neurosens_code").removeClass('nodisplay');
1131 $
("#neurosens_code").addClass('nodisplay');
1136 * Function to check documentation level for coding purposes
1137 * And make suggestions to end user.
1139 function check_exam_detail() {
1140 detail_reached_HPI
='0';
1141 chronic_reached_HPI
='0';
1142 $
(".count_HPI").each(function(index
) {
1143 if ($
( this
).val() > '') detail_reached_HPI++
;
1145 if (detail_reached_HPI
> '3') {
1146 $
(".detail_4_elements").css("color","red");
1147 $
(".CODE_LOW").addClass("nodisplay");
1148 $
(".CODE_HIGH").removeClass("nodisplay");
1149 $
(".detailed_HPI").css("color","red");
1151 $
(".detail_4_elements").css("color","#876F6F");
1153 $
(".chronic_HPI").each(function(index
) {
1154 if ($
( this
).val() > '') chronic_reached_HPI++
;
1156 if (chronic_reached_HPI
> '2') {
1157 $
(".chronic_3_elements").css("color","red");
1158 $
(".CODE_LOW").addClass("nodisplay");
1159 $
(".CODE_HIGH").removeClass("nodisplay");
1160 $
(".detailed_HPI").css("color","red");
1162 $
(".chronic_3_elements").css("color","#876F6F");
1164 if ((chronic_reached_HPI
> '2')||
(detail_reached_HPI
> '3')) {
1165 $
(".CODE_LOW").addClass("nodisplay");
1166 $
(".CODE_HIGH").removeClass("nodisplay");
1167 $
(".detailed_HPI").css("color","red");
1168 detail_reached_HPI
= '1';
1170 $
(".CODE_LOW").removeClass("nodisplay");
1171 $
(".CODE_HIGH").addClass("nodisplay");
1172 $
(".detailed_HPI").css("color","#876F6F");
1173 detail_reached_HPI
= '0';
1175 if ((($
("#DIL_RISKS").is(':checked')) ||
($
(".dil_drug").is(':checked'))) && (($
('#ODPERIPH').val() >'') ||
($
('#OSPERIPH').val() >''))) {
1176 $
(".EXAM_LOW").addClass("nodisplay");
1177 $
(".DIL_RISKS").removeClass("nodisplay");
1178 $
("#DIL_RISKS").prop("checked","checked");
1179 detail_reached_exam
= '1';
1181 $
(".EXAM_LOW").removeClass("nodisplay");
1182 $
(".DIL_RISKS").addClass("nodisplay");
1183 detail_reached_exam
= '0';
1185 Suggest_visit_code();
1188 /* END Functions related to CODING */
1190 /* START Functions related to IMPPLAN Builder */
1192 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1193 * Will use actual list from obj.IMPPLAN_items for coding.
1194 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1195 * available to build the Impression/Plan from.
1197 function build_DX_list(obj
) {
1200 $
( "#build_DX_list" ).empty();
1201 //add in inc_FIELDCODES culled from the datafields
1202 if (typeof obj
.PMSFH
=== "undefined") return;
1203 if (typeof obj
.Clinical
=== "undefined") submit_form('obj.clinical is undefined');
1204 if (!obj
.PMSFH
['POH'] && !obj
.PMSFH
['PMH'] && !obj
.Clinical
) {
1205 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 />';
1206 $
( "#build_DX_list" ).html(out
);
1209 build_IMPPLAN(obj
.IMPPLAN_items
);
1210 if ($
('#inc_PE').is(':checked') && obj
.Clinical
) {
1211 $
.each(obj
.Clinical
, function(key
, value
) {
1213 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)
1214 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.Clinical
[key
][0].code+
"</code>";
1216 out +
= "<li class='ui-widget-content'><span name='DX_Clinical_"+key+
"' id='DX_Clinical_"+key+
"'>"+obj
.Clinical
[key
][0].title+
"</span> "+diagnosis+
"</li> ";
1220 if ($
('#inc_POH').is(':checked') && (obj
.PMSFH
['POH']||obj
.PMSFH
['POS'])) {
1221 $
.each(obj
.PMSFH
['POH'], function(key
, value
) {
1223 if (obj
.PMSFH
['POH'][key
].diagnosis
> '' ) {
1224 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POH'][key
].code+
"</code>";
1226 out +
= "<li class='ui-widget-content'><span name='DX_POH_"+key+
"' id='DX_POH_"+key+
"'>"+obj
.PMSFH
['POH'][key
].title+
"</span> "+diagnosis+
"</li>";
1228 $
.each(obj
.PMSFH
['POS'], function(key
, value
) {
1230 if (obj
.PMSFH
['POS'][key
].diagnosis
> '' ) {
1231 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POS'][key
].code+
"</code>";
1233 out +
= "<li class='ui-widget-content'><span name='DX_POS_"+key+
"' id='DX_POS_"+key+
"'>"+obj
.PMSFH
['POS'][key
].title+
"</span> "+diagnosis+
"</li>";
1236 if ($
('#inc_PMH').is(':checked') && obj
.PMSFH
['PMH']) {
1237 $
.each(obj
.PMSFH
['PMH'], function(key
, value
) {
1239 if (obj
.PMSFH
['PMH'][key
].diagnosis
> '') {
1240 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['PMH'][key
].code+
"</code>";
1242 out +
= "<li class='ui-widget-content'><span name='DX_PMH_"+key+
"' id='DX_PMH_"+key+
"'>"+obj
.PMSFH
['PMH'][key
].title+
"</span>"+diagnosis+
"</li> ";
1245 //add in inc_FIELDCODES culled from the datafields
1247 rebuild_IMP($
( "#build_DX_list" ));
1248 $
( "#build_DX_list" )
1249 .html(out
).sortable({ handle
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1250 .selectable({ filter
: "li", cancel
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1252 .addClass( "ui-corner-all ui-selected" )
1253 .dblclick(function(){
1254 rebuild_IMP($
( "#build_DX_list" ));
1255 $
('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1257 //this places the handle for the user to drag the item around.
1258 .prepend( "<div class='handle '><i class='fas fa-arrows-alt fa-1'></i></div>" );
1260 out
= '<br /><span class="bold"><?php echo xlt("Build Your Plan") . "."; ?></span><br /><br />';
1261 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 />';
1262 out +
= '<?php echo xlt('Update the chart to build this
list') . "."; ?><br />';
1263 $
( "#build_DX_list" ).html(out
);
1267 * Function: After the Builder DX list is built from all the available options,
1268 * the end user can select to use only certain Dxs and change their sort order of importance.
1269 * This function builds the list of DXs selected and in the order as the user sorted them,
1270 * so we know what to use to build the Impression/Plan area and in what order to display them.
1272 function rebuild_IMP(obj2
) {
1276 $
( ".ui-selected", obj2
).each(function() {
1277 var index
= $
( "#build_DX_list li" ).index( this
);
1278 if ($
('#build_DX_list li span')[index
].id
.match(/DX_POH_(.*)/)) {
1279 surface
= 'POH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POH_(.*)/)[1];
1280 IMP_order
[k
] = surface
;
1281 }else if ($
('#build_DX_list li span')[index
].id
.match(/DX_POS_(.*)/)) {
1282 surface
= 'POS_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POS_(.*)/)[1];
1283 IMP_order
[k
] = surface
;
1284 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_PMH_(.*)/)) {
1285 surface
= 'PMH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_PMH_(.*)/)[1];
1286 IMP_order
[k
] = surface
;
1287 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_Clinical_(.*)/)) {
1288 surface
= 'CLINICAL_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_Clinical_(.*)/)[1];
1289 IMP_order
[k
] = surface
;
1295 * This function builds the Impression/Plan area using the object supplied: items
1296 * It appends "items" into the Impression Plan area, complete with:
1297 * contenteditable Titles (the Impression),
1298 * its code (if part of the item object),
1299 * Plan textareas (autofilled with the item/object's "comment")
1300 * for each member of "items".
1301 * Duplicates are removed by server.
1303 function build_IMPPLAN(items
,nodisplay
) {
1305 if (typeof nodisplay
== "undefined") {
1306 $
('#IMPPLAN_zone').html("");
1308 $
('#Coding_DX_Codes').html("");
1309 $
('#visit_justification').html("");
1311 if ((items
== null) ||
( (typeof items
== "undefined") ||
(items
.length
=='0') ) ) {
1313 $
('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1314 $
('#IMPPLAN_zone').addClass('nodisplay');
1316 //ok we have at least one item, display them in order; hide the Builder instructions
1317 $
('#IMPPLAN_text').addClass('nodisplay');
1318 $
('#IMPPLAN_zone').removeClass('nodisplay');
1320 visit_justifier
=[];
1321 $
.each(items
, function( index
, value
) {
1322 if (!value
.codetext
) value
.codetext
="";
1323 if (!value
.code
) value
.code
="";
1324 if ((value
.code
==="") ||
(value
.code
.match(/Code
/) ||
(value
.code
==null))) {
1325 value
.code
="<i class='fa fa-search-plus'></i> Code";
1329 if (value
.code
.match(/\
,/g
)) {
1330 // If there is a comma in there, there is more than one code present for this item. Split them out.
1331 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1332 // PMSFH_link is only present when the Builder was used to make the entry.
1334 // So if there is no PMSFH_link and it is not generated from a clinical field:
1335 if ( ((typeof value
.PMSFH_link
!== "undefined") ||
(value
.PMSFH_link
!== null)) && (!value
.PMSFH_link
.match(/Clinical_(.*)/)) ) {
1336 //The Title should have the description.
1337 var CodeArr
= value
.code
.split(",");
1338 var TitleArr
= value
.codedesc
.split("\r");//I don't see a second codedesc being adding in for this yet...
1339 for (i
=0;i
< CodeArr
.length
;i++
) {
1340 if (CodeArr
.length
== (TitleArr
.length
-1)) { //there is a trailing \r but second codedesc should have "\r" also
1341 $
('#Coding_DX_Codes').append(count_dx +
'. '+CodeArr
[i
]+
': '+TitleArr
[i
]+
'<br />');
1343 justify_btn
= '<span class="modifier status_on" name="visit_justifier" id="visit_just_'+count_dx+
'" value="" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span>';
1344 $
('#visit_justification').append(justify_btn
);
1345 visit_justifier
.push(value
.codetype+
'|'+value
.code
[i
]);
1347 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1348 $
('#Coding_DX_Codes').append(CodeArr
[i
]+
': <?php echo xlt('Manually retrieve description on Fee Sheet
'); ?> <br />');
1350 var justify_btn
= '<span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" value="" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span>';
1352 $
('#visit_justification').append(justify_btn
);
1353 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1358 // So there IS a PMSFH_link or it was generated from a clinical field:
1360 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1361 if (value
.PMSFH_link
.match(/Clinical_(.*)/)) {
1362 if (typeof obj
.Clinical
!== "undefined") {
1363 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1364 if (obj
.Clinical
[location
]!=null ) {
1365 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1366 $
('#Coding_DX_Codes').append(count_dx +
'. '+obj
.Clinical
[location
][i
].code+
': '+obj
.Clinical
[location
][i
].codedesc+
'<br />');
1367 justify_btn
= '<span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" value="" data-justcode="'+obj
.Clinical
[location
][i
].codetype+
'|'+obj
.Clinical
[location
][i
].code+
'" title="'+obj
.Clinical
[location
][i
].codedesc+
'">'+count_dx+
'</span>';
1369 $
('#visit_justification').append(justify_btn
);
1371 visit_justifier
.push(obj
.Clinical
[location
][i
].codetype+
'|'+obj
.Clinical
[location
][i
].code
);
1377 } else { //all is good, one code only
1378 $
('#Coding_DX_Codes').append(count_dx +
'. '+value
.code+
': '+value
.codedesc+
'<br />');
1380 justify_btn
= ' <span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span> ';
1381 $
('#visit_justification').append(justify_btn
);
1382 //we assume the visit code will use this as a justification in billing so activate that link now.
1383 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1387 if (typeof nodisplay
!== "undefined") {
1390 var title2
= value
.title
.replace(/(\')/g
, '');
1391 contents_here
= "<span class='bold' contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+
"'>" +
1392 value
.title +
"</span>"+
1393 " <span contenteditable class='float-right' onclick='sel_diagnosis("+index+
",\""+title2+
"\");' title='"+value
.codetext+
"' id='CODE_"+index+
"'>"+
1394 value
.code +
"</span>"+
1395 "<br /><textarea id='PLAN_"+index+
"' name='PLAN_"+index+
1396 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1397 value
.plan +
"</textarea><br /></li>";
1398 $
('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+
'" class="IMPPLAN_class">'+
1399 '<i class="float-right fa fa-times" id="BUTTON_IMPPLAN_'+index+
'"></i>'+
1400 contents_here+
'</div>');
1401 $
('#BUTTON_IMPPLAN_'+index
).on('click', function() {//delete/close icon
1402 var item
= this
.id
.match(/BUTTON_IMPPLAN_(.*)/)[1];
1403 obj
.IMPPLAN_items
.splice(item
,1);
1404 build_IMPPLAN(obj
.IMPPLAN_items
);
1405 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1407 $
('#PLAN_'+index
).css("background-color","#F0F8FF");
1410 //now attach visit_justifier(s) to each TEST
1411 //If the TEST_justifiers were ever touched AND
1412 $
.each($
(".TESTS_justify"), function( index
, value
) {
1414 var herenow
= $
("#TEST_"+index+
"_justify");
1416 for (var i
= 0, length
= visit_justifier
.length
; i
< length
; i++
) {
1417 item2
= visit_justifier
[i
];
1419 for (var j
=0;j
< CODING_items
.length
; j++
) {
1420 if (CODING_items
[j
].justify
== item2
) {
1424 //if item2 is in CODING_items, it will have class=status_on and we need modifier 25, maybe 59 if there are two or more?
1425 justify_btn
= ' <span class="modifier '+status+
'" id="TEST_'+index+
'_just_'+i+
'" name="TEST_'+index+
'_justifiers" value="" data-justcode="'+item2+
'" title="'+item2+
'">'+
(i+
1)+
'</span>';
1426 herenow
.append(justify_btn
);
1430 // The IMPRESSION DXs are "contenteditable" spans.
1431 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1432 $
('[id^=IMPRESSION_]').on('blur', function(e
) {
1434 var item
= this
.id
.match(/IMPRESSION_(.*)/)[1];
1435 var content
= this
.innerText || this
.innerHTML
;
1437 if (pmsfh_here
= obj
.IMPPLAN_items
[item
].PMSFH_link
.match(/(.*)\
_(.*)/)) {
1438 //we are going to change how this appears in PMH too.
1439 var pmsfh_zone
= pmsfh_here
[1];
1440 var pmsfh_item
= pmsfh_here
[2];
1441 obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].title
= content
;
1442 alter_issue2(obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].issue
,pmsfh_zone
,pmsfh_item
);
1445 obj
.IMPPLAN_items
[item
].title
= content
;
1446 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1447 //$(this).css('background-color','#F0F8FF');
1450 $
('[id^=CODE_]').on('blur', function() {
1451 var item
= this
.id
.match(/CODE_(.*)/)[1];
1452 var new_code
= this
.innerText || this
.innerHTML
;
1453 obj
.IMPPLAN_items
[item
].code
= new_code
;
1454 //obj.IMPPLAN_items[item].codetext = '';
1455 //obj.IMPPLAN_items[item].codedesc = '';
1456 $
(this
).css('background-color','#F0F8FF');
1457 store_IMPPLAN(obj
.IMPPLAN_items
);
1460 $
('[id^=PLAN_]').on('change', function() {
1461 var item
= this
.id
.match(/PLAN_(.*)/)[1];
1462 obj
.IMPPLAN_items
[item
].plan
= $
(this
).val();
1463 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1464 $
(this
).css('background-color','#F0F8FF');
1467 $
('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e
){
1468 //$(this).css('height', 'auto' );
1469 // $(this).height( this.scrollHeight );
1471 $
('#IMPPLAN_zone').find( 'textarea' ).keyup();
1472 obj
.IMPPLAN_items
= items
;
1478 * This functions updates a PMSFH item's code on the server via its issue number
1480 function update_PMSFH_code(the_issue
,new_code
){
1481 var url
= "../../forms/eye_mag/save.php?mode=update";
1482 top
.restoreSession();
1487 action
: 'code_PMSFH',
1488 pid
: $
('#pid').val(),
1489 form_id
: $
('#form_id').val(),
1490 encounter
: $
('#encounter').val(),
1491 uniqueID
: $
('#uniqueID').val(),
1495 }).done(function(result
) {
1496 if (result
== 'Code 400') {
1497 code_400(); //the user does not have write privileges!
1505 * This function sends the obj.IMPPLAN_items to the server for storage
1507 function store_IMPPLAN(storage
,nodisplay
) {
1508 if (typeof storage
!== "undefined") {
1509 var url
= "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1510 var formData
= JSON
.stringify(storage
);
1511 top
.restoreSession();
1517 parameter
: formData
,
1518 action
: 'store_IMPPLAN',
1519 pid
: $
('#pid').val(),
1520 form_id
: $
('#form_id').val(),
1521 encounter
: $
('#encounter').val(),
1522 uniqueID
: $
('#uniqueID').val()
1524 }).done(function(result
) {
1525 if (result
== "Code 400") {
1526 code_400(); //the user does not have write privileges!
1529 obj
.IMPPLAN_items
= result
;
1530 // if (typeof nodisplay === "undefined") {
1531 build_IMPPLAN(obj
.IMPPLAN_items
,nodisplay
);
1539 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1542 function CODING_to_feesheet(CODING_items
) {
1543 if (typeof CODING_items
!== "undefined") {
1544 var url
= "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1545 var formData
= JSON
.stringify(CODING_items
);
1546 top
.restoreSession();
1551 'parameter' : formData
,
1552 'action' : 'code_visit',
1553 'pid' : $
('#pid').val(),
1554 'form_id' : $
('#form_id').val(),
1555 'encounter' : $
('#encounter').val(),
1556 'uniqueID' : $
('#uniqueID').val()
1558 }).done(function(result
) {
1559 if (result
== "Code 400") {
1560 code_400(); //the user does not have write privileges!
1563 //$("#goto_fee_sheet").prop('disabled', false);
1564 $
("#goto_fee_sheet").removeClass('nodisplay');
1572 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1573 * This item is appended to the $('#IMPPLAN_zone').
1575 function dragto_IMPPLAN_zone(event
, ui
) {
1576 var findme
= ui
.draggable
.find("span").attr("id");
1577 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1578 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1580 var the_codedesc
='';
1581 var the_codetext
='';
1583 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
1584 if (group
=="Clinical") {
1585 //more than one field can contain this DX.
1586 //Group them into one IMPPLAN.
1587 for (i
=0;i
< obj
.Clinical
[location
].length
; i++
) {
1588 the_code +
= obj
.Clinical
[location
][i
]['code']+
',';
1589 the_codedesc
= obj
.Clinical
[location
][i
]['codedesc'];
1590 the_codetext
= obj
.Clinical
[location
][i
]['codetext'];
1591 the_plan +
= obj
.Clinical
[location
][i
]['codedesc'] +
"\r";
1593 if (i
> 0) the_code
= the_code
.slice(0, -1);
1594 obj
.IMPPLAN_items
.push({
1596 codedesc
: the_codedesc
,
1597 codetext
: the_codetext
,
1598 codetype
: obj
.Clinical
[location
][0]['codetype'],
1600 PMSFH_link
: obj
.Clinical
[location
][0]['PMSFH_link'],
1601 title
: obj
.Clinical
[location
][0]['title']
1605 obj
.IMPPLAN_items
.push({
1606 code
: obj
.PMSFH
[group
][location
]['code'],
1607 codedesc
: obj
.PMSFH
[group
][location
]['codedesc'],
1608 codetext
: obj
.PMSFH
[group
][location
]['codetext'],
1609 codetype
: obj
.PMSFH
[group
][location
]['codetype'],
1610 plan
: obj
.PMSFH
[group
][location
]['comments'],
1611 PMSFH_link
: obj
.PMSFH
[group
][location
]['PMSFH_link'],
1612 title
: obj
.PMSFH
[group
][location
]['title']
1616 store_IMPPLAN(obj
.IMPPLAN_items
); //redisplay the items
1619 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field (#IMP) <-- New Dx textarea
1620 * The data is appended to the end of the text.
1621 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1623 function dragto_IMPPLAN(event
, ui
) {
1624 var findme
= ui
.draggable
.find("span").attr("id");
1625 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1626 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1627 var draggable2
= ui
.draggable
;
1628 if (group
=="Clinical") {
1629 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n");
1631 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n"+obj
.PMSFH
[group
][location
]['comments']);
1634 /* END Functions related to IMPPLAN Builder */
1636 function Suggest_visit_code() {
1637 //assume Eyes and established patient
1638 (Code_group
!= 'Eyes') ?
(digit_2
= '9') : digit_2
= '2'; //920XX or 990XX
1639 (Code_new_est
== 'New') ?
(digit_4
= '0') : digit_4
= '1'; //9X01X or 9X00X
1640 if (detail_reached_exam
=='1' && (detail_reached_HPI
=='1')) {
1641 (Code_group
=='Eyes') ?
(digit_5
= '4') : (digit_5
='3'); //920X4 or 990X3
1642 detailed
= "comprehensive";
1644 digit_5
= '2'; //920X2
1645 detailed
= "intermediate";
1647 visit_desc
= Code_new_est +
" "+ detailed +
" "+digit_5
;
1648 visit_code
= "9"+digit_2+
"0"+digit_4+digit_5
;
1649 $
('#visit_codes').val("CPT4|"+visit_code+
"|").change();
1652 * This function builds the codes and populates the billing table for this encounter.
1654 function build_CODING_list() {
1656 /* the following things get billed:
1657 1. Visit code(s) including neurosensory if performed
1661 //3. Diagnostic Codes
1662 $
.each(obj
.IMPPLAN_items
, function( index
, value
) {
1663 if (value
['codetype']) {
1664 if (value
['code'].match(/\
,/g
)) {
1665 // physical finding found in more than one location, more than one code...
1666 // if there is a comma in there, there is more than one code present. Split them out.
1667 // And all those in one group have the same link out (PMSFH_link) value
1668 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1669 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1671 code
: obj
.Clinical
[location
][i
]['code'],
1672 codedesc
: obj
.Clinical
[location
][i
]['codedesc'],
1673 codetext
: obj
.Clinical
[location
][i
]['codetext'],
1674 codetype
: obj
.Clinical
[location
][i
]['codetype'],
1675 title
: obj
.Clinical
[location
][i
]['title']
1678 } else if (value
['code'].match(/Code
/)){
1682 code
: value
['code'],
1683 codedesc
: value
['codedesc'],
1684 codetext
: value
['codetext'],
1685 codetype
: value
['codetype'],
1686 title
: value
['title']
1692 //1. Visit Codes. These can have a modifier (22,24,25,57 hard coded so far)
1693 var visit_justify
= visit_justifier
.join(":");
1694 if (typeof visit_modifier
!= "object") {
1695 visit_modifiers
= [];
1697 visit_modifiers
= visit_modifier
.join(":");//
1701 codedesc
: visit_desc
,
1704 title
: 'Visit Code',
1705 modifier
: visit_modifiers
,
1706 justify
: visit_justify
1709 if (CPT_92060
== 'here') {
1712 codedesc
: 'Sensorimotor exam',
1713 codetext
: 'Sensorimotor exam (CPT4:92060)',
1715 title
: 'Neuro/Sensorimotor Code',
1716 justify
: visit_justify
1719 //2. Tests/procedures performed to bill
1720 $
('.TESTS').each(function(i
, obj
) {
1721 if ($
(this
).is(':checked')) {
1722 var codetype
= obj
.value
.match(/(.*):(.*)/)[1];
1723 var code
= obj
.value
.match(/(.*):(.*)/)[2];
1724 var modifier
= $
('#'+obj
.id+
'_modifier').val();
1726 $
('[name="TEST_'+i+
'_justifiers"]').each(function(j
,obj2
) {
1727 if ($
('#TEST_'+i+
'_just_'+j
).hasClass('status_on') ) {
1728 var h
= $
(this
).data();
1729 justify
= h
.justcode
;
1732 var d
= $
(this
).data();
1735 'codedesc' : d
.title
,
1736 'codetext' : d
.codetext
,
1737 'codetype' : codetype
,
1739 'modifier' : modifier
,
1747 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1749 function toggle_active_flags(new_state
) {
1750 if (($
("#chart_status").val() == "off") ||
(new_state
== "on")) {
1751 // we are read-only and we want to go active.
1752 $
("#chart_status").val("on");
1753 $
("#active_flag").html(" Active Chart ");
1754 $
("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1755 $
("#warning").addClass("nodisplay");
1756 $
('input, select, textarea, a').removeAttr('disabled');
1757 $
('input, textarea').removeAttr('readonly');
1759 //else clicking this means we want to go from active to read-only
1760 $
("#chart_status").val("off");
1761 $
("#active_flag").html(" READ-ONLY ");
1762 $
("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1763 $
("#warning").removeClass("nodisplay");
1764 //we should tell the form fields to be disabled. should already be...
1765 $
('input, select, textarea, a').attr('disabled', 'disabled');
1766 $
('input, textarea').attr('readonly', 'readonly');
1767 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1768 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1769 this_form_id
= $
("#form_id").val();
1770 $
("#COPY_SECTION").val("READONLY-"+this_form_id
);
1774 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1776 function update_READONLY() {
1778 'action' : 'retrieve',
1779 'copy' : 'READONLY',
1780 'zone' : 'READONLY',
1781 'copy_to' : $
("#form_id").val(),
1782 'copy_from' : $
("#form_id").val(),
1783 'pid' : $
("#pid").val()
1785 //we are going to update the whole form
1786 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1787 //We are not ready to actively chart, just looking to see how far along our staff is...
1788 //or maybe just looking ahead to see the who's being worked up in the next room?
1789 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1790 // yet it is updating every 10-15 seconds if another user is making changes.
1791 top
.restoreSession();
1795 url
: "../../forms/eye_mag/save.php?copy=READONLY",
1797 success
: function(result
) {
1798 $
.map(result
, function(valhere
, keyhere
) {
1799 if ($
("#"+keyhere
).val() != valhere
) {
1800 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
1802 if (keyhere
.match(/MOTILITY_
/)) {
1803 // Copy forward ductions and versions visually
1804 // Make each blank, and rebuild them
1805 $
("[name='"+keyhere+
"_1']").html('');
1806 $
("[name='"+keyhere+
"_2']").html('');
1807 $
("[name='"+keyhere+
"_3']").html('');
1808 $
("[name='"+keyhere+
"_4']").html('');
1809 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
1810 // Show a horizontal (minus) tag.
1811 hash_tag
= '<i class="fa fa-minus"></i>';
1812 } else { //show vertical tag
1813 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
1815 for (index
=1; index
<= valhere
; ++index
) {
1816 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
1818 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
1819 if (valhere
=='1') {
1820 $
("#FieldsNormal").prop('checked', false);
1821 $
("#"+keyhere
).prop('checked', true);
1822 $
("#"+keyhere
).val('1');
1824 $
("#"+keyhere
).val('0');
1825 $
("#"+keyhere
).prop('checked', false);
1827 } else if (keyhere
.match(/AMSLERO(.)/)) {
1828 var sidehere
= keyhere
.match(/AMSLERO(.)/);
1829 if (valhere
< '1') valhere
='0';
1830 $
("#"+keyhere
).val(valhere
);
1831 var srcvalue
="AmslerO"+sidehere
[1];
1832 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
1833 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
1834 } else if (keyhere
.match(/VA$
/)) {
1835 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
1836 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
1837 } else if (keyhere
.match(/^O
.VA_
/)) {
1838 var side
=keyhere
.match(/(O
.)VA_(.)/)[1];
1839 var rx_number
=keyhere
.match(/(O
.)VA_(.)/)[2];
1840 if (rx_number
== '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1841 $
('#'+side+
'VA_1_copy').val(valhere
).css("background-color","#F0F8FF");;
1842 $
('#'+side+
'VA_1_copy_brd').val(valhere
).css("background-color","#F0F8FF");;
1844 } else if (keyhere
.match(/^RX_TYPE_\d$
/)) {
1845 if (typeof $
('input:radio[name='+keyhere+
']')[valhere
] !== "undefined") {
1846 $
('input:radio[name='+keyhere+
']')[valhere
].checked
= true;
1848 } else if (keyhere
.match(/(alert|oriented|confused|PUPIL_NORMAL
)/)) {
1849 if (valhere
=='1') {
1850 $
('#'+keyhere
).val(valhere
).prop('checked', true);
1852 $
('#'+keyhere
).val(valhere
).prop('checked', false);
1858 function dopopup(url
) {
1859 window
.open(url
, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1861 function goto_url(url
) {
1863 top
.restoreSession();
1866 //is this used anywhere? Looks like it should be deleted...
1867 function openImage() {
1868 dlgopen(base+
'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1871 // Called to open a document in another tab for this encounter.
1872 function openDocumentNewTab(doc_id
) {
1873 var url
= '../../interface/patient_file/encounter/view_form.php?formname=' + formdir +
'&id=' + formid
;
1874 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
1875 top
.restoreSession();
1876 location
.href
= url
;
1878 parent
.twAddFrameTab('enctabs', formname
, url
);
1883 function HPI_sync_heights() {
1884 if ( ($
('#PMSFH_block_1').height() > $
('#PMH_left').height() ) ||
1885 ($
('#PMSFH_block_2').height() > $
('#PMH_left').height()) )
1887 if ($
('#PMSFH_block_1').height() > $
('#PMSFH_block_2').height()) {
1888 heights
= $
('#PMSFH_block_1').height();
1890 heights
= $
('#PMSFH_block_2').height();
1892 $
('#PMH_left').height(heights
);
1893 $
('#PMH_right').height(heights
)
1894 $
('#PMH_1').height(heights+
20);
1895 } else if ( $
("#PMH_2").hasClass('nodisplay') ) {
1896 $
('#PMH_1').height($
('#HPI_1').height());
1898 $
('#PMH_1').height($
('#PMH_2').height());
1902 * Keyboard shortcut commands.
1904 const shortcut
= new Set();
1906 shortcut
.add("Control+T",function() {
1909 shortcut
.add("Meta+T",function() {
1912 shortcut
.add("Control+D",function() {
1915 shortcut
.add("Meta+D",function() {
1918 shortcut
.add("Control+P",function() {
1919 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1921 shortcut
.add("Meta+P",function() {
1923 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1925 shortcut
.add("Control+B",function() {
1928 shortcut
.add("Meta+B",function() {
1931 shortcut
.add("Control+K",function() {
1934 shortcut
.add("Meta+K",function() {
1939 * this swallows backspace keys on the "rx" elements.
1940 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1942 var rx
= /INPUT|SELECT|TEXTAREA|SPAN|DIV
/i
;
1944 $
(document
).bind("keydown keypress", function(e
){
1945 if( e
.which
== 8 ){ // 8 == backspace
1946 if(!rx
.test(e
.target
.tagName
) || e
.target
.disabled || e
.target
.readOnly
){
1954 * Function to update the PCP and referring person
1957 function update_DOCS() {
1958 var url
= "../../forms/eye_mag/save.php?mode=update";
1959 top
.restoreSession();
1965 pid
: $
('#pid').val(),
1966 pcp
: $
('#form_PCP').val(),
1967 rDOC
: $
('#form_rDOC').val(),
1968 form_id
: $
('#form_id').val(),
1969 encounter
: $
('#encounter').val(),
1970 uniqueID
: $
('#uniqueID').val()
1972 }).done(function(result
) {
1973 if (result
== "Code 400") {
1974 code_400(); //the user does not have write privileges!
1977 obj
= JSON
.parse(result
);
1983 * Function to update the PCP and Referring Doctors data.
1984 * Initial use: update data returned from an ajax call.
1986 function build_DOCS(DOCS
) {
1988 $
("#pcp_name").html(DOCS
['pcp']['name']);
1989 $
("#pcp_address").html(DOCS
['pcp']['address']);
1990 $
("#pcp_phone").html(DOCS
['pcp']['phone']);
1991 $
("#pcp_phonew2").html(DOCS
['pcp']['phone2']);
1992 $
("#pcp_fax").html(DOCS
['pcp']['fax']);
1993 $
("#pcp_fax_info").html(DOCS
['pcp']['fax_info']);
1995 $
("#pcp_name").html('');
1996 $
("#pcp_address").html('');
1997 $
("#pcp_phone").html('');
1998 $
("#pcp_phonew2").html('');
1999 $
("#pcp_fax").html('');
2000 $
("#pcp_fax_info").html('');
2003 $
("#ref_name").html(DOCS
['ref']['name']);
2004 $
("#ref_address").html(DOCS
['ref']['address']);
2005 $
("#ref_phone").html(DOCS
['ref']['phone']);
2006 $
("#ref_phonew2").html(DOCS
['ref']['phonew2']);
2007 $
("#ref_fax").html(DOCS
['ref']['fax']);
2008 $
("#ref_fax_info").html(DOCS
['ref']['fax_info']);
2010 $
("#ref_name").html('');
2011 $
("#ref_address").html('');
2012 $
("#ref_phone").html('');
2013 $
("#ref_phonew2").html('');
2014 $
("#ref_fax").html('');
2015 $
("#ref_fax_info").html('');
2020 * Function to update the patient's current pharmacy
2023 function update_Pharma() {
2024 //$(#form_pharmacy_id) has changed value, update the patient_data field pharmacy_id
2025 var pharm
= $
("#form_pharmacy_id").val();
2026 var url
= "../../forms/eye_mag/save.php?mode=update";
2027 top
.restoreSession();
2032 action
: 'new_pharmacy',
2033 pid
: $
('#pid').val(),
2034 form_id
: $
('#form_id').val(),
2035 encounter
: $
('#encounter').val(),
2036 uniqueID
: $
('#uniqueID').val(),
2037 pc_eid
: $
("#pc_eid").val(),
2038 visit_date
: $
("#visit_date").val(),
2039 new_pharmacy
: pharm
2041 }).done(function(result
) {
2042 if (result
== "Code 400") {
2043 code_400(); //the user does not have write privileges!
2051 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
2054 function reverse_cylinder(target
) {
2055 //target can be revW1-5,AR,MR,CR,CTL,
2058 if (target
.match(/^
(AR|MR|CR|CTL
)$
/)) {
2062 if (target
.match(/^revW
[1-5]{1}$
/)) { //matches on digit only, here 1-5
2063 target
= target
.replace("revW","");
2065 suffix
= '_'+target
;
2067 var Rsph
= $
('#'+prefix+
'ODSPH'+suffix
).val();
2068 var Rcyl
= $
('#'+prefix+
'ODCYL'+suffix
).val();
2069 var Raxis
= $
('#'+prefix+
'ODAXIS'+suffix
).val();
2070 var Lsph
= $
('#'+prefix+
'OSSPH'+suffix
).val();
2071 var Lcyl
= $
('#'+prefix+
'OSCYL'+suffix
).val();
2072 var Laxis
= $
('#'+prefix+
'OSAXIS'+suffix
).val();
2073 if (Rsph
=='' && Rcyl
=='' && Lsph
=='' && lcyl
=='') return;
2074 if ((!Rcyl
.match(/SPH
/i
)) && (Rcyl
>'')) {
2075 if (Rsph
.match(/plano
/i
)) Rsph
='0';
2076 Rsph
= Number(Rsph
);
2077 Rcyl
= Number(Rcyl
);
2078 Rnewsph
= Rsph + Rcyl
;
2079 if (Rnewsph
==0) Rnewsph
="PLANO";
2080 Rnewcyl
= Rcyl
* -1;
2081 if (Rnewcyl
> 0) Rnewcyl
= "+"+Rnewcyl
;
2082 if (parseInt(Raxis
) < 90) {
2083 Rnewaxis
= parseInt(Raxis
) +
90;
2085 Rnewaxis
= parseInt(Raxis
) - 90;
2087 if (Rnewcyl
=='0') Rnewcyl
= "SPH";
2088 if (Rnewsph
=='0') {
2090 if (Rnewcyl
=="SPH") Rnewcyl
= '';
2092 $
('#'+prefix+
'ODSPH'+suffix
).val(Rnewsph
);
2093 $
('#'+prefix+
'ODCYL'+suffix
).val(Rnewcyl
);
2094 $
('#'+prefix+
'ODAXIS'+suffix
).val(Rnewaxis
);
2095 $
('#'+prefix+
'ODAXIS'+suffix
).trigger('blur');
2096 $
('#'+prefix+
'ODSPH'+suffix
).trigger('blur');
2097 $
('#'+prefix+
'ODCYL'+suffix
).trigger('blur');
2099 if ((!Lcyl
.match(/SPH
/i
)) && (Lcyl
>'')) {
2100 if (!Lsph
.match(/\d
/)) Lsph
='0';
2101 Lsph
= Number(Lsph
);
2102 Lcyl
= Number(Lcyl
);
2103 Lnewsph
= Lsph + Lcyl
;
2104 Lnewcyl
= Lcyl
* -1;
2105 if (Lnewcyl
> 0) Lnewcyl
= "+"+ Lnewcyl
;
2106 if (parseInt(Laxis
) < 90) {
2107 Lnewaxis
= parseInt(Laxis
) +
90;
2109 Lnewaxis
= parseInt(Laxis
) - 90;
2112 if (Lnewcyl
=='0') Lnewcyl
= "SPH";
2113 if (Lnewsph
=='0') {
2115 if (Lnewcyl
=="SPH") Lnewcyl
= '';
2118 $
('#'+prefix+
'OSSPH'+suffix
).val(Lnewsph
);
2119 $
('#'+prefix+
'OSCYL'+suffix
).val(Lnewcyl
);
2120 $
('#'+prefix+
'OSAXIS'+suffix
).val(Lnewaxis
);
2121 $
('#'+prefix+
'OSAXIS'+suffix
).trigger('blur');
2122 $
('#'+prefix+
'OSSPH'+suffix
).trigger('blur');
2123 $
('#'+prefix+
'OSCYL'+suffix
).trigger('blur');
2126 function scrollTo(target
) {
2128 var scrollSpeed
= 500;
2129 var wheight
= $
(window
).height();
2130 offset
= $
("#"+target
).offset().top
- (wheight
/ 2)+
200;
2131 if (offset
> (window
.pageYOffset +
150)||offset
< (window
.pageYOffset
-150)) {
2132 $
('html, body').animate({scrollTop
:offset
}, scrollSpeed
);
2136 function update_appt_status(new_status
) {
2137 var url
= "../../forms/eye_mag/save.php?mode=update";
2138 top
.restoreSession();
2143 action
: 'new_appt_status',
2144 pid
: $
('#pid').val(),
2145 form_id
: $
('#form_id').val(),
2146 encounter
: $
('#encounter').val(),
2147 uniqueID
: $
('#uniqueID').val(),
2148 pc_eid
: $
("#pc_eid").val(),
2149 visit_date
: $
("#visit_date").val(),
2150 new_status
: new_status
2152 }).done(function(result
) {
2153 if (result
== "Code 400") {
2154 code_400(); //the user does not have write privileges!
2159 function color_IOP(IOP
){
2160 if (!$
.isNumeric(IOP
.value
)) return;
2161 if (IOP
.value
> '21') {
2162 $
(IOP
).css("background-color","rgb(255, 153, 153)");
2165 function showpnotes(docid
) {
2166 let btnClose
= 'Done';
2167 let url
= base+
'/interface/patient_file/summary/pnotes.php?docid=' +
encodeURIComponent(docid
);
2168 dlgopen(url
, 'pno1', 'modal-xl', 500, '', '', {
2170 {text
: btnClose
, close
: true, style
: 'default btn-sm'}
2180 function getTimeStamp() {
2181 var now
= new Date();
2182 var AMPM
= now
.getHours() >= 12 ?
'PM' : 'AM';
2183 return now
.getHours() +
':' +
((now
.getMinutes() < 10) ?
("0" + now
.getMinutes()) : (now
.getMinutes())) + AMPM
;
2187 * This function is only run onload to hide sections per user preference.
2188 * Any changes during the encounter to display or hide a section are stored
2189 * as a previous setting and the next eye form opened will appear the same way.
2191 function show_by_setting() {
2192 var tabs_left
= $
("#setting_tabs_left").val();
2193 if (typeof tabs_left
==undefined
) exit;
2194 var arrSet
= ["HPI","PMH","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2195 sLen
= arrSet
.length
;
2196 for (i
= 0; i
< sLen
; i++
) {
2197 var value
= $
("#setting_"+arrSet
[i
]).val();
2198 if (typeof value
!== undefined
&& value
!='1') {
2199 $
('#tabs-left-'+arrSet
[i
]).addClass('ui-state-default');
2200 $
("#setting_"+arrSet
[i
]).val('0');
2201 $
("#"+arrSet
[i
]+
'_1').addClass('nodisplay');
2202 $
("#setting_"+arrSet
[i
]).val('0');
2204 $
("#setting_"+arrSet
[i
]).val('1');
2207 if (tabs_left
== '0') {
2208 $
("#tabs_left").addClass('nodisplay');
2210 $
("#tabs_left").removeClass('nodisplay');
2219 var allPanels
= $
('.building_blocks > dd').hide();
2220 var allPanels2
= $
('.building_blocks2 > dd').hide();
2223 // AUTO- CODING FEATURES
2225 check_exam_detail();
2228 //alert('Suggest a Code');
2229 Suggest_visit_code();
2230 show_QP_section('IMPPLAN','1');
2233 //on checking TESTS, show modifiers and justifier fields
2234 $
(".TESTS").on("click", function() {
2235 var test_id
= this
.id
;
2236 if ($
(this
).is(':checked')) {
2237 $
("#"+test_id+
"_justmods").removeClass('nodisplay');
2238 $
("#"+test_id+
"_modifier").val('59');
2239 //make vist_modifier 25 light up too...
2240 $
(this
).parent().removeClass('lights_off').addClass('lights_on');
2242 $
("#"+test_id+
"_justmods").addClass('nodisplay');
2243 $
(this
).parent().removeClass('lights_on').addClass('lights_off');
2247 $
('[title]').tooltip();
2248 $
('#form_PCP,#form_rDOC').on('change', function() {
2252 $
("#form_pharmacy_id").change(function() {
2256 $
('#tooltips_status').html($
('#PREFS_TOOLTIPS').val());
2257 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
2258 $
('[title]').each(function() {
2259 var $this = $
(this
);
2260 $this.data('title',$this.attr('title'));
2261 $this.attr('title', '');
2264 $
('#tooltips_toggle,#tooltips_status').on('click', function() {
2265 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
2266 $
('#PREFS_TOOLTIPS').val('<?php echo xla('Off
'); ?>');
2267 $
("#tooltips_status").html('<?php echo xla('are off
'); ?>');
2268 $
('[title]').each(function() {
2269 var $this = $
(this
);
2270 $this.data('title',$this.attr('title'));
2271 $this.attr('title', '');
2274 $
('#PREFS_TOOLTIPS').val('<?php echo xla('On
'); ?>');
2275 $
('#tooltips_status').html('<?php echo xla('are on
'); ?>');
2276 $
('[title]').each(function() {
2277 var $this = $
(this
);
2278 $this.attr('title', $this.data('title'));
2283 $
('#toggle_drugs').on('click', function(){
2284 $
('.hideme_drugs').toggleClass('nodisplay');
2285 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2288 $
('#toggle_VFs').on('click', function(){
2289 $
('.hideme_VFs').toggleClass('nodisplay');
2290 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2293 $
('#toggle_OCTs').on('click', function(){
2294 $
('.hideme_OCTs').toggleClass('nodisplay');
2295 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2298 $
('#toggle_cups').on('click', function(){
2299 $
('.hideme_cups').toggleClass('nodisplay');
2300 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2303 $
('#toggle_gonios').on('click', function(){
2304 $
('.hideme_gonios').toggleClass('nodisplay');
2305 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2308 $
('.close').on('click', function(){
2309 $
('#GFS_accordion .hide').slideUp();
2311 $
('#ODIOPTARGET').on('change', function() {
2312 $
('#OSIOPTARGET').val($
('#ODIOPTARGET').val());
2315 $
('#ODIOPAP,#OSIOPAP,#ODIOPTARGET,#ODIOPTPN,#OSIOPTPN,#OSIOPTARGET').on('change', function() {
2316 //this is failing if there is no config_by_day variable.
2319 if ($
("#PREFS_KB").val() =='1') {
2320 $
(".kb").removeClass('nodisplay');
2321 $
(".kb_off").addClass('nodisplay');
2323 $
(".kb").addClass('nodisplay');
2324 $
(".kb_off").removeClass('nodisplay');
2327 $
("[name$='_kb']").on('click', function() {
2328 $
('.kb').toggleClass('nodisplay');
2329 $
('.kb_off').toggleClass('nodisplay');
2330 $
('.copier').toggleClass('nodisplay');
2331 if ($
('#PREFS_EXAM').val() == 'DRAW') {
2335 if ($
("#PREFS_KB").val() > 0) {
2336 $
("#PREFS_KB").val('0');
2338 $
("#PREFS_KB").val('1');
2342 $
('.ke').on('mouseover', function() {
2343 $
(this
).toggleClass('yellow');
2345 $
('.ke').on('mouseout', function() {
2346 $
(this
).toggleClass('yellow');
2348 $
("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e
) {
2349 //this is the Shorthand engine's ignition
2350 if (e
.which
== 13|| e
.keyCode
== 13||e
.which
== 9|| e
.keyCode
== 9) {
2352 var data_all
= $
(this
).val();
2353 var data_seg
= data_all
.match(/([^
;]*)/gm
);
2357 for (index
=0; index
< data_seg
.length
; ++index
) {
2358 if (data_seg
[index
] =='') continue;
2359 data_seg
[index
] = data_seg
[index
].replace(/^
[\n\v\f\r\x85\u2028\u2029\W
]*/
,'');
2360 data_seg
[index
] = data_seg
[index
].replace(/^
[\s
]*/
,'');
2361 if (data_seg
[index
].match(/^
D($|
;)/i
)) {
2362 $
("#EXT_defaults").trigger("click");
2363 $
("#ANTSEG_defaults").trigger("click");
2364 $
("#RETINA_defaults").trigger("click");
2365 $
("#NEURO_defaults").trigger("click");
2368 if (data_seg
[index
].match(/^
DEXT($|
;)/i
)) {
2369 $
("#EXT_defaults").trigger("click");
2372 if (data_seg
[index
].match(/^
DANTSEG($|
;)/i
)) {
2373 $
("#ANTSEG_defaults").trigger("click");
2376 if (data_seg
[index
].match(/^
DAS($|
;)/i
)) {
2377 $
("#ANTSEG_defaults").trigger("click");
2380 if (data_seg
[index
].match(/^
DRETINA($|
;)/i
)) {
2381 $
("#RETINA_defaults").trigger("click");
2384 if (data_seg
[index
].match(/^
DRET($|
;)/i
)) {
2385 $
("#RETINA_defaults").trigger("click");
2388 if (data_seg
[index
].match(/^
DNEURO($|
;)/i
)) {
2389 $
("#NEURO_defaults").trigger("click");
2392 if ((data_seg
[index
].match(/^
CLEAREXT($|
;)/i
))||
2393 (data_seg
[index
].match(/^
CEXT($|
;)/i
))) {
2397 if ((data_seg
[index
].match(/^
CLEARAS($|
;)/i
))||
2398 (data_seg
[index
].match(/^
CLEARANTSEG($|
;)/i
))||
2399 (data_seg
[index
].match(/^
CANTSEG($|
;)/i
))||
2400 (data_seg
[index
].match(/^
CANT($|
;)/i
))||
2401 (data_seg
[index
].match(/^
CAS($|
;)/i
))) {
2402 $
(".ANTSEG").val('');
2405 if ((data_seg
[index
].match(/^
CLEARRET($|
;)/i
))||
2406 (data_seg
[index
].match(/^
CRET($|
;)/i
)) ||
2407 (data_seg
[index
].match(/^
CLEARRETINA($|
;)/i
))||
2408 (data_seg
[index
].match(/^
CRETINA($|
;)/i
))) {
2409 $
(".RETINA").val('');
2414 var data
= data_seg
[index
].match(/^
(\w
*)\
:?
(.*)/);
2415 (data
[2].match(/\
.a$
/))?
(data
[2] = data
[2].replace(/\
.a$
/,'')):(appendix
= "nope");
2416 var field
= data
[1].toUpperCase();
2418 text
= expand_vocab(text
);
2419 priors
= process_kb(field
,text
,appendix
,prior_field
,prior_text
);
2420 prior_field
= priors
['field'];
2421 prior_text
= priors
['prior_text'];
2429 $
("[id^='sketch_tools_']").click(function() {
2430 var zone
= this
.id
.match(/sketch_tools_(.*)_
/)[1];
2431 $
("[id^='sketch_tools_"+zone+
"']").css("height","30px");
2432 $
(this
).css("height","50px");
2433 $
("#sketch_tool_"+zone+
"_color").css("background-image","").css("background-color",$
("#selColor_"+zone
).val());
2435 $
("[id^='sketch_sizes_']").click(function() {
2436 var zone
= this
.id
.match(/sketch_sizes_(.*)_
/)[1];
2437 $
("[id^='sketch_sizes_"+zone+
"']").css("background","").css("border-bottom","");
2438 $
(this
).css("border-bottom","2pt solid black");
2442 // Here we get CC1 to show
2443 $
(".tab_content").addClass('nodisplay');
2444 $
("#tab1_CC_text").removeClass('nodisplay');
2445 $
("#tab1_HPI_text").removeClass('nodisplay');
2446 $
("[id$='_CC'],[id$='_HPI_tab']").on('click', function() {
2447 // First remove class "active" from currently active tabs
2448 $
("[id$='_CC']").removeClass('active');
2449 $
("[id$='_HPI_tab']").removeClass('active');
2450 // Hide all tab content
2451 $
(".tab_content").addClass('nodisplay');
2452 // Here we get the href value of the selected tab
2453 var selected_tab
= $
(this
).find("a").attr("href");
2454 // Now add class "active" to the selected/clicked tab and content
2455 $
(selected_tab+
"_CC").addClass('active');
2456 $
(selected_tab+
"_CC_text").removeClass('nodisplay');
2457 $
(selected_tab+
"_HPI_tab").addClass('active');
2458 $
(selected_tab+
"_HPI_text").removeClass('nodisplay');
2459 // At the end, we add return false so that the click on the link is not executed
2462 $
("input,textarea,text").css("background-color","#FFF8DC");
2463 $
("[id*=ODIOP],[id*=OSIOP]").each(function() { color_IOP(this
); });
2464 $
("#IOPTIME").css("background-color","#FFFFFF");
2465 $
("#refraction_width").css("width","8.5in");
2466 $
(".Draw_class").addClass('nodisplay');
2467 $
(".PRIORS_class").addClass('nodisplay');
2468 $
(window
).on("resize", function() {
2469 if (window
.innerWidth
>'900') {
2470 $
("#refraction_width").css("width","900px");
2471 $
("#LayerVision2").css("padding","4px");
2473 if (window
.innerWidth
>'1300') {
2474 $
("#refraction_width").css("width","1300px");
2475 //$("#first").css("width","1300px");
2477 if (window
.innerWidth
>'1900') {
2478 $
("#refraction_width").css("width","1600px");
2484 var hash_tag
= '<i class="fa fa-minus"></i>';
2486 // display any stored MOTILITY values
2487 $
("#MOTILITY_RS").value
= parseInt($
("#MOTILITY_RS").val());
2488 if ($
("#MOTILITY_RS").val() > '0') {
2489 $
("#MOTILITYNORMAL").removeAttr('checked');
2490 for (index
=1; index
<= ($
("#MOTILITY_RS").val()); ++index
) {
2491 $
("#MOTILITY_RS_"+index
).html(hash_tag
);
2494 $
("#MOTILITY_RI").value
= parseInt($
("#MOTILITY_RI").val());
2495 if ($
("#MOTILITY_RI").val() > '0') {
2496 $
("#MOTILITYNORMAL").removeAttr('checked');
2497 for (index
=1; index
<= ($
("#MOTILITY_RI").val()); ++index
) {
2498 $
("#MOTILITY_RI_"+index
).html(hash_tag
);
2501 $
("#MOTILITY_LS").value
= parseInt($
("#MOTILITY_LS").val());
2502 if ($
("#MOTILITY_LS").val() > '0') {
2503 $
("#MOTILITYNORMAL").removeAttr('checked');
2504 for (index
=1; index
<= ($
("#MOTILITY_LS").val()); ++index
) {
2505 $
("#MOTILITY_LS_"+index
).html(hash_tag
);
2508 $
("#MOTILITY_LI").value
= parseInt($
("#MOTILITY_LI").val());
2509 if ($
("#MOTILITY_LI").val() > '0') {
2510 $
("#MOTILITYNORMAL").removeAttr('checked');
2511 for (index
=1; index
<= ($
("#MOTILITY_LI").val()); ++index
) {
2512 $
("#MOTILITY_LI_"+index
).html(hash_tag
);
2516 $
("#MOTILITY_RRSO").value
= parseInt($
("#MOTILITY_RRSO").val());
2517 if ($
("#MOTILITY_RRSO").val() > '0') {
2518 $
("#MOTILITYNORMAL").removeAttr('checked');
2519 for (index
=1; index
<= ($
("#MOTILITY_RRSO").val()); ++index
) {
2520 $
("#MOTILITY_RRSO_"+index
).html(hash_tag
);
2523 $
("#MOTILITY_RRIO").value
= parseInt($
("#MOTILITY_RRIO").val());
2524 if ($
("#MOTILITY_RRIO").val() > '0') {
2525 $
("#MOTILITYNORMAL").removeAttr('checked');
2526 for (index
=1; index
<= ($
("#MOTILITY_RRIO").val()); ++index
) {
2527 $
("#MOTILITY_RRIO_"+index
).html(hash_tag
);
2530 $
("#MOTILITY_RLIO").value
= parseInt($
("#MOTILITY_RLIO").val());
2531 if ($
("#MOTILITY_RLIO").val() > '0') {
2532 $
("#MOTILITYNORMAL").removeAttr('checked');
2533 for (index
=1; index
<= ($
("#MOTILITY_RLIO").val()); ++index
) {
2534 $
("#MOTILITY_RLIO_"+index
).html(hash_tag
);
2537 $
("#MOTILITY_RLSO").value
= parseInt($
("#MOTILITY_RLSO").val());
2538 if ($
("#MOTILITY_RLSO").val() > '0') {
2539 $
("#MOTILITYNORMAL").removeAttr('checked');
2540 for (index
=1; index
<= ($
("#MOTILITY_RLSO").val()); ++index
) {
2541 $
("#MOTILITY_RLSO_"+index
).html(hash_tag
);
2544 $
("#MOTILITY_LRSO").value
= parseInt($
("#MOTILITY_LRSO").val());
2545 if ($
("#MOTILITY_LRSO").val() > '0') {
2546 $
("#MOTILITYNORMAL").removeAttr('checked');
2547 for (index
=1; index
<= ($
("#MOTILITY_LRSO").val()); ++index
) {
2548 $
("#MOTILITY_LRSO_"+index
).html(hash_tag
);
2551 $
("#MOTILITY_LRIO").value
= parseInt($
("#MOTILITY_LRIO").val());
2552 if ($
("#MOTILITY_LRIO").val() > '0') {
2553 $
("#MOTILITYNORMAL").removeAttr('checked');
2554 for (index
=1; index
<= ($
("#MOTILITY_LRIO").val()); ++index
) {
2555 $
("#MOTILITY_LRIO_"+index
).html(hash_tag
);
2558 $
("#MOTILITY_LLSO").value
= parseInt($
("#MOTILITY_LLSO").val());
2559 if ($
("#MOTILITY_LLSO").val() > '0') {
2560 $
("#MOTILITYNORMAL").removeAttr('checked');
2561 for (index
=1; index
<= ($
("#MOTILITY_LLSO").val()); ++index
) {
2562 $
("#MOTILITY_LLSO_"+index
).html(hash_tag
);
2565 $
("#MOTILITY_LLIO").value
= parseInt($
("#MOTILITY_LLIO").val());
2566 if ($
("#MOTILITY_LLIO").val() > '0') {
2567 $
("#MOTILITYNORMAL").removeAttr('checked');
2568 for (index
=1; index
<= ($
("#MOTILITY_LLIO").val()); ++index
) {
2569 $
("#MOTILITY_LLIO_"+index
).html(hash_tag
);
2573 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
2574 $
("#MOTILITY_LR").value
= parseInt($
("#MOTILITY_LR").val());
2575 if ($
("#MOTILITY_LR").val() > '0') {
2576 $
("#MOTILITYNORMAL").removeAttr('checked');
2577 for (index
=1; index
<= ($
("#MOTILITY_LR").val()); ++index
) {
2578 $
("#MOTILITY_LR_"+index
).html(hash_tag
);
2581 $
("#MOTILITY_LL").value
= parseInt($
("#MOTILITY_LL").val());
2582 if ($
("#MOTILITY_LL").val() > '0') {
2583 $
("#MOTILITYNORMAL").removeAttr('checked');
2584 for (index
=1; index
<= ($
("#MOTILITY_LL").val()); ++index
) {
2585 $
("#MOTILITY_LL_"+index
).html(hash_tag
);
2588 $
("#MOTILITY_RR").value
= parseInt($
("#MOTILITY_RR").val());
2589 if ($
("#MOTILITY_RR").val() > '0') {
2590 $
("#MOTILITYNORMAL").removeAttr('checked');
2591 for (index
=1; index
<= ($
("#MOTILITY_RR").val()); ++index
) {
2592 $
("#MOTILITY_RR_"+index
).html(hash_tag
);
2595 $
("#MOTILITY_RL").value
= parseInt($
("#MOTILITY_RL").val());
2596 if ($
("#MOTILITY_RL").val() > '0') {
2597 $
("#MOTILITYNORMAL").removeAttr('checked');
2598 for (index
=1; index
<= ($
("#MOTILITY_RL").val()); ++index
) {
2599 $
("#MOTILITY_RL_"+index
).html(hash_tag
);
2603 $
(".chronic_HPI,.count_HPI").on("blur", function() {
2604 check_exam_detail();
2607 $
("#DIL_RISKS").on('change', function(o
) {
2608 ($
(this
).is(':checked')) ?
($
(".DIL_RISKS").removeClass("nodisplay")) : ($
(".DIL_RISKS").addClass("nodisplay"));
2609 check_exam_detail();
2611 $
(".dil_drug").on('change', function(o
) {
2612 if ($
(this
).is(':checked')) {
2613 $
("#DIL_RISKS").prop("checked","checked");
2614 check_exam_detail();
2615 var timestamp
= getTimeStamp();
2616 $
("#DIL_MEDS").val(timestamp
);
2619 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2620 $
(".neurosens,.neurosens2").on("blur", function() {
2624 // functions to improve flow of refraction input
2625 $
("input[name$='PRISM'],input[class^='prism']").on("blur", function() {
2627 var str
= $
(this
).val();
2628 str
= str
.toUpperCase();
2631 $
('input[class^="sphere"],input[name$="SPH"]').on("blur", function() {
2632 var mid
= $
(this
).val();
2633 if (mid
.match(/PLANO
/i
)) {
2634 $
(this
).val('PLANO');
2637 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2640 if (mid
.match(/\
.[27]$
/)) {
2643 if (mid
.match(/\
.\d$
/)) {
2646 //if near is +2. make it +2.00
2647 if (mid
.match(/\
.$
/)) {
2650 if ((!mid
.match(/\
./))&&(mid
.match(00|
25|
50|
75))) {
2651 var front
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[1];
2652 var back
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[2];
2653 if (front
=='') front
='0';
2654 mid
= front +
"." + back
;
2656 if (!mid
.match(/\
./)) {
2657 var front
= mid
.match(/([\+\
-]?\d
{0,2})(\d
{2})/)[1];
2658 var back
= mid
.match(/(\d
{0,2})(\d
{2})/)[2];
2659 if (front
=='') front
='0';
2660 if (front
=='-') front
='-0';
2661 mid
= front +
"." + back
;
2663 if (!mid
.match(/^
(\+|\
-){1}/)) {
2669 $
("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").on("blur", function() {
2670 var add
= $
(this
).val();
2671 add
= add
.replace(/=/g
,"+");
2672 //if add is one digit, eg. 2, make it +2.00
2673 if (add
.match(/^\d
{1}$
/)) {
2674 add
= "+"+add+
".00";
2676 //if add is '+'one digit, eg. +2, make it +2.00
2677 if (add
.match(/^\+\d
{1}$
/)) {
2680 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2681 if (add
.match(/\
.[05]$
/)) {
2684 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2685 if (add
.match(/\
.[27]$
/)) {
2688 //if add is +2. make it +2.00
2689 if (add
.match(/\
.$
/)) {
2692 if ((!add
.match(/\
./))&&(add
.match(/(0|
25|
50|
75)$
/))) {
2693 var front
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[1];
2694 var back
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[2];
2695 if (front
=='') front
='0';
2696 add
= front +
"." + back
;
2698 if (!add
.match(/^
(\+
)/) && (add
.length
> 0)) {
2702 if (this
.id
=="ODADD_1") $
('#OSADD_1').val(add
);
2703 if (this
.id
=="ODMIDADD_1") $
('#OSMIDADD_1').val(add
);
2704 if (this
.id
=="ODADD_2") $
('#OSADD_2').val(add
);
2705 if (this
.id
=="ODMIDADD_2") $
('#OSMIDADD_2').val(add
);
2706 if (this
.id
=="ODADD_3") $
('#OSADD_3').val(add
);
2707 if (this
.id
=="ODMIDADD_3") $
('#OSMIDADD_3').val(add
);
2708 if (this
.id
=="ODADD_4") $
('#OSADD_4').val(add
);
2709 if (this
.id
=="ODMIDADD_4") $
('#OSMIDADD_4').val(add
);
2710 if (this
.id
=="ODADD_5") $
('#OSADD_5').val(add
);
2711 if (this
.id
=="ODMIDADD_5") $
('#OSMIDADD_5').val(add
);
2712 if (this
.id
=="MRODADD") $
('#MROSADD').val(add
);
2713 if (this
.id
=="ARODADD") $
('#AROSADD').val(add
);
2714 if (this
.id
=="CTLODADD") $
('#CTLOSADD').val(add
);
2717 $
("input[class^='axis'],input[name$='AXIS']").on("blur", function() {
2718 // Make this a 3 digit leading zeros number.
2719 // we are not translating text to numbers, just numbers to
2720 // a 3 digit format with leading zeroes as needed.
2721 // assume the end user KNOWS there are only numbers presented and
2722 // more than 3 digits is a mistake...
2723 // (although this may change with topography)
2724 var axis
= $
(this
).val();
2725 if (this
.name
.match(/K2AXIS
/)) {
2726 var group
= this
.name
.replace("AXIS", "");
2728 var group
= this
.name
.replace("AXIS", "CYL");
2730 var cyl
= $
("#"+group
).val();
2731 if ( (cyl
> '') && (cyl
!= 'SPH') ) {
2732 if (!axis
.match(/\d\d\d
/)) {
2733 if (!axis
.match(/\d\d
/)) {
2734 if (!axis
.match(/\d
/)) {
2744 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2745 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2746 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2750 $
("input[class^='cylinder'],input[name$='CYL']").on("blur", function() {
2751 var mid
= $
(this
).val();
2752 var group
= this
.name
.replace("CYL", "SPH");;
2753 var sphere
= $
("#"+group
).val();
2754 if (((mid
.length
== 0) && (sphere
.length
> 0))||
(mid
.match(/sph
/i
))) {
2756 if (sphere
.match(/plano
/i
)) $
(this
).val('');
2757 var axis
= this
.name
.replace("CYL", "AXIS");
2758 $
("#"+axis
).val('');
2759 submit_form($
(this
));
2761 } else if (sphere
.length
> 0) {
2762 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2765 if (mid
.match(/^
(\d
)(\d
)$
/)) {
2766 mid
= mid
[0] +
'.' +mid
[1];
2769 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2770 if (mid
.match(/\
.[05]$
/)) {
2773 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2774 if (mid
.match(/\
.[27]$
/)) {
2777 //if mid is +2. make it +2.00
2778 if (mid
.match(/\
.$
/)) {
2781 if (mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)) {
2782 var front
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[1];
2783 var back
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[2];
2784 if (front
=='') front
='0';
2785 mid
= front +
"." + back
;
2787 if (!$
('#PREFS_CYL').val()) {
2788 $
('#PREFS_CYL').val('+');
2791 if (!mid
.match(/^
(\+|\
-){1}/) && (sphere
.length
> 0)) {
2792 //no +/- sign at the start of the field.
2793 //ok so there is a preference set
2794 //Since it doesn't start with + or - then give it the preference value
2795 mid
= $
('#PREFS_CYL').val() + mid
;
2796 } else if (mid
.match(/^
(\+|\
-){1}/)) {
2797 pref
= mid
.match(/^
(\+|\
-){1}/)[0];
2798 //so they used a value + or - at the start of the field.
2799 //The only reason to work on this is to change to cylinder preference
2800 if ($
('#PREFS_CYL').val() != pref
){
2801 //and that is what they are doing here
2802 $
('#PREFS_CYL').val(pref
);
2809 //bootstrap menu functions
2810 $
("[class='dropdown-toggle']").hover(function(){
2811 $
("[class='dropdown-toggle']").parent().removeClass('open');
2812 var menuitem
= this
.id
.match(/(.*)/)[1];
2813 //if the menu is active through a prior click, show it
2814 // Have to override Bootstrap then
2815 if ($
("#menustate").val() !="1") { //menu not active -> ignore
2816 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2817 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2818 } else { //menu is active -> respond
2819 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2820 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2821 $
("#"+menuitem
).css("text-decoration","none");
2822 $
("#"+menuitem
).parent().addClass('open');
2825 var menuitem
= this
.id
.match(/(.*)/)[1];
2826 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2827 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2830 $
("[class='dropdown-toggle']").on('click', function() {
2831 $
("#menustate").val('1');
2832 var menuitem
= this
.id
.match(/(.*)/)[1];
2833 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2834 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2835 $
("#"+menuitem
).css("text-decoration","none");
2837 $
("#right-panel-link, #close-panel-bt,#right-panel-link_2").on('click', function() {
2838 if ($
("#PREFS_PANEL_RIGHT").val() =='1') {
2839 $
("#PREFS_PANEL_RIGHT").val('0');
2841 $
("#PREFS_PANEL_RIGHT").val('1');
2845 $
("[name^='menu_']").on('click', function() {
2846 $
("[name^='menu_']").removeClass('active');
2847 var menuitem
= this
.id
.match(/menu_(.*)/)[1];
2848 $
(this
).addClass('active');
2849 $
("#menustate").val('1');
2850 if (menuitem
=='left_tabs') {
2851 var tabs_left
= $
("#setting_tabs_left").val();
2852 if (tabs_left
== '1') {
2853 $
("#tabs_left").addClass('nodisplay');
2854 $
("#setting_tabs_left").val('0');
2856 $
("#tabs_left").removeClass('nodisplay');
2857 $
("#setting_tabs_left").val('1');
2861 $
("#BUTTON_TAB_"+menuitem
).trigger('click');
2862 $
("#tabs-left-"+menuitem
).trigger('click');
2863 menu_select(menuitem
);
2867 // set display functions for Draw panel appearance
2868 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2869 var zones
= ["PMH","HPI","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2870 for (index
= '0'; index
< zones
.length
; ++index
) {
2871 if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='DRAW') {
2872 show_DRAW_section(zones
[index
]);
2873 } else if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='QP') {
2874 show_QP_section(zones
[index
],'1');
2877 $
("body").on("click","[name$='_text_view']" , function() {
2878 var header
= this
.id
.match(/(.*)_text_view$
/)[1];
2879 $
("#"+header+
"_text_list").toggleClass('wide_textarea');
2880 $
("#"+header+
"_text_list").toggleClass('narrow_textarea');
2881 $
(this
).toggleClass('fa-plus-square-o');
2882 $
(this
).toggleClass('fa-minus-square-o');
2883 if (header
!= /PRIOR
/) {
2884 var imagine
= $
("#PREFS_"+header+
"_VIEW").val();
2886 $
("#PREFS_"+header+
"_VIEW").val(imagine
);
2891 $
("body").on("change", "select", function(e
){
2892 if (this
.name
.match(/PRIOR_(.*)/)) {
2893 var new_section
= this
.name
.match(/PRIOR_(.*)/);
2894 var newValue
= this
.value
;
2895 if (new_section
[1] =='') return;
2896 if (new_section
[1].match(/_canvas
/)) {
2897 goto_section
= new_section
[1].match(/_canvas
/)[1];
2898 show_PRIOR_CANVAS_section(goto_section
,newValue
);
2902 if (new_section
[1] == /\_
/){
2905 var newValue
= this
.value
;
2906 if (newValue
== $
("#form_id").val()) {
2907 if (new_section
[1] =="ALL") {
2908 //click updates prefs too
2909 $
('#EXAM_QP').trigger("click");
2912 $
('#BUTTON_QP_'+new_section
[1]).trigger("click").trigger("click");//double click intended RM
2914 $
("#LayerTechnical_sections_1").css("clear","both");
2917 //now go get the prior page via ajax
2918 $
("#PRIORS_"+ new_section
[1] +
"_left_text").removeClass('nodisplay');
2919 $
("#DRAWS_" + new_section
[1] +
"_right").addClass('nodisplay');
2920 $
("#QP_" + new_section
[1]).addClass('nodisplay');
2922 if (new_section
[1] =="ALL") {
2924 show_PRIORS_section("ALL",newValue
);
2925 show_PRIORS_section("EXT",newValue
);
2926 show_PRIORS_section("ANTSEG",newValue
);
2927 show_PRIORS_section("RETINA",newValue
);
2928 show_PRIORS_section("NEURO",newValue
);
2929 show_PRIORS_section("IMPPLAN",newValue
);
2930 scrollTo("EXT_left");
2932 show_PRIORS_section(new_section
[1],newValue
);
2938 $
("body").on("click","[name^='old_canvas']", function() {
2940 //het h.step from SELECT_CANVAS_" . attr($zone) . "
2941 var h
= $
(this
).data();
2942 var target
= h
.target
;
2943 var direction
= h
.direction
;
2944 var select
= document
.getElementById(target
);
2945 var len
= select
.getElementsByTagName('option').length
-1;
2946 var t
= $
("#"+target
).data();
2948 if (direction
=="oldest") {
2950 next
= select
.getElementsByTagName('option')[index
];
2951 if(typeof next
!== undefined
) {
2952 select
.options
[index
].selected
= 'selected';
2954 } else if (direction
=="older") {
2956 next
= select
.getElementsByTagName('option')[index
];
2957 if(typeof next
!== undefined
&& index
<= len
) {
2958 select
.options
[index
].selected
= 'selected';
2962 } else if (direction
=="newer") {
2964 next
= select
.getElementsByTagName('option')[index
];
2965 if (typeof next
!== undefined
&& index
>= 0) {
2966 select
.options
[index
].selected
= 'selected';
2969 select
.options
[index
].selected
= 'selected';
2971 } else if (direction
=="newest") {
2973 next
= select
.getElementsByTagName('option')[index
];
2974 if(typeof next
!== undefined
) {
2975 select
.options
[index
].selected
= 'selected';
2979 $
("#"+target
).trigger('change');
2983 $
("body").on("click","[id^='Close_PRIORS_']", function() {
2984 var new_section
= this
.id
.match(/Close_PRIORS_(.*)$
/)[1];
2985 $
("#PRIORS_"+ new_section +
"_left_text").addClass('nodisplay');
2986 $
("#QP_" + new_section
).removeClass('nodisplay');
2988 $
("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").on("mouseover", function() {
2989 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2991 $
("#pupils,#vision_tab,[name='CTL']").on("mouseout", function() {
2992 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
2994 $
("#pupils").on("click", function(){
2995 if ($
("#dim_pupils_panel").hasClass("nodisplay")) {
2996 $
("#dim_pupils_panel").removeClass('nodisplay');
2998 $
("#dim_pupils_panel").fadeToggle();
3001 $
("#vision_tab").on("click", function(){
3002 $
("#REFRACTION_sections").toggleClass('nodisplay');
3003 ($
("#PREFS_VA").val() =='1') ?
($
("#PREFS_VA").val('0')) : $
("#PREFS_VA").val('1');
3005 //set wearing to single vision or bifocal? Bifocal
3006 $
(".WNEAR").removeClass('nodisplay');
3007 $
("#WNEARODAXIS").addClass('nodisplay');
3008 $
("#WNEARODCYL").addClass('nodisplay');
3009 $
("#WNEARODPRISM").addClass('nodisplay');
3010 $
("#WNEAROSAXIS").addClass('nodisplay');
3011 $
("#WNEAROSCYL").addClass('nodisplay');
3012 $
("#WNEAROSPRISM").addClass('nodisplay');
3013 $
("#Single").on("click", function(){
3014 $
("#WNEARODAXIS").addClass('nodisplay');
3015 $
("#WNEARODCYL").addClass('nodisplay');
3016 $
("#WNEARODPRISM").addClass('nodisplay');
3017 $
("#WODADD2").addClass('nodisplay');
3018 $
("#WOSADD2").addClass('nodisplay');
3019 $
("#WNEAROSAXIS").addClass('nodisplay');
3020 $
("#WNEAROSCYL").addClass('nodisplay');
3021 $
("#WNEAROSPRISM").addClass('nodisplay');
3022 $
(".WSPACER").removeClass('nodisplay');
3024 $
("#Bifocal").on("click", function(){
3025 $
(".WSPACER").addClass('nodisplay');
3026 $
(".WNEAR").removeClass('nodisplay');
3027 $
(".WMid").addClass('nodisplay');
3028 $
(".WHIDECYL").removeClass('nodisplay');
3029 $
("[name=RX]").val(["1"]);
3030 $
("#WNEARODAXIS").addClass('nodisplay');
3031 $
("#WNEARODCYL").addClass('nodisplay');
3032 $
("#WNEARODPRISM").addClass('nodisplay');
3033 $
("#WNEAROSAXIS").addClass('nodisplay');
3034 $
("#WNEAROSCYL").addClass('nodisplay');
3035 $
("#WNEAROSPRISM").addClass('nodisplay');
3036 $
("#WODADD2").removeClass('nodisplay');
3037 $
("#WOSADD2").removeClass('nodisplay');
3039 $
("#Trifocal").on("click", function(){
3040 $
(".WSPACER").addClass('nodisplay');
3041 $
(".WNEAR").removeClass('nodisplay');
3042 $
(".WMid").removeClass('nodisplay');
3043 $
(".WHIDECYL").addClass('nodisplay');
3044 $
("[name=RX]").val(["2"]);
3045 $
("#WNEARODAXIS").addClass('nodisplay');
3046 $
("#WNEARODCYL").addClass('nodisplay');
3047 $
("#WNEARODPRISM").addClass('nodisplay');
3048 $
("#WNEAROSAXIS").addClass('nodisplay');
3049 $
("#WNEAROSCYL").addClass('nodisplay');
3050 $
("#WNEAROSPRISM").addClass('nodisplay');
3051 $
("#WODADD2").removeClass('nodisplay');
3052 $
("#WOSADD2").removeClass('nodisplay');
3054 $
("#Progressive").on("click", function(){
3055 $
(".WSPACER").addClass('nodisplay');
3056 $
(".WNEAR").removeClass('nodisplay');
3057 $
(".WMid").addClass('nodisplay');
3058 $
(".WHIDECYL").removeClass('nodisplay');
3059 $
("[name=RX]").val(["3"]);
3060 $
("#WNEARODAXIS").addClass('nodisplay');
3061 $
("#WNEARODCYL").addClass('nodisplay');
3062 $
("#WNEARODPRISM").addClass('nodisplay');
3063 $
("#WNEAROSAXIS").addClass('nodisplay');
3064 $
("#WNEAROSCYL").addClass('nodisplay');
3065 $
("#WNEAROSPRISM").addClass('nodisplay');
3066 $
("#WODADD2").removeClass('nodisplay');
3067 $
("#WOSADD2").removeClass('nodisplay');
3069 $
("[name=W_width_display]").on("click", function() {
3070 if ($
("#PREFS_W_width").val() !="1") {
3071 $
("#PREFS_W_width").val('1');
3072 //make each display W wide
3073 $
("[name=currentRX]").addClass('refraction_wide');
3074 $
("[name=W_wide]").removeClass('nodisplay');
3075 $
("[name=W_wide2]").removeClass('nodisplay');
3077 $
("#PREFS_W_width").val('0');
3078 //make each display W narrow
3079 $
("[name=currentRX]").removeClass('refraction_wide');
3080 $
("[name=W_wide]").addClass('nodisplay');
3081 $
("[name=W_wide2]").addClass('nodisplay');
3086 if ($
("#PREFS_W_width").val() == '1') {
3087 $
("[name=W_wide]").removeClass('nodisplay');
3088 $
("[name=W_wide2]").removeClass('nodisplay')
3090 $
("[name=W_wide]").addClass('nodisplay');
3091 $
("[name=W_wide2]").addClass('nodisplay');
3093 $
("#Amsler-Normal").on("change", function() {
3094 if ($
(this
).is(':checked')) {
3095 var number1
= document
.getElementById("AmslerOD").src
.match(/(Amsler_\d
)/)[1];
3096 document
.getElementById("AmslerOD").src
= document
.getElementById("AmslerOD").src
.replace(number1
,"Amsler_0");
3097 var number2
= document
.getElementById("AmslerOS").src
.match(/(Amsler_\d
)/)[1];
3098 document
.getElementById("AmslerOS").src
= document
.getElementById("AmslerOS").src
.replace(number2
,"Amsler_0");
3099 $
("#AMSLEROD").val("0");
3100 $
("#AMSLEROS").val("0");
3101 $
("#AmslerODvalue").text("0");
3102 $
("#AmslerOSvalue").text("0");
3103 submit_form("eye_mag");
3107 $
("#PUPIL_NORMAL").on("change", function() {
3108 if ($
(this
).is(':checked')) {
3109 $
("#ODPUPILSIZE1").val('3.0');
3110 $
("#OSPUPILSIZE1").val('3.0');
3111 $
("#ODPUPILSIZE2").val('2.0');
3112 $
("#OSPUPILSIZE2").val('2.0');
3113 $
("#ODPUPILREACTIVITY").val('+2');
3114 $
("#OSPUPILREACTIVITY").val('+2');
3115 $
("#ODAPD").val('0');
3116 $
("#OSAPD").val('0');
3117 submit_form("eye_mag");
3121 $
("[name$='PUPILREACTIVITY']").on("change", function() {
3122 var react
= $
(this
).val();
3123 if (react
.match(/^\d
{1}$
/)) {
3129 $
("[name^='EXAM']").on("mouseover", function(){
3130 $
(this
).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
3132 $
("[name^='EXAM']").on("mouseout", function(){
3133 $
(this
).toggleClass("borderShadow2");
3135 $
("#AmslerOD, #AmslerOS").on("click", function() {
3136 if ($
('#chart_status').val() !="on") return;
3137 var number1
= this
.src
.match(/Amsler_(\d
)/)[1];
3138 var number2
= +number1 +
1;
3139 this
.src
= this
.src
.replace('Amsler_'+number1
,'Amsler_'+number2
);
3140 this
.src
= this
.src
.replace('Amsler_6','Amsler_0');
3141 $
("#Amsler-Normal").removeAttr('checked');
3142 var number3
= this
.src
.match(/Amsler_(\d
)/)[1];
3143 this
.html
= number3
;
3144 if (number3
=="6") {
3147 if ($
(this
).attr("id")=="AmslerOD") {
3148 $
("#AmslerODvalue").text(number3
);
3149 $
('#AMSLEROD').val(number3
);
3151 $
('#AMSLEROS').val(number3
);
3152 $
("#AmslerOSvalue").text(number3
);
3154 var title
= "#"+$
(this
).attr("id")+
"_tag";
3157 $
("#AmslerOD, #AmslerOS").on("mouseout", function() {
3158 submit_form("eye_mag");
3160 $
("[name^='ODVF'],[name^='OSVF']").on("click", function() {
3161 if ($
(this
).is(':checked') == true) {
3162 $
("#FieldsNormal").prop('checked', false);
3166 $
(this
).prop('checked', false);
3168 submit_form("eye_mag");
3170 $
("#FieldsNormal").on("click", function() {
3171 if ($
(this
).is(':checked')) {
3172 $
("#ODVF1").removeAttr('checked');
3173 $
("#ODVF2").removeAttr('checked');
3174 $
("#ODVF3").removeAttr('checked');
3175 $
("#ODVF4").removeAttr('checked');
3176 $
("#OSVF1").removeAttr('checked');
3177 $
("#OSVF2").removeAttr('checked');
3178 $
("#OSVF3").removeAttr('checked');
3179 $
("#OSVF4").removeAttr('checked');
3182 $
("[id^='EXT_prefix']").on("change", function() {
3183 var newValue
=$
('#EXT_prefix').val();
3184 newValue
= newValue
.replace('+', '');
3185 if (newValue
=="off") {$
(this
).val('');}
3186 if (newValue
=="clear") {
3187 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
3192 $
("[name^='EXT_prefix_']").removeClass('eye_button_selected');
3193 $
("#EXT_prefix_"+ newValue
).addClass("eye_button_selected");
3196 $
("#ANTSEG_prefix").on("change", function() {
3197 var newValue
= $
(this
).val().replace('+', '');
3198 if ($
(this
).value
=="off") {$
(this
).val('');}
3199 if (newValue
=="clear") {
3200 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
3202 $
(".ANTSEG").val('');
3205 $
("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
3206 $
("#ANTSEG_prefix_"+ newValue
).addClass("eye_button_selected");
3209 $
("#RETINA_prefix").on("change", function() {
3210 var newValue
= $
("#RETINA_prefix").val().replace('+', '');
3211 if ($
(this
).value
=="off") {$
(this
).val('');}
3212 if (newValue
=="clear") {
3213 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
3215 $
(".RETINA").val('');
3218 $
("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
3219 $
("#RETINA_prefix_"+ newValue
).addClass("eye_button_selected");
3222 $
("#NEURO_ACT_zone").on("change", function() {
3223 var newValue
= $
(this
).val();
3224 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3225 $
("#NEURO_ACT_zone_"+ newValue
).addClass("eye_button_selected");
3226 $
("#PREFS_ACT_SHOW").val(newValue
);
3228 $
("#ACT_tab_"+newValue
).trigger('click');
3230 $
("#NEURO_side").on("change", function() {
3231 var newValue
= $
(this
).val();
3232 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3233 $
("#NEURO_side_"+ newValue
).addClass("eye_button_selected");
3235 $
('.ACT').on('focus', function() {
3236 var id
= this
.id
.match(/ACT(\d
*)/);
3237 $
('#NEURO_field').val(''+id
[1]).trigger('change');
3239 $
("#NEURO_field").on("change", function() {
3240 var newValue
= $
(this
).val();
3241 $
("[name^='NEURO_field']").removeClass('eye_button_selected');
3242 $
("#NEURO_field_"+ newValue
).addClass("eye_button_selected");
3243 $
('.ACT').each(function(i
){
3244 var color
= $
(this
).css('background-color');
3245 if ((color
== 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
3246 $
(this
).css("background-color","red");
3249 //change to highlight field in zone entry is for
3250 var zone
= $
("#NEURO_ACT_zone").val();
3251 $
("#ACT"+newValue+zone
).css("background-color","yellow");
3253 $
("[name^='NEURO_ACT_strab']").on("click", function() {
3254 var newValue
= $
(this
).val();
3255 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3256 $
(this
).addClass("eye_button_selected");
3258 $
("#NEURO_value").on("change", function() {
3259 var newValue
= $
(this
).val();
3260 $
("[name^='NEURO_value']").removeClass('eye_button_selected');
3261 $
("#NEURO_value_"+ newValue
).addClass("eye_button_selected");
3262 if (newValue
== "ortho") {
3263 $
("#NEURO_ACT_strab").val('');
3264 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3265 $
("#NEURO_side").val('');
3266 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3269 $
("#NEURO_RECORD").on("mouseover", function() {
3270 $
("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
3272 $
("#NEURO_RECORD").on("mouseout", function() {
3273 $
("#NEURO_RECORD").removeClass('borderShadow2');
3275 $
("#NEURO_RECORD").on("mousedown", function() {
3276 $
("#NEURO_RECORD").removeClass('borderShadow2');
3277 $
(this
).toggleClass('button_over');
3279 $
("#NEURO_RECORD").on("mouseup", function() {
3280 $
("#NEURO_RECORD").removeClass('borderShadow2');
3281 $
(this
).toggleClass('button_over');
3283 $
("#NEURO_RECORD").on("click", function() {
3284 //find out the field we are updating
3285 var number
= $
("#NEURO_field").val();
3286 var zone
= $
("#NEURO_ACT_zone").val();
3287 var strab
= $
("#NEURO_value").val() +
' '+ $
("#NEURO_side").val() + $
("#NEURO_ACT_strab").val();
3289 $
("#ACT"+number+zone
).val(strab
).css("background-color","#F0F8FF");
3294 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseover", function(){
3295 $
(this
).addClass("borderShadow2");
3297 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseout", function(){
3298 $
(this
).removeClass("borderShadow2");
3300 $
("[id$='_lightswitch']").on("click", function() {
3301 var section
= "#"+this
.id
.match(/(.*)_lightswitch$
/)[1];
3302 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3303 var elem
= document
.getElementById("PREFS_"+section2
);
3304 $
("#PREFS_VA").val('0');
3305 if (section2
!= "IOP")$
("#REFRACTION_sections").removeClass('nodisplay');
3306 if (elem
.value
== "0" || elem
.value
=='') {
3308 if (section2
=="ADDITIONAL") {
3309 $
("#LayerVision_ADDITIONAL").removeClass('nodisplay');
3311 if (section2
=="IOP") {
3312 $
("#LayerVision_IOP").removeClass('nodisplay');
3315 $
(section
).removeClass('nodisplay');
3316 $
(this
).addClass("buttonRefraction_selected");
3319 $
(section
).addClass('nodisplay');
3320 if (section2
=="VAX") {
3321 $
("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
3323 if (section2
=="IOP") {
3324 $
("#LayerVision_IOP").addClass('nodisplay');
3326 $
(this
).removeClass("buttonRefraction_selected");
3328 $
(this
).css( 'cursor', 'pointer' );
3332 $
('[id$=_lightswitch]').on("mouseover", function() {
3333 $
(this
).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
3335 var section
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3336 if (section
== 'IOP') {
3337 $
("#LayerTension").addClass("borderShadow2");
3339 $
("#LayerVision").addClass("borderShadow2");
3342 $
('[id$=_lightswitch]').on('mouseout', function() {
3343 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3344 var elem
= document
.getElementById("PREFS_"+section2
);
3346 if (elem
.value
!= "1") {
3347 $
(this
).removeClass('buttonRefraction_selected');
3349 $
(this
).addClass('buttonRefraction_selected');
3352 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
3353 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
3354 // "-" is still == "-"
3355 $
("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
) {
3356 if (e
.keyCode
=='61' || e
.keyCode
=='74') {
3357 now
= $
(this
).val();
3358 now
= now
.replace(/=/g
,"+").replace(/^j
/g
,"J");
3362 //useful to make all VA fields stay in sync
3363 $
("input[name$='VA']").on('change',function() {
3364 var hereValue
= $
(this
).val();
3365 var newValue
= $
(this
).attr('name').replace('VA', 'VA_copy');
3366 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3367 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");;
3369 $
("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
3370 var hereValue
= $
(this
).val();
3371 hereValue
= hereValue
.replace(/=$
/g
,"+").replace(/^j
/g
,"J");
3372 $
(this
).val(hereValue
);
3373 if (this
.name
.match(/_1$
/)) {
3374 var newValue
= $
(this
).attr('name').replace('VA_1', 'VA_1_copy');
3375 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3376 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");
3380 $
("input[name$='_copy']").on("blur", function() {
3381 var hereValue
= $
(this
).val();
3382 var newValue
= $
(this
).attr('name').replace('_copy', '');
3383 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3384 $
("#" + newValue +
"_copy_brd").val(hereValue
).css("background-color","#F0F8FF");;
3386 $
("input[name$='_copy_brd']").on("change", function() {
3387 var hereValue
= $
(this
).val();
3388 var newValue
= $
(this
).attr('name').replace('_copy_brd', '');
3389 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3390 $
("#" + newValue +
"_copy").val(hereValue
).css("background-color","#F0F8FF");;
3392 $
("[name^='more_']").on("mouseout", function() {
3393 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
3395 $
("[name^='more_']").on("click", function() {
3396 $
("#Visions_A").toggleClass('nodisplay');
3397 $
("#Visions_B").toggleClass('nodisplay');
3399 $
("#EXAM_defaults").on("click", function() {
3400 if (!confirm('<?php echo xla("Replace all exam findings with Default values? Are you sure?"); ?>')) {
3404 // This query is specific to the provider.
3405 $query = "select seq from list_options where option_id=?";
3406 $result = sqlStatement($query, array("Eye_defaults_$providerID"));
3408 $list = sqlFetchArray($result);
3409 $SEQ = $list['seq'] ??
'';
3411 // If there is no list for this provider, we create it here.
3412 // This list is part of the idea to create a way to add Eye_Defaults_$providerID specific to the
3413 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3414 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3415 // Let's see if the public likes the form itself before developing these subspecialty lists...
3417 //Copy the Eye_Defaults_for_GENERAL to Eye_defaults_$providerID
3418 $sql = "SELECT * from list_options where list_id = 'Eye_Defaults_for_GENERAL'";
3419 $start = sqlStatement($sql);
3420 $add_fields = array();
3422 while ($val = sqlFetchArray($start)) {
3423 $parameters .= "(?, ?, ?, ?, ?, ?),";
3424 array_push($add_fields, "Eye_defaults_" . $providerID, $val['option_id'], $val['title'], $val['notes'], '1', $val['seq']);
3426 $parameters = rtrim($parameters, ",");
3427 $query = "SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'";
3428 $pres = sqlStatement($query);
3429 $maxseq = sqlFetchArray($pres);
3431 $seq = $maxseq['maxseq'];
3432 $query = "INSERT INTO `list_options`
3433 (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`) VALUES
3434 ('lists', ?, ?, ?, '1', '0', '', '', '')";
3435 $providerNAME = getProviderName($providerID);
3437 sqlStatement($query, array("Eye_defaults_$providerID","Eye Exam Defaults $providerNAME ",$seq));
3438 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`,`notes`,`activity`,`seq`) VALUES " . $parameters;
3439 sqlStatement($query, $add_fields);
3442 $query = "select * from list_options where list_id =? and activity='1' order by seq";
3444 $DEFAULT_data = sqlStatement($query, array("Eye_defaults_$providerID"));
3445 while ($row = sqlFetchArray($DEFAULT_data)) {
3446 //$row['notes'] is the clinical zone (EXT,ANTSEG,RETINA,NEURO)
3447 //$row['option_id'] is the field name
3448 //$row['title'] is the default value to use for this provider
3449 $
{$row['notes']}[$row['option_id']] = $row['title']; //This builds each clinical section into its own array (used below)
3450 echo '$("#' . $row['option_id'] . '").val("' . $row['title'] . '").css("background-color","beige");
3453 function startsWith($str, $needle)
3455 return substr($str, 0, strlen($needle)) === $needle;
3458 submit_form("eye_mag");
3460 $
("#EXT_defaults_R").on("click", function() {
3462 foreach ($EXT as $item => $value) {
3463 if (startsWith($item, "R")) {
3464 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3469 submit_form("eye_mag");
3472 $
("#EXT_defaults_L").on("click", function() {
3474 foreach ($EXT as $item => $value) {
3475 if (startsWith($item, "L")) {
3476 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3481 submit_form("eye_mag");
3483 $
("#EXT_defaults").on("click", function() {
3484 $
("#EXT_defaults_L").trigger('click');
3485 $
("#EXT_defaults_R").trigger('click');
3486 submit_form("eye_mag");
3489 $
("#EXT_R_L").on('click', function () {
3490 $
("#LBROW").val($
("#RBROW").val());
3491 $
("#LUL").val($
("#RUL").val());
3492 $
("#LLL").val($
("#RLL").val());
3493 $
("#LMCT").val($
("#RMCT").val());
3494 $
("#LADNEXA").val($
("#RADNEXA").val());
3495 submit_form("eye_mag");
3498 $
("#EXT_L_R").on('click', function () {
3499 $
("#RBROW").val($
("#LBROW").val());
3500 $
("#RUL").val($
("#LUL").val());
3501 $
("#RLL").val($
("#LLL").val());
3502 $
("#RMCT").val($
("#LMCT").val());
3503 $
("#RADNEXA").val($
("#LADNEXA").val());
3504 submit_form("eye_mag");
3506 $
("#ANTSEG_defaults_OD").on("click", function() {
3508 foreach ($ANTSEG as $item => $value) {
3509 if (startsWith($item, "OD")) {
3510 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3515 submit_form("eye_mag");
3518 $
("#ANTSEG_defaults_OS").on("click", function() {
3520 foreach ($ANTSEG as $item => $value) {
3521 if (startsWith($item, "OS")) {
3522 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3527 submit_form("eye_mag");
3529 $
("#ANTSEG_defaults").on("click", function() {
3530 $
("#ANTSEG_defaults_OD").trigger('click');
3531 $
("#ANTSEG_defaults_OS").trigger('click');
3532 submit_form("eye_mag");
3534 $
("#ANTSEG_OD_OS").on('click', function () {
3535 $
("#OSCONJ").val($
("#ODCONJ").val());
3536 $
("#OSCORNEA").val($
("#ODCORNEA").val());
3537 $
("#OSAC").val($
("#ODAC").val());
3538 $
("#OSLENS").val($
("#ODLENS").val());
3539 $
("#OSIRIS").val($
("#ODIRIS").val());
3540 submit_form("eye_mag");
3542 $
("#ANTSEG_OS_OD").on('click', function () {
3543 $
("#ODCONJ").val($
("#OSCONJ").val());
3544 $
("#ODCORNEA").val($
("#OSCORNEA").val());
3545 $
("#ODAC").val($
("#OSAC").val());
3546 $
("#ODLENS").val($
("#OSLENS").val());
3547 $
("#ODIRIS").val($
("#OSIRIS").val());
3548 submit_form("eye_mag");
3551 $
("#RETINA_OD_OS").on('click', function () {
3552 $
("#OSDISC").val($
("#ODDISC").val());
3553 $
("#OSCUP").val($
("#ODCUP").val());
3554 $
("#OSMACULA").val($
("#ODMACULA").val());
3555 $
("#OSVESSELS").val($
("#ODVESSELS").val());
3556 $
("#OSVITREOUS").val($
("#ODVITREOUS").val());
3557 $
("#OSPERIPH").val($
("#ODPERIPH").val());
3558 submit_form("eye_mag");
3561 $
("#RETINA_OS_OD").on('click', function () {
3562 $
("#ODDISC").val($
("#OSDISC").val());
3563 $
("#ODCUP").val($
("#OSCUP").val());
3564 $
("#ODMACULA").val($
("#OSMACULA").val());
3565 $
("#ODVESSELS").val($
("#OSVESSELS").val());
3566 $
("#ODVITREOUS").val($
("#OSVITREOUS").val());
3567 $
("#ODPERIPH").val($
("#OSPERIPH").val());
3568 submit_form("eye_mag");
3571 $
("#clear_EXT_L").on('click', function () {
3572 $
("#LBROW").val('');
3576 $
("#LADNEXA").val('');
3579 submit_form("eye_mag");
3582 $
("#clear_EXT_R").on('click', function () {
3583 $
("#RBROW").val('');
3587 $
("#RADNEXA").val('');
3590 submit_form("eye_mag");
3593 $
("#RETINA_defaults_OD").on("click", function() {
3595 foreach ($RETINA as $item => $value) {
3596 if (startsWith($item, "OD")) {
3597 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3602 submit_form("eye_mag");
3605 $
("#RETINA_defaults_OS").on("click", function() {
3607 foreach ($RETINA as $item => $value) {
3608 if (startsWith($item, "OS")) {
3609 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3614 submit_form("eye_mag");
3616 $
("#RETINA_defaults").on("click", function() {
3617 $
("#RETINA_defaults_OD").trigger('click');
3618 $
("#RETINA_defaults_OS").trigger('click');
3619 submit_form("eye_mag");
3623 $
("#NEURO_defaults").on("click", function() {
3625 foreach ($NEURO as $item => $value) {
3626 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3630 submit_form("eye_mag");
3633 $
("#clear_EXT_R").on('click', function() {
3634 $
('.right.EXT').val('');
3635 submit_form("eye_mag");
3637 $
("#clear_EXT_L").on('click', function() {
3638 $
('.left.EXT').val('');
3639 submit_form("eye_mag");
3641 $
("#clear_ANTSEG_OD").on('click', function() {
3642 $
('.right.ANTSEG').val('');
3643 submit_form("eye_mag");});
3644 $
("#clear_ANTSEG_OS").on('click', function() {
3645 $
('.left.ANTSEG').val('');
3646 submit_form("eye_mag");
3648 $
("#clear_RETINA_OD").on('click', function() {
3649 $
('.right.RETINA').val('');
3650 submit_form("eye_mag");
3652 $
("#clear_RETINA_OS").on('click', function() {
3653 $
('.left.RETINA').val('');
3654 submit_form("eye_mag");
3657 $
("[id^='cpf_']").on('click', function() {
3658 var to_field
= this
.id
.match(/cpf_(.*)_(.*)/)[1];
3659 var from_field
= this
.id
.match(/cpf_(.*)_(.*)/)[2];
3660 $
("#"+to_field
).val($
("#"+from_field
).val());
3661 submit_form("eye_mag");
3663 $
("#MOTILITYNORMAL").on("click", function() {
3664 $
("#MOTILITY_RS").val('0');
3665 $
("#MOTILITY_RI").val('0');
3666 $
("#MOTILITY_RR").val('0');
3667 $
("#MOTILITY_RL").val('0');
3668 $
("#MOTILITY_LS").val('0');
3669 $
("#MOTILITY_LI").val('0');
3670 $
("#MOTILITY_LR").val('0');
3671 $
("#MOTILITY_LL").val('0');
3673 $
("#MOTILITY_RRSO").val('0');
3674 $
("#MOTILITY_RRIO").val('0');
3675 $
("#MOTILITY_RLSO").val('0');
3676 $
("#MOTILITY_RLIO").val('0');
3677 $
("#MOTILITY_LRSO").val('0');
3678 $
("#MOTILITY_LRIO").val('0');
3679 $
("#MOTILITY_LLSO").val('0');
3680 $
("#MOTILITY_LLIO").val('0');
3682 for (index
= '0'; index
< 5; ++index
) {
3683 $
("#MOTILITY_RS_"+index
).html('');
3684 $
("#MOTILITY_RI_"+index
).html('');
3685 $
("#MOTILITY_RR_"+index
).html('');
3686 $
("#MOTILITY_RL_"+index
).html('');
3687 $
("#MOTILITY_LS_"+index
).html('');
3688 $
("#MOTILITY_LI_"+index
).html('');
3689 $
("#MOTILITY_LR_"+index
).html('');
3690 $
("#MOTILITY_LL_"+index
).html('');
3692 $
("#MOTILITY_RRSO_"+index
).html('');
3693 $
("#MOTILITY_RRIO_"+index
).html('');
3694 $
("#MOTILITY_RLSO_"+index
).html('');
3695 $
("#MOTILITY_RLIO_"+index
).html('');
3696 $
("#MOTILITY_LRSO_"+index
).html('');
3697 $
("#MOTILITY_LRIO_"+index
).html('');
3698 $
("#MOTILITY_LLSO_"+index
).html('');
3699 $
("#MOTILITY_LLIO_"+index
).html('');
3701 submit_form('eye_mag');
3704 $
("[name^='MOTILITY_']").on("click", function() {
3705 $
("#MOTILITYNORMAL").removeAttr('checked');
3707 if (this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/)) {
3708 var zone
= this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/);
3710 var valued
= isNaN($
("#"+zone
[1]).val());
3711 if ((zone
[2] =='RLSO')||
(zone
[2] =='LLSO')||
(zone
[2] =='RRIO')||
(zone
[2] =='LRIO')) {
3712 //find or make a hash tage for "\"
3713 var hash_tag
= '<i class="fa fa-minus"></i>';
3715 //find or make a hash tage for "/"
3716 var hash_tag
= '<i class="fa fa-minus"></i>';
3719 var zone
= this
.id
.match(/(MOTILITY_
..)_(.)/);
3720 var section
= this
.id
.match(/MOTILITY_(.)(.)_
/);
3721 var section2
= section
[2];
3722 var Eye
= section
[1];
3723 var SupInf
= section2
.search(/S|I
/);
3724 var RorLside
= section2
.search(/R|L
/);
3727 if (RorLside
=='0') {
3728 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
3730 var hash_tag
= '<i class="fa fa-minus"></i>';
3733 if (valued
!= true && $
("#"+zone
[1]).val() <'4') {
3734 valued
=$
("#"+zone
[1]).val();
3738 $
("#"+zone
[1]).val('0');
3741 $
("#"+zone
[1]).val(valued
);
3743 for (index
= '0'; index
< 5; ++index
) {
3744 $
("#"+zone
[1]+
"_"+index
).html('');
3747 for (index
=1; index
< (valued+
1); ++index
) {
3748 $
("#"+zone
[1]+
"_"+index
).html(hash_tag
);
3755 $
("[name^='Close_']").on("click", function() {
3756 var section
= this
.id
.match(/Close_(.*)$
/)[1];
3757 if (this
.id
.match(/Close_W_(.*)$
/) != null) {
3758 var W_section
= this
.id
.match(/Close_W_(.*)$
/)[1];
3759 if (W_section
> '1') {
3760 $
('#LayerVision_W_'+W_section
).addClass('nodisplay');
3761 $
('[name$=SPH_'+W_section+
']').val('');
3762 $
('[name$=CYL_'+W_section+
']').val('');
3763 $
('[name$=AXIS_'+W_section+
']').val('');
3764 $
('[name$=ADD_'+W_section+
']').val('');
3765 $
('[name$=PRISM_'+W_section+
']').val('');
3766 $
('[name$=VA_'+W_section+
']').val('');
3767 $
('#RX_TYPE_'+W_section
).val('');
3768 $
('#Add_Glasses').removeClass('nodisplay');
3769 $
('#W_'+W_section
).val('');
3772 $
("#LayerVision_W_lightswitch").click();
3774 } else if (section
=="ACTMAIN") {
3775 $
("#ACTTRIGGER").trigger( "click" );
3777 $
("#LayerVision_"+section+
"_lightswitch").click();
3782 $
("#EXAM_DRAW, #BUTTON_DRAW_menu, #PANEL_DRAW").on("click", function() {
3783 if ($
("#PREFS_CLINICAL").value
!='0') {
3785 $
("#PREFS_CLINICAL").val('0');
3788 if ($
("#PREFS_EXAM").val() != 'DRAW') {
3789 $
("#PREFS_EXAM").val('DRAW');
3790 $
("#EXAM_QP").removeClass('button_selected');
3791 $
("#EXAM_DRAW").addClass('button_selected');
3792 $
("#EXAM_TEXT").removeClass('button_selected');
3797 $
("#EXAM_QP,#PANEL_QP").on("click", function() {
3798 if ($
("#PREFS_CLINICAL").value
!='0') {
3799 $
("#PREFS_CLINICAL").val('0');
3802 if ($
("#PREFS_EXAM").value
!= 'QP') {
3803 $
("#PREFS_EXAM").val('QP');
3804 $
("#EXAM_QP").addClass('button_selected');
3805 $
("#EXAM_DRAW").removeClass('button_selected');
3806 $
("#EXAM_TEXT").removeClass('button_selected');
3811 scrollTo("EXT_left");
3814 $
("#EXAM_TEXT,#PANEL_TEXT").on("click", function() {
3816 // also hide QP, DRAWs, and PRIORS
3823 for (index
= '0'; index
< zones
.length
; ++index
) {
3824 $
("#PREFS_"+zones
[index
]+
"_RIGHT").val(0);
3828 $
("#EXAM_DRAW").removeClass('button_selected');
3829 $
("#EXAM_QP").removeClass('button_selected');
3830 $
("#EXAM_TEXT").addClass('button_selected');
3831 scrollTo("EXT_left");
3833 $
("[id^='BUTTON_TEXT_']").on("click", function() {
3834 var zone
= this
.id
.match(/BUTTON_TEXT_(.*)/)[1];
3835 if (zone
!= "menu") {
3836 $
("#"+zone+
"_right").addClass('nodisplay');
3837 $
("#"+zone+
"_left").removeClass('display');
3838 $
("#"+zone+
"_left_text").removeClass('display');
3839 $
("#PREFS_"+zone+
"_RIGHT").val(0);
3842 scrollTo("EXT_left");
3844 $
("[id^='BUTTON_TEXTD_']").on("click", function() {
3845 var zone
= this
.id
.match(/BUTTON_TEXTD_(.*)/)[1];
3846 if (zone
!= "menu") {
3847 if ((zone
=="PMH") ||
(zone
== "HPI")) {
3848 $
("#PMH_right").addClass('nodisplay');
3849 $
("#PREFS_PMH_RIGHT").val(1);
3850 $
("#HPI_right").addClass('nodisplay');
3851 $
("#PREFS_HPI_RIGHT").val(1);
3852 var reset
= $
("#HPI_1").height();
3853 $
("#PMH_1").css("min-height",'0');
3854 $
("#PMH_left").height(reset
-40);
3856 $
("#LayerTechnical_sections_1").css("clear","both");
3858 $
("#"+zone+
"_right").addClass('nodisplay');
3859 $
("#PREFS_"+zone+
"_RIGHT").val(1);
3861 scrollTo(zone+
"_left");
3866 $
("#EXAM_TEXT").addClass('button_selected');
3867 if (($
("#PREFS_CLINICAL").val() !='1')) {
3868 var actionQ
= "#EXAM_"+$
("#PREFS_EXAM").val();
3869 $
(actionQ
).trigger('click');
3871 $
("#EXAM_TEXT").addClass('button_selected');
3873 if ($
("#ANTSEG_prefix").val() > '') {
3874 $
("#ANTSEG_prefix_"+$
("#ANTSEG_prefix").val()).addClass('button_selected');
3876 $
("#ANTSEG_prefix").val('off').trigger('change');
3878 $
("[name^='ACT_tab_']").on("mouseover", function() {
3879 $
(this
).toggleClass('underline').css( 'cursor', 'pointer' );
3881 $
("[name^='ACT_tab_']").on("mouseout", function() {
3882 $
(this
).toggleClass('underline');
3885 $
("[name^='ACT_tab_']").on("click", function() {
3886 var section
= this
.id
.match(/ACT_tab_(.*)/)[1];
3887 $
("[name^='ACT_']").addClass('nodisplay');
3888 $
("[name^='ACT_tab_']").removeClass('nodisplay').removeClass('ACT_selected').addClass('ACT_deselected');
3889 $
("#ACT_tab_" + section
).addClass('ACT_selected').removeClass('ACT_deselected');
3890 $
("#ACT_" + section
).removeClass('nodisplay');
3891 $
("#PREFS_ACT_SHOW").val(section
);
3892 //selection correct QP zone
3893 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3894 $
("#NEURO_ACT_zone_"+ section
).addClass("eye_button_selected");
3895 $
("#NEURO_ACT_zone").val(section
);
3898 $
("#ACTTRIGGER").on("mouseout", function() {
3899 $
("#ACTTRIGGER").toggleClass('buttonRefraction_selected').toggleClass('underline');
3901 if ($
("#PREFS_ACT_VIEW").val() == '1') {
3902 $
("#ACTMAIN").toggleClass('nodisplay');
3903 $
("#NPCNPA").toggleClass('nodisplay');
3904 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3905 $
("#ACTTRIGGER").toggleClass('underline');
3906 var show
= $
("#PREFS_ACT_SHOW").val();
3907 $
("#ACT_tab_"+show
).trigger('click');
3909 $
("#ACTTRIGGER").on("click", function() {
3910 $
("#ACTMAIN").toggleClass('nodisplay').toggleClass('ACT_TEXT');
3911 $
("#NPCNPA").toggleClass('nodisplay');
3912 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3913 $
("#ACTTRIGGER").toggleClass('underline');
3914 if ($
("#PREFS_ACT_VIEW").val()=='1') {
3915 $
("#PREFS_ACT_VIEW").val('0');
3917 $
("#PREFS_ACT_VIEW").val('1');
3919 var show
= $
("#PREFS_ACT_SHOW").val();
3920 $
("#ACT_tab_"+show
).trigger('click');
3923 $
("#NEURO_COLOR").on("click", function() {
3924 $
("#ODCOLOR").val("11/11");
3925 $
("#OSCOLOR").val("11/11");
3926 submit_form("eye_mag");
3929 $
("#NEURO_COINS").on("click", function() {
3930 $
("#ODCOINS").val("1.00");
3931 //leave currency symbol out unless it is an openEMR defined option
3932 $
("#OSCOINS").val("1.00");
3933 submit_form("eye_mag");
3936 $
("#NEURO_REDDESAT").on("click", function() {
3937 $
("#ODREDDESAT").val("100");
3938 $
("#OSREDDESAT").val("100");
3939 submit_form("eye_mag");
3942 $
("[id^='myCanvas_']").on("mouseout", function() {
3943 var zone
= this
.id
.match(/myCanvas_(.*)/)[1];
3944 submit_canvas(zone
);
3946 $
("[id^='Undo_']").on("click", function() {
3947 var zone
= this
.id
.match(/Undo_Canvas_(.*)/)[1];
3948 submit_canvas(zone
);
3950 $
("[id^='Redo_']").on("click", function() {
3951 var zone
= this
.id
.match(/Redo_Canvas_(.*)/)[1];
3952 submit_canvas(zone
);
3954 $
("[id^='Clear_']").on("click", function() {
3955 var zone
= this
.id
.match(/Clear_Canvas_(.*)/)[1];
3956 submit_canvas(zone
);
3958 $
("[id^='Blank_']").on("click", function() {
3960 var zone
= this
.id
.match(/Blank_Canvas_(.*)/)[1];
3961 $
("#url_"+zone
).val("../../forms/eye_mag/images/BLANK_BASE.png");
3962 //canvas.renderAll();
3966 $
("#COPY_SECTION").on("change", function() {
3967 var start
= $
("#COPY_SECTION").val();
3968 if (start
=='') return;
3969 var value
= start
.match(/(\w
*)-(\w
*)/);
3970 var zone
= value
[1];
3971 var copy_from
= value
[2];
3972 if (zone
=="READONLY") copy_from
= $
("#form_id").val();
3973 var count_changes
='0';
3979 copy_to
: $
("#form_id").val(),
3980 copy_from
: copy_from
,
3981 pid
: $
("#pid").val()
3983 if (zone
=="READONLY") {
3984 //we are going to update the whole form
3985 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
3986 //We are not ready to actively chart, just looking to see how far along our staff is...
3987 //or maybe just looking ahead to see who's next in the next room?
3988 //Either way, we are looking at a record that at present will be disabled/we cannot change...
3989 // yet it is updating every 10 seconds if another user is making changes.
3991 // READONLY does not show IMPPLAN changes!!!!
3993 //here we are retrieving an old record to copy forward to today's active chart.
3994 data
= $
("#"+zone+
"_left_text").serialize() +
"&" + $
.param(data
);
3996 top
.restoreSession();
4000 url
: "../../forms/eye_mag/save.php",
4002 success
: function(result
) {
4003 //we have to process impplan differently
4004 if (zone
=='IMPPLAN') {
4005 //we get a json result.IMPPLAN back from the prior visit
4006 //we need to add that to the current list? Replace for now.
4007 build_IMPPLAN(result
.IMPPLAN
);
4008 store_IMPPLAN(result
.IMPPLAN
);
4009 // need to make the Plan areas purple?
4011 $
.map(result
, function(valhere
, keyhere
) {
4012 if ($
("#"+keyhere
).val() != valhere
) {
4013 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
4014 } else if (keyhere
.match(/MOTILITY_
/)) {
4015 // Copy forward ductions and versions visually
4016 // Make each blank, and rebuild them
4017 $
("[name='"+keyhere+
"_1']").html('');
4018 $
("[name='"+keyhere+
"_2']").html('');
4019 $
("[name='"+keyhere+
"_3']").html('');
4020 $
("[name='"+keyhere+
"_4']").html('');
4021 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
4022 // Show a horizontal (minus) tag. When "/" and "\" fa-icons are available will need to change.
4023 // Maybe just use small font "/" and "\" directly.
4024 hash_tag
= '<i class="fa fa-minus"></i>';
4025 } else { //show vertical tag
4026 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
4028 for (index
=1; index
<= valhere
; ++index
) {
4029 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
4031 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
4032 if (valhere
=='1') {
4033 $
("#FieldsNormal").prop('checked', false);
4034 $
("#"+keyhere
).prop('checked', true);
4035 $
("#"+keyhere
).val('1');
4037 $
("#"+keyhere
).val('0');
4038 $
("#"+keyhere
).prop('checked', false);
4040 } else if (keyhere
.match(/AMSLERO(.)/)) {
4041 var sidehere
= keyhere
.match(/AMSLERO(.)/);
4042 if (valhere
< '1') valhere
='0';
4043 $
("#"+keyhere
).val(valhere
);
4044 var srcvalue
="AmslerO"+sidehere
[1];
4045 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
4046 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
4047 } else if (keyhere
.match(/VA$
/)) {
4048 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
4049 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
4052 if (zone
!= "READONLY") { submit_form("eye_mag"); }
4056 $
("[id^='BUTTON_DRAW_']").on("click", function() {
4057 var zone
=this
.id
.match(/BUTTON_DRAW_(.*)$
/)[1];
4060 if ($
('#PREFS_'+zone+
'_RIGHT').val() =="DRAW") {
4061 $
('#BUTTON_TEXTD_'+zone
).trigger("click");//closes draw
4062 //maybe this should revert to last right panel state (qp,text)
4065 $
("#"+zone+
"_1").removeClass('nodisplay');
4066 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
4067 $
("#QP_"+zone
).addClass('nodisplay');
4068 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
4069 $
("#Draw_"+zone
).removeClass('nodisplay');
4070 $
("#PREFS_"+zone+
"_RIGHT").val('DRAW');
4071 scrollTo(zone+
"_left");
4075 $
("[id^='BUTTON_QP_']").on("click", function() {
4076 var zone
= this
.id
.match(/BUTTON_QP_(.*)$
/)[1].replace(/_\d*/
,'');
4077 if (zone
=='IMPPLAN2') {
4078 $
('#IMP_start_acc').slideDown();
4081 if (($
("#PREFS_"+zone+
"_RIGHT").val() =='QP')&&(zone
!='IMPPLAN')) {
4082 $
('#BUTTON_TEXTD_'+zone
).trigger("click");
4085 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
4086 $
("#Draw_"+zone
).addClass('nodisplay');
4087 show_QP_section(zone
, '1');
4088 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
4090 if ((zone
== 'PMH')||
(zone
== 'HPI')) {
4091 if ($
('#HPI_right').css('display') == 'none') {
4092 $
("#Draw_HPI").addClass('nodisplay');
4093 show_QP_section('HPI', '1');
4094 $
("#PREFS_HPI_RIGHT").val('QP');
4099 if (zone
== 'HPI') {
4100 if ($
('#PMH_right').css('display') == 'none') {
4101 $
("#PRIORS_PMH_left_text").addClass('nodisplay');
4102 $
("#Draw_PMH").addClass('nodisplay');
4103 show_QP_section('PMH','1');
4104 $
("#PREFS_PMH_RIGHT").val('QP');
4106 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
4107 $
('#PMH_left').height($
('#PMH_right').height());
4109 $
('#PMH_1').height($
('#HPI_1').height());
4111 } else if (zone
== 'menu') {
4113 } else if (zone
== 'IMPPLAN') {
4114 show_QP_section('IMPPLAN','1');
4120 // set default to ccDist. Change as desired.
4121 $
('#NEURO_ACT_zone').val('CCDIST').trigger('change');
4122 if ($
("#RXStart").val() =="2") {
4123 $
("#Trifocal").trigger('click');
4125 $
("[id$='_loading']").addClass('nodisplay');
4126 $
("[id$='_sections']").removeClass('nodisplay');
4128 $
('#left-panel').css("right","0px");
4129 $
('#EXAM_KB').css({position
: 'fixed', top
: '29px'});
4130 $
('#EXAM_KB').css('display', 'block');
4131 $
('#EXAM_KB').draggable();
4132 $
('#IMP').droppable({ drop
: dragto_IMPPLAN
} );
4133 $
('#IMPPLAN_zone').droppable({ drop
: dragto_IMPPLAN_zone
} );
4134 $
('#IMPPLAN_text').droppable({ drop
: dragto_IMPPLAN_zone
} );
4136 $
('[id^="PLANS"]').draggable( { cursor
: 'move', revert
: true });
4137 $
('[id^="PLAN_"]').height( $
(this
).scrollHeight
);
4139 /* Sorting of diagnoses in IMP/PLAN right panel builds IMP_order[] array.
4140 Foreach index => value in IMP_order[order,PMSFH[type][i]]:
4141 retrieve PMSFH[type][value] and build the IMPRESSION/PLAN area
4142 openEMR ICD-10 seems to have newlines in codetext? strip them with replace.
4143 All the ISSUE_TYPES and their fields are available in obj.PMSFH:
4144 'title' => $disptitle,
4145 'status' => $statusCompute,
4146 'enddate' => $row['enddate'],
4147 'reaction' => $row['reaction'],
4148 'referredby' => $row['referredby'],
4149 'extrainfo' => $row['extrainfo'],
4150 'diagnosis' => $row['diagnosis'],
4152 'codedesc' => $codedesc,
4153 'codetext' => $codetext,
4154 'codetype' => $codetype,
4155 'comments' => $row['comments'],
4156 'rowid' => $row['id'],
4157 'row_type' => $row['type']
4158 eg. obj.IMPPLAN_items[index] = code: obj.PMSFH['POH'][value]['code'],
4159 codedesc: obj.PMSFH['POH'][value]['codedesc'],
4160 codetype: obj.PMSFH['POH'][value]['codetype']
4163 $
('#make_new_IMP').on("click", function() {
4165 if (IMP_order
.length
==0) rebuild_IMP($
( "#build_DX_list" ));
4166 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
4167 $
.each(IMP_order
, function( index
, value
) {
4168 issue
= value
.match(/(.*)_(.*)/);
4169 if (issue
[1] == "CLINICAL") {
4170 if (!$
('#inc_PE').is(':checked')) { return; }
4173 var the_codedesc
='';
4174 var the_codetext
='';
4176 for (i
=0;i
< obj
.Clinical
[issue
[2]].length
; i++
) {
4178 the_code
= obj
.Clinical
[issue
[2]][i
]['code'];
4179 } else if (i
< obj
.Clinical
[issue
[2]].length
) {
4180 the_code +
= ', '+ obj
.Clinical
[issue
[2]][i
]['code'];
4182 the_codedesc +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
4183 the_codetext +
= obj
.Clinical
[issue
[2]][i
]['codetext'] +
"\r";
4184 the_plan +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
4186 obj
.IMPPLAN_items
.push({
4187 title
:obj
.Clinical
[issue
[2]][0]['title'],
4189 codetype
: obj
.Clinical
[issue
[2]][0]['codetype'],
4190 codedesc
: the_codedesc
,
4191 codetext
: the_codetext
,
4193 PMSFH_link
: obj
.Clinical
[issue
[2]][0]['PMSFH_link']
4196 if (issue
[1] == "PMH") {
4197 if (!$
('#inc_PMH').is(':checked')) { return; }
4198 } else if (issue
[1] == "POH"){
4199 if (!$
('#inc_POH').is(':checked')) { return; }
4200 } else if (issue
[1] == "POS"){
4201 if (!$
('#inc_POH').is(':checked')) { return; }
4203 obj
.IMPPLAN_items
.push({
4204 title
: obj
.PMSFH
[issue
[1]][issue
[2]]['title'],
4205 code
: obj
.PMSFH
[issue
[1]][issue
[2]]['code'],
4206 codetype
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetype'],
4207 codedesc
: obj
.PMSFH
[issue
[1]][issue
[2]]['codedesc'],
4208 codetext
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetext'].replace(/(\r\n|\n|\r
)/gm
,""),
4209 plan
: obj
.PMSFH
[issue
[1]][issue
[2]]['comments'],
4210 PMSFH_link
: obj
.PMSFH
[issue
[1]][issue
[2]]['PMSFH_link']
4214 build_IMPPLAN(obj
.IMPPLAN_items
);
4215 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
4219 $
('.building_blocks > dt ').on('click', function() {
4220 if ( $
(this
).next().css('display') !== 'block' ) {
4221 allPanels
.slideUp();
4222 $
(this
).next().slideDown();
4224 allPanels
.slideUp();
4227 $
('#IMP_start_acc').slideDown();
4228 $
('[id^=inc_]').on('click', function() {
4232 $
('#active_flag').on('click', function() { check_lock('1'); });
4233 $
('#active_icon').on('click', function() { check_lock('1'); });
4235 $
("input,textarea,text,checkbox").on("change", function(){
4236 $
(this
).css("background-color","#F0F8FF");
4237 if (this
.name
.match(/IOP
/)) { color_IOP(this
); }
4238 if ( ($
(this
).id
!= 'IMP') &&
4239 (!this
.name
.match(/^inc_
/)) &&
4240 (!this
.name
.match(/_modifier$
/))
4244 $
("#IMP_start_acc").slideDown();
4247 $
("[name='CANVAS_selector']").on("change", function(){
4248 //we are going to display an old image from a previous encounter
4249 zone
= this
.id
.match(/CANVAS_(.*)/)[1];
4250 if (this
.value
!= 'current') {
4251 $
("#"+zone+
"_canvas").addClass('nodisplay');
4252 $
("#"+zone+
"_olddrawing").removeClass('nodisplay');
4253 show_PRIOR_CANVAS_section(zone
, this
.value
);
4255 $
("#"+zone+
"_canvas").removeClass('nodisplay');
4257 $
("#"+zone+
"_olddrawing").addClass('nodisplay');
4262 $
('#IMP').on("blur", function() {
4263 //add this DX to the obj.IMPPLAN_items array
4264 //take the first line as the impression and the rest as the plan
4265 var total_imp
= $
('#IMP').val();
4266 $
('#IMP').val('');//clear the box
4267 var local_plan
= '';
4269 if (total_imp
.length
< '2') return; //reject text under two letters?
4270 var re
= /\r\n|
[\n\v\f\r\x85\u2028\u2029]/; //official list of line delimiters for a regex
4271 //local_impression is first line only[1]
4272 var local_imp
= total_imp
.match(/^
(.*)(?
:\r\n|
[\n\v\f\r\x85\u2028\u2029])(.*)/);
4273 if (local_imp
== null || local_imp
[1] == null) {
4274 local_imp
= total_imp
;
4276 // If the first line was dropped in from the Builder via a draggable DX_list
4277 // it will include the IMPRESSION + CODE.
4278 // Consider stripping out the CODE
4279 var local_imp_code
= local_imp
[1].match(/(.*)(ICD
.*)$
/);
4280 if (local_imp_code
) {
4281 local_imp
= local_imp_code
[1];
4282 local_code
= local_imp_code
[2];
4283 local_plan
= total_imp
.replace(local_imp_code
[0],''); //plan is line 2+ if present, strip off first line
4284 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
4286 local_imp
= local_imp
[1];
4288 local_plan
= total_imp
.replace(local_imp
,''); //plan is line 2+ if present, strip off first line
4289 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
4292 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];//can't push if array does not exist
4293 obj
.IMPPLAN_items
.push({
4294 form_id
: $
('#form_id').val(),
4295 pid
: $
('#pid').val(),
4304 build_IMPPLAN(obj
.IMPPLAN_items
,'1');
4305 store_IMPPLAN(obj
.IMPPLAN_items
);
4307 $
('#Add_Glasses').on('click', function() {
4308 for (i
=2; i
<6; i++
) { //come on, 5 current rx glasses should be enough...
4309 if ($
('#W_'+i
).val() != '1') {
4310 $
('#W_'+i
).val('1');
4311 $
('#LayerVision_W_'+i
).removeClass('nodisplay');
4312 if (i
==5) { $
('#Add_Glasses').addClass('nodisplay'); }
4317 $
("[name='reverseme']").on('click', function() {
4318 var target
= this
.id
;
4319 reverse_cylinder(target
);
4322 $
('#code_me_now').on('click', function(event
) {
4323 event
.preventDefault();
4324 build_CODING_list();
4325 CODING_to_feesheet(CODING_items
);
4327 $
( ".widget a" ).button();
4329 $
( "button" ).button().on('click', function( event
) {
4330 event
.preventDefault();
4332 $
('#visit_codes').on('change', function() {
4333 var data_all
= $
(this
).val();
4334 var data
= data_all
.match(/^
(.*)\|
(.*)\|
/);
4335 visit_code
= data
[2];
4336 visit_type
= data
[1];
4338 $
('[name="visit_modifier"]').on('click', function () {
4339 var item
= this
.id
.match(/visit_mod_(.*)/)[1];
4340 if ($
(this
).hasClass('status_on')) {
4341 $
(this
).css("background-color","navy");
4342 $
(this
).removeClass('status_on');
4343 visit_modifier
= visit_modifier
.filter(function(e
) { return e
!== item
});
4345 $
(this
).css("background-color","red");
4346 $
(this
).addClass('status_on');
4347 visit_modifier
.push(item
);
4349 build_CODING_list();
4352 $
('[id^="tabs-left-"]').on('click', function () {
4353 var item
= this
.id
.match(/tabs
-left
-(.*)/)[1];
4354 var value
= $
("#setting_"+item
).val();
4356 $
("#setting_"+item
).val('1');
4357 $
(this
).removeClass('ui-state-default');
4358 $
('#'+ item +
'_1').removeClass('nodisplay');
4361 $
("#setting_"+item
).val('0');
4362 $
(this
).addClass('ui-state-default');
4363 $
('#'+ item +
'_1').addClass('nodisplay');
4368 $
(document
).on('change','[name="visit_status"]', function (event
) {
4369 var item
= $
( "input[type=radio][name=visit_status]:checked" ).val();
4370 update_appt_status(item
);
4373 $
(document
).on("click", "[name='visit_justifier']", function () {
4374 var d
= $
(this
).data();
4375 var item
= d
.justcode
;
4376 if ($
(this
).hasClass('status_on')) {
4377 $
(this
).css("background-color","navy");
4378 $
(this
).removeClass('status_on');
4379 visit_justifier
= visit_justifier
.filter(function(e
) { return e
!== item
});
4381 $
(this
).css("background-color","red");
4382 $
(this
).addClass('status_on');
4383 visit_justifier
.push(item
);
4385 build_CODING_list();
4387 $
(document
).on("click", "span[name$='_justifiers']", function () {
4388 var item
= parseInt( this
.id
.match(/_just_(.*)/)[1] ) +
1;
4389 if ($
(this
).hasClass('status_on')) {
4390 $
(this
).css("background-color","navy");
4391 $
(this
).removeClass('status_on');
4393 if ( $
('#visit_just_'+item
).hasClass('status_on') ) {
4394 $
('#visit_just_'+item
).trigger('click');
4396 $
(this
).css("background-color","red");
4397 $
(this
).addClass('status_on');
4398 if (!$
('#visit_mod_25').hasClass("status_on")) {
4399 $
('#visit_mod_25').trigger('click');
4402 build_CODING_list();
4405 build_IMPPLAN(obj
.IMPPLAN_items
);
4407 $
('[id^="BUTTON_TAB_"]').on('click', function () {
4408 var item
= this
.id
.match(/BUTTON_TAB_(.*)/)[1];
4410 $
('#tabs-left-'+item
).addClass('ui-state-default');
4411 $
("#setting_"+item
).val('0');
4412 $
("#"+item+
'_1').addClass('nodisplay');
4413 $
("#tabs_left").removeClass('nodisplay');
4417 $
("input,textarea,text").on("focus", function(){
4418 $
(this
).css("background-color","#ffff99");
4420 //This listener no longer works in tabs because of the new tab wrapper.
4421 $
(window
).bind('onbeforeunload', function(){
4422 alert('Closing time');
4423 if ($
('#chart_status').val()=="on") {