From a70d9a216ce59d5cef380104c5cd543cd39cbb1a Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Mon, 4 Nov 2024 20:47:31 +0530
Subject: [PATCH 1/7] missed file

---
 .../common/repo/customization/SectionAndFieldsMappingRepo.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/main/java/com/iemr/common/repo/customization/SectionAndFieldsMappingRepo.java b/src/main/java/com/iemr/common/repo/customization/SectionAndFieldsMappingRepo.java
index 038e34ef..e58f220b 100644
--- a/src/main/java/com/iemr/common/repo/customization/SectionAndFieldsMappingRepo.java
+++ b/src/main/java/com/iemr/common/repo/customization/SectionAndFieldsMappingRepo.java
@@ -16,8 +16,7 @@ public interface SectionAndFieldsMappingRepo extends CrudRepository<SectionAndFi
 //	List<SectionAndFieldsMapping> findBySectionIdAndSectionNameAndServiceProviderId(
 //			@Param("sectionId") Integer sectionId, @Param("serviceProviderId") Integer serviceProviderId);
 
-
-	@Query("SELECT sfm FROM SectionAndFieldsMapping sfm WHERE sfm.fieldName = :fieldName AND (sfm.serviceProviderId = :serviceProviderId OR sfm.serviceProviderId = 0) AND (sfm.projectId = :projectId OR sfm.projectId = 0)")
+	@Query("SELECT sfm FROM SectionAndFieldsMapping sfm WHERE sfm.sectionId = :sectionId AND (sfm.serviceProviderId = :serviceProviderId OR sfm.serviceProviderId= 0) AND (sfm.projectId = :projectId OR sfm.projectId= 0)")
 	List<SectionAndFieldsMapping> findSectionIdAndSectionNameAndServiceProviderId(
 			@Param("sectionId") Integer sectionId, @Param("serviceProviderId") Integer serviceProviderId, @Param("projectId") Integer projectId);
 	

From 76f1d39c256b5f5bf112872d9189deb42985929f Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Mon, 18 Nov 2024 10:01:44 +0530
Subject: [PATCH 2/7] FieldName Patching

---
 .../java/com/iemr/common/dto/identity/BeneficiariesDTO.java    | 2 +-
 .../java/com/iemr/common/dto/identity/IdentityEditDTO.java     | 1 +
 .../com/iemr/common/model/beneficiary/BeneficiaryModel.java    | 3 ++-
 .../common/service/beneficiary/IEMRSearchUserServiceImpl.java  | 2 ++
 .../service/beneficiary/RegisterBenificiaryServiceImpl.java    | 1 +
 5 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/iemr/common/dto/identity/BeneficiariesDTO.java b/src/main/java/com/iemr/common/dto/identity/BeneficiariesDTO.java
