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

To Add validation for patient family by Saiprasad.

parent 382e1454
......@@ -9,7 +9,11 @@ import java.util.Date;
import javax.naming.InitialContext;
import org.json.simple.JSONObject;
import org.apache.poi.ss.formula.ptg.MemErrPtg;
import org.json.JSONObject;
import org.json.XML;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import ibase.system.config.AppConnectParm;
......@@ -37,9 +41,11 @@ public class PatientFamily
district = "", stanCode = "", stateCode = "", pin = "",birthDate ="",
countCode = "", tel1 = "", tel2 = "", tel3 = "", mobileNo = "",
status = "", sex = "", dob = "", serviceType = "", serviceNo = "",
name = "",memberName="",attachment="",gender ="",
name = "",memberName="",attachment="",gender ="",errSting = "",
relation ="",familyMobileNo="",birthDateStr="",attachmentDbValue = "";
JSONObject jsonObject = new JSONObject();
E12GenericUtility genericUtility = new E12GenericUtility();
Timestamp birtDateTstmp = null;
try {
SimpleDateFormat sdfAngularFormat = new SimpleDateFormat("dd-MM-yyyy");
......@@ -115,14 +121,95 @@ public class PatientFamily
//JSONObject json = (JSONObject) parser.parse(data);
System.out.println("##json object data"+data);
memberName = (String) data.get("name");
gender= (String) data.get("gender");
birthDate = (String) data.get("dateOfBirth");
memberName = data.getString("name");
gender= data.getString("gender");
birthDate = E12GenericUtility.checkNull(data.getString("dateOfBirth"));
System.out.println("###birthDate:"+birthDate);
attachment = (String) data.get("attachment");
relation = (String) data.get("relation");
familyMobileNo = (String) data.get("mobileNo");
attachment = data.getString("attachment");
relation = data.getString("relation");
familyMobileNo = data.getString("mobileNo");
Date date= new Date();
long time = date.getTime();
try
{
birtDateTstmp= Timestamp.valueOf(String.valueOf(genericUtility.getValidDateString(birthDate, genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())) + " 00:00:00.00");
}
catch(Exception e)
{
errSting = genericUtility.getErrorString("dateOfBirth", "VTBIRTH", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
Timestamp currTimeStamp = new Timestamp(time);
if("".equalsIgnoreCase(memberName))
{
System.out.println("memberName"+memberName);
errSting = genericUtility.getErrorString("name", "VTMENAME", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
System.out.println("######retStr"+retstr);
return retstr;
}
else if( "".equalsIgnoreCase(birthDate) )
{
try
{
birtDateTstmp= Timestamp.valueOf(String.valueOf(genericUtility.getValidDateString(birthDate, genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat())) + " 00:00:00.00");
errSting = genericUtility.getErrorString("dateOfBirth", "VTBIRTH", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
catch(Exception e)
{
errSting = genericUtility.getErrorString("dateOfBirth", "VTBIRTH", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
}
else if(birtDateTstmp.after(currTimeStamp))
{
errSting = genericUtility.getErrorString("dateOfBirth", "INVBRTHDAY", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
else if("".equalsIgnoreCase(gender))
{
errSting = genericUtility.getErrorString("gender", "VTGENDER", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
else if("".equalsIgnoreCase(relation))
{
errSting = genericUtility.getErrorString("relation", "VTRELATION", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
else if("".equalsIgnoreCase(familyMobileNo))
{
errSting = genericUtility.getErrorString("mobileNo", "VTMOBILE", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
else if(familyMobileNo.length()< 10 || familyMobileNo.length() > 10)
{
errSting = genericUtility.getErrorString("mobileNo", "VTMOBNO1", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
return retstr;
}
else
{
System.out.println("#####retstr"+retstr);
System.out.println("birth date in the db format TESTING:"+birthDateStr);
AppConnectParm appConnect = new AppConnectParm();
......@@ -228,6 +315,11 @@ public class PatientFamily
masterStateful = (MasterStatefulRemote) ctx.lookup("ibase/MasterStatefulEJB/remote");
retstr = masterStateful.processRequest(userInfoBean.toString(), xmlString.toString(), false, null);
errSting = genericUtility.getErrorString("", "VTCONPARM", userId);
jsonObject = this.convertXmlToJsonInError(errSting);
retstr = jsonObject.toString();
}
BaseLogger.log("3",userInfoBean,null,"retstr" + retstr);
} catch (Exception e) {
......@@ -242,5 +334,30 @@ public class PatientFamily
}
return retstr;
}
public org.json.JSONObject convertXmlToJsonInError(String xmlString)
{
org.json.JSONObject jsonObject = new org.json.JSONObject();
try
{
org.json.JSONObject obj = XML.toJSONObject(xmlString);
org.json.JSONObject root = obj.getJSONObject("Root");
org.json.JSONObject Errors = root.getJSONObject("Errors");
org.json.JSONObject error = Errors.getJSONObject("error");
String trace = error.getString("trace");
String columnName = error.getString("column_name");
String description = error.getString("description");
org.json.JSONArray jsonArraytype = error.getJSONArray("type");
String type = jsonArraytype.getString(1);
System.out.println("trace"+trace+"\t column_name"+columnName+"\t description"+description+"\t type:"+type);
jsonObject.put("trace", trace);
jsonObject.put("column_name", columnName);
jsonObject.put("description", description);
jsonObject.put("type", type);
}
catch (Exception e)
{
System.out.println("SellsStock.convertXmlToJsonInError()"+e);
}
return jsonObject;
}
}
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