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

To send mail to all the patients after doctor cancel the visit.

parent 189e77a5
...@@ -17,6 +17,7 @@ import org.json.simple.JSONObject; ...@@ -17,6 +17,7 @@ import org.json.simple.JSONObject;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants; import ibase.utility.CommonConstants;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.utility.EMail;
import ibase.utility.UserInfoBean; import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.DBAccessEJB; import ibase.webitm.ejb.DBAccessEJB;
...@@ -333,7 +334,7 @@ public class Appointment ...@@ -333,7 +334,7 @@ public class Appointment
String sql = ""; String sql = "";
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null;
PreparedStatement pStmt = null; PreparedStatement pStmt = null, pStmt1 = null;
ResultSet rs = null; ResultSet rs = null;
String transDB = userInfoBean.getTransDB(); String transDB = userInfoBean.getTransDB();
String userCode = userInfoBean.getLoginCode(); String userCode = userInfoBean.getLoginCode();
...@@ -344,6 +345,7 @@ public class Appointment ...@@ -344,6 +345,7 @@ public class Appointment
Timestamp fromDtTStmp = null; Timestamp fromDtTStmp = null;
Timestamp toDtTStmp = null; Timestamp toDtTStmp = null;
SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT); SimpleDateFormat output = new SimpleDateFormat(CommonConstants.APPL_DATE_FORMAT);
String updateAppt = "UPDATE APPOINTMENT SET STATUS = ? WHERE DOCTOR_CODE = ? AND VISIT_REF_NO = ? AND APPOINT_DATE BETWEEN ? AND ? ";
try try
{ {
try try
...@@ -433,7 +435,32 @@ public class Appointment ...@@ -433,7 +435,32 @@ public class Appointment
if(result.length == visitplaces.size()) if(result.length == visitplaces.size())
{ {
System.out.println("1............."); System.out.println("1............."+visitplaces);
pStmt1 = conn.prepareStatement(updateAppt);
Iterator<String> visitPLaceItr = visitplaces.iterator();
while(visitPLaceItr.hasNext())
{
lineNo = visitPLaceItr.next();
System.out.println("visitPlace .. "+lineNo);
pStmt1.setString(1, "X");
pStmt1.setString(2, userCode);
pStmt1.setString(3, lineNo);
pStmt1.setTimestamp(4, fromDtTStmp);
pStmt1.setTimestamp(5, toDtTStmp);
pStmt1.addBatch();
}
int[] updateCount = pStmt1.executeBatch();
if(updateCount.length > 0)
{
conn.commit();
System.out.println("2............."+visitplaces);
getMailFormatDetails(visitPLaceItr, "0", userCode, fromDtTStmp, toDtTStmp, userInfoBean, conn);
}
if(pStmt1 != null)
{
pStmt1.close();
pStmt1 = null;
}
} }
else else
{ {
...@@ -503,6 +530,18 @@ public class Appointment ...@@ -503,6 +530,18 @@ public class Appointment
conn.commit(); conn.commit();
errSting = genericUtility.getErrorString("SC_CODE", "VISUNAVAIL", userCode); errSting = genericUtility.getErrorString("SC_CODE", "VISUNAVAIL", userCode);
jsonObject = convertXmlToJsonInError(errSting); jsonObject = convertXmlToJsonInError(errSting);
pStmt1 = conn.prepareStatement(updateAppt);
pStmt1.setString(1, "X");
pStmt1.setString(2, userCode);
pStmt1.setString(3, lineNo);
pStmt1.setTimestamp(4, fromDtTStmp);
pStmt1.setTimestamp(5, toDtTStmp);
int updCount = pStmt1.executeUpdate();
if(updCount > 0)
{
conn.commit();
getMailFormatDetails(null, lineNo, userCode, fromDtTStmp, toDtTStmp, userInfoBean, conn);
}
} }
else else
{ {
...@@ -727,8 +766,18 @@ public class Appointment ...@@ -727,8 +766,18 @@ public class Appointment
state = jsonData.getString("state"); state = jsonData.getString("state");
city = jsonData.getString("city"); city = jsonData.getString("city");
pinCode = jsonData.getString("pinCode"); pinCode = jsonData.getString("pinCode");
try
{
dateOfBirth = output.parse(dob); dateOfBirth = output.parse(dob);
dtOfBirth = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(dob, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00"); dtOfBirth = Timestamp.valueOf(String.valueOf(this.genericUtility.getValidDateString(dob, this.genericUtility.getApplDateFormat(), this.genericUtility.getDBDateFormat())) + " 00:00:00.00");
}
catch(Exception e)
{
errString = genericUtility.getErrorString("dateOfBirth", "VTBIRTH", userId);
jsonObject = this.convertXmlToJsonInError(errString);
return jsonObject.toString();
}
if (emailId.length() == 0) if (emailId.length() == 0)
{ {
...@@ -1248,4 +1297,190 @@ public class Appointment ...@@ -1248,4 +1297,190 @@ public class Appointment
return jsonObject.toString(); return jsonObject.toString();
} }
//Added by Amey W. [ To update status of appointment when delete ] on 20-04-2020 START
@SuppressWarnings({ "static-access", "resource" })
public String updateMyApptStatusDelete(String apptId, UserInfoBean userInfoBean) {
System.out.println("apptId ::" + apptId);
System.out.println("userInfoBean ::" + userInfoBean);
String sql = "", status = "", errSting = "";
int cnt = 0;
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pStmt = null;
ResultSet rs = null;
String userCode = userInfoBean.getLoginCode();
org.json.JSONObject jsonObject = new org.json.JSONObject();
try {
String transDB = userInfoBean.getTransDB();
System.out.println("DELETE Update Status transDB :: " + transDB);
conn = connDriver.getConnectDB(transDB);
sql = "update APPOINTMENT set appoint_status = ? where APPOINT_ID = ? ";
pStmt = conn.prepareStatement(sql);
pStmt.setString(1, "X");
pStmt.setString(2, apptId);
cnt = pStmt.executeUpdate();
System.out.println("AMy Update Status Count :: " + cnt);
if (cnt > 0) {
System.out.println("AMy Update Status Count ::SSSS ");
conn.commit();
status = "Amy success";
errSting = genericUtility.getErrorString("appt_id", "VMAPPTCOMP", userCode);
jsonObject = convertXmlToJsonInError(errSting);
} else {
System.out.println("AMy Update Status Count ::FFF ");
status = "Amy fail";
}
if (pStmt != null) {
pStmt.close();
pStmt = null;
}
} catch (Exception e) {
System.out.println(
"Exception in Appointment Dashboard .DELETE.............."
+ 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 Appointment Dashboard ... " + e);
}
}
return jsonObject.toString();
}
//Added by Amey W. [ To update status of appointment when delete ] on 3-04-2020 END
public void getMailFormatDetails(Iterator<String> itr, String visitRefNo, String doctorCode,
Timestamp frDate, Timestamp toDate, UserInfoBean userInfo, Connection conn)
{
System.out.println("Appointment.getMailFormatDetails()");
String lineNo = "", apptId = "", visitPlace = "",
docName = "", apptDate = "", emailId = "";
StringBuilder builder = new StringBuilder();
PreparedStatement psmt = null;
ResultSet rs = null;
final List<String> apptIdArr = new ArrayList<String>();
final List<String> apptDateArr = new ArrayList<String>();
final List<String> visiPlaceArr = new ArrayList<String>();
final List<String> docNameArr = new ArrayList<String>();
final List<String> emailIdArr = new ArrayList<String>();
try
{
builder.append("SELECT APPT.APPOINT_ID, TO_CHAR(APPT.APPOINT_DATE, 'DD-MON-YY') APPOINT_DATE , SVH.VISIT_PLACE, PAT.EMAIL_ID ,");
builder.append("SC.FIRST_NAME || ' ' || SC.MIDDLE_NAME || ' ' || SC.LAST_NAME AS DOC_NAME ");
builder.append("FROM APPOINTMENT APPT, STRG_CUSTOMER SC, STRG_VISIT_HOURS SVH, PATIENT PAT ");
builder.append("WHERE APPT.DOCTOR_CODE = SC.SC_CODE AND APPT.PATIENT_CODE = PAT.PATIENT_CODE ");
builder.append("AND APPT.VISIT_REF_NO = SVH.LINE_NO AND APPT.DOCTOR_CODE = SVH.SC_CODE AND DOCTOR_CODE = ? ");
builder.append("AND VISIT_REF_NO = ? AND APPOINT_DATE BETWEEN ? AND ? ");
psmt = conn.prepareStatement(builder.toString());
if(itr != null)
{
while(itr.hasNext())
{
lineNo = itr.next();
psmt.setString(1, doctorCode);
psmt.setString(2, lineNo);
psmt.setTimestamp(3, frDate);
psmt.setTimestamp(4, toDate);
rs = psmt.executeQuery();
while(rs.next())
{
apptId = rs.getString("appoint_id");
visitPlace = rs.getString("visit_place");
docName = rs.getString("doc_name");
apptDate = rs.getString("appoint_date");
emailId = rs.getString("email_id");
apptIdArr.add(apptId);
visiPlaceArr.add(visitPlace);
docNameArr.add(docName);
apptDateArr.add(apptDate);
emailIdArr.add(emailId);
}
}
}
else
{
psmt.setString(1, doctorCode);
psmt.setString(2, visitRefNo);
psmt.setTimestamp(3, frDate);
psmt.setTimestamp(4, toDate);
rs = psmt.executeQuery();
while(rs.next())
{
apptId = rs.getString("appoint_id");
visitPlace = rs.getString("visit_place");
docName = rs.getString("doc_name");
apptDate = rs.getString("appoint_date");
emailId = rs.getString("email_id");
apptIdArr.add(apptId);
visiPlaceArr.add(visitPlace);
docNameArr.add(docName);
apptDateArr.add(apptDate);
emailIdArr.add(emailId);
}
}
new Thread("SendMailToPatients")
{
public void run()
{
System.out.println("apptDateArr L "+apptDateArr);
sendMail(apptIdArr, docNameArr, apptDateArr, visiPlaceArr, emailIdArr, userInfo);
};
}.start();
}
catch(Exception e)
{
System.out.println("Exception Appointment.getMailFormatDetails() : "+e);
}
}
public void sendMail(List<String> refId, List<String> docName, List<String> apptDate,
List<String> visitPlace, List<String> emailId, UserInfoBean userInfo)
{
EMail email = new EMail();
try
{
if(refId != null)
{
for (int i = 0; i < refId.size(); i++)
{
String patientMailDomStr = "<ROOT><TRANS_INFO><OBJ_NAME>APPOINTMENT</OBJ_NAME>"+
"<REF_SER>APPT</REF_SER><REF_ID>"+refId.get(i)+"</REF_ID>"+
"<LINE_NO></LINE_NO><XSL_FILE_NAME></XSL_FILE_NAME></TRANS_INFO>"+
"<MAIL><EMAIL_TYPE>page</EMAIL_TYPE><ENTITY_CODE>"+userInfo.getEntityCode()+"</ENTITY_CODE>"+ //TO DO
"<ENTITY_TYPE>"+"E"+
"</ENTITY_TYPE><SUBJECT>"+"Appointment Cancelled.</SUBJECT>"+
" <BODY_TEXT>"+"Your appotment with Dr. "+docName.get(i)+" scheduled on Date "+apptDate.get(i)+","+visitPlace.get(i)+" has been cancelled."+ "</BODY_TEXT>"+
"<TO_ADD>"+emailId.get(i)+"</TO_ADD><CC_ADD></CC_ADD>"+
"<FORMAT_CODE>"+""+"</FORMAT_CODE>"+
"<ATTACHMENT><BODY></BODY><LOCATION></LOCATION></ATTACHMENT>"+
" </MAIL><XML_DATA></XML_DATA></ROOT>";
//Changed by pankaj T. on 10-04-2020 for Configure SMTP mail server against ENTERPRISE
//email.sendMail(patientMailDomStr, "ITM", conn);
email.sendMail(patientMailDomStr, "ITM", userInfo);
}
}
}
catch(Exception e)
{
System.out.println("Exception Appointment.sendMail() : "+e);
}
}
} }
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