4 * forms/eye_mag/js/eye_base.php
6 * JS Functions for eye_mag form(s), built with php features for run-time options and translations
8 * Copyright (C) 2016 Raymond Magauran <magauran@MedFetch.com>
10 * LICENSE: This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Affero General Public License as
12 * published by the Free Software Foundation, either version 3 of the
13 * License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Affero General Public License for more details.
20 * You should have received a copy of the GNU Affero General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Ray Magauran <magauran@MedFetch.com>
25 * @link http://www.open-emr.org
29 include_once("../../../globals.php");
30 include_once("$srcdir/acl.inc");
31 include_once("$srcdir/api.inc");
32 include_once("$srcdir/forms.inc");
33 include_once("$srcdir/patient.inc");
35 $providerID = $_REQUEST['providerID'];
47 var detail_reached_exam
='0';
48 var detail_reached_HPI
='0';
49 var chronic_reached_HPI
='0';
50 //Coding Engine Defaults
51 var Code_group
="Eyes";//options are Eyes - anything else and Coding Engine prefers E&M Codes
52 var digit_2
="2"; //Eye Code
53 var digit_4
="1"; //Established
54 var digit_5
="4"; //Level 4
58 var $root = $
('html, body');
60 var visit_modifier
=[];
64 * Functions to add a quick pick selection to the correct fields on the form.
66 function fill_QP_2fields(PEZONE
, ODOSOU
, LOCATION_text
, selection
, fill_action
, Code_to_process
) {
67 var prefix
= document
.getElementById(PEZONE+
'_prefix').value
;
68 if (prefix
> '' && prefix
!='off') {prefix
= prefix +
" ";}
69 if ((prefix
=='off')||
(LOCATION_text
=='')) { prefix
=''; }
70 var saved_prefix
= prefix
;
72 fill_QP_field(PEZONE
, "OD", LOCATION_text
, selection
, fill_action
, Code_to_process
);
73 fill_QP_field(PEZONE
, "OS", LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
);
74 } else if (ODOSOU
=="B") {
75 fill_QP_field(PEZONE
, "R", LOCATION_text
, selection
, fill_action
, Code_to_process
);
76 fill_QP_field(PEZONE
, "L", LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
);
79 function fill_QP_field(PEZONE
, ODOSOU
, LOCATION_text
, selection
, fill_action
, Code_to_process
,saved_prefix
) {
81 var FIELDID
= ODOSOU + LOCATION_text
;
83 var FIELDID
= document
.getElementById(PEZONE+
'_'+ODOSOU
).value + LOCATION_text
;
85 var bgcolor
= $
("#" +FIELDID
).css("background-color");
88 var prefix
= saved_prefix
;
90 var prefix
= document
.getElementById(PEZONE+
'_prefix').value
;
93 var Fvalue
= document
.getElementById(FIELDID
).value
;
94 if (prefix
> '' && prefix
!='off') {prefix
= prefix +
" ";}
95 if (prefix
=='off') { prefix
=''; }
96 if (fill_action
=="REPLACE") {
97 $
("#" +FIELDID
).val(prefix +selection
);
98 $
("#" +FIELDID
).css("background-color","#F0F8FF");
99 } else if (fill_action
=="APPEND") {
100 $
("#" +FIELDID
).val(Fvalue+selection
).css("background-color","#F0F8FF");
102 if (($
("#" +FIELDID
).css("background-color")=="rgb(245, 245, 220)") ||
(Fvalue
=='')) {
103 //rgb(245, 245, 220) is beige - the field is untouched
104 $
("#" +FIELDID
).val(prefix+selection
).css("background-color","#F0F8FF");
105 } else if (Fvalue
.match(/x$
/)) {
106 $
("#" +FIELDID
).val(Fvalue+selection
).css("background-color","#F0F8FF");
108 if (Fvalue
>'') prefix
= ", "+prefix
;
109 $
("#" +FIELDID
).val(Fvalue + prefix +selection
).css("background-color","#F0F8FF");
112 submit_form(FIELDID
);
113 $
('#'+PEZONE+
'_prefix').val('off').trigger('change');
117 * This is the core function of the form.
118 * It submits the data in the background via ajax.
119 * It is the reason we don't use a submit button.
120 * It is called often, perhaps too often for some installs because it uses bandwidth.
121 * It needs to be keenly looked at by developers as it will affect scalability.
122 * It return either "Code 400" or positive hits from the clinical data passed through the Coding engine.
123 * It ensures ownership of the form or provides background updates to READ-ONLY instances of the form.
124 * It doesn't unlock a form to change ownership/provide write privileges. This is done via the unlock() function.
126 function submit_form(action
) {
127 var url
= "../../forms/eye_mag/save.php?sub=1&mode=update&id=" + $
("#form_id").val();
128 if ($
("#COPY_SECTION").value
== "READONLY") return;
129 formData
= $
("form#eye_mag").serialize();
130 $
("#menustate").val('0');
131 top
.restoreSession();
135 data
: formData
//, dataType: "json"
136 }).done(function(result
) {
137 if (result
== 'Code 400') {
138 code_400(); //Not the owner: read-only mode or take ownership
141 // Coding engine returns any positive Clinical findings.
142 //List these findings in the IMP_PLAN Builder
143 if (action
=='1') {}else{populate_form(result
);}
149 * This function alerts the user that they have lost write privileges to another user.
150 * The form is locked (fields disabled) and they enter the READ-ONLY mode.
151 * In READ-ONLY mode the form is refreshed every 15 seconds showing changes made by the user with write privileges.
153 function code_400() {
154 //User lost ownership. Just watching now...
155 //now we should get every variable and update the form, every 15 seconds...
156 $
("#active_flag").html(" READ-ONLY ");
157 toggle_active_flags("off");
158 alert("Another user has taken control of this form.\rEntering READ-ONLY mode.");
160 this_form_id
= $
("#form_id").val();
161 $
("#COPY_SECTION").val("READONLY");
162 update_chart
= setInterval(function() {
163 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
169 * Convert the DB datetime values into date objects in JS
171 * "You should parse them to get a Date object, for that format I always use the following function:
172 * http://stackoverflow.com/questions/2627650/why-javascript-gettime-is-not-a-function"
175 function parseDate(input
) {
176 var parts
= input
.match(/(\d+
)/g
);
177 // new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
178 return new Date(parts
[0], parts
[1]-1, parts
[2]); // months are 0-based
181 * Function to check locked state
183 function check_lock(modify
) {
184 var locked
= $
("#LOCKED").val();
185 var locked_by
= $
("#LOCKEDBY").val();
186 if ($
("#LOCKEDDATE").val() > '') {
187 var locked_date
= parseDate($
("#LOCKEDDATE").val());
189 var locked_date
= new Date('2000-01-01');
191 var uniqueID
= $
('#uniqueID').val();
193 var url
= "../../forms/eye_mag/save.php?mode=update&id=" + $
("#form_id").val();
194 clearInterval(update_chart
);
195 //if the form was locked > 1 hour ago, tag we are it - we should auto-get ownership
196 //if not we have to physically take it.
198 now_time
= now
.getTime();
199 var interval
= locked_date
.setTime(locked_date
.getTime() +
(60*60*1000));//locked timestamp + 1 hour
201 if ($
("#chart_status").val() == "on") {
203 toggle_active_flags("off");
204 update_chart
= setInterval(function() {
205 if ($
("#chart_status").val() == "on") { clearInterval(update_chart
);}
208 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
210 top
.restoreSession();
215 'acquire_lock' : '1',
216 'uniqueID' : uniqueID
,
217 'form_id' : $
("#form_id").val(),
218 'locked_by' : $
("#LOCKEDBY").val()
220 }).done(function(d
) {
221 $
("#LOCKEDBY").val(uniqueID
);
222 toggle_active_flags("on");
223 clearInterval(update_chart
);
226 } else if (locked
=='1' && (interval
< now_time
)) { //it was locked more than an hour ago, take ownership quietly
227 top
.restoreSession();
232 'acquire_lock' : '1',
233 'uniqueID' : uniqueID
, //this user is becoming the new owner
234 'locked_by' : locked_by
, //this is the old owner
235 'form_id' : $
("#form_id").val()
237 }).done(function(d
) {
238 $
("#LOCKEDBY").val(uniqueID
);
239 $
("#LOCKEDDATE").val(d
);
240 toggle_active_flags("on");
243 } else if (locked
=='1' && locked_by
>'' && (uniqueID
!= locked_by
)) {
244 //form is locked by someone else, less than an hour ago...
245 $
("#active_flag").html(" READ-ONLY ");
246 if (confirm('\tLOCKED by another user:\t\n\tSelect OK to take ownership or\t\n\tCANCEL to enter READ-ONLY mode.\t')) {
247 top
.restoreSession();
252 'acquire_lock' : '1',
253 'uniqueID' : uniqueID
, //this user is becoming the new owner
254 'locked_by' : locked_by
, //this is the old owner
255 'form_id' : $
("#form_id").val()
257 }).done(function(d
) {
258 $
("#LOCKEDBY").val(uniqueID
);
259 toggle_active_flags("on");
263 //User selected "Cancel" -- ie. doesn't want ownership. Just watching...
264 toggle_active_flags("off");
265 update_chart
= setInterval(function() {
266 $
("#COPY_SECTION").trigger('change');
267 if ($
("#chart_status").val() == "on") { clearInterval(update_chart
);}
270 if ($
("#chart_status").value
== "on") { clearInterval(update_chart
); }
276 * Function to save a canvas by zone
278 function submit_canvas(zone
) {
279 var id_here
= document
.getElementById('myCanvas_'+zone
);
280 var dataURL
= id_here
.toDataURL('image/jpeg');
281 top
.restoreSession();
284 url
: "../../forms/eye_mag/save.php?canvas="+zone+
"&id="+$
("#form_id").val(),
286 imgBase64
: dataURL
, //this contains the canvas + new strokes, the sketch.js foreground
288 'visit_date' : $
("#visit_date").val(),
289 'encounter' : $
("#encounter").val(),
290 'pid' : $
("#pid").val()
293 }).done(function(o
) {
297 * Function to update the user's preferences
299 function update_PREFS() {
300 var url
= "../../forms/eye_mag/save.php";
303 'PREFS_VA' : $
('#PREFS_VA').val(),
304 'PREFS_W' : $
('#PREFS_W').val(),
305 'PREFS_MR' : $
('#PREFS_MR').val(),
306 'PREFS_W_width' : $
('#PREFS_W_width').val(),
307 'PREFS_MR_width' : $
('#PREFS_MR_width').val(),
308 'PREFS_CR' : $
('#PREFS_CR').val(),
309 'PREFS_CTL' : $
('#PREFS_CTL').val(),
310 'PREFS_ADDITIONAL' : $
('#PREFS_ADDITIONAL').val(),
311 'PREFS_VAX' : $
('#PREFS_VAX').val(),
312 'PREFS_IOP' : $
('#PREFS_IOP').val(),
313 'PREFS_CLINICAL' : $
('#PREFS_CLINICAL').val(),
314 'PREFS_EXAM' : $
('#PREFS_EXAM').val(),
315 'PREFS_CYL' : $
('#PREFS_CYL').val(),
316 'PREFS_EXT_VIEW' : $
('#PREFS_EXT_VIEW').val(),
317 'PREFS_ANTSEG_VIEW' : $
('#PREFS_ANTSEG_VIEW').val(),
318 'PREFS_RETINA_VIEW' : $
('#PREFS_RETINA_VIEW').val(),
319 'PREFS_NEURO_VIEW' : $
('#PREFS_NEURO_VIEW').val(),
320 'PREFS_ACT_VIEW' : $
('#PREFS_ACT_VIEW').val(),
321 'PREFS_ACT_SHOW' : $
('#PREFS_ACT_SHOW').val(),
322 'PREFS_HPI_RIGHT' : $
('#PREFS_HPI_RIGHT').val(),
323 'PREFS_PMH_RIGHT' : $
('#PREFS_PMH_RIGHT').val(),
324 'PREFS_EXT_RIGHT' : $
('#PREFS_EXT_RIGHT').val(),
325 'PREFS_ANTSEG_RIGHT' : $
('#PREFS_ANTSEG_RIGHT').val(),
326 'PREFS_RETINA_RIGHT' : $
('#PREFS_RETINA_RIGHT').val(),
327 'PREFS_NEURO_RIGHT' : $
('#PREFS_NEURO_RIGHT').val(),
328 'PREFS_PANEL_RIGHT' : $
('#PREFS_PANEL_RIGHT').val(),
329 'PREFS_IMPPLAN_RIGHT' : $
('#PREFS_IMPPLAN_DRAW').val(),
330 'PREFS_KB' : $
('#PREFS_KB').val(),
331 'PREFS_TOOLTIPS' : $
('#PREFS_TOOLTIPS').val()
333 top
.restoreSession();
341 * Function to unlock the form - remove temporary lock at DB level.
344 var url
= "../../forms/eye_mag/save.php?mode=update&id=" + $
("#form_id").val();
348 'encounter' : $
('#encounter').val(),
349 'pid' : $
('#pid').val(),
350 'LOCKEDBY' : $
('#LOCKEDBY').val(),
351 'form_id' : $
("#form_id").val()
353 top
.restoreSession();
357 data
: formData
}).done(function(o
) {
358 $
("#warning").removeClass("nodisplay");
359 $
('#LOCKEDBY').val('');
360 $
('#chart_status').val('off');
364 * Function to fax this visit report to someone.
366 function create_task(to_id
,task
,to_type
) {
367 var url
= "../../forms/eye_mag/taskman.php";
369 'action' : "make_task",
370 'from_id' : '<?php echo $providerID; ?>',
372 'pid' : $
('#pid').val(),
374 'enc' : $
('#encounter').val(),
375 'form_id' : $
('#form_id').val()
377 top
.restoreSession();
382 }).done(function(result
) {
383 //OPTIONS to consider: we could return a status code from the server.
384 //maybe 1 = no doc, 2= doc made and queued, 3= sent
385 //maybe this is a checkbox. Check to create the task, uncheck to delete it.
386 //if the task is completed, checkbox is checked and disabled?
387 //return doc_id and display it in html for id='status_'+task+'_'+to_type
388 obj
= JSON
.parse(result
);
390 $
('#status_'+task+
'_'+to_type
).html(obj
.DOC_link
);
392 if (obj
.comments
) alert(obj
.comments
);
393 //maybe change an icon to sent? Think.
399 * START OF PMSFH FUNCTIONS
401 function alter_issue2(issue_number
,issue_type
,index
) {
402 if (!obj
.PMSFH
) { refresh_page(); }
403 if (typeof obj
.PMSFH
== "undefined") { submit_form(); }
404 var here
= obj
.PMSFH
[issue_type
][index
];
405 window
.frames
[0].frameElement
.contentWindow
.newtype(issue_type
);
406 if (issue_type
!='SOCH' && issue_type
!='FH' && issue_type
!='ROS') {
407 $
('iframe').contents().find('#delete_button').removeClass('nodisplay');
409 $
('iframe').contents().find('#delete_button').addClass('nodisplay');
411 $
('iframe').contents().find('#issue' ).val(issue_number
);
412 if (typeof here
!== "undefined") {
413 $
('iframe').contents().find('#form_title' ).val(here
.title
);
414 $
('iframe').contents().find('#form_diagnosis' ).val(here
.diagnosis
);
415 $
('iframe').contents().find('#form_begin' ).val(here
.begdate
);
416 $
('iframe').contents().find('#form_end' ).val(here
.enddate
);
417 $
('iframe').contents().find('#form_reaction' ).val(here
.reaction
);
418 $
('iframe').contents().find('#form_referredby' ).val(here
.referredby
);
419 $
('iframe').contents().find('#form_classification' ).val(here
.classification
);
420 $
('iframe').contents().find('#form_occur' ).val(here
.occurrence
);
421 $
('iframe').contents().find('#form_comments' ).val(here
.comments
);
422 $
('iframe').contents().find('#form_outcome' ).val(here
.outcome
);
423 $
('iframe').contents().find('#form_destination' ).val(here
.destination
);
424 if (here
.row_subtype
=='eye') {
425 $
('iframe').contents().find('#form_eye_subtype' ).prop("checked","checked");
427 $
('iframe').contents().find('#form_eye_subtype' ).prop("checked",false);
429 if (here
.enddate
> '') {
430 $
('iframe').contents().find('#form_active' ).prop("checked",true);
431 $
('iframe').contents().find('#delete_button').addClass("nodisplay");
433 $
('iframe').contents().find('#form_active' ).prop("checked",false);
436 var location
= $
("#PMH_left").offset().top
-55;
437 $root.animate({scrollTop
: location
}, "slow");
439 function showArray(arr
) {
440 var tS
= new String();
441 for (var iI in arr
) {
442 tS +
= "Index "+iI+
", Type "+
(typeof arr
[iI
])+
", Value "+arr
[iI
]+
"\n";
448 * Function to delete an issue from server via ajax
449 * Ajax returns json obj.PMSFH
450 * Refresh displays (right_panel and QP_PMH panel)
452 function delete_issue2(issue_number
,PMSFH_type
) {
453 $
('#form#theform issue').val(issue_number
);
454 $
('iframe').contents().find('#issue').val(issue_number
);
455 $
('form#theform form_type');
457 var url
= '../../forms/eye_mag/a_issue.php';
459 'a_issue' : issue_number
,
463 top
.restoreSession();
468 success
:(function(result
) {
469 populate_PMSFH(result
);
477 * Function to save the PMSFH array to the server.
478 * This can be removed in the future - save for now
480 function submit_PMSFH() {
481 var url
= "../../forms/eye_mag/save.php?PMSFH_save=1&mode=update";
482 formData
= $
("[id^=f]").serialize();
483 var f
= document
.forms
[0];
484 top
.restoreSession();
489 }).done(function(result
){
490 f
.form_title
.value
= '';
491 f
.form_diagnosis
.value
= '';
492 f
.form_begin
.value
='';
493 f
.form_end
.value
='';
494 f
.form_referredby
.value
='';
495 f
.form_reaction
.value
='';
496 f
.form_classification
.value
='';
497 f
.form_occur
.value
='';
498 f
.form_comments
.value
='';
499 f
.form_outcome
.value
='';
500 f
.form_destination
.value
='';
502 populate_form(result
);
506 * END OF PMSFH FUNCTIONS
510 * Function to refresh the issues, the panels and the Impression/coding areas.
512 function refresh_page() {
513 var url
= '../../forms/eye_mag/view.php?display=PMSFH';
515 'action' : "refresh",
516 'id' : $
('#form_id').val(),
517 'encounter' : $
('#encounter').val(),
518 'pid' : $
('#pid').val(),
521 top
.restoreSession();
526 success
:(function(result
) {
527 populate_form(result
);
530 //Make the height of the panels equal if they grow really large
531 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
532 $
('#PMH_left').height($
('#PMH_right').height());
533 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
538 * Function to refresh the Glaucoma Flow Sheet.
540 function refresh_GFS() {
541 if (typeof config_byday
== "undefined") { return; }
543 var indexToUpdate
= '0';
544 $
.each(config_byday
.data
.labels
, function(key
,value
) {
545 if (value
== visit_date
) {
550 //var indexToUpdate = config_byday.data.labels.length-1;
553 if ( $
('#ODIOPAP').val()) {
554 ODIOP
= $
('#ODIOPAP').val();
555 } else if ( $
('#ODIOPTPN').val()) {
556 ODIOP
= $
('#ODIOPTPN').val();
559 if ( $
('#OSIOPAP').val() >'0') {
560 OSIOP
= $
('#OSIOPAP').val();
561 } else if ( $
('#OSIOPTPN').val() > '0') {
562 OSIOP
= $
('#OSIOPTPN').val();
565 config_byday
.data
.datasets
[0].data
[indexToUpdate
] = $
('#ODIOPTARGET').val();
566 config_byday
.data
.datasets
[1].data
[indexToUpdate
] = ODIOP
;
567 config_byday
.data
.datasets
[2].data
[indexToUpdate
] = OSIOP
;
570 var time
= $
('#IOPTIME').val();
571 times
= time
.match(/^
(\d
{1,2}):(\d
{2})/);
572 if (times
[1] < 10) times
[1] = "0"+
''+times
[1];
573 time
= times
[1]+
':'+times
[2];
574 //alert("time is "+time);
575 var indexToUpdate2
= '0';
576 $
.each(config_byhour
.data
.labels
, function(key
,value
) {
578 indexToUpdate2
= key
;
581 config_byhour
.data
.datasets
[0].data
[indexToUpdate2
] = ODIOP
;
582 config_byhour
.data
.datasets
[1].data
[indexToUpdate2
] = OSIOP
;
584 // Update one of the points in the second dataset
585 // myLine.data.datasets[1].data[indexToUpdate].val($('#ODIOPAP').val());
586 //alert(config_byday.data.datasets[1].data[indexToUpdate].val()+' is ending _bydat val');
591 this should refresh locally and not go back to the server
592 the only things that would trigger a refresh are
596 change in GONIO fields
597 additional tests (VF/OCT) would not affect this in its live format
600 var url = '../../forms/eye_mag/view.php?display=GFS';
602 'action' : "refresh_GFS",
603 'id' : $('#form_id').val(),
604 'encounter' : $('#encounter').val(),
605 'pid' : $('#pid').val(),
608 top.restoreSession();
613 success:(function(result) {
614 populate_GFS(result);
620 function populate_GFS(result
) {
621 $
("#LayerVision_IOP").html(result
);
625 * Server returns a json encoding object: obj to update the page
626 * Here we refresh the PMSFH display panels,
627 * Rebuild the Impression/Plan Builder DX lists,
628 * the Impression Plan area
629 * and the CHRONIC fields.
631 function populate_form(result
) {
632 obj
= JSON
.parse(result
);
633 $
("#QP_PMH").html(obj
.PMH_panel
);
634 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
635 $
('#PMH_left').height($
('#PMH_right').height());
636 } else { $
('#PMH_left').height($
('#PMH_right').height()); }
637 $
("#right_panel_refresh").html(obj
.right_panel
);
638 build_IMPPLAN(obj
.IMPPLAN_items
);
640 build_DX_list(obj
); //build the list of DXs to show in the Impression/Plan Builder
643 * Function to auto-fill CHRONIC fields
644 * To reach a detailed E&M level of documentation the chart
645 * may comment on the status of 3 or more CHRONIC/Inactive problems.
646 * The user can type them into the CHRONIC fields manually, or
647 * we can do it programatically if the user does the following:
648 * 1. documenting a PMH diagnosis in the PMSFH area
649 * 2. listing it as "Chronic"
650 * 3. making a comment about it
651 * With these three steps completed, this build_CHRONIC function displays the changes
652 * in the CHRONIC1-3 textareas, if not already filled in, for today's visit.
653 * On subsequent visits, the CHRONIC1-3 fields are blank, unless the above steps
654 * were performed previously, then they are filled in automatically on loading of the new form.
656 function build_Chronics(obj
) {
657 if (typeof obj
.PMSFH
=== "undefined") return;
658 var CHRONICS
= obj
.PMSFH
['CHRONIC'];
662 $
.each(CHRONICS
, function(key
, value
) {
663 local_comment
= CHRONICS
[key
].title+
" "+CHRONICS
[key
].diagnosis+
"\n"+CHRONICS
[key
].comments
;
665 for (i
=1; i
< 4; i++
) {
666 chronic_value
= $
('#CHRONIC'+i
).val();
667 if (chronic_value
== local_comment
) {
668 here_already
='1'; //this is here, move to next CHRONICS
672 if (here_already
!='1') {
673 for (i
=1; i
< 4; i++
) {
674 chronic_value
= $
('#CHRONIC'+i
).val();
675 if (chronic_value
== '') { //if the CHRONIC1-3 field is empty, fill it.
676 $
('textarea#CHRONIC'+i
).val(local_comment
);
685 * Function to autocreate a PDF of this form as a document linked to this encounter.
686 * Each time it is runs it updates by replacing the encounter's PDF.
687 * This used to be fired often, but it is a server resource beast.
688 * Use it sparingly, and intentionally only.
689 * Currently only invoked via the bootstrap menu: Menu->File->Print/Store PDF
691 function store_PDF() {
692 var url
= "../../forms/eye_mag/save.php?mode=update";
694 'action' : 'store_PDF',
695 'patient_id' : $
('#pid').val(),
698 'form_folder' : $
('#form_folder').val(),
699 'form_id' : $
('#form_id').val(),
700 'encounter' : $
('#encounter').val(),
701 'uniqueID' : $
('#uniqueID').val()
703 top
.restoreSession();
711 /* START Functions related to form VIEW */
713 * Function to blow out the form and display the right side of every section.
715 function show_right() {
716 $
("#HPI_1").removeClass("size50").addClass("size100");
717 $
("#PMH_1").removeClass("size50").addClass("size100");
718 $
("#EXT_1").removeClass("size50").addClass("size100");
719 $
("#ANTSEG_1").removeClass("size50").addClass("size100");
720 $
("#NEURO_1").removeClass("size50").addClass("size100");
721 $
("#RETINA_1").removeClass("size50").addClass("size100");
722 $
("#IMPPLAN_1").removeClass("size50").addClass("size100");
723 $
("#HPI_right").removeClass('nodisplay');
724 $
("#PMH_right").removeClass('nodisplay');
725 $
("#EXT_right").removeClass('nodisplay');
726 $
("#ANTSEG_right").removeClass('nodisplay');
727 $
("#NEURO_right").removeClass('nodisplay');
728 $
("#RETINA_right").removeClass('nodisplay');
729 $
("#IMPPLAN_right").removeClass('nodisplay');
730 $
("#PMH_1").addClass("clear_both");
731 $
("#ANTSEG_1").addClass("clear_both");
732 $
("#RETINA_1").addClass("clear_both");
733 $
("#NEURO_1").addClass("clear_both");
734 $
("#IMPPLAN_1").addClass("clear_both");
738 * Function to implode the form and hide the right side of every section.
740 function hide_right() {
741 $
("#HPI_1").removeClass("size100").addClass("size50");
742 $
("#PMH_1").removeClass("size100").addClass("size50");
743 $
("#EXT_1").removeClass("size100").addClass("size50");
744 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
745 $
("#NEURO_1").removeClass("size100").addClass("size50");
746 $
("#RETINA_1").removeClass("size100").addClass("size50");
747 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
748 $
("#HPI_right").addClass('nodisplay');
749 $
("#PMH_right").addClass('nodisplay');
750 $
("#EXT_right").addClass('nodisplay');
751 $
("#ANTSEG_right").addClass('nodisplay');
752 $
("#NEURO_right").addClass('nodisplay');
753 $
("#RETINA_right").addClass('nodisplay');
754 $
("#PMH_1").removeClass("clear_both");
755 $
("#ANTSEG_1").removeClass("clear_both");
756 $
("#RETINA_1").removeClass("clear_both");
757 $
("#NEURO_1").removeClass("clear_both");
761 * Function to explode the form and show the left side of every section.
763 function show_left() {
764 $
("#HPI_1").removeClass("size100").addClass("size50");
765 $
("#PMH_1").removeClass("size100").addClass("size50");
766 $
("#EXT_1").removeClass("size100").addClass("size50");
767 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
768 $
("#NEURO_1").removeClass("size100").addClass("size50");
769 $
("#RETINA_1").removeClass("size100").addClass("size50");
770 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
771 $
("#HPI_left").removeClass('nodisplay');
772 $
("#PMH_left").removeClass('nodisplay');
773 $
("#EXT_left").removeClass('nodisplay');
774 $
("#ANTSEG_left").removeClass('nodisplay');
775 $
("#RETINA_left").removeClass('nodisplay');
776 $
("#NEURO_left").removeClass('nodisplay');
777 $
("#IMPPLAN_left").removeClass('nodisplay');
778 $
("[name$='_left']").removeClass('nodisplay');
781 * Function to implode the form and hide the left side of every section.
783 function hide_left() {
784 $
("#HPI_1").removeClass("size100").addClass("size50");
785 $
("#PMH_1").removeClass("size100").addClass("size50");
786 $
("#EXT_1").removeClass("size100").addClass("size50");
787 $
("#ANTSEG_1").removeClass("size100").addClass("size50");
788 $
("#NEURO_1").removeClass("size100").addClass("size50");
789 $
("#RETINA_1").removeClass("size100").addClass("size50");
790 $
("#IMPPLAN_1").removeClass("size100").addClass("size50");
791 $
("#HPI_left").addClass('nodisplay');
792 $
("#PMH_left").addClass('nodisplay');
793 $
("#EXT_left").addClass('nodisplay');
794 $
("#ANTSEG_left").addClass('nodisplay');
795 $
("#RETINA_left").addClass('nodisplay');
796 $
("#NEURO_left").addClass('nodisplay');
797 $
("#IMPPLAN_left").addClass('nodisplay');
798 $
("[name $='_left']").addClass('nodisplay');
801 * Function to display only the DRAW panels of every section.
802 * The technical section, between HPI and Clinical section is still viible.
804 function show_DRAW() {
812 $
("#HPI_right").addClass('canvas');
813 $
("#PMH_right").addClass('canvas');
814 $
("#EXT_right").addClass('canvas');
815 $
("#ANTSEG_right").addClass('canvas');
816 $
("#RETINA_right").addClass('canvas');
817 $
("#NEURO_right").addClass('canvas');
818 $
("#IMPPLAN_right").addClass('canvas');
819 $
(".Draw_class").removeClass('nodisplay');
820 if ($
("#PREFS_CLINICAL").val() !='1') {
821 $
("#PREFS_CLINICAL").val('1');
822 $
("#PREFS_EXAM").val('DRAW');
827 * Function to display only the TEXT panels in every section.
829 function show_TEXT() {
830 $
("#PMH_1").removeClass('nodisplay');
831 $
("#NEURO_1").removeClass('nodisplay');
832 $
("#IMPPLAN_1").removeClass('nodisplay');
833 $
(".TEXT_class").removeClass('nodisplay');
835 hide_right(); //this hides the right half
839 if ($
("#PREFS_CLINICAL").val() !='1') {
840 // we want to show text_only which are found on left half
841 $
("#PREFS_CLINICAL").val('1');
843 $
("#PREFS_EXAM").val('TEXT');
844 $
("#IMPPLAN_right").addClass('canvas').removeClass('nodisplay');
845 $
("#QP_IMPPLAN").removeClass('nodisplay');
846 $
("#DRAW_"+zone
).addClass('nodisplay');
847 $
("#IMPPLAN_1").removeClass('nodisplay');
848 $
("#IMPPLAN_left").removeClass('nodisplay');
849 $
("#PREFS_IMPPLAN_RIGHT").val('QP');
850 if (!scroll
) scrollTo("HPI_left");
854 * Function to display the PRIORS panels in every right section.
856 function show_PRIORS() {
857 $
("#NEURO_sections").removeClass('nodisplay');
859 $
("#EXT_right").addClass("PRIORS_color");
863 $
("#QP_HPI").removeClass('nodisplay');
864 $
("#QP_PMH").removeClass('nodisplay');
865 $
("#HPI_right").addClass('canvas');
866 $
("#PMH_right").addClass('canvas');
867 $
("#IMPPLAN_right").addClass('canvas');
868 $
("#EXT_right").addClass('canvas');
869 $
("#ANTSEG_right").addClass('canvas');
870 $
("#RETINA_right").addClass('canvas');
871 $
("#NEURO_right").addClass('canvas');
872 $
(".PRIORS_class").removeClass('nodisplay');
873 if ($
("#PREFS_CLINICAL").val() !='1') {
874 // we want to show text_only which are found on left half now that PRIORS are visible.
875 $
("#PREFS_CLINICAL").val('1');
877 $
("#PREFS_EXAM").val('PRIORS');
881 * Function to show the Quick Picks panel on the right side of every section.
890 $
("#HPI_right").addClass('canvas');
891 $
("#PMH_right").addClass('canvas');
892 $
("#EXT_right").addClass('canvas');
893 $
("#ANTSEG_right").addClass('canvas');
894 $
("#RETINA_right").addClass('canvas');
895 $
("#NEURO_right").addClass('canvas');
896 $
("#IMPPLAN_right").addClass('canvas');
897 $
(".QP_class").removeClass('nodisplay');
898 $
(".QP_class2").removeClass('nodisplay');
899 $
("#PREFS_EXAM").val('QP');
903 * Function to display only one DRAW panel of one section.
905 function show_DRAW_section(zone
) {
906 $
("#QP_"+zone
).addClass('nodisplay');
907 $
("#"+zone+
"_1").removeClass('nodisplay');
908 $
("#"+zone+
"_left").removeClass('nodisplay');
909 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
910 $
("#Draw_"+zone
).addClass('canvas');
911 $
("#Draw_"+zone
).removeClass('nodisplay');
912 $
("#PREFS_"+zone+
"_DRAW").val(1);
916 * Function to display only one PRIORS panel of one section.
918 function show_PRIORS_section(section
,newValue
) {
919 var url
= "../../forms/eye_mag/save.php?mode=retrieve";
922 'PRIORS_query' : "1",
924 'id_to_show' : newValue
,
925 'pid' : $
('#pid').val(),
926 'orig_id' : $
('#form_id').val()
928 top
.restoreSession();
933 success
: function(result
) {
934 $
("#PRIORS_" + section +
"_left_text").html(result
);
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+
"_1").removeClass('nodisplay');
946 $
("#"+zone+
"_left").removeClass('nodisplay');
947 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
948 if (!scroll
) scrollTo(zone+
"_left");
951 * Function to hide all the DRAW panels of every section.
953 function hide_DRAW() {
954 $
(".Draw_class").addClass('nodisplay');
956 $
("#LayerTechnical_sections").removeClass('nodisplay');
957 $
("#REFRACTION_sections").removeClass('nodisplay');
958 $
("#PMH_sections").removeClass('nodisplay');
959 $
("#HPI_right").addClass('nodisplay');
960 $
("#HPI_right").removeClass('canvas');
961 $
("#EXT_right").removeClass('canvas');
962 $
("#RETINA_right").removeClass('canvas');
963 $
("#ANTSEG_right").removeClass('canvas');
966 * Function to hide all the Quick Pick panels of every section.
969 $
(".QP_class").addClass('nodisplay');
970 $
(".QP_class2").addClass('nodisplay');
971 $
("[name$='_right']").removeClass('canvas');
974 * Function to hide all the TEXT panels of every section.
976 function hide_TEXT() {
977 $
(".TEXT_class").addClass('nodisplay');
980 * Function to hide all the PIORS panels of every section.
982 function hide_PRIORS() {
983 $
("#EXT_right").removeClass("PRIORS_color");
984 $
("#PRIORS_EXT_left_text").addClass('nodisplay');
985 $
("#PRIORS_ANTSEG_left_text").addClass('nodisplay');
986 $
("#PRIORS_RETINA_left_text").addClass('nodisplay');
987 $
("#PRIORS_NEURO_left_text").addClass('nodisplay');
988 $
(".PRIORS_class").addClass('nodisplay');
991 * Function to hide Shorthand/Keyboard Entry panel.
994 $
('.kb').addClass('nodisplay');
995 $
('.kb_off').removeClass('nodisplay');
996 if ($
("#PREFS_KB").val() > 0) {
997 $
("#PREFS_KB").val('0');
1001 * Function to show the Shorthand/Keyboard panel.
1003 function show_KB() {
1004 $
('.kb').toggleClass('nodisplay');
1005 $
('.kb_off').toggleClass('nodisplay');
1006 if ($
('#PREFS_EXAM').val() == 'DRAW') {
1010 if ($
("#PREFS_KB").val() > 0) {
1011 $
("#PREFS_KB").val('0');
1013 $
("#PREFS_KB").val('1');
1017 /* END Functions related to form VIEW */
1020 * Function contains menu commands specific to this form.
1022 function menu_select(zone
,che
) {
1023 $
("#menu_"+zone
).addClass('active');
1024 if (zone
=='PREFERENCES') {
1025 window
.parent
.RTop
.document
.location
.href
= base+
"interface/super/edit_globals.php";
1026 var url
= base+
"/interface/super/edit_globals.php";
1028 'id' : $
('#id').val(),
1029 'encounter' : $
('#encounter').val(),
1030 'pid' : $
('#pid').val(),
1032 top
.restoreSession();
1037 success
: function(result
) {
1038 window
.parent
.RTop
.document
.result
;
1042 if (zone
=='PRIORS') $
("#PRIORS_ALL_minus_one").trigger("click");
1043 if (zone
=='QP') show_QP();
1044 if (zone
=='KB') show_KB();
1045 if (zone
=='DRAW') show_DRAW();
1046 if (zone
=='TEXT') show_TEXT();
1047 if (zone
=='IOP_graph') $
("#LayerVision_IOP_lightswitch").trigger('click');
1048 if (zone
== "HPI") scrollTo("HPI_left");
1049 if (zone
== "PMH") scrollTo("PMH_left");
1050 if (zone
== "EXT") scrollTo("EXT_left");
1051 if (zone
== "ANTSEG") scrollTo("ANTSEG_left");
1052 if (zone
== "POSTSEG") scrollTo("RETINA_left");
1053 if (zone
== "NEURO") scrollTo("NEURO_left");
1058 * Function to test blowing up any section to fullscren - towards tablet functionality?
1059 * Currently not used.
1061 function show_Section(section
) {
1062 //hide everything, show the section. For fullscreen perhaps Tablet view per section
1064 $
("div[name='_sections']").style
.display
= "none"; //
1065 $
('#'+section+
'_sections').style
.display
= "block";
1066 //.show().appendTo('form_container');
1069 * Function to display Chief Complaint 1-3
1071 function show_CC(CC_X
) {
1072 $
("[name^='CC_']").addClass('nodisplay');
1073 $
("#CC_"+CC_X
).removeClass('nodisplay');
1074 $
("#CC_"+CC_X
).index
;
1077 /* START Functions related to CODING */
1080 * Function to determine if add on NeuroSensory(92060) code can be billed.
1082 function check_CPT_92060() {
1085 if ($
("#STEREOPSIS").val() > '') (neuro1
="1");
1086 $
(".neurosens2").each(function(index
) {
1087 if ($
( this
).val() > '') {
1091 if (neuro1
&& neuro2
){
1092 $
("#neurosens_code").removeClass('nodisplay');
1095 $
("#neurosens_code").addClass('nodisplay');
1100 * Function to check documentation level for coding purposes
1101 * And make suggestions to end user.
1103 function check_exam_detail() {
1104 detail_reached_HPI
='0';
1105 chronic_reached_HPI
='0';
1106 $
(".count_HPI").each(function(index
) {
1107 if ($
( this
).val() > '') detail_reached_HPI++
;
1109 if (detail_reached_HPI
> '3') {
1110 $
(".detail_4_elements").css("color","red");
1111 $
(".CODE_LOW").addClass("nodisplay");
1112 $
(".CODE_HIGH").removeClass("nodisplay");
1113 $
(".detailed_HPI").css("color","red");
1115 $
(".detail_4_elements").css("color","#876F6F");
1117 $
(".chronic_HPI").each(function(index
) {
1118 if ($
( this
).val() > '') chronic_reached_HPI++
;
1120 if (chronic_reached_HPI
> '2') {
1121 $
(".chronic_3_elements").css("color","red");
1122 $
(".CODE_LOW").addClass("nodisplay");
1123 $
(".CODE_HIGH").removeClass("nodisplay");
1124 $
(".detailed_HPI").css("color","red");
1126 $
(".chronic_3_elements").css("color","#876F6F");
1128 if ((chronic_reached_HPI
> '2')||
(detail_reached_HPI
> '3')) {
1129 $
(".CODE_LOW").addClass("nodisplay");
1130 $
(".CODE_HIGH").removeClass("nodisplay");
1131 $
(".detailed_HPI").css("color","red");
1132 detail_reached_HPI
= '1';
1134 $
(".CODE_LOW").removeClass("nodisplay");
1135 $
(".CODE_HIGH").addClass("nodisplay");
1136 $
(".detailed_HPI").css("color","#876F6F");
1137 detail_reached_HPI
= '0';
1139 if ((($
("#DIL_RISKS").is(':checked')) ||
($
(".dil_drug").is(':checked'))) && (($
('#ODPERIPH').val() >'') ||
($
('#OSPERIPH').val() >''))) {
1140 $
(".EXAM_LOW").addClass("nodisplay");
1141 $
(".DIL_RISKS").removeClass("nodisplay");
1142 $
("#DIL_RISKS").prop("checked","checked");
1143 detail_reached_exam
= '1';
1145 $
(".EXAM_LOW").removeClass("nodisplay");
1146 $
(".DIL_RISKS").addClass("nodisplay");
1147 detail_reached_exam
= '0';
1149 Suggest_visit_code();
1152 /* END Functions related to CODING */
1154 /* START Functions related to IMPPLAN Builder */
1156 * Function to update the list of Dxs available for Impression/Plan and Coding(?).
1157 * Will use actual list from obj.IMPPLAN_items for coding.
1158 * After a new DX is added via PMSFH (or other ways), it updates the sortable and draggable list of DXs
1159 * available to build the Impression/Plan from.
1161 function build_DX_list(obj
) {
1164 $
( "#build_DX_list" ).empty();
1165 //add in inc_FIELDCODES culled from the datafields
1166 if (typeof obj
.PMSFH
=== "undefined") return;
1167 if (typeof obj
.Clinical
=== "undefined") submit_form('obj.clinical is undefined');
1168 if (!obj
.PMSFH
['POH'] && !obj
.PMSFH
['PMH'] && !obj
.Clinical
) {
1169 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 />';
1170 $
( "#build_DX_list" ).html(out
);
1173 build_IMPPLAN(obj
.IMPPLAN_items
);
1174 if ($
('#inc_PE').is(':checked') && obj
.Clinical
) {
1175 $
.each(obj
.Clinical
, function(key
, value
) {
1177 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)
1178 diagnosis
= "<code class='pull-right ICD_CODE'>"+obj
.Clinical
[key
][0].code+
"</code>";
1180 out +
= "<li class='ui-widget-content'><span name='DX_Clinical_"+key+
"' id='DX_Clinical_"+key+
"'>"+obj
.Clinical
[key
][0].title+
"</span> "+diagnosis+
"</li> ";
1184 if ($
('#inc_POH').is(':checked') && (obj
.PMSFH
['POH']||obj
.PMSFH
['POS'])) {
1185 $
.each(obj
.PMSFH
['POH'], function(key
, value
) {
1187 if (obj
.PMSFH
['POH'][key
].diagnosis
> '' ) {
1188 diagnosis
= "<code class='pull-right ICD_CODE'>"+obj
.PMSFH
['POH'][key
].code+
"</code>";
1190 out +
= "<li class='ui-widget-content'><span name='DX_POH_"+key+
"' id='DX_POH_"+key+
"'>"+obj
.PMSFH
['POH'][key
].title+
"</span> "+diagnosis+
"</li>";
1192 $
.each(obj
.PMSFH
['POS'], function(key
, value
) {
1194 if (obj
.PMSFH
['POS'][key
].diagnosis
> '' ) {
1195 diagnosis
= "<code class='pull-right ICD_CODE'>"+obj
.PMSFH
['POS'][key
].code+
"</code>";
1197 out +
= "<li class='ui-widget-content'><span name='DX_POS_"+key+
"' id='DX_POS_"+key+
"'>"+obj
.PMSFH
['POS'][key
].title+
"</span> "+diagnosis+
"</li>";
1200 if ($
('#inc_PMH').is(':checked') && obj
.PMSFH
['PMH']) {
1201 $
.each(obj
.PMSFH
['PMH'], function(key
, value
) {
1203 if (obj
.PMSFH
['PMH'][key
].diagnosis
> '') {
1204 diagnosis
= "<code class='pull-right ICD_CODE'>"+obj
.PMSFH
['PMH'][key
].code+
"</code>";
1206 out +
= "<li class='ui-widget-content'><span name='DX_PMH_"+key+
"' id='DX_PMH_"+key+
"'>"+obj
.PMSFH
['PMH'][key
].title+
"</span>"+diagnosis+
"</li> ";
1209 //add in inc_FIELDCODES culled from the datafields
1211 rebuild_IMP($
( "#build_DX_list" ));
1212 $
( "#build_DX_list" )
1213 .html(out
).sortable({ handle
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1214 .selectable({ filter
: "li", cancel
: ".handle",stop
: function(event
, ui
){ rebuild_IMP($
( "#build_DX_list" )) } })
1216 .addClass( "ui-corner-all ui-selected" )
1217 .dblclick(function(){
1218 rebuild_IMP($
( "#build_DX_list" ));
1219 $
('#make_new_IMP').trigger('click'); //any items selected are sent to IMPPLAN directly.
1221 //this places the handle for the user to drag the item around.
1222 .prepend( "<div class='handle '><i class='fa fa-arrows fa-1'></i></div>" );
1224 out
= '<br /><span class="bold"><?php echo xlt("Build Your Plan")."."; ?></span><br /><br>';
1225 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 />';
1226 out +
= '<?php echo xlt('Update the chart to build this
list')."."; ?><br />';
1227 $
( "#build_DX_list" ).html(out
);
1231 * Function: After the Builder DX list is built from all the available options,
1232 * the end user can select to use only certain Dxs and change their sort order of importance.
1233 * This function builds the list of DXs selected and in the order as the user sorted them,
1234 * so we know what to use to build the Impression/Plan area and in what order to display them.
1236 function rebuild_IMP(obj2
) {
1240 $
( ".ui-selected", obj2
).each(function() {
1241 var index
= $
( "#build_DX_list li" ).index( this
);
1242 if ($
('#build_DX_list li span')[index
].id
.match(/DX_POH_(.*)/)) {
1243 surface
= 'POH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POH_(.*)/)[1];
1244 IMP_order
[k
] = surface
;
1245 }else if ($
('#build_DX_list li span')[index
].id
.match(/DX_POS_(.*)/)) {
1246 surface
= 'POS_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_POS_(.*)/)[1];
1247 IMP_order
[k
] = surface
;
1248 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_PMH_(.*)/)) {
1249 surface
= 'PMH_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_PMH_(.*)/)[1];
1250 IMP_order
[k
] = surface
;
1251 } else if ($
('#build_DX_list li span')[index
].id
.match(/DX_Clinical_(.*)/)) {
1252 surface
= 'CLINICAL_' + $
( "#build_DX_list li span" )[index
].id
.match(/DX_Clinical_(.*)/)[1];
1253 IMP_order
[k
] = surface
;
1259 * This function builds the Impression/Plan area using the object supplied: items
1260 * It appends "items" into the Impression Plan area, complete with:
1261 * contenteditable Titles (the Impression),
1262 * its code (if part of the item object),
1263 * Plan textareas (autofilled with the item/object's "comment")
1264 * for each member of "items".
1265 * Duplicates are removed by server.
1267 function build_IMPPLAN(items
,nodisplay
) {
1269 if (typeof nodisplay
== "undefined") {
1270 $
('#IMPPLAN_zone').html("");
1272 $
('#Coding_DX_Codes').html("");
1274 if ((items
== null) ||
((typeof items
== "undefined")||
(items
.length
=='0'))) {
1276 $
('#IMPPLAN_text').removeClass('nodisplay'); //Display Builder instructions for starting out
1277 $
('#IMPPLAN_zone').addClass('nodisplay');
1279 //ok we have at least one item, display them in order; hide the Builder instructions
1280 $
('#IMPPLAN_text').addClass('nodisplay');
1281 $
('#IMPPLAN_zone').removeClass('nodisplay');
1283 $
.each(items
, function( index
, value
) {
1284 if (!value
.codetext
) value
.codetext
="";
1285 if (!value
.code
) value
.code
="";
1286 if ((value
.code
==="") ||
(value
.code
.match(/Code
/) ||
(value
.code
==null))) {
1287 value
.code
="<i class='fa fa-search-plus'></i> Code";
1290 if (value
.code
.match(/\
,/g
)) {
1291 // If there is a comma in there, there is more than one code present for this item. Split them out.
1292 // If code is manually changed or copied from a prior visit - item will not have a PMSFH_link
1293 // PMSFH_link is only present when the Builder was used to make the entry.
1294 if ((typeof value
.PMSFH_link
!== "undefined") ||
(value
.PMSFH_link
!== null)) {
1295 //The Title should have the description.
1296 var CodeArr
= value
.code
.split(",");
1297 var TitleArr
= value
.codedesc
.split("\r");
1298 for (i
=0;i
< CodeArr
.length
;i++
) {
1299 if (CodeArr
.length
== (TitleArr
.length
-1)) { //there is a trailing \r
1300 $
('#Coding_DX_Codes').append(count_dx +
'. '+CodeArr
[i
]+
': '+TitleArr
[i
]+
'<br />');
1302 //just look it up via ajax or tell them to code it manually on the feesheet ;).
1303 $
('#Coding_DX_Codes').append(CodeArr
[i
]+
': <?php echo xlt('Manually retrieve description on Fee Sheet
'); ?> <br />');
1307 //this works for Clinical-derived terms with more than one Dx Code (found in more than one location/field)
1308 if (value
.PMSFH_link
.match(/Clinical_(.*)/)) {
1309 if (typeof obj
.Clinical
!== "undefined") {
1310 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1311 if (obj
.Clinical
[location
]!=null ) {
1312 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1313 $
('#Coding_DX_Codes').append(count_dx +
'. '+obj
.Clinical
[location
][i
].code+
': '+obj
.Clinical
[location
][i
].codedesc+
'<br />');
1316 //item has a PMSFH_link but it is not from a Clinical field
1317 alert("Houston, we have a problem!");
1322 } else { //all is good, one code only
1323 $
('#Coding_DX_Codes').append(count_dx +
'. '+value
.code+
': '+value
.codedesc+
'<br />');
1327 if (typeof nodisplay
!== "undefined") {
1330 var title2
= value
.title
.replace(/(\')/g
, '');
1331 contents_here
= "<span class='bold' contenteditable title='<?php echo xla('Click to edit'); ?>' id='IMPRESSION_"+index+
"'>" +
1332 value
.title +
"</span>"+
1333 "<span contenteditable class='pull-right' onclick='sel_diagnosis("+index+
",\""+title2+
"\");' title='"+value
.codetext+
"' id='CODE_"+index+
"'>"+
1334 value
.code +
"</span> "+
1335 "<br /><textarea id='PLAN_"+index+
"' name='PLAN_"+index+
1336 "' style='width:100%;max-width:100%;height:auto;min-height:3em;overflow-y: hidden;padding-top: 1.1em; '>"+
1337 value
.plan +
"</textarea><br /></li>";
1338 $
('#IMPPLAN_zone').append('<div id="IMPPLAN_zone_'+index+
'" class="IMPPLAN_class">'+
1339 '<i class="pull-right fa fa-close" id="BUTTON_IMPPLAN_'+index+
'"></i>'+
1340 contents_here+
'</div>');
1341 $
('#BUTTON_IMPPLAN_'+index
).click(function() {//delete/close icon
1342 var item
= this
.id
.match(/BUTTON_IMPPLAN_(.*)/)[1];
1343 obj
.IMPPLAN_items
.splice(item
,1);
1344 build_IMPPLAN(obj
.IMPPLAN_items
);
1345 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1347 $
('#PLAN_'+index
).css("background-color","#F0F8FF");
1351 // The IMPRESSION DXs are "contenteditable" spans.
1352 // If the user changes the words in an IMPRESSION Diagnosis area, store it.
1353 $
('[id^=IMPRESSION_]').blur(function(e
) {
1355 var item
= this
.id
.match(/IMPRESSION_(.*)/)[1];
1356 var content
= this
.innerText || this
.innerHTML
;
1357 obj
.IMPPLAN_items
[item
].title
= content
;
1358 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1359 //$(this).css('background-color','#F0F8FF');
1362 $
('[id^=CODE_]').blur(function() {
1363 var item
= this
.id
.match(/CODE_(.*)/)[1];
1364 var new_code
= this
.innerText || this
.innerHTML
;
1365 obj
.IMPPLAN_items
[item
].code
= new_code
;
1366 //obj.IMPPLAN_items[item].codetext = '';
1367 //obj.IMPPLAN_items[item].codedesc = '';
1368 $
(this
).css('background-color','#F0F8FF');
1369 store_IMPPLAN(obj
.IMPPLAN_items
);
1372 $
('[id^=PLAN_]').change(function() {
1373 var item
= this
.id
.match(/PLAN_(.*)/)[1];
1374 obj
.IMPPLAN_items
[item
].plan
= $
(this
).val();
1375 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
1376 $
(this
).css('background-color','#F0F8FF');
1379 $
('#IMPPLAN_zone').on( 'keyup', 'textarea', function (e
){
1380 $
(this
).css('height', 'auto' );
1381 $
(this
).height( this
.scrollHeight
);
1383 $
('#IMPPLAN_zone').find( 'textarea' ).keyup();
1384 obj
.IMPPLAN_items
= items
;
1390 * This functions updates a PMSFH item's code on the server via its issue number
1392 function update_PMSFH_code(the_issue
,new_code
){
1393 var url
= "../../forms/eye_mag/save.php?mode=update";
1394 top
.restoreSession();
1399 action
: 'code_PMSFH',
1400 pid
: $
('#pid').val(),
1401 form_id
: $
('#form_id').val(),
1402 encounter
: $
('#encounter').val(),
1403 uniqueID
: $
('#uniqueID').val(),
1407 }).done(function(result
) {
1408 if (result
== 'Code 400') {
1409 code_400(); //the user does not have write privileges!
1417 * This function sends the obj.IMPPLAN_items to the server for storage
1419 function store_IMPPLAN(storage
,nodisplay
) {
1420 if (typeof storage
!== "undefined") {
1421 var url
= "../../forms/eye_mag/save.php?mode=update&store_IMPPLAN";
1422 var formData
= JSON
.stringify(storage
);
1423 top
.restoreSession();
1429 parameter
: formData
,
1430 action
: 'store_IMPPLAN',
1431 pid
: $
('#pid').val(),
1432 form_id
: $
('#form_id').val(),
1433 encounter
: $
('#encounter').val(),
1434 uniqueID
: $
('#uniqueID').val()
1436 }).done(function(result
) {
1437 if (result
== "Code 400") {
1438 code_400(); //the user does not have write privileges!
1441 obj
.IMPPLAN_items
= result
;
1442 // if (typeof nodisplay === "undefined") {
1443 build_IMPPLAN(obj
.IMPPLAN_items
,nodisplay
);
1451 * This submits any codes we have in the obj.IMPPLAN_items variable, ie. what is in the Impression Plan currently, to the coding engine.
1454 function CODING_to_feesheet(CODING_items
) {
1455 if (typeof CODING_items
!== "undefined") {
1456 var url
= "../../forms/eye_mag/save.php?mode=update&track=ThingOne";
1457 var formData
= JSON
.stringify(CODING_items
);
1458 top
.restoreSession();
1463 'parameter' : formData
,
1464 'action' : 'code_visit',
1465 'pid' : $
('#pid').val(),
1466 'form_id' : $
('#form_id').val(),
1467 'encounter' : $
('#encounter').val(),
1468 'uniqueID' : $
('#uniqueID').val()
1470 }).done(function(result
) {
1471 if (result
== "Code 400") {
1472 code_400(); //the user does not have write privileges!
1475 $
("#goto_fee_sheet").removeClass('nodisplay');
1483 * This function allows the user to drag a DX from the Impression/Plan Builder list directly onto the Impression Plan list.
1484 * This item is appended to the $('#IMPPLAN_zone').
1486 function dragto_IMPPLAN_zone(event
, ui
) {
1487 var findme
= ui
.draggable
.find("span").attr("id");
1488 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1489 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1491 var the_codedesc
='';
1492 var the_codetext
='';
1494 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
1495 if (group
=="Clinical") {
1496 //more than one field can contain this DX.
1497 //Group them into one IMPPLAN.
1498 for (i
=0;i
< obj
.Clinical
[location
].length
; i++
) {
1499 the_code +
= obj
.Clinical
[location
][i
]['code']+
',';
1500 the_codedesc
= obj
.Clinical
[location
][i
]['codedesc'];
1501 the_codetext
= obj
.Clinical
[location
][i
]['codetext'];
1502 the_plan +
= obj
.Clinical
[location
][i
]['codedesc'] +
"\r";
1504 if (i
> 0) the_code
= the_code
.slice(0, -1);
1505 obj
.IMPPLAN_items
.push({
1507 codedesc
: the_codedesc
,
1508 codetext
: the_codetext
,
1509 codetype
: obj
.Clinical
[location
][0]['codetype'],
1511 PMSFH_link
: obj
.Clinical
[location
][0]['PMSFH_link'],
1512 title
: obj
.Clinical
[location
][0]['title']
1516 obj
.IMPPLAN_items
.push({
1517 code
: obj
.PMSFH
[group
][location
]['code'],
1518 codedesc
: obj
.PMSFH
[group
][location
]['codedesc'],
1519 codetext
: obj
.PMSFH
[group
][location
]['codetext'],
1520 codetype
: obj
.PMSFH
[group
][location
]['codetype'],
1521 plan
: obj
.PMSFH
[group
][location
]['comments'],
1522 PMSFH_link
: obj
.PMSFH
[group
][location
]['PMSFH_link'],
1523 title
: obj
.PMSFH
[group
][location
]['title']
1527 store_IMPPLAN(obj
.IMPPLAN_items
); //redisplay the items
1530 * This function allows the user to drag a DX from the IMPRESSION list directly into the New Dx field $('#IMP') <-- New Dx textarea
1531 * The data is appended to the end of the text.
1532 * It doesn't know what is already there (yet) so numbering if desired must be done manually.
1534 function dragto_IMPPLAN(event
, ui
) {
1535 var findme
= ui
.draggable
.find("span").attr("id");
1536 var group
= findme
.match(/DX_(.*)_(.*)/)[1];
1537 var location
= findme
.match(/DX_(.*)_(.*)/)[2];
1538 var draggable2
= ui
.draggable
;
1539 if (group
=="Clinical") {
1540 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n");
1542 $
('#IMP').val(ui
.draggable
[0].textContent+
"\n"+obj
.PMSFH
[group
][location
]['comments']);
1545 /* END Functions related to IMPPLAN Builder */
1547 function Suggest_visit_code() {
1548 //assume Eyes and established patient
1549 (Code_group
!= 'Eyes') ?
(digit_2
= '9') : digit_2
= '2'; //920XX or 990XX
1550 (Code_new_est
== 'New') ?
(digit_4
= '0') : digit_4
= '1'; //9X01X or 9X00X
1551 if (detail_reached_exam
=='1' && (detail_reached_HPI
=='1')) {
1552 (Code_group
=='Eyes') ?
(digit_5
= '4') : (digit_5
='3'); //920X4 or 990X3
1553 detailed
= "comprehensive";
1555 digit_5
= '2'; //920X2
1556 detailed
= "intermediate";
1558 visit_desc
= Code_new_est +
" "+ detailed +
" "+digit_5
;
1559 visit_code
= "9"+digit_2+
"0"+digit_4+digit_5
;
1560 $
('#visit_codes').val("CPT4|"+visit_code+
"|").change();
1563 * This function builds the codes and populates the billing table for this encounter.
1565 function build_CODING_list() {
1567 /* the following things get billed:
1568 1. Visit code(s) including neurosensory if performed
1572 //3. Diagnostic Codes
1573 $
.each(obj
.IMPPLAN_items
, function( index
, value
) {
1574 if (value
['codetype']) {
1575 if (value
['code'].match(/\
,/g
)) {
1576 // physical finding found in more than one location, more than one code...
1577 // if there is a comma in there, there is more than one code present. Split them out.
1578 // And all those in one group have the same link out (PMSFH_link) value
1579 var location
= value
.PMSFH_link
.match(/Clinical_(.*)/)[1];
1580 for (i
=0; i
< obj
.Clinical
[location
].length
; i++
) {
1582 code
: obj
.Clinical
[location
][i
]['code'],
1583 codedesc
: obj
.Clinical
[location
][i
]['codedesc'],
1584 codetext
: obj
.Clinical
[location
][i
]['codetext'],
1585 codetype
: obj
.Clinical
[location
][i
]['codetype'],
1586 title
: obj
.Clinical
[location
][i
]['title']
1589 } else if (value
['code'].match(/Code
/)){
1593 code
: value
['code'],
1594 codedesc
: value
['codedesc'],
1595 codetext
: value
['codetext'],
1596 codetype
: value
['codetype'],
1597 title
: value
['title']
1603 //1. Visit Codes. These can have a modifier (22,25,57 hard coded so far)
1606 codedesc
: visit_desc
,
1609 title
: 'Visit Code',
1610 modifier
: visit_modifier
,
1611 justify
: visit_justify
1614 if (CPT_92060
== 'here') {
1617 codedesc
: 'Sensorimotor exam',
1618 codetext
: 'Sensorimotor exam (CPT4:92060)',
1620 title
: 'Neuro/Sensorimotor Code',
1621 justify
: visit_justify
1624 //2. Tests/procedures performed to bill
1625 $
('.TESTS').each(function(i
, obj
) {
1627 if ($
(this
).is(':checked')) {
1628 var codetype
= obj
.value
.match(/(.*):(.*)/)[1];
1629 var code
= obj
.value
.match(/(.*):(.*)/)[2];
1630 var modifier
= $
('#'+obj
.id+
'_modifier').val();
1634 'codedesc' : obj
.title
,
1635 'codetext' : obj
.codetext
,
1636 'codetype' : codetype
,
1637 'title' : obj
.title
,
1638 'modifier' : modifier
1643 CODING_to_feesheet(CODING_items
);
1647 * Function to make the form fields inactive or active depending on the form's state (Active vs. READ-ONLY)
1649 function toggle_active_flags(new_state
) {
1650 if (($
("#chart_status").val() == "off") ||
(new_state
== "on")) {
1651 // we are read-only and we want to go active.
1652 $
("#chart_status").val("on");
1653 $
("#active_flag").html(" Active Chart ");
1654 $
("#active_icon").html("<i class='fa fa-toggle-on'></i>");
1655 $
("#warning").addClass("nodisplay");
1656 $
('input, select, textarea, a').removeAttr('disabled');
1657 $
('input, textarea').removeAttr('readonly');
1659 //else clicking this means we want to go from active to read-only
1660 $
("#chart_status").val("off");
1661 $
("#active_flag").html(" READ-ONLY ");
1662 $
("#active_icon").html("<i class='fa fa-toggle-off'></i>");
1663 $
("#warning").removeClass("nodisplay");
1664 //we should tell the form fields to be disabled. should already be...
1665 $
('input, select, textarea, a').attr('disabled', 'disabled');
1666 $
('input, textarea').attr('readonly', 'readonly');
1667 //need to also disable Ductions and Versions, PRIORS, Quicks Picks and Drawing!!! AND IMPPLAN area.
1668 //Either way a save in READ-ONLY mode fails - just returns this pop_up again, without saving...
1669 this_form_id
= $
("#form_id").val();
1670 $
("#COPY_SECTION").val("READONLY-"+this_form_id
);
1674 * Function to update a form in READ-ONLY mode with any data added by the Active version of this form_id/encounter form
1676 function update_READONLY() {
1678 'action' : 'retrieve',
1679 'copy' : 'READONLY',
1680 'zone' : 'READONLY',
1681 'copy_to' : $
("#form_id").val(),
1682 'copy_from' : $
("#form_id").val(),
1683 'pid' : $
("#pid").val()
1685 //we are going to update the whole form
1686 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
1687 //We are not ready to actively chart, just looking to see how far along our staff is...
1688 //or maybe just looking ahead to see the who's being worked up in the next room?
1689 //Either way, we are looking at a record that at present will be disabled/we cannot change...
1690 // yet it is updating every 10-15 seconds if another user is making changes.
1691 top
.restoreSession();
1695 url
: "../../forms/eye_mag/save.php?copy=READONLY",
1697 success
: function(result
) {
1698 $
.map(result
, function(valhere
, keyhere
) {
1699 if ($
("#"+keyhere
).val() != valhere
) {
1700 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
1702 if (keyhere
.match(/MOTILITY_
/)) {
1703 // Copy forward ductions and versions visually
1704 // Make each blank, and rebuild them
1705 $
("[name='"+keyhere+
"_1']").html('');
1706 $
("[name='"+keyhere+
"_2']").html('');
1707 $
("[name='"+keyhere+
"_3']").html('');
1708 $
("[name='"+keyhere+
"_4']").html('');
1709 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
1710 // Show a horizontal (minus) tag.
1711 hash_tag
= '<i class="fa fa-minus"></i>';
1712 } else { //show vertical tag
1713 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
1715 for (index
=1; index
<= valhere
; ++index
) {
1716 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
1718 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
1719 if (valhere
=='1') {
1720 $
("#FieldsNormal").prop('checked', false);
1721 $
("#"+keyhere
).prop('checked', true);
1722 $
("#"+keyhere
).val('1');
1724 $
("#"+keyhere
).val('0');
1725 $
("#"+keyhere
).prop('checked', false);
1727 } else if (keyhere
.match(/AMSLERO(.)/)) {
1728 var sidehere
= keyhere
.match(/AMSLERO(.)/);
1729 if (valhere
< '1') valhere
='0';
1730 $
("#"+keyhere
).val(valhere
);
1731 var srcvalue
="AmslerO"+sidehere
[1];
1732 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
1733 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
1734 } else if (keyhere
.match(/VA$
/)) {
1735 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
1736 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
1737 } else if (keyhere
.match(/^O
.VA_
/)) {
1738 var side
=keyhere
.match(/(O
.)VA_(.)/)[1];
1739 var rx_number
=keyhere
.match(/(O
.)VA_(.)/)[2];
1740 if (rx_number
== '1') { //update VA_1_copy and VA_1_copy_brd (first wearing RX only)
1741 $
('#'+side+
'VA_1_copy').val(valhere
).css("background-color","#F0F8FF");;
1742 $
('#'+side+
'VA_1_copy_brd').val(valhere
).css("background-color","#F0F8FF");;
1744 } else if (keyhere
.match(/^RX_TYPE_\d$
/)) {
1745 if (typeof $
('input:radio[name='+keyhere+
']')[valhere
] !== "undefined") {
1746 $
('input:radio[name='+keyhere+
']')[valhere
].checked
= true;
1748 } else if (keyhere
.match(/(alert|oriented|confused|PUPIL_NORMAL
)/)) {
1749 if (valhere
=='1') {
1750 $
('#'+keyhere
).val(valhere
).prop('checked', true);
1752 $
('#'+keyhere
).val(valhere
).prop('checked', false);
1758 function dopopup(url
) {
1759 window
.open(url
, 'clinical', 'width=fullscreen,height=fullscreen,resizable=1,scrollbars=1,directories=0,titlebar=0,toolbar=0,location=0,status=0,menubar=0');
1761 function goto_url(url
) {
1763 top
.restoreSession();
1766 function openImage() {
1767 dlgopen(base+
'/controller.php?document&retrieve&patient_id=3&document_id=10&as_file=false', '_blank', 600, 475);
1770 * Keyboard shortcut commands.
1773 shortcut
.add("Control+T",function() {
1776 shortcut
.add("Meta+T",function() {
1779 shortcut
.add("Control+D",function() {
1782 shortcut
.add("Meta+D",function() {
1785 shortcut
.add("Control+P",function() {
1786 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1788 shortcut
.add("Meta+P",function() {
1790 $
("#PRIOR_ALL").val($
('#form_id').val()).trigger("change");
1792 shortcut
.add("Control+B",function() {
1795 shortcut
.add("Meta+B",function() {
1798 shortcut
.add("Control+K",function() {
1801 shortcut
.add("Meta+K",function() {
1806 * this swallows backspace keys on the "rx" elements.
1807 * stops backspace -> back a page in the browser, a very annoying thing indeed.
1809 var rx
= /INPUT|SELECT|TEXTAREA|SPAN|DIV
/i
;
1811 $
(document
).bind("keydown keypress", function(e
){
1812 if( e
.which
== 8 ){ // 8 == backspace
1813 if(!rx
.test(e
.target
.tagName
) || e
.target
.disabled || e
.target
.readOnly
){
1821 * RIGHT NOW THIS WORKS PER FIELD ONLY in FF. In Chrome it works great. Not sure about IE at all.
1822 * In FF, you select a field and CTRL-Z reverses/Shift-Ctrl-Z forwards value
1823 * To get true Undo Redo, we will need to create two arrays, one with the command/field, prior value, next value to undo
1824 * and when undone, add this to the REDO array. When an Undo command is followed by anything other than Redo, it erases REDO array.
1825 * Ctrl-Z works without this extra code! Fuzzy on the details for specific browsers so TODO.
1830 * Function to update the PCP and referring person
1833 function update_DOCS() {
1834 var url
= "../../forms/eye_mag/save.php?mode=update";
1835 top
.restoreSession();
1841 pid
: $
('#pid').val(),
1842 pcp
: $
('#form_PCP').val(),
1843 rDOC
: $
('#form_rDOC').val(),
1844 form_id
: $
('#form_id').val(),
1845 encounter
: $
('#encounter').val(),
1846 uniqueID
: $
('#uniqueID').val()
1848 }).done(function(result
) {
1849 if (result
== "Code 400") {
1850 code_400(); //the user does not have write privileges!
1857 * Function to convert ophthalmic prescriptions between plus cylinder and minus cylinder
1860 function reverse_cylinder(target
) {
1861 //target can be revW1-5,AR,MR,CR,CTL,
1864 if (target
.match(/^
(AR|MR|CR|CTL
)$
/)) {
1868 if (target
.match(/^revW
[1-5]{1}$
/)) { //matches on digit only, here 1-5
1869 target
= target
.replace("revW","");
1871 suffix
= '_'+target
;
1873 var Rsph
= $
('#'+prefix+
'ODSPH'+suffix
).val();
1874 var Rcyl
= $
('#'+prefix+
'ODCYL'+suffix
).val();
1875 var Raxis
= $
('#'+prefix+
'ODAXIS'+suffix
).val();
1876 var Lsph
= $
('#'+prefix+
'OSSPH'+suffix
).val();
1877 var Lcyl
= $
('#'+prefix+
'OSCYL'+suffix
).val();
1878 var Laxis
= $
('#'+prefix+
'OSAXIS'+suffix
).val();
1879 if (Rsph
=='' && Rcyl
=='' && Lsph
=='' && lcyl
=='') return;
1880 if ((!Rcyl
.match(/SPH
/i
)) && (Rcyl
>'')) {
1881 if (Rsph
.match(/plano
/i
)) Rsph
='0';
1882 Rsph
= Number(Rsph
);
1883 Rcyl
= Number(Rcyl
);
1884 Rnewsph
= Rsph + Rcyl
;
1885 if (Rnewsph
==0) Rnewsph
="PLANO";
1886 Rnewcyl
= Rcyl
* -1;
1887 if (Rnewcyl
> 0) Rnewcyl
= "+"+Rnewcyl
;
1888 if (parseInt(Raxis
) < 90) {
1889 Rnewaxis
= parseInt(Raxis
) +
90;
1891 Rnewaxis
= parseInt(Raxis
) - 90;
1893 if (Rnewcyl
=='0') Rnewcyl
= "SPH";
1894 if (Rnewsph
=='0') {
1896 if (Rnewcyl
=="SPH") Rnewcyl
= '';
1898 $
('#'+prefix+
'ODSPH'+suffix
).val(Rnewsph
);
1899 $
('#'+prefix+
'ODCYL'+suffix
).val(Rnewcyl
);
1900 $
('#'+prefix+
'ODAXIS'+suffix
).val(Rnewaxis
);
1901 $
('#'+prefix+
'ODAXIS'+suffix
).trigger('blur');
1902 $
('#'+prefix+
'ODSPH'+suffix
).trigger('blur');
1903 $
('#'+prefix+
'ODCYL'+suffix
).trigger('blur');
1905 if ((!Lcyl
.match(/SPH
/i
)) && (Lcyl
>'')) {
1906 if (!Lsph
.match(/\d
/)) Lsph
='0';
1907 Lsph
= Number(Lsph
);
1908 Lcyl
= Number(Lcyl
);
1909 Lnewsph
= Lsph + Lcyl
;
1910 Lnewcyl
= Lcyl
* -1;
1911 if (Lnewcyl
> 0) Lnewcyl
= "+"+ Lnewcyl
;
1912 if (parseInt(Laxis
) < 90) {
1913 Lnewaxis
= parseInt(Laxis
) +
90;
1915 Lnewaxis
= parseInt(Laxis
) - 90;
1918 if (Lnewcyl
=='0') Lnewcyl
= "SPH";
1919 if (Lnewsph
=='0') {
1921 if (Lnewcyl
=="SPH") Lnewcyl
= '';
1924 $
('#'+prefix+
'OSSPH'+suffix
).val(Lnewsph
);
1925 $
('#'+prefix+
'OSCYL'+suffix
).val(Lnewcyl
);
1926 $
('#'+prefix+
'OSAXIS'+suffix
).val(Lnewaxis
);
1927 $
('#'+prefix+
'OSAXIS'+suffix
).trigger('blur');
1928 $
('#'+prefix+
'OSSPH'+suffix
).trigger('blur');
1929 $
('#'+prefix+
'OSCYL'+suffix
).trigger('blur');
1932 function scrollTo(target
) {
1933 //if (scroll !== '1') return;
1935 var scrollSpeed
= 500;
1936 var wheight
= $
(window
).height();
1937 offset
= $
("#"+target
).offset().top
- (wheight
/ 2)+
200;
1938 if (offset
> (window
.pageYOffset +
150)||offset
< (window
.pageYOffset
-150)) {
1939 $
('html, body').animate({scrollTop
:offset
}, scrollSpeed
);
1943 $
(document
).ready(function() {
1947 my
: 'top Right', // Position my top left...
1948 at
: 'bottom Left', // at the bottom right of...
1949 target
: 'mouse' // my target
1953 $
('#form_PCP,#form_rDOC').change(function() {
1956 $
('#tooltips_status').html($
('#PREFS_TOOLTIPS').val());
1957 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('Off'); ?>") {
1958 $
('[title]').qtip('disable');
1960 $
('#tooltips_toggle,#tooltips_status').click(function() {
1961 if ($
("#PREFS_TOOLTIPS").val() == "<?php echo xla('On'); ?>") {
1962 $
('#PREFS_TOOLTIPS').val('<?php echo xla('Off
'); ?>');
1963 $
("#tooltips_status").html('<?php echo xla('are off
'); ?>');
1964 $
('[title]').qtip('disable');
1966 $
('#PREFS_TOOLTIPS').val('<?php echo xla('On
'); ?>');
1967 $
('#tooltips_status').html('<?php echo xla('are on
'); ?>');
1968 $
('[title]').qtip('enable');
1972 $
('#toggle_drugs').click(function(){
1973 $
('.hideme_drugs').toggleClass('nodisplay');
1974 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1977 $
('#toggle_VFs').click(function(){
1978 $
('.hideme_VFs').toggleClass('nodisplay');
1979 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1982 $
('#toggle_OCTs').click(function(){
1983 $
('.hideme_OCTs').toggleClass('nodisplay');
1984 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1987 $
('#toggle_cups').click(function(){
1988 $
('.hideme_cups').toggleClass('nodisplay');
1989 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1992 $
('#toggle_gonios').click(function(){
1993 $
('.hideme_gonios').toggleClass('nodisplay');
1994 $
(this
).find('i').toggleClass('fa-toggle-down fa-toggle-up')
1997 $
('.close').click(function(){
1998 $
('#GFS_accordion .hide').slideUp();
2000 $
('#ODIOPTARGET').change(function() {
2001 $
('#OSIOPTARGET').val($
('#ODIOPTARGET').val());
2004 $
('#ODIOPAP,#OSIOPAP,#ODIOPTARGET').change(function() {
2005 //this is failing if there is no config_by_day variable.
2008 if ($
("#PREFS_KB").val() =='1') {
2009 $
(".kb").removeClass('nodisplay');
2010 $
(".kb_off").addClass('nodisplay');
2012 $
(".kb").addClass('nodisplay');
2013 $
(".kb_off").removeClass('nodisplay');
2016 $
("[name$='_kb']").click(function() {
2017 $
('.kb').toggleClass('nodisplay');
2018 $
('.kb_off').toggleClass('nodisplay');
2019 if ($
('#PREFS_EXAM').val() == 'DRAW') {
2023 if ($
("#PREFS_KB").val() > 0) {
2024 $
("#PREFS_KB").val('0');
2026 $
("#PREFS_KB").val('1');
2030 $
('.ke').mouseover(function() {
2031 $
(this
).toggleClass('yellow');
2033 $
('.ke').mouseout(function() {
2034 $
(this
).toggleClass('yellow');
2036 $
("[id$='_keyboard'],[id$='_keyboard_left']").on('keydown', function(e
) {
2037 //this is the Shorthand engine's ignition
2038 if (e
.which
== 13|| e
.keyCode
== 13||e
.which
== 9|| e
.keyCode
== 9) {
2040 var data_all
= $
(this
).val();
2041 var data_seg
= data_all
.match(/([^
;]*)/gm
);
2045 for (index
=0; index
< data_seg
.length
; ++index
) {
2046 if (data_seg
[index
] =='') continue;
2047 data_seg
[index
] = data_seg
[index
].replace(/^
[\n\v\f\r\x85\u2028\u2029\W
]*/
,'');
2048 data_seg
[index
] = data_seg
[index
].replace(/^
[\s
]*/
,'');
2049 if (data_seg
[index
].match(/^
D($|
;)/i
)) {
2050 $
("#EXT_defaults").trigger("click");
2051 $
("#ANTSEG_defaults").trigger("click");
2052 $
("#RETINA_defaults").trigger("click");
2053 $
("#NEURO_defaults").trigger("click");
2056 if (data_seg
[index
].match(/^
DEXT($|
;)/i
)) {
2057 $
("#EXT_defaults").trigger("click");
2060 if (data_seg
[index
].match(/^
DANTSEG($|
;)/i
)) {
2061 $
("#ANTSEG_defaults").trigger("click");
2064 if (data_seg
[index
].match(/^
DAS($|
;)/i
)) {
2065 $
("#ANTSEG_defaults").trigger("click");
2068 if (data_seg
[index
].match(/^
DRETINA($|
;)/i
)) {
2069 $
("#RETINA_defaults").trigger("click");
2072 if (data_seg
[index
].match(/^
DRET($|
;)/i
)) {
2073 $
("#RETINA_defaults").trigger("click");
2076 if (data_seg
[index
].match(/^
DNEURO($|
;)/i
)) {
2077 $
("#NEURO_defaults").trigger("click");
2080 if ((data_seg
[index
].match(/^
CLEAREXT($|
;)/i
))||
2081 (data_seg
[index
].match(/^
CEXT($|
;)/i
))) {
2085 if ((data_seg
[index
].match(/^
CLEARAS($|
;)/i
))||
2086 (data_seg
[index
].match(/^
CLEARANTSEG($|
;)/i
))||
2087 (data_seg
[index
].match(/^
CANTSEG($|
;)/i
))||
2088 (data_seg
[index
].match(/^
CANT($|
;)/i
))||
2089 (data_seg
[index
].match(/^
CAS($|
;)/i
))) {
2090 $
(".ANTSEG").val('');
2093 if ((data_seg
[index
].match(/^
CLEARRET($|
;)/i
))||
2094 (data_seg
[index
].match(/^
CRET($|
;)/i
)) ||
2095 (data_seg
[index
].match(/^
CLEARRETINA($|
;)/i
))||
2096 (data_seg
[index
].match(/^
CRETINA($|
;)/i
))) {
2097 $
(".RETINA").val('');
2102 var data
= data_seg
[index
].match(/^
(\w
*)\
:?
(.*)/);
2103 (data
[2].match(/\
.a$
/))?
(data
[2] = data
[2].replace(/\
.a$
/,'')):(appendix
= "nope");
2104 var field
= data
[1].toUpperCase();
2106 text
= expand_vocab(text
);
2107 priors
= process_kb(field
,text
,appendix
,prior_field
,prior_text
);
2108 prior_field
= priors
['field'];
2109 prior_text
= priors
['prior_text'];
2117 $
("[id^='sketch_tools_']").click(function() {
2118 var zone
= this
.id
.match(/sketch_tools_(.*)_
/)[1];
2119 $
("[id^='sketch_tools_"+zone+
"']").css("height","30px");
2120 $
(this
).css("height","50px");
2121 $
("#sketch_tool_"+zone+
"_color").css("background-color",$
("#selColor_"+zone
).val());
2123 $
("[id^='sketch_sizes_']").click(function() {
2124 var zone
= this
.id
.match(/sketch_sizes_(.*)_
/)[1];
2125 $
("[id^='sketch_sizes_"+zone+
"']").css("background","").css("border-bottom","");
2126 $
(this
).css("border-bottom","2pt solid black");
2129 // Here we get CC1 to show
2130 $
(".tab_content").addClass('nodisplay');
2131 $
("#tab1_CC_text").removeClass('nodisplay');
2132 $
("#tab1_HPI_text").removeClass('nodisplay');
2133 $
("[id$='_CC'],[id$='_HPI_tab']").click(function() {
2134 // First remove class "active" from currently active tabs
2135 $
("[id$='_CC']").removeClass('active');
2136 $
("[id$='_HPI_tab']").removeClass('active');
2137 // Hide all tab content
2138 $
(".tab_content").addClass('nodisplay');
2139 // Here we get the href value of the selected tab
2140 var selected_tab
= $
(this
).find("a").attr("href");
2141 // Now add class "active" to the selected/clicked tab and content
2142 $
(selected_tab+
"_CC").addClass('active');
2143 $
(selected_tab+
"_CC_text").removeClass('nodisplay');
2144 $
(selected_tab+
"_HPI_tab").addClass('active');
2145 $
(selected_tab+
"_HPI_text").removeClass('nodisplay');
2146 // At the end, we add return false so that the click on the link is not executed
2149 $
("[id^='CONSTRUCTION_']").toggleClass('nodisplay');
2150 $
("input,textarea,text").css("background-color","#FFF8DC");
2151 $
("#IOPTIME").css("background-color","#FFFFFF");
2152 $
("#refraction_width").css("width","8.5in");
2153 $
(".Draw_class").addClass('nodisplay');
2154 $
(".PRIORS_class").addClass('nodisplay');
2157 $
(window
).resize(function() {
2158 if (window
.innerWidth
>'900') {
2159 $
("#refraction_width").css("width","900px");
2160 $
("#LayerVision2").css("padding","4px");
2162 if (window
.innerWidth
>'1300') {
2163 $
("#refraction_width").css("width","1300px");
2164 //$("#first").css("width","1300px");
2166 if (window
.innerWidth
>'1900') {
2167 $
("#refraction_width").css("width","1600px");
2173 var hash_tag
= '<i class="fa fa-minus"></i>';
2175 // display any stored MOTILITY values
2176 $
("#MOTILITY_RS").value
= parseInt($
("#MOTILITY_RS").val());
2177 if ($
("#MOTILITY_RS").val() > '0') {
2178 $
("#MOTILITYNORMAL").removeAttr('checked');
2179 for (index
=1; index
<= ($
("#MOTILITY_RS").val()); ++index
) {
2180 $
("#MOTILITY_RS_"+index
).html(hash_tag
);
2183 $
("#MOTILITY_RI").value
= parseInt($
("#MOTILITY_RI").val());
2184 if ($
("#MOTILITY_RI").val() > '0') {
2185 $
("#MOTILITYNORMAL").removeAttr('checked');
2186 for (index
=1; index
<= ($
("#MOTILITY_RI").val()); ++index
) {
2187 $
("#MOTILITY_RI_"+index
).html(hash_tag
);
2190 $
("#MOTILITY_LS").value
= parseInt($
("#MOTILITY_LS").val());
2191 if ($
("#MOTILITY_LS").val() > '0') {
2192 $
("#MOTILITYNORMAL").removeAttr('checked');
2193 for (index
=1; index
<= ($
("#MOTILITY_LS").val()); ++index
) {
2194 $
("#MOTILITY_LS_"+index
).html(hash_tag
);
2197 $
("#MOTILITY_LI").value
= parseInt($
("#MOTILITY_LI").val());
2198 if ($
("#MOTILITY_LI").val() > '0') {
2199 $
("#MOTILITYNORMAL").removeAttr('checked');
2200 for (index
=1; index
<= ($
("#MOTILITY_LI").val()); ++index
) {
2201 $
("#MOTILITY_LI_"+index
).html(hash_tag
);
2205 $
("#MOTILITY_RRSO").value
= parseInt($
("#MOTILITY_RRSO").val());
2206 if ($
("#MOTILITY_RRSO").val() > '0') {
2207 $
("#MOTILITYNORMAL").removeAttr('checked');
2208 for (index
=1; index
<= ($
("#MOTILITY_RRSO").val()); ++index
) {
2209 $
("#MOTILITY_RRSO_"+index
).html(hash_tag
);
2212 $
("#MOTILITY_RRIO").value
= parseInt($
("#MOTILITY_RRIO").val());
2213 if ($
("#MOTILITY_RRIO").val() > '0') {
2214 $
("#MOTILITYNORMAL").removeAttr('checked');
2215 for (index
=1; index
<= ($
("#MOTILITY_RRIO").val()); ++index
) {
2216 $
("#MOTILITY_RRIO_"+index
).html(hash_tag
);
2219 $
("#MOTILITY_RLIO").value
= parseInt($
("#MOTILITY_RLIO").val());
2220 if ($
("#MOTILITY_RLIO").val() > '0') {
2221 $
("#MOTILITYNORMAL").removeAttr('checked');
2222 for (index
=1; index
<= ($
("#MOTILITY_RLIO").val()); ++index
) {
2223 $
("#MOTILITY_RLIO_"+index
).html(hash_tag
);
2226 $
("#MOTILITY_RLSO").value
= parseInt($
("#MOTILITY_RLSO").val());
2227 if ($
("#MOTILITY_RLSO").val() > '0') {
2228 $
("#MOTILITYNORMAL").removeAttr('checked');
2229 for (index
=1; index
<= ($
("#MOTILITY_RLSO").val()); ++index
) {
2230 $
("#MOTILITY_RLSO_"+index
).html(hash_tag
);
2233 $
("#MOTILITY_LRSO").value
= parseInt($
("#MOTILITY_LRSO").val());
2234 if ($
("#MOTILITY_LRSO").val() > '0') {
2235 $
("#MOTILITYNORMAL").removeAttr('checked');
2236 for (index
=1; index
<= ($
("#MOTILITY_LRSO").val()); ++index
) {
2237 $
("#MOTILITY_LRSO_"+index
).html(hash_tag
);
2240 $
("#MOTILITY_LRIO").value
= parseInt($
("#MOTILITY_LRIO").val());
2241 if ($
("#MOTILITY_LRIO").val() > '0') {
2242 $
("#MOTILITYNORMAL").removeAttr('checked');
2243 for (index
=1; index
<= ($
("#MOTILITY_LRIO").val()); ++index
) {
2244 $
("#MOTILITY_LRIO_"+index
).html(hash_tag
);
2247 $
("#MOTILITY_LLSO").value
= parseInt($
("#MOTILITY_LLSO").val());
2248 if ($
("#MOTILITY_LLSO").val() > '0') {
2249 $
("#MOTILITYNORMAL").removeAttr('checked');
2250 for (index
=1; index
<= ($
("#MOTILITY_LLSO").val()); ++index
) {
2251 $
("#MOTILITY_LLSO_"+index
).html(hash_tag
);
2254 $
("#MOTILITY_LLIO").value
= parseInt($
("#MOTILITY_LLIO").val());
2255 if ($
("#MOTILITY_LLIO").val() > '0') {
2256 $
("#MOTILITYNORMAL").removeAttr('checked');
2257 for (index
=1; index
<= ($
("#MOTILITY_LLIO").val()); ++index
) {
2258 $
("#MOTILITY_LLIO_"+index
).html(hash_tag
);
2262 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
2263 $
("#MOTILITY_LR").value
= parseInt($
("#MOTILITY_LR").val());
2264 if ($
("#MOTILITY_LR").val() > '0') {
2265 $
("#MOTILITYNORMAL").removeAttr('checked');
2266 for (index
=1; index
<= ($
("#MOTILITY_LR").val()); ++index
) {
2267 $
("#MOTILITY_LR_"+index
).html(hash_tag
);
2270 $
("#MOTILITY_LL").value
= parseInt($
("#MOTILITY_LL").val());
2271 if ($
("#MOTILITY_LL").val() > '0') {
2272 $
("#MOTILITYNORMAL").removeAttr('checked');
2273 for (index
=1; index
<= ($
("#MOTILITY_LL").val()); ++index
) {
2274 $
("#MOTILITY_LL_"+index
).html(hash_tag
);
2277 $
("#MOTILITY_RR").value
= parseInt($
("#MOTILITY_RR").val());
2278 if ($
("#MOTILITY_RR").val() > '0') {
2279 $
("#MOTILITYNORMAL").removeAttr('checked');
2280 for (index
=1; index
<= ($
("#MOTILITY_RR").val()); ++index
) {
2281 $
("#MOTILITY_RR_"+index
).html(hash_tag
);
2284 $
("#MOTILITY_RL").value
= parseInt($
("#MOTILITY_RL").val());
2285 if ($
("#MOTILITY_RL").val() > '0') {
2286 $
("#MOTILITYNORMAL").removeAttr('checked');
2287 for (index
=1; index
<= ($
("#MOTILITY_RL").val()); ++index
) {
2288 $
("#MOTILITY_RL_"+index
).html(hash_tag
);
2292 $
(".chronic_HPI,.count_HPI").blur(function() {
2293 check_exam_detail();
2296 $
("#DIL_RISKS").change(function(o
) {
2297 ($
(this
).is(':checked')) ?
($
(".DIL_RISKS").removeClass("nodisplay")) : ($
(".DIL_RISKS").addClass("nodisplay"));
2298 check_exam_detail();
2300 $
(".dil_drug").change(function(o
) {
2301 if ($
(this
).is(':checked')) {
2302 //($(".DIL_RISKS").removeClass("nodisplay"));
2303 $
("#DIL_RISKS").prop("checked","checked");
2304 check_exam_detail();
2307 //neurosens exam = stereopsis + strab||NPC||NPA||etc
2308 $
(".neurosens,.neurosens2").blur(function() {
2311 // END AUTO-CODING FEATURES
2313 // functions to improve flow of refraction input
2314 $
("input[name$='PRISM'],input[class^='prism']").blur(function() {
2316 var str
= $
(this
).val();
2317 str
= str
.toUpperCase();
2320 $
('input[class^="sphere"],input[name$="SPH"]').blur(function() {
2321 var mid
= $
(this
).val();
2322 if (mid
.match(/PLANO
/i
)) {
2323 $
(this
).val('PLANO');
2326 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2329 if (mid
.match(/\
.[27]$
/)) {
2332 if (mid
.match(/\
.\d$
/)) {
2335 //if near is +2. make it +2.00
2336 if (mid
.match(/\
.$
/)) {
2339 if ((!mid
.match(/\
./))&&(mid
.match(00|
25|
50|
75))) {
2340 var front
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[1];
2341 var back
= mid
.match(/(\d
{0,2})(00|
25|
50|
75)/)[2];
2342 if (front
=='') front
='0';
2343 mid
= front +
"." + back
;
2345 if (!mid
.match(/\
./)) {
2346 var front
= mid
.match(/([\+\
-]?\d
{0,2})(\d
{2})/)[1];
2347 var back
= mid
.match(/(\d
{0,2})(\d
{2})/)[2];
2348 if (front
=='') front
='0';
2349 if (front
=='-') front
='-0';
2350 mid
= front +
"." + back
;
2352 if (!mid
.match(/^
(\+|\
-){1}/)) {
2358 $
("input[class^='presbyopia'],input[name$='ADD'],#ODADD_1,#ODADD_2,#OSADD_1,#OSADD_2").blur(function() {
2359 var add
= $
(this
).val();
2360 add
= add
.replace(/=/g
,"+");
2361 //if add is one digit, eg. 2, make it +2.00
2362 if (add
.match(/^\d
{1}$
/)) {
2363 add
= "+"+add+
".00";
2365 //if add is '+'one digit, eg. +2, make it +2.00
2366 if (add
.match(/^\+\d
{1}$
/)) {
2369 //if add is 2.5 or 2.0 make it 2.50 or 2.00
2370 if (add
.match(/\
.[05]$
/)) {
2373 //if add is 2.2 or 2.7 make it 2.25 or 2.75
2374 if (add
.match(/\
.[27]$
/)) {
2377 //if add is +2. make it +2.00
2378 if (add
.match(/\
.$
/)) {
2381 if ((!add
.match(/\
./))&&(add
.match(/(0|
25|
50|
75)$
/))) {
2382 var front
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[1];
2383 var back
= add
.match(/([\+
]?\d
{0,1})(00|
25|
50|
75)/)[2];
2384 if (front
=='') front
='0';
2385 add
= front +
"." + back
;
2387 if (!add
.match(/^
(\+
)/) && (add
.length
> 0)) {
2391 if (this
.id
=="ODADD_1") $
('#OSADD_1').val(add
);
2392 if (this
.id
=="ODMIDADD_1") $
('#OSMIDADD_1').val(add
);
2393 if (this
.id
=="ODADD_2") $
('#OSADD_2').val(add
);
2394 if (this
.id
=="ODMIDADD_2") $
('#OSMIDADD_2').val(add
);
2395 if (this
.id
=="ODADD_3") $
('#OSADD_3').val(add
);
2396 if (this
.id
=="ODMIDADD_3") $
('#OSMIDADD_3').val(add
);
2397 if (this
.id
=="ODADD_4") $
('#OSADD_4').val(add
);
2398 if (this
.id
=="ODMIDADD_4") $
('#OSMIDADD_4').val(add
);
2399 if (this
.id
=="ODADD_5") $
('#OSADD_5').val(add
);
2400 if (this
.id
=="ODMIDADD_5") $
('#OSMIDADD_5').val(add
);
2401 if (this
.id
=="MRODADD") $
('#MROSADD').val(add
);
2402 if (this
.id
=="ARODADD") $
('#AROSADD').val(add
);
2403 if (this
.id
=="CTLODADD") $
('#CTLOSADD').val(add
);
2406 $
("input[class^='axis'],input[name$='AXIS']").blur(function() {
2407 // Make this a 3 digit leading zeros number.
2408 // we are not translating text to numbers, just numbers to
2409 // a 3 digit format with leading zeroes as needed.
2410 // assume the end user KNOWS there are only numbers presented and
2411 // more than 3 digits is a mistake...
2412 // (although this may change with topography)
2413 var axis
= $
(this
).val();
2414 var group
= this
.name
.replace("AXIS", "CYL");;
2415 var cyl
= $
("#"+group
).val();
2416 if ((cyl
> '') && (cyl
!= 'SPH')) {
2417 if (!axis
.match(/\d\d\d
/)) {
2418 if (!axis
.match(/\d\d
/)) {
2419 if (!axis
.match(/\d
/)) {
2429 //we can utilize a phoropter dial feature, we can start them at their age appropriate with/against the rule value.
2430 //requires touch screen. requires complete touch interface development. Exists in refraction lanes. Would
2431 //be nice to tie them all together. Would require manufacturers to publish their APIs to communicate with
2435 $
("input[class^='cylinder'],input[name$='CYL']").blur(function() {
2436 var mid
= $
(this
).val();
2437 var group
= this
.name
.replace("CYL", "SPH");;
2438 var sphere
= $
("#"+group
).val();
2439 if (((mid
.length
== 0) && (sphere
.length
> 0))||
(mid
.match(/sph
/i
))) {
2441 if (sphere
.match(/plano
/i
)) $
(this
).val('');
2442 var axis
= this
.name
.replace("CYL", "AXIS");
2443 $
("#"+axis
).val('');
2444 submit_form($
(this
));
2446 } else if (sphere
.length
> 0) {
2447 if (mid
.match(/^
[\+\
-]?\d
{1}$
/)) {
2450 if (mid
.match(/^
(\d
)(\d
)$
/)) {
2451 mid
= mid
[0] +
'.' +mid
[1];
2454 //if mid is 2.5 or 2.0 make it 2.50 or 2.00
2455 if (mid
.match(/\
.[05]$
/)) {
2458 //if mid is 2.2 or 2.7 make it 2.25 or 2.75
2459 if (mid
.match(/\
.[27]$
/)) {
2462 //if mid is +2. make it +2.00
2463 if (mid
.match(/\
.$
/)) {
2466 if (mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)) {
2467 var front
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[1];
2468 var back
= mid
.match(/([\+\
-]?\d
{0,2})\
.?
(00|
25|
50|
75)/)[2];
2469 if (front
=='') front
='0';
2470 mid
= front +
"." + back
;
2472 if (!$
('#PREFS_CYL').val()) {
2473 $
('#PREFS_CYL').val('+');
2476 if (!mid
.match(/^
(\+|\
-){1}/) && (sphere
.length
> 0)) {
2477 //no +/- sign at the start of the field.
2478 //ok so there is a preference set
2479 //Since it doesn't start with + or - then give it the preference value
2480 mid
= $
('#PREFS_CYL').val() + mid
;
2481 } else if (mid
.match(/^
(\+|\
-){1}/)) {
2482 pref
= mid
.match(/^
(\+|\
-){1}/)[0];
2483 //so they used a value + or - at the start of the field.
2484 //The only reason to work on this is to change to cylinder preference
2485 if ($
('#PREFS_CYL').val() != pref
){
2486 //and that is what they are doing here
2487 $
('#PREFS_CYL').val(pref
);
2494 //bootstrap menu functions
2495 $
("[class='dropdown-toggle']").hover(function(){
2496 $
("[class='dropdown-toggle']").parent().removeClass('open');
2497 var menuitem
= this
.id
.match(/(.*)/)[1];
2498 //if the menu is active through a prior click, show it
2499 // Have to override Bootstrap then
2500 if ($
("#menustate").val() !="1") { //menu not active -> ignore
2501 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2502 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2503 } else { //menu is active -> respond
2504 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2505 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2506 $
("#"+menuitem
).css("text-decoration","none");
2507 $
("#"+menuitem
).parent().addClass('open');
2510 var menuitem
= this
.id
.match(/(.*)/)[1];
2511 $
("#"+menuitem
).css("color","#000"); /*#262626;*/
2512 $
("#"+menuitem
).css("background-color", "#C9DBF2");
2515 $
("[class='dropdown-toggle']").click(function() {
2516 $
("#menustate").val('1');
2517 var menuitem
= this
.id
.match(/(.*)/)[1];
2518 $
("#"+menuitem
).css("background-color", "#1C5ECF");
2519 $
("#"+menuitem
).css("color","#fff"); /*#262626;*/
2520 $
("#"+menuitem
).css("text-decoration","none");
2522 $
("#right-panel-link, #close-panel-bt,#right-panel-link_2").click(function() {
2523 if ($
("#PREFS_PANEL_RIGHT").val() =='1') {
2524 $
("#PREFS_PANEL_RIGHT").val('0');
2526 $
("#PREFS_PANEL_RIGHT").val('1');
2530 $
("[name^='menu_']").click(function() {
2531 $
("[name^='menu_']").removeClass('active');
2532 var menuitem
= this
.id
.match(/menu_(.*)/)[1];
2533 $
(this
).addClass('active');
2534 $
("#menustate").val('1');
2535 menu_select(menuitem
);
2537 // set display functions for Draw panel appearance
2538 // for each DRAW area, if the value AREA_DRAW = 1, show it.
2539 var zones
= ["PMH","HPI","EXT","ANTSEG","RETINA","NEURO","IMPPLAN"];
2540 for (index
= '0'; index
< zones
.length
; ++index
) {
2541 if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='DRAW') {
2542 show_DRAW_section(zones
[index
]);
2543 } else if ($
("#PREFS_"+zones
[index
]+
"_RIGHT").val() =='QP') {
2544 show_QP_section(zones
[index
]);
2547 $
("body").on("click","[name$='_text_view']" , function() {
2548 var header
= this
.id
.match(/(.*)_text_view$
/)[1];
2549 $
("#"+header+
"_text_list").toggleClass('wide_textarea');
2550 $
("#"+header+
"_text_list").toggleClass('narrow_textarea');
2551 $
(this
).toggleClass('fa-plus-square-o');
2552 $
(this
).toggleClass('fa-minus-square-o');
2553 if (header
!= /PRIOR
/) {
2554 var imagine
= $
("#PREFS_"+header+
"_VIEW").val();
2556 $
("#PREFS_"+header+
"_VIEW").val(imagine
);
2561 $
("body").on("change", "select", function(e
){
2562 if (this
.name
.match(/PRIOR_(.*)/)) {
2563 var new_section
= this
.name
.match(/PRIOR_(.*)/);
2564 if (new_section
[1] =='') return;
2565 if (new_section
[1] == /\_
/){
2568 var newValue
= this
.value
;
2569 if (newValue
== $
("#form_id").val()) {
2570 if (new_section
[1] =="ALL") {
2571 //click updates prefs too
2572 $
('#EXAM_QP').trigger("click");
2573 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
2574 $
('#PMH_left').height($
('#PMH_right').height());
2575 $
('#PMH_1').height($
('#PMH_right').height()+
20);
2576 } else { $
('#PMH_1').height($
('#HPI_1').height()); }
2578 $
('#BUTTON_QP_'+new_section
[1]).trigger("click");
2580 $
("#LayerTechnical_sections_1").css("clear","both");
2583 //now go get the prior page via ajax
2584 var newValue
= this
.value
;
2585 $
("#PRIORS_"+ new_section
[1] +
"_left_text").removeClass('nodisplay');
2586 $
("#DRAWS_" + new_section
[1] +
"_right").addClass('nodisplay');
2587 $
("#QP_" + new_section
[1]).addClass('nodisplay');
2589 if (new_section
[1] =="ALL") {
2591 show_PRIORS_section("ALL",newValue
);
2592 show_PRIORS_section("EXT",newValue
);
2593 show_PRIORS_section("ANTSEG",newValue
);
2594 show_PRIORS_section("RETINA",newValue
);
2595 show_PRIORS_section("NEURO",newValue
);
2596 show_PRIORS_section("IMPPLAN",newValue
);
2597 scrollTo("EXT_left");
2599 show_PRIORS_section(new_section
[1],newValue
);
2603 $
("body").on("click","[id^='Close_PRIORS_']", function() {
2604 var new_section
= this
.id
.match(/Close_PRIORS_(.*)$
/)[1];
2605 $
("#PRIORS_"+ new_section +
"_left_text").addClass('nodisplay');
2606 $
("#QP_" + new_section
).removeClass('nodisplay');
2608 $
("#pupils,#vision_tab,[name='CTL'],[name^='more_'],#ACTTRIGGER").mouseover(function() {
2609 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline').css( 'cursor', 'pointer' );
2611 $
("#pupils,#vision_tab,[name='CTL']").mouseout(function() {
2612 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
2614 $
("#pupils").click(function(){
2615 if ($
("#dim_pupils_panel").hasClass("nodisplay")) {
2616 $
("#dim_pupils_panel").removeClass('nodisplay');
2618 $
("#dim_pupils_panel").fadeToggle();
2621 $
("#vision_tab").click(function(){
2622 $
("#REFRACTION_sections").toggleClass('nodisplay');
2623 ($
("#PREFS_VA").val() =='1') ?
($
("#PREFS_VA").val('0')) : $
("#PREFS_VA").val('1');
2625 //set wearing to single vision or bifocal? Bifocal
2626 $
(".WNEAR").removeClass('nodisplay');
2627 $
("#WNEARODAXIS").addClass('nodisplay');
2628 $
("#WNEARODCYL").addClass('nodisplay');
2629 $
("#WNEARODPRISM").addClass('nodisplay');
2630 $
("#WNEAROSAXIS").addClass('nodisplay');
2631 $
("#WNEAROSCYL").addClass('nodisplay');
2632 $
("#WNEAROSPRISM").addClass('nodisplay');
2633 $
("#Single").click(function(){
2634 $
("#WNEARODAXIS").addClass('nodisplay');
2635 $
("#WNEARODCYL").addClass('nodisplay');
2636 $
("#WNEARODPRISM").addClass('nodisplay');
2637 $
("#WODADD2").addClass('nodisplay');
2638 $
("#WOSADD2").addClass('nodisplay');
2639 $
("#WNEAROSAXIS").addClass('nodisplay');
2640 $
("#WNEAROSCYL").addClass('nodisplay');
2641 $
("#WNEAROSPRISM").addClass('nodisplay');
2642 $
(".WSPACER").removeClass('nodisplay');
2644 $
("#Bifocal").click(function(){
2645 $
(".WSPACER").addClass('nodisplay');
2646 $
(".WNEAR").removeClass('nodisplay');
2647 $
(".WMid").addClass('nodisplay');
2648 $
(".WHIDECYL").removeClass('nodisplay');
2649 $
("[name=RX]").val(["1"]);
2650 $
("#WNEARODAXIS").addClass('nodisplay');
2651 $
("#WNEARODCYL").addClass('nodisplay');
2652 $
("#WNEARODPRISM").addClass('nodisplay');
2653 $
("#WNEAROSAXIS").addClass('nodisplay');
2654 $
("#WNEAROSCYL").addClass('nodisplay');
2655 $
("#WNEAROSPRISM").addClass('nodisplay');
2656 $
("#WODADD2").removeClass('nodisplay');
2657 $
("#WOSADD2").removeClass('nodisplay');
2659 $
("#Trifocal").click(function(){
2660 $
(".WSPACER").addClass('nodisplay');
2661 $
(".WNEAR").removeClass('nodisplay');
2662 $
(".WMid").removeClass('nodisplay');
2663 $
(".WHIDECYL").addClass('nodisplay');
2664 $
("[name=RX]").val(["2"]);
2665 $
("#WNEARODAXIS").addClass('nodisplay');
2666 $
("#WNEARODCYL").addClass('nodisplay');
2667 $
("#WNEARODPRISM").addClass('nodisplay');
2668 $
("#WNEAROSAXIS").addClass('nodisplay');
2669 $
("#WNEAROSCYL").addClass('nodisplay');
2670 $
("#WNEAROSPRISM").addClass('nodisplay');
2671 $
("#WODADD2").removeClass('nodisplay');
2672 $
("#WOSADD2").removeClass('nodisplay');
2674 $
("#Progressive").click(function(){
2675 $
(".WSPACER").addClass('nodisplay');
2676 $
(".WNEAR").removeClass('nodisplay');
2677 $
(".WMid").addClass('nodisplay');
2678 $
(".WHIDECYL").removeClass('nodisplay');
2679 $
("[name=RX]").val(["3"]);
2680 $
("#WNEARODAXIS").addClass('nodisplay');
2681 $
("#WNEARODCYL").addClass('nodisplay');
2682 $
("#WNEARODPRISM").addClass('nodisplay');
2683 $
("#WNEAROSAXIS").addClass('nodisplay');
2684 $
("#WNEAROSCYL").addClass('nodisplay');
2685 $
("#WNEAROSPRISM").addClass('nodisplay');
2686 $
("#WODADD2").removeClass('nodisplay');
2687 $
("#WOSADD2").removeClass('nodisplay');
2689 $
("[name=W_width_display]").click(function() {
2690 if ($
("#PREFS_W_width").val() !="1") {
2691 $
("#PREFS_W_width").val('1');
2692 //make each display W wide
2693 $
("[name=currentRX]").addClass('refraction_wide');
2694 $
("[name=W_wide]").removeClass('nodisplay');
2695 $
("[name=W_wide2]").removeClass('nodisplay');
2697 $
("#PREFS_W_width").val('0');
2698 //make each display W narrow
2699 $
("[name=currentRX]").removeClass('refraction_wide');
2700 $
("[name=W_wide]").addClass('nodisplay');
2701 $
("[name=W_wide2]").addClass('nodisplay');
2706 if ($
("#PREFS_W_width").val() == '1') {
2707 $
("[name=W_wide]").removeClass('nodisplay');
2708 $
("[name=W_wide2]").removeClass('nodisplay')
2710 $
("[name=W_wide]").addClass('nodisplay');
2711 $
("[name=W_wide2]").addClass('nodisplay');
2713 $
("#Amsler-Normal").change(function() {
2714 if ($
(this
).is(':checked')) {
2715 var number1
= document
.getElementById("AmslerOD").src
.match(/(Amsler_\d
)/)[1];
2716 document
.getElementById("AmslerOD").src
= document
.getElementById("AmslerOD").src
.replace(number1
,"Amsler_0");
2717 var number2
= document
.getElementById("AmslerOS").src
.match(/(Amsler_\d
)/)[1];
2718 document
.getElementById("AmslerOS").src
= document
.getElementById("AmslerOS").src
.replace(number2
,"Amsler_0");
2719 $
("#AMSLEROD").val("0");
2720 $
("#AMSLEROS").val("0");
2721 $
("#AmslerODvalue").text("0");
2722 $
("#AmslerOSvalue").text("0");
2723 submit_form("eye_mag");
2727 $
("#PUPIL_NORMAL").change(function() {
2728 if ($
(this
).is(':checked')) {
2729 $
("#ODPUPILSIZE1").val('3.0');
2730 $
("#OSPUPILSIZE1").val('3.0');
2731 $
("#ODPUPILSIZE2").val('2.0');
2732 $
("#OSPUPILSIZE2").val('2.0');
2733 $
("#ODPUPILREACTIVITY").val('+2');
2734 $
("#OSPUPILREACTIVITY").val('+2');
2735 $
("#ODAPD").val('0');
2736 $
("#OSAPD").val('0');
2737 submit_form("eye_mag");
2741 $
("[name$='PUPILREACTIVITY']").change(function() {
2742 var react
= $
(this
).val();
2743 if (react
.match(/^\d
{1}$
/)) {
2749 $
("[name^='EXAM']").mouseover(function(){
2750 $
(this
).toggleClass("borderShadow2").css( 'cursor', 'pointer' );
2752 $
("[name^='EXAM']").mouseout(function(){
2753 $
(this
).toggleClass("borderShadow2");
2755 $
("#AmslerOD, #AmslerOS").click(function() {
2756 if ($
('#chart_status').val() !="on") return;
2757 var number1
= this
.src
.match(/Amsler_(\d
)/)[1];
2758 var number2
= +number1 +
1;
2759 this
.src
= this
.src
.replace('Amsler_'+number1
,'Amsler_'+number2
);
2760 this
.src
= this
.src
.replace('Amsler_6','Amsler_0');
2761 $
("#Amsler-Normal").removeAttr('checked');
2762 var number3
= this
.src
.match(/Amsler_(\d
)/)[1];
2763 this
.html
= number3
;
2764 if (number3
=="6") {
2767 if ($
(this
).attr("id")=="AmslerOD") {
2768 $
("#AmslerODvalue").text(number3
);
2769 $
('#AMSLEROD').val(number3
);
2771 $
('#AMSLEROS').val(number3
);
2772 $
("#AmslerOSvalue").text(number3
);
2774 var title
= "#"+$
(this
).attr("id")+
"_tag";
2777 $
("#AmslerOD, #AmslerOS").mouseout(function() {
2778 submit_form("eye_mag");
2780 $
("[name^='ODVF'],[name^='OSVF']").click(function() {
2781 if ($
(this
).is(':checked') == true) {
2782 $
("#FieldsNormal").prop('checked', false);
2786 $
(this
).prop('checked', false);
2788 submit_form("eye_mag");
2790 $
("#FieldsNormal").click(function() {
2791 if ($
(this
).is(':checked')) {
2792 $
("#ODVF1").removeAttr('checked');
2793 $
("#ODVF2").removeAttr('checked');
2794 $
("#ODVF3").removeAttr('checked');
2795 $
("#ODVF4").removeAttr('checked');
2796 $
("#OSVF1").removeAttr('checked');
2797 $
("#OSVF2").removeAttr('checked');
2798 $
("#OSVF3").removeAttr('checked');
2799 $
("#OSVF4").removeAttr('checked');
2802 $
("[id^='EXT_prefix']").change(function() {
2803 var newValue
=$
('#EXT_prefix').val();
2804 newValue
= newValue
.replace('+', '');
2805 if (newValue
=="off") {$
(this
).val('');}
2806 if (newValue
=="clear") {
2807 if (confirm('\tSelect OK to clear all the External Exam values\t\n\t or CANCEL to continue.\t')) {
2812 $
("[name^='EXT_prefix_']").removeClass('eye_button_selected');
2813 $
("#EXT_prefix_"+ newValue
).addClass("eye_button_selected");
2816 $
("#ANTSEG_prefix").change(function() {
2817 var newValue
= $
(this
).val().replace('+', '');
2818 if ($
(this
).value
=="off") {$
(this
).val('');}
2819 if (newValue
=="clear") {
2820 if (confirm('\tSelect OK to clear all the Anterior Segment Exam values\t\n\t or CANCEL to continue.\t')) {
2822 $
(".ANTSEG").val('');
2825 $
("[name^='ANTSEG_prefix_']").removeClass('eye_button_selected');
2826 $
("#ANTSEG_prefix_"+ newValue
).addClass("eye_button_selected");
2829 $
("#RETINA_prefix").change(function() {
2830 var newValue
= $
("#RETINA_prefix").val().replace('+', '');
2831 if ($
(this
).value
=="off") {$
(this
).val('');}
2832 if (newValue
=="clear") {
2833 if (confirm('\tSelect OK to clear all the Retina Exam values\t\n\t or CANCEL to continue.\t')) {
2835 $
(".RETINA").val('');
2838 $
("[name^='RETINA_prefix_']").removeClass('eye_button_selected');
2839 $
("#RETINA_prefix_"+ newValue
).addClass("eye_button_selected");
2842 $
("#NEURO_ACT_zone").change(function() {
2843 var newValue
= $
(this
).val();
2844 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
2845 $
("#NEURO_ACT_zone_"+ newValue
).addClass("eye_button_selected");
2846 $
("#PREFS_ACT_SHOW").val(newValue
);
2848 $
("#ACT_tab_"+newValue
).trigger('click');
2850 $
("#NEURO_side").change(function() {
2851 var newValue
= $
(this
).val();
2852 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
2853 $
("#NEURO_side_"+ newValue
).addClass("eye_button_selected");
2855 $
('.ACT').focus(function() {
2856 var id
= this
.id
.match(/ACT(\d
*)/);
2857 $
('#NEURO_field').val(''+id
[1]).trigger('change');
2859 $
("#NEURO_field").change(function() {
2860 var newValue
= $
(this
).val();
2861 $
("[name^='NEURO_field']").removeClass('eye_button_selected');
2862 $
("#NEURO_field_"+ newValue
).addClass("eye_button_selected");
2863 $
('.ACT').each(function(i
){
2864 var color
= $
(this
).css('background-color');
2865 if ((color
== 'rgb(255, 255, 153)')) {// =='blue' <- IE hack
2866 $
(this
).css("background-color","red");
2869 //change to highlight field in zone entry is for
2870 var zone
= $
("#NEURO_ACT_zone").val();
2871 $
("#ACT"+newValue+zone
).css("background-color","yellow");
2873 $
("[name^='NEURO_ACT_strab']").click(function() {
2874 var newValue
= $
(this
).val();
2875 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2876 $
(this
).addClass("eye_button_selected");
2878 $
("#NEURO_value").change(function() {
2879 var newValue
= $
(this
).val();
2880 $
("[name^='NEURO_value']").removeClass('eye_button_selected');
2881 $
("#NEURO_value_"+ newValue
).addClass("eye_button_selected");
2882 if (newValue
== "ortho") {
2883 $
("#NEURO_ACT_strab").val('');
2884 $
("[name^='NEURO_ACT_strab']").removeClass('eye_button_selected');
2885 $
("#NEURO_side").val('');
2886 $
("[name^='NEURO_side']").removeClass('eye_button_selected');
2889 $
("#NEURO_RECORD").mouseover(function() {
2890 $
("#NEURO_RECORD").addClass('borderShadow2').css( 'cursor', 'pointer' );
2892 $
("#NEURO_RECORD").mouseout(function() {
2893 $
("#NEURO_RECORD").removeClass('borderShadow2');
2895 $
("#NEURO_RECORD").mousedown(function() {
2896 $
("#NEURO_RECORD").removeClass('borderShadow2');
2897 $
(this
).toggleClass('button_over');
2899 $
("#NEURO_RECORD").mouseup(function() {
2900 $
("#NEURO_RECORD").removeClass('borderShadow2');
2901 $
(this
).toggleClass('button_over');
2903 $
("#NEURO_RECORD").click(function() {
2904 //find out the field we are updating
2905 var number
= $
("#NEURO_field").val();
2906 var zone
= $
("#NEURO_ACT_zone").val();
2907 var strab
= $
("#NEURO_value").val() +
' '+ $
("#NEURO_side").val() + $
("#NEURO_ACT_strab").val();
2909 $
("#ACT"+number+zone
).val(strab
).css("background-color","#F0F8FF");
2914 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseover(function(){
2915 $
(this
).addClass("borderShadow2");
2917 $
("#LayerMood,#LayerVision, #LayerTension, #LayerMotility, #LayerAmsler, #LayerFields, #LayerPupils,#dim_pupils_panel,#PRIORS_ALL_left_text").mouseout(function(){
2918 $
(this
).removeClass("borderShadow2");
2920 $
("[id$='_lightswitch']").click(function() {
2921 var section
= "#"+this
.id
.match(/(.*)_lightswitch$
/)[1];
2922 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
2923 var elem
= document
.getElementById("PREFS_"+section2
);
2924 $
("#PREFS_VA").val('0');
2925 if (section2
!= "IOP")$
("#REFRACTION_sections").removeClass('nodisplay');
2926 if (elem
.value
== "0" || elem
.value
=='') {
2928 if (section2
=="ADDITIONAL") {
2929 $
("#LayerVision_ADDITIONAL").removeClass('nodisplay');
2931 if (section2
=="IOP") {
2932 $
("#LayerVision_IOP").removeClass('nodisplay');
2935 $
(section
).removeClass('nodisplay');
2936 $
(this
).addClass("buttonRefraction_selected");
2939 $
(section
).addClass('nodisplay');
2940 if (section2
=="VAX") {
2941 $
("#LayerVision_ADDITIONAL_VISION").addClass('nodisplay');
2943 if (section2
=="IOP") {
2944 $
("#LayerVision_IOP").addClass('nodisplay');
2946 $
(this
).removeClass("buttonRefraction_selected");
2948 $
(this
).css( 'cursor', 'pointer' );
2952 $
('[id$=_lightswitch]').mouseover(function() {
2953 $
(this
).addClass('buttonRefraction_selected').css( 'cursor', 'pointer' );
2955 var section
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
2956 if (section
== 'IOP') {
2957 $
("#LayerTension").addClass("borderShadow2");
2959 $
("#LayerVision").addClass("borderShadow2");
2962 $
('[id$=_lightswitch]').mouseout(function() {
2963 var section2
= this
.id
.match(/(.*)_(.*)_lightswitch$
/)[2];
2964 var elem
= document
.getElementById("PREFS_"+section2
);
2966 if (elem
.value
!= "1") {
2967 $
(this
).removeClass('buttonRefraction_selected');
2969 $
(this
).addClass('buttonRefraction_selected');
2972 // let users enter "=" sign for "+" to cut down on keyboard movements (keyCode 61)
2973 // "+" == "shift" + "=" ==> now "=" == "+", "j" ==> "J" for Jaeger acuity (keyCode 74)
2974 // "-" is still == "-"
2975 $
("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
) {
2976 if (e
.keyCode
=='61' || e
.keyCode
=='74') {
2977 now
= $
(this
).val();
2978 now
= now
.replace(/=/g
,"+").replace(/^j
/g
,"J");
2982 //useful to make all VA fields stay in sync
2983 $
("input[name$='VA']").on('change',function() {
2984 var hereValue
= $
(this
).val();
2985 var newValue
= $
(this
).attr('name').replace('VA', 'VA_copy');
2986 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
2987 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");;
2989 $
("input[class^='jaeger'],input[name$='VA_1']").on('change',function() {
2990 var hereValue
= $
(this
).val();
2991 hereValue
= hereValue
.replace(/=$
/g
,"+").replace(/^j
/g
,"J");
2992 $
(this
).val(hereValue
);
2993 if (this
.name
.match(/_1$
/)) {
2994 var newValue
= $
(this
).attr('name').replace('VA_1', 'VA_1_copy');
2995 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
2996 $
("#" + newValue +
"_brd").val(hereValue
).css("background-color","#F0F8FF");
3000 $
("input[name$='_copy']").blur(function() {
3001 var hereValue
= $
(this
).val();
3002 var newValue
= $
(this
).attr('name').replace('_copy', '');
3003 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3004 $
("#" + newValue +
"_copy_brd").val(hereValue
).css("background-color","#F0F8FF");;
3006 $
("input[name$='_copy_brd']").change(function() {
3007 var hereValue
= $
(this
).val();
3008 var newValue
= $
(this
).attr('name').replace('_copy_brd', '');
3009 $
("#" + newValue
).val(hereValue
).css("background-color","#F0F8FF");;
3010 $
("#" + newValue +
"_copy").val(hereValue
).css("background-color","#F0F8FF");;
3012 $
("[name^='more_']").mouseout(function() {
3013 $
(this
).toggleClass('buttonRefraction_selected').toggleClass('underline');
3015 $
("[name^='more_']").click(function() {
3016 $
("#Visions_A").toggleClass('nodisplay');
3017 $
("#Visions_B").toggleClass('nodisplay');
3019 $
("#EXAM_defaults").click(function() {
3021 // This query is specific to the provider.
3022 $query = "select seq from list_options where option_id=?";
3023 $result = sqlStatement($query, array("Eye_defaults_$providerID"));
3025 $list = sqlFetchArray($result);
3026 $SEQ = $list['seq'];
3028 // If there is no list for this provider, we create it here.
3029 // Instead of the below code, we should be copying the Eye_Defaults_for_GENERAL
3030 // to Eye_defaults_$providerID
3031 // This list is part of the idea to create a way to add Eye_defaults_$providerID specific to the
3032 // subspecialty of the doctor. ie. Eye_defaults_for_GENERAL (the only one that exists today)
3033 // or Eye_defaults_for_CORNEA, RETINA, NEURO, PLASTICS, REFRACTIVE, PEDS, UVEITIS
3034 // Also, each field should be "display:none" if desired, via another user specific list.
3035 // This would be another list. Let's see if the public likes the form itself before
3036 // developing these features...
3037 $query = "SELECT max(seq) as maxseq FROM list_options WHERE list_id= 'lists'";
3038 $pres = sqlStatement($query);
3039 $maxseq = sqlFetchArray($pres);
3041 $seq=$maxseq['maxseq'];
3042 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`) VALUES
3043 ('lists', ?, ?, ?, '1', '0', '', '', '')";
3044 sqlStatement($query, array("Eye_defaults_$providerID","Eye Exam Defaults $providerNAME ",$seq));
3045 $query = "INSERT INTO `list_options` (`list_id`, `option_id`, `title`,`notes`,`seq`) VALUES
3046 ('Eye_defaults_".$providerID."','RUL','normal lids and lashes','EXT','10'),
3047 ('Eye_defaults_".$providerID."','LUL','normal lids and lashes','EXT','20'),
3048 ('Eye_defaults_".$providerID."','RLL','good tone','EXT','30'),
3049 ('Eye_defaults_".$providerID."','LLL','good tone','EXT','40'),
3050 ('Eye_defaults_".$providerID."','RBROW','no brow ptosis','EXT','50'),
3051 ('Eye_defaults_".$providerID."','LBROW','no brow ptosis','EXT','60'),
3052 ('Eye_defaults_".$providerID."','RMCT','no masses','EXT','70'),
3053 ('Eye_defaults_".$providerID."','LMCT','no masses','EXT','80'),
3054 ('Eye_defaults_".$providerID."','RADNEXA','normal lacrimal gland and orbit','EXT','90'),
3055 ('Eye_defaults_".$providerID."','LADNEXA','normal lacrimal gland and orbit','EXT','100'),
3056 ('Eye_defaults_".$providerID."','RMRD','+3','EXT','110'),
3057 ('Eye_defaults_".$providerID."','LMRD','+3','EXT','120'),
3058 ('Eye_defaults_".$providerID."','RLF','17','EXT','130'),
3059 ('Eye_defaults_".$providerID."','LLF','17','EXT','140'),
3060 ('Eye_defaults_".$providerID."','OSCONJ','quiet','ANTSEG','150'),
3061 ('Eye_defaults_".$providerID."','ODCONJ','quiet','ANTSEG','160'),
3062 ('Eye_defaults_".$providerID."','ODCORNEA','clear','ANTSEG','170'),
3063 ('Eye_defaults_".$providerID."','OSCORNEA','clear','ANTSEG','180'),
3064 ('Eye_defaults_".$providerID."','ODAC','deep and quiet','ANTSEG','190'),
3065 ('Eye_defaults_".$providerID."','OSAC','deep and quiet','ANTSEG','200'),
3066 ('Eye_defaults_".$providerID."','ODLENS','clear','ANTSEG','210'),
3067 ('Eye_defaults_".$providerID."','OSLENS','clear','ANTSEG','220'),
3068 ('Eye_defaults_".$providerID."','ODIRIS','round','ANTSEG','230'),
3069 ('Eye_defaults_".$providerID."','OSIRIS','round','ANTSEG','240'),
3070 ('Eye_defaults_".$providerID."','ODPUPILSIZE1','3','NEURO','250'),
3071 ('Eye_defaults_".$providerID."','ODPUPILSIZE2','2','NEURO','260'),
3072 ('Eye_defaults_".$providerID."','ODPUPILREACTIVITY','+2','NEURO','270'),
3073 ('Eye_defaults_".$providerID."','ODAPD','0','NEURO','280'),
3074 ('Eye_defaults_".$providerID."','OSPUPILSIZE1','3','NEURO','290'),
3075 ('Eye_defaults_".$providerID."','OSPUPILSIZE2','2','NEURO','300'),
3076 ('Eye_defaults_".$providerID."','OSPUPILREACTIVITY','+2','NEURO','310'),
3077 ('Eye_defaults_".$providerID."','OSAPD','0','NEURO','320'),
3078 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION1','0','NEURO','330'),
3079 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION2','0','NEURO','340'),
3080 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION3','0','NEURO','350'),
3081 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION4','0','NEURO','360'),
3082 ('Eye_defaults_".$providerID."','ODVFCONFRONTATION5','0','NEURO','370'),
3083 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION1','0','NEURO','380'),
3084 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION2','0','NEURO','390'),
3085 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION3','0','NEURO','400'),
3086 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION4','0','NEURO','410'),
3087 ('Eye_defaults_".$providerID."','OSVFCONFRONTATION5','0','NEURO','420'),
3088 ('Eye_defaults_".$providerID."','ODDISC','pink','RETINA','430'),
3089 ('Eye_defaults_".$providerID."','OSDISC','pink','RETINA','440'),
3090 ('Eye_defaults_".$providerID."','ODCUP','0.3','RETINA','450'),
3091 ('Eye_defaults_".$providerID."','OSCUP','0.3','RETINA','460'),
3092 ('Eye_defaults_".$providerID."','ODMACULA','flat','RETINA','470'),
3093 ('Eye_defaults_".$providerID."','OSMACULA','flat','RETINA','480'),
3094 ('Eye_defaults_".$providerID."','ODVESSELS','2:3','RETINA','490'),
3095 ('Eye_defaults_".$providerID."','OSVESSELS','2:3','RETINA','500'),
3096 ('Eye_defaults_".$providerID."','ODPERIPH','flat','RETINA','510'),
3097 ('Eye_defaults_".$providerID."','OSPERIPH','flat','RETINA','520')";
3098 sqlStatement($query);
3101 $query = "select * from list_options where list_id =? and activity='1' order by seq";
3103 $DEFAULT_data =sqlStatement($query, array("Eye_defaults_$providerID"));
3104 while ($row = sqlFetchArray($DEFAULT_data)) {
3105 //$row['notes'] is the clinical zone (EXT,ANTSEG,RETINA,NEURO)
3106 //$row['option_id'] is the field name
3107 //$row['title'] is the default value to use for this provider
3108 $
{$row[notes
]}[$row[option_id
]] = $row[title
]; //This builds each clinical section into its own array (used below)
3109 echo '$("#'.$row['option_id'].'").val("'.$row['title'].'").css("background-color","beige");
3113 submit_form("eye_mag");
3116 $
("#EXT_defaults").click(function() {
3118 foreach ($EXT as $item => $value) {
3119 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3123 submit_form("eye_mag");
3126 $
("#ANTSEG_defaults").click(function() {
3128 foreach ($ANTSEG as $item => $value) {
3129 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3133 submit_form("eye_mag");
3135 $
("#RETINA_defaults").click(function() {
3137 foreach ($RETINA as $item => $value) {
3138 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3142 submit_form("eye_mag");
3144 $
("#NEURO_defaults").click(function() {
3146 foreach ($NEURO as $item => $value) {
3147 echo '$("#'.$item.'").val("'.$value.'").css("background-color","beige");
3151 submit_form("eye_mag");
3155 $
("#MOTILITYNORMAL").click(function() {
3156 $
("#MOTILITY_RS").val('0');
3157 $
("#MOTILITY_RI").val('0');
3158 $
("#MOTILITY_RR").val('0');
3159 $
("#MOTILITY_RL").val('0');
3160 $
("#MOTILITY_LS").val('0');
3161 $
("#MOTILITY_LI").val('0');
3162 $
("#MOTILITY_LR").val('0');
3163 $
("#MOTILITY_LL").val('0');
3165 $
("#MOTILITY_RRSO").val('0');
3166 $
("#MOTILITY_RRIO").val('0');
3167 $
("#MOTILITY_RLSO").val('0');
3168 $
("#MOTILITY_RLIO").val('0');
3169 $
("#MOTILITY_LRSO").val('0');
3170 $
("#MOTILITY_LRIO").val('0');
3171 $
("#MOTILITY_LLSO").val('0');
3172 $
("#MOTILITY_LLIO").val('0');
3174 for (index
= '0'; index
< 5; ++index
) {
3175 $
("#MOTILITY_RS_"+index
).html('');
3176 $
("#MOTILITY_RI_"+index
).html('');
3177 $
("#MOTILITY_RR_"+index
).html('');
3178 $
("#MOTILITY_RL_"+index
).html('');
3179 $
("#MOTILITY_LS_"+index
).html('');
3180 $
("#MOTILITY_LI_"+index
).html('');
3181 $
("#MOTILITY_LR_"+index
).html('');
3182 $
("#MOTILITY_LL_"+index
).html('');
3184 $
("#MOTILITY_RRSO_"+index
).html('');
3185 $
("#MOTILITY_RRIO_"+index
).html('');
3186 $
("#MOTILITY_RLSO_"+index
).html('');
3187 $
("#MOTILITY_RLIO_"+index
).html('');
3188 $
("#MOTILITY_LRSO_"+index
).html('');
3189 $
("#MOTILITY_LRIO_"+index
).html('');
3190 $
("#MOTILITY_LLSO_"+index
).html('');
3191 $
("#MOTILITY_LLIO_"+index
).html('');
3193 submit_form('eye_mag');
3196 $
("[name^='MOTILITY_']").click(function() {
3197 $
("#MOTILITYNORMAL").removeAttr('checked');
3199 if (this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/)) {
3200 var zone
= this
.id
.match(/(MOTILITY_([A
-Z
]{4}))_(.)/);
3202 var valued
= isNaN($
("#"+zone
[1]).val());
3203 if ((zone
[2] =='RLSO')||
(zone
[2] =='LLSO')||
(zone
[2] =='RRIO')||
(zone
[2] =='LRIO')) {
3204 //find or make a hash tage for "\"
3205 var hash_tag
= '<i class="fa fa-minus"></i>';
3207 //find or make a hash tage for "/"
3208 var hash_tag
= '<i class="fa fa-minus"></i>';
3211 var zone
= this
.id
.match(/(MOTILITY_
..)_(.)/);
3212 var section
= this
.id
.match(/MOTILITY_(.)(.)_
/);
3213 var section2
= section
[2];
3214 var Eye
= section
[1];
3215 var SupInf
= section2
.search(/S|I
/);
3216 var RorLside
= section2
.search(/R|L
/);
3219 if (RorLside
=='0') {
3220 var hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
3222 var hash_tag
= '<i class="fa fa-minus"></i>';
3225 if (valued
!= true && $
("#"+zone
[1]).val() <'4') {
3226 valued
=$
("#"+zone
[1]).val();
3230 $
("#"+zone
[1]).val('0');
3233 $
("#"+zone
[1]).val(valued
);
3235 for (index
= '0'; index
< 5; ++index
) {
3236 $
("#"+zone
[1]+
"_"+index
).html('');
3239 for (index
=1; index
< (valued+
1); ++index
) {
3240 $
("#"+zone
[1]+
"_"+index
).html(hash_tag
);
3247 $
("[name^='Close_']").click(function() {
3248 var section
= this
.id
.match(/Close_(.*)$
/)[1];
3249 if (this
.id
.match(/Close_W_(.*)$
/) != null) {
3250 var W_section
= this
.id
.match(/Close_W_(.*)$
/)[1];
3251 if (W_section
> '1') {
3252 $
('#LayerVision_W_'+W_section
).addClass('nodisplay');
3253 $
('[name$=SPH_'+W_section+
']').val('');
3254 $
('[name$=CYL_'+W_section+
']').val('');
3255 $
('[name$=AXIS_'+W_section+
']').val('');
3256 $
('[name$=ADD_'+W_section+
']').val('');
3257 $
('[name$=PRISM_'+W_section+
']').val('');
3258 $
('[name$=VA_'+W_section+
']').val('');
3259 $
('#RX_TYPE_'+W_section
).val('');
3260 $
('#Add_Glasses').removeClass('nodisplay');
3261 $
('#W_'+W_section
).val('');
3264 $
("#LayerVision_W_lightswitch").click();
3266 } else if (section
=="ACTMAIN") {
3267 $
("#ACTTRIGGER").trigger( "click" );
3269 $
("#LayerVision_"+section+
"_lightswitch").click();
3274 $
("#EXAM_DRAW, #BUTTON_DRAW_menu, #PANEL_DRAW").click(function() {
3275 if ($
("#PREFS_CLINICAL").value
!='0') {
3277 $
("#PREFS_CLINICAL").val('0');
3280 if ($
("#PREFS_EXAM").val() != 'DRAW') {
3281 $
("#PREFS_EXAM").val('DRAW');
3282 $
("#EXAM_QP").removeClass('button_selected');
3283 $
("#EXAM_DRAW").addClass('button_selected');
3284 $
("#EXAM_TEXT").removeClass('button_selected');
3289 $
("#EXAM_QP,#PANEL_QP").click(function() {
3290 if ($
("#PREFS_CLINICAL").value
!='0') {
3291 $
("#PREFS_CLINICAL").val('0');
3294 if ($
("#PREFS_EXAM").value
!= 'QP') {
3295 $
("#PREFS_EXAM").val('QP');
3296 $
("#EXAM_QP").addClass('button_selected');
3297 $
("#EXAM_DRAW").removeClass('button_selected');
3298 $
("#EXAM_TEXT").removeClass('button_selected');
3302 scrollTo("EXT_left");
3305 $
("#EXAM_TEXT,#PANEL_TEXT").click(function() {
3307 // also hide QP, DRAWs, and PRIORS
3313 for (index
= '0'; index
< zones
.length
; ++index
) {
3314 $
("#PREFS_"+zones
[index
]+
"_RIGHT").val(0);
3318 $
("#EXAM_DRAW").removeClass('button_selected');
3319 $
("#EXAM_QP").removeClass('button_selected');
3320 $
("#EXAM_TEXT").addClass('button_selected');
3321 scrollTo("EXT_left");
3323 $
("[id^='BUTTON_TEXT_']").click(function() {
3324 var zone
= this
.id
.match(/BUTTON_TEXT_(.*)/)[1];
3325 if (zone
!= "menu") {
3326 $
("#"+zone+
"_right").addClass('nodisplay');
3327 $
("#"+zone+
"_left").removeClass('display');
3328 $
("#"+zone+
"_left_text").removeClass('display');
3329 $
("#PREFS_"+zone+
"_RIGHT").val(0);
3333 scrollTo("EXT_left");
3335 $
("[id^='BUTTON_TEXTD_']").click(function() {
3336 var zone
= this
.id
.match(/BUTTON_TEXTD_(.*)/)[1];
3337 if (zone
!= "menu") {
3338 if ((zone
=="PMH") ||
(zone
== "HPI")) {
3339 $
("#PMH_right").addClass('nodisplay');
3340 $
("#PREFS_PMH_RIGHT").val(1);
3341 $
("#HPI_right").addClass('nodisplay');
3342 $
("#PREFS_HPI_RIGHT").val(1);
3343 var reset
= $
("#HPI_1").height();
3344 $
("#PMH_1").height(reset
);
3345 $
("#PMH_left").height(reset
-40);
3346 $
("#LayerTechnical_sections_1").css("clear","both");
3348 $
("#"+zone+
"_right").addClass('nodisplay');
3349 $
("#PREFS_"+zone+
"_RIGHT").val(1);
3351 scrollTo(zone+
"_left");
3357 $
("#EXAM_TEXT").addClass('button_selected');
3358 if (($
("#PREFS_CLINICAL").val() !='1')) {
3359 var actionQ
= "#EXAM_"+$
("#PREFS_EXAM").val();
3360 $
(actionQ
).trigger('click');
3362 $
("#EXAM_TEXT").addClass('button_selected');
3364 if ($
("#ANTSEG_prefix").val() > '') {
3365 $
("#ANTSEG_prefix_"+$
("#ANTSEG_prefix").val()).addClass('button_selected');
3367 $
("#ANTSEG_prefix").val('off').trigger('change');
3369 $
("[name^='ACT_tab_']").mouseover(function() {
3370 $
(this
).toggleClass('underline').css( 'cursor', 'pointer' );
3372 $
("[name^='ACT_tab_']").mouseout(function() {
3373 $
(this
).toggleClass('underline');
3376 $
("[name^='ACT_tab_']").click(function() {
3377 var section
= this
.id
.match(/ACT_tab_(.*)/)[1];
3378 $
("[name^='ACT_']").addClass('nodisplay');
3379 $
("[name^='ACT_tab_']").removeClass('nodisplay').removeClass('ACT_selected').addClass('ACT_deselected');
3380 $
("#ACT_tab_" + section
).addClass('ACT_selected').removeClass('ACT_deselected');
3381 $
("#ACT_" + section
).removeClass('nodisplay');
3382 $
("#PREFS_ACT_SHOW").val(section
);
3383 //selection correct QP zone
3384 $
("[name^='NEURO_ACT_zone']").removeClass('eye_button_selected');
3385 $
("#NEURO_ACT_zone_"+ section
).addClass("eye_button_selected");
3386 $
("#NEURO_ACT_zone").val(section
);
3389 $
("#ACTTRIGGER").mouseout(function() {
3390 $
("#ACTTRIGGER").toggleClass('buttonRefraction_selected').toggleClass('underline');
3392 if ($
("#PREFS_ACT_VIEW").val() == '1') {
3393 $
("#ACTMAIN").toggleClass('nodisplay');
3394 $
("#NPCNPA").toggleClass('nodisplay');
3395 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3396 $
("#ACTTRIGGER").toggleClass('underline');
3397 var show
= $
("#PREFS_ACT_SHOW").val();
3398 $
("#ACT_tab_"+show
).trigger('click');
3400 $
("#ACTTRIGGER").click(function() {
3401 $
("#ACTMAIN").toggleClass('nodisplay').toggleClass('ACT_TEXT');
3402 $
("#NPCNPA").toggleClass('nodisplay');
3403 $
("#ACTNORMAL_CHECK").toggleClass('nodisplay');
3404 $
("#ACTTRIGGER").toggleClass('underline');
3405 if ($
("#PREFS_ACT_VIEW").val()=='1') {
3406 $
("#PREFS_ACT_VIEW").val('0');
3408 $
("#PREFS_ACT_VIEW").val('1');
3410 var show
= $
("#PREFS_ACT_SHOW").val();
3411 $
("#ACT_tab_"+show
).trigger('click');
3414 $
("#NEURO_COLOR").click(function() {
3415 $
("#ODCOLOR").val("11/11");
3416 $
("#OSCOLOR").val("11/11");
3417 submit_form("eye_mag");
3420 $
("#NEURO_COINS").click(function() {
3421 $
("#ODCOINS").val("1.00");
3422 //leave currency symbol out unless it is an openEMR defined option
3423 $
("#OSCOINS").val("1.00");
3424 submit_form("eye_mag");
3427 $
("#NEURO_REDDESAT").click(function() {
3428 $
("#ODREDDESAT").val("100");
3429 $
("#OSREDDESAT").val("100");
3430 submit_form("eye_mag");
3433 $
("[id^='myCanvas_']").mouseout(function() {
3434 var zone
= this
.id
.match(/myCanvas_(.*)/)[1];
3435 submit_canvas(zone
);
3437 $
("[id^='Undo_']").click(function() {
3438 var zone
= this
.id
.match(/Undo_Canvas_(.*)/)[1];
3439 submit_canvas(zone
);
3441 $
("[id^='Redo_']").click(function() {
3442 var zone
= this
.id
.match(/Redo_Canvas_(.*)/)[1];
3443 submit_canvas(zone
);
3445 $
("[id^='Clear_']").click(function() {
3446 var zone
= this
.id
.match(/Clear_Canvas_(.*)/)[1];
3447 submit_canvas(zone
);
3449 $
("[id^='Blank_']").click(function() {
3451 var zone
= this
.id
.match(/Blank_Canvas_(.*)/)[1];
3452 $
("#url_"+zone
).val("../../forms/eye_mag/images/BLANK_BASE.png");
3453 //canvas.renderAll();
3457 $
("#COPY_SECTION").change(function() {
3458 var start
= $
("#COPY_SECTION").val();
3459 if (start
=='') return;
3460 var value
= start
.match(/(\w
*)-(\w
*)/);
3461 var zone
= value
[1];
3462 var copy_from
= value
[2];
3463 if (zone
=="READONLY") copy_from
= $
("#form_id").val();
3464 var count_changes
='0';
3470 copy_to
: $
("#form_id").val(),
3471 copy_from
: copy_from
,
3472 pid
: $
("#pid").val()
3474 if (zone
=="READONLY") {
3475 //we are going to update the whole form
3476 //Imagine you are watching on your browser while the tech adds stuff in another room on another computer.
3477 //We are not ready to actively chart, just looking to see how far along our staff is...
3478 //or maybe just looking ahead to see who's next in the next room?
3479 //Either way, we are looking at a record that at present will be disabled/we cannot change...
3480 // yet it is updating every 10 seconds if another user is making changes.
3482 // READONLY does not show IMPPLAN changes!!!!
3484 //here we are retrieving an old record to copy forward to today's active chart.
3485 data
= $
("#"+zone+
"_left_text").serialize() +
"&" + $
.param(data
);
3487 top
.restoreSession();
3491 url
: "../../forms/eye_mag/save.php",
3493 success
: function(result
) {
3494 //we have to process impplan differently
3495 if (zone
=='IMPPLAN') {
3496 //we get a json result.IMPPLAN back from the prior visit
3497 //we need to add that to the current list? Replace for now.
3498 build_IMPPLAN(result
.IMPPLAN
);
3499 store_IMPPLAN(result
.IMPPLAN
);
3500 // need to make the Plan areas purple?
3502 $
.map(result
, function(valhere
, keyhere
) {
3503 if ($
("#"+keyhere
).val() != valhere
) {
3504 $
("#"+keyhere
).val(valhere
).css("background-color","#CCF");
3505 } else if (keyhere
.match(/MOTILITY_
/)) {
3506 // Copy forward ductions and versions visually
3507 // Make each blank, and rebuild them
3508 $
("[name='"+keyhere+
"_1']").html('');
3509 $
("[name='"+keyhere+
"_2']").html('');
3510 $
("[name='"+keyhere+
"_3']").html('');
3511 $
("[name='"+keyhere+
"_4']").html('');
3512 if (keyhere
.match(/(_RS|_LS|_RI|_LI|_RRSO|_RRIO|_RLSO|_RLIO|_LRSO|_LRIO|_LLSO|_LLIO
)/)) {
3513 // Show a horizontal (minus) tag. When "/" and "\" fa-icons are available will need to change.
3514 // Maybe just use small font "/" and "\" directly.
3515 hash_tag
= '<i class="fa fa-minus"></i>';
3516 } else { //show vertical tag
3517 hash_tag
= '<i class="fa fa-minus rotate-left"></i>';
3519 for (index
=1; index
<= valhere
; ++index
) {
3520 $
("#"+keyhere+
"_"+index
).html(hash_tag
);
3522 } else if (keyhere
.match(/^
(ODVF|OSVF
)\d$
/)) {
3523 if (valhere
=='1') {
3524 $
("#FieldsNormal").prop('checked', false);
3525 $
("#"+keyhere
).prop('checked', true);
3526 $
("#"+keyhere
).val('1');
3528 $
("#"+keyhere
).val('0');
3529 $
("#"+keyhere
).prop('checked', false);
3531 } else if (keyhere
.match(/AMSLERO(.)/)) {
3532 var sidehere
= keyhere
.match(/AMSLERO(.)/);
3533 if (valhere
< '1') valhere
='0';
3534 $
("#"+keyhere
).val(valhere
);
3535 var srcvalue
="AmslerO"+sidehere
[1];
3536 document
.getElementById(srcvalue
).src
= document
.getElementById(srcvalue
).src
.replace(/\_\d
/g
,"_"+valhere
);
3537 $
("#AmslerO"+sidehere
[1]+
"value").text(valhere
);
3538 } else if (keyhere
.match(/VA$
/)) {
3539 $
("#"+keyhere+
"_copy").val(valhere
).css("background-color","#F0F8FF");;
3540 $
("#"+keyhere+
"_copy_brd").val(valhere
).css("background-color","#F0F8FF");;
3543 if (zone
!= "READONLY") { submit_form("eye_mag"); }
3547 $
("[id^='BUTTON_DRAW_']").click(function() {
3548 var zone
=this
.id
.match(/BUTTON_DRAW_(.*)$
/)[1];
3551 if ($
('#PREFS_'+zone+
'_RIGHT').val() =="DRAW") {
3552 $
('#BUTTON_TEXTD_'+zone
).trigger("click");//closes draw
3553 //maybe this should revert to last right panel state (qp,text)
3556 $
("#"+zone+
"_1").removeClass('nodisplay');
3557 $
("#"+zone+
"_right").addClass('canvas').removeClass('nodisplay');
3558 $
("#QP_"+zone
).addClass('nodisplay');
3559 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
3560 $
("#Draw_"+zone
).removeClass('nodisplay');
3561 $
("#PREFS_"+zone+
"_RIGHT").val('DRAW');
3562 scrollTo(zone+
"_left");
3567 $
("[id^='BUTTON_QP_']").click(function() {
3568 var zone
= this
.id
.match(/BUTTON_QP_(.*)$
/)[1].replace(/_\d*/
,'');
3569 if (zone
=='IMPPLAN2') {
3570 $
('#IMP_start_acc').slideDown();
3573 if (($
("#PREFS_"+zone+
"_RIGHT").val() =='QP')&&(zone
!='IMPPLAN')) {
3574 $
('#BUTTON_TEXTD_'+zone
).trigger("click");
3577 $
("#PRIORS_"+zone+
"_left_text").addClass('nodisplay');
3578 $
("#Draw_"+zone
).addClass('nodisplay');
3579 show_QP_section(zone
);
3580 $
("#PREFS_"+zone+
"_RIGHT").val('QP');
3581 if ((zone
!= 'PMH')&&(zone
!= 'HPI')) {
3583 if (zone
== 'PMH') {
3584 if($
('#HPI_right').css('display') == 'none') {
3585 $
("#PRIORS_HPI_left_text").addClass('nodisplay');
3586 $
("#Draw_HPI").addClass('nodisplay');
3587 show_QP_section('HPI');
3588 $
("#PREFS_HPI_RIGHT").val('QP');
3589 //$("html,body").animate({scrollTop: '400'}, "slow");
3591 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
3592 $
('#PMH_left').height($
('#PMH_right').height());
3593 $
('#PMH_1').height($
('#PMH_right').height()+
20);
3594 } else { $
('#PMH_1').height($
('#HPI_1').height()); }
3596 else if (zone
== 'HPI') {
3597 if($
('#PMH_right').css('display') == 'none') {
3598 $
("#PRIORS_PMH_left_text").addClass('nodisplay');
3599 $
("#Draw_PMH").addClass('nodisplay');
3600 show_QP_section('PMH','1');
3601 $
("#PREFS_PMH_RIGHT").val('QP');
3603 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
3604 $
('#PMH_left').height($
('#PMH_right').height());
3605 } else { $
('#PMH_1').height($
('#HPI_1').height()); }
3606 } else if (zone
== 'menu') {
3608 } else if (zone
== 'IMPPLAN') {
3609 show_QP_section('IMPPLAN');
3616 // set default to ccDist. Change as desired.
3617 $
('#NEURO_ACT_zone').val('CCDIST').trigger('change');
3618 if ($
("#RXStart").val() =="2") {
3619 $
("#Trifocal").trigger('click');
3621 $
("[id$='_loading']").addClass('nodisplay');
3622 $
("[id$='_sections']").removeClass('nodisplay');
3624 if ($
('#PMH_right').height() > $
('#PMH_left').height()) {
3625 $
('#PMH_left').height($
('#PMH_right').height());
3626 } else { $
('#PMH_1').height($
('#HPI_1').height()); }
3628 $
('#left-panel').css("right","0px");
3629 $
('#EXAM_KB').css({position
: 'fixed', top
: '29px'});
3630 $
('#EXAM_KB').css('display', 'block');
3631 $
('#EXAM_KB').draggable();
3632 $
('#IMP').droppable({ drop
: dragto_IMPPLAN
} );
3633 $
('#IMPPLAN_zone').droppable({ drop
: dragto_IMPPLAN_zone
} );
3634 $
('#IMPPLAN_text').droppable({ drop
: dragto_IMPPLAN_zone
} );
3636 $
('[id^="PLANS"]').draggable( { cursor
: 'move', revert
: true });
3637 $
('[id^="PLAN_"]').height( $
(this
).scrollHeight
);
3639 /* Sorting of diagnoses in IMP/PLAN right panel builds IMP_order[] array.
3640 Foreach index => value in IMP_order[order,PMSFH[type][i]]:
3641 retrieve PMSFH[type][value] and build the IMPRESSION/PLAN area
3642 openEMR ICD-10 seems to have newlines in codetext? strip them with replace.
3643 All the ISSUE_TYPES and their fields are available in obj.PMSFH:
3644 'title' => $disptitle,
3645 'status' => $statusCompute,
3646 'enddate' => $row['enddate'],
3647 'reaction' => $row['reaction'],
3648 'referredby' => $row['referredby'],
3649 'extrainfo' => $row['extrainfo'],
3650 'diagnosis' => $row['diagnosis'],
3652 'codedesc' => $codedesc,
3653 'codetext' => $codetext,
3654 'codetype' => $codetype,
3655 'comments' => $row['comments'],
3656 'rowid' => $row['id'],
3657 'row_type' => $row['type']
3658 eg. obj.IMPPLAN_items[index] = code: obj.PMSFH['POH'][value]['code'],
3659 codedesc: obj.PMSFH['POH'][value]['codedesc'],
3660 codetype: obj.PMSFH['POH'][value]['codetype']
3663 $
('#make_new_IMP').click(function() {
3665 if (IMP_order
.length
==0) rebuild_IMP($
( "#build_DX_list" ));
3666 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];
3667 $
.each(IMP_order
, function( index
, value
) {
3668 issue
= value
.match(/(.*)_(.*)/);
3669 if (issue
[1] == "CLINICAL") {
3670 if (!$
('#inc_PE').is(':checked')) { return; }
3673 var the_codedesc
='';
3674 var the_codetext
='';
3676 for (i
=0;i
< obj
.Clinical
[issue
[2]].length
; i++
) {
3678 the_code
= obj
.Clinical
[issue
[2]][i
]['code'];
3679 } else if (i
< obj
.Clinical
[issue
[2]].length
) {
3680 the_code +
= ', '+ obj
.Clinical
[issue
[2]][i
]['code'];
3682 the_codedesc +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
3683 the_codetext +
= obj
.Clinical
[issue
[2]][i
]['codetext'] +
"\r";
3684 the_plan +
= obj
.Clinical
[issue
[2]][i
]['codedesc'] +
"\r";
3686 obj
.IMPPLAN_items
.push({
3687 title
:obj
.Clinical
[issue
[2]][0]['title'],
3689 codetype
: obj
.Clinical
[issue
[2]][0]['codetype'],
3690 codedesc
: the_codedesc
,
3691 codetext
: the_codetext
,
3693 PMSFH_link
: obj
.Clinical
[issue
[2]][0]['PMSFH_link']
3696 if (issue
[1] == "PMH") {
3697 if (!$
('#inc_PMH').is(':checked')) { return; }
3698 } else if (issue
[1] == "POH"){
3699 if (!$
('#inc_POH').is(':checked')) { return; }
3700 } else if (issue
[1] == "POS"){
3701 if (!$
('#inc_POH').is(':checked')) { return; }
3703 obj
.IMPPLAN_items
.push({
3704 title
: obj
.PMSFH
[issue
[1]][issue
[2]]['title'],
3705 code
: obj
.PMSFH
[issue
[1]][issue
[2]]['code'],
3706 codetype
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetype'],
3707 codedesc
: obj
.PMSFH
[issue
[1]][issue
[2]]['codedesc'],
3708 codetext
: obj
.PMSFH
[issue
[1]][issue
[2]]['codetext'].replace(/(\r\n|\n|\r
)/gm
,""),
3709 plan
: obj
.PMSFH
[issue
[1]][issue
[2]]['comments'],
3710 PMSFH_link
: obj
.PMSFH
[issue
[1]][issue
[2]]['PMSFH_link']
3714 build_IMPPLAN(obj
.IMPPLAN_items
);
3715 store_IMPPLAN(obj
.IMPPLAN_items
,'1');
3719 var allPanels
= $
('.building_blocks > dd').hide();
3720 var allPanels2
= $
('.building_blocks2 > dd').hide();
3722 $
('.building_blocks > dt > span').click(function() {
3723 allPanels
.slideUp();
3724 $
(this
).parent().next().slideDown();
3727 $
('.building_blocks2 > dt > span').click(function() {
3728 allPanels2
.slideUp();
3729 $
(this
).parent().next().slideDown();
3732 $
('#IMP_start_acc').slideDown();
3733 $
('[id^=inc_]').click(function() {
3737 $
('#active_flag').click(function() { check_lock('1'); });
3738 $
('#active_icon').click(function() { check_lock('1'); });
3740 $
("input,textarea,text,checkbox").change(function(){
3741 $
(this
).css("background-color","#F0F8FF");
3742 if ($
(this
).id
!= 'IMP') {
3743 //alert('form is '+$(this).id);
3746 // alert('Form was IMP');
3750 $
('#IMP').blur(function() {
3751 //add this DX to the obj.IMPPLAN_items array
3752 //take the first line as the impression and the rest as the plan
3753 var total_imp
= $
('#IMP').val();
3754 $
('#IMP').val('');//clear the box
3755 var local_plan
= '';
3757 if (total_imp
.length
< '2') return; //reject text under two letters?
3758 var re
= /\r\n|
[\n\v\f\r\x85\u2028\u2029]/; //official list of line delimiters for a regex
3759 //local_impression is first line only[1]
3760 var local_imp
= total_imp
.match(/^
(.*)(?
:\r\n|
[\n\v\f\r\x85\u2028\u2029])(.*)/);
3761 if (local_imp
== null || local_imp
[1] == null) {
3762 local_imp
= total_imp
;
3764 // If the first line was dropped in from the Builder via a draggable DX_list
3765 // it will include the IMPRESSION + CODE.
3766 // Consider stripping out the CODE
3767 var local_imp_code
= local_imp
[1].match(/(.*)(ICD
.*)$
/);
3768 if (local_imp_code
) {
3769 local_imp
= local_imp_code
[1];
3770 local_code
= local_imp_code
[2];
3771 local_plan
= total_imp
.replace(local_imp_code
[0],''); //plan is line 2+ if present, strip off first line
3772 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
3774 local_imp
= local_imp
[1];
3776 local_plan
= total_imp
.replace(local_imp
,''); //plan is line 2+ if present, strip off first line
3777 local_plan
= local_plan
.replace(/^\r\n|
[\n\v\f\r\x85\u2028\u2029]/,'');
3780 if (obj
.IMPPLAN_items
==null) obj
.IMPPLAN_items
= [];//can't push if array does not exist
3781 obj
.IMPPLAN_items
.push({
3782 form_id
: $
('#form_id').val(),
3783 pid
: $
('#pid').val(),
3792 build_IMPPLAN(obj
.IMPPLAN_items
,'1');
3793 store_IMPPLAN(obj
.IMPPLAN_items
);
3795 //submit_form('1');//tell the server where we stand
3797 $
('#Add_Glasses').click(function() {
3798 for (i
=2; i
<6; i++
) { //come on, 5 current rx glasses should be enough...
3799 if ($
('#W_'+i
).val() != '1') {
3800 $
('#W_'+i
).val('1');
3801 $
('#LayerVision_W_'+i
).removeClass('nodisplay');
3802 if (i
==5) { $
('#Add_Glasses').addClass('nodisplay'); }
3807 $
("[name='reverseme']").click(function() {
3808 var target
= this
.id
;
3809 reverse_cylinder(target
);
3812 $
('#code_me_now').click(function(event
) {
3813 event
.preventDefault();
3814 build_CODING_list();
3816 $
( ".widget a" ).button();
3818 $
('#goto_fee_sheet2').click(function(event
) {
3819 goto_url('<?php echo $GLOBALS['webroot
']; ?>/interface/patient_file/encounter/load_form.php?formname=fee_sheet');
3822 $
( "button" ).button().click(function( event
) {
3823 event
.preventDefault();
3826 // AUTO- CODING FEATURES
3828 check_exam_detail();
3829 if ($
("#PRIOR_ALL").value
== "undefined") {
3830 var Code_new_est
="New";
3832 var Code_new_est
="Est";
3834 Suggest_visit_code();
3835 $
('#visit_codes').change(function() {
3836 var data_all
= $
(this
).val();
3837 var data
= data_all
.match(/^
(.*)\|
(.*)\|
/);
3838 visit_code
= data
[2];
3839 visit_type
= data
[1];
3841 show_QP_section('IMPPLAN','1');
3842 $
('.modifier').on('click', function () {
3843 var item
= this
.id
.match(/visit_mod_(.*)/)[1];
3844 if ($
(this
).hasClass('status_on')) {
3845 $
(this
).css("background-color","navy");
3846 $
(this
).removeClass('status_on');
3847 delete visit_modifier
[''+item
];
3849 $
(this
).css("background-color","red");
3850 $
(this
).addClass('status_on');
3851 visit_modifier
.push(item
);
3854 build_IMPPLAN(obj
.IMPPLAN_items
);
3856 <?php
if ($GLOBALS['new_tabs_layout'] !=='1') {
3857 ?
> $
("[class='tabHide']").css("display","inline-block"); <?php
3859 $
("input,textarea,text").focus(function(){
3860 $
(this
).css("background-color","#ffff99");
3862 $
(window
).bind('onbeforeunload', function(){
3863 if ($
('#chart_status').val()=="on") {