Create New Appointment Broken

yehster wrote on Tuesday, May 29, 2012:

Go to the demo site and create a new patient.  Then go to the calendar and click on an empty slot.  Hit Save.  The system currently prompts that slot is already booked even though it’s not.

I suspect that Rod’s code here:
https://github.com/openemr/openemr/commit/99a727cba3e62d8fdac4b15e3a21cdda6ef80933
is the culprit.

is the culprit.

tmccormi wrote on Tuesday, November 06, 2012:

I’m having this issue as well on one of my customers that I just upgraded to 4.1.1 (7).

-Tony

doccbst wrote on Tuesday, November 06, 2012:

confirmed issue: add anyway appointment is added
not sure why? but some conflict somewhere ?

yehster wrote on Tuesday, November 06, 2012:

The work around is to create IN/OUT events on the calendar. 

Rod seems to be using the “find available” code to decide if a slot is being double booked which does not correctly distinguish between an already used slot and an “out of office hours” slot.

sunsetsystems wrote on Tuesday, November 06, 2012:

It’s not a work around - IN/OUT events are required by design.  You don’t want to book an appointment where the doc is not in!

Rod
www.sunsetsystems.com

sunsetsystems wrote on Tuesday, November 06, 2012:

Looks like the easy fix here is to change the wording “This appointment slot is already used” to “This appointment slot is not available”.

Rod
www.sunsetsystems.com

tmccormi wrote on Tuesday, November 06, 2012:

I would add a reminder to the effect of, “Make sure you have configured IN/OUT times”.  I guarantee that most people miss this step.

Another option might be to alert the user  when a provider is selected: “IN / OUT are not configured for this provider”.  or similar.

-Tony

cverk wrote on Wednesday, November 07, 2012:

This problem happens even if you are editing and re-saving an existing appointment.  It also happens on parts of the schedule where I am in the office. Maybe we missed some sort of in/out setting, but it is pretty unclear if that is the case.

sunsetsystems wrote on Thursday, November 08, 2012:

This problem happens even if you are editing and re-saving an existing appointment. It also happens on parts of the schedule where I am in the office. Maybe we missed some sort of in/out setting, but it is pretty unclear if that is the case.

Cverk, it would help if you can repro those problems on the demo site.  But that sounds like stuff I fixed, so if you are on an older release that may be the problem.

Rod
www.sunsetsystems.com

cverk wrote on Friday, November 09, 2012:

I tried the demo and it does seem to work better than ours.  I am using windows xampp 4.1.1 patch 7. I will try not to make observations of things to fix unless I have put in all the established fixes that have already been made. If you look at a scheduled visit and check the provider box it says in office, but when you try to resave it there is a box telling you the slot is used.  You can click and overide it, but it makes everyone think there is something wrong. Does the demo represent fixes past the official patch releases?  Or could this be windows specific?  On the demo it looks like it trys to make an error box that goes away quickly by itself.

bradymiller wrote on Sunday, November 11, 2012:

Hi,

This is a known bug that we haven’t been able to fix, mostly because I haven’t been able to reproduce it (to verify, I mean when get this error as in cverk’s case where the template has been properly set). I couldn’t reproduce this in xampp-4.1.1 package (note this is likely using a newer version of xampp than cverk above; cverk can you verify this), so am wondering if it’s happening on Windows in older php versions.

-brady
OpenEMR

cverk wrote on Sunday, November 11, 2012:

I am using the xampp version with the current xampp 4.1.1 package.  I imported our old data into that in order to use the newer xampp.  I have put in all the patches as well.

yehster wrote on Monday, November 12, 2012:

https://github.com/yehster/openemr/commit/a4cee0a8ab9a5a71eabdfe3d80f47b142b835494
This commit isn’t meant to go into the master branch, but cverk, if you just want to bypass the “find_available” verification step temporarily, you could apply this change. 

jjcahs wrote on Monday, November 12, 2012:

Brady,

Can you please tell the current process to get on the Professional Support Page as a provider? I have trained and helped several OpenEMR customers but now am operating under a new company name that is not on the list. Also, my partner is working on an innovative mobile app and some new forms. Please advise. email JC@acehealthsolutions.com

tmccormi wrote on Monday, November 12, 2012:

First, jjcahs, I suggest that you don’t post requests that not related to the topic.  This thread is about a bug in the calendar.  Create a new topic at least, probably in the ‘Help’ section.

-Tony

bradymiller wrote on Saturday, November 17, 2012:

Hi cverk,

I just re-tested it on 4.1.1(7) from the xampp package (which is xampp 1.8.0) and I can’t confirm this (if I set the IN/OUT template and create an appt with this I do not get the message). Very odd, Even tried it with users in different acl groups. Here’s is the code that is related to this from interface/main/calendar/add_edit_event.php:

