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 js_escape($providerID); ?
>,
374 'pid' : $
('#pid').val(),
376 'enc' : $
('#encounter').val(),
377 'form_id' : $
('#form_id').val()
379 top
.restoreSession();
384 }).done(function(result
) {
385 //OPTIONS to consider: we could return a status code from the server.
386 //maybe 1 = no doc, 2= doc made and queued, 3= sent
387 //maybe this is a checkbox. Check to create the task, uncheck to delete it.
388 //if the task is completed, checkbox is checked and disabled?
389 //return doc_id and display it in html for id='status_'+task+'_'+to_type
390 obj
= JSON
.parse(result
);
392 $
('#status_'+task+
'_'+to_type
).html(obj
.DOC_link
);
394 if (obj
.comments
) alert(obj
.comments
);
395 //maybe change an icon to sent? Think.
401 * START OF PMSFH FUNCTIONS
403 function alter_issue2(issue_number
,issue_type
,index
) {
404 if (!obj
.PMSFH
) { refresh_page(); }
405 if (typeof obj
.PMSFH
== "undefined") { submit_form(); }
406 var here
= obj
.PMSFH
[issue_type
][index
];
407 window
.frames
[0].frameElement
.contentWindow
.newtype(issue_type
);
408 if (issue_type
!='SOCH' && issue_type
!='FH' && issue_type
!='ROS') {
409 $
('iframe').contents().find('#delete_button').removeClass('nodisplay');
411 $
('iframe').contents().find('#delete_button').addClass('nodisplay');
413 $
('iframe').contents().find('#issue').val(issue_number
);
414 if (typeof here
!== "undefined") {
415 $
('iframe').contents().find('#form_title' ).val(here
.title
);
416 $
('iframe').contents().find('#form_diagnosis' ).val(here
.diagnosis
);
417 $
('iframe').contents().find('#form_begin' ).val(here
.begdate
);
418 $
('iframe').contents().find('#form_end' ).val(here
.enddate
);
419 $
('iframe').contents().find('#form_reaction' ).val(here
.reaction
);
420 $
('iframe').contents().find('#form_referredby' ).val(here
.referredby
);
421 $
('iframe').contents().find('#form_classification' ).val(here
.classification
);
422 $
('iframe').contents().find('#form_occur' ).val(here
.occurrence
);
423 $
('iframe').contents().find('#form_comments' ).val(here
.comments
);
424 $
('iframe').contents().find('#form_outcome' ).val(here
.outcome
);
425 $
('iframe').contents().find('#form_destination' ).val(here
.destination
);
426 if (here
.row_subtype
=='eye') {
427 $
('iframe').contents().find('#form_eye_subtype' ).prop("checked","checked");
429 $
('iframe').contents().find('#form_eye_subtype' ).prop("checked",false);
431 if (here
.enddate
> '') {
432 $
('iframe').contents().find('#form_active' ).prop("checked",true);
433 $
('iframe').contents().find('#delete_button').addClass("nodisplay");
435 $
('iframe').contents().find('#form_active' ).prop("checked",false);
438 var location
= $
("#PMH_left").offset().top
-55;
439 $root.animate({scrollTop
: location
}, "slow");
441 function showArray(arr
) {
442 var tS
= new String();
443 for (var iI in arr
) {
444 tS +
= "Index "+iI+
", Type "+
(typeof arr
[iI
])+
", Value "+arr
[iI
]+
"\n";
450 * Function to delete an issue from server via ajax
451 * Ajax returns json obj.PMSFH
452 * Refresh displays (right_panel and QP_PMH panel)
454 function delete_issue2(issue_number
,PMSFH_type
) {
455 $
('#form#theform issue').val(issue_number
);
456 $
('iframe').contents().find('#issue').val(issue_number
);
457 $
('form#theform form_type');
459 var url
= '../../forms/eye_mag/a_issue.php';
461 'a_issue' : issue_number
,
465 top
.restoreSession();
470 success
:(function(result
) {
471 populate_PMSFH(result
);
479 * Function to save the PMSFH array to the server.
480 * This can be removed in the future - save for now
482 function submit_PMSFH() {
483 var url
= "../../forms/eye_mag/save.php?PMSFH_save=1&mode=update";
484 formData
= $
("[id^=f]").serialize();
485 var f
= document
.forms
[0];
486 top
.restoreSession();
491 }).done(function(result
){
492 f
.form_title
.value
= '';
493 f
.form_diagnosis
.value
= '';
494 f
.form_begin
.value
='';
495 f
.form_end
.value
='';
496 f
.form_referredby
.value
='';
497 f
.form_reaction
.value
='';
498 f
.form_classification
.value
='';
499 f
.form_occur
.value
='';
500 f
.form_comments
.value
='';
501 f
.form_outcome
.value
='';
502 f
.form_destination
.value
='';
504 populate_form(result
);
508 * END OF PMSFH FUNCTIONS
512 * Function to refresh the issues, the panels and the Impression/coding areas.
514 function refresh_page() {
515 var url
= '../../forms/eye_mag/view.php?display=PMSFH';
517 'action' : "refresh",
518 'id' : $
('#form_id').val(),
519 'encounter' : $
('#encounter').val(),
520 'pid' : $
('#pid').val(),
523 top
.restoreSession();
528 success
:(function(result
) {
529 populate_form(result
);
532 //Make the height of the panels equal if they grow really large
533 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
534 $
('#PMH_left').height($
('#PMH_right').height());
535 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
540 * Function to refresh the Glaucoma Flow Sheet.
542 function refresh_GFS() {
543 if (typeof config_byday
== "undefined") { return; }
545 var indexToUpdate
= '0';
546 $
.each(config_byday
.data
.labels
, function(key
,value
) {
547 if (value
== visit_date
) {
552 //var indexToUpdate = config_byday.data.labels.length-1;
555 if ( $
('#ODIOPAP').val()) {
556 ODIOP
= $
('#ODIOPAP').val();
557 } else if ( $
('#ODIOPTPN').val()) {
558 ODIOP
= $
('#ODIOPTPN').val();
561 if ( $
('#OSIOPAP').val() >'0') {
562 OSIOP
= $
('#OSIOPAP').val();
563 } else if ( $
('#OSIOPTPN').val() > '0') {
564 OSIOP
= $
('#OSIOPTPN').val();
567 config_byday
.data
.datasets
[0].data
[indexToUpdate
] = $
('#ODIOPTARGET').val();
568 config_byday
.data
.datasets
[1].data
[indexToUpdate
] = ODIOP
;
569 config_byday
.data
.datasets
[2].data
[indexToUpdate
] = OSIOP
;
572 var time
= $
('#IOPTIME').val();
573 times
= time
.match(/^
(\d
{1,2}):(\d
{2})/);
574 if (times
[1] < 10) times
[1] = "0"+
''+times
[1];
575 time
= times
[1]+
':'+times
[2];
576 var indexToUpdate2
= '0';
577 $
.each(config_byhour
.data
.labels
, function(key
,value
) {
579 indexToUpdate2
= key
;
582 config_byhour
.data
.datasets
[0].data
[indexToUpdate2
] = ODIOP
;
583 config_byhour
.data
.datasets
[1].data
[indexToUpdate2
] = OSIOP
;
585 // Update one of the points in the second dataset
586 // myLine.data.datasets[1].data[indexToUpdate].val($('#ODIOPAP').val());
587 //alert(config_byday.data.datasets[1].data[indexToUpdate].val()+' is ending _bydat val');
592 this should refresh locally and not go back to the server
593 the only things that would trigger a refresh are
597 change in GONIO fields
598 additional tests (VF/OCT) would not affect this in its live format
603 function populate_GFS(result
) {
604 $
("#LayerVision_IOP").html(result
);
608 * Server returns a json encoding object: obj to update the page
609 * Here we refresh the PMSFH display panels,
610 * Rebuild the Impression/Plan Builder DX lists,
611 * the Impression Plan area
612 * and the CHRONIC fields.
614 function populate_form(result
) {
615 obj
= JSON
.parse(result
);
616 $
("#QP_PMH").html(obj
.PMH_panel
);
617 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
618 $
('#PMH_left').height($
('#PMH_right').height());
619 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
620 $
("#right_panel_refresh").html(obj
.right_panel
);
621 build_IMPPLAN(obj
.IMPPLAN_items
);
623 build_DX_list(obj
); //build the list of DXs to show in the Impression/Plan Builder
626 * Function to auto-fill CHRONIC fields
627 * To reach a detailed E&M level of documentation the chart
628 * may comment on the status of 3 or more CHRONIC/Inactive problems.
629 * The user can type them into the CHRONIC fields manually, or
630 * we can do it programatically if the user does the following:
631 * 1. documenting a PMH diagnosis in the PMSFH area
632 * 2. listing it as "Chronic"
633 * 3. making a comment about it
634 * With these three steps completed, this build_CHRONIC function displays the changes
635 * in the CHRONIC1-3 textareas, if not already filled in, for today's visit.
636 * On subsequent visits, the CHRONIC1-3 fields are blank, unless the above steps
637 * were performed previously, then they are filled in automatically on loading of the new form.
639 function build_Chronics(obj
) {
640 if (typeof obj
.PMSFH
=== "undefined") return;
641 var CHRONICS
= obj
.PMSFH
['CHRONIC'];
645 $
.each(CHRONICS
, function(key
, value
) {
646 local_comment
= CHRONICS
[key
].title+
" "+CHRONICS
[key
].diagnosis+
"\n"+CHRONICS
[key
].comments
;
648 for (i
=1; i
< 4; i++
) {
649 chronic_value
= $
('#CHRONIC'+i
).val();
650 if (chronic_value
== local_comment
) {
651 here_already
='1'; //this is here, move to next CHRONICS
655 if (here_already
!='1') {
656 for (i
=1; i
< 4; i++
) {
657 chronic_value
= $
('#CHRONIC'+i
).val();
658 if (chronic_value
== '') { //if the CHRONIC1-3 field is empty, fill it.
659 $
('textarea#CHRONIC'+i
).val(local_comment
);
668 * Function to autocreate a PDF of this form as a document linked to this encounter.
669 * Each time it is runs it updates by replacing the encounter's PDF.
670 * This used to be fired often, but it is a server resource beast.
671 * Use it sparingly, and intentionally only.
672 * Currently only invoked via the bootstrap menu: Menu->File->Print/Store PDF
674 function store_PDF() {
675 var url
= "../../forms/eye_mag/save.php?mode=update";
677 'action' : 'store_PDF',
678 'patient_id' : $
('#pid').val(),
681 'form_folder' : $
('#form_folder').val(),
682 'form_id' : $
('#form_id').val(),
683 'encounter' : $
('#encounter').val(),
684 'uniqueID' : $
('#uniqueID').val()
686 top
.restoreSession();
694 /* START Functions related to form VIEW */
696 * Function to blow out the form and display the right side of every section.
698 function show_right() {
699 $
("#HPI_1").removeClass("size50").addClass("size100");
700 $
("#PMH_1").removeClass("size50").addClass("size100");
701 $
("#EXT_1").removeClass("size50").addClass("size100");
702 $
("#ANTSEG_1").removeClass("size50").addClass("size100");
703 $
("#NEURO_1").removeClass("size50").addClass("size100");
704 $
("#POSTSEG_1").removeClass("size50").addClass("size100");
705 $
("#IMPPLAN_1").removeClass("size50").addClass("size100");
706 $
("#HPI_right").removeClass('nodisplay');
707 $
("#PMH_right").removeClass('nodisplay');
708 $
("#EXT_right").removeClass('nodisplay');
709 $
("#ANTSEG_right").removeClass('nodisplay');
710 $
("#NEURO_right").removeClass('nodisplay');
711 $
("#RETINA_right").removeClass('nodisplay');
712 $
("#IMPPLAN_right").removeClass('nodisplay');
713 $
("#PMH_1").addClass("clear_both");
714 $
("#ANTSEG_1").addClass("clear_both");
715 $
("#POSTSEG_1").addClass("clear_both");
716 $
("#NEURO_1").addClass("clear_both");
717 $
("#IMPPLAN_1").addClass("clear_both");
721 * Function to implode the form and hide the right side of every section.
723 function hide_right() {
724 $
("#HPI_1").removeClass("size100").addClass("size50");
725 $
("#PMH_1").removeClass("size100").addClass("size50");
726 $
("#EXT_1").removeClass("size100").addClass("size50");
727 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
728 $
("#NEURO_1").removeClass("size100").addClass("size50");
729 $
("#RETINA_1").removeClass("size100").addClass("size50");
730 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
731 $
("#HPI_right").addClass('nodisplay');
732 $
("#PMH_right").addClass('nodisplay');
733 $
("#EXT_right").addClass('nodisplay');
734 $
("#ANTSEG_right").addClass('nodisplay');
735 $
("#NEURO_right").addClass('nodisplay');
736 $
("#RETINA_right").addClass('nodisplay');
737 $
("#PMH_1").removeClass("clear_both");
738 $
("#ANTSEG_1").removeClass("clear_both");
739 $
("#POSTSEG_1").removeClass("clear_both");
740 $
("#NEURO_1").removeClass("clear_both");
744 * Function to explode the form and show the left side of every section.
746 function show_left() {
747 $
("#HPI_1").removeClass("size100").addClass("size50");
748 $
("#PMH_1").removeClass("size100").addClass("size50");
749 $
("#EXT_1").removeClass("size100").addClass("size50");
750 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
751 $
("#NEURO_1").removeClass("size100").addClass("size50");
752 $
("#POSTSEG_1").removeClass("size100").addClass("size50");
753 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
754 $
("#HPI_left").removeClass('nodisplay');
755 $
("#PMH_left").removeClass('nodisplay');
756 $
("#EXT_left").removeClass('nodisplay');
757 $
("#ANTSEG_left").removeClass('nodisplay');
758 $
("#RETINA_left").removeClass('nodisplay');
759 $
("#NEURO_left").removeClass('nodisplay');
760 $
("#IMPPLAN_left").removeClass('nodisplay');
761 $
("[name$='_left']").removeClass('nodisplay');
764 * Function to implode the form and hide the left side of every section.
766 function hide_left() {
767 $
("#HPI_1").removeClass("size100").addClass("size50");
768 $
("#PMH_1").removeClass("size100").addClass("size50");
769 $
("#EXT_1").removeClass("size100").addClass("size50");
770 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
771 $
("#NEURO_1").removeClass("size100").addClass("size50");
772 $
("#POSTSEG_1").removeClass("size100").addClass("size50");
773 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
774 $
("#HPI_left").addClass('nodisplay');
775 $
("#PMH_left").addClass('nodisplay');
776 $
("#EXT_left").addClass('nodisplay');
777 $
("#ANTSEG_left").addClass('nodisplay');
778 $
("#RETINA_left").addClass('nodisplay');
779 $
("#NEURO_left").addClass('nodisplay');
780 $
("#IMPPLAN_left").addClass('nodisplay');
781 $
("[name $='_left']").addClass('nodisplay');
784 * Function to display only the DRAW panels of every section.
785 * The technical section, between HPI and Clinical section is still visible.
787 function show_DRAW() {
795 $
("#HPI_right").addClass('canvas');
796 $
("#PMH_right").addClass('canvas');
797 $
("#EXT_right").addClass('canvas');
798 $
("#ANTSEG_right").addClass('canvas');
799 $
("#RETINA_right").addClass('canvas');
800 $
("#NEURO_right").addClass('canvas');
801 $
("#IMPPLAN_right").addClass('canvas');
802 $
(".Draw_class").removeClass('nodisplay');
803 if ($
("#PREFS_CLINICAL").val() !='1') {
804 $
("#PREFS_CLINICAL").val('1');
805 $
("#PREFS_EXAM").val('DRAW');
810 * Function to display only the TEXT panels in every section.
812 function show_TEXT() {
813 $
(".TEXT_class").removeClass('nodisplay');
815 hide_right(); //this hides the right half
819 if ($
("#PREFS_CLINICAL").val() !='1') {
820 // we want to show text_only which are found on left half
821 $
("#PREFS_CLINICAL").val('1');
823 $
("#PREFS_EXAM").val('TEXT');
824 $
("#IMPPLAN_right").addClass('canvas').removeClass('nodisplay');
825 $
("#QP_IMPPLAN").removeClass('nodisplay');
826 $
("#DRAW_"+zone
).addClass('nodisplay');
827 $
("#IMPPLAN_left").removeClass('nodisplay');
828 $
("#PREFS_IMPPLAN_RIGHT").val('QP');
832 * Function to display the PRIORS panels in every right section.
834 function show_PRIORS() {
835 $
("#NEURO_sections").removeClass('nodisplay');
837 $
("#EXT_right").addClass("PRIORS_color");
841 $
("#QP_HPI").removeClass('nodisplay');
842 $
("#QP_PMH").removeClass('nodisplay');
843 $
("#HPI_right").addClass('canvas');
844 $
("#PMH_right").addClass('canvas');
845 $
("#IMPPLAN_right").addClass('canvas');
846 $
("#EXT_right").addClass('canvas');
847 $
("#ANTSEG_right").addClass('canvas');
848 $
("#RETINA_right").addClass('canvas');
849 $
("#NEURO_right").addClass('canvas');
850 $
(".PRIORS_class").removeClass('nodisplay');
851 if ($
("#PREFS_CLINICAL").val() !='1') {
852 // we want to show text_only which are found on left half now that PRIORS are visible.
853 $
("#PREFS_CLINICAL").val('1');
855 $
("#PREFS_EXAM").val('PRIORS');
859 * Function to show the Quick Picks panel on the right side of every section.
868 $
("#HPI_right").addClass('canvas');
869 $
("#PMH_right").addClass('canvas');
870 $
("#EXT_right").addClass('canvas');
871 $
("#ANTSEG_right").addClass('canvas');
872 $
("#RETINA_right").addClass('canvas');
873 $
("#NEURO_right").addClass('canvas');
874 $
("#IMPPLAN_right").addClass('canvas');
875 $
(".QP_class").removeClass('nodisplay');
876 $
(".QP_class2").removeClass('nodisplay');
877 $
("#PREFS_EXAM").val('QP');
881 * Function to display only one DRAW panel of one section.
883 function show_DRAW_section(zone
) {
884 $
("#QP_"+zone
).addClass('nodisplay');
885 $
("#"+zone+
"_left").removeClass('nodisplay');
886 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
887 $
("#Draw_"+zone
).addClass('canvas');
888 $
("#Draw_"+zone
).removeClass('nodisplay');
889 $
("#PREFS_"+zone+
"_DRAW").val(1);
893 * Function to display only one PRIORS panel of one section.
895 function show_PRIORS_section(section
,newValue
) {
896 var url
= "../../forms/eye_mag/save.php?mode=retrieve";
899 'PRIORS_query' : "1",
901 'id_to_show' : newValue
,
902 'pid' : $
('#pid').val(),
903 'orig_id' : $
('#form_id').val()
905 top
.restoreSession();
910 success
: function(result
) {
911 $
("#PRIORS_" + section +
"_left_text").html(result
);
916 * Function to display a canvas/drawing from a prior visit.
919 function show_PRIOR_CANVAS_section(section
, newValue
) {
920 var pid
= $
('#pid').val();
922 var result
= base+
'/controller.php?document&retrieve&patient_id='+pid+
'&document_id='+newValue+
'&as_file=false';
923 var cp_forward
= '<button onclick="replace_CANVAS(\''+zone+
'\',\''+result+
'\'); return false;" id="Replace_Canvas_ANTSEG" class="ui-button ui-corner-all ui-widget"><?php echo xlt('Use this image
'); ?></button>';
924 var filler
= "<div class='tools text-info'><?php echo xlt('Previous Encounter Drawings'); ?>: "+cp_forward+
"</div><div class='borderShadow'><img src='"+result+
"' alt='<?php echo xla("Loading prior image
");?>...'></div>";
926 $
("#"+zone+
"_canvas").addClass('nodisplay');
927 $
("#"+zone+
"_olddrawing").html(filler
);
928 $
("#"+zone+
"_olddrawing").removeClass('nodisplay');
931 function replace_CANVAS(zone
, url
) {
932 $
("#url_"+zone
).val(url
);
934 $
("#SELECT_CANVAS_"+zone
).val('current');
935 $
("#"+zone+
"_canvas").removeClass('nodisplay');
936 $
("#"+zone+
"_olddrawing").addClass('nodisplay');
939 * Function to show one of the Quick Picks section on the right side of its section.
941 function show_QP_section(zone
,scroll
) {
942 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
943 $
("#QP_"+zone
).removeClass('nodisplay');
944 $
("#DRAW_"+zone
).addClass('nodisplay');
945 $
("#"+zone+
"_left").removeClass('nodisplay');
946 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
949 scrollTo(zone+
"_left");
953 * Function to hide all the DRAW panels of every section.
955 function hide_DRAW() {
956 $
(".Draw_class").addClass('nodisplay');
958 $
("#LayerTechnical_sections").removeClass('nodisplay');
959 $
("#REFRACTION_sections").removeClass('nodisplay');
960 $
("#PMH_sections").removeClass('nodisplay');
961 $
("#HPI_right").addClass('nodisplay');
962 $
("#HPI_right").removeClass('canvas');
963 $
("#EXT_right").removeClass('canvas');
964 $
("#RETINA_right").removeClass('canvas');
965 $
("#ANTSEG_right").removeClass('canvas');
968 * Function to hide all the Quick Pick panels of every section.
971 $
(".QP_class").addClass('nodisplay');
972 $
(".QP_class2").addClass('nodisplay');
973 $
("[name$='_right']").removeClass('canvas');
976 * Function to hide all the TEXT panels of every section.
978 function hide_TEXT() {
979 $
(".TEXT_class").addClass('nodisplay');
982 * Function to hide all the PIORS panels of every section.
984 function hide_PRIORS() {
985 $
("#EXT_right").removeClass("PRIORS_color");
986 $
("#PRIORS_EXT_left_text").addClass('nodisplay');
987 $
("#PRIORS_ANTSEG_left_text").addClass('nodisplay');
988 $
("#PRIORS_RETINA_left_text").addClass('nodisplay');
989 $
("#PRIORS_NEURO_left_text").addClass('nodisplay');
990 $
(".PRIORS_class").addClass('nodisplay');
993 * Function to hide Shorthand/Keyboard Entry panel.
996 $
('.kb').addClass('nodisplay');
997 $
('.kb_off').removeClass('nodisplay');
998 if ($
("#PREFS_KB").val() > 0) {
999 $
("#PREFS_KB").val('0');
1003 * Function to show the Shorthand/Keyboard panel.
1005 function show_KB() {
1006 $
('.kb').toggleClass('nodisplay');
1007 $
('.kb_off').toggleClass('nodisplay');
1008 $
('.copier').toggleClass('nodisplay');
1009 if ($
('#PREFS_EXAM').val() == 'DRAW') {
1013 if ($
("#PREFS_KB").val() > 0) {
1014 $
("#PREFS_KB").val('0');
1016 $
("#PREFS_KB").val('1');
1021 function editScripts(url
) {
1022 var pid
= $
('#pid').val();
1023 var AddScript
= function () {
1024 var iam
= top
.frames
.editScripts
;
1025 iam
.location
.href
= base +
"/controller.php?prescription&edit&id=&pid="+
encodeURIComponent(pid
)
1027 var ListScripts
= function () {
1028 var iam
= top
.frames
.editScripts
;
1029 iam
.location
.href
= base +
"/controller.php?prescription&list&id="+
encodeURIComponent(pid
)
1032 let title
= 'Prescriptions';
1036 dlgopen(url
, 'editScripts', w
, 300, '', '', {
1038 {text
: 'Add', close
: false, style
: 'primary btn-sm', click
: AddScript
},
1039 {text
: 'List', close
: false, style
: 'primary btn-sm', click
: ListScripts
},
1040 {text
: 'Done', close
: true, style
: 'default btn-sm'}
1042 onClosed
: 'refreshme',
1045 dialogId
: 'editscripts',
1050 /* END Functions related to form VIEW */
1053 * Function contains menu commands specific to this form.
1055 function menu_select(zone
) {
1056 $
("#menu_"+zone
).addClass('active');
1057 if (zone
=='PREFERENCES') {
1058 window
.parent
.RTop
.document
.location
.href
= base+
"interface/super/edit_globals.php";
1059 var url
= base+
"/interface/super/edit_globals.php";
1061 'id' : $
('#id').val(),
1062 'encounter' : $
('#encounter').val(),
1063 'pid' : $
('#pid').val(),
1065 top
.restoreSession();
1070 success
: function(result
) {
1071 window
.parent
.RTop
.document
.result
;
1075 if (zone
=='Left_Panel') $
("#left-panel-link").trigger('click');
1076 if (zone
=='Right_Panel') $
("#right-panel-link").trigger('click');
1077 if (zone
=='PRIORS') $
("#PRIORS_ALL_minus_one").trigger("click");
1078 if (zone
=='QP') show_QP();
1079 if (zone
=='KB') show_KB();
1080 if (zone
=='DRAW') show_DRAW();
1081 if (zone
=='TEXT') show_TEXT();
1082 if (zone
=='IOP_graph') $
("#LayerVision_IOP_lightswitch").trigger('click');
1083 if (zone
== "HPI") scrollTo("HPI_left");
1084 if (zone
== "PMH") scrollTo("PMH_left");
1085 if (zone
== "EXT") scrollTo("EXT_left");
1086 if (zone
== "ANTSEG") scrollTo("ANTSEG_left");
1087 if (zone
== "POSTSEG") scrollTo("RETINA_left");
1088 if (zone
== "NEURO") scrollTo("NEURO_left");
1089 if (zone
== "IMPPLAN") scrollTo("IMPPLAN_left");
1094 * Function to test blowing up any section to fullscren - towards tablet functionality?
1095 * Currently not used.
1097 function show_Section(section
) {
1098 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1100 $
("div[name='_sections']").style
.display
= "none"; //
1101 $
('#'+section+
'_sections').style
.display
= "block";
1102 //.show().appendTo('form_container');
1105 * Function to display Chief Complaint 1-3
1107 function show_CC(CC_X
) {
1108 $
("[name^='CC_']").addClass('nodisplay');
1109 $
("#CC_"+CC_X
).removeClass('nodisplay');
1110 $
("#CC_"+CC_X
).index
;
1113 /* START Functions related to CODING */
1116 * Function to determine if add on NeuroSensory(92060) code can be billed.
1118 function check_CPT_92060() {
1121 if ($
("#STEREOPSIS").val() > '') (neuro1
="1");
1122 $
(".neurosens2").each(function(index
) {
1123 if ($
( this
).val() > '') {
1127 if (neuro1
&& neuro2
){
1128 $
("#neurosens_code").removeClass('nodisplay');
1131 $
("#neurosens_code").addClass('nodisplay');
1136 * Function to check documentation level for coding purposes
1137 * And make suggestions to end user.
1139 function check_exam_detail() {
1140 detail_reached_HPI
='0';
1141 chronic_reached_HPI
='0';
1142 $
(".count_HPI").each(function(index
) {
1143 if ($
( this
).val() > '') detail_reached_HPI++
;
1145 if (detail_reached_HPI
> '3') {
1146 $
(".detail_4_elements").css("color","red");
1147 $
(".CODE_LOW").addClass("nodisplay");
1148 $
(".CODE_HIGH").removeClass("nodisplay");
1149 $
(".detailed_HPI").css("color","red");
1151 $
(".detail_4_elements").css("color","#876F6F");
1153 $
(".chronic_HPI").each(function(index
) {
1154 if ($
( this
).val() > '') chronic_reached_HPI++
;
1156 if (chronic_reached_HPI
> '2') {
1157 $
(".chronic_3_elements").css("color","red");
1158 $
(".CODE_LOW").addClass("nodisplay");
1159 $
(".CODE_HIGH").removeClass("nodisplay");
1160 $
(".detailed_HPI").css("color","red");
1162 $
(".chronic_3_elements").css("color","#876F6F");
1164 if ((chronic_reached_HPI
> '2')||
(detail_reached_HPI
> '3')) {
1165 $
(".CODE_LOW").addClass("nodisplay");
1166 $
(".CODE_HIGH").removeClass("nodisplay");
1167 $
(".detailed_HPI").css("color","red");
1168 detail_reached_HPI
= '1';
1170 $
(".CODE_LOW").removeClass("nodisplay");
1171 $
(".CODE_HIGH").addClass("nodisplay");
1172 $
(".detailed_HPI").css("color","#876F6F");
1173 detail_reached_HPI
= '0';
1175 if ((($
("#DIL_RISKS").is(':checked')) ||
($
(".dil_drug").is(':checked'))) && (($
('#ODPERIPH').val() >'') ||
($
('#OSPERIPH').val() >''))) {
1176 $
(".EXAM_LOW").addClass("nodisplay");
1177 $
(".DIL_RISKS").removeClass("nodisplay");
1178 $
("#DIL_RISKS").prop("checked","checked");
1179 detail_reached_exam
= '1';
1181 $
(".EXAM_LOW").removeClass("nodisplay");
1182 $
(".DIL_RISKS").addClass("nodisplay");
1183 detail_reached_exam
= '0';
1185 Suggest_visit_code();
1188 /* END Functions related to CODING */
1190 /* START Functions related to IMPPLAN Builder */
1192 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1193 * Will use actual list from obj.IMPPLAN_items for coding.
1194 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1195 * available to build the Impression/Plan from.
1197 function build_DX_list(obj
) {
1200 $
( "#build_DX_list" ).empty();
1201 //add in inc_FIELDCODES culled from the datafields
1202 if (typeof obj
.PMSFH
=== "undefined") return;
1203 if (typeof obj
.Clinical
=== "undefined") submit_form('obj.clinical is undefined');
1204 if (!obj
.PMSFH
['POH'] && !obj
.PMSFH
['PMH'] && !obj
.Clinical
) {
1205 out
= '<br /><span class="bold">The Past Ocular History (POH) and Past Medical History (PMH) are negative and no diagnosis was auto-generated from the clinical findings.</span><br /><br />Update the chart to activate the Builder.<br />';
1206 $
( "#build_DX_list" ).html(out
);
1209 build_IMPPLAN(obj
.IMPPLAN_items
);
1210 if ($
('#inc_PE').is(':checked') && obj
.Clinical
) {
1211 $
.each(obj
.Clinical
, function(key
, value
) {
1213 if (obj
.Clinical
[key
][0].diagnosis
> '') { //so we are just showing this first item of each Dx (Eg bilateral, x4 pterygium, only first shows up)
1214 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.Clinical
[key
][0].code+
"</code>";
1216 out +
= "<li class='ui-widget-content'><span name='DX_Clinical_"+key+
"' id='DX_Clinical_"+key+
"'>"+obj
.Clinical
[key
][0].title+
"</span> "+diagnosis+
"</li> ";
1220 if ($
('#inc_POH').is(':checked') && (obj
.PMSFH
['POH']||obj
.PMSFH
['POS'])) {
1221 $
.each(obj
.PMSFH
['POH'], function(key
, value
) {
1223 if (obj
.PMSFH
['POH'][key
].diagnosis
> '' ) {
1224 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POH'][key
].code+
"</code>";
1226 out +
= "<li class='ui-widget-content'><span name='DX_POH_"+key+
"' id='DX_POH_"+key+
"'>"+obj
.PMSFH
['POH'][key
].title+
"</span> "+diagnosis+
"</li>";
1228 $
.each(obj
.PMSFH
['POS'], function(key
, value
) {
1230 if (obj
.PMSFH
['POS'][key
].diagnosis
> '' ) {
1231 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['POS'][key
].code+
"</code>";
1233 out +
= "<li class='ui-widget-content'><span name='DX_POS_"+key+
"' id='DX_POS_"+key+
"'>"+obj
.PMSFH
['POS'][key
].title+
"</span> "+diagnosis+
"</li>";
1236 if ($
('#inc_PMH').is(':checked') && obj
.PMSFH
['PMH']) {
1237 $
.each(obj
.PMSFH
['PMH'], function(key
, value
) {
1239 if (obj
.PMSFH
['PMH'][key
].diagnosis
> '') {
1240 diagnosis
= "<code class='float-right ICD_CODE'>"+obj
.PMSFH
['PMH'][key
].code+
"</code>";
1242 out +
= "<li class='ui-widget-content'><span name='DX_PMH_"+key+
"' id='DX_PMH_"+key+
"'>"+obj
.PMSFH
['PMH'][key
].title+
"</span>"+diagnosis+
"</li> ";
1245 //add in inc_FIELDCODES culled from the datafields
1247 rebuild_IMP($
( "#build_DX_list" ));
1248 $
( "#build_DX_list" )
1249 .html(out
).sortable({ handle
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1250 .selectable({ filter
: "li", cancel
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1252 .addClass( "ui-corner-all ui-selected" )
1253 .dblclick(function(){
1254 rebuild_IMP($
( "#build_DX_list" ));
1255 $
('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1257 //this places the handle for the user to drag the item around.
1258 .prepend( "<div class='handle '><i class='fas fa-arrows-alt fa-1'></i></div>" );
1260 out
= '<br /><span class="bold"><?php echo xlt("Build Your Plan") . "."; ?></span><br /><br />';
1261 out +
= '<?php echo xlt('Suggestions
for the Imp
/Plan are built from the Exam
, the Past Ocular
History (POH
and POS
) and the Past Medical
History (PMH
)') . "."; ?><br />';
1262 out +
= '<?php echo xlt('Update the chart to build this
list') . "."; ?><br />';
1263 $
( "#build_DX_list" ).html(out
);
1267 * Function: After the Builder DX list is built from all the available options,
1268 * the end user can select to use only certain Dxs and change their sort order of importance.
1269 * This function builds the list of DXs selected and in the order as the user sorted them,
1270 * so we know what to use to build the Impression/Plan area and in what order to display them.
1272 function rebuild_IMP(obj2
) {
1276 $
( ".ui-selected", obj2
).each(function() {
1277 var index
= $
( "#build_DX_list li" ).index( this
);
1278 if ($
('#build_DX_list li span')[index
].id
.match(/DX_POH_(.*)/)) {
1279 surface
= 'POH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POH_(.*)/)[1];
1280 IMP_order
[k
] = surface
;
1281 }else if ($
('#build_DX_list li span')[index
].id
.match(/DX_POS_(.*)/)) {
1282 surface
= 'POS_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POS_(.*)/)[1];
1283 IMP_order
[k
] = surface
;
1284 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_PMH_(.*)/)) {
1285 surface
= 'PMH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_PMH_(.*)/)[1];
1286 IMP_order
[k
] = surface
;
1287 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_Clinical_(.*)/)) {
1288 surface
= 'CLINICAL_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_Clinical_(.*)/)[1];
1289 IMP_order
[k
] = surface
;
1295 * This function builds the Impression/Plan area using the object supplied: items
1296 * It appends "items" into the Impression Plan area, complete with:
1297 * contenteditable Titles (the Impression),
1298 * its code (if part of the item object),
1299 * Plan textareas (autofilled with the item/object's "comment")
1300 * for each member of "items".
1301 * Duplicates are removed by server.
1303 function build_IMPPLAN(items
,nodisplay
) {
1305 if (typeof nodisplay
== "undefined") {
1306 $
('#IMPPLAN_zone').html("");
1308 $
('#Coding_DX_Codes').html("");
1309 $
('#visit_justification').html("");
1311 if ((items
== null) ||
( (typeof items
== "undefined") ||
(items
.length
=='0') ) ) {
1313 $
('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1314 $
('#IMPPLAN_zone').addClass('nodisplay');
1316 //ok we have at least one item, display them in order; hide the Builder instructions
1317 $
('#IMPPLAN_text').addClass('nodisplay');
1318 $
('#IMPPLAN_zone').removeClass('nodisplay');
1320 visit_justifier
=[];
1321 $
.each(items
, function( index
, value
) {
1322 if (!value
.codetext
) value
.codetext
="";
1323 if (!value
.code
) value
.code
="";
1324 if ((value
.code
==="") ||
(value
.code
.match(/Code
/) ||
(value
.code
==null))) {
1325 value
.code
="<i class='fa fa-search-plus'></i> Code";
1329 if (value
.code
.match(/\
,/g
)) {
1330 // If there is a comma in there, there is more than one code present for this item. Split them out.
1331 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1332 // PMSFH_link is only present when the Builder was used to make the entry.
1334 // So if there is no PMSFH_link and it is not generated from a clinical field:
1335 if ( ((typeof value
.PMSFH_link
!== "undefined") ||
(value
.PMSFH_link
!== null)) && (!value
.PMSFH_link
.match(/Clinical_(.*)/)) ) {
1336 //The Title should have the description.
1337 var CodeArr
= value
.code
.split(",");
1338 var TitleArr
= value
.codedesc
.split("\r");//I don't see a second codedesc being adding in for this yet...
1339 for (i
=0;i
< CodeArr
.length
;i++
) {
1340 if (CodeArr
.length
== (TitleArr
.length
-1)) { //there is a trailing \r but second codedesc should have "\r" also
1341 $
('#Coding_DX_Codes').append(count_dx +
'. '+CodeArr
[i
]+
': '+TitleArr
[i
]+
'<br />');
1343 justify_btn
= '<span class="modifier status_on" name="visit_justifier" id="visit_just_'+count_dx+
'" value="" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span>';
1344 $
('#visit_justification').append(justify_btn
);
1345 visit_justifier
.push(value
.codetype+
'|'+value
.code
[i
]);
1347 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1348 $
('#Coding_DX_Codes').append(CodeArr
[i
]+
': <?php echo xlt('Manually retrieve description on Fee Sheet
'); ?> <br />');
1350 var justify_btn
= '<span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" value="" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span>';
1352 $
('#visit_justification').append(justify_btn
);
1353 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1358 // So there IS a PMSFH_link or it was generated from a clinical field:
1360 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1361 if (value
.PMSFH_link
.match(/Clinical_(.*)/)) {
1362 if (typeof obj
.Clinical
!== "undefined") {
1363 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1364 if (obj
.Clinical
[location
]!=null ) {
1365 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1366 $
('#Coding_DX_Codes').append(count_dx +
'. '+obj
.Clinical
[location
][i
].code+
': '+obj
.Clinical
[location
][i
].codedesc+
'<br />');
1367 justify_btn
= '<span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" value="" data-justcode="'+obj
.Clinical
[location
][i
].codetype+
'|'+obj
.Clinical
[location
][i
].code+
'" title="'+obj
.Clinical
[location
][i
].codedesc+
'">'+count_dx+
'</span>';
1369 $
('#visit_justification').append(justify_btn
);
1371 visit_justifier
.push(obj
.Clinical
[location
][i
].codetype+
'|'+obj
.Clinical
[location
][i
].code
);
1377 } else { //all is good, one code only
1378 $
('#Coding_DX_Codes').append(count_dx +
'. '+value
.code+
': '+value
.codedesc+
'<br />');
1380 justify_btn
= ' <span class="modifier status_on" id="visit_just_'+count_dx+
'" name="visit_justifier" data-justcode="'+value
.codetype+
'|'+value
.code+
'" title="'+value
.codedesc+
'">'+count_dx+
'</span> ';
1381 $
('#visit_justification').append(justify_btn
);
1382 //we assume the visit code will use this as a justification in billing so activate that link now.
1383 visit_justifier
.push(value
.codetype+
'|'+value
.code
);
1387 if (typeof nodisplay
!== "undefined") {
1390 var title2
= value
.title
.replace(/(\')/g
, '');
1391 contents_here
= "<span class='bold' contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+
"'>" +
1392 value
.title +
"</span>"+
1393 " <span contenteditable class='float-right' onclick='sel_diagnosis("+index+
",\""+title2+
"\");' title='"+value
.codetext+
"' id='CODE_"+index+
"'>"+
1394 value
.code +
"</span>"+
1395 "<br /><textarea id='PLAN_"+index+
"' name='PLAN_"+index+
1396 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1397 value
.plan +
"</textarea><br /></li>";
1398 $
('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+
'" class="IMPPLAN_class">'+
1399 '<i class="float-right fa fa-times" id="BUTTON_IMPPLAN_'+index+
'"></i>'+
1400 contents_here+
'</div>');
1401 $
('#BUTTON_IMPPLAN_'+index
).on('click', function() {//delete/close icon
1402 var item
= this
.id
.match(/BUTTON_IMPPLAN_(.*)/)[1];
1403 obj
.IMPPLAN_items
.splice(item
,1);
1404 build_IMPPLAN(obj
.IMPPLAN_items
);
1405 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1407 $
('#PLAN_'+index
).css("background-color","#F0F8FF");
1410 //now attach visit_justifier(s) to each TEST
1411 //If the TEST_justifiers were ever touched AND
1412 $
.each($
(".TESTS_justify"), function( index
, value
) {
1414 var herenow
= $
("#TEST_"+index+
"_justify");
1416 for (var i
= 0, length
= visit_justifier
.length
; i
< length
; i++
) {
1417 item2
= visit_justifier
[i
];
1419 for (var j
=0;j
< CODING_items
.length
; j++
) {
1420 if (CODING_items
[j
].justify
== item2
) {
1424 //if item2 is in CODING_items, it will have class=status_on and we need modifier 25, maybe 59 if there are two or more?
1425 justify_btn
= ' <span class="modifier '+status+
'" id="TEST_'+index+
'_just_'+i+
'" name="TEST_'+index+
'_justifiers" value="" data-justcode="'+item2+
'" title="'+item2+
'">'+
(i+
1)+
'</span>';
1426 herenow
.append(justify_btn
);
1430 // The IMPRESSION DXs are "contenteditable" spans.
1431 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1432 $
('[id^=IMPRESSION_]').on('blur', function(e
) {
1434 var item
= this
.id
.match(/IMPRESSION_(.*)/)[1];
1435 var content
= this
.innerText || this
.innerHTML
;
1437 if (pmsfh_here
= obj
.IMPPLAN_items
[item
].PMSFH_link
.match(/(.*)\
_(.*)/)) {
1438 //we are going to change how this appears in PMH too.
1439 var pmsfh_zone
= pmsfh_here
[1];
1440 var pmsfh_item
= pmsfh_here
[2];
1441 obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].title
= content
;
1442 alter_issue2(obj
.PMSFH
[pmsfh_zone
][pmsfh_item
].issue
,pmsfh_zone
,pmsfh_item
);
1445 obj
.IMPPLAN_items
[item
].title
= content
;
1446 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1447 //$(this).css('background-color','#F0F8FF');
1450 $
('[id^=CODE_]').on('blur', function() {
1451 var item
= this
.id
.match(/CODE_(.*)/)[1];
1452 var new_code
= this
.innerText || this
.innerHTML
;
1453 obj
.IMPPLAN_items
[item
].code
= new_code
;
1454 //obj.IMPPLAN_items[item].codetext = '';
1455 //obj.IMPPLAN_items[item].codedesc = '';
1456 $
(this
).css('background-color','#F0F8FF');
1457 store_IMPPLAN(obj
.IMPPLAN_items
);
1460 $
('[id^=PLAN_]').on('change', function() {
1461 var item
= this
.id
.match(/PLAN_(.*)/)[1];
1462 obj
.IMPPLAN_items
[item
].plan
= $
(this
).val();
1463 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1464 $
(this
).css('background-color','#F0F8FF');
1467 $
('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e
){
1468 //$(this).css('height', 'auto' );
1469 // $(this).height( this.scrollHeight );
1471 $
('#IMPPLAN_zone').find( 'textarea' ).keyup();
1472 obj
.IMPPLAN_items
= items
;
1478 * This functions updates a PMSFH item's code on the server via its issue number
1480 function update_PMSFH_code(the_issue
,new_code
){
1481 var url
= "../../forms/eye_mag/save.php?mode=update";
1482 top
.restoreSession();
1487 action
: 'code_PMSFH',
1488 pid
: $
('#pid').val(),
1489 form_id
: $
('#form_id').val(),
1490 encounter
: $
('#encounter').val(),
1491 uniqueID
: $
('#uniqueID').val(),
1495 }).done(function(result
) {
1496 if (result
== 'Code 400') {
1497 code_400(); //the user does not have write privileges!
1505 * This function sends the obj.IMPPLAN_items to the server for storage
1507 function store_IMPPLAN(storage
,nodisplay
) {
1508 if (typeof storage
!== "undefined") {
1509 var url
= "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1510 var formData
= JSON
.stringify(storage
);
1511 top
.restoreSession();
1517 parameter
: formData
,
1518 action
: 'store_IMPPLAN',
1519 pid
: $
('#pid').val(),
1520 form_id
: $
('#form_id').val(),
1521 encounter
: $
('#encounter').val(),
1522 uniqueID
: $
('#uniqueID').val()
1524 }).done(function(result
) {
1525 if (result
== "Code 400") {
1526 code_400(); //the user does not have write privileges!
1529 obj
.IMPPLAN_items
= result
;
1530 // if (typeof nodisplay === "undefined") {
1531 build_IMPPLAN(obj
.IMPPLAN_items
,nodisplay
);
1539 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1542 function CODING_to_feesheet(CODING_items
) {
1543 if (typeof CODING_items
!== "undefined") {
1544 var url
= "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1545 var formData
= JSON
.stringify(CODING_items
);
1546 top
.restoreSession();
1551 'parameter' : formData
,
1552 'action' : 'code_visit',
1553 'pid' : $
('#pid').val(),
1554 'form_id' : $
('#form_id').val(),
1555 'encounter' : $
('#encounter').val(),
1556 'uniqueID' : $
('#uniqueID').val()
1558 }).done(function(result
) {
1559 if (result
== "Code 400") {
1560 code_400(); //the user does not have write privileges!
1563 //$("#goto_fee_sheet").prop('disabled', false);
1564 $
("#goto_fee_sheet").removeClass('nodisplay');
1572 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1573 * This item is appended to the $('#IMPPLAN_zone').
1575 function dragto_IMPPLAN_zone(event
, ui
) {
1576 var findme
= ui
.draggable
.find("span").attr("id");
1577 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1578 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1580 var the_codedesc
='';
1581 var the_codetext
='';
1583 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
1584 if (group
=="Clinical") {
1585 //more than one field can contain this DX.
1586 //Group them into one IMPPLAN.
1587 for (i
=0;i
< obj
.Clinical
[location
].length
; i++
) {
1588 the_code +
= obj
.Clinical
[location
][i
]['code']+
',';
1589 the_codedesc
= obj
.Clinical
[location
][i
]['codedesc'];
1590 the_codetext
= obj
.Clinical
[location
][i
]['codetext'];
1591 the_plan +
= obj
.Clinical
[location
][i
]['codedesc'] +
"\r";
1593 if (i
> 0) the_code
= the_code
.slice(0, -1);
1594 obj
.IMPPLAN_items
.push({
1596 codedesc
: the_codedesc
,
1597 codetext
: the_codetext
,
1598 codetype
: obj
.Clinical
[location
][0]['codetype'],
1600 PMSFH_link
: obj
.Clinical
[location
][0]['PMSFH_link'],
1601 title
: obj
.Clinical
[location
][0]['title']
1605 obj
.IMPPLAN_items
.push({
1606 code
: obj
.PMSFH
[group
][location
]['code'],
1607 codedesc
: obj
.PMSFH
[group
][location
]['codedesc'],
1608 codetext
: obj
.PMSFH
[group
][location
]['codetext'],
1609 codetype
: obj
.PMSFH
[group
][location
]['codetype'],
1610 plan
: obj
.PMSFH
[group
][location
]['comments'],
1611 PMSFH_link
: obj
.PMSFH
[group
][location
]['PMSFH_link'],
1612 title
: obj
.PMSFH
[group
][location
]['title']
1616 store_IMPPLAN(obj
.IMPPLAN_items
); //redisplay the items
1619 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field (#IMP) <-- New Dx textarea
1620 * The data is appended to the end of the text.
1621 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1623 function dragto_IMPPLAN(event
, ui
) {
1624 var findme
= ui
.draggable
.find("span").attr("id");
1625 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1626 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1627 var draggable2
= ui
.draggable
;
1628 if (group
=="Clinical") {
1629 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n");
1631 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n"+obj
.PMSFH
[group
][location
]['comments']);
1634 /* END Functions related to IMPPLAN Builder */
1636 function Suggest_visit_code() {
1637 //assume Eyes and established patient
1638 (Code_group
!= 'Eyes') ?
(digit_2
= '9') : digit_2
= '2'; //920XX or 990XX
1639 (Code_new_est
== 'New') ?
(digit_4
= '0') : digit_4
= '1'; //9X01X or 9X00X
1640 if (detail_reached_exam
=='1' && (detail_reached_HPI
=='1')) {
1641 (Code_group
=='Eyes') ?
(digit_5
= '4') : (digit_5
='3'); //920X4 or 990X3
1642 detailed
= "comprehensive";
1644 digit_5
= '2'; //920X2
1645 detailed
= "intermediate";
1647 visit_desc
= Code_new_est +
" "+ detailed +
" "+digit_5
;
1648 visit_code
= "9"+digit_2+
"0"+digit_4+digit_5
;
1649 $
('#visit_codes').val("CPT4|"+visit_code+
"|").change();
1652 * This function builds the codes and populates the billing table for this encounter.
1654 function build_CODING_list() {
1656 /* the following things get billed:
1657 1. Visit code(s) including neurosensory if performed
1661 //3. Diagnostic Codes
1662 $
.each(obj
.IMPPLAN_items
, function( index
, value
) {
1663 if (value
['codetype']) {
1664 if (value
['code'].match(/\
,/g
)) {
1665 // physical finding found in more than one location, more than one code...
1666 // if there is a comma in there, there is more than one code present. Split them out.
1667 // And all those in one group have the same link out (PMSFH_link) value
1668 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1669 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1671 code
: obj
.Clinical
[location
][i
]['code'],
1672 codedesc
: obj
.Clinical
[location
][i
]['codedesc'],
1673 codetext
: obj
.Clinical
[location
][i
]['codetext'],
1674 codetype
: obj
.Clinical
[location
][i
]['codetype'],
1675 title
: obj
.Clinical
[location
][i
]['title']
1678 } else if (value
['code'].match(/Code
/)){
1682 code
: value
['code'],
1683 codedesc
: value
['codedesc'],
1684 codetext
: value
['codetext'],
1685 codetype
: value
['codetype'],
1686 title
: value
['title']
1692 //1. Visit Codes. These can have a modifier (22,24,25,57 hard coded so far)
1693 var visit_justify
= visit_justifier
.join(":");
1694 if (typeof visit_modifier
!= "object") {
1695 visit_modifiers
= [];
1697 visit_modifiers
= visit_modifier
.join(":");//
1701 codedesc
: visit_desc
,
1704 title
: 'Visit Code',
1705 modifier
: visit_modifiers
,
1706 justify
: visit_justify
1709 if (CPT_92060
== 'here') {
1712 codedesc
: 'Sensorimotor exam',
1713 codetext
: 'Sensorimotor exam (CPT4:92060)',
1715 title
: 'Neuro/Sensorimotor Code',
1716 justify
: visit_justify
1719 //2. Tests/procedures performed to bill
1720 $
('.TESTS').each(function(i
, obj
) {
1721 if ($
(this
).is(':checked')) {
1722 var codetype
= obj
.value
.match(/(.*):(.*)/)[1];
1723 var code
= obj
.value
.match(/(.*):(.*)/)[2];
1724 var modifier
= $
('#'+obj
.id+
'_modifier').val();
1726 $
('[name="TEST_'+i+
'_justifiers"]').each(function(j
,obj2
) {
1727 if ($
('#TEST_'+i+
'_just_'+j
).hasClass('status_on') ) {
1728 var h
= $
(this
).data();
1729 justify
= h
.justcode
;
1732 var d
= $
(this
).data();
1735 'codedesc' : d
.title
,
1736 'codetext' : d
.codetext
,
1737 'codetype' : codetype
,
1739 'modifier' : modifier
,
1747 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1749 function toggle_active_flags(new_state
) {
1750 if (($
("#chart_status").val() == "off") ||
(new_state
== "on")) {
1751 // we are read-only and we want to go active.
1752 $
("#chart_status").val("on");
1753 $
("#active_flag").html(" Active Chart ");
1754 $
("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1755 $
("#warning").addClass("nodisplay");
1756 $
('input, select, textarea, a').removeAttr('disabled');
1757 $
('input, textarea').removeAttr('readonly');
1759 //else clicking this means we want to go from active to read-only
1760 $
("#chart_status").val("off");
1761 $
("#active_flag").html(" READ-ONLY ");
1762 $
("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1763 $
("#warning").removeClass("nodisplay");
1764 //we should tell the form fields to be disabled. should already be...
1765 $
('input, select, textarea, a').attr('disabled', 'disabled');
1766 $
('input, textarea').attr('readonly', 'readonly');
1767 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1768 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1769 this_form_id
= $
("#form_id").val();
1770 $
("#COPY_SECTION").val("READONLY-"+this_form_id
);
1774 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1776 function update_READONLY() {
1778 'action' : 'retrieve',
1779 'copy' : 'READONLY',
1780 'zone' : 'READONLY',
1781 'copy_to' : $
("#form_id").val(),
1782 'copy_from' : $
("#form_id").val(),
1783 'pid' : $
("#pid").val()
1785 //we are going to update the whole form
1786 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1787 //We are not ready to actively chart, just looking to see how far along our staff is...
1788 //or maybe just looking ahead to see the who's being worked up in the next room?
1789 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1790 // yet it is updating every 10-15 seconds if another user is making changes.
1791 top
.restoreSession();
1795 url
: "../../forms/eye_mag/save.php?copy=READONLY",
1797 success
: function(result
) {
1798 $
.map(result
, function(valhere
, keyhere
) {
1799 if ($
("#"+keyhere
).val() != valhere
) {
1800 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
1802 if (keyhere
.match(/MOTILITY_
/)) {
1803 // Copy forward ductions and versions visually
1804 // Make each blank, and rebuild them
1805 $
("[name='"+keyhere+
"_1']").html('');
1806 $
("[name='"+keyhere+
"_2']").html('');
1807 $
("[name='"+keyhere+
"_3']").html('');
1808 $
("[name='"+keyhere+
"_4']").html('');
1809 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
1810 // Show a horizontal (minus) tag.
1811 hash_tag
= '<i class="fa fa-minus"></i>';
1812 } else { //show vertical tag
1813 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
1815 for (index
=1; index
<= valhere
; ++index
) {
1816 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
1818 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
1819 if (valhere
=='1') {
1820 $
("#FieldsNormal").prop('checked', false);
1821 $
("#"+keyhere
).prop('checked', true);
1822 $
("#"+keyhere
).val('1');
1824 $
("#"+keyhere
).val('0');
1825 $
("#"+keyhere
).prop('checked', false);
1827 } else if (keyhere
.match(/AMSLERO(.)/)) {
1828 var sidehere
= keyhere
.match(/AMSLERO(.)/);
1829 if (valhere
< '1') valhere
='0';
1830 $
("#"+keyhere
).val(valhere
);
1831 var srcvalue
="AmslerO"+sidehere
[1];
1832 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
1833 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
1834 } else if (keyhere
.match(/VA$
/)) {
1835 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
1836 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
1837 } else if (keyhere
.match(/^O
.VA_
/)) {
1838 var side
=keyhere
.match(/(O
.)VA_(.)/)[1];
1839 var rx_number
=keyhere
.match(/(O
.)VA_(.)/)[2];
1840 if (rx_number
== '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1841 $
('#'+side+
'VA_1_copy').val(valhere
).css("background-color","#F0F8FF");;
1842 $
('#'+side+
'VA_1_copy_brd').val(valhere
).css("background-color","#F0F8FF");;
1844 } else if (keyhere
.match(/^RX_TYPE_\d$
/)) {
1845 if (typeof $
('input:radio[name='+keyhere+
']')[valhere
] !== "undefined") {
1846 $
('input:radio[name='+keyhere+
']')[valhere
].checked
= true;
1848 } else if (keyhere
.match(/(alert|oriented|confused|PUPIL_NORMAL
)/)) {
1849 if (valhere
=='1') {
1850 $
('#'+keyhere
).val(valhere
).prop('checked', true);
1852 $
('#'+keyhere
).val(valhere
).prop('checked', false);
1858 function dopopup(url
) {
1859 window
.open(url
, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1861 function goto_url(url
) {
1863 top
.restoreSession();
1866 //is this used anywhere? Looks like it should be deleted...
1867 function openImage() {
1868 dlgopen(base+
'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1871 // Called to open a document in another tab for this encounter.
1872 function openDocumentNewTab(doc_id
) {
1873 var url
= '../../interface/patient_file/encounter/view_form.php?formname=' + formdir +
'&id=' + formid
;
1874 if (formdir
== 'newpatient' ||
!parent
.twAddFrameTab
) {
1875 top
.restoreSession();
1876 location
.href
= url
;
1878 parent
.twAddFrameTab('enctabs', formname
, url
);
1883 function HPI_sync_heights() {
1884 if ( ($
('#PMSFH_block_1').height() > $
('#PMH_left').height() ) ||
1885 ($
('#PMSFH_block_2').height() > $
('#PMH_left').height()) )
1887 if ($
('#PMSFH_block_1').height() > $
('#PMSFH_block_2').height()) {
1888 heights
= $
('#PMSFH_block_1').height();
1890 heights
= $
('#PMSFH_block_2').height();
1892 $
('#PMH_left').height(heights
);
1893 $
('#PMH_right').height(heights
)
1894 $
('#PMH_1').height(heights+
20);
1895 } else if ( $
("#PMH_2").hasClass('nodisplay') ) {
1896 $
('#PMH_1').height($
('#HPI_1').height());
1898 $
('#PMH_1').height($
('#PMH_2').height());
1902 * Keyboard shortcut commands.
1905 shortcut
.add("Control+T",function() {
1908 shortcut
.add("Meta+T",function() {
1911 shortcut
.add("Control+D",function() {
1914 shortcut
.add("Meta+D",function() {
1917 shortcut
.add("Control+P",function() {
1918 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1920 shortcut
.add("Meta+P",function() {
1922 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1924 shortcut
.add("Control+B",function() {
1927 shortcut
.add("Meta+B",function() {
1930 shortcut
.add("Control+K",function() {
1933 shortcut
.add("Meta+K",function() {
1938 * this swallows backspace keys on the "rx" elements.
1939 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1941 var rx
= /INPUT|SELECT|TEXTAREA|SPAN|DIV
/i
;
1943 $
(document
).bind("keydown keypress", function(e
){
1944 if( e
.which
== 8 ){ // 8 == backspace
1945 if(!rx
.test(e
.target
.tagName
) || e
.target
.disabled || e
.target
.readOnly
){
1953 * Function to update the PCP and referring person
1956 function update_DOCS() {
1957 var url
= "../../forms/eye_mag/save.php?mode=update";
1958 top
.restoreSession();
1964 pid
: $
('#pid').val(),
1965 pcp
: $
('#form_PCP').val(),
1966 rDOC
: $
('#form_rDOC').val(),
1967 form_id
: $
('#form_id').val(),
1968 encounter
: $
('#encounter').val(),
1969 uniqueID
: $
('#uniqueID').val()
1971 }).done(function(result
) {
1972 if (result
== "Code 400") {
1973 code_400(); //the user does not have write privileges!
1976 obj
= JSON
.parse(result
);
1982 * Function to update the PCP and Referring Doctors data.
1983 * Initial use: update data returned from an ajax call.
1985 function build_DOCS(DOCS
) {
1987 $
("#pcp_name").html(DOCS
['pcp']['name']);
1988 $
("#pcp_address").html(DOCS
['pcp']['address']);
1989 $
("#pcp_phone").html(DOCS
['pcp']['phone']);
1990 $
("#pcp_phonew2").html(DOCS
['pcp']['phone2']);
1991 $
("#pcp_fax").html(DOCS
['pcp']['fax']);
1992 $
("#pcp_fax_info").html(DOCS
['pcp']['fax_info']);
1994 $
("#pcp_name").html('');
1995 $
("#pcp_address").html('');
1996 $
("#pcp_phone").html('');
1997 $
("#pcp_phonew2").html('');
1998 $
("#pcp_fax").html('');
1999 $
("#pcp_fax_info").html('');
2002 $
("#ref_name").html(DOCS
['ref']['name']);
2003 $
("#ref_address").html(DOCS
['ref']['address']);
2004 $
("#ref_phone").html(DOCS
['ref']['phone']);
2005 $
("#ref_phonew2").html(DOCS
['ref']['phonew2']);
2006 $
("#ref_fax").html(DOCS
['ref']['fax']);
2007 $
("#ref_fax_info").html(DOCS
['ref']['fax_info']);
2009 $
("#ref_name").html('');
2010 $
("#ref_address").html('');
2011 $
("#ref_phone").html('');
2012 $
("#ref_phonew2").html('');
2013 $
("#ref_fax").html('');
2014 $
("#ref_fax_info").html('');
2019 * Function to update the patient's current pharmacy
2022 function update_Pharma() {
2023 //$(#form_pharmacy_id) has changed value, update the patient_data field pharmacy_id
2024 var pharm
= $
("#form_pharmacy_id").val();
2025 var url
= "../../forms/eye_mag/save.php?mode=update";
2026 top
.restoreSession();
2031 action
: 'new_pharmacy',
2032 pid
: $
('#pid').val(),
2033 form_id
: $
('#form_id').val(),
2034 encounter
: $
('#encounter').val(),
2035 uniqueID
: $
('#uniqueID').val(),
2036 pc_eid
: $
("#pc_eid").val(),
2037 visit_date
: $
("#visit_date").val(),
2038 new_pharmacy
: pharm
2040 }).done(function(result
) {
2041 if (result
== "Code 400") {
2042 code_400(); //the user does not have write privileges!
2050 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
2053 function reverse_cylinder(target
) {
2054 //target can be revW1-5,AR,MR,CR,CTL,
2057 if (target
.match(/^
(AR|MR|CR|CTL
)$
/)) {
2061 if (target
.match(/^revW
[1-5]{1}$
/)) { //matches on digit only, here 1-5
2062 target
= target
.replace("revW","");
2064 suffix
= '_'+target
;
2066 var Rsph
= $
('#'+prefix+
'ODSPH'+suffix
).val();
2067 var Rcyl
= $
('#'+prefix+
'ODCYL'+suffix
).val();
2068 var Raxis
= $
('#'+prefix+
'ODAXIS'+suffix
).val();
2069 var Lsph
= $
('#'+prefix+
'OSSPH'+suffix
).val();
2070 var Lcyl
= $
('#'+prefix+
'OSCYL'+suffix
).val();
2071 var Laxis
= $
('#'+prefix+
'OSAXIS'+suffix
).val();
2072 if (Rsph
=='' && Rcyl
=='' && Lsph
=='' && lcyl
=='') return;
2073 if ((!Rcyl
.match(/SPH
/i
)) && (Rcyl
>'')) {
2074 if (Rsph
.match(/plano
/i
)) Rsph
='0';
2075 Rsph
= Number(Rsph
);
2076 Rcyl
= Number(Rcyl
);
2077 Rnewsph
= Rsph + Rcyl
;
2078 if (Rnewsph
==0) Rnewsph
="PLANO";
2079 Rnewcyl
= Rcyl
* -1;
2080 if (Rnewcyl
> 0) Rnewcyl
= "+"+Rnewcyl
;
2081 if (parseInt(Raxis
) < 90) {
2082 Rnewaxis
= parseInt(Raxis
) +
90;
2084 Rnewaxis
= parseInt(Raxis
) - 90;
2086 if (Rnewcyl
=='0') Rnewcyl
= "SPH";
2087 if (Rnewsph
=='0') {
2089 if (Rnewcyl
=="SPH") Rnewcyl
= '';
2091 $
('#'+prefix+
'ODSPH'+suffix
).val(Rnewsph
);
2092 $
('#'+prefix+
'ODCYL'+suffix
).val(Rnewcyl
);
2093 $
('#'+prefix+
'ODAXIS'+suffix
).val(Rnewaxis
);
2094 $
('#'+prefix+
'ODAXIS'+suffix
).trigger('blur');
2095 $
('#'+prefix+
'ODSPH'+suffix
).trigger('blur');
2096 $
('#'+prefix+
'ODCYL'+suffix
).trigger('blur');
2098 if ((!Lcyl
.match(/SPH
/i
)) && (Lcyl
>'')) {
2099 if (!Lsph
.match(/\d
/)) Lsph
='0';
2100 Lsph
= Number(Lsph
);
2101 Lcyl
= Number(Lcyl
);
2102 Lnewsph
= Lsph + Lcyl
;
2103 Lnewcyl
= Lcyl
* -1;
2104 if (Lnewcyl
> 0) Lnewcyl
= "+"+ Lnewcyl
;
2105 if (parseInt(Laxis
) < 90) {
2106 Lnewaxis
= parseInt(Laxis
) +
90;
2108 Lnewaxis
= parseInt(Laxis
) - 90;
2111 if (Lnewcyl
=='0') Lnewcyl
= "SPH";
2112 if (Lnewsph
=='0') {
2114 if (Lnewcyl
=="SPH") Lnewcyl
= '';
2117 $
('#'+prefix+
'OSSPH'+suffix
).val(Lnewsph
);
2118 $
('#'+prefix+
'OSCYL'+suffix
).val(Lnewcyl
);
2119 $
('#'+prefix+
'OSAXIS'+suffix
).val(Lnewaxis
);
2120 $
('#'+prefix+
'OSAXIS'+suffix
).trigger('blur');
2121 $
('#'+prefix+
'OSSPH'+suffix
).trigger('blur');
2122 $
('#'+prefix+
'OSCYL'+suffix
).trigger('blur');
2125 function scrollTo(target
) {
2127 var scrollSpeed
= 500;
2128 var wheight
= $
(window
).height();
2129 offset
= $
("#"+target
).offset().top
- (wheight
/ 2)+
200;
2130 if (offset
> (window
.pageYOffset +
150)||offset
< (window
.pageYOffset
-150)) {
2131 $
('html, body').animate({scrollTop
:offset
}, scrollSpeed
);
2135 function update_appt_status(new_status
) {
2136 var url
= "../../forms/eye_mag/save.php?mode=update";
2137 top
.restoreSession();
2142 action
: 'new_appt_status',
2143 pid
: $
('#pid').val(),
2144 form_id
: $
('#form_id').val(),
2145 encounter
: $
('#encounter').val(),
2146 uniqueID
: $
('#uniqueID').val(),
2147 pc_eid
: $
("#pc_eid").val(),
2148 visit_date
: $
("#visit_date").val(),
2149 new_status
: new_status
2151 }).done(function(result
) {
2152 if (result
== "Code 400") {
2153 code_400(); //the user does not have write privileges!
2158 function color_IOP(IOP
){
2159 if (!$
.isNumeric(IOP
.value
)) return;
2160 if (IOP
.value
> '21') {
2161 $
(IOP
).css("background-color","rgb(255, 153, 153)");
2164 function showpnotes(docid
) {
2165 let btnClose
= 'Done';
2166 let url
= base+
'/interface/patient_file/summary/pnotes.php?docid=' +
encodeURIComponent(docid
);
2167 dlgopen(url
, 'pno1', 'modal-xl', 500, '', '', {
2169 {text
: btnClose
, close
: true, style
: 'default btn-sm'}
2179 function getTimeStamp() {
2180 var now
= new Date();
2181 var AMPM
= now
.getHours() >= 12 ?
'PM' : 'AM';
2182 return now
.getHours() +
':' +
((now
.getMinutes() < 10) ?
("0" + now
.getMinutes()) : (now
.getMinutes())) + AMPM
;
2186 * This function is only run onload to hide sections per user preference.
2187 * Any changes during the encounter to display or hide a section are stored
2188 * as a previous setting and the next eye form opened will appear the same way.
2190 function show_by_setting() {
2191 var tabs_left
= $
("#setting_tabs_left").val();
2192 if (typeof tabs_left
==undefined
) exit;
2193 var arrSet
= ["HPI","PMH","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2194 sLen
= arrSet
.length
;
2195 for (i
= 0; i
< sLen
; i++
) {
2196 var value
= $
("#setting_"+arrSet
[i
]).val();
2197 if (typeof value
!== undefined
&& value
!='1') {
2198 $
('#tabs-left-'+arrSet
[i
]).addClass('ui-state-default');
2199 $
("#setting_"+arrSet
[i
]).val('0');
2200 $
("#"+arrSet
[i
]+
'_1').addClass('nodisplay');
2201 $
("#setting_"+arrSet
[i
]).val('0');
2203 $
("#setting_"+arrSet
[i
]).val('1');
2206 if (tabs_left
== '0') {
2207 $
("#tabs_left").addClass('nodisplay');
2209 $
("#tabs_left").removeClass('nodisplay');
2218 var allPanels
= $
('.building_blocks > dd').hide();
2219 var allPanels2
= $
('.building_blocks2 > dd').hide();
2222 // AUTO- CODING FEATURES
2224 check_exam_detail();
2227 //alert('Suggest a Code');
2228 Suggest_visit_code();
2229 show_QP_section('IMPPLAN','1');
2232 //on checking TESTS, show modifiers and justifier fields
2233 $
(".TESTS").on("click", function() {
2234 var test_id
= this
.id
;
2235 if ($
(this
).is(':checked')) {
2236 $
("#"+test_id+
"_justmods").removeClass('nodisplay');
2237 $
("#"+test_id+
"_modifier").val('59');
2238 //make vist_modifier 25 light up too...
2239 $
(this
).parent().removeClass('lights_off').addClass('lights_on');
2241 $
("#"+test_id+
"_justmods").addClass('nodisplay');
2242 $
(this
).parent().removeClass('lights_on').addClass('lights_off');
2246 $
('[title]').tooltip();
2247 $
('#form_PCP,#form_rDOC').on('change', function() {
2251 $
("#form_pharmacy_id").change(function() {
2255 $
('#tooltips_status').html($
('#PREFS_TOOLTIPS').val());
2256 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
2257 $
('[title]').each(function() {
2258 var $this = $
(this
);
2259 $this.data('title',$this.attr('title'));
2260 $this.attr('title', '');
2263 $
('#tooltips_toggle,#tooltips_status').on('click', function() {
2264 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
2265 $
('#PREFS_TOOLTIPS').val('<?php echo xla('Off
'); ?>');
2266 $
("#tooltips_status").html('<?php echo xla('are off
'); ?>');
2267 $
('[title]').each(function() {
2268 var $this = $
(this
);
2269 $this.data('title',$this.attr('title'));
2270 $this.attr('title', '');
2273 $
('#PREFS_TOOLTIPS').val('<?php echo xla('On
'); ?>');
2274 $
('#tooltips_status').html('<?php echo xla('are on
'); ?>');
2275 $
('[title]').each(function() {
2276 var $this = $
(this
);
2277 $this.attr('title', $this.data('title'));
2282 $
('#toggle_drugs').on('click', function(){
2283 $
('.hideme_drugs').toggleClass('nodisplay');
2284 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2287 $
('#toggle_VFs').on('click', function(){
2288 $
('.hideme_VFs').toggleClass('nodisplay');
2289 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2292 $
('#toggle_OCTs').on('click', function(){
2293 $
('.hideme_OCTs').toggleClass('nodisplay');
2294 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2297 $
('#toggle_cups').on('click', function(){
2298 $
('.hideme_cups').toggleClass('nodisplay');
2299 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2302 $
('#toggle_gonios').on('click', function(){
2303 $
('.hideme_gonios').toggleClass('nodisplay');
2304 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
2307 $
('.close').on('click', function(){
2308 $
('#GFS_accordion .hide').slideUp();
2310 $
('#ODIOPTARGET').on('change', function() {
2311 $
('#OSIOPTARGET').val($
('#ODIOPTARGET').val());
2314 $
('#ODIOPAP,#OSIOPAP,#ODIOPTARGET,#ODIOPTPN,#OSIOPTPN,#OSIOPTARGET').on('change', function() {
2315 //this is failing if there is no config_by_day variable.
2318 if ($
("#PREFS_KB").val() =='1') {
2319 $
(".kb").removeClass('nodisplay');
2320 $
(".kb_off").addClass('nodisplay');
2322 $
(".kb").addClass('nodisplay');
2323 $
(".kb_off").removeClass('nodisplay');
2326 $
("[name$='_kb']").on('click', function() {
2327 $
('.kb').toggleClass('nodisplay');
2328 $
('.kb_off').toggleClass('nodisplay');
2329 $
('.copier').toggleClass('nodisplay');
2330 if ($
('#PREFS_EXAM').val() == 'DRAW') {
2334 if ($
("#PREFS_KB").val() > 0) {
2335 $
("#PREFS_KB").val('0');
2337 $
("#PREFS_KB").val('1');
2341 $
('.ke').on('mouseover', function() {
2342 $
(this
).toggleClass('yellow');
2344 $
('.ke').on('mouseout', function() {
2345 $
(this
).toggleClass('yellow');
2347 $
("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e
) {
2348 //this is the Shorthand engine's ignition
2349 if (e
.which
== 13|| e
.keyCode
== 13||e
.which
== 9|| e
.keyCode
== 9) {
2351 var data_all
= $
(this
).val();
2352 var data_seg
= data_all
.match(/([^
;]*)/gm
);
2356 for (index
=0; index
< data_seg
.length
; ++index
) {
2357 if (data_seg
[index
] =='') continue;
2358 data_seg
[index
] = data_seg
[index
].replace(/^
[\n\v\f\r\x85\u2028\u2029\W
]*/
,'');
2359 data_seg
[index
] = data_seg
[index
].replace(/^
[\s
]*/
,'');
2360 if (data_seg
[index
].match(/^
D($|
;)/i
)) {
2361 $
("#EXT_defaults").trigger("click");
2362 $
("#ANTSEG_defaults").trigger("click");
2363 $
("#RETINA_defaults").trigger("click");
2364 $
("#NEURO_defaults").trigger("click");
2367 if (data_seg
[index
].match(/^
DEXT($|
;)/i
)) {
2368 $
("#EXT_defaults").trigger("click");
2371 if (data_seg
[index
].match(/^
DANTSEG($|
;)/i
)) {
2372 $
("#ANTSEG_defaults").trigger("click");
2375 if (data_seg
[index
].match(/^
DAS($|
;)/i
)) {
2376 $
("#ANTSEG_defaults").trigger("click");
2379 if (data_seg
[index
].match(/^
DRETINA($|
;)/i
)) {
2380 $
("#RETINA_defaults").trigger("click");
2383 if (data_seg
[index
].match(/^
DRET($|
;)/i
)) {
2384 $
("#RETINA_defaults").trigger("click");
2387 if (data_seg
[index
].match(/^
DNEURO($|
;)/i
)) {
2388 $
("#NEURO_defaults").trigger("click");
2391 if ((data_seg
[index
].match(/^
CLEAREXT($|
;)/i
))||
2392 (data_seg
[index
].match(/^
CEXT($|
;)/i
))) {
2396 if ((data_seg
[index
].match(/^
CLEARAS($|
;)/i
))||
2397 (data_seg
[index
].match(/^
CLEARANTSEG($|
;)/i
))||
2398 (data_seg
[index
].match(/^
CANTSEG($|
;)/i
))||
2399 (data_seg
[index
].match(/^
CANT($|
;)/i
))||
2400 (data_seg
[index
].match(/^
CAS($|
;)/i
))) {
2401 $
(".ANTSEG").val('');
2404 if ((data_seg
[index
].match(/^
CLEARRET($|
;)/i
))||
2405 (data_seg
[index
].match(/^
CRET($|
;)/i
)) ||
2406 (data_seg
[index
].match(/^
CLEARRETINA($|
;)/i
))||
2407 (data_seg
[index
].match(/^
CRETINA($|
;)/i
))) {
2408 $
(".RETINA").val('');
2413 var data
= data_seg
[index
].match(/^
(\w
*)\
:?
(.*)/);
2414 (data
[2].match(/\
.a$
/))?
(data
[2] = data
[2].replace(/\
.a$
/,'')):(appendix
= "nope");
2415 var field
= data
[1].toUpperCase();
2417 text
= expand_vocab(text
);
2418 priors
= process_kb(field
,text
,appendix
,prior_field
,prior_text
);
2419 prior_field
= priors
['field'];
2420 prior_text
= priors
['prior_text'];
2428 $
("[id^='sketch_tools_']").click(function() {
2429 var zone
= this
.id
.match(/sketch_tools_(.*)_
/)[1];
2430 $
("[id^='sketch_tools_"+zone+
"']").css("height","30px");
2431 $
(this
).css("height","50px");
2432 $
("#sketch_tool_"+zone+
"_color").css("background-image","").css("background-color",$
("#selColor_"+zone
).val());
2434 $
("[id^='sketch_sizes_']").click(function() {
2435 var zone
= this
.id
.match(/sketch_sizes_(.*)_
/)[1];
2436 $
("[id^='sketch_sizes_"+zone+
"']").css("background","").css("border-bottom","");
2437 $
(this
).css("border-bottom","2pt solid black");
2441 // Here we get CC1 to show
2442 $
(".tab_content").addClass('nodisplay');
2443 $
("#tab1_CC_text").removeClass('nodisplay');
2444 $
("#tab1_HPI_text").removeClass('nodisplay');
2445 $
("[id$='_CC'],[id$='_HPI_tab']").on('click', function() {
2446 // First remove class "active" from currently active tabs
2447 $
("[id$='_CC']").removeClass('active');
2448 $
("[id$='_HPI_tab']").removeClass('active');
2449 // Hide all tab content
2450 $
(".tab_content").addClass('nodisplay');
2451 // Here we get the href value of the selected tab
2452 var selected_tab
= $
(this
).find("a").attr("href");
2453 // Now add class "active" to the selected/clicked tab and content
2454 $
(selected_tab+
"_CC").addClass('active');
2455 $
(selected_tab+
"_CC_text").removeClass('nodisplay');
2456 $
(selected_tab+
"_HPI_tab").addClass('active');
2457 $
(selected_tab+
"_HPI_text").removeClass('nodisplay');
2458 // At the end, we add return false so that the click on the link is not executed
2461 $
("input,textarea,text").css("background-color","#FFF8DC");
2462 $
("[id*=ODIOP],[id*=OSIOP]").each(function() { color_IOP(this
); });
2463 $
("#IOPTIME").css("background-color","#FFFFFF");
2464 $
("#refraction_width").css("width","8.5in");
2465 $
(".Draw_class").addClass('nodisplay');
2466 $
(".PRIORS_class").addClass('nodisplay');
2467 $
(window
).on("resize", function() {
2468 if (window
.innerWidth
>'900') {
2469 $
("#refraction_width").css("width","900px");
2470 $
("#LayerVision2").css("padding","4px");
2472 if (window
.innerWidth
>'1300') {
2473 $
("#refraction_width").css("width","1300px");
2474 //$("#first").css("width","1300px");
2476 if (window
.innerWidth
>'1900') {
2477 $
("#refraction_width").css("width","1600px");
2483 var hash_tag
= '<i class="fa fa-minus"></i>';
2485 // display any stored MOTILITY values
2486 $
("#MOTILITY_RS").value
= parseInt($
("#MOTILITY_RS").val());
2487 if ($
("#MOTILITY_RS").val() > '0') {
2488 $
("#MOTILITYNORMAL").removeAttr('checked');
2489 for (index
=1; index
<= ($
("#MOTILITY_RS").val()); ++index
) {
2490 $
("#MOTILITY_RS_"+index
).html(hash_tag
);
2493 $
("#MOTILITY_RI").value
= parseInt($
("#MOTILITY_RI").val());
2494 if ($
("#MOTILITY_RI").val() > '0') {
2495 $
("#MOTILITYNORMAL").removeAttr('checked');
2496 for (index
=1; index
<= ($
("#MOTILITY_RI").val()); ++index
) {
2497 $
("#MOTILITY_RI_"+index
).html(hash_tag
);
2500 $
("#MOTILITY_LS").value
= parseInt($
("#MOTILITY_LS").val());
2501 if ($
("#MOTILITY_LS").val() > '0') {
2502 $
("#MOTILITYNORMAL").removeAttr('checked');
2503 for (index
=1; index
<= ($
("#MOTILITY_LS").val()); ++index
) {
2504 $
("#MOTILITY_LS_"+index
).html(hash_tag
);
2507 $
("#MOTILITY_LI").value
= parseInt($
("#MOTILITY_LI").val());
2508 if ($
("#MOTILITY_LI").val() > '0') {
2509 $
("#MOTILITYNORMAL").removeAttr('checked');
2510 for (index
=1; index
<= ($
("#MOTILITY_LI").val()); ++index
) {
2511 $
("#MOTILITY_LI_"+index
).html(hash_tag
);
2515 $
("#MOTILITY_RRSO").value
= parseInt($
("#MOTILITY_RRSO").val());
2516 if ($
("#MOTILITY_RRSO").val() > '0') {
2517 $
("#MOTILITYNORMAL").removeAttr('checked');
2518 for (index
=1; index
<= ($
("#MOTILITY_RRSO").val()); ++index
) {
2519 $
("#MOTILITY_RRSO_"+index
).html(hash_tag
);
2522 $
("#MOTILITY_RRIO").value
= parseInt($
("#MOTILITY_RRIO").val());
2523 if ($
("#MOTILITY_RRIO").val() > '0') {
2524 $
("#MOTILITYNORMAL").removeAttr('checked');
2525 for (index
=1; index
<= ($
("#MOTILITY_RRIO").val()); ++index
) {
2526 $
("#MOTILITY_RRIO_"+index
).html(hash_tag
);
2529 $
("#MOTILITY_RLIO").value
= parseInt($
("#MOTILITY_RLIO").val());
2530 if ($
("#MOTILITY_RLIO").val() > '0') {
2531 $
("#MOTILITYNORMAL").removeAttr('checked');
2532 for (index
=1; index
<= ($
("#MOTILITY_RLIO").val()); ++index
) {
2533 $
("#MOTILITY_RLIO_"+index
).html(hash_tag
);
2536 $
("#MOTILITY_RLSO").value
= parseInt($
("#MOTILITY_RLSO").val());
2537 if ($
("#MOTILITY_RLSO").val() > '0') {
2538 $
("#MOTILITYNORMAL").removeAttr('checked');
2539 for (index
=1; index
<= ($
("#MOTILITY_RLSO").val()); ++index
) {
2540 $
("#MOTILITY_RLSO_"+index
).html(hash_tag
);
2543 $
("#MOTILITY_LRSO").value
= parseInt($
("#MOTILITY_LRSO").val());
2544 if ($
("#MOTILITY_LRSO").val() > '0') {
2545 $
("#MOTILITYNORMAL").removeAttr('checked');
2546 for (index
=1; index
<= ($
("#MOTILITY_LRSO").val()); ++index
) {
2547 $
("#MOTILITY_LRSO_"+index
).html(hash_tag
);
2550 $
("#MOTILITY_LRIO").value
= parseInt($
("#MOTILITY_LRIO").val());
2551 if ($
("#MOTILITY_LRIO").val() > '0') {
2552 $
("#MOTILITYNORMAL").removeAttr('checked');
2553 for (index
=1; index
<= ($
("#MOTILITY_LRIO").val()); ++index
) {
2554 $
("#MOTILITY_LRIO_"+index
).html(hash_tag
);
2557 $
("#MOTILITY_LLSO").value
= parseInt($
("#MOTILITY_LLSO").val());
2558 if ($
("#MOTILITY_LLSO").val() > '0') {
2559 $
("#MOTILITYNORMAL").removeAttr('checked');
2560 for (index
=1; index
<= ($
("#MOTILITY_LLSO").val()); ++index
) {
2561 $
("#MOTILITY_LLSO_"+index
).html(hash_tag
);
2564 $
("#MOTILITY_LLIO").value
= parseInt($
("#MOTILITY_LLIO").val());
2565 if ($
("#MOTILITY_LLIO").val() > '0') {
2566 $
("#MOTILITYNORMAL").removeAttr('checked');
2567 for (index
=1; index
<= ($
("#MOTILITY_LLIO").val()); ++index
) {
2568 $
("#MOTILITY_LLIO_"+index
).html(hash_tag
);
2572 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
2573 $
("#MOTILITY_LR").value
= parseInt($
("#MOTILITY_LR").val());
2574 if ($
("#MOTILITY_LR").val() > '0') {
2575 $
("#MOTILITYNORMAL").removeAttr('checked');
2576 for (index
=1; index
<= ($
("#MOTILITY_LR").val()); ++index
) {
2577 $
("#MOTILITY_LR_"+index
).html(hash_tag
);
2580 $
("#MOTILITY_LL").value
= parseInt($
("#MOTILITY_LL").val());
2581 if ($
("#MOTILITY_LL").val() > '0') {
2582 $
("#MOTILITYNORMAL").removeAttr('checked');
2583 for (index
=1; index
<= ($
("#MOTILITY_LL").val()); ++index
) {
2584 $
("#MOTILITY_LL_"+index
).html(hash_tag
);
2587 $
("#MOTILITY_RR").value
= parseInt($
("#MOTILITY_RR").val());
2588 if ($
("#MOTILITY_RR").val() > '0') {
2589 $
("#MOTILITYNORMAL").removeAttr('checked');
2590 for (index
=1; index
<= ($
("#MOTILITY_RR").val()); ++index
) {
2591 $
("#MOTILITY_RR_"+index
).html(hash_tag
);
2594 $
("#MOTILITY_RL").value
= parseInt($
("#MOTILITY_RL").val());
2595 if ($
("#MOTILITY_RL").val() > '0') {
2596 $
("#MOTILITYNORMAL").removeAttr('checked');
2597 for (index
=1; index
<= ($
("#MOTILITY_RL").val()); ++index
) {
2598 $
("#MOTILITY_RL_"+index
).html(hash_tag
);
2602 $
(".chronic_HPI,.count_HPI").on("blur", function() {
2603 check_exam_detail();
2606 $
("#DIL_RISKS").on('change', function(o
) {
2607 ($
(this
).is(':checked')) ?
($
(".DIL_RISKS").removeClass("nodisplay")) : ($
(".DIL_RISKS").addClass("nodisplay"));
2608 check_exam_detail();
2610 $
(".dil_drug").on('change', function(o
) {
2611 if ($
(this
).is(':checked')) {
2612 $
("#DIL_RISKS").prop("checked","checked");
2613 check_exam_detail();
2614 var timestamp
= getTimeStamp();
2615 $
("#DIL_MEDS").val(timestamp
);
2618 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2619 $
(".neurosens,.neurosens2").on("blur", function() {
2623 // functions to improve flow of refraction input
2624 $
("input[name$='PRISM'],input[class^='prism']").on("blur", function() {
2626 var str
= $
(this
).val();
2627 str
= str
.toUpperCase();
2630 $
('input[class^="sphere"],input[name$="SPH"]').on("blur", function() {
2631 var mid
= $
(this
).val();
2632 if (mid
.match(/PLANO
/i
)) {
2633 $
(this
).val('PLANO');
2636 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2639 if (mid
.match(/\
.[27]$
/)) {
2642 if (mid
.match(/\
.\d$
/)) {
2645 //if near is +2. make it +2.00
2646 if (mid
.match(/\
.$
/)) {
2649 if ((!mid
.match(/\
./))&&(mid
.match(00|
25|
50|
75))) {
2650 var front
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[1];
2651 var back
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[2];
2652 if (front
=='') front
='0';
2653 mid
= front +
"." + back
;
2655 if (!mid
.match(/\
./)) {
2656 var front
= mid
.match(/([\+\
-]?\d
{0,2})(\d
{2})/)[1];
2657 var back
= mid
.match(/(\d
{0,2})(\d
{2})/)[2];
2658 if (front
=='') front
='0';
2659 if (front
=='-') front
='-0';
2660 mid
= front +
"." + back
;
2662 if (!mid
.match(/^
(\+|\
-){1}/)) {
2668 $
("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").on("blur", function() {
2669 var add
= $
(this
).val();
2670 add
= add
.replace(/=/g
,"+");
2671 //if add is one digit, eg. 2, make it +2.00
2672 if (add
.match(/^\d
{1}$
/)) {
2673 add
= "+"+add+
".00";
2675 //if add is '+'one digit, eg. +2, make it +2.00
2676 if (add
.match(/^\+\d
{1}$
/)) {
2679 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2680 if (add
.match(/\
.[05]$
/)) {
2683 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2684 if (add
.match(/\
.[27]$
/)) {
2687 //if add is +2. make it +2.00
2688 if (add
.match(/\
.$
/)) {
2691 if ((!add
.match(/\
./))&&(add
.match(/(0|
25|
50|
75)$
/))) {
2692 var front
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[1];
2693 var back
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[2];
2694 if (front
=='') front
='0';
2695 add
= front +
"." + back
;
2697 if (!add
.match(/^
(\+
)/) && (add
.length
> 0)) {
2701 if (this
.id
=="ODADD_1") $
('#OSADD_1').val(add
);
2702 if (this
.id
=="ODMIDADD_1") $
('#OSMIDADD_1').val(add
);
2703 if (this
.id
=="ODADD_2") $
('#OSADD_2').val(add
);
2704 if (this
.id
=="ODMIDADD_2") $
('#OSMIDADD_2').val(add
);
2705 if (this
.id
=="ODADD_3") $
('#OSADD_3').val(add
);
2706 if (this
.id
=="ODMIDADD_3") $
('#OSMIDADD_3').val(add
);
2707 if (this
.id
=="ODADD_4") $
('#OSADD_4').val(add
);
2708 if (this
.id
=="ODMIDADD_4") $
('#OSMIDADD_4').val(add
);
2709 if (this
.id
=="ODADD_5") $
('#OSADD_5').val(add
);
2710 if (this
.id
=="ODMIDADD_5") $
('#OSMIDADD_5').val(add
);
2711 if (this
.id
=="MRODADD") $
('#MROSADD').val(add
);
2712 if (this
.id
=="ARODADD") $
('#AROSADD').val(add
);
2713 if (this
.id
=="CTLODADD") $
('#CTLOSADD').val(add
);
2716 $
("input[class^='axis'],input[name$='AXIS']").on("blur", function() {
2717 // Make this a 3 digit leading zeros number.
2718 // we are not translating text to numbers, just numbers to
2719 // a 3 digit format with leading zeroes as needed.
2720 // assume the end user KNOWS there are only numbers presented and
2721 // more than 3 digits is a mistake...
2722 // (although this may change with topography)
2723 var axis
= $
(this
).val();
2724 if (this
.name
.match(/K2AXIS
/)) {
2725 var group
= this
.name
.replace("AXIS", "");
2727 var group
= this
.name
.replace("AXIS", "CYL");
2729 var cyl
= $
("#"+group
).val();
2730 if ( (cyl
> '') && (cyl
!= 'SPH') ) {
2731 if (!axis
.match(/\d\d\d
/)) {
2732 if (!axis
.match(/\d\d
/)) {
2733 if (!axis
.match(/\d
/)) {
2743 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2744 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2745 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2749 $
("input[class^='cylinder'],input[name$='CYL']").on("blur", function() {
2750 var mid
= $
(this
).val();
2751 var group
= this
.name
.replace("CYL", "SPH");;
2752 var sphere
= $
("#"+group
).val();
2753 if (((mid
.length
== 0) && (sphere
.length
> 0))||
(mid
.match(/sph
/i
))) {
2755 if (sphere
.match(/plano
/i
)) $
(this
).val('');
2756 var axis
= this
.name
.replace("CYL", "AXIS");
2757 $
("#"+axis
).val('');
2758 submit_form($
(this
));
2760 } else if (sphere
.length
> 0) {
2761 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2764 if (mid
.match(/^
(\d
)(\d
)$
/)) {
2765 mid
= mid
[0] +
'.' +mid
[1];
2768 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2769 if (mid
.match(/\
.[05]$
/)) {
2772 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2773 if (mid
.match(/\
.[27]$
/)) {
2776 //if mid is +2. make it +2.00
2777 if (mid
.match(/\
.$
/)) {
2780 if (mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)) {
2781 var front
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[1];
2782 var back
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[2];
2783 if (front
=='') front
='0';
2784 mid
= front +
"." + back
;
2786 if (!$
('#PREFS_CYL').val()) {
2787 $
('#PREFS_CYL').val('+');
2790 if (!mid
.match(/^
(\+|\
-){1}/) && (sphere
.length
> 0)) {
2791 //no +/- sign at the start of the field.
2792 //ok so there is a preference set
2793 //Since it doesn't start with + or - then give it the preference value
2794 mid
= $
('#PREFS_CYL').val() + mid
;
2795 } else if (mid
.match(/^
(\+|\
-){1}/)) {
2796 pref
= mid
.match(/^
(\+|\
-){1}/)[0];
2797 //so they used a value + or - at the start of the field.
2798 //The only reason to work on this is to change to cylinder preference
2799 if ($
('#PREFS_CYL').val() != pref
){
2800 //and that is what they are doing here
2801 $
('#PREFS_CYL').val(pref
);
2808 //bootstrap menu functions
2809 $
("[class='dropdown-toggle']").hover(function(){
2810 $
("[class='dropdown-toggle']").parent().removeClass('open');
2811 var menuitem
= this
.id
.match(/(.*)/)[1];
2812 //if the menu is active through a prior click, show it
2813 // Have to override Bootstrap then
2814 if ($
("#menustate").val() !="1") { //menu not active -> ignore
2815 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2816 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2817 } else { //menu is active -> respond
2818 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2819 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2820 $
("#"+menuitem
).css("text-decoration","none");
2821 $
("#"+menuitem
).parent().addClass('open');
2824 var menuitem
= this
.id
.match(/(.*)/)[1];
2825 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2826 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2829 $
("[class='dropdown-toggle']").on('click', function() {
2830 $
("#menustate").val('1');
2831 var menuitem
= this
.id
.match(/(.*)/)[1];
2832 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2833 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2834 $
("#"+menuitem
).css("text-decoration","none");
2836 $
("#right-panel-link, #close-panel-bt,#right-panel-link_2").on('click', function() {
2837 if ($
("#PREFS_PANEL_RIGHT").val() =='1') {
2838 $
("#PREFS_PANEL_RIGHT").val('0');
2840 $
("#PREFS_PANEL_RIGHT").val('1');
2844 $
("[name^='menu_']").on('click', function() {
2845 $
("[name^='menu_']").removeClass('active');
2846 var menuitem
= this
.id
.match(/menu_(.*)/)[1];
2847 $
(this
).addClass('active');
2848 $
("#menustate").val('1');
2849 if (menuitem
=='left_tabs') {
2850 var tabs_left
= $
("#setting_tabs_left").val();
2851 if (tabs_left
== '1') {
2852 $
("#tabs_left").addClass('nodisplay');
2853 $
("#setting_tabs_left").val('0');
2855 $
("#tabs_left").removeClass('nodisplay');
2856 $
("#setting_tabs_left").val('1');
2860 $
("#BUTTON_TAB_"+menuitem
).trigger('click');
2861 $
("#tabs-left-"+menuitem
).trigger('click');
2862 menu_select(menuitem
);
2866 // set display functions for Draw panel appearance
2867 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2868 var zones
= ["PMH","HPI","EXT","ANTSEG","POSTSEG","NEURO","IMPPLAN"];
2869 for (index
= '0'; index
< zones
.length
; ++index
) {
2870 if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='DRAW') {
2871 show_DRAW_section(zones
[index
]);
2872 } else if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='QP') {
2873 show_QP_section(zones
[index
],'1');
2876 $
("body").on("click","[name$='_text_view']" , function() {
2877 var header
= this
.id
.match(/(.*)_text_view$
/)[1];
2878 $
("#"+header+
"_text_list").toggleClass('wide_textarea');
2879 $
("#"+header+
"_text_list").toggleClass('narrow_textarea');
2880 $
(this
).toggleClass('fa-plus-square-o');
2881 $
(this
).toggleClass('fa-minus-square-o');
2882 if (header
!= /PRIOR
/) {
2883 var imagine
= $
("#PREFS_"+header+
"_VIEW").val();
2885 $
("#PREFS_"+header+
"_VIEW").val(imagine
);
2890 $
("body").on("change", "select", function(e
){
2891 if (this
.name
.match(/PRIOR_(.*)/)) {
2892 var new_section
= this
.name
.match(/PRIOR_(.*)/);
2893 var newValue
= this
.value
;
2894 if (new_section
[1] =='') return;
2895 if (new_section
[1].match(/_canvas
/)) {
2896 goto_section
= new_section
[1].match(/_canvas
/)[1];
2897 show_PRIOR_CANVAS_section(goto_section
,newValue
);
2901 if (new_section
[1] == /\_
/){
2904 var newValue
= this
.value
;
2905 if (newValue
== $
("#form_id").val()) {
2906 if (new_section
[1] =="ALL") {
2907 //click updates prefs too
2908 $
('#EXAM_QP').trigger("click");
2911 $
('#BUTTON_QP_'+new_section
[1]).trigger("click").trigger("click");//double click intended RM
2913 $
("#LayerTechnical_sections_1").css("clear","both");
2916 //now go get the prior page via ajax
2917 $
("#PRIORS_"+ new_section
[1] +
"_left_text").removeClass('nodisplay');
2918 $
("#DRAWS_" + new_section
[1] +
"_right").addClass('nodisplay');
2919 $
("#QP_" + new_section
[1]).addClass('nodisplay');
2921 if (new_section
[1] =="ALL") {
2923 show_PRIORS_section("ALL",newValue
);
2924 show_PRIORS_section("EXT",newValue
);
2925 show_PRIORS_section("ANTSEG",newValue
);
2926 show_PRIORS_section("RETINA",newValue
);
2927 show_PRIORS_section("NEURO",newValue
);
2928 show_PRIORS_section("IMPPLAN",newValue
);
2929 scrollTo("EXT_left");
2931 show_PRIORS_section(new_section
[1],newValue
);
2937 $
("body").on("click","[name^='old_canvas']", function() {
2939 //het h.step from SELECT_CANVAS_" . attr($zone) . "
2940 var h
= $
(this
).data();
2941 var target
= h
.target
;
2942 var direction
= h
.direction
;
2943 var select
= document
.getElementById(target
);
2944 var len
= select
.getElementsByTagName('option').length
-1;
2945 var t
= $
("#"+target
).data();
2947 if (direction
=="oldest") {
2949 next
= select
.getElementsByTagName('option')[index
];
2950 if(typeof next
!== undefined
) {
2951 select
.options
[index
].selected
= 'selected';
2953 } else if (direction
=="older") {
2955 next
= select
.getElementsByTagName('option')[index
];
2956 if(typeof next
!== undefined
&& index
<= len
) {
2957 select
.options
[index
].selected
= 'selected';
2961 } else if (direction
=="newer") {
2963 next
= select
.getElementsByTagName('option')[index
];
2964 if (typeof next
!== undefined
&& index
>= 0) {
2965 select
.options
[index
].selected
= 'selected';
2968 select
.options
[index
].selected
= 'selected';
2970 } else if (direction
=="newest") {
2972 next
= select
.getElementsByTagName('option')[index
];
2973 if(typeof next
!== undefined
) {
2974 select
.options
[index
].selected
= 'selected';
2978 $
("#"+target
).trigger('change');
2982 $
("body").on("click","[id^='Close_PRIORS_']", function() {
2983 var new_section
= this
.id
.match(/Close_PRIORS_(.*)$
/)[1];
2984 $
("#PRIORS_"+ new_section +
"_left_text").addClass('nodisplay');
2985 $
("#QP_" + new_section
).removeClass('nodisplay');
2987 $
("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").on("mouseover", function() {
2988 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2990 $
("#pupils,#vision_tab,[name='CTL']").on("mouseout", function() {
2991 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
2993 $
("#pupils").on("click", function(){
2994 if ($
("#dim_pupils_panel").hasClass("nodisplay")) {
2995 $
("#dim_pupils_panel").removeClass('nodisplay');
2997 $
("#dim_pupils_panel").fadeToggle();
3000 $
("#vision_tab").on("click", function(){
3001 $
("#REFRACTION_sections").toggleClass('nodisplay');
3002 ($
("#PREFS_VA").val() =='1') ?
($
("#PREFS_VA").val('0')) : $
("#PREFS_VA").val('1');
3004 //set wearing to single vision or bifocal? Bifocal
3005 $
(".WNEAR").removeClass('nodisplay');
3006 $
("#WNEARODAXIS").addClass('nodisplay');
3007 $
("#WNEARODCYL").addClass('nodisplay');
3008 $
("#WNEARODPRISM").addClass('nodisplay');
3009 $
("#WNEAROSAXIS").addClass('nodisplay');
3010 $
("#WNEAROSCYL").addClass('nodisplay');
3011 $
("#WNEAROSPRISM").addClass('nodisplay');
3012 $
("#Single").on("click", function(){
3013 $
("#WNEARODAXIS").addClass('nodisplay');
3014 $
("#WNEARODCYL").addClass('nodisplay');
3015 $
("#WNEARODPRISM").addClass('nodisplay');
3016 $
("#WODADD2").addClass('nodisplay');
3017 $
("#WOSADD2").addClass('nodisplay');
3018 $
("#WNEAROSAXIS").addClass('nodisplay');
3019 $
("#WNEAROSCYL").addClass('nodisplay');
3020 $
("#WNEAROSPRISM").addClass('nodisplay');
3021 $
(".WSPACER").removeClass('nodisplay');
3023 $
("#Bifocal").on("click", function(){
3024 $
(".WSPACER").addClass('nodisplay');
3025 $
(".WNEAR").removeClass('nodisplay');
3026 $
(".WMid").addClass('nodisplay');
3027 $
(".WHIDECYL").removeClass('nodisplay');
3028 $
("[name=RX]").val(["1"]);
3029 $
("#WNEARODAXIS").addClass('nodisplay');
3030 $
("#WNEARODCYL").addClass('nodisplay');
3031 $
("#WNEARODPRISM").addClass('nodisplay');
3032 $
("#WNEAROSAXIS").addClass('nodisplay');
3033 $
("#WNEAROSCYL").addClass('nodisplay');
3034 $
("#WNEAROSPRISM").addClass('nodisplay');
3035 $
("#WODADD2").removeClass('nodisplay');
3036 $
("#WOSADD2").removeClass('nodisplay');
3038 $
("#Trifocal").on("click", function(){
3039 $
(".WSPACER").addClass('nodisplay');
3040 $
(".WNEAR").removeClass('nodisplay');
3041 $
(".WMid").removeClass('nodisplay');
3042 $
(".WHIDECYL").addClass('nodisplay');
3043 $
("[name=RX]").val(["2"]);
3044 $
("#WNEARODAXIS").addClass('nodisplay');
3045 $
("#WNEARODCYL").addClass('nodisplay');
3046 $
("#WNEARODPRISM").addClass('nodisplay');
3047 $
("#WNEAROSAXIS").addClass('nodisplay');
3048 $
("#WNEAROSCYL").addClass('nodisplay');
3049 $
("#WNEAROSPRISM").addClass('nodisplay');
3050 $
("#WODADD2").removeClass('nodisplay');
3051 $
("#WOSADD2").removeClass('nodisplay');
3053 $
("#Progressive").on("click", function(){
3054 $
(".WSPACER").addClass('nodisplay');
3055 $
(".WNEAR").removeClass('nodisplay');
3056 $
(".WMid").addClass('nodisplay');
3057 $
(".WHIDECYL").removeClass('nodisplay');
3058 $
("[name=RX]").val(["3"]);
3059 $
("#WNEARODAXIS").addClass('nodisplay');
3060 $
("#WNEARODCYL").addClass('nodisplay');
3061 $
("#WNEARODPRISM").addClass('nodisplay');
3062 $
("#WNEAROSAXIS").addClass('nodisplay');
3063 $
("#WNEAROSCYL").addClass('nodisplay');
3064 $
("#WNEAROSPRISM").addClass('nodisplay');
3065 $
("#WODADD2").removeClass('nodisplay');
3066 $
("#WOSADD2").removeClass('nodisplay');
3068 $
("[name=W_width_display]").on("click", function() {
3069 if ($
("#PREFS_W_width").val() !="1") {
3070 $
("#PREFS_W_width").val('1');
3071 //make each display W wide
3072 $
("[name=currentRX]").addClass('refraction_wide');
3073 $
("[name=W_wide]").removeClass('nodisplay');
3074 $
("[name=W_wide2]").removeClass('nodisplay');
3076 $
("#PREFS_W_width").val('0');
3077 //make each display W narrow
3078 $
("[name=currentRX]").removeClass('refraction_wide');
3079 $
("[name=W_wide]").addClass('nodisplay');
3080 $
("[name=W_wide2]").addClass('nodisplay');
3085 if ($
("#PREFS_W_width").val() == '1') {
3086 $
("[name=W_wide]").removeClass('nodisplay');
3087 $
("[name=W_wide2]").removeClass('nodisplay')
3089 $
("[name=W_wide]").addClass('nodisplay');
3090 $
("[name=W_wide2]").addClass('nodisplay');
3092 $
("#Amsler-Normal").on("change", function() {
3093 if ($
(this
).is(':checked')) {
3094 var number1
= document
.getElementById("AmslerOD").src
.match(/(Amsler_\d
)/)[1];
3095 document
.getElementById("AmslerOD").src
= document
.getElementById("AmslerOD").src
.replace(number1
,"Amsler_0");
3096 var number2
= document
.getElementById("AmslerOS").src
.match(/(Amsler_\d
)/)[1];
3097 document
.getElementById("AmslerOS").src
= document
.getElementById("AmslerOS").src
.replace(number2
,"Amsler_0");
3098 $
("#AMSLEROD").val("0");
3099 $
("#AMSLEROS").val("0");
3100 $
("#AmslerODvalue").text("0");
3101 $
("#AmslerOSvalue").text("0");
3102 submit_form("eye_mag");
3106 $
("#PUPIL_NORMAL").on("change", function() {
3107 if ($
(this
).is(':checked')) {
3108 $
("#ODPUPILSIZE1").val('3.0');
3109 $
("#OSPUPILSIZE1").val('3.0');
3110 $
("#ODPUPILSIZE2").val('2.0');
3111 $
("#OSPUPILSIZE2").val('2.0');
3112 $
("#ODPUPILREACTIVITY").val('+2');
3113 $
("#OSPUPILREACTIVITY").val('+2');
3114 $
("#ODAPD").val('0');
3115 $
("#OSAPD").val('0');
3116 submit_form("eye_mag");
3120 $
("[name$='PUPILREACTIVITY']").on("change", function() {
3121 var react
= $
(this
).val();
3122 if (react
.match(/^\d
{1}$
/)) {
3128 $
("[name^='EXAM']").on("mouseover", function(){
3129 $
(this
).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
3131 $
("[name^='EXAM']").on("mouseout", function(){
3132 $
(this
).toggleClass("borderShadow2");
3134 $
("#AmslerOD, #AmslerOS").on("click", function() {
3135 if ($
('#chart_status').val() !="on") return;
3136 var number1
= this
.src
.match(/Amsler_(\d
)/)[1];
3137 var number2
= +number1 +
1;
3138 this
.src
= this
.src
.replace('Amsler_'+number1
,'Amsler_'+number2
);
3139 this
.src
= this
.src
.replace('Amsler_6','Amsler_0');
3140 $
("#Amsler-Normal").removeAttr('checked');
3141 var number3
= this
.src
.match(/Amsler_(\d
)/)[1];
3142 this
.html
= number3
;
3143 if (number3
=="6") {
3146 if ($
(this
).attr("id")=="AmslerOD") {
3147 $
("#AmslerODvalue").text(number3
);
3148 $
('#AMSLEROD').val(number3
);
3150 $
('#AMSLEROS').val(number3
);
3151 $
("#AmslerOSvalue").text(number3
);
3153 var title
= "#"+$
(this
).attr("id")+
"_tag";
3156 $
("#AmslerOD, #AmslerOS").on("mouseout", function() {
3157 submit_form("eye_mag");
3159 $
("[name^='ODVF'],[name^='OSVF']").on("click", function() {
3160 if ($
(this
).is(':checked') == true) {
3161 $
("#FieldsNormal").prop('checked', false);
3165 $
(this
).prop('checked', false);
3167 submit_form("eye_mag");
3169 $
("#FieldsNormal").on("click", function() {
3170 if ($
(this
).is(':checked')) {
3171 $
("#ODVF1").removeAttr('checked');
3172 $
("#ODVF2").removeAttr('checked');
3173 $
("#ODVF3").removeAttr('checked');
3174 $
("#ODVF4").removeAttr('checked');
3175 $
("#OSVF1").removeAttr('checked');
3176 $
("#OSVF2").removeAttr('checked');
3177 $
("#OSVF3").removeAttr('checked');
3178 $
("#OSVF4").removeAttr('checked');
3181 $
("[id^='EXT_prefix']").on("change", function() {
3182 var newValue
=$
('#EXT_prefix').val();
3183 newValue
= newValue
.replace('+', '');
3184 if (newValue
=="off") {$
(this
).val('');}
3185 if (newValue
=="clear") {
3186 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
3191 $
("[name^='EXT_prefix_']").removeClass('eye_button_selected');
3192 $
("#EXT_prefix_"+ newValue
).addClass("eye_button_selected");
3195 $
("#ANTSEG_prefix").on("change", function() {
3196 var newValue
= $
(this
).val().replace('+', '');
3197 if ($
(this
).value
=="off") {$
(this
).val('');}
3198 if (newValue
=="clear") {
3199 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
3201 $
(".ANTSEG").val('');
3204 $
("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
3205 $
("#ANTSEG_prefix_"+ newValue
).addClass("eye_button_selected");
3208 $
("#RETINA_prefix").on("change", function() {
3209 var newValue
= $
("#RETINA_prefix").val().replace('+', '');
3210 if ($
(this
).value
=="off") {$
(this
).val('');}
3211 if (newValue
=="clear") {
3212 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
3214 $
(".RETINA").val('');
3217 $
("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
3218 $
("#RETINA_prefix_"+ newValue
).addClass("eye_button_selected");
3221 $
("#NEURO_ACT_zone").on("change", function() {
3222 var newValue
= $
(this
).val();
3223 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3224 $
("#NEURO_ACT_zone_"+ newValue
).addClass("eye_button_selected");
3225 $
("#PREFS_ACT_SHOW").val(newValue
);
3227 $
("#ACT_tab_"+newValue
).trigger('click');
3229 $
("#NEURO_side").on("change", function() {
3230 var newValue
= $
(this
).val();
3231 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3232 $
("#NEURO_side_"+ newValue
).addClass("eye_button_selected");
3234 $
('.ACT').on('focus', function() {
3235 var id
= this
.id
.match(/ACT(\d
*)/);
3236 $
('#NEURO_field').val(''+id
[1]).trigger('change');
3238 $
("#NEURO_field").on("change", function() {
3239 var newValue
= $
(this
).val();
3240 $
("[name^='NEURO_field']").removeClass('eye_button_selected');
3241 $
("#NEURO_field_"+ newValue
).addClass("eye_button_selected");
3242 $
('.ACT').each(function(i
){
3243 var color
= $
(this
).css('background-color');
3244 if ((color
== 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
3245 $
(this
).css("background-color","red");
3248 //change to highlight field in zone entry is for
3249 var zone
= $
("#NEURO_ACT_zone").val();
3250 $
("#ACT"+newValue+zone
).css("background-color","yellow");
3252 $
("[name^='NEURO_ACT_strab']").on("click", function() {
3253 var newValue
= $
(this
).val();
3254 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3255 $
(this
).addClass("eye_button_selected");
3257 $
("#NEURO_value").on("change", function() {
3258 var newValue
= $
(this
).val();
3259 $
("[name^='NEURO_value']").removeClass('eye_button_selected');
3260 $
("#NEURO_value_"+ newValue
).addClass("eye_button_selected");
3261 if (newValue
== "ortho") {
3262 $
("#NEURO_ACT_strab").val('');
3263 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
3264 $
("#NEURO_side").val('');
3265 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
3268 $
("#NEURO_RECORD").on("mouseover", function() {
3269 $
("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
3271 $
("#NEURO_RECORD").on("mouseout", function() {
3272 $
("#NEURO_RECORD").removeClass('borderShadow2');
3274 $
("#NEURO_RECORD").on("mousedown", function() {
3275 $
("#NEURO_RECORD").removeClass('borderShadow2');
3276 $
(this
).toggleClass('button_over');
3278 $
("#NEURO_RECORD").on("mouseup", function() {
3279 $
("#NEURO_RECORD").removeClass('borderShadow2');
3280 $
(this
).toggleClass('button_over');
3282 $
("#NEURO_RECORD").on("click", function() {
3283 //find out the field we are updating
3284 var number
= $
("#NEURO_field").val();
3285 var zone
= $
("#NEURO_ACT_zone").val();
3286 var strab
= $
("#NEURO_value").val() +
' '+ $
("#NEURO_side").val() + $
("#NEURO_ACT_strab").val();
3288 $
("#ACT"+number+zone
).val(strab
).css("background-color","#F0F8FF");
3293 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseover", function(){
3294 $
(this
).addClass("borderShadow2");
3296 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").on("mouseout", function(){
3297 $
(this
).removeClass("borderShadow2");
3299 $
("[id$='_lightswitch']").on("click", function() {
3300 var section
= "#"+this
.id
.match(/(.*)_lightswitch$
/)[1];
3301 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3302 var elem
= document
.getElementById("PREFS_"+section2
);
3303 $
("#PREFS_VA").val('0');
3304 if (section2
!= "IOP")$
("#REFRACTION_sections").removeClass('nodisplay');
3305 if (elem
.value
== "0" || elem
.value
=='') {
3307 if (section2
=="ADDITIONAL") {
3308 $
("#LayerVision_ADDITIONAL").removeClass('nodisplay');
3310 if (section2
=="IOP") {
3311 $
("#LayerVision_IOP").removeClass('nodisplay');
3314 $
(section
).removeClass('nodisplay');
3315 $
(this
).addClass("buttonRefraction_selected");
3318 $
(section
).addClass('nodisplay');
3319 if (section2
=="VAX") {
3320 $
("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
3322 if (section2
=="IOP") {
3323 $
("#LayerVision_IOP").addClass('nodisplay');
3325 $
(this
).removeClass("buttonRefraction_selected");
3327 $
(this
).css( 'cursor', 'pointer' );
3331 $
('[id$=_lightswitch]').on("mouseover", function() {
3332 $
(this
).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
3334 var section
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3335 if (section
== 'IOP') {
3336 $
("#LayerTension").addClass("borderShadow2");
3338 $
("#LayerVision").addClass("borderShadow2");
3341 $
('[id$=_lightswitch]').on('mouseout', function() {
3342 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
3343 var elem
= document
.getElementById("PREFS_"+section2
);
3345 if (elem
.value
!= "1") {
3346 $
(this
).removeClass('buttonRefraction_selected');
3348 $
(this
).addClass('buttonRefraction_selected');
3351 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
3352 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
3353 // "-" is still == "-"
3354 $
("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
) {
3355 if (e
.keyCode
=='61' || e
.keyCode
=='74') {
3356 now
= $
(this
).val();
3357 now
= now
.replace(/=/g
,"+").replace(/^j
/g
,"J");
3361 //useful to make all VA fields stay in sync
3362 $
("input[name$='VA']").on('change',function() {
3363 var hereValue
= $
(this
).val();
3364 var newValue
= $
(this
).attr('name').replace('VA', 'VA_copy');
3365 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3366 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");;
3368 $
("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
3369 var hereValue
= $
(this
).val();
3370 hereValue
= hereValue
.replace(/=$
/g
,"+").replace(/^j
/g
,"J");
3371 $
(this
).val(hereValue
);
3372 if (this
.name
.match(/_1$
/)) {
3373 var newValue
= $
(this
).attr('name').replace('VA_1', 'VA_1_copy');
3374 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3375 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");
3379 $
("input[name$='_copy']").on("blur", function() {
3380 var hereValue
= $
(this
).val();
3381 var newValue
= $
(this
).attr('name').replace('_copy', '');
3382 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3383 $
("#" + newValue +
"_copy_brd").val(hereValue
).css("background-color","#F0F8FF");;
3385 $
("input[name$='_copy_brd']").on("change", function() {
3386 var hereValue
= $
(this
).val();
3387 var newValue
= $
(this
).attr('name').replace('_copy_brd', '');
3388 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3389 $
("#" + newValue +
"_copy").val(hereValue
).css("background-color","#F0F8FF");;
3391 $
("[name^='more_']").on("mouseout", function() {
3392 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
3394 $
("[name^='more_']").on("click", function() {
3395 $
("#Visions_A").toggleClass('nodisplay');
3396 $
("#Visions_B").toggleClass('nodisplay');
3398 $
("#EXAM_defaults").on("click", function() {
3399 if (!confirm('<?php echo xla("Replace all exam findings with Default values? Are you sure?"); ?>')) {
3403 // This query is specific to the provider.
3404 $query = "select seq from list_options where option_id=?";
3405 $result = sqlStatement($query, array("Eye_defaults_$providerID"));
3407 $list = sqlFetchArray($result);
3408 $SEQ = $list['seq'];
3410 // If there is no list for this provider, we create it here.
3411 // This list is part of the idea to create a way to add Eye_Defaults_$providerID specific to the
3412 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3413 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3414 // Let's see if the public likes the form itself before developing these subspecialty lists...
3416 //Copy the Eye_Defaults_for_GENERAL to Eye_defaults_$providerID
3417 $sql = "SELECT * from list_options where list_id = 'Eye_Defaults_for_GENERAL'";
3418 $start = sqlStatement($sql);
3419 $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") {