From 40142a0e311e9eb72ccbce840cfd17292967b58d Mon Sep 17 00:00:00 2001
From: Aditya Bhansali <adityab3@illinois.edu>
Date: Fri, 30 Oct 2020 11:31:46 -0500
Subject: [PATCH] Fixed null error in PreRegisterPatient.jsp

---
 iTrust/WebRoot/util/PreRegisterPatient.jsp           | 12 +++++++-----
 .../itrust/action/AddPreRegisteredPatientAction.java |  4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/iTrust/WebRoot/util/PreRegisterPatient.jsp b/iTrust/WebRoot/util/PreRegisterPatient.jsp
index d433504..17637e9 100755
--- a/iTrust/WebRoot/util/PreRegisterPatient.jsp
+++ b/iTrust/WebRoot/util/PreRegisterPatient.jsp
@@ -1,10 +1,10 @@
 <%@taglib prefix="itrust" uri="/WEB-INF/tags.tld"%>
 <%@page errorPage="/auth/exceptionHandler.jsp"%>
 
-<%@page import="edu.ncsu.csc.itrust.action.AddPatientAction"%>
+<%@page import="edu.ncsu.csc.itrust.action.AddPreRegisteredPatientAction"%>
 <%@page import="edu.ncsu.csc.itrust.BeanBuilder"%>
 <%@page import="edu.ncsu.csc.itrust.beans.PatientBean"%>
-<%@page import="edu.ncsu.csc.itrust.beans.HealthRecord"%>
+<%@page import="edu.ncsu.csc.itrust.beans.forms.HealthRecordForm"%>
 <%@page import="edu.ncsu.csc.itrust.exception.FormValidationException"%>
 <%@include file="/global.jsp" %>
 
@@ -19,11 +19,13 @@ boolean formIsFilled = request.getParameter("formIsFilled") != null && request.g
 
 if (formIsFilled) {
     PatientBean p = new BeanBuilder<PatientBean>().build(request.getParameterMap(), new PatientBean());    
-    HealthRecord h = new BeanBuilder<HealthRecord>().build(request.getParameterMap(), new HealthRecord());
+    HealthRecordForm h = new BeanBuilder<HealthRecordForm>().build(request.getParameterMap(), new HealthRecordForm());
 
-    String s = "bla";
+    long mid = new PreRegisterPatientAction(prodDAO).addPatient(p);
+
+    String name = "<Name>";
     if (p != null) {
-	s = p.getFullName();
+         name = p.getFullName();
     }
 %>
 <div><%=s%></div>
diff --git a/iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java b/iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
index 50de00c..7a97978 100644
--- a/iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
+++ b/iTrust/src/edu/ncsu/csc/itrust/action/AddPreRegisteredPatientAction.java
@@ -27,8 +27,8 @@ public class AddPreRegisteredPatientAction {
 	 * @param loggedInMID
 	 */
 	public AddPreRegisteredPatientAction(DAOFactory factory, long loggedInMID) {
-		this.patientDAO = factory.getPatientDAO();
-		this.loggedInMID = loggedInMID;
+        this.patientDAO = factory.getPatientDAO();
+        this.loggedInMID = loggedInMID;
 		this.authDAO = factory.getAuthDAO();
 	}
 	
-- 
GitLab