Commit caf00733 authored by CORP\sonam.kamble's avatar CORP\sonam.kamble

Changes done for Doctor , Patient Registration

parent 035b2f33
...@@ -6,7 +6,9 @@ import java.sql.ResultSet; ...@@ -6,7 +6,9 @@ import java.sql.ResultSet;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import org.json.XML; import org.json.XML;
import org.json.simple.JSONArray; import org.json.simple.JSONArray;
...@@ -76,7 +78,9 @@ public class Appointment ...@@ -76,7 +78,9 @@ public class Appointment
" APT.STATUS AS STATUS, " + " APT.STATUS AS STATUS, " +
" '/IBASE/RESOURCE/IMAGES/DETAILFORMICON/COMPLETED.PNG' AS VISIT_COMP_ICON, " + " '/IBASE/RESOURCE/IMAGES/DETAILFORMICON/COMPLETED.PNG' AS VISIT_COMP_ICON, " +
" '/IBASE/RESOURCE/IMAGES/DETAILFORMICON/DOC_VERIFY.PNG' AS VERIFY_DOC_ICON, " + " '/IBASE/RESOURCE/IMAGES/DETAILFORMICON/DOC_VERIFY.PNG' AS VERIFY_DOC_ICON, " +
" APT.PATIENT_REF_NO " + " APT.PATIENT_REF_NO ," +
" PTF.ATTACHMENT AS REF_ID, " +
"'PAT-F' AS REF_SER" +
" FROM APPOINTMENT APT " + " FROM APPOINTMENT APT " +
" JOIN PATIENT PT ON APT.PATIENT_CODE = PT.PATIENT_CODE " + " JOIN PATIENT PT ON APT.PATIENT_CODE = PT.PATIENT_CODE " +
" JOIN PATIENT_FAMILY PTF ON PTF.PATIENT_CODE = APT.PATIENT_CODE AND PTF.LINE_NO = APT.PATIENT_REF_NO " + " JOIN PATIENT_FAMILY PTF ON PTF.PATIENT_CODE = APT.PATIENT_CODE AND PTF.LINE_NO = APT.PATIENT_REF_NO " +
...@@ -163,12 +167,6 @@ public class Appointment ...@@ -163,12 +167,6 @@ public class Appointment
try try
{ {
conn = connDriver.getConnectDB(transDB); conn = connDriver.getConnectDB(transDB);
/*
* sql=
* " SELECT APT.STATUS,PT.PATIENT_CODE,PT.FIRST_NAME || ' ' || PT.MIDDLE_NAME || ' ' || PT.LAST_NAME AS PATIENT_NAME\n"
* + " FROM APPOINTMENT APT \n" + " JOIN PATIENT PT\n" +
* " ON PT.PATIENT_CODE = APT.PATIENT_CODE \n" + " WHERE APT.APPOINT_ID = ? ";
*/
sql = " SELECT " + sql = " SELECT " +
" CASE " + " CASE " +
...@@ -357,7 +355,6 @@ public class Appointment ...@@ -357,7 +355,6 @@ public class Appointment
toDateStr = jsonData.getString("toDate"); toDateStr = jsonData.getString("toDate");
visitplace = jsonData.getString("visitPlace"); visitplace = jsonData.getString("visitPlace");
remarks = jsonData.getString("remark"); remarks = jsonData.getString("remark");
//SimpleDateFormat input = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
if("".equalsIgnoreCase(visitplace)) if("".equalsIgnoreCase(visitplace))
{ {
...@@ -366,7 +363,6 @@ public class Appointment ...@@ -366,7 +363,6 @@ public class Appointment
jsonObject = this.convertXmlToJsonInError(errSting); jsonObject = this.convertXmlToJsonInError(errSting);
return jsonObject.toString(); return jsonObject.toString();
} }
;
try try
{ {
frDate = output.parse(fromDateStr); frDate = output.parse(fromDateStr);
...@@ -394,6 +390,65 @@ public class Appointment ...@@ -394,6 +390,65 @@ public class Appointment
System.out.println("Excepetion ...1 "+e.getMessage()); System.out.println("Excepetion ...1 "+e.getMessage());
} }
if("All".equalsIgnoreCase(visitplace))
{
try
{
conn=connDriver.getConnectDB(transDB);
sql = "SELECT LINE_NO FROM STRG_VISIT_HOURS WHERE SC_CODE = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, userCode);
rs = pStmt.executeQuery();
while (rs.next())
{
visitplaces.add(genericUtility.checkNull(rs.getString("LINE_NO")).trim());
}
pStmt = null;
rs=null;
System.out.println(visitplaces);
//Validation on all location Start
//select * from VISIT_UNAVAILABLE where fr_date = '18-APR-2020' and to_date = '18-APR-2020' AND VIST_REF_NO IN ('1','2','3');
//Validation on all location End
if(visitplaces.size() > 0)
{
sql = "INSERT INTO VISIT_UNAVAILABLE (SC_CODE,FR_DATE,TO_DATE,VIST_REF_NO,REMARK) VALUES (?,?,?,?,?)";
pStmt = conn.prepareStatement(sql);
Iterator<String> itr = visitplaces.iterator();
while(itr.hasNext())
{
lineNo = itr.next();
System.out.println("visitPlace .. "+lineNo);
pStmt.setString(1, userCode);
pStmt.setTimestamp(2, fromDtTStmp);
pStmt.setTimestamp(3, toDtTStmp);
pStmt.setString(4, lineNo);
pStmt.setString(5, remarks);
pStmt.addBatch();
}
int[] result = pStmt.executeBatch();
System.out.println("The number of rows inserted: "+ result.length);
conn.commit();
if(result.length == visitplaces.size())
{
System.out.println("1.............");
}
else
{
System.out.println("2.............");
}
}
}
catch(Exception e)
{
System.out.println("Exception while inserting into strg_visit_hours for all location :: "+e);
}
}
else
{
conn=connDriver.getConnectDB(transDB); conn=connDriver.getConnectDB(transDB);
sql="SELECT LINE_NO FROM STRG_VISIT_HOURS WHERE SC_CODE = ? AND VISIT_PLACE = ?"; sql="SELECT LINE_NO FROM STRG_VISIT_HOURS WHERE SC_CODE = ? AND VISIT_PLACE = ?";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
...@@ -474,6 +529,7 @@ public class Appointment ...@@ -474,6 +529,7 @@ public class Appointment
jsonObject = convertXmlToJsonInError(errSting); jsonObject = convertXmlToJsonInError(errSting);
} }
} }
}
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception in getDoctorDetails :: "+e.getMessage()); System.out.println("Exception in getDoctorDetails :: "+e.getMessage());
...@@ -509,7 +565,7 @@ public class Appointment ...@@ -509,7 +565,7 @@ public class Appointment
//Added by Amey W. [ To update status of appointment ] on 3-04-2020 START //Added by Amey W. [ To update status of appointment ] on 3-04-2020 START
@SuppressWarnings({ "static-access", "resource" }) @SuppressWarnings({ "static-access", "resource" })
public String updateMyApptStatus(String apptId, UserInfoBean userInfoBean) { public String updateMyApptStatus(String apptId, UserInfoBean userInfoBean) {
String sql = "", status = "", errSting = ""; String sql = "", status = "", errSting = "", name = "";
int cnt = 0; int cnt = 0;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null;
...@@ -521,6 +577,34 @@ public class Appointment ...@@ -521,6 +577,34 @@ public class Appointment
try { try {
String transDB = userInfoBean.getTransDB(); String transDB = userInfoBean.getTransDB();
conn = connDriver.getConnectDB(transDB); conn = connDriver.getConnectDB(transDB);
StringBuilder builder = new StringBuilder("select appt.appoint_status, appt.doctor_code,");
builder.append("sc.first_name || ' '|| sc.middle_name || ' ' || sc.last_name as name ");
builder.append("from appointment appt, strg_customer sc where sc.sc_code = appt.doctor_code and appt.appoint_id = ?");
pStmt = conn.prepareStatement(builder.toString());
pStmt.setString(1, apptId);
rs = pStmt.executeQuery();
if(rs.next())
{
status = rs.getString("appoint_status");
name = rs.getString("name");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
if("C".equalsIgnoreCase(status))
{
errSting = genericUtility.getErrorString("appt_id", "VMAPPTCPAR", userCode);
jsonObject = convertXmlToJsonInError(errSting);
}
else
{
sql = "update APPOINTMENT set appoint_status = ? where APPOINT_ID = ? "; sql = "update APPOINTMENT set appoint_status = ? where APPOINT_ID = ? ";
pStmt = conn.prepareStatement(sql); pStmt = conn.prepareStatement(sql);
pStmt.setString(1, "C"); pStmt.setString(1, "C");
...@@ -541,6 +625,9 @@ public class Appointment ...@@ -541,6 +625,9 @@ public class Appointment
pStmt.close(); pStmt.close();
pStmt = null; pStmt = null;
} }
}
jsonObject.append("doctor_name", name);
} catch (Exception e) { } catch (Exception e) {
System.out.println( System.out.println(
"Exception in Appointment Dashboard ..............."+ e); "Exception in Appointment Dashboard ..............."+ e);
...@@ -595,98 +682,426 @@ public class Appointment ...@@ -595,98 +682,426 @@ public class Appointment
public String registerDoctor(String data,UserInfoBean userInfoBean) public String registerDoctor(String data,UserInfoBean userInfoBean)
{ {
System.out.println("Inside insertUnableToVisit "); System.out.println("Appointment.registerDoctor().....");
String lineNo = "",visitplace = "",errSting="",fromDateStr="",toDateStr="",scCode="",remarks=""; String errString="", userId = "", scCode = "";
String sql = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null, conn1 = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
ResultSet rs = null; ResultSet rs = null;
String transDB = userInfoBean.getTransDB();
String userCode = userInfoBean.getLoginCode();
org.json.JSONObject jsonObject = new org.json.JSONObject(); org.json.JSONObject jsonObject = new org.json.JSONObject();
List<String> visitplaces = new ArrayList<String>(); List<String> visitplaces = new ArrayList<String>();
java.util.Date frDate = null; java.util.Date dateOfBirth = null, currDate = null;
java.util.Date toDate = null; java.util.Date toDate = null;
Timestamp fromDtTStmp = null; Timestamp dtOfBirth = null, currTmpStmp = null;
Timestamp toDtTStmp = null; Timestamp toDtTStmp = null;
SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT); SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
StringBuilder builder = new StringBuilder();
String mobNo = "", name = "", dob = "", gender = "", ediArr = "", chgDate = "",
chgUSer = "", chgTerm = "", emailId = "", entityCode = "", siteCodeDef = "",
userLev = "", profileId = "", entityType = "", userType = "", transDb = "",
firstName = "", middleName = "", lastName = "", regNo = "",
qualification = "", address = "", state = "", city = "", pinCode = "";
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
String mobileRex = "(0/91)?[1-9][0-9]{9}";
try try
{ {
org.json.JSONObject jsonData = new org.json.JSONObject(data);
System.out.println("#jsonData " + jsonData.toString());
currDate = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
String date = sdf.format(currDate);
currTmpStmp = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(date, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00");
firstName = jsonData.getString("firstName");
middleName = jsonData.getString("middleName");
lastName = jsonData.getString("lastName");
regNo = jsonData.getString("regNo");
emailId = E12GenericUtility.checkNull(jsonData.getString("email"));
mobNo = jsonData.getString("mobileNo");
dob = E12GenericUtility.checkNull(jsonData.getString("birth_date"));
gender = E12GenericUtility.checkNull(jsonData.getString("gender"));
qualification = jsonData.getString("qualification");
address = E12GenericUtility.checkNull(jsonData.getString("address"));
state = jsonData.getString("state");
city = jsonData.getString("city");
pinCode = jsonData.getString("pinCode");
dateOfBirth = output.parse(dob);
dtOfBirth = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(dob, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00");
if (emailId.length() == 0)
{
errString = genericUtility.getErrorString("email_id", "VTEMAILBK", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
else
{
Pattern pat = Pattern.compile(emailRegex);
boolean isValidEmailId = pat.matcher(emailId).matches();
if(!isValidEmailId)
{
errString = genericUtility.getErrorString("email_id", "VTINVEMILD", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
}
if(mobNo.length() == 0)
{
errString = genericUtility.getErrorString("mob_no", "VTADDCHG12", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
else
{
Pattern pat = Pattern.compile(mobileRex);
boolean isValidMobNo = pat.matcher(mobNo).matches();
if(! isValidMobNo)
{
errString = genericUtility.getErrorString("mob_no", "INVMOBNUM", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
}
if(dob.length() == 0)
{
errString = genericUtility.getErrorString("date_of_birth", "VTBIRTH", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
else if(dtOfBirth.after(currTmpStmp))
{
errString = genericUtility.getErrorString("dateOfBirth", "INVBRTHDAY", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
if(gender.length() == 0)
{
errString = genericUtility.getErrorString("gender", "VTGENDER", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
if(address.length() == 0)
{
errString = genericUtility.getErrorString("address", "VTADDBK", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
System.out.println(""+name+ " fi "+firstName+" "+middleName+" "+lastName+ "mobNo :"+mobNo+"genser : "+gender+"email Id = "+emailId);
System.out.println("dtOfBirth :: ["+dtOfBirth+"]");
boolean isUserCreated = insertUser(mobNo, name, gender, emailId, "KOYE_HELP");
try try
{ {
org.json.JSONObject jsonData = new org.json.JSONObject(data); if(isUserCreated)
System.out.println("#jsonData " + jsonData.toString()); {
scCode = jsonData.getString("scCode"); System.out.println("currTmpStmp :: ["+currTmpStmp+"]");
fromDateStr = jsonData.getString("fromDate");
toDateStr = jsonData.getString("toDate"); conn1 = connDriver.getConnectDB("KOYEHELP");
visitplace = jsonData.getString("visitPlace"); StringBuilder doctorBuilder = new StringBuilder("Insert into strg_customer (SC_CODE,FIRST_NAME,MIDDLE_NAME,LAST_NAME,ADDRESS_AS,QUALIFICATION,");
remarks = jsonData.getString("remark"); doctorBuilder.append("ADDR1,ADDR2,ADDR3,CITY,STAN_CODE,STATE_CODE,PIN,COUNT_CODE,MOBILE_NO,STATUS,SEX,BIRTH_DATE,EMAIL_ADDR,CHG_USER,CHG_DATE,CHG_TERM)");
doctorBuilder.append("values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
pStmt = conn1.prepareStatement(doctorBuilder.toString());
pStmt.setString(1, mobNo);
pStmt.setString(2, firstName);
pStmt.setString(3, middleName);
pStmt.setString(4, lastName);
pStmt.setString(5, address);
pStmt.setString(6, qualification);
pStmt.setString(7, address);
pStmt.setString(8, "");
pStmt.setString(9, "");
pStmt.setString(10, city);
pStmt.setString(11, "DUMMY");
pStmt.setString(12, "DUMMY");
pStmt.setString(13, pinCode);
pStmt.setString(14, "IND");
pStmt.setString(15, mobNo);
pStmt.setString(16, "A");
pStmt.setString(17, gender);
pStmt.setTimestamp(18, dtOfBirth);
pStmt.setString(19, emailId);
pStmt.setString(20, "BASE");
pStmt.setTimestamp(21, currTmpStmp);
pStmt.setString(22, "BASE");
int docCount = pStmt.executeUpdate();
if(docCount > 0)
{
errString = genericUtility.getErrorString("CODE", "DOC_REGIS", mobNo);
jsonObject = convertXmlToJsonInError(errString);
conn1.commit();
}
}
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception 001"+e.getMessage()); System.out.println("Appointment.registerDoctor() .. "+e);
} }
}catch(Exception e) }
catch(Exception e)
{
System.out.println("Exception Doctr 002"+e.getMessage());
}
finally
{ {
System.out.println("Exception 002"+e.getMessage()); try
{
if(conn != null)
{
conn.close();
conn = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
}
catch(Exception e)
{
System.out.println("Exception While Closing resourses Appointment.registerDoctor()..... :: "+e);
}
} }
return null; return jsonObject.toString();
} }
public String registerPatient(String data,UserInfoBean userInfoBean) public String registerPatient(String data,UserInfoBean userInfoBean)
{ {
System.out.println("Inside insertUnableToVisit "); System.out.println("Inside insertUnableToVisit ");
String sql = "",tranID="";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null, conn1 = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
ResultSet rs = null; ResultSet rs = null;
String transDB = userInfoBean.getTransDB();
String userCode = userInfoBean.getLoginCode();
org.json.JSONObject jsonObject = new org.json.JSONObject(); org.json.JSONObject jsonObject = new org.json.JSONObject();
List<String> visitplaces = new ArrayList<String>(); java.util.Date dateOfBirth = null, currDate = null;
java.util.Date frDate = null; Timestamp dtOfBirth = null , currTmpStmp = null;
java.util.Date toDate = null;
Timestamp fromDtTStmp = null;
Timestamp toDtTStmp = null;
SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT); SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
final DBAccessEJB dbAcc = new DBAccessEJB(); final DBAccessEJB dbAcc = new DBAccessEJB();
String mobNo = "", name = "", dob = "", gender = "", ediArr = "", chgDate = "",
chgUSer = "", chgTerm = "", emailId = "", entityCode = "", siteCodeDef = "",
userLev = "", profileId = "", entityType = "", userType = "", transDb = "", errString = "",
address = "", city = "";
String emailRegex = "^[a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,7}$";
String mobileRex = "(0/91)?[1-9][0-9]{9}";
try try
{ {
try
{
org.json.JSONObject jsonData = new org.json.JSONObject(data); org.json.JSONObject jsonData = new org.json.JSONObject(data);
System.out.println("#jsonData " + jsonData.toString()); System.out.println("#jsonData " + jsonData.toString());
currDate = new java.util.Date();
SimpleDateFormat sdf = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
String date = sdf.format(currDate);
currTmpStmp = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(date, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00");
name = jsonData.getString("patient_name");
dob = E12GenericUtility.checkNull(jsonData.getString("birth_date"));
gender = E12GenericUtility.checkNull(jsonData.getString("gender"));
mobNo = E12GenericUtility.checkNull(jsonData.getString("mobile_no"));
address = E12GenericUtility.checkNull(jsonData.getString("addr1"));
city = jsonData.getString("city");
dateOfBirth = output.parse(dob);
dtOfBirth = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(dob, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00");
/*
* if (emailId.length() == 0) { errString =
* genericUtility.getErrorString("email_id", "VTEMAILBK", mobNo); jsonObject =
* this.convertXmlToJsonInError(errString); return jsonObject.toString(); } else
* { Pattern pat = Pattern.compile(emailRegex); boolean isValidEmailId =
* pat.matcher(emailId).matches(); if(!isValidEmailId) { errString =
* genericUtility.getErrorString("email_id", "VTINVEMILD", mobNo); jsonObject =
* this.convertXmlToJsonInError(errString); return jsonObject.toString(); } }
*/
if(mobNo.length() == 0)
{
errString = genericUtility.getErrorString("mob_no", "VTADDCHG12", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
} }
catch(Exception e) else
{ {
System.out.println("Exception 01 "+e.getMessage()); Pattern pat = Pattern.compile(mobileRex);
boolean isValidMobNo = pat.matcher(mobNo).matches();
if(! isValidMobNo)
{
errString = genericUtility.getErrorString("mob_no", "INVMOBNUM", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
}
if(dob.length() == 0)
{
errString = genericUtility.getErrorString("date_of_birth", "VTBIRTH", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
else if(dtOfBirth.after(currTmpStmp))
{
errString = genericUtility.getErrorString("dateOfBirth", "INVBRTHDAY", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
if(gender.length() == 0)
{
errString = genericUtility.getErrorString("gender", "VTGENDER", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
if(address.length() == 0)
{
errString = genericUtility.getErrorString("address", "VTADDBK", mobNo);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
boolean userCreated = insertUser(mobNo, name, gender, emailId, "KOYE_H_PAT");
try
{
if(userCreated)
{
conn1 = connDriver.getConnectDB("KOYEHELP");
String fName = "", mName = "", lName = "";
String[] s = name.split(" ");
System.out.println(s.length);
if(s.length == 1)
{
fName = s[0];
}
else if(s.length == 2)
{
fName = s[0];
mName = s[1];
}
else if (s.length > 2)
{
fName = s[0];
mName = s[1];
lName = s[2];
}
StringBuilder builder1 = new StringBuilder("Insert into patient (PATIENT_CODE,FIRST_NAME,MIDDLE_NAME,LAST_NAME,ADDR1,ADDR2,ADDR3,CITY," );
builder1.append("MOBILE_NO,STATUS,SEX,BIRTH_DATE,ADD_DATE,ADD_USER,ADD_TERM,CHG_DATE,CHG_USER,CHG_TERM,SERVICE_TYPE,SERVICE_NO,NAME)");
builder1.append("values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ");
pStmt = conn1.prepareStatement(builder1.toString());
pStmt.setString(1, mobNo);
pStmt.setString(2, fName);
pStmt.setString(3, mName);
pStmt.setString(4, lName);
pStmt.setString(5, address);
pStmt.setString(6, "");
pStmt.setString(7, "");
pStmt.setString(8, city);
pStmt.setString(9, mobNo);
pStmt.setString(10, "A");
pStmt.setString(11, gender);
pStmt.setTimestamp(12, dtOfBirth);
pStmt.setTimestamp(13, new java.sql.Timestamp(System.currentTimeMillis()));
pStmt.setString(14, "BASE");
pStmt.setString(15, "BASE");
pStmt.setTimestamp(16, new java.sql.Timestamp(System.currentTimeMillis()));
pStmt.setString(17, "BASE");
pStmt.setString(18, "BASE");
pStmt.setString(19, "S");
pStmt.setString(20, "15963258");
pStmt.setString(21, name);
int patCount = pStmt.executeUpdate();
if(patCount > 0)
{
errString = genericUtility.getErrorString("CODE", "PAT_REGIS", mobNo);
jsonObject = convertXmlToJsonInError(errString);
conn1.commit();
}
}
}
catch(Exception ex)
{
System.out.println("Exception while Inserting patient Appointment.registerPatient() : "+ex);
} }
tranID = dbAcc.generateTranId("W_WELCOME_SCREEN", userInfoBean.getSiteCode(), userInfoBean.getLoginCode(), conn);
}catch(Exception e) }catch(Exception e)
{ {
System.out.println("Exception 02 "+e.getMessage()); System.out.println("Exception 02 "+e.getMessage());
} }
return null; return errString;
} }
public String insertUser() public boolean insertUser(String mobNo, String name, String gender, String emailId, String profileId)
{ {
System.out.println("Inside insertUnableToVisit "); System.out.println("Inside insertUnableToVisit ");
String sql = ""; String sql = "" , errString = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null;
ResultSet rs = null; StringBuilder builder = new StringBuilder();
org.json.JSONObject jsonObject = new org.json.JSONObject();
boolean isUserCreated = false;
try try
{ {
try try
{ {
conn = connDriver.getConnectDB(); conn = connDriver.getConnectDB("Driver");
//userId = dbAccessEJB.generateTranId("W", userInfo.getSiteCode(), userInfo.getLoginCode(), conn);
builder.append("INSERT INTO USERS(CODE, NAME, GENDER, PASS_WD , CHG_DATE, CHG_USER, CHG_TERM, MOBILE_NO, EMAIL_ID, ENTITY_CODE,");
builder.append("SITE_CODE__DEF, USR_LEV, PROFILE_ID, USER_TYPE, TRANS_DB, USER_LANG ) ");
builder.append("values(? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,? ,?) ");
pStmt = conn.prepareStatement(builder.toString());
pStmt.setString(1, mobNo);
pStmt.setString(2, name);
pStmt.setString(3, gender);
pStmt.setString(4, mobNo);
pStmt.setTimestamp(5, new java.sql.Timestamp(System.currentTimeMillis()));
pStmt.setString(6, mobNo);
pStmt.setString(7, "SYSTEM");
pStmt.setString(8, mobNo);
pStmt.setString(9, emailId);
pStmt.setString(10, mobNo);
pStmt.setString(11, "S0001");
pStmt.setString(12, "2");
pStmt.setString(13, profileId);
pStmt.setString(14, "C");
pStmt.setString(15, "KOYEHELP");
pStmt.setString(16, "en");
int i = pStmt.executeUpdate();
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
String userSiteSql = "Insert into USER_SITE (USER_ID,SITE_CODE,CHG_DATE,CHG_USER,CHG_TERM,ADD_DATE,ADD_USER,ADD_TERM,PROFILE_ID)"
+ " values (?,?,?,?,?,?,?,?,?)";
pStmt = conn.prepareStatement(userSiteSql);
pStmt.setString(1, mobNo);
pStmt.setString(2, "S0001");
pStmt.setTimestamp(3, new java.sql.Timestamp(System.currentTimeMillis()));
pStmt.setString(4, "BASE");
pStmt.setString(5, "BASE");
pStmt.setTimestamp(6, new java.sql.Timestamp(System.currentTimeMillis()));
pStmt.setString(7, "BASE");
pStmt.setString(8, "BASE");
pStmt.setString(9, "");
int j = pStmt.executeUpdate();
if (i > 0 && j > 0 )
{
isUserCreated = true;
conn.commit();
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -697,8 +1112,140 @@ public class Appointment ...@@ -697,8 +1112,140 @@ public class Appointment
{ {
System.out.println("Exception 02 "+e.getMessage()); System.out.println("Exception 02 "+e.getMessage());
} }
return null; System.out.println("Appointment.insertUser() isUserCreated .. "+isUserCreated);
return isUserCreated;
}
public String getDocProfileDet(UserInfoBean userInfoBean)
{
System.out.println("Inside getDocProfileDet ");
String sql = "";
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String transDB = userInfoBean.getTransDB();
String userCode = userInfoBean.getLoginCode();
JSONObject jsonObject = new JSONObject();
try
{
conn=connDriver.getConnectDB(transDB);
sql = "SELECT FIRST_NAME , MIDDLE_NAME ,LAST_NAME,REG_NO,EMAIL_ADDR,MOBILE_NO,BIRTH_DATE,SEX,QUALIFICATION,ADDRESS_AS,CITY,STAN_CODE,PIN FROM STRG_CUSTOMER WHERE SC_CODE = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, userCode);
rs = pStmt.executeQuery();
while (rs.next())
{
jsonObject.put("first_name", genericUtility.checkNull(rs.getString("FIRST_NAME")));
jsonObject.put("middle_name", genericUtility.checkNull(rs.getString("MIDDLE_NAME")));
jsonObject.put("last_name", genericUtility.checkNull(rs.getString("LAST_NAME")));
jsonObject.put("reg_no", genericUtility.checkNull(rs.getString("REG_NO")));
jsonObject.put("email_addr", genericUtility.checkNull(rs.getString("EMAIL_ADDR")));
jsonObject.put("mobile_no", genericUtility.checkNull(rs.getString("MOBILE_NO")));
jsonObject.put("birth_date", genericUtility.checkNull(rs.getString("BIRTH_DATE")));
jsonObject.put("sex", genericUtility.checkNull(rs.getString("SEX")));
jsonObject.put("qualification", genericUtility.checkNull(rs.getString("QUALIFICATION")));
jsonObject.put("address_as", genericUtility.checkNull(rs.getString("ADDRESS_AS")));
jsonObject.put("city", genericUtility.checkNull(rs.getString("CITY")));
jsonObject.put("pin", genericUtility.checkNull(rs.getString("PIN")));
}
}
catch(Exception e)
{
System.out.println("Exception in getDocProfileDet : "+e);
}
finally
{
try
{
if(conn != null)
{
conn.close();
conn = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.out.println("Exception while closing resourse in getDocProfileDet ... "+e);
}
}
return jsonObject.toString();
} }
public String getPatProfileDet(UserInfoBean userInfoBean)
{
System.out.println("Inside getDocProfileDet ");
String sql = "";
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String transDB = userInfoBean.getTransDB();
String userCode = userInfoBean.getLoginCode();
JSONObject jsonObject = new JSONObject();
try
{
conn=connDriver.getConnectDB(transDB);
sql = " SELECT FIRST_NAME || ' ' || MIDDLE_NAME || ' ' ||LAST_NAME AS NAME,SEX,SERVICE_NO,SERVICE_TYPE,BIRTH_DATE,MOBILE_NO,ADDR1,CITY FROM PATIENT WHERE PATIENT_CODE = ?";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, userCode);
rs = pStmt.executeQuery();
if(rs.next())
{
jsonObject.put("NAME", genericUtility.checkNull(rs.getString("NAME")));
jsonObject.put("BIRTH_DATE", genericUtility.checkNull(rs.getString("BIRTH_DATE")));
jsonObject.put("SEX", genericUtility.checkNull(rs.getString("SEX")));
jsonObject.put("SERVICE_NO", genericUtility.checkNull(rs.getString("SERVICE_NO")));
jsonObject.put("SERVICE_TYPE", genericUtility.checkNull(rs.getString("SERVICE_TYPE")));
jsonObject.put("MOBILE_NO", genericUtility.checkNull(rs.getString("MOBILE_NO")));
jsonObject.put("ADDR1", genericUtility.checkNull(rs.getString("ADDR1")));
jsonObject.put("CITY", genericUtility.checkNull(rs.getString("CITY")));
}
}
catch(Exception e)
{
System.out.println("Exception in getDocProfileDet : "+e);
}
finally {
try
{
if(conn != null)
{
conn.close();
conn = null;
}
if(pStmt != null)
{
pStmt.close();
pStmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.out.println("Exception while closing resourse in getDocProfileDet ... "+e);
}
}
return jsonObject.toString();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment