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
, 400, '', '', {
1037 resolvePromiseOn
: 'close',
1040 dialogId
: 'editscripts',
1043 top
.restoreSession();
1048 /* END Functions related to form VIEW */
1051 * Function contains menu commands specific to this form.
1053 function menu_select(zone
) {
1054 $
("#menu_"+zone
).addClass('active');
1055 if (zone
=='PREFERENCES') {
1056 window
.parent
.RTop
.document
.location
.href
= base+
"interface/super/edit_globals.php";
1057 var url
= base+
"/interface/super/edit_globals.php";
1059 'id' : $
('#id').val(),
1060 'encounter' : $
('#encounter').val(),
1061 'pid' : $
('#pid').val(),
1063 top
.restoreSession();
1068 success
: function(result
) {
1069 window
.parent
.RTop
.document
.result
;
1073 if (zone
=='Left_Panel') $
("#left-panel-link").trigger('click');
1074 if (zone
=='Right_Panel') $
("#right-panel-link").trigger('click');
1075 if (zone
=='PRIORS') $
("#PRIORS_ALL_minus_one").trigger("click");
1076 if (zone
=='QP') show_QP();
1077 if (zone
=='KB') show_KB();
1078 if (zone
=='DRAW') show_DRAW();
1079 if (zone
=='TEXT') show_TEXT();
1080 if (zone
=='IOP_graph') $
("#LayerVision_IOP_lightswitch").trigger('click');
1081 if (zone
== "HPI") scrollTo("HPI_left");
1082 if (zone
== "PMH") scrollTo("PMH_left");
1083 if (zone
== "EXT") scrollTo("EXT_left");
1084 if (zone
== "ANTSEG") scrollTo("ANTSEG_left");
1085 if (zone
== "POSTSEG") scrollTo("RETINA_left");
1086 if (zone
== "NEURO") scrollTo("NEURO_left");
1087 if (zone
== "IMPPLAN") scrollTo("IMPPLAN_left");
1092 * Function to test blowing up any section to fullscren - towards tablet functionality?
1093 * Currently not used.
1095 function show_Section(section
) {
1096 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1098 $
("div[name='_sections']").style
.display
= "none"; //
1099 $
('#'+section+
'_sections').style
.display
= "block";
1100 //.show().appendTo('form_container');
1103 * Function to display Chief Complaint 1-3
1105 function show_CC(CC_X
) {
1106 $
("[name^='CC_']").addClass('nodisplay');
1107 $
("#CC_"+CC_X
).removeClass('nodisplay');
1108 $
("#CC_"+CC_X
).index
;
1111 /* START Functions related to CODING */
1114 * Function to determine if add on NeuroSensory(92060) code can be billed.
1116 function check_CPT_92060() {
1119 if ($
("#STEREOPSIS").val() > '') (neuro1
="1");
1120 $
(".neurosens2").each(function(index
) {
1121 if ($
( this
).val() > '') {
1125 if (neuro1
&& neuro2
){
1126 $
("#neurosens_code").removeClass('nodisplay');
1129 $
("#neurosens_code").addClass('nodisplay');
1134 * Function to check documentation level for coding purposes
1135 * And make suggestions to end user.
1137 function check_exam_detail() {
1138 detail_reached_HPI
='0';
1139 chronic_reached_HPI
='0';
1140 $
(".count_HPI").each(function(index
) {
1141 if ($
( this
).val() > '') detail_reached_HPI++
;
1143 if (detail_reached_HPI
> '3') {
1144 $
(".detail_4_elements").css("color","red");
1145 $
(".CODE_LOW").addClass("nodisplay");
1146 $
(".CODE_HIGH").removeClass("nodisplay");
1147 $
(".detailed_HPI").css("color","red");
1149 $
(".detail_4_elements").css("color","#876F6F");
1151 $
(".chronic_HPI").each(function(index
) {
1152 if ($
( this
).val() > '') chronic_reached_HPI++
;
1154 if (chronic_reached_HPI
> '2') {
1155 $
(".chronic_3_elements").css("color","red");
1156 $
(".CODE_LOW").addClass("nodisplay");
1157 $
(".CODE_HIGH").removeClass("nodisplay");
1158 $
(".detailed_HPI").css("color","red");
1160 $
(".chronic_3_elements").css("color","#876F6F");
1162 if ((chronic_reached_HPI
> '2')||
(detail_reached_HPI
> '3')) {
1163 $
(".CODE_LOW").addClass("nodisplay");
1164 $
(".CODE_HIGH").removeClass("nodisplay");
1165 $
(".detailed_HPI").css("color","red");
1166 detail_reached_HPI
= '1';
1168 $
(".CODE_LOW").removeClass("nodisplay");
1169 $
(".CODE_HIGH").addClass("nodisplay");
1170 $
(".detailed_HPI").css("color","#876F6F");
1171 detail_reached_HPI
= '0';
1173 if ((($
("#DIL_RISKS").is(':checked')) ||
($
(".dil_drug").is(':checked'))) && (($
('#ODPERIPH').val() >'') ||
($
('#OSPERIPH').val() >''))) {
1174 $
(".EXAM_LOW").addClass("nodisplay");
1175 $
(".DIL_RISKS").removeClass("nodisplay");
1176 $
("#DIL_RISKS").prop("checked","checked");
1177 detail_reached_exam
= '1';
1179 $
(".EXAM_LOW").removeClass("nodisplay");
1180 $
(".DIL_RISKS").addClass("nodisplay");
1181 detail_reached_exam
= '0';
1183 Suggest_visit_code();
1186 /* END Functions related to CODING */
1188 /* START Functions related to IMPPLAN Builder */
1190 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1191 * Will use actual list from obj.IMPPLAN_items for coding.
1192 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1193 * available to build the Impression/Plan from.
1195 function build_DX_list(obj
) {
1198 $
( "#build_DX_list" ).empty();
1199 //add in inc_FIELDCODES culled from the datafields
1200 if (typeof obj
.PMSFH
=== "undefined") return;
1201 if (typeof obj
.Clinical
=== "undefined") submit_form('obj.clinical is undefined');
1202 if (!obj
.PMSFH
['POH'] && !obj
.PMSFH
['PMH'] && !obj
.Clinical
) {
1203 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 />';
1204 $
( "#build_DX_list" ).html(out
);
1207 build_IMPPLAN(obj
.IMPPLAN_items
);
1208 if ($
('#inc_PE').is(':checked') && obj
.Clinical
) {
1209 $
.each(obj
.Clinical
, function(key
, value
) {
1211 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)
1212 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.Clinical
[key
][0].code+
"</code>";
1214 out +
= "<li class='ui-widget-content'><span name='DX_Clinical_"+key+
"' id='DX_Clinical_"+key+
"'>"+obj
.Clinical
[key
][0].title+
"</span> "+diagnosis+
"</li> ";
1218 if ($
('#inc_POH').is(':checked') && (obj
.PMSFH
['POH']||obj
.PMSFH
['POS'])) {
1219 $
.each(obj
.PMSFH
['POH'], function(key
, value
) {
1221 if (obj
.PMSFH
['POH'][key
].diagnosis
> '' ) {
1222 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POH'][key
].code+
"</code>";
1224 out +
= "<li class='ui-widget-content'><span name='DX_POH_"+key+
"' id='DX_POH_"+key+
"'>"+obj
.PMSFH
['POH'][key
].title+
"</span> "+diagnosis+
"</li>";
1226 $
.each(obj
.PMSFH
['POS'], function(key
, value
) {
1228 if (obj
.PMSFH
['POS'][key
].diagnosis
> '' ) {
1229 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POS'][key
].code+
"</code>";
1231 out +
= "<li class='ui-widget-content'><span name='DX_POS_"+key+
"' id='DX_POS_"+key+
"'>"+obj
.PMSFH
['POS'][key
].title+
"</span> "+diagnosis+
"</li>";
1234 if ($
('#inc_PMH').is(':checked') && obj
.PMSFH
['PMH']) {
1235 $
.each(obj
.PMSFH
['PMH'], function(key
, value
) {
1237 if (obj
.PMSFH
['PMH'][key
].diagnosis
> '') {
1238 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['PMH'][key
].code+
"</code>";
1240 out +
= "<li class='ui-widget-content'><span name='DX_PMH_"+key+
"' id='DX_PMH_"+key+
"'>"+obj
.PMSFH
['PMH'][key
].title+
"</span>"+diagnosis+
"</li> ";
1243 //add in inc_FIELDCODES culled from the datafields
1245 rebuild_IMP($
( "#build_DX_list" ));
1246 $
( "#build_DX_list" )
1247 .html(out
).sortable({ handle
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1248 .selectable({ filter
: "li", cancel
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1250 .addClass( "ui-corner-all ui-selected" )
1251 .dblclick(function(){
1252 rebuild_IMP($
( "#build_DX_list" ));
1253 $
('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1255 //this places the handle for the user to drag the item around.
1256 .prepend( "<div class='handle '><i class='fas fa-arrows-alt fa-1'></i></div>" );
1258 out
= '<br /><span class="bold"><?php echo xlt("Build Your Plan") . "."; ?></span><br /><br />';
1259 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 />';
1260 out +
= '<?php echo xlt('Update the chart to build this
list') . "."; ?><br />';
1261 $
( "#build_DX_list" ).html(out
);
1265 * Function: After the Builder DX list is built from all the available options,
1266 * the end user can select to use only certain Dxs and change their sort order of importance.
1267 * This function builds the list of DXs selected and in the order as the user sorted them,
1268 * so we know what to use to build the Impression/Plan area and in what order to display them.
1270 function rebuild_IMP(obj2
) {
1274 $
( ".ui-selected", obj2
).each(function() {
1275 var index
= $
( "#build_DX_list li" ).index( this
);
1276 if ($
('#build_DX_list li span')[index
].id
.match(/DX_POH_(.*)/)) {
1277 surface
= 'POH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POH_(.*)/)[1];
1278 IMP_order
[k
] = surface
;
1279 }else if ($
('#build_DX_list li span')[index
].id
.match(/DX_POS_(.*)/)) {
1280 surface
= 'POS_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POS_(.*)/)[1];
1281 IMP_order
[k
] = surface
;
1282 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_PMH_(.*)/)) {
1283 surface
= 'PMH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_PMH_(.*)/)[1];
1284 IMP_order
[k
] = surface
;
1285 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_Clinical_(.*)/)) {
1286 surface
= 'CLINICAL_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_Clinical_(.*)/)[1];
1287 IMP_order
[k
] = surface
;
1293 * This function builds the Impression/Plan area using the object supplied: items
1294 * It appends "items" into the Impression Plan area, complete with:
1295 * contenteditable Titles (the Impression),
1296 * its code (if part of the item object),
1297 * Plan textareas (autofilled with the item/object's "comment")
1298 * for each member of "items".
1299 * Duplicates are removed by server.
1301 function build_IMPPLAN(items
,nodisplay
) {
1303 if (typeof nodisplay
== "undefined") {
1304 $
('#IMPPLAN_zone').html("");
1306 $
('#Coding_DX_Codes').html("");
1307 $
('#visit_justification').html("");
1309 if ((items
== null) ||
( (typeof items
== "undefined") ||
(items
.length
=='0') ) ) {
1311 $
('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1312 $
('#IMPPLAN_zone').addClass('nodisplay');
1314 //ok we have at least one item, display them in order; hide the Builder instructions
1315 $
('#IMPPLAN_text').addClass('nodisplay');
1316 $
('#IMPPLAN_zone').removeClass('nodisplay');
1318 visit_justifier
=[];
1319 $
.each(items
, function( index
, value
) {
1320 if (!value
.codetext
) value
.codetext
="";
1321 if (!value
.code
) value
.code
="";
1322 if ((value
.code
==="") ||
(value
.code
.match(/Code
/) ||
(value
.code
==null))) {
1323 value
.code
="<i class='fa fa-search-plus'></i> Code";
1327 if (value
.code
.match(/\
,/g
)) {
1328 // If there is a comma in there, there is more than one code present for this item. Split them out.
1329 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1330 // PMSFH_link is only present when the Builder was used to make the entry.
1332 // So if there is no PMSFH_link and it is not generated from a clinical field:
1333 if ( ((typeof value
.PMSFH_link
!== "undefined") ||
(value
.PMSFH_link
!== null)) && (!value
.PMSFH_link
.match(/Clinical_(.*)/)) ) {
1334 //The Title should have the description.
1335 var CodeArr
= value
.code
.split(",");
1336 var TitleArr
= value
.codedesc
.split("\r");//I don't see a second codedesc being adding in for this yet...
1337 for (i
=0;i
< CodeArr
.length
;i++
) {
1338 if (CodeArr
.length
== (TitleArr
.length
-1)) { //there is a trailing \r but second codedesc should have "\r" also
1339 $
('#Coding_DX_Codes').append(count_dx +
'. '+CodeArr
[i
]+
': '+TitleArr
[i
]+
'<br />');
1341 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>';
1342 $
('#visit_justification').append(justify_btn
);
1343 visit_justifier
.push(value
.codetype+
'|'+value
.code
[i
]);
1345 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1346 $
('#Coding_DX_Codes').append(CodeArr
[i
]+
': <?php echo xlt('Manually retrieve description on Fee Sheet
'); ?> <br />');
1348 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>';
1350 $
('#visit_justification').append(justify_btn
);
1351 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1356 // So there IS a PMSFH_link or it was generated from a clinical field:
1358 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1359 if (value
.PMSFH_link
.match(/Clinical_(.*)/)) {
1360 if (typeof obj
.Clinical
!== "undefined") {
1361 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1362 if (obj
.Clinical
[location
]!=null ) {
1363 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1364 $
('#Coding_DX_Codes').append(count_dx +
'. '+obj
.Clinical
[location
][i
].code+
': '+obj
.Clinical
[location
][i
].codedesc+
'<br />');
1365 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>';
1367 $
('#visit_justification').append(justify_btn
);
1369 visit_justifier
.push(obj
.Clinical
[location
][i
].codetype+
'|'+obj
.Clinical
[location
][i
].code
);
1375 } else { //all is good, one code only
1376 $
('#Coding_DX_Codes').append(count_dx +
'. '+value
.code+
': '+value
.codedesc+
'<br />');
1378 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> ';
1379 $
('#visit_justification').append(justify_btn
);
1380 //we assume the visit code will use this as a justification in billing so activate that link now.
1381 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1385 if (typeof nodisplay
!== "undefined") {
1388 var title2
= value
.title
.replace(/(\')/g
, '');
1389 contents_here
= "<span class='bold' contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+
"'>" +
1390 value
.title +
"</span>"+
1391 " <span contenteditable class='float-right' onclick='sel_diagnosis("+index+
",\""+title2+
"\");' title='"+value
.codetext+
"' id='CODE_"+index+
"'>"+
1392 value
.code +
"</span>"+
1393 "<br /><textarea id='PLAN_"+index+
"' name='PLAN_"+index+
1394 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1395 value
.plan +
"</textarea><br /></li>";
1396 $
('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+
'" class="IMPPLAN_class">'+
1397 '<i class="float-right fa fa-times" id="BUTTON_IMPPLAN_'+index+
'"></i>'+
1398 contents_here+
'</div>');
1399 $
('#BUTTON_IMPPLAN_'+index
).on('click', function() {//delete/close icon
1400 var item
= this
.id
.match(/BUTTON_IMPPLAN_(.*)/)[1];
1401 obj
.IMPPLAN_items
.splice(item
,1);
1402 build_IMPPLAN(obj
.IMPPLAN_items
);
1403 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1405 $
('#PLAN_'+index
).css("background-color","#F0F8FF");
1408 //now attach visit_justifier(s) to each TEST
1409 //If the TEST_justifiers were ever touched AND
1410 $
.each($
(".TESTS_justify"), function( index
, value
) {
1412 var herenow
= $
("#TEST_"+index+
"_justify");
1414 for (var i
= 0, length
= visit_justifier
.length
; i
< length
; i++
) {
1415 item2
= visit_justifier
[i
];
1417 for (var j
=0;j
< CODING_items
.length
; j++
) {
1418 if (CODING_items
[j
].justify
== item2
) {
1422 //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?
1423 justify_btn
= ' <span class="modifier '+status+
'" id="TEST_'+index+
'_just_'+i+
'" name="TEST_'+index+
'_justifiers" value="" data-justcode="'+item2+
'" title="'+item2+
'">'+
(i+
1)+
'</span>';
1424 herenow
.append(justify_btn
);
1428 // The IMPRESSION DXs are "contenteditable" spans.
1429 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1430 $
('[id^=IMPRESSION_]').on('blur', function(e
) {
1432 var item
= this
.id
.match(/IMPRESSION_(.*)/)[1];
1433 var content
= this
.innerText || this
.innerHTML
;
1435 if (pmsfh_here
= obj
.IMPPLAN_items
[item
].PMSFH_link
.match(/(.*)\
_(.*)/)) {
1436 //we are going to change how this appears in PMH too.
1437 var pmsfh_zone
= pmsfh_here
[1];
1438 var pmsfh_item
= pmsfh_here
[2];
1439 obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].title
= content
;
1440 alter_issue2(obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].issue
,pmsfh_zone
,pmsfh_item
);
1443 obj
.IMPPLAN_items
[item
].title
= content
;
1444 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1445 //$(this).css('background-color','#F0F8FF');
1448 $
('[id^=CODE_]').on('blur', function() {
1449 var item
= this
.id
.match(/CODE_(.*)/)[1];
1450 var new_code
= this
.innerText || this
.innerHTML
;
1451 obj
.IMPPLAN_items
[item
].code
= new_code
;
1452 //obj.IMPPLAN_items[item].codetext = '';
1453 //obj.IMPPLAN_items[item].codedesc = '';
1454 $
(this
).css('background-color','#F0F8FF');
1455 store_IMPPLAN(obj
.IMPPLAN_items
);
1458 $
('[id^=PLAN_]').on('change', function() {
1459 var item
= this
.id
.match(/PLAN_(.*)/)[1];
1460 obj
.IMPPLAN_items
[item
].plan
= $
(this
).val();
1461 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1462 $
(this
).css('background-color','#F0F8FF');
1465 $
('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e
){
1466 //$(this).css('height', 'auto' );
1467 // $(this).height( this.scrollHeight );
1469 $
('#IMPPLAN_zone').find( 'textarea' ).keyup();
1470 obj
.IMPPLAN_items
= items
;
1476 * This functions updates a PMSFH item's code on the server via its issue number
1478 function update_PMSFH_code(the_issue
,new_code
){
1479 var url
= "../../forms/eye_mag/save.php?mode=update";
1480 top
.restoreSession();
1485 action
: 'code_PMSFH',
1486 pid
: $
('#pid').val(),
1487 form_id
: $
('#form_id').val(),
1488 encounter
: $
('#encounter').val(),
1489 uniqueID
: $
('#uniqueID').val(),
1493 }).done(function(result
) {
1494 if (result
== 'Code 400') {
1495 code_400(); //the user does not have write privileges!
1503 * This function sends the obj.IMPPLAN_items to the server for storage
1505 function store_IMPPLAN(storage
,nodisplay
) {
1506 if (typeof storage
!== "undefined") {
1507 var url
= "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1508 var formData
= JSON
.stringify(storage
);
1509 top
.restoreSession();
1515 parameter
: formData
,
1516 action
: 'store_IMPPLAN',
1517 pid
: $
('#pid').val(),
1518 form_id
: $
('#form_id').val(),
1519 encounter
: $
('#encounter').val(),
1520 uniqueID
: $
('#uniqueID').val()
1522 }).done(function(result
) {
1523 if (result
== "Code 400") {
1524 code_400(); //the user does not have write privileges!
1527 obj
.IMPPLAN_items
= result
;
1528 // if (typeof nodisplay === "undefined") {
1529 build_IMPPLAN(obj
.IMPPLAN_items
,nodisplay
);
1537 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1540 function CODING_to_feesheet(CODING_items
) {
1541 if (typeof CODING_items
!== "undefined") {
1542 var url
= "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1543 var formData
= JSON
.stringify(CODING_items
);
1544 top
.restoreSession();
1549 'parameter' : formData
,
1550 'action' : 'code_visit',
1551 'pid' : $
('#pid').val(),
1552 'form_id' : $
('#form_id').val(),
1553 'encounter' : $
('#encounter').val(),
1554 'uniqueID' : $
('#uniqueID').val()
1556 }).done(function(result
) {
1557 if (result
== "Code 400") {
1558 code_400(); //the user does not have write privileges!
1561 //$("#goto_fee_sheet").prop('disabled', false);
1562 $
("#goto_fee_sheet").removeClass('nodisplay');
1570 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1571 * This item is appended to the $('#IMPPLAN_zone').
1573 function dragto_IMPPLAN_zone(event
, ui
) {
1574 var findme
= ui
.draggable
.find("span").attr("id");
1575 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1576 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1578 var the_codedesc
='';
1579 var the_codetext
='';
1581 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
1582 if (group
=="Clinical") {
1583 //more than one field can contain this DX.
1584 //Group them into one IMPPLAN.
1585 for (i
=0;i
< obj
.Clinical
[location
].length
; i++
) {
1586 the_code +
= obj
.Clinical
[location
][i
]['code']+
',';
1587 the_codedesc
= obj
.Clinical
[location
][i
]['codedesc'];
1588 the_codetext
= obj
.Clinical
[location
][i
]['codetext'];
1589 the_plan +
= obj
.Clinical
[location
][i
]['codedesc'] +
"\r";
1591 if (i
> 0) the_code
= the_code
.slice(0, -1);
1592 obj
.IMPPLAN_items
.push({
1594 codedesc
: the_codedesc
,
1595 codetext
: the_codetext
,
1596 codetype
: obj
.Clinical
[location
][0]['codetype'],
1598 PMSFH_link
: obj
.Clinical
[location
][0]['PMSFH_link'],
1599 title
: obj
.Clinical
[location
][0]['title']
1603 obj
.IMPPLAN_items
.push({
1604 code
: obj
.PMSFH
[group
][location
]['code'],
1605 codedesc
: obj
.PMSFH
[group
][location
]['codedesc'],
1606 codetext
: obj
.PMSFH
[group
][location
]['codetext'],
1607 codetype
: obj
.PMSFH
[group
][location
]['codetype'],
1608 plan
: obj
.PMSFH
[group
][location
]['comments'],
1609 PMSFH_link
: obj
.PMSFH
[group
][location
]['PMSFH_link'],
1610 title
: obj
.PMSFH
[group
][location
]['title']
1614 store_IMPPLAN(obj
.IMPPLAN_items
); //redisplay the items
1617 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field (#IMP) <-- New Dx textarea
1618 * The data is appended to the end of the text.
1619 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1621 function dragto_IMPPLAN(event
, ui
) {
1622 var findme
= ui
.draggable
.find("span").attr("id");
1623 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1624 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1625 var draggable2
= ui
.draggable
;
1626 if (group
=="Clinical") {
1627 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n");
1629 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n"+obj
.PMSFH
[group
][location
]['comments']);
1632 /* END Functions related to IMPPLAN Builder */
1634 function Suggest_visit_code() {
1635 //assume Eyes and established patient
1636 (Code_group
!= 'Eyes') ?
(digit_2
= '9') : digit_2
= '2'; //920XX or 990XX
1637 (Code_new_est
== 'New') ?
(digit_4
= '0') : digit_4
= '1'; //9X01X or 9X00X
1638 if (detail_reached_exam
=='1' && (detail_reached_HPI
=='1')) {
1639 (Code_group
=='Eyes') ?
(digit_5
= '4') : (digit_5
='3'); //920X4 or 990X3
1640 detailed
= "comprehensive";
1642 digit_5
= '2'; //920X2
1643 detailed
= "intermediate";
1645 visit_desc
= Code_new_est +
" "+ detailed +
" "+digit_5
;
1646 visit_code
= "9"+digit_2+
"0"+digit_4+digit_5
;
1647 $
('#visit_codes').val("CPT4|"+visit_code+
"|").change();
1650 * This function builds the codes and populates the billing table for this encounter.
1652 function build_CODING_list() {
1654 /* the following things get billed:
1655 1. Visit code(s) including neurosensory if performed
1659 //3. Diagnostic Codes
1660 $
.each(obj
.IMPPLAN_items
, function( index
, value
) {
1661 if (value
['codetype']) {
1662 if (value
['code'].match(/\
,/g
)) {
1663 // physical finding found in more than one location, more than one code...
1664 // if there is a comma in there, there is more than one code present. Split them out.
1665 // And all those in one group have the same link out (PMSFH_link) value
1666 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1667 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1669 code
: obj
.Clinical
[location
][i
]['code'],
1670 codedesc
: obj
.Clinical
[location
][i
]['codedesc'],
1671 codetext
: obj
.Clinical
[location
][i
]['codetext'],
1672 codetype
: obj
.Clinical
[location
][i
]['codetype'],
1673 title
: obj
.Clinical
[location
][i
]['title']
1676 } else if (value
['code'].match(/Code
/)){
1680 code
: value
['code'],
1681 codedesc
: value
['codedesc'],
1682 codetext
: value
['codetext'],
1683 codetype
: value
['codetype'],
1684 title
: value
['title']
1690 //1. Visit Codes. These can have a modifier (22,24,25,57 hard coded so far)
1691 var visit_justify
= visit_justifier
.join(":");
1692 if (typeof visit_modifier
!= "object") {
1693 visit_modifiers
= [];
1695 visit_modifiers
= visit_modifier
.join(":");//
1699 codedesc
: visit_desc
,
1702 title
: 'Visit Code',
1703 modifier
: visit_modifiers
,
1704 justify
: visit_justify
1707 if (CPT_92060
== 'here') {
1710 codedesc
: 'Sensorimotor exam',
1711 codetext
: 'Sensorimotor exam (CPT4:92060)',
1713 title
: 'Neuro/Sensorimotor Code',
1714 justify
: visit_justify
1717 //2. Tests/procedures performed to bill
1718 $
('.TESTS').each(function(i
, obj
) {
1719 if ($
(this
).is(':checked')) {
1720 var codetype
= obj
.value
.match(/(.*):(.*)/)[1];
1721 var code
= obj
.value
.match(/(.*):(.*)/)[2];
1722 var modifier
= $
('#'+obj
.id+
'_modifier').val();
1724 $
('[name="TEST_'+i+
'_justifiers"]').each(function(j
,obj2
) {
1725 if ($
('#TEST_'+i+
'_just_'+j
).hasClass('status_on') ) {
1726 var h
= $
(this
).data();
1727 justify
= h
.justcode
;
1730 var d
= $
(this
).data();
1733 'codedesc' : d
.title
,
1734 'codetext' : d
.codetext
,
1735 'codetype' : codetype
,
1737 'modifier' : modifier
,
1745 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1747 function toggle_active_flags(new_state
) {
1748 if (($
("#chart_status").val() == "off") ||
(new_state
== "on")) {
1749 // we are read-only and we want to go active.
1750 $
("#chart_status").val("on");
1751 $
("#active_flag").html(" Active Chart ");
1752 $
("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1753 $
("#warning").addClass("nodisplay");
1754 $
('input, select, textarea, a').removeAttr('disabled');
1755 $
('input, textarea').removeAttr('readonly');
1757 //else clicking this means we want to go from active to read-only
1758 $
("#chart_status").val("off");
1759 $
("#active_flag").html(" READ-ONLY ");
1760 $
("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1761 $
("#warning").removeClass("nodisplay");
1762 //we should tell the form fields to be disabled. should already be...
1763 $
('input, select, textarea, a').attr('disabled', 'disabled');
1764 $
('input, textarea').attr('readonly', 'readonly');
1765 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1766 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1767 this_form_id
= $
("#form_id").val();
1768 $
("#COPY_SECTION").val("READONLY-"+this_form_id
);
1772 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1774 function update_READONLY() {
1776 'action' : 'retrieve',
1777 'copy' : 'READONLY',
1778 'zone' : 'READONLY',
1779 'copy_to' : $
("#form_id").val(),
1780 'copy_from' : $
("#form_id").val(),
1781 'pid' : $
("#pid").val()
1783 //we are going to update the whole form
1784 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1785 //We are not ready to actively chart, just looking to see how far along our staff is...
1786 //or maybe just looking ahead to see the who's being worked up in the next room?
1787 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1788 // yet it is updating every 10-15 seconds if another user is making changes.
1789 top
.restoreSession();
1793 url
: "../../forms/eye_mag/save.php?copy=READONLY",
1795 success
: function(result
) {
1796 $
.map(result
, function(valhere
, keyhere
) {
1797 if ($
("#"+keyhere
).val() != valhere
) {
1798 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
1800 if (keyhere
.match(/MOTILITY_
/)) {
1801 // Copy forward ductions and versions visually
1802 // Make each blank, and rebuild them
1803 $
("[name='"+keyhere+
"_1']").html('');
1804 $
("[name='"+keyhere+
"_2']").html('');
1805 $
("[name='"+keyhere+
"_3']").html('');
1806 $
("[name='"+keyhere+
"_4']").html('');
1807 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
1808 // Show a horizontal (minus) tag.
1809 hash_tag
= '<i class="fa fa-minus"></i>';
1810 } else { //show vertical tag
1811 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
1813 for (index
=1; index
<= valhere
; ++index
) {
1814 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
1816 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
1817 if (valhere
=='1') {
1818 $
("#FieldsNormal").prop('checked', false);
1819 $
("#"+keyhere
).prop('checked', true);
1820 $
("#"+keyhere
).val('1');
1822 $
("#"+keyhere
).val('0');
1823 $
("#"+keyhere
).prop('checked', false);
1825 } else if (keyhere
.match(/AMSLERO(.)/)) {
1826 var sidehere
= keyhere
.match(/AMSLERO(.)/);
1827 if (valhere
< '1') valhere
='0';
1828 $
("#"+keyhere
).val(valhere
);
1829 var srcvalue
="AmslerO"+sidehere
[1];
1830 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
1831 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
1832 } else if (keyhere
.match(/VA$
/)) {
1833 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
1834 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
1835 } else if (keyhere
.match(/^O
.VA_
/)) {
1836 var side
=keyhere
.match(/(O
.)VA_(.)/)[1];
1837 var rx_number
=keyhere
.match(/(O
.)VA_(.)/)[2];
1838 if (rx_number
== '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1839 $
('#'+side+
'VA_1_copy').val(valhere
).css("background-color","#F0F8FF");;
1840 $
('#'+side+
'VA_1_copy_brd').val(valhere
).css("background-color","#F0F8FF");;
1842 } else if (keyhere
.match(/^RX_TYPE_\d$
/)) {
1843 if (typeof $
('input:radio[name='+keyhere+
']')[valhere
] !== "undefined") {
1844 $
('input:radio[name='+keyhere+
']')[valhere
].checked
= true;
1846 } else if (keyhere
.match(/(alert|oriented|confused|PUPIL_NORMAL
)/)) {
1847 if (valhere
=='1') {
1848 $
('#'+keyhere
).val(valhere
).prop('checked', true);
1850 $
('#'+keyhere
).val(valhere
).prop('checked', false);
1856 function dopopup(url
) {
1857 window
.open(url
, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1859 function goto_url(url
) {
1861 top
.restoreSession();
1864 //is this used anywhere? Looks like it should be deleted...
1865 function openImage() {
1866 dlgopen(base+
'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1869 // Called to open a document in another tab for this encounter.
1870 function openDocumentNewTab(doc_id
) {
1871 var url
= '../../interface/patient_file/encounter/view_form.php?formname=' + formdir +
'&id=' + formid
;
1872 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
1873 top
.restoreSession();
1874 location
.href
= url
;
1876 parent
.twAddFrameTab('enctabs', formname
, url
);
1881 function HPI_sync_heights() {
1882 if ( ($
('#PMSFH_block_1').height() > $
('#PMH_left').height() ) ||
1883 ($
('#PMSFH_block_2').height() > $
('#PMH_left').height()) )
1885 if ($
('#PMSFH_block_1').height() > $
('#PMSFH_block_2').height()) {
1886 heights
= $
('#PMSFH_block_1').height();
1888 heights
= $
('#PMSFH_block_2').height();
1890 $
('#PMH_left').height(heights
);
1891 $
('#PMH_right').height(heights
)
1892 $
('#PMH_1').height(heights+
20);
1893 } else if ( $
("#PMH_2").hasClass('nodisplay') ) {
1894 $
('#PMH_1').height($
('#HPI_1').height());
1896 $
('#PMH_1').height($
('#PMH_2').height());
1900 * Keyboard shortcut commands.
1902 const shortcut
= new Set();
1904 shortcut
.add("Control+T",function() {
1907 shortcut
.add("Meta+T",function() {
1910 shortcut
.add("Control+D",function() {
1913 shortcut
.add("Meta+D",function() {
1916 shortcut
.add("Control+P",function() {
1917 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1919 shortcut
.add("Meta+P",function() {
1921 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1923 shortcut
.add("Control+B",function() {
1926 shortcut
.add("Meta+B",function() {
1929 shortcut
.add("Control+K",function() {
1932 shortcut
.add("Meta+K",function() {
1937 * this swallows backspace keys on the "rx" elements.
1938 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1940 var rx
= /INPUT|SELECT|TEXTAREA|SPAN|DIV
/i
;
1942 $
(document
).bind("keydown keypress", function(e
){
1943 if( e
.which
== 8 ){ // 8 == backspace
1944 if(!rx
.test(e
.target
.tagName
) || e
.target
.disabled || e
.target
.readOnly
){
1952 * Function to update the PCP and referring person
1955 function update_DOCS() {
1956 var url
= "../../forms/eye_mag/save.php?mode=update";
1957 top
.restoreSession();
1963 pid
: $
('#pid').val(),
1964 pcp
: $
('#form_PCP').val(),
1965 rDOC
: $
('#form_rDOC').val(),
1966 form_id
: $
('#form_id').val(),
1967 encounter
: $
('#encounter').val(),
1968 uniqueID
: $
('#uniqueID').val()
1970 }).done(function(result
) {
1971 if (result
== "Code 400") {
1972 code_400(); //the user does not have write privileges!
1975 obj
= JSON
.parse(result
);
1981 * Function to update the PCP and Referring Doctors data.
1982 * Initial use: update data returned from an ajax call.
1984 function build_DOCS(DOCS
) {
1986 $
("#pcp_name").html(DOCS
['pcp']['name']);
1987 $
("#pcp_address").html(DOCS
['pcp']['address']);
1988 $
("#pcp_phone").html(DOCS
['pcp']['phone']);
1989 $
("#pcp_phonew2").html(DOCS
['pcp']['phone2']);
1990 $
("#pcp_fax").html(DOCS
['pcp']['fax']);
1991 $
("#pcp_fax_info").html(DOCS
['pcp']['fax_info']);
1993 $
("#pcp_name").html('');
1994 $
("#pcp_address").html('');
1995 $
("#pcp_phone").html('');
1996 $
("#pcp_phonew2").html('');
1997 $
("#pcp_fax").html('');
1998 $
("#pcp_fax_info").html('');
2001 $
("#ref_name").html(DOCS
['ref']['name']);
2002 $
("#ref_address").html(DOCS
['ref']['address']);
2003 $
("#ref_phone").html(DOCS
['ref']['phone']);
2004 $
("#ref_phonew2").html(DOCS
['ref']['phonew2']);
2005 $
("#ref_fax").html(DOCS
['ref']['fax']);
2006 $
("#ref_fax_info").html(DOCS
['ref']['fax_info']);
2008 $
("#ref_name").html('');
2009 $
("#ref_address").html('');
2010 $
("#ref_phone").html('');
2011 $
("#ref_phonew2").html('');
2012 $
("#ref_fax").html('');
2013 $
("#ref_fax_info").html('');
2018 * Function to update the patient's current pharmacy
2021 function update_Pharma() {
2022 //$(#form_pharmacy_id) has changed value, update the patient_data field pharmacy_id
2023 var pharm
= $
("#form_pharmacy_id").val();
2024 var url
= "../../forms/eye_mag/save.php?mode=update";
2025 top
.restoreSession();
2030 action
: 'new_pharmacy',
2031 pid
: $
('#pid').val(),
2032 form_id
: $
('#form_id').val(),
2033 encounter
: $
('#encounter').val(),
2034 uniqueID
: $
('#uniqueID').val(),
2035 pc_eid
: $
("#pc_eid").val(),
2036 visit_date
: $
("#visit_date").val(),
2037 new_pharmacy
: pharm
2039 }).done(function(result
) {
2040 if (result
== "Code 400") {
2041 code_400(); //the user does not have write privileges!
2049 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
2052 function reverse_cylinder(target
) {
2053 //target can be revW1-5,AR,MR,CR,CTL,
2056 if (target
.match(/^
(AR|MR|CR|CTL
)$
/)) {
2060 if (target
.match(/^revW
[1-5]{1}$
/)) { //matches on digit only, here 1-5
2061 target
= target
.replace("revW","");
2063 suffix
= '_'+target
;
2065 var Rsph
= $
('#'+prefix+
'ODSPH'+suffix
).val();
2066 var Rcyl
= $
('#'+prefix+
'ODCYL'+suffix
).val();
2067 var Raxis
= $
('#'+prefix+
'ODAXIS'+suffix
).val();
2068 var Lsph
= $
('#'+prefix+
'OSSPH'+suffix
).val();
2069 var Lcyl
= $
('#'+prefix+
'OSCYL'+suffix
).val();
2070 var Laxis
= $
('#'+prefix+
'OSAXIS'+suffix
).val();
2071 if (Rsph
=='' && Rcyl
=='' && Lsph
=='' && lcyl
=='') return;
2072 if ((!Rcyl
.match(/SPH
/i
)) && (Rcyl
>'')) {
2073 if (Rsph
.match(/plano
/i
)) Rsph
='0';
2074 Rsph
= Number(Rsph
);
2075 Rcyl
= Number(Rcyl
);
2076 Rnewsph
= Rsph + Rcyl
;
2077 if (Rnewsph
==0) Rnewsph
="PLANO";
2078 Rnewcyl
= Rcyl
* -1;
2079 if (Rnewcyl
> 0) Rnewcyl
= "+"+Rnewcyl
;
2080 if (parseInt(Raxis
) < 90) {
2081 Rnewaxis
= parseInt(Raxis
) +
90;
2083 Rnewaxis
= parseInt(Raxis
) - 90;
2085 if (Rnewcyl
=='0') Rnewcyl
= "SPH";
2086 if (Rnewsph
=='0') {
2088 if (Rnewcyl
=="SPH") Rnewcyl
= '';
2090 $
('#'+prefix+
'ODSPH'+suffix
).val(Rnewsph
);
2091 $
('#'+prefix+
'ODCYL'+suffix
).val(Rnewcyl
);
2092 $
('#'+prefix+
'ODAXIS'+suffix
).val(Rnewaxis
);
2093 $
('#'+prefix+
'ODAXIS'+suffix
).trigger('blur');
2094 $
('#'+prefix+
'ODSPH'+suffix
).trigger('blur');
2095 $
('#'+prefix+
'ODCYL'+suffix
).trigger('blur');
2097 if ((!Lcyl
.match(/SPH
/i
)) && (Lcyl
>'')) {
2098 if (!Lsph
.match(/\d
/)) Lsph
='0';
2099 Lsph
= Number(Lsph
);
2100 Lcyl
= Number(Lcyl
);
2101 Lnewsph
= Lsph + Lcyl
;
2102 Lnewcyl
= Lcyl
* -1;
2103 if (Lnewcyl
> 0) Lnewcyl
= "+"+ Lnewcyl
;
2104 if (parseInt(Laxis
) < 90) {
2105 Lnewaxis
= parseInt(Laxis
) +
90;
2107 Lnewaxis
= parseInt(Laxis
) - 90;
2110 if (Lnewcyl
=='0') Lnewcyl
= "SPH";
2111 if (Lnewsph
=='0') {
2113 if (Lnewcyl
=="SPH") Lnewcyl
= '';
2116 $
('#'+prefix+
'OSSPH'+suffix
).val(Lnewsph
);
2117 $
('#'+prefix+
'OSCYL'+suffix
).val(Lnewcyl
);
2118 $
('#'+prefix+
'OSAXIS'+suffix
).val(Lnewaxis
);
2119 $
('#'+prefix+
'OSAXIS'+suffix
).trigger('blur');
2120 $
('#'+prefix+
'OSSPH'+suffix
).trigger('blur');
2121 $
('#'+prefix+
'OSCYL'+suffix
).trigger('blur');
2124 function scrollTo(target
) {
2126 var scrollSpeed
= 500;
2127 var wheight
= $
(window
).height();
2128 offset
= $
("#"+target
).offset().top
- (wheight
/ 2)+
200;
2129 if (offset
> (window
.pageYOffset +
150)||offset
< (window
.pageYOffset
-150)) {
2130 $
('html, body').animate({scrollTop
:offset
}, scrollSpeed
);
2134 function update_appt_status(new_status
) {
2135 var url
= "../../forms/eye_mag/save.php?mode=update";
2136 top
.restoreSession();
2141 action
: 'new_appt_status',
2142 pid
: $
('#pid').val(),
2143 form_id
: $
('#form_id').val(),
2144 encounter
: $
('#encounter').val(),
2145 uniqueID
: $
('#uniqueID').val(),
2146 pc_eid
: $
("#pc_eid").val(),
2147 visit_date
: $
("#visit_date").val(),
2148 new_status
: new_status
2150 }).done(function(result
) {
2151 if (result
== "Code 400") {
2152 code_400(); //the user does not have write privileges!
2157 function color_IOP(IOP
){
2158 if (!$
.isNumeric(IOP
.value
)) return;
2159 if (IOP
.value
> '21') {
2160 $
(IOP
).css("background-color","rgb(255, 153, 153)");
2163 function showpnotes(docid
) {
2164 let btnClose
= 'Done';
2165 let url
= base+
'/interface/patient_file/summary/pnotes.php?docid=' +
encodeURIComponent(docid
);
2166 dlgopen(url
, 'pno1', 'modal-xl', 500, '', '', {
2168 {text
: btnClose
, close
: true, style
: 'default btn-sm'}
2178 function getTimeStamp() {
2179 var now
= new Date();
2180 var AMPM
= now
.getHours() >= 12 ?
'PM' : 'AM';
2181 return now
.getHours() +
':' +
((now
.getMinutes() < 10) ?
("0" + now
.getMinutes()) : (now
.getMinutes())) + AMPM
;
2185 * This function is only run onload to hide sections per user preference.
2186 * Any changes during the encounter to display or hide a section are stored
2187 * as a previous setting and the next eye form opened will appear the same way.
2189 function show_by_setting() {
2190 var tabs_left
= $
("#setting_tabs_left").val();
2191 if (typeof tabs_left
==undefined
) exit;
2192 var arrSet
= ["HPI","PMH","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2193 sLen
= arrSet
.length
;
2194 for (i
= 0; i
< sLen
; i++
) {
2195 var value
= $
("#setting_"+arrSet
[i
]).val();
2196 if (typeof value
!== undefined
&& value
!='1') {
2197 $
('#tabs-left-'+arrSet
[i
]).addClass('ui-state-default');
2198 $
("#setting_"+arrSet
[i
]).val('0');
2199 $
("#"+arrSet
[i
]+
'_1').addClass('nodisplay');
2200 $
("#setting_"+arrSet
[i
]).val('0');
2202 $
("#setting_"+arrSet
[i
]).val('1');
2205 if (tabs_left
== '0') {
2206 $
("#tabs_left").addClass('nodisplay');
2208 $
("#tabs_left").removeClass('nodisplay');
2217 var allPanels
= $
('.building_blocks > dd').hide();
2218 var allPanels2
= $
('.building_blocks2 > dd').hide();
2221 // AUTO- CODING FEATURES
2223 check_exam_detail();
2226 //alert('Suggest a Code');
2227 Suggest_visit_code();
2228 show_QP_section('IMPPLAN','1');
2231 //on checking TESTS, show modifiers and justifier fields
2232 $
(".TESTS").on("click", function() {
2233 var test_id
= this
.id
;
2234 if ($
(this
).is(':checked')) {
2235 $
("#"+test_id+
"_justmods").removeClass('nodisplay');
2236 $
("#"+test_id+
"_modifier").val('59');
2237 //make vist_modifier 25 light up too...
2238 $
(this
).parent().removeClass('lights_off').addClass('lights_on');
2240 $
("#"+test_id+
"_justmods").addClass('nodisplay');
2241 $
(this
).parent().removeClass('lights_on').addClass('lights_off');
2245 $
('[title]').tooltip();
2246 $
('#form_PCP,#form_rDOC').on('change', function() {
2250 $
("#form_pharmacy_id").change(function() {
2254 $
('#tooltips_status').html($
('#PREFS_TOOLTIPS').val());
2255 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
2256 $
('[title]').each(function() {
2257 var $this = $
(this
);
2258 $this.data('title',$this.attr('title'));
2259 $this.attr('title', '');
2262 $
('#tooltips_toggle,#tooltips_status').on('click', function() {
2263 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
2264 $
('#PREFS_TOOLTIPS').val('<?php echo xla('Off
'); ?>');
2265 $
("#tooltips_status").html('<?php echo xla('are off
'); ?>');
2266 $
('[title]').each(function() {
2267 var $this = $
(this
);
2268 $this.data('title',$this.attr('title'));
2269 $this.attr('title', '');
2272 $
('#PREFS_TOOLTIPS').val('<?php echo xla('On
'); ?>');
2273 $
('#tooltips_status').html('<?php echo xla('are on
'); ?>');
2274 $
('[title]').each(function() {
2275 var $this = $
(this
);
2276 $this.attr('title', $this.data('title'));
2281 $
('#toggle_drugs').on('click', function(){
2282 $
('.hideme_drugs').toggleClass('nodisplay');
2283 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2286 $
('#toggle_VFs').on('click', function(){
2287 $
('.hideme_VFs').toggleClass('nodisplay');
2288 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2291 $
('#toggle_OCTs').on('click', function(){
2292 $
('.hideme_OCTs').toggleClass('nodisplay');
2293 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2296 $
('#toggle_cups').on('click', function(){
2297 $
('.hideme_cups').toggleClass('nodisplay');
2298 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2301 $
('#toggle_gonios').on('click', function(){
2302 $
('.hideme_gonios').toggleClass('nodisplay');
2303 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2306 $
('.close').on('click', function(){
2307 $
('#GFS_accordion .hide').slideUp();
2309 $
('#ODIOPTARGET').on('change', function() {
2310 $
('#OSIOPTARGET').val($
('#ODIOPTARGET').val());
2313 $
('#ODIOPAP,#OSIOPAP,#ODIOPTARGET,#ODIOPTPN,#OSIOPTPN,#OSIOPTARGET').on('change', function() {
2314 //this is failing if there is no config_by_day variable.
2317 if ($
("#PREFS_KB").val() =='1') {
2318 $
(".kb").removeClass('nodisplay');
2319 $
(".kb_off").addClass('nodisplay');
2321 $
(".kb").addClass('nodisplay');
2322 $
(".kb_off").removeClass('nodisplay');
2325 $
("[name$='_kb']").on('click', function() {
2326 $
('.kb').toggleClass('nodisplay');
2327 $
('.kb_off').toggleClass('nodisplay');
2328 $
('.copier').toggleClass('nodisplay');
2329 if ($
('#PREFS_EXAM').val() == 'DRAW') {
2333 if ($
("#PREFS_KB").val() > 0) {
2334 $
("#PREFS_KB").val('0');
2336 $
("#PREFS_KB").val('1');
2340 $
('.ke').on('mouseover', function() {
2341 $
(this
).toggleClass('yellow');
2343 $
('.ke').on('mouseout', function() {
2344 $
(this
).toggleClass('yellow');
2346 $
("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e
) {
2347 //this is the Shorthand engine's ignition
2348 if (e
.which
== 13|| e
.keyCode
== 13||e
.which
== 9|| e
.keyCode
== 9) {
2350 var data_all
= $
(this
).val();
2351 var data_seg
= data_all
.match(/([^
;]*)/gm
);
2355 for (index
=0; index
< data_seg
.length
; ++index
) {
2356 if (data_seg
[index
] =='') continue;
2357 data_seg
[index
] = data_seg
[index
].replace(/^
[\n\v\f\r\x85\u2028\u2029\W
]*/
,'');
2358 data_seg
[index
] = data_seg
[index
].replace(/^
[\s
]*/
,'');
2359 if (data_seg
[index
].match(/^
D($|
;)/i
)) {
2360 $
("#EXT_defaults").trigger("click");
2361 $
("#ANTSEG_defaults").trigger("click");
2362 $
("#RETINA_defaults").trigger("click");
2363 $
("#NEURO_defaults").trigger("click");
2366 if (data_seg
[index
].match(/^
DEXT($|
;)/i
)) {
2367 $
("#EXT_defaults").trigger("click");
2370 if (data_seg
[index
].match(/^
DANTSEG($|
;)/i
)) {
2371 $
("#ANTSEG_defaults").trigger("click");
2374 if (data_seg
[index
].match(/^
DAS($|
;)/i
)) {
2375 $
("#ANTSEG_defaults").trigger("click");
2378 if (data_seg
[index
].match(/^
DRETINA($|
;)/i
)) {
2379 $
("#RETINA_defaults").trigger("click");
2382 if (data_seg
[index
].match(/^
DRET($|
;)/i
)) {
2383 $
("#RETINA_defaults").trigger("click");
2386 if (data_seg
[index
].match(/^
DNEURO($|
;)/i
)) {
2387 $
("#NEURO_defaults").trigger("click");
2390 if ((data_seg
[index
].match(/^
CLEAREXT($|
;)/i
))||
2391 (data_seg
[index
].match(/^
CEXT($|
;)/i
))) {
2395 if ((data_seg
[index
].match(/^
CLEARAS($|
;)/i
))||
2396 (data_seg
[index
].match(/^
CLEARANTSEG($|
;)/i
))||
2397 (data_seg
[index
].match(/^
CANTSEG($|
;)/i
))||
2398 (data_seg
[index
].match(/^
CANT($|
;)/i
))||
2399 (data_seg
[index
].match(/^
CAS($|
;)/i
))) {
2400 $
(".ANTSEG").val('');
2403 if ((data_seg
[index
].match(/^
CLEARRET($|
;)/i
))||
2404 (data_seg
[index
].match(/^
CRET($|
;)/i
)) ||
2405 (data_seg
[index
].match(/^
CLEARRETINA($|
;)/i
))||
2406 (data_seg
[index
].match(/^
CRETINA($|
;)/i
))) {
2407 $
(".RETINA").val('');
2412 var data
= data_seg
[index
].match(/^
(\w
*)\
:?
(.*)/);
2413 (data
[2].match(/\
.a$
/))?
(data
[2] = data
[2].replace(/\
.a$
/,'')):(appendix
= "nope");
2414 var field
= data
[1].toUpperCase();
2416 text
= expand_vocab(text
);
2417 priors
= process_kb(field
,text
,appendix
,prior_field
,prior_text
);
2418 prior_field
= priors
['field'];
2419 prior_text
= priors
['prior_text'];
2427 $
("[id^='sketch_tools_']").click(function() {
2428 var zone
= this
.id
.match(/sketch_tools_(.*)_
/)[1];
2429 $
("[id^='sketch_tools_"+zone+
"']").css("height","30px");
2430 $
(this
).css("height","50px");
2431 $
("#sketch_tool_"+zone+
"_color").css("background-image","").css("background-color",$
("#selColor_"+zone
).val());
2433 $
("[id^='sketch_sizes_']").click(function() {
2434 var zone
= this
.id
.match(/sketch_sizes_(.*)_
/)[1];
2435 $
("[id^='sketch_sizes_"+zone+
"']").css("background","").css("border-bottom","");
2436 $
(this
).css("border-bottom","2pt solid black");
2440 // Here we get CC1 to show
2441 $
(".tab_content").addClass('nodisplay');
2442 $
("#tab1_CC_text").removeClass('nodisplay');
2443 $
("#tab1_HPI_text").removeClass('nodisplay');
2444 $
("[id$='_CC'],[id$='_HPI_tab']").on('click', function() {
2445 // First remove class "active" from currently active tabs
2446 $
("[id$='_CC']").removeClass('active');
2447 $
("[id$='_HPI_tab']").removeClass('active');
2448 // Hide all tab content
2449 $
(".tab_content").addClass('nodisplay');
2450 // Here we get the href value of the selected tab
2451 var selected_tab
= $
(this
).find("a").attr("href");
2452 // Now add class "active" to the selected/clicked tab and content
2453 $
(selected_tab+
"_CC").addClass('active');
2454 $
(selected_tab+
"_CC_text").removeClass('nodisplay');
2455 $
(selected_tab+
"_HPI_tab").addClass('active');
2456 $
(selected_tab+
"_HPI_text").removeClass('nodisplay');
2457 // At the end, we add return false so that the click on the link is not executed
2460 $
("input,textarea,text").css("background-color","#FFF8DC");
2461 $
("[id*=ODIOP],[id*=OSIOP]").each(function() { color_IOP(this
); });
2462 $
("#IOPTIME").css("background-color","#FFFFFF");
2463 $
("#refraction_width").css("width","8.5in");
2464 $
(".Draw_class").addClass('nodisplay');
2465 $
(".PRIORS_class").addClass('nodisplay');
2466 $
(window
).on("resize", function() {
2467 if (window
.innerWidth
>'900') {
2468 $
("#refraction_width").css("width","900px");
2469 $
("#LayerVision2").css("padding","4px");
2471 if (window
.innerWidth
>'1300') {
2472 $
("#refraction_width").css("width","1300px");
2473 //$("#first").css("width","1300px");
2475 if (window
.innerWidth
>'1900') {
2476 $
("#refraction_width").css("width","1600px");
2482 var hash_tag
= '<i class="fa fa-minus"></i>';
2484 // display any stored MOTILITY values
2485 $
("#MOTILITY_RS").value
= parseInt($
("#MOTILITY_RS").val());
2486 if ($
("#MOTILITY_RS").val() > '0') {
2487 $
("#MOTILITYNORMAL").removeAttr('checked');
2488 for (index
=1; index
<= ($
("#MOTILITY_RS").val()); ++index
) {
2489 $
("#MOTILITY_RS_"+index
).html(hash_tag
);
2492 $
("#MOTILITY_RI").value
= parseInt($
("#MOTILITY_RI").val());
2493 if ($
("#MOTILITY_RI").val() > '0') {
2494 $
("#MOTILITYNORMAL").removeAttr('checked');
2495 for (index
=1; index
<= ($
("#MOTILITY_RI").val()); ++index
) {
2496 $
("#MOTILITY_RI_"+index
).html(hash_tag
);
2499 $
("#MOTILITY_LS").value
= parseInt($
("#MOTILITY_LS").val());
2500 if ($
("#MOTILITY_LS").val() > '0') {
2501 $
("#MOTILITYNORMAL").removeAttr('checked');
2502 for (index
=1; index
<= ($
("#MOTILITY_LS").val()); ++index
) {
2503 $
("#MOTILITY_LS_"+index
).html(hash_tag
);
2506 $
("#MOTILITY_LI").value
= parseInt($
("#MOTILITY_LI").val());
2507 if ($
("#MOTILITY_LI").val() > '0') {
2508 $
("#MOTILITYNORMAL").removeAttr('checked');
2509 for (index
=1; index
<= ($
("#MOTILITY_LI").val()); ++index
) {
2510 $
("#MOTILITY_LI_"+index
).html(hash_tag
);
2514 $
("#MOTILITY_RRSO").value
= parseInt($
("#MOTILITY_RRSO").val());
2515 if ($
("#MOTILITY_RRSO").val() > '0') {
2516 $
("#MOTILITYNORMAL").removeAttr('checked');
2517 for (index
=1; index
<= ($
("#MOTILITY_RRSO").val()); ++index
) {
2518 $
("#MOTILITY_RRSO_"+index
).html(hash_tag
);
2521 $
("#MOTILITY_RRIO").value
= parseInt($
("#MOTILITY_RRIO").val());
2522 if ($
("#MOTILITY_RRIO").val() > '0') {
2523 $
("#MOTILITYNORMAL").removeAttr('checked');
2524 for (index
=1; index
<= ($
("#MOTILITY_RRIO").val()); ++index
) {
2525 $
("#MOTILITY_RRIO_"+index
).html(hash_tag
);
2528 $
("#MOTILITY_RLIO").value
= parseInt($
("#MOTILITY_RLIO").val());
2529 if ($
("#MOTILITY_RLIO").val() > '0') {
2530 $
("#MOTILITYNORMAL").removeAttr('checked');
2531 for (index
=1; index
<= ($
("#MOTILITY_RLIO").val()); ++index
) {
2532 $
("#MOTILITY_RLIO_"+index
).html(hash_tag
);
2535 $
("#MOTILITY_RLSO").value
= parseInt($
("#MOTILITY_RLSO").val());
2536 if ($
("#MOTILITY_RLSO").val() > '0') {
2537 $
("#MOTILITYNORMAL").removeAttr('checked');
2538 for (index
=1; index
<= ($
("#MOTILITY_RLSO").val()); ++index
) {
2539 $
("#MOTILITY_RLSO_"+index
).html(hash_tag
);
2542 $
("#MOTILITY_LRSO").value
= parseInt($
("#MOTILITY_LRSO").val());
2543 if ($
("#MOTILITY_LRSO").val() > '0') {
2544 $
("#MOTILITYNORMAL").removeAttr('checked');
2545 for (index
=1; index
<= ($
("#MOTILITY_LRSO").val()); ++index
) {
2546 $
("#MOTILITY_LRSO_"+index
).html(hash_tag
);
2549 $
("#MOTILITY_LRIO").value
= parseInt($
("#MOTILITY_LRIO").val());
2550 if ($
("#MOTILITY_LRIO").val() > '0') {
2551 $
("#MOTILITYNORMAL").removeAttr('checked');
2552 for (index
=1; index
<= ($
("#MOTILITY_LRIO").val()); ++index
) {
2553 $
("#MOTILITY_LRIO_"+index
).html(hash_tag
);
2556 $
("#MOTILITY_LLSO").value
= parseInt($
("#MOTILITY_LLSO").val());
2557 if ($
("#MOTILITY_LLSO").val() > '0') {
2558 $
("#MOTILITYNORMAL").removeAttr('checked');
2559 for (index
=1; index
<= ($
("#MOTILITY_LLSO").val()); ++index
) {
2560 $
("#MOTILITY_LLSO_"+index
).html(hash_tag
);
2563 $
("#MOTILITY_LLIO").value
= parseInt($
("#MOTILITY_LLIO").val());
2564 if ($
("#MOTILITY_LLIO").val() > '0') {
2565 $
("#MOTILITYNORMAL").removeAttr('checked');
2566 for (index
=1; index
<= ($
("#MOTILITY_LLIO").val()); ++index
) {
2567 $
("#MOTILITY_LLIO_"+index
).html(hash_tag
);
2571 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
2572 $
("#MOTILITY_LR").value
= parseInt($
("#MOTILITY_LR").val());
2573 if ($
("#MOTILITY_LR").val() > '0') {
2574 $
("#MOTILITYNORMAL").removeAttr('checked');
2575 for (index
=1; index
<= ($
("#MOTILITY_LR").val()); ++index
) {
2576 $
("#MOTILITY_LR_"+index
).html(hash_tag
);
2579 $
("#MOTILITY_LL").value
= parseInt($
("#MOTILITY_LL").val());
2580 if ($
("#MOTILITY_LL").val() > '0') {
2581 $
("#MOTILITYNORMAL").removeAttr('checked');
2582 for (index
=1; index
<= ($
("#MOTILITY_LL").val()); ++index
) {
2583 $
("#MOTILITY_LL_"+index
).html(hash_tag
);
2586 $
("#MOTILITY_RR").value
= parseInt($
("#MOTILITY_RR").val());
2587 if ($
("#MOTILITY_RR").val() > '0') {
2588 $
("#MOTILITYNORMAL").removeAttr('checked');
2589 for (index
=1; index
<= ($
("#MOTILITY_RR").val()); ++index
) {
2590 $
("#MOTILITY_RR_"+index
).html(hash_tag
);
2593 $
("#MOTILITY_RL").value
= parseInt($
("#MOTILITY_RL").val());
2594 if ($
("#MOTILITY_RL").val() > '0') {
2595 $
("#MOTILITYNORMAL").removeAttr('checked');
2596 for (index
=1; index
<= ($
("#MOTILITY_RL").val()); ++index
) {
2597 $
("#MOTILITY_RL_"+index
).html(hash_tag
);
2601 $
(".chronic_HPI,.count_HPI").on("blur", function() {
2602 check_exam_detail();
2605 $
("#DIL_RISKS").on('change', function(o
) {
2606 ($
(this
).is(':checked')) ?
($
(".DIL_RISKS").removeClass("nodisplay")) : ($
(".DIL_RISKS").addClass("nodisplay"));
2607 check_exam_detail();
2609 $
(".dil_drug").on('change', function(o
) {
2610 if ($
(this
).is(':checked')) {
2611 $
("#DIL_RISKS").prop("checked","checked");
2612 check_exam_detail();
2613 var timestamp
= getTimeStamp();
2614 $
("#DIL_MEDS").val(timestamp
);
2617 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2618 $
(".neurosens,.neurosens2").on("blur", function() {
2622 // functions to improve flow of refraction input
2623 $
("input[name$='PRISM'],input[class^='prism']").on("blur", function() {
2625 var str
= $
(this
).val();
2626 str
= str
.toUpperCase();
2629 $
('input[class^="sphere"],input[name$="SPH"]').on("blur", function() {
2630 var mid
= $
(this
).val();
2631 if (mid
.match(/PLANO
/i
)) {
2632 $
(this
).val('PLANO');
2635 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2638 if (mid
.match(/\
.[27]$
/)) {
2641 if (mid
.match(/\
.\d$
/)) {
2644 //if near is +2. make it +2.00
2645 if (mid
.match(/\
.$
/)) {
2648 if ((!mid
.match(/\
./))&&(mid
.match(00|
25|
50|
75))) {
2649 var front
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[1];
2650 var back
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[2];
2651 if (front
=='') front
='0';
2652 mid
= front +
"." + back
;
2654 if (!mid
.match(/\
./)) {
2655 var front
= mid
.match(/([\+\
-]?\d
{0,2})(\d
{2})/)[1];
2656 var back
= mid
.match(/(\d
{0,2})(\d
{2})/)[2];
2657 if (front
=='') front
='0';
2658 if (front
=='-') front
='-0';
2659 mid
= front +
"." + back
;
2661 if (!mid
.match(/^
(\+|\
-){1}/)) {
2667 $
("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").on("blur", function() {
2668 var add
= $
(this
).val();
2669 add
= add
.replace(/=/g
,"+");
2670 //if add is one digit, eg. 2, make it +2.00
2671 if (add
.match(/^\d
{1}$
/)) {
2672 add
= "+"+add+
".00";
2674 //if add is '+'one digit, eg. +2, make it +2.00
2675 if (add
.match(/^\+\d
{1}$
/)) {
2678 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2679 if (add
.match(/\
.[05]$
/)) {
2682 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2683 if (add
.match(/\
.[27]$
/)) {
2686 //if add is +2. make it +2.00
2687 if (add
.match(/\
.$
/)) {
2690 if ((!add
.match(/\
./))&&(add
.match(/(0|
25|
50|
75)$
/))) {
2691 var front
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[1];
2692 var back
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[2];
2693 if (front
=='') front
='0';
2694 add
= front +
"." + back
;
2696 if (!add
.match(/^
(\+
)/) && (add
.length
> 0)) {
2700 if (this
.id
=="ODADD_1") $
('#OSADD_1').val(add
);
2701 if (this
.id
=="ODMIDADD_1") $
('#OSMIDADD_1').val(add
);
2702 if (this
.id
=="ODADD_2") $
('#OSADD_2').val(add
);
2703 if (this
.id
=="ODMIDADD_2") $
('#OSMIDADD_2').val(add
);
2704 if (this
.id
=="ODADD_3") $
('#OSADD_3').val(add
);
2705 if (this
.id
=="ODMIDADD_3") $
('#OSMIDADD_3').val(add
);
2706 if (this
.id
=="ODADD_4") $
('#OSADD_4').val(add
);
2707 if (this
.id
=="ODMIDADD_4") $
('#OSMIDADD_4').val(add
);
2708 if (this
.id
=="ODADD_5") $
('#OSADD_5').val(add
);
2709 if (this
.id
=="ODMIDADD_5") $
('#OSMIDADD_5').val(add
);
2710 if (this
.id
=="MRODADD") $
('#MROSADD').val(add
);
2711 if (this
.id
=="ARODADD") $
('#AROSADD').val(add
);
2712 if (this
.id
=="CTLODADD") $
('#CTLOSADD').val(add
);
2715 $
("input[class^='axis'],input[name$='AXIS']").on("blur", function() {
2716 // Make this a 3 digit leading zeros number.
2717 // we are not translating text to numbers, just numbers to
2718 // a 3 digit format with leading zeroes as needed.
2719 // assume the end user KNOWS there are only numbers presented and
2720 // more than 3 digits is a mistake...
2721 // (although this may change with topography)
2722 var axis
= $
(this
).val();
2723 if (this
.name
.match(/K2AXIS
/)) {
2724 var group
= this
.name
.replace("AXIS", "");
2726 var group
= this
.name
.replace("AXIS", "CYL");
2728 var cyl
= $
("#"+group
).val();
2729 if ( (cyl
> '') && (cyl
!= 'SPH') ) {
2730 if (!axis
.match(/\d\d\d
/)) {
2731 if (!axis
.match(/\d\d
/)) {
2732 if (!axis
.match(/\d
/)) {
2742 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2743 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2744 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2748 $
("input[class^='cylinder'],input[name$='CYL']").on("blur", function() {
2749 var mid
= $
(this
).val();
2750 var group
= this
.name
.replace("CYL", "SPH");;
2751 var sphere
= $
("#"+group
).val();
2752 if (((mid
.length
== 0) && (sphere
.length
> 0))||
(mid
.match(/sph
/i
))) {
2754 if (sphere
.match(/plano
/i
)) $
(this
).val('');
2755 var axis
= this
.name
.replace("CYL", "AXIS");
2756 $
("#"+axis
).val('');
2757 submit_form($
(this
));
2759 } else if (sphere
.length
> 0) {
2760 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2763 if (mid
.match(/^
(\d
)(\d
)$
/)) {
2764 mid
= mid
[0] +
'.' +mid
[1];
2767 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2768 if (mid
.match(/\
.[05]$
/)) {
2771 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2772 if (mid
.match(/\
.[27]$
/)) {
2775 //if mid is +2. make it +2.00
2776 if (mid
.match(/\
.$
/)) {
2779 if (mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)) {
2780 var front
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[1];
2781 var back
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[2];
2782 if (front
=='') front
='0';
2783 mid
= front +
"." + back
;
2785 if (!$
('#PREFS_CYL').val()) {
2786 $
('#PREFS_CYL').val('+');
2789 if (!mid
.match(/^
(\+|\
-){1}/) && (sphere
.length
> 0)) {
2790 //no +/- sign at the start of the field.
2791 //ok so there is a preference set
2792 //Since it doesn't start with + or - then give it the preference value
2793 mid
= $
('#PREFS_CYL').val() + mid
;
2794 } else if (mid
.match(/^
(\+|\
-){1}/)) {
2795 pref
= mid
.match(/^
(\+|\
-){1}/)[0];
2796 //so they used a value + or - at the start of the field.
2797 //The only reason to work on this is to change to cylinder preference
2798 if ($
('#PREFS_CYL').val() != pref
){
2799 //and that is what they are doing here
2800 $
('#PREFS_CYL').val(pref
);
2807 //bootstrap menu functions
2808 $
("[class='dropdown-toggle']").hover(function(){
2809 $
("[class='dropdown-toggle']").parent().removeClass('open');
2810 var menuitem
= this
.id
.match(/(.*)/)[1];
2811 //if the menu is active through a prior click, show it
2812 // Have to override Bootstrap then
2813 if ($
("#menustate").val() !="1") { //menu not active -> ignore
2814 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2815 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2816 } else { //menu is active -> respond
2817 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2818 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2819 $
("#"+menuitem
).css("text-decoration","none");
2820 $
("#"+menuitem
).parent().addClass('open');
2823 var menuitem
= this
.id
.match(/(.*)/)[1];
2824 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2825 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2828 $
("[class='dropdown-toggle']").on('click', function() {
2829 $
("#menustate").val('1');
2830 var menuitem
= this
.id
.match(/(.*)/)[1];
2831 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2832 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2833 $
("#"+menuitem
).css("text-decoration","none");
2835 $
("#right-panel-link, #close-panel-bt,#right-panel-link_2").on('click', function() {
2836 if ($
("#PREFS_PANEL_RIGHT").val() =='1') {
2837 $
("#PREFS_PANEL_RIGHT").val('0');
2839 $
("#PREFS_PANEL_RIGHT").val('1');
2843 $
("[name^='menu_']").on('click', function() {
2844 $
("[name^='menu_']").removeClass('active');
2845 var menuitem
= this
.id
.match(/menu_(.*)/)[1];
2846 $
(this
).addClass('active');
2847 $
("#menustate").val('1');
2848 if (menuitem
=='left_tabs') {
2849 var tabs_left
= $
("#setting_tabs_left").val();
2850 if (tabs_left
== '1') {
2851 $
("#tabs_left").addClass('nodisplay');
2852 $
("#setting_tabs_left").val('0');
2854 $
("#tabs_left").removeClass('nodisplay');
2855 $
("#setting_tabs_left").val('1');
2859 $
("#BUTTON_TAB_"+menuitem
).trigger('click');
2860 $
("#tabs-left-"+menuitem
).trigger('click');
2861 menu_select(menuitem
);
2865 // set display functions for Draw panel appearance
2866 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2867 var zones
= ["PMH","HPI","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2868 for (index
= '0'; index
< zones
.length
; ++index
) {
2869 if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='DRAW') {
2870 show_DRAW_section(zones
[index
]);
2871 } else if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='QP') {
2872 show_QP_section(zones
[index
],'1');
2875 $
("body").on("click","[name$='_text_view']" , function() {
2876 var header
= this
.id
.match(/(.*)_text_view$
/)[1];
2877 $
("#"+header+
"_text_list").toggleClass('wide_textarea');
2878 $
("#"+header+
"_text_list").toggleClass('narrow_textarea');
2879 $
(this
).toggleClass('fa-plus-square-o');
2880 $
(this
).toggleClass('fa-minus-square-o');
2881 if (header
!= /PRIOR
/) {
2882 var imagine
= $
("#PREFS_"+header+
"_VIEW").val();
2884 $
("#PREFS_"+header+
"_VIEW").val(imagine
);
2889 $
("body").on("change", "select", function(e
){
2890 if (this
.name
.match(/PRIOR_(.*)/)) {
2891 var new_section
= this
.name
.match(/PRIOR_(.*)/);
2892 var newValue
= this
.value
;
2893 if (new_section
[1] =='') return;
2894 if (new_section
[1].match(/_canvas
/)) {
2895 goto_section
= new_section
[1].match(/_canvas
/)[1];
2896 show_PRIOR_CANVAS_section(goto_section
,newValue
);
2900 if (new_section
[1] == /\_
/){
2903 var newValue
= this
.value
;
2904 if (newValue
== $
("#form_id").val()) {
2905 if (new_section
[1] =="ALL") {
2906 //click updates prefs too
2907 $
('#EXAM_QP').trigger("click");
2910 $
('#BUTTON_QP_'+new_section
[1]).trigger("click").trigger("click");//double click intended RM
2912 $
("#LayerTechnical_sections_1").css("clear","both");
2915 //now go get the prior page via ajax
2916 $
("#PRIORS_"+ new_section
[1] +
"_left_text").removeClass('nodisplay');
2917 $
("#DRAWS_" + new_section
[1] +
"_right").addClass('nodisplay');
2918 $
("#QP_" + new_section
[1]).addClass('nodisplay');
2920 if (new_section
[1] =="ALL") {
2922 show_PRIORS_section("ALL",newValue
);
2923 show_PRIORS_section("EXT",newValue
);
2924 show_PRIORS_section("ANTSEG",newValue
);
2925 show_PRIORS_section("RETINA",newValue
);
2926 show_PRIORS_section("NEURO",newValue
);
2927 show_PRIORS_section("IMPPLAN",newValue
);
2928 scrollTo("EXT_left");
2930 show_PRIORS_section(new_section
[1],newValue
);
2936 $
("body").on("click","[name^='old_canvas']", function() {
2938 //het h.step from SELECT_CANVAS_" . attr($zone) . "
2939 var h
= $
(this
).data();
2940 var target
= h
.target
;
2941 var direction
= h
.direction
;
2942 var select
= document
.getElementById(target
);
2943 var len
= select
.getElementsByTagName('option').length
-1;
2944 var t
= $
("#"+target
).data();
2946 if (direction
=="oldest") {
2948 next
= select
.getElementsByTagName('option')[index
];
2949 if(typeof next
!== undefined
) {
2950 select
.options
[index
].selected
= 'selected';
2952 } else if (direction
=="older") {
2954 next
= select
.getElementsByTagName('option')[index
];
2955 if(typeof next
!== undefined
&& index
<= len
) {
2956 select
.options
[index
].selected
= 'selected';
2960 } else if (direction
=="newer") {
2962 next
= select
.getElementsByTagName('option')[index
];
2963 if (typeof next
!== undefined
&& index
>= 0) {
2964 select
.options
[index
].selected
= 'selected';
2967 select
.options
[index
].selected
= 'selected';
2969 } else if (direction
=="newest") {
2971 next
= select
.getElementsByTagName('option')[index
];
2972 if(typeof next
!== undefined
) {
2973 select
.options
[index
].selected
= 'selected';
2977 $
("#"+target
).trigger('change');
2981 $
("body").on("click","[id^='Close_PRIORS_']", function() {
2982 var new_section
= this
.id
.match(/Close_PRIORS_(.*)$
/)[1];
2983 $
("#PRIORS_"+ new_section +
"_left_text").addClass('nodisplay');
2984 $
("#QP_" + new_section
).removeClass('nodisplay');
2986 $
("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").on("mouseover", function() {
2987 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2989 $
("#pupils,#vision_tab,[name='CTL']").on("mouseout", function() {
2990 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
2992 $
("#pupils").on("click", function(){
2993 if ($
("#dim_pupils_panel").hasClass("nodisplay")) {
2994 $
("#dim_pupils_panel").removeClass('nodisplay');
2996 $
("#dim_pupils_panel").fadeToggle();
2999 $
("#vision_tab").on("click", function(){
3000 $
("#REFRACTION_sections").toggleClass('nodisplay');
3001 ($
("#PREFS_VA").val() =='1') ?
($
("#PREFS_VA").val('0')) : $
("#PREFS_VA").val('1');
3003 //set wearing to single vision or bifocal? Bifocal
3004 $
(".WNEAR").removeClass('nodisplay');
3005 $
("#WNEARODAXIS").addClass('nodisplay');
3006 $
("#WNEARODCYL").addClass('nodisplay');
3007 $
("#WNEARODPRISM").addClass('nodisplay');
3008 $
("#WNEAROSAXIS").addClass('nodisplay');
3009 $
("#WNEAROSCYL").addClass('nodisplay');
3010 $
("#WNEAROSPRISM").addClass('nodisplay');
3011 $
("#Single").on("click", function(){
3012 $
("#WNEARODAXIS").addClass('nodisplay');
3013 $
("#WNEARODCYL").addClass('nodisplay');
3014 $
("#WNEARODPRISM").addClass('nodisplay');
3015 $
("#WODADD2").addClass('nodisplay');
3016 $
("#WOSADD2").addClass('nodisplay');
3017 $
("#WNEAROSAXIS").addClass('nodisplay');
3018 $
("#WNEAROSCYL").addClass('nodisplay');
3019 $
("#WNEAROSPRISM").addClass('nodisplay');
3020 $
(".WSPACER").removeClass('nodisplay');
3022 $
("#Bifocal").on("click", function(){
3023 $
(".WSPACER").addClass('nodisplay');
3024 $
(".WNEAR").removeClass('nodisplay');
3025 $
(".WMid").addClass('nodisplay');
3026 $
(".WHIDECYL").removeClass('nodisplay');
3027 $
("[name=RX]").val(["1"]);
3028 $
("#WNEARODAXIS").addClass('nodisplay');
3029 $
("#WNEARODCYL").addClass('nodisplay');
3030 $
("#WNEARODPRISM").addClass('nodisplay');
3031 $
("#WNEAROSAXIS").addClass('nodisplay');
3032 $
("#WNEAROSCYL").addClass('nodisplay');
3033 $
("#WNEAROSPRISM").addClass('nodisplay');
3034 $
("#WODADD2").removeClass('nodisplay');
3035 $
("#WOSADD2").removeClass('nodisplay');
3037 $
("#Trifocal").on("click", function(){
3038 $
(".WSPACER").addClass('nodisplay');
3039 $
(".WNEAR").removeClass('nodisplay');
3040 $
(".WMid").removeClass('nodisplay');
3041 $
(".WHIDECYL").addClass('nodisplay');
3042 $
("[name=RX]").val(["2"]);
3043 $
("#WNEARODAXIS").addClass('nodisplay');
3044 $
("#WNEARODCYL").addClass('nodisplay');
3045 $
("#WNEARODPRISM").addClass('nodisplay');
3046 $
("#WNEAROSAXIS").addClass('nodisplay');
3047 $
("#WNEAROSCYL").addClass('nodisplay');
3048 $
("#WNEAROSPRISM").addClass('nodisplay');
3049 $
("#WODADD2").removeClass('nodisplay');
3050 $
("#WOSADD2").removeClass('nodisplay');
3052 $
("#Progressive").on("click", function(){
3053 $
(".WSPACER").addClass('nodisplay');
3054 $
(".WNEAR").removeClass('nodisplay');
3055 $
(".WMid").addClass('nodisplay');
3056 $
(".WHIDECYL").removeClass('nodisplay');
3057 $
("[name=RX]").val(["3"]);
3058 $
("#WNEARODAXIS").addClass('nodisplay');
3059 $
("#WNEARODCYL").addClass('nodisplay');
3060 $
("#WNEARODPRISM").addClass('nodisplay');
3061 $
("#WNEAROSAXIS").addClass('nodisplay');
3062 $
("#WNEAROSCYL").addClass('nodisplay');
3063 $
("#WNEAROSPRISM").addClass('nodisplay');
3064 $
("#WODADD2").removeClass('nodisplay');
3065 $
("#WOSADD2").removeClass('nodisplay');
3067 $
("[name=W_width_display]").on("click", function() {
3068 if ($
("#PREFS_W_width").val() !="1") {
3069 $
("#PREFS_W_width").val('1');
3070 //make each display W wide
3071 $
("[name=currentRX]").addClass('refraction_wide');
3072 $
("[name=W_wide]").removeClass('nodisplay');
3073 $
("[name=W_wide2]").removeClass('nodisplay');
3075 $
("#PREFS_W_width").val('0');
3076 //make each display W narrow
3077 $
("[name=currentRX]").removeClass('refraction_wide');
3078 $
("[name=W_wide]").addClass('nodisplay');
3079 $
("[name=W_wide2]").addClass('nodisplay');
3084 if ($
("#PREFS_W_width").val() == '1') {
3085 $
("[name=W_wide]").removeClass('nodisplay');
3086 $
("[name=W_wide2]").removeClass('nodisplay')
3088 $
("[name=W_wide]").addClass('nodisplay');
3089 $
("[name=W_wide2]").addClass('nodisplay');
3091 $
("#Amsler-Normal").on("change", function() {
3092 if ($
(this
).is(':checked')) {
3093 var number1
= document
.getElementById("AmslerOD").src
.match(/(Amsler_\d
)/)[1];
3094 document
.getElementById("AmslerOD").src
= document
.getElementById("AmslerOD").src
.replace(number1
,"Amsler_0");
3095 var number2
= document
.getElementById("AmslerOS").src
.match(/(Amsler_\d
)/)[1];
3096 document
.getElementById("AmslerOS").src
= document
.getElementById("AmslerOS").src
.replace(number2
,"Amsler_0");
3097 $
("#AMSLEROD").val("0");
3098 $
("#AMSLEROS").val("0");
3099 $
("#AmslerODvalue").text("0");
3100 $
("#AmslerOSvalue").text("0");
3101 submit_form("eye_mag");
3105 $
("#PUPIL_NORMAL").on("change", function() {
3106 if ($
(this
).is(':checked')) {
3107 $
("#ODPUPILSIZE1").val('3.0');
3108 $
("#OSPUPILSIZE1").val('3.0');
3109 $
("#ODPUPILSIZE2").val('2.0');
3110 $
("#OSPUPILSIZE2").val('2.0');
3111 $
("#ODPUPILREACTIVITY").val('+2');
3112 $
("#OSPUPILREACTIVITY").val('+2');
3113 $
("#ODAPD").val('0');
3114 $
("#OSAPD").val('0');
3115 submit_form("eye_mag");
3119 $
("[name$='PUPILREACTIVITY']").on("change", function() {
3120 var react
= $
(this
).val();
3121 if (react
.match(/^\d
{1}$
/)) {
3127 $
("[name^='EXAM']").on("mouseover", function(){
3128 $
(this
).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
3130 $
("[name^='EXAM']").on("mouseout", function(){
3131 $
(this
).toggleClass("borderShadow2");
3133 $
("#AmslerOD, #AmslerOS").on("click", function() {
3134 if ($
('#chart_status').val() !="on") return;
3135 var number1
= this
.src
.match(/Amsler_(\d
)/)[1];
3136 var number2
= +number1 +
1;
3137 this
.src
= this
.src
.replace('Amsler_'+number1
,'Amsler_'+number2
);
3138 this
.src
= this
.src
.replace('Amsler_6','Amsler_0');
3139 $
("#Amsler-Normal").removeAttr('checked');
3140 var number3
= this
.src
.match(/Amsler_(\d
)/)[1];
3141 this
.html
= number3
;
3142 if (number3
=="6") {
3145 if ($
(this
).attr("id")=="AmslerOD") {
3146 $
("#AmslerODvalue").text(number3
);
3147 $
('#AMSLEROD').val(number3
);
3149 $
('#AMSLEROS').val(number3
);
3150 $
("#AmslerOSvalue").text(number3
);
3152 var title
= "#"+$
(this
).attr("id")+
"_tag";
3155 $
("#AmslerOD, #AmslerOS").on("mouseout", function() {
3156 submit_form("eye_mag");
3158 $
("[name^='ODVF'],[name^='OSVF']").on("click", function() {
3159 if ($
(this
).is(':checked') == true) {
3160 $
("#FieldsNormal").prop('checked', false);
3164 $
(this
).prop('checked', false);
3166 submit_form("eye_mag");
3168 $
("#FieldsNormal").on("click", function() {
3169 if ($
(this
).is(':checked')) {
3170 $
("#ODVF1").removeAttr('checked');
3171 $
("#ODVF2").removeAttr('checked');
3172 $
("#ODVF3").removeAttr('checked');
3173 $
("#ODVF4").removeAttr('checked');
3174 $
("#OSVF1").removeAttr('checked');
3175 $
("#OSVF2").removeAttr('checked');
3176 $
("#OSVF3").removeAttr('checked');
3177 $
("#OSVF4").removeAttr('checked');
3180 $
("[id^='EXT_prefix']").on("change", function() {
3181 var newValue
=$
('#EXT_prefix').val();
3182 newValue
= newValue
.replace('+', '');
3183 if (newValue
=="off") {$
(this
).val('');}
3184 if (newValue
=="clear") {
3185 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
3190 $
("[name^='EXT_prefix_']").removeClass('eye_button_selected');
3191 $
("#EXT_prefix_"+ newValue
).addClass("eye_button_selected");
3194 $
("#ANTSEG_prefix").on("change", function() {
3195 var newValue
= $
(this
).val().replace('+', '');
3196 if ($
(this
).value
=="off") {$
(this
).val('');}
3197 if (newValue
=="clear") {
3198 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
3200 $
(".ANTSEG").val('');
3203 $
("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
3204 $
("#ANTSEG_prefix_"+ newValue
).addClass("eye_button_selected");
3207 $
("#RETINA_prefix").on("change", function() {
3208 var newValue
= $
("#RETINA_prefix").val().replace('+', '');
3209 if ($
(this
).value
=="off") {$
(this
).val('');}
3210 if (newValue
=="clear") {
3211 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
3213 $
(".RETINA").val('');
3216 $
("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
3217 $
("#RETINA_prefix_"+ newValue
).addClass("eye_button_selected");
3220 $
("#NEURO_ACT_zone").on("change", function() {
3221 var newValue
= $
(this
).val();
3222 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3223 $
("#NEURO_ACT_zone_"+ newValue
).addClass("eye_button_selected");
3224 $
("#PREFS_ACT_SHOW").val(newValue
);
3226 $
("#ACT_tab_"+newValue
).trigger('click');
3228 $
("#NEURO_side").on("change", function() {
3229 var newValue
= $
(this
).val();
3230 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3231 $
("#NEURO_side_"+ newValue
).addClass("eye_button_selected");
3233 $
('.ACT').on('focus', function() {
3234 var id
= this
.id
.match(/ACT(\d
*)/);
3235 $
('#NEURO_field').val(''+id
[1]).trigger('change');
3237 $
("#NEURO_field").on("change", function() {
3238 var newValue
= $
(this
).val();
3239 $
("[name^='NEURO_field']").removeClass('eye_button_selected');
3240 $
("#NEURO_field_"+ newValue
).addClass("eye_button_selected");
3241 $
('.ACT').each(function(i
){
3242 var color
= $
(this
).css('background-color');
3243 if ((color
== 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
3244 $
(this
).css("background-color","red");
3247 //change to highlight field in zone entry is for
3248 var zone
= $
("#NEURO_ACT_zone").val();
3249 $
("#ACT"+newValue+zone
).css("background-color","yellow");
3251 $
("[name^='NEURO_ACT_strab']").on("click", function() {
3252 var newValue
= $
(this
).val();
3253 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3254 $
(this
).addClass("eye_button_selected");
3256 $
("#NEURO_value").on("change", function() {
3257 var newValue
= $
(this
).val();
3258 $
("[name^='NEURO_value']").removeClass('eye_button_selected');
3259 $
("#NEURO_value_"+ newValue
).addClass("eye_button_selected");
3260 if (newValue
== "ortho") {
3261 $
("#NEURO_ACT_strab").val('');
3262 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3263 $
("#NEURO_side").val('');
3264 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3267 $
("#NEURO_RECORD").on("mouseover", function() {
3268 $
("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
3270 $
("#NEURO_RECORD").on("mouseout", function() {
3271 $
("#NEURO_RECORD").removeClass('borderShadow2');
3273 $
("#NEURO_RECORD").on("mousedown", function() {
3274 $
("#NEURO_RECORD").removeClass('borderShadow2');
3275 $
(this
).toggleClass('button_over');
3277 $
("#NEURO_RECORD").on("mouseup", function() {
3278 $
("#NEURO_RECORD").removeClass('borderShadow2');
3279 $
(this
).toggleClass('button_over');
3281 $
("#NEURO_RECORD").on("click", function() {
3282 //find out the field we are updating
3283 var number
= $
("#NEURO_field").val();
3284 var zone
= $
("#NEURO_ACT_zone").val();
3285 var strab
= $
("#NEURO_value").val() +
' '+ $
("#NEURO_side").val() + $
("#NEURO_ACT_strab").val();
3287 $
("#ACT"+number+zone
).val(strab
).css("background-color","#F0F8FF");
3292 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseover", function(){
3293 $
(this
).addClass("borderShadow2");
3295 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseout", function(){
3296 $
(this
).removeClass("borderShadow2");
3298 $
("[id$='_lightswitch']").on("click", function() {
3299 var section
= "#"+this
.id
.match(/(.*)_lightswitch$
/)[1];
3300 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3301 var elem
= document
.getElementById("PREFS_"+section2
);
3302 $
("#PREFS_VA").val('0');
3303 if (section2
!= "IOP")$
("#REFRACTION_sections").removeClass('nodisplay');
3304 if (elem
.value
== "0" || elem
.value
=='') {
3306 if (section2
=="ADDITIONAL") {
3307 $
("#LayerVision_ADDITIONAL").removeClass('nodisplay');
3309 if (section2
=="IOP") {
3310 $
("#LayerVision_IOP").removeClass('nodisplay');
3313 $
(section
).removeClass('nodisplay');
3314 $
(this
).addClass("buttonRefraction_selected");
3317 $
(section
).addClass('nodisplay');
3318 if (section2
=="VAX") {
3319 $
("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
3321 if (section2
=="IOP") {
3322 $
("#LayerVision_IOP").addClass('nodisplay');
3324 $
(this
).removeClass("buttonRefraction_selected");
3326 $
(this
).css( 'cursor', 'pointer' );
3330 $
('[id$=_lightswitch]').on("mouseover", function() {
3331 $
(this
).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
3333 var section
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3334 if (section
== 'IOP') {
3335 $
("#LayerTension").addClass("borderShadow2");
3337 $
("#LayerVision").addClass("borderShadow2");
3340 $
('[id$=_lightswitch]').on('mouseout', function() {
3341 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3342 var elem
= document
.getElementById("PREFS_"+section2
);
3344 if (elem
.value
!= "1") {
3345 $
(this
).removeClass('buttonRefraction_selected');
3347 $
(this
).addClass('buttonRefraction_selected');
3350 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
3351 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
3352 // "-" is still == "-"
3353 $
("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
) {
3354 if (e
.keyCode
=='61' || e
.keyCode
=='74') {
3355 now
= $
(this
).val();
3356 now
= now
.replace(/=/g
,"+").replace(/^j
/g
,"J");
3360 //useful to make all VA fields stay in sync
3361 $
("input[name$='VA']").on('change',function() {
3362 var hereValue
= $
(this
).val();
3363 var newValue
= $
(this
).attr('name').replace('VA', 'VA_copy');
3364 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3365 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");;
3367 $
("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
3368 var hereValue
= $
(this
).val();
3369 hereValue
= hereValue
.replace(/=$
/g
,"+").replace(/^j
/g
,"J");
3370 $
(this
).val(hereValue
);
3371 if (this
.name
.match(/_1$
/)) {
3372 var newValue
= $
(this
).attr('name').replace('VA_1', 'VA_1_copy');
3373 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3374 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");
3378 $
("input[name$='_copy']").on("blur", function() {
3379 var hereValue
= $
(this
).val();
3380 var newValue
= $
(this
).attr('name').replace('_copy', '');
3381 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3382 $
("#" + newValue +
"_copy_brd").val(hereValue
).css("background-color","#F0F8FF");;
3384 $
("input[name$='_copy_brd']").on("change", function() {
3385 var hereValue
= $
(this
).val();
3386 var newValue
= $
(this
).attr('name').replace('_copy_brd', '');
3387 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3388 $
("#" + newValue +
"_copy").val(hereValue
).css("background-color","#F0F8FF");;
3390 $
("[name^='more_']").on("mouseout", function() {
3391 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
3393 $
("[name^='more_']").on("click", function() {
3394 $
("#Visions_A").toggleClass('nodisplay');
3395 $
("#Visions_B").toggleClass('nodisplay');
3397 $
("#EXAM_defaults").on("click", function() {
3398 if (!confirm('<?php echo xla("Replace all exam findings with Default values? Are you sure?"); ?>')) {
3402 // This query is specific to the provider.
3403 $query = "select seq from list_options where option_id=?";
3404 $result = sqlStatement($query, array("Eye_defaults_$providerID"));
3406 $list = sqlFetchArray($result);
3407 $SEQ = $list['seq'] ??
'';
3409 // If there is no list for this provider, we create it here.
3410 // This list is part of the idea to create a way to add Eye_Defaults_$providerID specific to the
3411 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3412 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3413 // Let's see if the public likes the form itself before developing these subspecialty lists...
3415 //Copy the Eye_Defaults_for_GENERAL to Eye_defaults_$providerID
3416 $sql = "SELECT * from list_options where list_id = 'Eye_Defaults_for_GENERAL'";
3417 $start = sqlStatement($sql);
3418 $add_fields = array();
3420 while ($val = sqlFetchArray($start)) {
3421 $parameters .= "(?, ?, ?, ?, ?, ?),";
3422 array_push($add_fields, "Eye_defaults_" . $providerID, $val['option_id'], $val['title'], $val['notes'], '1', $val['seq']);
3424 $parameters = rtrim($parameters, ",");
3425 $query = "SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'";
3426 $pres = sqlStatement($query);
3427 $maxseq = sqlFetchArray($pres);
3429 $seq = $maxseq['maxseq'];
3430 $query = "INSERT INTO `list_options`
3431 (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`) VALUES
3432 ('lists', ?, ?, ?, '1', '0', '', '', '')";
3433 $providerNAME = getProviderName($providerID);
3435 sqlStatement($query, array("Eye_defaults_$providerID","Eye Exam Defaults $providerNAME ",$seq));
3436 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`,`notes`,`activity`,`seq`) VALUES " . $parameters;
3437 sqlStatement($query, $add_fields);
3440 $query = "select * from list_options where list_id =? and activity='1' order by seq";
3442 $DEFAULT_data = sqlStatement($query, array("Eye_defaults_$providerID"));
3443 while ($row = sqlFetchArray($DEFAULT_data)) {
3444 //$row['notes'] is the clinical zone (EXT,ANTSEG,RETINA,NEURO)
3445 //$row['option_id'] is the field name
3446 //$row['title'] is the default value to use for this provider
3447 $
{$row['notes']}[$row['option_id']] = $row['title']; //This builds each clinical section into its own array (used below)
3448 echo '$("#' . $row['option_id'] . '").val("' . $row['title'] . '").css("background-color","beige");
3451 function startsWith($str, $needle)
3453 return substr($str, 0, strlen($needle)) === $needle;
3456 submit_form("eye_mag");
3458 $
("#EXT_defaults_R").on("click", function() {
3460 foreach ($EXT as $item => $value) {
3461 if (startsWith($item, "R")) {
3462 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3467 submit_form("eye_mag");
3470 $
("#EXT_defaults_L").on("click", function() {
3472 foreach ($EXT as $item => $value) {
3473 if (startsWith($item, "L")) {
3474 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3479 submit_form("eye_mag");
3481 $
("#EXT_defaults").on("click", function() {
3482 $
("#EXT_defaults_L").trigger('click');
3483 $
("#EXT_defaults_R").trigger('click');
3484 submit_form("eye_mag");
3487 $
("#EXT_R_L").on('click', function () {
3488 $
("#LBROW").val($
("#RBROW").val());
3489 $
("#LUL").val($
("#RUL").val());
3490 $
("#LLL").val($
("#RLL").val());
3491 $
("#LMCT").val($
("#RMCT").val());
3492 $
("#LADNEXA").val($
("#RADNEXA").val());
3493 submit_form("eye_mag");
3496 $
("#EXT_L_R").on('click', function () {
3497 $
("#RBROW").val($
("#LBROW").val());
3498 $
("#RUL").val($
("#LUL").val());
3499 $
("#RLL").val($
("#LLL").val());
3500 $
("#RMCT").val($
("#LMCT").val());
3501 $
("#RADNEXA").val($
("#LADNEXA").val());
3502 submit_form("eye_mag");
3504 $
("#ANTSEG_defaults_OD").on("click", function() {
3506 foreach ($ANTSEG as $item => $value) {
3507 if (startsWith($item, "OD")) {
3508 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3513 submit_form("eye_mag");
3516 $
("#ANTSEG_defaults_OS").on("click", function() {
3518 foreach ($ANTSEG as $item => $value) {
3519 if (startsWith($item, "OS")) {
3520 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3525 submit_form("eye_mag");
3527 $
("#ANTSEG_defaults").on("click", function() {
3528 $
("#ANTSEG_defaults_OD").trigger('click');
3529 $
("#ANTSEG_defaults_OS").trigger('click');
3530 submit_form("eye_mag");
3532 $
("#ANTSEG_OD_OS").on('click', function () {
3533 $
("#OSCONJ").val($
("#ODCONJ").val());
3534 $
("#OSCORNEA").val($
("#ODCORNEA").val());
3535 $
("#OSAC").val($
("#ODAC").val());
3536 $
("#OSLENS").val($
("#ODLENS").val());
3537 $
("#OSIRIS").val($
("#ODIRIS").val());
3538 submit_form("eye_mag");
3540 $
("#ANTSEG_OS_OD").on('click', function () {
3541 $
("#ODCONJ").val($
("#OSCONJ").val());
3542 $
("#ODCORNEA").val($
("#OSCORNEA").val());
3543 $
("#ODAC").val($
("#OSAC").val());
3544 $
("#ODLENS").val($
("#OSLENS").val());
3545 $
("#ODIRIS").val($
("#OSIRIS").val());
3546 submit_form("eye_mag");
3549 $
("#RETINA_OD_OS").on('click', function () {
3550 $
("#OSDISC").val($
("#ODDISC").val());
3551 $
("#OSCUP").val($
("#ODCUP").val());
3552 $
("#OSMACULA").val($
("#ODMACULA").val());
3553 $
("#OSVESSELS").val($
("#ODVESSELS").val());
3554 $
("#OSVITREOUS").val($
("#ODVITREOUS").val());
3555 $
("#OSPERIPH").val($
("#ODPERIPH").val());
3556 submit_form("eye_mag");
3559 $
("#RETINA_OS_OD").on('click', function () {
3560 $
("#ODDISC").val($
("#OSDISC").val());
3561 $
("#ODCUP").val($
("#OSCUP").val());
3562 $
("#ODMACULA").val($
("#OSMACULA").val());
3563 $
("#ODVESSELS").val($
("#OSVESSELS").val());
3564 $
("#ODVITREOUS").val($
("#OSVITREOUS").val());
3565 $
("#ODPERIPH").val($
("#OSPERIPH").val());
3566 submit_form("eye_mag");
3569 $
("#clear_EXT_L").on('click', function () {
3570 $
("#LBROW").val('');
3574 $
("#LADNEXA").val('');
3577 submit_form("eye_mag");
3580 $
("#clear_EXT_R").on('click', function () {
3581 $
("#RBROW").val('');
3585 $
("#RADNEXA").val('');
3588 submit_form("eye_mag");
3591 $
("#RETINA_defaults_OD").on("click", function() {
3593 foreach ($RETINA as $item => $value) {
3594 if (startsWith($item, "OD")) {
3595 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3600 submit_form("eye_mag");
3603 $
("#RETINA_defaults_OS").on("click", function() {
3605 foreach ($RETINA as $item => $value) {
3606 if (startsWith($item, "OS")) {
3607 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3612 submit_form("eye_mag");
3614 $
("#RETINA_defaults").on("click", function() {
3615 $
("#RETINA_defaults_OD").trigger('click');
3616 $
("#RETINA_defaults_OS").trigger('click');
3617 submit_form("eye_mag");
3621 $
("#NEURO_defaults").on("click", function() {
3623 foreach ($NEURO as $item => $value) {
3624 echo '$("#' . $item . '").val("' . $value . '").css("background-color","beige");
3628 submit_form("eye_mag");
3631 $
("#clear_EXT_R").on('click', function() {
3632 $
('.right.EXT').val('');
3633 submit_form("eye_mag");
3635 $
("#clear_EXT_L").on('click', function() {
3636 $
('.left.EXT').val('');
3637 submit_form("eye_mag");
3639 $
("#clear_ANTSEG_OD").on('click', function() {
3640 $
('.right.ANTSEG').val('');
3641 submit_form("eye_mag");});
3642 $
("#clear_ANTSEG_OS").on('click', function() {
3643 $
('.left.ANTSEG').val('');
3644 submit_form("eye_mag");
3646 $
("#clear_RETINA_OD").on('click', function() {
3647 $
('.right.RETINA').val('');
3648 submit_form("eye_mag");
3650 $
("#clear_RETINA_OS").on('click', function() {
3651 $
('.left.RETINA').val('');
3652 submit_form("eye_mag");
3655 $
("[id^='cpf_']").on('click', function() {
3656 var to_field
= this
.id
.match(/cpf_(.*)_(.*)/)[1];
3657 var from_field
= this
.id
.match(/cpf_(.*)_(.*)/)[2];
3658 $
("#"+to_field
).val($
("#"+from_field
).val());
3659 submit_form("eye_mag");
3661 $
("#MOTILITYNORMAL").on("click", function() {
3662 $
("#MOTILITY_RS").val('0');
3663 $
("#MOTILITY_RI").val('0');
3664 $
("#MOTILITY_RR").val('0');
3665 $
("#MOTILITY_RL").val('0');
3666 $
("#MOTILITY_LS").val('0');
3667 $
("#MOTILITY_LI").val('0');
3668 $
("#MOTILITY_LR").val('0');
3669 $
("#MOTILITY_LL").val('0');
3671 $
("#MOTILITY_RRSO").val('0');
3672 $
("#MOTILITY_RRIO").val('0');
3673 $
("#MOTILITY_RLSO").val('0');
3674 $
("#MOTILITY_RLIO").val('0');
3675 $
("#MOTILITY_LRSO").val('0');
3676 $
("#MOTILITY_LRIO").val('0');
3677 $
("#MOTILITY_LLSO").val('0');
3678 $
("#MOTILITY_LLIO").val('0');
3680 for (index
= '0'; index
< 5; ++index
) {
3681 $
("#MOTILITY_RS_"+index
).html('');
3682 $
("#MOTILITY_RI_"+index
).html('');
3683 $
("#MOTILITY_RR_"+index
).html('');
3684 $
("#MOTILITY_RL_"+index
).html('');
3685 $
("#MOTILITY_LS_"+index
).html('');
3686 $
("#MOTILITY_LI_"+index
).html('');
3687 $
("#MOTILITY_LR_"+index
).html('');
3688 $
("#MOTILITY_LL_"+index
).html('');
3690 $
("#MOTILITY_RRSO_"+index
).html('');
3691 $
("#MOTILITY_RRIO_"+index
).html('');
3692 $
("#MOTILITY_RLSO_"+index
).html('');
3693 $
("#MOTILITY_RLIO_"+index
).html('');
3694 $
("#MOTILITY_LRSO_"+index
).html('');
3695 $
("#MOTILITY_LRIO_"+index
).html('');
3696 $
("#MOTILITY_LLSO_"+index
).html('');
3697 $
("#MOTILITY_LLIO_"+index
).html('');
3699 submit_form('eye_mag');
3702 $
("[name^='MOTILITY_']").on("click", function() {
3703 $
("#MOTILITYNORMAL").removeAttr('checked');
3705 if (this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/)) {
3706 var zone
= this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/);
3708 var valued
= isNaN($
("#"+zone
[1]).val());
3709 if ((zone
[2] =='RLSO')||
(zone
[2] =='LLSO')||
(zone
[2] =='RRIO')||
(zone
[2] =='LRIO')) {
3710 //find or make a hash tage for "\"
3711 var hash_tag
= '<i class="fa fa-minus"></i>';
3713 //find or make a hash tage for "/"
3714 var hash_tag
= '<i class="fa fa-minus"></i>';
3717 var zone
= this
.id
.match(/(MOTILITY_
..)_(.)/);
3718 var section
= this
.id
.match(/MOTILITY_(.)(.)_
/);
3719 var section2
= section
[2];
3720 var Eye
= section
[1];
3721 var SupInf
= section2
.search(/S|I
/);
3722 var RorLside
= section2
.search(/R|L
/);
3725 if (RorLside
=='0') {
3726 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
3728 var hash_tag
= '<i class="fa fa-minus"></i>';
3731 if (valued
!= true && $
("#"+zone
[1]).val() <'4') {
3732 valued
=$
("#"+zone
[1]).val();
3736 $
("#"+zone
[1]).val('0');
3739 $
("#"+zone
[1]).val(valued
);
3741 for (index
= '0'; index
< 5; ++index
) {
3742 $
("#"+zone
[1]+
"_"+index
).html('');
3745 for (index
=1; index
< (valued+
1); ++index
) {
3746 $
("#"+zone
[1]+
"_"+index
).html(hash_tag
);
3753 $
("[name^='Close_']").on("click", function() {
3754 var section
= this
.id
.match(/Close_(.*)$
/)[1];
3755 if (this
.id
.match(/Close_W_(.*)$
/) != null) {
3756 var W_section
= this
.id
.match(/Close_W_(.*)$
/)[1];
3757 if (W_section
> '1') {
3758 $
('#LayerVision_W_'+W_section
).addClass('nodisplay');
3759 $
('[name$=SPH_'+W_section+
']').val('');
3760 $
('[name$=CYL_'+W_section+
']').val('');
3761 $
('[name$=AXIS_'+W_section+
']').val('');
3762 $
('[name$=ADD_'+W_section+
']').val('');
3763 $
('[name$=PRISM_'+W_section+
']').val('');
3764 $
('[name$=VA_'+W_section+
']').val('');
3765 $
('#RX_TYPE_'+W_section
).val('');
3766 $
('#Add_Glasses').removeClass('nodisplay');
3767 $
('#W_'+W_section
).val('');
3770 $
("#LayerVision_W_lightswitch").click();
3772 } else if (section
=="ACTMAIN") {
3773 $
("#ACTTRIGGER").trigger( "click" );
3775 $
("#LayerVision_"+section+
"_lightswitch").click();
3780 $
("#EXAM_DRAW, #BUTTON_DRAW_menu, #PANEL_DRAW").on("click", function() {
3781 if ($
("#PREFS_CLINICAL").value
!='0') {
3783 $
("#PREFS_CLINICAL").val('0');
3786 if ($
("#PREFS_EXAM").val() != 'DRAW') {
3787 $
("#PREFS_EXAM").val('DRAW');
3788 $
("#EXAM_QP").removeClass('button_selected');
3789 $
("#EXAM_DRAW").addClass('button_selected');
3790 $
("#EXAM_TEXT").removeClass('button_selected');
3795 $
("#EXAM_QP,#PANEL_QP").on("click", function() {
3796 if ($
("#PREFS_CLINICAL").value
!='0') {
3797 $
("#PREFS_CLINICAL").val('0');
3800 if ($
("#PREFS_EXAM").value
!= 'QP') {
3801 $
("#PREFS_EXAM").val('QP');
3802 $
("#EXAM_QP").addClass('button_selected');
3803 $
("#EXAM_DRAW").removeClass('button_selected');
3804 $
("#EXAM_TEXT").removeClass('button_selected');
3809 scrollTo("EXT_left");
3812 $
("#EXAM_TEXT,#PANEL_TEXT").on("click", function() {
3814 // also hide QP, DRAWs, and PRIORS
3821 for (index
= '0'; index
< zones
.length
; ++index
) {
3822 $
("#PREFS_"+zones
[index
]+
"_RIGHT").val(0);
3826 $
("#EXAM_DRAW").removeClass('button_selected');
3827 $
("#EXAM_QP").removeClass('button_selected');
3828 $
("#EXAM_TEXT").addClass('button_selected');
3829 scrollTo("EXT_left");
3831 $
("[id^='BUTTON_TEXT_']").on("click", function() {
3832 var zone
= this
.id
.match(/BUTTON_TEXT_(.*)/)[1];
3833 if (zone
!= "menu") {
3834 $
("#"+zone+
"_right").addClass('nodisplay');
3835 $
("#"+zone+
"_left").removeClass('display');
3836 $
("#"+zone+
"_left_text").removeClass('display');
3837 $
("#PREFS_"+zone+
"_RIGHT").val(0);
3840 scrollTo("EXT_left");
3842 $
("[id^='BUTTON_TEXTD_']").on("click", function() {
3843 var zone
= this
.id
.match(/BUTTON_TEXTD_(.*)/)[1];
3844 if (zone
!= "menu") {
3845 if ((zone
=="PMH") ||
(zone
== "HPI")) {
3846 $
("#PMH_right").addClass('nodisplay');
3847 $
("#PREFS_PMH_RIGHT").val(1);
3848 $
("#HPI_right").addClass('nodisplay');
3849 $
("#PREFS_HPI_RIGHT").val(1);
3850 var reset
= $
("#HPI_1").height();
3851 $
("#PMH_1").css("min-height",'0');
3852 $
("#PMH_left").height(reset
-40);
3854 $
("#LayerTechnical_sections_1").css("clear","both");
3856 $
("#"+zone+
"_right").addClass('nodisplay');
3857 $
("#PREFS_"+zone+
"_RIGHT").val(1);
3859 scrollTo(zone+
"_left");
3864 $
("#EXAM_TEXT").addClass('button_selected');
3865 if (($
("#PREFS_CLINICAL").val() !='1')) {
3866 var actionQ
= "#EXAM_"+$
("#PREFS_EXAM").val();
3867 $
(actionQ
).trigger('click');
3869 $
("#EXAM_TEXT").addClass('button_selected');
3871 if ($
("#ANTSEG_prefix").val() > '') {
3872 $
("#ANTSEG_prefix_"+$
("#ANTSEG_prefix").val()).addClass('button_selected');
3874 $
("#ANTSEG_prefix").val('off').trigger('change');
3876 $
("[name^='ACT_tab_']").on("mouseover", function() {
3877 $
(this
).toggleClass('underline').css( 'cursor', 'pointer' );
3879 $
("[name^='ACT_tab_']").on("mouseout", function() {
3880 $
(this
).toggleClass('underline');
3883 $
("[name^='ACT_tab_']").on("click", function() {
3884 var section
= this
.id
.match(/ACT_tab_(.*)/)[1];
3885 $
("[name^='ACT_']").addClass('nodisplay');
3886 $
("[name^='ACT_tab_']").removeClass('nodisplay').removeClass('ACT_selected').addClass('ACT_deselected');
3887 $
("#ACT_tab_" + section
).addClass('ACT_selected').removeClass('ACT_deselected');
3888 $
("#ACT_" + section
).removeClass('nodisplay');
3889 $
("#PREFS_ACT_SHOW").val(section
);
3890 //selection correct QP zone
3891 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3892 $
("#NEURO_ACT_zone_"+ section
).addClass("eye_button_selected");
3893 $
("#NEURO_ACT_zone").val(section
);
3896 $
("#ACTTRIGGER").on("mouseout", function() {
3897 $
("#ACTTRIGGER").toggleClass('buttonRefraction_selected').toggleClass('underline');
3899 if ($
("#PREFS_ACT_VIEW").val() == '1') {
3900 $
("#ACTMAIN").toggleClass('nodisplay');
3901 $
("#NPCNPA").toggleClass('nodisplay');
3902 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3903 $
("#ACTTRIGGER").toggleClass('underline');
3904 var show
= $
("#PREFS_ACT_SHOW").val();
3905 $
("#ACT_tab_"+show
).trigger('click');
3907 $
("#ACTTRIGGER").on("click", function() {
3908 $
("#ACTMAIN").toggleClass('nodisplay').toggleClass('ACT_TEXT');
3909 $
("#NPCNPA").toggleClass('nodisplay');
3910 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3911 $
("#ACTTRIGGER").toggleClass('underline');
3912 if ($
("#PREFS_ACT_VIEW").val()=='1') {
3913 $
("#PREFS_ACT_VIEW").val('0');
3915 $
("#PREFS_ACT_VIEW").val('1');
3917 var show
= $
("#PREFS_ACT_SHOW").val();
3918 $
("#ACT_tab_"+show
).trigger('click');
3921 $
("#NEURO_COLOR").on("click", function() {
3922 $
("#ODCOLOR").val("11/11");
3923 $
("#OSCOLOR").val("11/11");
3924 submit_form("eye_mag");
3927 $
("#NEURO_COINS").on("click", function() {
3928 $
("#ODCOINS").val("1.00");
3929 //leave currency symbol out unless it is an openEMR defined option
3930 $
("#OSCOINS").val("1.00");
3931 submit_form("eye_mag");
3934 $
("#NEURO_REDDESAT").on("click", function() {
3935 $
("#ODREDDESAT").val("100");
3936 $
("#OSREDDESAT").val("100");
3937 submit_form("eye_mag");
3940 $
("[id^='myCanvas_']").on("mouseout", function() {
3941 var zone
= this
.id
.match(/myCanvas_(.*)/)[1];
3942 submit_canvas(zone
);
3944 $
("[id^='Undo_']").on("click", function() {
3945 var zone
= this
.id
.match(/Undo_Canvas_(.*)/)[1];
3946 submit_canvas(zone
);
3948 $
("[id^='Redo_']").on("click", function() {
3949 var zone
= this
.id
.match(/Redo_Canvas_(.*)/)[1];
3950 submit_canvas(zone
);
3952 $
("[id^='Clear_']").on("click", function() {
3953 var zone
= this
.id
.match(/Clear_Canvas_(.*)/)[1];
3954 submit_canvas(zone
);
3956 $
("[id^='Blank_']").on("click", function() {
3958 var zone
= this
.id
.match(/Blank_Canvas_(.*)/)[1];
3959 $
("#url_"+zone
).val("../../forms/eye_mag/images/BLANK_BASE.png");
3960 //canvas.renderAll();
3964 $
("#COPY_SECTION").on("change", function() {
3965 var start
= $
("#COPY_SECTION").val();
3966 if (start
=='') return;
3967 var value
= start
.match(/(\w
*)-(\w
*)/);
3968 var zone
= value
[1];
3969 var copy_from
= value
[2];
3970 if (zone
=="READONLY") copy_from
= $
("#form_id").val();
3971 var count_changes
='0';
3977 copy_to
: $
("#form_id").val(),
3978 copy_from
: copy_from
,
3979 pid
: $
("#pid").val()
3981 if (zone
=="READONLY") {
3982 //we are going to update the whole form
3983 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
3984 //We are not ready to actively chart, just looking to see how far along our staff is...
3985 //or maybe just looking ahead to see who's next in the next room?
3986 //Either way, we are looking at a record that at present will be disabled/we cannot change...
3987 // yet it is updating every 10 seconds if another user is making changes.
3989 // READONLY does not show IMPPLAN changes!!!!
3991 //here we are retrieving an old record to copy forward to today's active chart.
3992 data
= $
("#"+zone+
"_left_text").serialize() +
"&" + $
.param(data
);
3994 top
.restoreSession();
3998 url
: "../../forms/eye_mag/save.php",
4000 success
: function(result
) {
4001 //we have to process impplan differently
4002 if (zone
=='IMPPLAN') {
4003 //we get a json result.IMPPLAN back from the prior visit
4004 //we need to add that to the current list? Replace for now.
4005 build_IMPPLAN(result
.IMPPLAN
);
4006 store_IMPPLAN(result
.IMPPLAN
);
4007 // need to make the Plan areas purple?
4009 $
.map(result
, function(valhere
, keyhere
) {
4010 if ($
("#"+keyhere
).val() != valhere
) {
4011 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
4012 } else if (keyhere
.match(/MOTILITY_
/)) {
4013 // Copy forward ductions and versions visually
4014 // Make each blank, and rebuild them
4015 $
("[name='"+keyhere+
"_1']").html('');
4016 $
("[name='"+keyhere+
"_2']").html('');
4017 $
("[name='"+keyhere+
"_3']").html('');
4018 $
("[name='"+keyhere+
"_4']").html('');
4019 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
4020 // Show a horizontal (minus) tag. When "/" and "\" fa-icons are available will need to change.
4021 // Maybe just use small font "/" and "\" directly.
4022 hash_tag
= '<i class="fa fa-minus"></i>';
4023 } else { //show vertical tag
4024 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
4026 for (index
=1; index
<= valhere
; ++index
) {
4027 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
4029 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
4030 if (valhere
=='1') {
4031 $
("#FieldsNormal").prop('checked', false);
4032 $
("#"+keyhere
).prop('checked', true);
4033 $
("#"+keyhere
).val('1');
4035 $
("#"+keyhere
).val('0');
4036 $
("#"+keyhere
).prop('checked', false);
4038 } else if (keyhere
.match(/AMSLERO(.)/)) {
4039 var sidehere
= keyhere
.match(/AMSLERO(.)/);
4040 if (valhere
< '1') valhere
='0';
4041 $
("#"+keyhere
).val(valhere
);
4042 var srcvalue
="AmslerO"+sidehere
[1];
4043 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
4044 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
4045 } else if (keyhere
.match(/VA$
/)) {
4046 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
4047 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
4050 if (zone
!= "READONLY") { submit_form("eye_mag"); }
4054 $
("[id^='BUTTON_DRAW_']").on("click", function() {
4055 var zone
=this
.id
.match(/BUTTON_DRAW_(.*)$
/)[1];
4058 if ($
('#PREFS_'+zone+
'_RIGHT').val() =="DRAW") {
4059 $
('#BUTTON_TEXTD_'+zone
).trigger("click");//closes draw
4060 //maybe this should revert to last right panel state (qp,text)
4063 $
("#"+zone+
"_1").removeClass('nodisplay');
4064 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
4065 $
("#QP_"+zone
).addClass('nodisplay');
4066 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
4067 $
("#Draw_"+zone
).removeClass('nodisplay');
4068 $
("#PREFS_"+zone+
"_RIGHT").val('DRAW');
4069 scrollTo(zone+
"_left");
4073 $
("[id^='BUTTON_QP_']").on("click", function() {
4074 var zone
= this
.id
.match(/BUTTON_QP_(.*)$
/)[1].replace(/_\d*/
,'');
4075 if (zone
=='IMPPLAN2') {
4076 $
('#IMP_start_acc').slideDown();
4079 if (($
("#PREFS_"+zone+
"_RIGHT").val() =='QP')&&(zone
!='IMPPLAN')) {
4080 $
('#BUTTON_TEXTD_'+zone
).trigger("click");
4083 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
4084 $
("#Draw_"+zone
).addClass('nodisplay');
4085 show_QP_section(zone
, '1');
4086 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
4088 if ((zone
== 'PMH')||
(zone
== 'HPI')) {
4089 if ($
('#HPI_right').css('display') == 'none') {
4090 $
("#Draw_HPI").addClass('nodisplay');
4091 show_QP_section('HPI', '1');
4092 $
("#PREFS_HPI_RIGHT").val('QP');
4097 if (zone
== 'HPI') {
4098 if ($
('#PMH_right').css('display') == 'none') {
4099 $
("#PRIORS_PMH_left_text").addClass('nodisplay');
4100 $
("#Draw_PMH").addClass('nodisplay');
4101 show_QP_section('PMH','1');
4102 $
("#PREFS_PMH_RIGHT").val('QP');
4104 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
4105 $
('#PMH_left').height($
('#PMH_right').height());
4107 $
('#PMH_1').height($
('#HPI_1').height());
4109 } else if (zone
== 'menu') {
4111 } else if (zone
== 'IMPPLAN') {
4112 show_QP_section('IMPPLAN','1');
4118 // set default to ccDist. Change as desired.
4119 $
('#NEURO_ACT_zone').val('CCDIST').trigger('change');
4120 if ($
("#RXStart").val() =="2") {
4121 $
("#Trifocal").trigger('click');
4123 $
("[id$='_loading']").addClass('nodisplay');
4124 $
("[id$='_sections']").removeClass('nodisplay');
4126 $
('#left-panel').css("right","0px");
4127 $
('#EXAM_KB').css({position
: 'fixed', top
: '29px'});
4128 $
('#EXAM_KB').css('display', 'block');
4129 $
('#EXAM_KB').draggable();
4130 $
('#IMP').droppable({ drop
: dragto_IMPPLAN
} );
4131 $
('#IMPPLAN_zone').droppable({ drop
: dragto_IMPPLAN_zone
} );
4132 $
('#IMPPLAN_text').droppable({ drop
: dragto_IMPPLAN_zone
} );
4134 $
('[id^="PLANS"]').draggable( { cursor
: 'move', revert
: true });
4135 $
('[id^="PLAN_"]').height( $
(this
).scrollHeight
);
4137 /* Sorting of diagnoses in IMP/PLAN right panel builds IMP_order[] array.
4138 Foreach index => value in IMP_order[order,PMSFH[type][i]]:
4139 retrieve PMSFH[type][value] and build the IMPRESSION/PLAN area
4140 openEMR ICD-10 seems to have newlines in codetext? strip them with replace.
4141 All the ISSUE_TYPES and their fields are available in obj.PMSFH:
4142 'title' => $disptitle,
4143 'status' => $statusCompute,
4144 'enddate' => $row['enddate'],
4145 'reaction' => $row['reaction'],
4146 'referredby' => $row['referredby'],
4147 'extrainfo' => $row['extrainfo'],
4148 'diagnosis' => $row['diagnosis'],
4150 'codedesc' => $codedesc,
4151 'codetext' => $codetext,
4152 'codetype' => $codetype,
4153 'comments' => $row['comments'],
4154 'rowid' => $row['id'],
4155 'row_type' => $row['type']
4156 eg. obj.IMPPLAN_items[index] = code: obj.PMSFH['POH'][value]['code'],
4157 codedesc: obj.PMSFH['POH'][value]['codedesc'],
4158 codetype: obj.PMSFH['POH'][value]['codetype']
4161 $
('#make_new_IMP').on("click", function() {
4163 if (IMP_order
.length
==0) rebuild_IMP($
( "#build_DX_list" ));
4164 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
4165 $
.each(IMP_order
, function( index
, value
) {
4166 issue
= value
.match(/(.*)_(.*)/);
4167 if (issue
[1] == "CLINICAL") {
4168 if (!$
('#inc_PE').is(':checked')) { return; }
4171 var the_codedesc
='';
4172 var the_codetext
='';
4174 for (i
=0;i
< obj
.Clinical
[issue
[2]].length
; i++
) {
4176 the_code
= obj
.Clinical
[issue
[2]][i
]['code'];
4177 } else if (i
< obj
.Clinical
[issue
[2]].length
) {
4178 the_code +
= ', '+ obj
.Clinical
[issue
[2]][i
]['code'];
4180 the_codedesc +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
4181 the_codetext +
= obj
.Clinical
[issue
[2]][i
]['codetext'] +
"\r";
4182 the_plan +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
4184 obj
.IMPPLAN_items
.push({
4185 title
:obj
.Clinical
[issue
[2]][0]['title'],
4187 codetype
: obj
.Clinical
[issue
[2]][0]['codetype'],
4188 codedesc
: the_codedesc
,
4189 codetext
: the_codetext
,
4191 PMSFH_link
: obj
.Clinical
[issue
[2]][0]['PMSFH_link']
4194 if (issue
[1] == "PMH") {
4195 if (!$
('#inc_PMH').is(':checked')) { return; }
4196 } else if (issue
[1] == "POH"){
4197 if (!$
('#inc_POH').is(':checked')) { return; }
4198 } else if (issue
[1] == "POS"){
4199 if (!$
('#inc_POH').is(':checked')) { return; }
4201 obj
.IMPPLAN_items
.push({
4202 title
: obj
.PMSFH
[issue
[1]][issue
[2]]['title'],
4203 code
: obj
.PMSFH
[issue
[1]][issue
[2]]['code'],
4204 codetype
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetype'],
4205 codedesc
: obj
.PMSFH
[issue
[1]][issue
[2]]['codedesc'],
4206 codetext
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetext'].replace(/(\r\n|\n|\r
)/gm
,""),
4207 plan
: obj
.PMSFH
[issue
[1]][issue
[2]]['comments'],
4208 PMSFH_link
: obj
.PMSFH
[issue
[1]][issue
[2]]['PMSFH_link']
4212 build_IMPPLAN(obj
.IMPPLAN_items
);
4213 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
4217 $
('.building_blocks > dt ').on('click', function() {
4218 if ( $
(this
).next().css('display') !== 'block' ) {
4219 allPanels
.slideUp();
4220 $
(this
).next().slideDown();
4222 allPanels
.slideUp();
4225 $
('#IMP_start_acc').slideDown();
4226 $
('[id^=inc_]').on('click', function() {
4230 $
('#active_flag').on('click', function() { check_lock('1'); });
4231 $
('#active_icon').on('click', function() { check_lock('1'); });
4233 $
("input,textarea,text,checkbox").on("change", function(){
4234 $
(this
).css("background-color","#F0F8FF");
4235 if (this
.name
.match(/IOP
/)) { color_IOP(this
); }
4236 if ( ($
(this
).id
!= 'IMP') &&
4237 (!this
.name
.match(/^inc_
/)) &&
4238 (!this
.name
.match(/_modifier$
/))
4242 $
("#IMP_start_acc").slideDown();
4245 $
("[name='CANVAS_selector']").on("change", function(){
4246 //we are going to display an old image from a previous encounter
4247 zone
= this
.id
.match(/CANVAS_(.*)/)[1];
4248 if (this
.value
!= 'current') {
4249 $
("#"+zone+
"_canvas").addClass('nodisplay');
4250 $
("#"+zone+
"_olddrawing").removeClass('nodisplay');
4251 show_PRIOR_CANVAS_section(zone
, this
.value
);
4253 $
("#"+zone+
"_canvas").removeClass('nodisplay');
4255 $
("#"+zone+
"_olddrawing").addClass('nodisplay');
4260 $
('#IMP').on("blur", function() {
4261 //add this DX to the obj.IMPPLAN_items array
4262 //take the first line as the impression and the rest as the plan
4263 var total_imp
= $
('#IMP').val();
4264 $
('#IMP').val('');//clear the box
4265 var local_plan
= '';
4267 if (total_imp
.length
< '2') return; //reject text under two letters?
4268 var re
= /\r\n|
[\n\v\f\r\x85\u2028\u2029]/; //official list of line delimiters for a regex
4269 //local_impression is first line only[1]
4270 var local_imp
= total_imp
.match(/^
(.*)(?
:\r\n|
[\n\v\f\r\x85\u2028\u2029])(.*)/);
4271 if (local_imp
== null || local_imp
[1] == null) {
4272 local_imp
= total_imp
;
4274 // If the first line was dropped in from the Builder via a draggable DX_list
4275 // it will include the IMPRESSION + CODE.
4276 // Consider stripping out the CODE
4277 var local_imp_code
= local_imp
[1].match(/(.*)(ICD
.*)$
/);
4278 if (local_imp_code
) {
4279 local_imp
= local_imp_code
[1];
4280 local_code
= local_imp_code
[2];
4281 local_plan
= total_imp
.replace(local_imp_code
[0],''); //plan is line 2+ if present, strip off first line
4282 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
4284 local_imp
= local_imp
[1];
4286 local_plan
= total_imp
.replace(local_imp
,''); //plan is line 2+ if present, strip off first line
4287 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
4290 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];//can't push if array does not exist
4291 obj
.IMPPLAN_items
.push({
4292 form_id
: $
('#form_id').val(),
4293 pid
: $
('#pid').val(),
4302 build_IMPPLAN(obj
.IMPPLAN_items
,'1');
4303 store_IMPPLAN(obj
.IMPPLAN_items
);
4305 $
('#Add_Glasses').on('click', function() {
4306 for (i
=2; i
<6; i++
) { //come on, 5 current rx glasses should be enough...
4307 if ($
('#W_'+i
).val() != '1') {
4308 $
('#W_'+i
).val('1');
4309 $
('#LayerVision_W_'+i
).removeClass('nodisplay');
4310 if (i
==5) { $
('#Add_Glasses').addClass('nodisplay'); }
4315 $
("[name='reverseme']").on('click', function() {
4316 var target
= this
.id
;
4317 reverse_cylinder(target
);
4320 $
('#code_me_now').on('click', function(event
) {
4321 event
.preventDefault();
4322 build_CODING_list();
4323 CODING_to_feesheet(CODING_items
);
4325 $
( ".widget a" ).button();
4327 $
( "button" ).button().on('click', function( event
) {
4328 event
.preventDefault();
4330 $
('#visit_codes').on('change', function() {
4331 var data_all
= $
(this
).val();
4332 var data
= data_all
.match(/^
(.*)\|
(.*)\|
/);
4333 visit_code
= data
[2];
4334 visit_type
= data
[1];
4336 $
('[name="visit_modifier"]').on('click', function () {
4337 var item
= this
.id
.match(/visit_mod_(.*)/)[1];
4338 if ($
(this
).hasClass('status_on')) {
4339 $
(this
).css("background-color","navy");
4340 $
(this
).removeClass('status_on');
4341 visit_modifier
= visit_modifier
.filter(function(e
) { return e
!== item
});
4343 $
(this
).css("background-color","red");
4344 $
(this
).addClass('status_on');
4345 visit_modifier
.push(item
);
4347 build_CODING_list();
4350 $
('[id^="tabs-left-"]').on('click', function () {
4351 var item
= this
.id
.match(/tabs
-left
-(.*)/)[1];
4352 var value
= $
("#setting_"+item
).val();
4354 $
("#setting_"+item
).val('1');
4355 $
(this
).removeClass('ui-state-default');
4356 $
('#'+ item +
'_1').removeClass('nodisplay');
4359 $
("#setting_"+item
).val('0');
4360 $
(this
).addClass('ui-state-default');
4361 $
('#'+ item +
'_1').addClass('nodisplay');
4366 $
(document
).on('change','[name="visit_status"]', function (event
) {
4367 var item
= $
( "input[type=radio][name=visit_status]:checked" ).val();
4368 update_appt_status(item
);
4371 $
(document
).on("click", "[name='visit_justifier']", function () {
4372 var d
= $
(this
).data();
4373 var item
= d
.justcode
;
4374 if ($
(this
).hasClass('status_on')) {
4375 $
(this
).css("background-color","navy");
4376 $
(this
).removeClass('status_on');
4377 visit_justifier
= visit_justifier
.filter(function(e
) { return e
!== item
});
4379 $
(this
).css("background-color","red");
4380 $
(this
).addClass('status_on');
4381 visit_justifier
.push(item
);
4383 build_CODING_list();
4385 $
(document
).on("click", "span[name$='_justifiers']", function () {
4386 var item
= parseInt( this
.id
.match(/_just_(.*)/)[1] ) +
1;
4387 if ($
(this
).hasClass('status_on')) {
4388 $
(this
).css("background-color","navy");
4389 $
(this
).removeClass('status_on');
4391 if ( $
('#visit_just_'+item
).hasClass('status_on') ) {
4392 $
('#visit_just_'+item
).trigger('click');
4394 $
(this
).css("background-color","red");
4395 $
(this
).addClass('status_on');
4396 if (!$
('#visit_mod_25').hasClass("status_on")) {
4397 $
('#visit_mod_25').trigger('click');
4400 build_CODING_list();
4403 build_IMPPLAN(obj
.IMPPLAN_items
);
4405 $
('[id^="BUTTON_TAB_"]').on('click', function () {
4406 var item
= this
.id
.match(/BUTTON_TAB_(.*)/)[1];
4408 $
('#tabs-left-'+item
).addClass('ui-state-default');
4409 $
("#setting_"+item
).val('0');
4410 $
("#"+item+
'_1').addClass('nodisplay');
4411 $
("#tabs_left").removeClass('nodisplay');
4415 $
("input,textarea,text").on("focus", function(){
4416 $
(this
).css("background-color","#ffff99");
4418 //This listener no longer works in tabs because of the new tab wrapper.
4419 $
(window
).bind('onbeforeunload', function(){
4420 alert('Closing time');
4421 if ($
('#chart_status').val()=="on") {