index 18c498c4..c2aeef35 100644
--- a/src/main/java/com/iemr/common/dto/identity/BeneficiariesDTO.java
+++ b/src/main/java/com/iemr/common/dto/identity/BeneficiariesDTO.java
@@ -78,7 +78,7 @@ public class BeneficiariesDTO {
 	private String otherFields;
 	private String genderName;
 	private String maritalStatusName;
-
+	private String community;
 	// End Outreach
 
 	// Start 1097
diff --git a/src/main/java/com/iemr/common/dto/identity/IdentityEditDTO.java b/src/main/java/com/iemr/common/dto/identity/IdentityEditDTO.java
index e0ddde39..44cd0a88 100644
--- a/src/main/java/com/iemr/common/dto/identity/IdentityEditDTO.java
+++ b/src/main/java/com/iemr/common/dto/identity/IdentityEditDTO.java
@@ -168,4 +168,5 @@ public class IdentityEditDTO {
 	private boolean emergencyRegistration;
 	private String otherFields;
 //	private Object otherFields;
+	private String communityName;
 }
diff --git a/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java b/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
index 800db14e..45064f55 100644
--- a/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
+++ b/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
@@ -280,7 +280,8 @@ public class BeneficiaryModel implements Comparable<BeneficiaryModel> {
 	private String monthlyFamilyIncome;
 	@Expose
 	private boolean emergencyRegistration;
-	
+	@Expose
+	private String communityName;
 	@Expose
 	private Boolean passToNurse = false;
 	private String otherFields;
diff --git a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
index ba0b1872..2936dac0 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
@@ -372,6 +372,8 @@ public List<BeneficiaryModel> getBeneficiaryListFromMapper(List<BeneficiariesDTO
 		benDetailForOutboundDTOList.forEach(beneficiaryModel -> {
 
 			BeneficiaryModel beneficiary = benCompleteMapper.benDetailForOutboundDTOToIBeneficiary(beneficiaryModel);
+			if(null != beneficiaryModel.getBeneficiaryDetails().getCommunity())
+				beneficiary.setCommunityName(beneficiaryModel.getBeneficiaryDetails().getCommunity());
 			if (beneficiary.getAge() == null) {
 				beneficiary.setAge(beneficiary.getActualAge());
 			}
diff --git a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
index 06f67a61..1580a4c8 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
@@ -114,6 +114,7 @@ public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String aut
 		Integer updatedRows = 0;
 
 		IdentityEditDTO identityEditDTO = identityBenEditMapper.BenToIdentityEditMapper(benificiaryDetails);
+		identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName());
 		if (benificiaryDetails.getBeneficiaryIdentities() != null
 				&& benificiaryDetails.getBeneficiaryIdentities().size() > 0) {
 			identityEditDTO.setIdentities(Identity.createIdentity(benificiaryDetails.getBeneficiaryIdentities(),

From 01e98714014fc9151d994c603ebb6db8836fb960 Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Mon, 18 Nov 2024 10:21:40 +0530
Subject: [PATCH 3/7] Null Conditions added

---
 .../common/service/beneficiary/IEMRSearchUserServiceImpl.java  | 2 +-
 .../service/beneficiary/RegisterBenificiaryServiceImpl.java    | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
index 2936dac0..8432d7e7 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
@@ -372,7 +372,7 @@ public List<BeneficiaryModel> getBeneficiaryListFromMapper(List<BeneficiariesDTO
 		benDetailForOutboundDTOList.forEach(beneficiaryModel -> {
 
 			BeneficiaryModel beneficiary = benCompleteMapper.benDetailForOutboundDTOToIBeneficiary(beneficiaryModel);
-			if(null != beneficiaryModel.getBeneficiaryDetails().getCommunity())
+			if(null != beneficiaryModel.getBeneficiaryDetails() && null != beneficiaryModel.getBeneficiaryDetails().getCommunity())
 				beneficiary.setCommunityName(beneficiaryModel.getBeneficiaryDetails().getCommunity());
 			if (beneficiary.getAge() == null) {
 				beneficiary.setAge(beneficiary.getActualAge());
diff --git a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
index 1580a4c8..e591d1f6 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
@@ -114,7 +114,8 @@ public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String aut
 		Integer updatedRows = 0;
 
 		IdentityEditDTO identityEditDTO = identityBenEditMapper.BenToIdentityEditMapper(benificiaryDetails);
-		identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName());
+		if(null != benificiaryDetails.getI_bendemographics())
+			identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName());
 		if (benificiaryDetails.getBeneficiaryIdentities() != null
 				&& benificiaryDetails.getBeneficiaryIdentities().size() > 0) {
 			identityEditDTO.setIdentities(Identity.createIdentity(benificiaryDetails.getBeneficiaryIdentities(),

From 2ee0d956704082fe10b6f8c7f3780e70d8f0c8bb Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Wed, 11 Dec 2024 14:00:11 +0530
Subject: [PATCH 4/7] Update beneficiary

---
 .../service/beneficiary/IdentityBeneficiaryServiceImpl.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
index 6fe48620..4273ba7e 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
@@ -30,6 +30,7 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
+import com.google.gson.Gson;
 import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -420,7 +421,7 @@ public Integer editIdentityEditDTO(IdentityEditDTO identityEditDTO, String auth,
 		JsonParser parser = new JsonParser();
 
 		String result;
-		String requestBody = OutputMapper.gsonWithoutExposeRestriction().toJson(identityEditDTO);
+		String requestBody = new Gson().toJson(identityEditDTO);
 		HashMap<String, Object> header = new HashMap<>();
 		if (auth != null) {
 			header.put("Authorization", auth);

From f6fb441a51f8cb75a327e7b523e87eaefc39c7b6 Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Wed, 11 Dec 2024 14:00:45 +0530
Subject: [PATCH 5/7] update

---
 .../service/beneficiary/RegisterBenificiaryServiceImpl.java   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
index e591d1f6..5a3cec87 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
@@ -114,8 +114,10 @@ public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String aut
 		Integer updatedRows = 0;
 
 		IdentityEditDTO identityEditDTO = identityBenEditMapper.BenToIdentityEditMapper(benificiaryDetails);
-		if(null != benificiaryDetails.getI_bendemographics())
+		if(null != benificiaryDetails.getI_bendemographics()) {
 			identityEditDTO.setCommunity(benificiaryDetails.getI_bendemographics().getCommunityName());
+			identityEditDTO.setCommunityName(benificiaryDetails.getI_bendemographics().getCommunityName());
+		}
 		if (benificiaryDetails.getBeneficiaryIdentities() != null
 				&& benificiaryDetails.getBeneficiaryIdentities().size() > 0) {
 			identityEditDTO.setIdentities(Identity.createIdentity(benificiaryDetails.getBeneficiaryIdentities(),

From 9ab8472d3192be14aa03bcca8816fcff949586cd Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Wed, 11 Dec 2024 15:46:18 +0530
Subject: [PATCH 6/7] Update

---
 .../beneficiary/IdentityBeneficiaryServiceImpl.java |  2 +-
 .../com/iemr/common/service/sms/SMSServiceImpl.java | 13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
index 4273ba7e..697322c6 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/IdentityBeneficiaryServiceImpl.java
@@ -421,7 +421,7 @@ public Integer editIdentityEditDTO(IdentityEditDTO identityEditDTO, String auth,
 		JsonParser parser = new JsonParser();
 
 		String result;
-		String requestBody = new Gson().toJson(identityEditDTO);
+		String requestBody = OutputMapper.gsonWithoutExposeRestriction().toJson(identityEditDTO);
 		HashMap<String, Object> header = new HashMap<>();
 		if (auth != null) {
 			header.put("Authorization", auth);
diff --git a/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java b/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
index 726862ca..c9ce6ef8 100644
--- a/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
@@ -801,8 +801,9 @@ private static String getSubstringInRange(String input, int startIndex, int endI
 	@Override
 	public void publishSMS() {
 		RestTemplate restTemplateLogin = new RestTemplate();
-		if (!SMSServiceImpl.publishingSMS) {
-			try {
+
+		try {
+			if (!SMSServiceImpl.publishingSMS) {
 				SMSServiceImpl.publishingSMS = true;
 				Boolean doSendSMS = ConfigProperties.getBoolean("send-sms");
 				String sendSMSURL = ConfigProperties.getPropertyByName("send-message-url");
@@ -875,11 +876,11 @@ public void publishSMS() {
 						sms = smsNotification.save(sms);
 					}
 				}
-			} catch (Exception e) {
-				logger.error("publishSMS failed with error " + e.getMessage());
-			} finally {
-				SMSServiceImpl.publishingSMS = false;
 			}
+		} catch (Exception e) {
+			logger.error("publishSMS failed with error " + e.getMessage());
+		} finally {
+			SMSServiceImpl.publishingSMS = false;
 		}
 	}
 

From 2447cd4a181b63b5925b350be96197062ca04fba Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Thu, 12 Dec 2024 18:08:28 +0530
Subject: [PATCH 7/7] community changes

---
 .../service/beneficiary/RegisterBenificiaryServiceImpl.java    | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
index 5a3cec87..2c675f51 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
@@ -145,6 +145,9 @@ public String save(BeneficiaryModel beneficiaryModel, HttpServletRequest servlet
 		// logger.info("benificiaryDetails: " + beneficiaryModel);
 
 		CommonIdentityDTO identityDTO = identityMapper.beneficiaryModelCommonIdentityDTO(beneficiaryModel);
+		if(null != beneficiaryModel.getI_bendemographics()) {
+			identityDTO.setCommunity(beneficiaryModel.getI_bendemographics().getCommunityName());
+		}
 		// identityDTO.setOtherFields(beneficiaryModel.getOtherFields());
 		identityDTO.setFaceEmbedding(beneficiaryModel.getFaceEmbedding());
 		identityDTO.setEmergencyRegistration(beneficiaryModel.isEmergencyRegistration());
