diff --git a/iTrust/WebRoot/auth/patient/cancelAppt.jsp b/iTrust/WebRoot/auth/patient/cancelAppt.jsp deleted file mode 100644 index 38242f1926449708bb5f3464390b0ba52b8609a8..0000000000000000000000000000000000000000 --- a/iTrust/WebRoot/auth/patient/cancelAppt.jsp +++ /dev/null @@ -1,146 +0,0 @@ -<%@page errorPage="/auth/exceptionHandler.jsp"%> - -<%@page import="java.util.Date"%> -<%@page import="java.text.DateFormat"%> -<%@page import="java.text.SimpleDateFormat"%> -<%@page import="edu.ncsu.csc.itrust.action.EditApptAction"%> -<%@page import="edu.ncsu.csc.itrust.action.EditApptTypeAction"%> -<%@page import="edu.ncsu.csc.itrust.action.ViewMyApptsAction"%> -<%@page import="edu.ncsu.csc.itrust.action.EditRepresentativesAction"%> -<%@page import="edu.ncsu.csc.itrust.action.ViewPersonnelAction"%> -<%@page import="edu.ncsu.csc.itrust.beans.ApptBean"%> -<%@page import="edu.ncsu.csc.itrust.dao.mysql.ApptTypeDAO"%> -<%@page import="edu.ncsu.csc.itrust.beans.PatientBean"%> -<%@page import="edu.ncsu.csc.itrust.beans.PersonnelBean"%> -<%@page import="java.util.List"%> - -<%@include file="/global.jsp" %> - -<% -pageTitle = "iTrust - Cancel This Appointment"; -%> - -<%@include file="/header.jsp" %> - -<% - long mid = loggedInMID.longValue(); - ViewMyApptsAction apptAction = new ViewMyApptsAction(prodDAO, loggedInMID.longValue()); - ApptTypeDAO apptTypeDAO = prodDAO.getApptTypeDAO(); - - if (request.getParameter("patient") != null) { - String patientParameter = request.getParameter("patient"); - try { - mid = Long.parseLong(patientParameter); - } catch (NumberFormatException nfe) { - response.sendRedirect("viewMyAppts.jsp"); - } - EditRepresentativesAction representativeAction = new EditRepresentativesAction(prodDAO, loggedInMID.longValue(), String.valueOf(loggedInMID.longValue())); - List<PatientBean> representees = representativeAction.getRepresented(loggedInMID.longValue()); - boolean isRepresented = (loggedInMID == mid); - if (!isRepresented) { - for(PatientBean patientDataBean: representees) { - if(patientDataBean.getMID() == mid) { - isRepresented = true; - break; - } - } - } - if(!isRepresented) { - response.sendRedirect("viewMyAppts.jsp"); - } - session.setAttribute("appts", apptAction.getAppointments(mid)); - } - - ViewMyApptsAction action = new ViewMyApptsAction(prodDAO, mid); - ApptBean original = null; - - if (request.getParameter("apt") != null) { - EditApptAction editAction = new EditApptAction(prodDAO, loggedInMID.longValue()); - String aptParameter = request.getParameter("apt"); - try { - int apptID = Integer.parseInt(aptParameter); - original = editAction.getAppt(apptID); - if (original == null){ - response.sendRedirect("viewMyAppts.jsp"); - } - } catch (NullPointerException npe) { - response.sendRedirect("viewMyAppts.jsp"); - } catch (NumberFormatException e) { - response.sendRedirect("viewMyAppts.jsp"); - } - } - else { - response.sendRedirect("viewMyAppts.jsp"); - } - - - if (original != null) { - EditRepresentativesAction repAction = new EditRepresentativesAction(prodDAO, loggedInMID, ""+loggedInMID); - List<PatientBean> representees = repAction.getRepresented(loggedInMID.longValue()); - boolean authorized = false; - for (PatientBean pBean : representees) { - if (pBean.getMID() == original.getPatient()) { - authorized = true; - break; - } - } - - if (loggedInMID == original.getPatient()) - authorized = true; - - if (authorized) { - Date d = new Date(original.getDate().getTime()); - DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); - - loggingAction.logEvent(TransactionType.APPOINTMENT_VIEW, loggedInMID, original.getPatient(), ""); - %> - <div align="center"> - <h2>You are about to Cancel the Following Appointment. Do you wish to proceed?</h2> - <div> - <ul> - <li><a href="/iTrust/auth/patient/cancelModMyAppts.jsp">Yes</a> - <li><a href="/iTrust/auth/patient/cancelModMyAppts.jsp">No</a> - </ul> - <table> - <tr> - <th>Appointment Info</th> - </tr> - <tr> - <td><b>Patient:</b> <%= StringEscapeUtils.escapeHtml("" + ( action.getName(original.getPatient()) )) %></td> - </tr> - <tr> - <td><b>HCP:</b> <%= StringEscapeUtils.escapeHtml("" + ( action.getName(original.getHcp()) )) %></td> - </tr> - <tr> - <td><b>Type:</b> <%= StringEscapeUtils.escapeHtml("" + ( original.getApptType() )) %></td> - </tr> - <tr> - <td><b>Date/Time:</b> <%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></td> - </tr> - <tr> - <td><b>Duration:</b> <%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(original.getApptType()).getDuration()+" minutes" )) %></td> - </tr> - </table> - </div> - - <table> - <tr> - <td colspan="2"><b>Comments:</b></td> - </tr> - <tr> - <td colspan="2"><%= StringEscapeUtils.escapeHtml("" + ( (original.getComment()== null)?"No Comment":original.getComment() )) %></td> - </tr> - </table> - </div> -<% - } else { -%> - <div align=center> - <span class="iTrustError">You are not authorized to view details of this appointment</span> - </div> -<% - } - } -%> - -<%@include file="/footer.jsp" %> diff --git a/iTrust/WebRoot/auth/patient/editApptPatient.jsp b/iTrust/WebRoot/auth/patient/editApptPatient.jsp new file mode 100644 index 0000000000000000000000000000000000000000..14d1bdf7cfcd1e6ffd82626e7cbe6c7f992fe9e7 --- /dev/null +++ b/iTrust/WebRoot/auth/patient/editApptPatient.jsp @@ -0,0 +1,287 @@ +<%@page import="java.text.ParseException"%> +<%@page import="java.sql.Timestamp"%> +<%@page import="java.util.Date"%> +<%@page import="java.text.SimpleDateFormat"%> +<%@page import="edu.ncsu.csc.itrust.action.EditApptAction"%> +<%@page import="edu.ncsu.csc.itrust.action.EditApptTypeAction"%> +<%@page import="edu.ncsu.csc.itrust.beans.ApptBean"%> +<%@page import="edu.ncsu.csc.itrust.beans.ApptTypeBean"%> +<%@page import="edu.ncsu.csc.itrust.dao.mysql.ApptTypeDAO"%> +<%@page import="edu.ncsu.csc.itrust.beans.HCPVisitBean"%> +<%@page import="edu.ncsu.csc.itrust.action.ViewVisitedHCPsAction"%> +<%@page import="edu.ncsu.csc.itrust.beans.PersonnelBean"%> +<%@page errorPage="/auth/exceptionHandler.jsp"%> +<%@page import="edu.ncsu.csc.itrust.action.AddApptRequestAction"%> +<%@page import="edu.ncsu.csc.itrust.beans.ApptRequestBean"%> +<%@page import="java.util.List"%> + +<%@page import="edu.ncsu.csc.itrust.action.ViewMyApptsAction"%> +<%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%> +<%@page import="edu.ncsu.csc.itrust.exception.ITrustException"%> +<%@page import="java.text.DateFormat"%> + +<%@include file="/global.jsp"%> + +<% + pageTitle = "iTrust - Appointment Requests"; +%> +<%@include file="/header.jsp"%> +<% + EditApptAction editAction = new EditApptAction(prodDAO, loggedInMID.longValue()); + AddApptRequestAction action = new AddApptRequestAction(prodDAO); //ViewAppt in HCP + ViewVisitedHCPsAction hcpAction = new ViewVisitedHCPsAction( + prodDAO, loggedInMID.longValue()); //ViewAppt in HCP + + List<HCPVisitBean> visits = hcpAction.getVisitedHCPs(); + + ApptTypeDAO apptTypeDAO = prodDAO.getApptTypeDAO(); + List<ApptTypeBean> apptTypes = apptTypeDAO.getApptTypes(); + String msg = ""; + long hcpid = 0L; + String comment = ""; + String date = ""; + String hourI = ""; + String minuteI = ""; + String tod = ""; + String apptType = ""; + String prompt = ""; + + // + EditApptTypeAction types = new EditApptTypeAction(prodDAO, loggedInMID.longValue()); + ViewMyApptsAction viewAction = new ViewMyApptsAction(prodDAO, loggedInMID.longValue()); + ApptBean original = null; + //List<ApptTypeBean> apptTypes = types.getApptTypes(); + String aptParameter = ""; + if (request.getParameter("apt") != null) { + aptParameter = request.getParameter("apt"); + try { + int apptID = Integer.parseInt(aptParameter); + original = editAction.getAppt(apptID); + if (original == null){ + response.sendRedirect("viewMyAppts.jsp"); + } + } catch (NullPointerException npe) { + response.sendRedirect("viewMyAppts.jsp"); + } catch (NumberFormatException e) { + // Handle Exception + response.sendRedirect("viewMyAppts.jsp"); + } + } else { + response.sendRedirect("viewMyAppts.jsp"); + } + + Long patientID = 0L; + if (session.getAttribute("pid") != null) { + String pidString = (String) session.getAttribute("pid"); + patientID = Long.parseLong(pidString); + try { + editAction.getName(patientID); + } catch (ITrustException ite) { + patientID = 0L; + } + } + + boolean hideForm = false; + + boolean error = false; + String hidden = ""; + + Date oldDate = new Date(original.getDate().getTime()); + DateFormat dFormat = new SimpleDateFormat("MM/dd/yyyy"); + DateFormat tFormat = new SimpleDateFormat("hhmma"); + String hPart = tFormat.format(oldDate).substring(0,2); + String mPart = tFormat.format(oldDate).substring(2,4); + String aPart = tFormat.format(oldDate).substring(4); + + String lastSchedDate=dFormat.format(oldDate); + String lastApptType=original.getComment(); + String lastTime1=hPart; + String lastTime2=mPart; + String lastTime3=aPart; + String lastComment=original.getComment(); + if(lastComment == null) lastComment=""; + // + + if (request.getParameter("editAppt") != null && request.getParameter("apptID") != null) { + String headerMessage = ""; + //if (request.getParameter("request") != null) { + if (request.getParameter("editAppt").equals("Request")) { + + ApptBean appt = new ApptBean(); + appt.setPatient(loggedInMID); + hcpid = Long.parseLong(request.getParameter("lhcp")); + appt.setHcp(hcpid); + comment = request.getParameter("comment"); + appt.setComment(comment); + SimpleDateFormat frmt = new SimpleDateFormat( + "MM/dd/yyyy hh:mm a"); + date = request.getParameter("startDate"); + date = date.trim(); + hourI = request.getParameter("time1"); + minuteI = request.getParameter("time2"); + tod = request.getParameter("time3"); + apptType = request.getParameter("apptType"); + appt.setApptType(apptType); + try { + if(date.length() == 10){ + Date d = frmt.parse(date + " " + hourI + ":" + minuteI + + " " + tod); + appt.setDate(new Timestamp(d.getTime())); + ApptRequestBean req = new ApptRequestBean(); + req.setRequestedAppt(appt); + msg = action.addApptRequest(req); + if (msg.contains("conflicts")) { + msg = "ERROR: " + msg; + frmt = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); + List<ApptBean> open = action.getNextAvailableAppts(3, appt); + prompt="<br/>The following nearby time slots are available:<br/>"; + int index = 0; + for(ApptBean possible : open) { + index++; + String newDate = frmt.format(possible.getDate()); + prompt += "<div style='padding:5px;margin:5px;float:left;border:1px solid black;'><b>Option " + index+ "</b><br/>"+ frmt.format(possible.getDate()); + prompt+="<form action='appointmentRequests.jsp' method='post'>" + +"<input type='hidden' name='lhcp' value='"+hcpid+"'/>" + +"<input type='hidden' name='apptType' value='"+apptType+"'/> " + +"<input type='hidden' name='startDate' value='"+newDate.substring(0,10)+"'/>" + +"<input type='hidden' name='time1' value='"+newDate.substring(11,13)+"'/>" + +"<input type='hidden' name='time2' value='"+newDate.substring(14,16)+"'/>" + +"<input type='hidden' name='time3' value='"+newDate.substring(17)+"'/>" + +"<input type='hidden' name='comment' value='"+comment+"'/>" + +"<input type='submit' name='request' value='Select this time'/>" + +"</form></div>"; + + } + prompt+="<div style='clear:both;'><br/></div>"; + } else { + loggingAction.logEvent( + TransactionType.APPOINTMENT_REQUEST_SUBMITTED, + loggedInMID, hcpid, ""); + } + }else{ + msg = "ERROR: Date must by in the format: MM/dd/yyyy"; + } + } catch (ParseException e) { + msg = "ERROR: Date must by in the format: MM/dd/yyyy"; + } + } + else if (request.getParameter("editAppt").equals("Remove")) { + // Delete the appointment + ApptBean appt = new ApptBean(); + appt.setApptID(Integer.parseInt(request.getParameter("apptID"))); + + headerMessage = editAction.removeAppt(appt); + if(headerMessage.startsWith("Success")) { + hideForm = true; + session.removeAttribute("pid"); + loggingAction.logEvent(TransactionType.APPOINTMENT_REMOVE, loggedInMID.longValue(), original.getPatient(), ""+original.getApptID()); + %> + <div align=center> + <span class="iTrustMessage"><%=StringEscapeUtils.escapeHtml(headerMessage)%></span> + </div> + <% + } else { + + %> + <div align=center> + <span class="iTrustError"><%=StringEscapeUtils.escapeHtml(headerMessage)%></span> + </div> + <% + } + } + } +%> +<h1>Request an Appointment</h1> +<% + if (msg.contains("ERROR")) { +%> +<span class="iTrustError"><%=msg%></span> +<% + } else { +%> +<span class="iTrustMessage"><%=msg%></span> +<% + } +%> +<%=prompt%> +<%-- <form action="appointmentRequests.jsp" method="post"> --%> +<form id="mainForm" type="hidden" method="post" action="editApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> + <p>HCP:</p> + <select name="lhcp"> + <% + for (HCPVisitBean visit : visits) { + %><option + <%if (visit.getHCPMID() == hcpid) + out.println("selected");%> + value="<%=visit.getHCPMID()%>"><%=visit.getHCPName()%></option> + <% + } + %> + </select> + <p>Appointment Type:</p> + <select name="apptType"> + <% + for (ApptTypeBean appt : apptTypes) { + %><option + <%if (appt.getName().equals(apptType)) + out.print("selected='selected'");%> + value="<%=appt.getName()%>"><%=appt.getName()%></option> + <% + } + String startDate = ""; + %> + </select> + <p>Date:</p> + <input name="startDate" + value="<%=StringEscapeUtils.escapeHtml("" + (date))%>" size="10"> + <input type=button value="Select Date" + onclick="displayDatePicker('startDate');"> + <p>Time:</p> + <select name="time1"> + <% + String hour = ""; + for (int i = 1; i <= 12; i++) { + if (i < 10) + hour = "0" + i; + else + hour = i + ""; + %> + <option <%if (hour.equals(hourI)) + out.print("selected");%> + value="<%=hour%>"><%=StringEscapeUtils.escapeHtml("" + (hour))%></option> + <% + } + %> + </select>:<select name="time2"> + <% + String min = ""; + for (int i = 0; i < 60; i += 5) { + if (i < 10) + min = "0" + i; + else + min = i + ""; + %> + <option <%if (min.equals(minuteI)) + out.print("selected");%> + value="<%=min%>"><%=StringEscapeUtils.escapeHtml("" + (min))%></option> + <% + } + %> + </select> <select name="time3"> + <option <%if ("AM".equals(tod)) + out.print("selected");%> value="AM">AM</option> + <option <%if ("PM".equals(tod)) + out.print("selected");%> value="PM">PM</option> + </select> + <p>Comment:</p> + <textarea name="comment" cols="100" rows="10"><%=StringEscapeUtils.escapeHtml("" + (comment))%></textarea> + <br /> <br /> + <input type="hidden" id="editAppt" name="editAppt" value=""/> + <input type="submit" name="request" value="Request" onClick="document.getElementById('editAppt').value='Request'"/> + <input type="submit" value="Remove" name="editApptButton" id="removeButton" onClick="document.getElementById('editAppt').value='Remove'"/> +</form> +<% + +%> + +<%@include file="/footer.jsp"%> diff --git a/iTrust/WebRoot/auth/patient/menu.jsp b/iTrust/WebRoot/auth/patient/menu.jsp index 9f0f4206237037400f1c472c575290fee86062a5..cd613b69cc9327af60c185b4968e0295d9379d6e 100644 --- a/iTrust/WebRoot/auth/patient/menu.jsp +++ b/iTrust/WebRoot/auth/patient/menu.jsp @@ -66,8 +66,7 @@ <div class="panel-body" id="appt-menu"> <ul class="nav nav-sidebar"> <li><a href="/iTrust/auth/patient/appointmentRequests.jsp">Appointment Requests</a> - <li><a href="/iTrust/auth/patient/cancelModMyAppts.jsp">Cancel/Modify My Appointments</a> - <li><a href="/iTrust/auth/patient/viewMyAppts.jsp">View My Appointments</a> + <li><a href="/iTrust/auth/patient/viewMyApptsPatient.jsp">View/Edit My Appointments</a> </ul> </div> </div> diff --git a/iTrust/WebRoot/auth/patient/cancelModMyAppts.jsp b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp similarity index 73% rename from iTrust/WebRoot/auth/patient/cancelModMyAppts.jsp rename to iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp index e15eea1f4e42fde6c8091fd8fdaa7fc443c09bb4..a032f3e7d535d08413364b531797cee134260cd4 100644 --- a/iTrust/WebRoot/auth/patient/cancelModMyAppts.jsp +++ b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp @@ -1,3 +1,4 @@ + <%@page errorPage="/auth/exceptionHandler.jsp"%> <%@page import="java.util.List"%> @@ -14,7 +15,7 @@ <%@include file="/global.jsp" %> <% -pageTitle = "iTrust - Cancel or Modify My Appointments"; +pageTitle = "iTrust - View My Messages"; %> <%@include file="/header.jsp" %> @@ -23,46 +24,35 @@ pageTitle = "iTrust - Cancel or Modify My Appointments"; <h2>My Appointments</h2> <% loggingAction.logEvent(TransactionType.APPOINTMENT_ALL_VIEW, loggedInMID.longValue(), 0, ""); - ViewMyApptsAction action = new ViewMyApptsAction(prodDAO, loggedInMID.longValue()); - EditApptTypeAction types = new EditApptTypeAction(prodDAO, loggedInMID.longValue()); ApptTypeDAO apptTypeDAO = prodDAO.getApptTypeDAO(); List<ApptBean> appts = action.getMyAppointments(); session.setAttribute("appts", appts); - if (appts.size() > 0) { -%> - <table class="fancyTable"> + if (appts.size() > 0) { %> + <table class="fTable"> <tr> - <th>Provider</th> + <th>HCP</th> <th>Appointment Type</th> <th>Appointment Date/Time</th> <th>Duration</th> - <th>Comment</th> - <th>Action</th> + <th>Comments</th> + <th>Change</th> </tr> <% - - List<ApptBean>conflicts = action.getAllConflicts(loggedInMID.longValue()); - int index = 0; for(ApptBean a : appts) { - String comment = ""; - String cancelMod = ""; - cancelMod = "<a href='cancelAppt.jsp?apt=" + a.getApptID() + "'>Cancel Appointment</a>"; - if(a.getComment() == null) - comment = "No Comment"; - else - comment = "<a href='viewAppt.jsp?apt=" + a.getApptID() + "'>Read Comment</a>"; + String comment = "No Comment"; + if(a.getComment() != null) + comment = "<a href='viewAppt.jsp?apt="+a.getApptID()+"'>Read Comment</a>"; Date d = new Date(a.getDate().getTime()); + Date now = new Date(); DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); - String row = ""; + String row = "<tr"; if(conflicts.contains(a)) - row = "<tr style='font-weight: bold;'"; - else - row = "<tr"; + row += " style='font-weight: bold;'"; %> <%=row+" "+((index%2 == 1)?"class=\"alt\"":"")+">"%> <td><%= StringEscapeUtils.escapeHtml("" + ( action.getName(a.getHcp()) )) %></td> @@ -70,10 +60,12 @@ pageTitle = "iTrust - Cancel or Modify My Appointments"; <td><%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></td> <td><%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(a.getApptType()).getDuration()+" minutes" )) %></td> <td><%= comment %></td> - <td><%= cancelMod %></td> + <td><% if(d.after(now)){ %><a href="editApptPatient.jsp?apt=<%=a.getApptID() %>">Edit/Remove</a> <% } %></td> </tr> - <% index ++; %> - <% } %> + <% + index ++; + } + %> </table> <% } else { %> <div>