From 70aba1ad0b2c79d2991542c395ae5374c8f71c15 Mon Sep 17 00:00:00 2001
From: Mukul Chajed <mu20340836@wipro.com>
Date: Fri, 30 Jun 2023 09:46:59 +0530
Subject: [PATCH 1/2] CreatedDate filed for Identity

---
 .../identity/domain/MBeneficiaryAccount.java  |  2 +-
 .../identity/domain/MBeneficiaryImage.java    |  2 +-
 .../identity/domain/MBeneficiaryaddress.java  |  2 +-
 .../identity/domain/MBeneficiaryconsent.java  |  2 +-
 .../identity/domain/MBeneficiarycontact.java  |  2 +-
 .../identity/domain/MBeneficiarydetail.java   |  2 +-
 .../identity/domain/MBeneficiarymapping.java  |  2 +-
 .../domain/MBeneficiaryregidmapping.java      |  2 +-
 .../iemr/common/identity/dto/IdentityDTO.java |  1 +
 .../identity/mapper/IdentityMapper.java       | 17 +++---
 .../identity/service/IdentityService.java     | 57 +++++++++++++++++++
 11 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryAccount.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryAccount.java
index eedd6f38..e5c89bad 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryAccount.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryAccount.java
@@ -66,7 +66,7 @@ public class MBeneficiaryAccount {
 	@Column(name = "CreatedBy", length = 50, updatable = false)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
 	private Timestamp createdDate;
 
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryImage.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryImage.java
index a762f64d..aaa29a35 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryImage.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryImage.java
@@ -53,7 +53,7 @@ public class MBeneficiaryImage {
 	private String processed;
 	@Column(name = "CreatedBy", updatable = false)
 	private String createdBy;
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
 	private Timestamp createdDate;
 	@Column(name = "Reserved")
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryaddress.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryaddress.java
index 3a3a8f99..c2d163e9 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryaddress.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryaddress.java
@@ -56,7 +56,7 @@ public class MBeneficiaryaddress implements Serializable {
 	@Column(nullable = false, length = 50)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	@Column(length = 50)
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryconsent.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryconsent.java
index 9ca86f44..dc03f1e4 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryconsent.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryconsent.java
@@ -56,7 +56,7 @@ public class MBeneficiaryconsent implements Serializable {
 	@Column(nullable = false, length = 50)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	private Boolean deleted = false;
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiarycontact.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiarycontact.java
index 7850e137..ee5e745d 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiarycontact.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiarycontact.java
@@ -58,7 +58,7 @@ public class MBeneficiarycontact implements Serializable {
 	@Column(nullable = false, length = 50, updatable = false)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	private Boolean deleted = false;
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java
index f9bd7858..e5017ff1 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiarydetail.java
@@ -70,7 +70,7 @@ public class MBeneficiarydetail implements Serializable {
 	@Column(nullable = false, length = 50, updatable = false)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	private Boolean deleted = false;
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiarymapping.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiarymapping.java
index 944df5c7..0e8e5bd3 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiarymapping.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiarymapping.java
@@ -61,7 +61,7 @@ public class MBeneficiarymapping implements Serializable {
 	@Column(nullable = false, length = 50)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	@Column(nullable = false)
diff --git a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryregidmapping.java b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryregidmapping.java
index 0e15dfcd..8dc86918 100644
--- a/src/main/java/com/iemr/common/identity/domain/MBeneficiaryregidmapping.java
+++ b/src/main/java/com/iemr/common/identity/domain/MBeneficiaryregidmapping.java
@@ -59,7 +59,7 @@ public class MBeneficiaryregidmapping implements Serializable {
 	@Column(length = 30)
 	private String createdBy;
 
-	@Column(name = "CreatedDate", insertable = false, updatable = false)
+	@Column(name = "CreatedDate")
 	private Timestamp createdDate;
 
 	private Boolean deleted = false;
diff --git a/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java b/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java
index 590bbfa3..9d268130 100644
--- a/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java
+++ b/src/main/java/com/iemr/common/identity/dto/IdentityDTO.java
@@ -47,6 +47,7 @@ public class IdentityDTO {
 	private Integer stateId;
 	private String stateName;
 	private Integer providerServiceMapId;
+	private Timestamp createdDate;
 
 	private Integer areaId;
 	private Integer beneficiaryId;
diff --git a/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java b/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java
index aaa690cb..32aa198f 100644
--- a/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java
+++ b/src/main/java/com/iemr/common/identity/mapper/IdentityMapper.java
@@ -56,7 +56,7 @@ public interface IdentityMapper {
 	IdentityMapper INSTANCE = Mappers.getMapper(IdentityMapper.class);
 
 	@Mappings({ @Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			// new mapping added for data sync(van ID & parking place ID)
 			// 17-09-2018
 			@Mapping(source = "dto.vanID", target = "vanID"),
@@ -112,7 +112,8 @@ public interface IdentityMapper {
 			@Mapping(source = "dto.permanentAddress.addressValue", target = "permAddressValue"),
 			@Mapping(source = "dto.permanentAddress.pinCode", target = "permPinCode"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			//@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 
 			/*
 			 * New columns added for MMU integration 09-04-2018
@@ -168,7 +169,7 @@ public interface IdentityMapper {
 			@Mapping(source = "defaultNo", target = "sharePersonalDetailsWithNGO"),
 			@Mapping(source = "defaultYes", target = "sharePersonalDetailsWithSpouse"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			// new mapping added for data sync(van ID & parking place ID)
 			// 17-09-2018
 			@Mapping(source = "dto.vanID", target = "vanID"),
@@ -196,7 +197,7 @@ public interface IdentityMapper {
 			@Mapping(source = "dto.contact.phoneTyp5", target = "phoneTyp5"),
 			@Mapping(source = "dto.preferredEmailId", target = "emailId"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			// new mapping added for data sync(van ID & parking place ID)
 			// 17-09-2018
 			@Mapping(source = "dto.vanID", target = "vanID"),
@@ -239,7 +240,7 @@ public interface IdentityMapper {
 			@Mapping(source = "dto.status", target = "status"), @Mapping(source = "dto.title", target = "title"),
 			@Mapping(source = "dto.titleId", target = "titleId"), @Mapping(source = "dto.zoneId", target = "zoneId"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			@Mapping(target = "isHIVPositive", expression = "java(MBeneficiarydetail.setIsHIVPositive(dto.getIsHIVPositive()))"),
 			// Start MMU specific code
 			@Mapping(target = "ageAtMarriage", expression = "java(MBeneficiarydetail.getAgeAtMarriageCalc(dto.getDob(), dto.getMarriageDate(), "
@@ -293,7 +294,7 @@ MBeneficiaryfamilymapping identityDTOToMBeneficiaryfamilymapping(BenFamilyDTO be
 			@Mapping(source = "dto.agentName", target = "registeredByName"),
 			@Mapping(source = "dto.eventTypeDate", target = "registeredDate"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			@Mapping(source = "dto.vanID", target = "vanID"),
 			@Mapping(source = "dto.parkingPlaceId", target = "parkingPlaceID") })
 	MBeneficiaryservicemapping identityDTOToMBeneficiaryservicemapping(IdentityDTO dto);
@@ -583,7 +584,7 @@ List<BenFamilyDTO> mapToMBeneficiaryfamilymappingWithBenFamilyDTOList(
 			@Mapping(source = "dto.ifscCode", target = "ifscCode"),
 			@Mapping(source = "dto.accountNo", target = "accountNo"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			@Mapping(source = "dto.vanID", target = "vanID"),
 			@Mapping(source = "dto.parkingPlaceId", target = "parkingPlaceID"),
 			// End
@@ -595,7 +596,7 @@ List<BenFamilyDTO> mapToMBeneficiaryfamilymappingWithBenFamilyDTOList(
 
 	@Mappings({ @Mapping(source = "dto.benImage", target = "benImage"),
 			@Mapping(source = "dto.agentName", target = "createdBy"),
-			@Mapping(source = "dto.eventTypeDate", target = "createdDate"),
+			@Mapping(source = "dto.createdDate", target = "createdDate"),
 			// new mapping added for data sync(van ID & parking place ID)
 			// 17-09-2018
 			@Mapping(source = "dto.vanID", target = "vanID"),
diff --git a/src/main/java/com/iemr/common/identity/service/IdentityService.java b/src/main/java/com/iemr/common/identity/service/IdentityService.java
index 9f925f64..66870612 100644
--- a/src/main/java/com/iemr/common/identity/service/IdentityService.java
+++ b/src/main/java/com/iemr/common/identity/service/IdentityService.java
@@ -24,8 +24,11 @@
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.ListIterator;
@@ -937,6 +940,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 			regMap = queue.removeFirst();
 		}
 		regMap.setReserved(true);
+		if(regMap.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    regMap.setCreatedDate(ts);
+			}
 
 		regIdRepo.save(regMap);
 
@@ -967,6 +976,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 			logger.debug("identity.getPermanentAddress = " + identity.getPermanentAddress());
 			mAddr.setEmergencyAddress(identity.getPermanentAddress());
 		}
+		if(mAddr.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    mAddr.setCreatedDate(ts);
+			}
 
 		mAddr = addressRepo.save(mAddr);
 		logger.info("IdentityService.createIdentity - Address saved - id = " + mAddr.getBenAddressID());
@@ -976,6 +991,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		MBeneficiaryconsent mConsnt = mapper.identityDTOToDefaultMBeneficiaryconsent(identity, true, false);
 		logger.info("IdentityService.createIdentity - saving Consent");
+		if(mConsnt.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    mConsnt.setCreatedDate(ts);
+			}
 		mConsnt = consentRepo.save(mConsnt);
 		logger.info("IdentityService.createIdentity - Consent saved - id = " + mConsnt.getBenConsentID());
 
@@ -984,6 +1005,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		logger.info("IdentityService.createIdentity - saving Contacts");
 		MBeneficiarycontact mContc = mapper.identityDTOToMBeneficiarycontact(identity);
+		if(mContc.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    mContc.setCreatedDate(ts);
+			}
 		mContc = contactRepo.save(mContc);
 		logger.info("IdentityService.createIdentity - Contacts saved - id = " + mContc.getBenContactsID());
 
@@ -992,6 +1019,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		logger.info("IdentityService.createIdentity - saving Details");
 		MBeneficiarydetail mDetl = mapper.identityDTOToMBeneficiarydetail(identity);
+		if(mDetl.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    mDetl.setCreatedDate(ts);
+			}
 		mDetl = detailRepo.save(mDetl);
 		logger.info("IdentityService.createIdentity - Details saved - id = " + mDetl.getBeneficiaryDetailsId());
 
@@ -999,11 +1032,23 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		int i3 = detailRepo.updateVanSerialNo(mDetl.getBeneficiaryDetailsId());
 
 		MBeneficiaryAccount bankOBJ = mapper.identityDTOToMBeneficiaryAccount(identity);
+		if(bankOBJ.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    bankOBJ.setCreatedDate(ts);
+			}
 		bankOBJ = accountRepo.save(bankOBJ);
 		// Update van serial no for data sync
 		int i4 = accountRepo.updateVanSerialNo(bankOBJ.getBenAccountID());
 
 		MBeneficiaryImage benImageOBJ = mapper.identityDTOToMBeneficiaryImage(identity);
+		if(benImageOBJ.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    benImageOBJ.setCreatedDate(ts);
+			}
 		benImageOBJ = imageRepo.save(benImageOBJ);
 
 		// Update van serial no for data sync
@@ -1031,6 +1076,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		// END
 
 		regIdRepo.save(regMap);
+		if(benMapping.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    benMapping.setCreatedDate(ts);
+			}
 
 		benMapping = mappingRepo.save(benMapping);
 		// Update van serial no for data sync
@@ -1073,6 +1124,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		logger.info("IdentityService.createIdentity - saving Service Map");
 		MBeneficiaryservicemapping sMap = mapper.identityDTOToMBeneficiaryservicemapping(identity);
 		sMap.setBenMapId(benMapping.getBenMapId());
+		if(sMap.getCreatedDate()==null) {
+		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
+		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
+		    sMap.setCreatedDate(ts);
+			}
 		sMap = serviceMapRepo.save(sMap);
 		logger.info("IdentityService.createIdentity - ServiceMap saved  - id = " + sMap.getBenServiceMapID());
 

From b68827fba157e530feafd501d9ee960bae66a8ad Mon Sep 17 00:00:00 2001
From: Mukul Chajed <mu20340836@wipro.com>
Date: Fri, 30 Jun 2023 17:27:28 +0530
Subject: [PATCH 2/2] removed uncommented code

---
 .../identity/service/IdentityService.java     | 108 +++++++++---------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/src/main/java/com/iemr/common/identity/service/IdentityService.java b/src/main/java/com/iemr/common/identity/service/IdentityService.java
index 66870612..afb951ed 100644
--- a/src/main/java/com/iemr/common/identity/service/IdentityService.java
+++ b/src/main/java/com/iemr/common/identity/service/IdentityService.java
@@ -940,12 +940,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 			regMap = queue.removeFirst();
 		}
 		regMap.setReserved(true);
-		if(regMap.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    regMap.setCreatedDate(ts);
-			}
+		if (regMap.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			regMap.setCreatedDate(ts);
+		}
 
 		regIdRepo.save(regMap);
 
@@ -976,12 +976,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 			logger.debug("identity.getPermanentAddress = " + identity.getPermanentAddress());
 			mAddr.setEmergencyAddress(identity.getPermanentAddress());
 		}
-		if(mAddr.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    mAddr.setCreatedDate(ts);
-			}
+		if (mAddr.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			mAddr.setCreatedDate(ts);
+		}
 
 		mAddr = addressRepo.save(mAddr);
 		logger.info("IdentityService.createIdentity - Address saved - id = " + mAddr.getBenAddressID());
@@ -991,12 +991,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		MBeneficiaryconsent mConsnt = mapper.identityDTOToDefaultMBeneficiaryconsent(identity, true, false);
 		logger.info("IdentityService.createIdentity - saving Consent");
-		if(mConsnt.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    mConsnt.setCreatedDate(ts);
-			}
+		if (mConsnt.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			mConsnt.setCreatedDate(ts);
+		}
 		mConsnt = consentRepo.save(mConsnt);
 		logger.info("IdentityService.createIdentity - Consent saved - id = " + mConsnt.getBenConsentID());
 
@@ -1005,12 +1005,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		logger.info("IdentityService.createIdentity - saving Contacts");
 		MBeneficiarycontact mContc = mapper.identityDTOToMBeneficiarycontact(identity);
-		if(mContc.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    mContc.setCreatedDate(ts);
-			}
+		if (mContc.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			mContc.setCreatedDate(ts);
+		}
 		mContc = contactRepo.save(mContc);
 		logger.info("IdentityService.createIdentity - Contacts saved - id = " + mContc.getBenContactsID());
 
@@ -1019,12 +1019,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 
 		logger.info("IdentityService.createIdentity - saving Details");
 		MBeneficiarydetail mDetl = mapper.identityDTOToMBeneficiarydetail(identity);
-		if(mDetl.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    mDetl.setCreatedDate(ts);
-			}
+		if (mDetl.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			mDetl.setCreatedDate(ts);
+		}
 		mDetl = detailRepo.save(mDetl);
 		logger.info("IdentityService.createIdentity - Details saved - id = " + mDetl.getBeneficiaryDetailsId());
 
@@ -1032,23 +1032,23 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		int i3 = detailRepo.updateVanSerialNo(mDetl.getBeneficiaryDetailsId());
 
 		MBeneficiaryAccount bankOBJ = mapper.identityDTOToMBeneficiaryAccount(identity);
-		if(bankOBJ.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    bankOBJ.setCreatedDate(ts);
-			}
+		if (bankOBJ.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			bankOBJ.setCreatedDate(ts);
+		}
 		bankOBJ = accountRepo.save(bankOBJ);
 		// Update van serial no for data sync
 		int i4 = accountRepo.updateVanSerialNo(bankOBJ.getBenAccountID());
 
 		MBeneficiaryImage benImageOBJ = mapper.identityDTOToMBeneficiaryImage(identity);
-		if(benImageOBJ.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    benImageOBJ.setCreatedDate(ts);
-			}
+		if (benImageOBJ.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			benImageOBJ.setCreatedDate(ts);
+		}
 		benImageOBJ = imageRepo.save(benImageOBJ);
 
 		// Update van serial no for data sync
@@ -1076,12 +1076,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		// END
 
 		regIdRepo.save(regMap);
-		if(benMapping.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    benMapping.setCreatedDate(ts);
-			}
+		if (benMapping.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			benMapping.setCreatedDate(ts);
+		}
 
 		benMapping = mappingRepo.save(benMapping);
 		// Update van serial no for data sync
@@ -1124,12 +1124,12 @@ public BeneficiaryCreateResp createIdentity(IdentityDTO identity) throws IEMRExc
 		logger.info("IdentityService.createIdentity - saving Service Map");
 		MBeneficiaryservicemapping sMap = mapper.identityDTOToMBeneficiaryservicemapping(identity);
 		sMap.setBenMapId(benMapping.getBenMapId());
-		if(sMap.getCreatedDate()==null) {
-		    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
-		    String DateToStoreInDataBase= sdf.format(new Date()); // java.util.Date
-		    Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase); // java.sql.Timestamp
-		    sMap.setCreatedDate(ts);
-			}
+		if (sMap.getCreatedDate() == null) {
+			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
+			String DateToStoreInDataBase = sdf.format(new Date());
+			Timestamp ts = Timestamp.valueOf(DateToStoreInDataBase);
+			sMap.setCreatedDate(ts);
+		}
 		sMap = serviceMapRepo.save(sMap);
 		logger.info("IdentityService.createIdentity - ServiceMap saved  - id = " + sMap.getBenServiceMapID());
 