function SubmitForm() {
 var f = document.forms[0];
 <?php if (!($GLOBALS['select_multi_providers'])) { // multi providers appt is not supported by check slot avail window, so skip ?>
  if (f.form_action.value != 'delete') {
    // Check slot availability.
    var mins = parseInt(f.form_hour.value) * 60 + parseInt(f.form_minute.value);
    if (f.form_ampm.value == '2' && mins < 720) mins += 720;
    find_available('&cktime=' + mins);
  }
  else {
    top.restoreSession();
    f.submit();
  }
 <?php } else { ?>
  top.restoreSession();
  f.submit();
 <?php } ?>
  return true;
}





    // Invoke the find-available popup.
    function find_available(extra) {
        top.restoreSession();
        // (CHEMED) Conditional value selection, because there is no <select> element
        // when making an appointment for a specific provider
        var s = document.forms[0].form_provider;
        var f = document.forms[0].facility;
        <?php if ($userid != 0) { ?>
            s = document.forms[0].form_provider.value;
            f = document.forms[0].facility.value;
        <?php } else {?>
            s = document.forms[0].form_provider.options[s.selectedIndex].value;
            f = document.forms[0].facility.options[f.selectedIndex].value;
        <?php }?>
        var c = document.forms[0].form_category;
        var formDate = document.forms[0].form_date;
        dlgopen('<?php echo $GLOBALS['web_root']; ?>/interface/main/calendar/find_appt_popup.php' +
                '?providerid=' + s +
                '&catid=' + c.options[c.selectedIndex].value +
                '&facility=' + f +
                '&startdate=' + formDate.value +
                '&evdur=' + document.forms[0].form_duration.value +
                '&eid=<?php echo 0 + $eid; ?>' +
                extra,
                '_blank', 500, 400);
        //END (CHEMED) modifications
    }

Which then goes to interface/main/calendar/find_appt_popup.php with related code there:

 // The cktime parameter is a number of minutes into the starting day of a
 // tentative appointment that is to be checked.  If it is present then we are
 // being asked to check if this indicated slot is available, and to submit
 // the opener and go away quietly if it is.  If it's not then we have more
 // work to do.
 $ckavail = true;
 if (isset($_REQUEST['cktime'])) {
  $cktime = 0 + $_REQUEST['cktime'];
  $ckindex = (int) ($cktime * 60 / $slotsecs);
  for ($j = $ckindex; $j < $ckindex + $evslots; ++$j) {
      if ($slots[$j] >= 4) $ckavail = false;
  }
  if ($ckavail) {
    // The chosen appointment time is available.
    echo "<html><script language='JavaScript'>\n";
    echo "function mytimeout() {\n";
    echo " opener.top.restoreSession();\n";
    echo " opener.document.forms[0].submit();\n";
    echo " window.close();\n";
    echo "}\n";
    echo "</script></head><body onload='setTimeout(\"mytimeout()\",250);'>" .
      xlt('Time slot is open, saving event') . "...</body></html>";
    exit();
  }
  // The appointment slot is not available.  A message will be displayed
  // after this page is loaded.
 }





<?php if (!$ckavail) { ?>
<?php if (acl_check('patients','appt','','write')) { ?>
 if (confirm('<?php echo addslashes(xl('This appointment slot is already used, use it anyway?')); ?>')) {
  opener.top.restoreSession();
  opener.document.forms[0].submit();
  window.close();
 }
<?php } else { ?>
 alert('<?php echo addslashes(xl('This appointment slot is not available, please choose another.')); ?>');
<?php } ?>
<?php } ?>

Wonder if it is related to how the slots are set up?

-brady
OpenEMR

cverk wrote on Sunday, November 25, 2012:

I think it may well be the slots issue. The IN/OUT recurring setting is almost impossible to reset.  Once a recurring setting is made , going back to change that gives you these overlapping frames and it aways trys to have you schedule an appointment instead of allowing you to schedule the provider in or out. I read the idea of sneaking up from underneath with the mouse cursor, but it is very difficult to make that work. I think I also had an ACL issue, because my scheduler seemed to think if I ran late a few days she would just set me as out of the office for the last half hour of the day for the next 2 years. We have had a not pleasant discussion regarding that and I believe I have removed that ability from her ACL, but resettiing that is proving very difficult. I watched the videos and read the manual etc which is good for first time setup, but not real helpful on resetting or altering things that have already been done.

jooaquin wrote on Sunday, November 25, 2012:

Cverk, I had the same issue. Here is what I did to solve it:
https://sourceforge.net/projects/openemr/forums/forum/202506/topic/6248910

cverk wrote on Sunday, November 25, 2012:

Maybe what would be useful is to have a way to reset the providers recurring IN/OUT schedule settings to baseline without erasing scheduled patient appointments.  So that way if a providers schedule changes or an error is made in scheduling them, you could start over, because currently trying to fix it makes a mess.  I tried just altering the database to try and make that happen, and that does not go well. Luckily that was with a test instance so I could just erase it and start over.

yehster wrote on Sunday, November 25, 2012:

Cverk,
Instead of reset, how about if I add a global setting that makes it so that creating new appointments works the “old way” and doesn’t require IN/OUT events.