diff --git a/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp b/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp new file mode 100644 index 0000000000000000000000000000000000000000..1da59f1cb5bfd884eaaad7aeda5e88dbec300466 --- /dev/null +++ b/iTrust/WebRoot/auth/patient/cancelApptPatient.jsp @@ -0,0 +1,166 @@ +<%@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; + 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("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>Cancel Existing Appointment</h1> +<% + if (msg.contains("ERROR")) { +%> +<span class="iTrustError"><%=msg%></span> +<% + } else { +%> +<span class="iTrustMessage"><%=msg%></span> +<% + } +%> +<%=prompt%> +<%Date d = new Date(original.getDate().getTime()); +DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); +%> +<div> + <h4>The following appointment will be canceled by pressing the "Cancel Appointment" button.</h4> + <p><b>Patient:</b> <%= StringEscapeUtils.escapeHtml("" + ( editAction.getName(original.getPatient()) )) %></p> + <p><b>HCP:</b> <%= StringEscapeUtils.escapeHtml("" + ( editAction.getName(original.getHcp()) )) %></p> + <p><b>Type:</b> <%= StringEscapeUtils.escapeHtml("" + ( original.getApptType() )) %></p> + <p><b>Date/Time:</b> <%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></p> + <p><b>Duration:</b> <%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(original.getApptType()).getDuration()+" minutes" )) %></p> +</div> + +<% +if(!hideForm){ +%> +<form id="mainForm" type="hidden" method="post" action="cancelApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> + <input type="submit" value="Cancel Appointment" name="editApptButton" id="removeButton" onClick="document.getElementById('editAppt').value='Remove';"/> + + <input type="hidden" id="editAppt" name="editAppt" value=""/> + +</form> +<%}%> +<%@include file="/footer.jsp"%> diff --git a/iTrust/WebRoot/auth/patient/editApptPatient.jsp b/iTrust/WebRoot/auth/patient/editApptPatient.jsp index dc19f39fe39a236c8ff3a9468aefabb6fdf9141a..7dfe0a8943ba729bde0078a45d7eb8e937bc497d 100644 --- a/iTrust/WebRoot/auth/patient/editApptPatient.jsp +++ b/iTrust/WebRoot/auth/patient/editApptPatient.jsp @@ -46,11 +46,9 @@ 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"); @@ -58,16 +56,16 @@ int apptID = Integer.parseInt(aptParameter); original = editAction.getAppt(apptID); if (original == null){ - response.sendRedirect("viewMyAppts.jsp"); + response.sendRedirect("viewMyApptsPatient.jsp"); } } catch (NullPointerException npe) { - response.sendRedirect("viewMyAppts.jsp"); + response.sendRedirect("viewMyApptsPatient.jsp"); } catch (NumberFormatException e) { // Handle Exception - response.sendRedirect("viewMyAppts.jsp"); + response.sendRedirect("viewMyApptsPatient.jsp"); } } else { - response.sendRedirect("viewMyAppts.jsp"); + response.sendRedirect("viewMyApptsPatient.jsp"); } Long patientID = 0L; @@ -100,13 +98,11 @@ 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")); @@ -165,33 +161,9 @@ 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>Cancel Existing Appointment or Request a New Appointment</h1> +<h1>Request a New Appointment</h1> <% if (msg.contains("ERROR")) { %> @@ -207,34 +179,18 @@ <%Date d = new Date(original.getDate().getTime()); DateFormat format = new SimpleDateFormat("MM/dd/yyyy hh:mm a"); %> -<div> - <h3>The following appointment will be canceled by pressing the "Cancel Appointment" button.</h3> - <p><b>Patient:</b> <%= StringEscapeUtils.escapeHtml("" + ( editAction.getName(original.getPatient()) )) %></p> - <p><b>HCP:</b> <%= StringEscapeUtils.escapeHtml("" + ( editAction.getName(original.getHcp()) )) %></p> - <p><b>Type:</b> <%= StringEscapeUtils.escapeHtml("" + ( original.getApptType() )) %></p> - <p><b>Date/Time:</b> <%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></p> - <p><b>Duration:</b> <%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(original.getApptType()).getDuration()+" minutes" )) %></p> -</div> - -<%-- <form action="appointmentRequests.jsp" method="post"> --%> <form id="mainForm" type="hidden" method="post" action="editApptPatient.jsp?apt=<%=aptParameter %>&apptID=<%=original.getApptID() %>"> - <input type="submit" value="Cancel Appointment" name="editApptButton" id="removeButton" onClick="document.getElementById('editAppt').value='Remove'"/> - <br/> - <br/> <p>HCP:</p> <select name="lhcp"> <% -/// -//<% + for(HCPVisitBean visit : visits){ if (visit.getHCPMID() == original.getHcp()){ %> <option selected="selected" value="<%=visit.getHCPMID()%>"><%=visit.getHCPName()%></option> <%}else { %> <option value="<%=visit.getHCPMID()%>"><%=visit.getHCPName()%></option> <%} } -/// - %> </select> @@ -247,9 +203,7 @@ for(HCPVisitBean visit : visits){ <option selected="selected" value="<%=appt.getName()%>"><%=appt.getName()%></option> <%}else { %> <option value="<%=appt.getName()%>"><%=appt.getName()%></option> - <%} } - - + <%} } String startDate = ""; %> @@ -310,8 +264,4 @@ for(HCPVisitBean visit : visits){ <input type="submit" name="request" value="Request" onClick="document.getElementById('editAppt').value='Request'"/> </form> -<% - -%> - <%@include file="/footer.jsp"%> diff --git a/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp index a032f3e7d535d08413364b531797cee134260cd4..f00a8ecd9f5ca2b63248b31c0a977ac3478e80a3 100644 --- a/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp +++ b/iTrust/WebRoot/auth/patient/viewMyApptsPatient.jsp @@ -60,7 +60,9 @@ pageTitle = "iTrust - View My Messages"; <td><%= StringEscapeUtils.escapeHtml("" + ( format.format(d) )) %></td> <td><%= StringEscapeUtils.escapeHtml("" + ( apptTypeDAO.getApptType(a.getApptType()).getDuration()+" minutes" )) %></td> <td><%= comment %></td> - <td><% if(d.after(now)){ %><a href="editApptPatient.jsp?apt=<%=a.getApptID() %>">Edit/Remove</a> <% } %></td> + <td style="display:inline"><% if(d.after(now)){ %><a href="editApptPatient.jsp?apt=<%=a.getApptID() %>">Edit</a> <% } %></td> + <td style="display:inline">|</td> + <td style="display:inline"><% if(d.after(now)){ %><a href="cancelApptPatient.jsp?apt=<%=a.getApptID() %>">Cancel Appointment</a> <% } %></td> </tr> <% index ++;