From 013f6c27cf52b7c6bfc19d52b2d184921fe74812 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Wed, 27 Sep 2023 14:56:25 +0530
Subject: [PATCH 01/23] Biometric changes

---
 pom.xml                                       |  12 +
 src/main/environment/common_test.properties   |   4 +
 .../biometric/BiometricController.java        |  42 ++++
 .../service/biometric/BiometricService.java   |   7 +
 .../biometric/BiometricServiceImpl.java       | 229 ++++++++++++++++++
 5 files changed, 294 insertions(+)
 create mode 100644 src/main/java/com/iemr/common/controller/biometric/BiometricController.java
 create mode 100644 src/main/java/com/iemr/common/service/biometric/BiometricService.java
 create mode 100644 src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java

diff --git a/pom.xml b/pom.xml
index 8ff8d6e6..131f6f11 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,6 +49,18 @@
 	</repositories>
 	<dependencies>
 
+		<dependency>
+		<groupId>org.apache.httpcomponents</groupId>
+		<artifactId>httpclient</artifactId>
+		
+		</dependency>
+		<!-- https://mvnrepository.com/artifact/xmlpull/xmlpull -->
+<dependency>
+    <groupId>xmlpull</groupId>
+    <artifactId>xmlpull</artifactId>
+    <version>1.1.3.1</version>
+</dependency>
+
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter</artifactId>
diff --git a/src/main/environment/common_test.properties b/src/main/environment/common_test.properties
index 57e182b6..dba62e8b 100644
--- a/src/main/environment/common_test.properties
+++ b/src/main/environment/common_test.properties
@@ -97,3 +97,7 @@ avniRegistrationLimit=7
 nhm.agent.real.time.data.url= http://175.101.1.83/apps/utility/alive_api.php
 nhm.agent.real.time.data.cron.scheduler=0 */2 * ? * *
 nhm.agent.real.time.data.cron.flag=true
+
+biometric.discover.url = http://127.0.0.1:port/
+biometric.deviceInfo.url = https://127.0.0.1:port/rd/info
+biometric.capture.url = https://127.0.0.1:port/rd/capture
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
new file mode 100644
index 00000000..fa41e914
--- /dev/null
+++ b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
@@ -0,0 +1,42 @@
+package com.iemr.common.controller.biometric;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestHeader;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+ 
+
+import com.iemr.common.service.biometric.BiometricService;
+import com.iemr.common.utils.response.OutputResponse;
+
+ 
+
+import io.swagger.annotations.ApiOperation;
+
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/biometric")
+public class BiometricController {
+	private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
+	@Autowired
+	private BiometricService biometricService;
+	@CrossOrigin
+	@RequestMapping(value = { "/getBiometricData/{pid}" }, method = { RequestMethod.GET })
+	public OutputResponse saveBenNurseDataCAC(@RequestParam String pid) {
+		OutputResponse response = new OutputResponse();
+		try {
+			String pidResponse = biometricService.getBioData(pid);
+			response.setResponse(pidResponse);
+		}catch (Exception e) {
+			logger.error("Error while fetching Biometric data : "+e.getMessage());
+		}
+		return response;
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricService.java b/src/main/java/com/iemr/common/service/biometric/BiometricService.java
new file mode 100644
index 00000000..af3d400d
--- /dev/null
+++ b/src/main/java/com/iemr/common/service/biometric/BiometricService.java
@@ -0,0 +1,7 @@
+package com.iemr.common.service.biometric;
+
+public interface BiometricService {
+
+	String getBioData(String pid);
+
+}
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
new file mode 100644
index 00000000..422f396a
--- /dev/null
+++ b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
@@ -0,0 +1,229 @@
+package com.iemr.common.service.biometric;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.util.stream.Collectors;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.json.XML;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Text;
+
+@Service
+public class BiometricServiceImpl implements BiometricService {
+	private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
+
+	@Value("${biometric.discover.url}")
+	String discoverUrl;
+
+	@Value("${biometric.deviceInfo.url}")
+	private String deviceInfoUrl;
+
+	@Value("${biometric.capture.url}")
+	private String captureUrl;
+	
+	@Override
+	public String getBioData(String env) {
+		String pidRes = null;
+		try {
+			String portNumber = null;
+			for (int i = 11100; i <= 11120; i++) {
+				String port = String.valueOf(i);
+				String apiUrl = discoverUrl.replace("port", port);
+
+				String httpMethod = "RDSERVICE";
+				HttpClient httpClient = HttpClientBuilder.create().build();
+
+				HttpRequestBase request = new HttpRequestBase() {
+					@Override
+					public String getMethod() {
+						return httpMethod;
+					}
+				};
+				request.setURI(URI.create(apiUrl));
+				request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
+				try {
+					HttpResponse response = httpClient.execute((HttpUriRequest) request);
+
+					HttpEntity entity = response.getEntity();
+					String responseString = EntityUtils.toString(entity, "UTF-8");
+					if (!responseString.contains("NOTREADY")) {
+						portNumber = port;
+						break;
+					}
+				} catch (Exception e) {
+					logger.error("Error while checking biometric status: " + e.getMessage());
+				}
+			}
+			String xmlResponse = getDeviceInfo(portNumber, env);
+			if(xmlResponse != null) {
+				JSONObject xmlJSONObj = XML.toJSONObject(xmlResponse);
+				String pidData = xmlJSONObj.get("PidData").toString();
+				JSONObject obj = new JSONObject(pidData);
+				String content = obj.get("Data").toString();
+				JSONObject obj1 = new JSONObject(content);
+				pidRes = obj1.get("content").toString();
+			}
+		} catch (Exception e) {
+			logger.error("Error while getting biometric data: " + e.getMessage());
+		}
+		return pidRes;
+	}
+
+	private String getDeviceInfo(String portNumber, String env) {
+		String deviceRes = null;
+		String deviceInforURL = deviceInfoUrl.replace("port", portNumber);
+
+		String httpMethod = "DEVICEINFO";
+		HttpClient httpClient = HttpClientBuilder.create().build();
+
+		HttpRequestBase request = new HttpRequestBase() {
+			@Override
+			public String getMethod() {
+				return httpMethod;
+			}
+		};
+		request.setURI(URI.create(deviceInforURL));
+		request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
+		try {
+			HttpResponse response = httpClient.execute((HttpUriRequest) request);
+
+			HttpEntity entity = response.getEntity();
+			String responseString = EntityUtils.toString(entity, "UTF-8");
+
+			if (null != response && response.getStatusLine().getStatusCode() == 200) {
+				deviceRes = getCaptureInfo(portNumber, env);
+			}
+		} catch (Exception e) {
+			logger.error("Error while getting biometric device info : " + e.getMessage());
+		}
+		return deviceRes;
+	}
+
+	private String getCaptureInfo(String portNumber, String env) throws Exception {
+		String captureRes = null;
+		if (null != portNumber) {
+			try {
+				// Create a new DocumentBuilder
+				DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
+				DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
+
+				// Create a new Document
+				Document doc = docBuilder.newDocument();
+
+				// Create the root element <PidOptions>
+				Element pidOptionsElement = doc.createElement("PidOptions");
+				pidOptionsElement.setAttribute("ver", "1.0");
+				doc.appendChild(pidOptionsElement);
+
+				// Create the <Opts> element and its attributes
+				Element optsElement = doc.createElement("Opts");
+				optsElement.setAttribute("fCount", "1");
+				optsElement.setAttribute("fType", "0");
+				optsElement.setAttribute("iCount", "0");
+				optsElement.setAttribute("pCount", "0");
+				optsElement.setAttribute("pgCount", "2");
+				optsElement.setAttribute("format", "0");
+				optsElement.setAttribute("pidVer", "2.0");
+				optsElement.setAttribute("timeout", "10000");
+				optsElement.setAttribute("pTimeout", "20000");
+				optsElement.setAttribute("posh", "UNKNOWN");
+				optsElement.setAttribute("env", env);
+				pidOptionsElement.appendChild(optsElement);
+
+				// Create the <CustOpts> element
+				Element custOptsElement = doc.createElement("CustOpts");
+				pidOptionsElement.appendChild(custOptsElement);
+
+				// Create the <Param> element inside <CustOpts> with its attributes
+				Element paramElement = doc.createElement("Param");
+				paramElement.setAttribute("name", "mantrakey");
+				paramElement.setAttribute("value", "");
+				custOptsElement.appendChild(paramElement);
+
+				// Create a text node for indentation
+				Text text = doc.createTextNode("\n");
+				pidOptionsElement.insertBefore(text, optsElement);
+
+				// Print the XML content to the console
+				String xml = XMLToString(doc);
+				
+				String captureUrl = "http://127.0.0.1:port/rd/capture";
+				String capturingURL = captureUrl.replace("port", portNumber);
+				URL url = new URL(capturingURL);
+
+				System.out.println(capturingURL);
+
+				String httpMethod = "CAPTURE";
+				HttpClient httpClient = HttpClients.createDefault();
+
+				HttpEntityEnclosingRequestBase request = new HttpEntityEnclosingRequestBase() {
+					@Override
+					public String getMethod() {
+						return httpMethod;
+					}
+				};
+				request.setURI(URI.create(capturingURL));
+				StringEntity entity2 = new StringEntity(xml);
+				request.setEntity(entity2);
+				request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
+				
+				HttpResponse response = httpClient.execute(request);
+				response.setHeader("Content-Type", "TEXT/XML");
+				InputStream entity1 = response.getEntity().getContent();
+				String result = new BufferedReader(new InputStreamReader(entity1))
+						   .lines().collect(Collectors.joining("\n"));
+				if(result.contains("Success")) {
+					captureRes = result;
+				} else {
+					throw new Exception("Capture timed out");
+				}
+				
+		} catch (ParserConfigurationException e) {
+			logger.error("Error while capturing fingerprint: " + e.getMessage());
+		}
+		}
+		return captureRes;
+	}
+
+	private String XMLToString(Document doc) {
+		String response = null;
+		try {
+			javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
+			javax.xml.transform.Transformer transformer = tf.newTransformer();
+			transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
+			javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(
+					new java.io.StringWriter());
+			javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(doc);
+			transformer.transform(source, result);
+			response = result.getWriter().toString();
+		} catch (Exception e) {
+			logger.error("Error while converting XML to String: " + e.getMessage());
+		}
+		return response;
+	}
+
+}

From dac5309d057e8bc2241ffaa594324871c65b23a0 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Thu, 28 Sep 2023 15:00:10 +0530
Subject: [PATCH 02/23] biometric device changes

---
 .../common/controller/biometric/BiometricController.java    | 6 ++++--
 .../iemr/common/service/biometric/BiometricServiceImpl.java | 3 ---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
index fa41e914..c95cad9b 100644
--- a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
+++ b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
@@ -4,6 +4,7 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.PathVariable;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestHeader;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -28,8 +29,9 @@ public class BiometricController {
 	@Autowired
 	private BiometricService biometricService;
 	@CrossOrigin
-	@RequestMapping(value = { "/getBiometricData/{pid}" }, method = { RequestMethod.GET })
-	public OutputResponse saveBenNurseDataCAC(@RequestParam String pid) {
+	@RequestMapping(value = { "/getBiometricData/{pid}" }, method = { RequestMethod.GET }, headers = "Authorization")
+	public OutputResponse saveBenNurseDataCAC(@PathVariable("pid") String pid,
+			@RequestHeader(value = "Authorization") String Authorization) {
 		OutputResponse response = new OutputResponse();
 		try {
 			String pidResponse = biometricService.getBioData(pid);
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
index 422f396a..fec438ea 100644
--- a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
@@ -171,12 +171,9 @@ private String getCaptureInfo(String portNumber, String env) throws Exception {
 				// Print the XML content to the console
 				String xml = XMLToString(doc);
 				
-				String captureUrl = "http://127.0.0.1:port/rd/capture";
 				String capturingURL = captureUrl.replace("port", portNumber);
 				URL url = new URL(capturingURL);
 
-				System.out.println(capturingURL);
-
 				String httpMethod = "CAPTURE";
 				HttpClient httpClient = HttpClients.createDefault();
 

From d20443f5f412e65eba4963d8ce1af56f78f37c41 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Wed, 4 Oct 2023 19:35:30 +0530
Subject: [PATCH 03/23] biometric pid changes

---
 .../controller/biometric/BiometricController.java     |  4 ++--
 .../service/biometric/BiometricServiceImpl.java       | 11 ++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
index c95cad9b..79546c87 100644
--- a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
+++ b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
@@ -30,7 +30,7 @@ public class BiometricController {
 	private BiometricService biometricService;
 	@CrossOrigin
 	@RequestMapping(value = { "/getBiometricData/{pid}" }, method = { RequestMethod.GET }, headers = "Authorization")
-	public OutputResponse saveBenNurseDataCAC(@PathVariable("pid") String pid,
+	public String saveBenNurseDataCAC(@PathVariable("pid") String pid,
 			@RequestHeader(value = "Authorization") String Authorization) {
 		OutputResponse response = new OutputResponse();
 		try {
@@ -39,6 +39,6 @@ public OutputResponse saveBenNurseDataCAC(@PathVariable("pid") String pid,
 		}catch (Exception e) {
 			logger.error("Error while fetching Biometric data : "+e.getMessage());
 		}
-		return response;
+		return response.toString();
 	}
 }
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
index fec438ea..0789ee86 100644
--- a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
@@ -5,6 +5,7 @@
 import java.io.InputStreamReader;
 import java.net.URI;
 import java.net.URL;
+import java.util.Base64;
 import java.util.stream.Collectors;
 
 import javax.xml.parsers.DocumentBuilder;
@@ -80,12 +81,7 @@ public String getMethod() {
 			}
 			String xmlResponse = getDeviceInfo(portNumber, env);
 			if(xmlResponse != null) {
-				JSONObject xmlJSONObj = XML.toJSONObject(xmlResponse);
-				String pidData = xmlJSONObj.get("PidData").toString();
-				JSONObject obj = new JSONObject(pidData);
-				String content = obj.get("Data").toString();
-				JSONObject obj1 = new JSONObject(content);
-				pidRes = obj1.get("content").toString();
+				pidRes = Base64.getEncoder().encodeToString(xmlResponse.getBytes());
 			}
 		} catch (Exception e) {
 			logger.error("Error while getting biometric data: " + e.getMessage());
@@ -142,7 +138,7 @@ private String getCaptureInfo(String portNumber, String env) throws Exception {
 				// Create the <Opts> element and its attributes
 				Element optsElement = doc.createElement("Opts");
 				optsElement.setAttribute("fCount", "1");
-				optsElement.setAttribute("fType", "0");
+				optsElement.setAttribute("fType", "2");
 				optsElement.setAttribute("iCount", "0");
 				optsElement.setAttribute("pCount", "0");
 				optsElement.setAttribute("pgCount", "2");
@@ -150,6 +146,7 @@ private String getCaptureInfo(String portNumber, String env) throws Exception {
 				optsElement.setAttribute("pidVer", "2.0");
 				optsElement.setAttribute("timeout", "10000");
 				optsElement.setAttribute("pTimeout", "20000");
+				optsElement.setAttribute("wadh", "E0jzJ/P8UopUHAieZn8CKqS4WPMi5ZSYXgfnlfkWjrc=");
 				optsElement.setAttribute("posh", "UNKNOWN");
 				optsElement.setAttribute("env", env);
 				pidOptionsElement.appendChild(optsElement);

From c6b15d82bfb451a059eaf02ec8b8f79f725b34e6 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Thu, 5 Oct 2023 11:16:28 +0530
Subject: [PATCH 04/23] removed unused imports

---
 .../esanjeevani/ESanjeevaniServiceImpl.java    | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java
index c4b0e409..47def2dc 100644
--- a/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java
@@ -1,26 +1,14 @@
 package com.iemr.common.service.esanjeevani;
 
 import java.math.BigInteger;
-
-import java.security.MessageDigest
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
+import java.security.MessageDigest;
 import java.time.LocalDate;
 import java.time.Period;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
-import javax.servlet.http.HttpUtils;
-
-import org.apache.commons.codec.digest.DigestUtils;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -29,8 +17,6 @@
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.ResponseEntity;
-import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
-import org.springframework.http.converter.StringHttpMessageConverter;
 import org.springframework.stereotype.Service;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MultiValueMap;
@@ -38,14 +24,12 @@
 import org.springframework.util.StringUtils;
 import org.springframework.web.client.RestTemplate;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.gson.Gson;
 import com.iemr.common.model.esanjeevani.ESanjeevaniPatientAddress;
 import com.iemr.common.model.esanjeevani.ESanjeevaniPatientContactDetail;
 import com.iemr.common.model.esanjeevani.ESanjeevaniPatientRegistration;
 import com.iemr.common.model.esanjeevani.ESanjeevaniProviderAuth;
 import com.iemr.common.repo.esanjeevani.ESanjeevaniRepo;
-import com.iemr.common.utils.config.ConfigProperties;
 
 @Service
 public class ESanjeevaniServiceImpl implements ESanjeevaniService {

From 243ba050946debe2408aecc02e1bc328fad3e0c6 Mon Sep 17 00:00:00 2001
From: "Burdhi. Shivani" <BU40088124@wipro.com>
Date: Fri, 24 Nov 2023 16:12:16 +0530
Subject: [PATCH 05/23]  http changes

---
 .../config/BlockingHttpMethodInterceptor.java | 36 +++++++++++++++++++
 .../iemr/common/config/InterceptorConfig.java | 14 +++++---
 2 files changed, 46 insertions(+), 4 deletions(-)
 create mode 100644 src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java

diff --git a/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java b/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java
new file mode 100644
index 00000000..447e3aaa
--- /dev/null
+++ b/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java
@@ -0,0 +1,36 @@
+package com.iemr.common.config;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.servlet.HandlerInterceptor;
+import org.springframework.web.servlet.ModelAndView;
+
+public class BlockingHttpMethodInterceptor implements HandlerInterceptor {
+	@Override
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        String method = request.getMethod();
+        if (!("GET".equals(method) || "POST".equals(method))) {
+            response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+            return false;
+        }
+        return true;
+}
+
+	@Override
+	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
+			ModelAndView modelAndView) throws Exception {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
+			throws Exception {
+		// TODO Auto-generated method stub
+		
+	}
+}
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/config/InterceptorConfig.java b/src/main/java/com/iemr/common/config/InterceptorConfig.java
index 0a325bba..37817edf 100644
--- a/src/main/java/com/iemr/common/config/InterceptorConfig.java
+++ b/src/main/java/com/iemr/common/config/InterceptorConfig.java
@@ -35,9 +35,15 @@ public class InterceptorConfig extends WebMvcConfigurerAdapter
 	@Autowired
 	HTTPRequestInterceptor requestInterceptor;
 
+//	@Override
+//	public void addInterceptors(InterceptorRegistry registry)
+//	{
+//		registry.addInterceptor(requestInterceptor);
+//	}
+	
 	@Override
-	public void addInterceptors(InterceptorRegistry registry)
-	{
-		registry.addInterceptor(requestInterceptor);
-	}
+    public void addInterceptors(InterceptorRegistry registry) {
+        registry.addInterceptor(new BlockingHttpMethodInterceptor())
+                .addPathPatterns("/**"); 
+    }
 }
\ No newline at end of file

From 6c9ce2ab30ab4a3b993f4898d78c98e7584de864 Mon Sep 17 00:00:00 2001
From: "Burdhi. Shivani" <BU40088124@wipro.com>
Date: Tue, 28 Nov 2023 10:45:02 +0530
Subject: [PATCH 06/23] primary db changes

---
 src/main/java/com/iemr/common/config/PrimaryDBConfig.java | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/main/java/com/iemr/common/config/PrimaryDBConfig.java b/src/main/java/com/iemr/common/config/PrimaryDBConfig.java
index 6fb54688..f58a7158 100644
--- a/src/main/java/com/iemr/common/config/PrimaryDBConfig.java
+++ b/src/main/java/com/iemr/common/config/PrimaryDBConfig.java
@@ -49,8 +49,6 @@
 		"com.iemr.common.repo", "com.iemr.common.notification.agent", "com.iemr.common.covidVaccination" })
 public class PrimaryDBConfig {
 
-	@Autowired
-
 	Logger logger = LoggerFactory.getLogger(this.getClass().getName());
 
 	@Primary

From fecd9d43e33fc6cb30380e3c15810e3398768d0a Mon Sep 17 00:00:00 2001
From: "Burdhi. Shivani" <BU40088124@wipro.com>
Date: Wed, 17 Jan 2024 17:31:46 +0530
Subject: [PATCH 07/23] outbound call changes

---
 .../iemr/common/controller/callhandling/CallController.java   | 1 +
 .../repository/callhandling/BeneficiaryCallRepository.java    | 4 ++--
 .../service/callhandling/BeneficiaryCallServiceImpl.java      | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/iemr/common/controller/callhandling/CallController.java b/src/main/java/com/iemr/common/controller/callhandling/CallController.java
index 762c7d1c..068dd77b 100644
--- a/src/main/java/com/iemr/common/controller/callhandling/CallController.java
+++ b/src/main/java/com/iemr/common/controller/callhandling/CallController.java
@@ -174,6 +174,7 @@ public String closeCall(
 					+ "\"agentIPAddress\":\"Optional String - agent IP address\", "
 					+ "\"agentID\":\"Optional String - agentID\", \"isSelf\":\"Optional boolean\", "
 					+ "\"isFeedback\":\"optional Boolean true if IVRS feedback to be taken\", "
+					+ "\"IsOutbound\":\"Optional Boolean - for checking outboundcall status\", "
 					+ "\"isTransfered\":\"Boolean - transfer call or not\"" + "}") @RequestBody String request,
 			HttpServletRequest serverRequest) {
 		OutputResponse response = new OutputResponse();
diff --git a/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java b/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
index e66778c4..cb11ce55 100644
--- a/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
+++ b/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
@@ -59,13 +59,13 @@ public int closeCallOld(@Param("benCallID") Long benCallID, @Param("remarks") St
 	@Query("update BeneficiaryCall set callEndTime = :callEndTime, remarks = :remarks, "
 			+ "callClosureType = :callClosureType, " + "dispositionStatusID = :dispositionStatusID, "
 			+ "callTypeID = :callTypeID, emergencyType = :emergencyType,"
-			+ " externalReferral=:externalReferral,instTypeId=:instTypeId,instName=:instName"
+			+ " externalReferral=:externalReferral,instTypeId=:instTypeId,instName=:instName,isOutbound = :isOutbound"
 			+ "   where benCallID = :benCallID")
 	public int closeCall(@Param("benCallID") Long benCallID, @Param("remarks") String remarks,
 			@Param("callEndTime") Timestamp callEndTime, @Param("callClosureType") String callClosureType,
 			@Param("callTypeID") Integer callTypeID, @Param("dispositionStatusID") Integer dispositionStatusID,
 			@Param("emergencyType") Short emergencyType, @Param("externalReferral") String externalReferral,
-			@Param("instTypeId") Integer instTypeId, @Param("instName") String instName);
+			@Param("instTypeId") Integer instTypeId, @Param("instName") String instName, @Param("isOutbound") Boolean isOutbound);
 
 	// @Transactional(propagation = Propagation.REQUIRES_NEW)
 	@Transactional
diff --git a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
index f0dd6c60..8ca3cadd 100644
--- a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
@@ -396,7 +396,7 @@ public Integer closeCall(String request, String ipAddress) throws Exception {
 				new Timestamp(Calendar.getInstance().getTimeInMillis()), benificiaryCall.getCallClosureType(),
 				benificiaryCall.getCallTypeID(), benificiaryCall.getDispositionStatusID(),
 				benificiaryCall.getEmergencyType(), benificiaryCall.getExternalReferral(),
-				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName());
+				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName(),benificiaryCall.getIsOutbound());
 
 		if (benificiaryCall.getBeneficiaryRegID() != null)
 			beneficiaryCallRepository.updateBeneficiaryRegIDInCall(benificiaryCall.getBenCallID(),
@@ -449,7 +449,7 @@ public Integer closeCallV1(String request, String ipAddress) throws Exception {
 				new Timestamp(Calendar.getInstance().getTimeInMillis()), benificiaryCall.getCallClosureType(),
 				benificiaryCall.getCallTypeID(), benificiaryCall.getDispositionStatusID(),
 				benificiaryCall.getEmergencyType(), benificiaryCall.getExternalReferral(),
-				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName());
+				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName(),benificiaryCall.getIsOutbound());
 		if (followupRequired.isFollowupRequired) {
 			OutboundCallRequest outboundCallRequest = inputMapper.gson().fromJson(request, OutboundCallRequest.class);
 			outboundCallRequestRepository.save(outboundCallRequest);

From 9c6bfb92a85ead1f467500115a14863da3741d72 Mon Sep 17 00:00:00 2001
From: bshivani7 <133210639+bshivani7@users.noreply.github.com>
Date: Wed, 24 Jan 2024 12:51:58 +0530
Subject: [PATCH 08/23] czentrix outbound point (#81)

* http changes

* primary db changes

* outbound call changes

---------

Co-authored-by: Burdhi. Shivani <BU40088124@wipro.com>
---
 .../iemr/common/controller/callhandling/CallController.java   | 1 +
 .../repository/callhandling/BeneficiaryCallRepository.java    | 4 ++--
 .../service/callhandling/BeneficiaryCallServiceImpl.java      | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/iemr/common/controller/callhandling/CallController.java b/src/main/java/com/iemr/common/controller/callhandling/CallController.java
index 2ea0f9b8..bd79929d 100644
--- a/src/main/java/com/iemr/common/controller/callhandling/CallController.java
+++ b/src/main/java/com/iemr/common/controller/callhandling/CallController.java
@@ -175,6 +175,7 @@ public String closeCall(
 					+ "\"agentIPAddress\":\"Optional String - agent IP address\", "
 					+ "\"agentID\":\"Optional String - agentID\", \"isSelf\":\"Optional boolean\", "
 					+ "\"isFeedback\":\"optional Boolean true if IVRS feedback to be taken\", "
+					+ "\"IsOutbound\":\"Optional Boolean - for checking outboundcall status\", "
 					+ "\"isTransfered\":\"Boolean - transfer call or not\"" + "}") @RequestBody String request,
 			HttpServletRequest serverRequest) {
 		OutputResponse response = new OutputResponse();
diff --git a/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java b/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
index e66778c4..cb11ce55 100644
--- a/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
+++ b/src/main/java/com/iemr/common/repository/callhandling/BeneficiaryCallRepository.java
@@ -59,13 +59,13 @@ public int closeCallOld(@Param("benCallID") Long benCallID, @Param("remarks") St
 	@Query("update BeneficiaryCall set callEndTime = :callEndTime, remarks = :remarks, "
 			+ "callClosureType = :callClosureType, " + "dispositionStatusID = :dispositionStatusID, "
 			+ "callTypeID = :callTypeID, emergencyType = :emergencyType,"
-			+ " externalReferral=:externalReferral,instTypeId=:instTypeId,instName=:instName"
+			+ " externalReferral=:externalReferral,instTypeId=:instTypeId,instName=:instName,isOutbound = :isOutbound"
 			+ "   where benCallID = :benCallID")
 	public int closeCall(@Param("benCallID") Long benCallID, @Param("remarks") String remarks,
 			@Param("callEndTime") Timestamp callEndTime, @Param("callClosureType") String callClosureType,
 			@Param("callTypeID") Integer callTypeID, @Param("dispositionStatusID") Integer dispositionStatusID,
 			@Param("emergencyType") Short emergencyType, @Param("externalReferral") String externalReferral,
-			@Param("instTypeId") Integer instTypeId, @Param("instName") String instName);
+			@Param("instTypeId") Integer instTypeId, @Param("instName") String instName, @Param("isOutbound") Boolean isOutbound);
 
 	// @Transactional(propagation = Propagation.REQUIRES_NEW)
 	@Transactional
diff --git a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
index 5c6b1b09..c554ee8d 100644
--- a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
@@ -403,7 +403,7 @@ public Integer closeCall(String request, String ipAddress) throws Exception {
 				new Timestamp(Calendar.getInstance().getTimeInMillis()), benificiaryCall.getCallClosureType(),
 				benificiaryCall.getCallTypeID(), benificiaryCall.getDispositionStatusID(),
 				benificiaryCall.getEmergencyType(), benificiaryCall.getExternalReferral(),
-				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName());
+				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName(),benificiaryCall.getIsOutbound());
 
 		if (benificiaryCall.getBeneficiaryRegID() != null)
 			beneficiaryCallRepository.updateBeneficiaryRegIDInCall(benificiaryCall.getBenCallID(),
@@ -456,7 +456,7 @@ public Integer closeCallV1(String request, String ipAddress) throws Exception {
 				new Timestamp(Calendar.getInstance().getTimeInMillis()), benificiaryCall.getCallClosureType(),
 				benificiaryCall.getCallTypeID(), benificiaryCall.getDispositionStatusID(),
 				benificiaryCall.getEmergencyType(), benificiaryCall.getExternalReferral(),
-				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName());
+				benificiaryCall.getInstTypeId(), benificiaryCall.getInstName(),benificiaryCall.getIsOutbound());
 		if (followupRequired.isFollowupRequired) {
 			OutboundCallRequest outboundCallRequest = inputMapper.gson().fromJson(request, OutboundCallRequest.class);
 			outboundCallRequestRepository.save(outboundCallRequest);

From 4c777fb37a2984923d4e79db54f64da57ffa41c4 Mon Sep 17 00:00:00 2001
From: appuser <appuser@amritwprdev.piramalswasthya.org>
Date: Mon, 29 Jan 2024 19:45:31 +0530
Subject: [PATCH 09/23] 1097 sms template changes

---
 .../common/service/sms/SMSServiceImpl.java    | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

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 e6d466ae..1d63bb45 100644
--- a/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
@@ -867,6 +867,30 @@ private String getInstituteData(String className, String methodName, SMSRequest
 			String address = institute.getAddress() != null ? institute.getAddress() + " " : "";
 			variableValue = address;
 			break;
+		case "address1":
+			String truncatedAdress1 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			if(!truncatedAdress1.isEmpty()) {
+				variableValue = getSubstringInRange(institute.getAddress(), 0, 29);
+			}else {
+				variableValue = "";
+			}
+			break;
+		case "address2":
+			String truncatedAdress2 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			if(!truncatedAdress2.isEmpty()) {
+				variableValue = getSubstringInRange(institute.getAddress(), 30, 59);
+			}else {
+				variableValue = "";
+			}
+			break;
+		case "address3":
+			String truncatedAdress3 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			if(!truncatedAdress3.isEmpty()) {
+				variableValue = getSubstringInRange(institute.getAddress(), 60, 89);
+			}else {
+				variableValue = "";
+			}
+			break;
 		case "contactperson1":
 			String contactPerson1 = institute.getContactPerson1() != null ? institute.getContactPerson1() + " " : "";
 			variableValue = contactPerson1;
@@ -898,6 +922,15 @@ private String getInstituteData(String className, String methodName, SMSRequest
 		}
 		return variableValue.trim();
 	}
+	
+	private static String getSubstringInRange(String input, int startIndex, int endIndex) {
+		if(input != null && startIndex>=0 && startIndex<input.length()) {
+			int truncatedEnd = Math.min(endIndex, input.length());
+			return input.substring(startIndex, truncatedEnd);
+			}else {
+				return " ";
+			}
+	}
 
 	@Async
 	@Override

From 988697d15a7808c9e85b901093419d6a4e967f60 Mon Sep 17 00:00:00 2001
From: devikasuresh20 <57424483+devikasuresh20@users.noreply.github.com>
Date: Mon, 5 Feb 2024 03:10:34 -0800
Subject: [PATCH 10/23] Minor modification in 1097 referral sms template (#84)

* Added limit condition while fetching Item stock entry details in eaushadha API

* Minor modifications in 1097 referral sms template

* Added institute name along with referral SMS

---------

Co-authored-by: Devika <de40034072@wipro.com>
---
 .../common/service/sms/SMSServiceImpl.java    | 20 ++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

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 1d63bb45..0de15785 100644
--- a/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
@@ -868,25 +868,31 @@ private String getInstituteData(String className, String methodName, SMSRequest
 			variableValue = address;
 			break;
 		case "address1":
-			String truncatedAdress1 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String hospitalName1 = institute.getInstitutionName() != null ? institute.getInstitutionName() + " " : "";
+			String addressValue1 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String truncatedAdress1 = hospitalName1.concat(" ").concat(addressValue1);
 			if(!truncatedAdress1.isEmpty()) {
-				variableValue = getSubstringInRange(institute.getAddress(), 0, 29);
+				variableValue = getSubstringInRange(truncatedAdress1, 0, 29);
 			}else {
 				variableValue = "";
 			}
 			break;
 		case "address2":
-			String truncatedAdress2 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String hospitalName2 = institute.getInstitutionName() != null ? institute.getInstitutionName() + " " : "";
+			String addressValue2 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String truncatedAdress2 = hospitalName2.concat(" ").concat(addressValue2);
 			if(!truncatedAdress2.isEmpty()) {
-				variableValue = getSubstringInRange(institute.getAddress(), 30, 59);
+				variableValue = getSubstringInRange(truncatedAdress2, 29, 59);
 			}else {
 				variableValue = "";
 			}
 			break;
 		case "address3":
-			String truncatedAdress3 = institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String hospitalName3 = institute.getInstitutionName() != null ? institute.getInstitutionName() + " " : "";
+			String addressValue3= institute.getAddress() != null ? institute.getAddress() + " " : "";
+			String truncatedAdress3 = hospitalName3.concat(" ").concat(addressValue3);
 			if(!truncatedAdress3.isEmpty()) {
-				variableValue = getSubstringInRange(institute.getAddress(), 60, 89);
+				variableValue = getSubstringInRange(truncatedAdress3, 59, 89);
 			}else {
 				variableValue = "";
 			}
@@ -920,7 +926,7 @@ private String getInstituteData(String className, String methodName, SMSRequest
 		default:
 			break;
 		}
-		return variableValue.trim();
+		return variableValue;
 	}
 	
 	private static String getSubstringInRange(String input, int startIndex, int endIndex) {

From a76c4df1031f683b9d18df3d62cc95a13e1db8d8 Mon Sep 17 00:00:00 2001
From: devikasuresh20 <57424483+devikasuresh20@users.noreply.github.com>
Date: Sat, 17 Feb 2024 20:52:45 +0530
Subject: [PATCH 11/23] Removed myapp properties (#89)

* Added limit condition while fetching Item stock entry details in eaushadha API

* Minor modifications in 1097 referral sms template

* Added institute name along with referral SMS

* Removed myapp propeties and minor change in interceptor.

---------

Co-authored-by: Devika <de40034072@wipro.com>
---
 .../config/BlockingHttpMethodInterceptor.java | 36 -------------------
 .../iemr/common/config/InterceptorConfig.java | 17 +++------
 .../CareStreamCreateOrderController.java      |  1 -
 3 files changed, 5 insertions(+), 49 deletions(-)
 delete mode 100644 src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java

diff --git a/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java b/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java
deleted file mode 100644
index 447e3aaa..00000000
--- a/src/main/java/com/iemr/common/config/BlockingHttpMethodInterceptor.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.iemr.common.config;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.servlet.HandlerInterceptor;
-import org.springframework.web.servlet.ModelAndView;
-
-public class BlockingHttpMethodInterceptor implements HandlerInterceptor {
-	@Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
-        String method = request.getMethod();
-        if (!("GET".equals(method) || "POST".equals(method))) {
-            response.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-            return false;
-        }
-        return true;
-}
-
-	@Override
-	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
-			ModelAndView modelAndView) throws Exception {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
-			throws Exception {
-		// TODO Auto-generated method stub
-		
-	}
-}
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/config/InterceptorConfig.java b/src/main/java/com/iemr/common/config/InterceptorConfig.java
index 37817edf..2beb8de9 100644
--- a/src/main/java/com/iemr/common/config/InterceptorConfig.java
+++ b/src/main/java/com/iemr/common/config/InterceptorConfig.java
@@ -29,21 +29,14 @@
 import com.iemr.common.utils.http.HTTPRequestInterceptor;
 
 @Configuration
-public class InterceptorConfig extends WebMvcConfigurerAdapter
-{
+public class InterceptorConfig extends WebMvcConfigurerAdapter {
 
 	@Autowired
 	HTTPRequestInterceptor requestInterceptor;
 
-//	@Override
-//	public void addInterceptors(InterceptorRegistry registry)
-//	{
-//		registry.addInterceptor(requestInterceptor);
-//	}
-	
 	@Override
-    public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(new BlockingHttpMethodInterceptor())
-                .addPathPatterns("/**"); 
-    }
+	public void addInterceptors(InterceptorRegistry registry) {
+		registry.addInterceptor(requestInterceptor);
+	}
+
 }
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java b/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java
index 529c759c..4a4f2a05 100644
--- a/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java
+++ b/src/main/java/com/iemr/common/controller/carestream/CareStreamCreateOrderController.java
@@ -44,7 +44,6 @@
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
-@PropertySource("classpath:myapp.properties")
 @RestController
 @RequestMapping(value = "/carestream")
 public class CareStreamCreateOrderController {

From d5e4f91d5828f2b30fe05c8c34bd08e275affadc Mon Sep 17 00:00:00 2001
From: devikasuresh20 <57424483+devikasuresh20@users.noreply.github.com>
Date: Thu, 21 Mar 2024 10:21:52 +0530
Subject: [PATCH 12/23] Change in Phone No Comparison while fetching call audit
 details (#94)

* Added limit condition while fetching Item stock entry details in eaushadha API

* Minor modifications in 1097 referral sms template

* Added institute name along with referral SMS

* Removed myapp propeties and minor change in interceptor.

* Change in Phone No comparison while fetching call audit details

---------

Co-authored-by: Devika <de40034072@wipro.com>
---
 .../callhandling/BeneficiaryCallServiceImpl.java | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
index c554ee8d..55f6b09c 100644
--- a/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/callhandling/BeneficiaryCallServiceImpl.java
@@ -1070,8 +1070,12 @@ private Long getTotalCallCount(CriteriaBuilder criteriaBuilder, BeneficiaryCall
 			predicates.add(criteriaBuilder.equal(entityRoot.get("callTypeID"), callRequest.getCallTypeID()));
 		}
 
-		predicates.add(criteriaBuilder.like(entityRoot.get("phoneNo"),
-				(callRequest.getPhoneNo() == null) ? "%%" : callRequest.getPhoneNo()));
+//		predicates.add(criteriaBuilder.like(entityRoot.get("phoneNo"),
+//				(callRequest.getPhoneNo() == null) ? "%%" : callRequest.getPhoneNo()));
+		
+		if (callRequest.getPhoneNo() != null) {
+			predicates.add(criteriaBuilder.equal(entityRoot.get("phoneNo"), callRequest.getPhoneNo()));
+		}
 
 		if (callRequest.getInboundOutbound() != null) {
 			callRequest.setIsOutbound(callRequest.getInboundOutbound().equalsIgnoreCase("outbound") ? true : false);
@@ -1211,8 +1215,12 @@ public String filterCallList(String request, String auth) throws IEMRException {
 			predicates.add(criteriaBuilder.equal(root.get("callTypeID"), callRequest.getCallTypeID()));
 		}
 
-		predicates.add(criteriaBuilder.like(root.get("phoneNo"),
-				(callRequest.getPhoneNo() == null) ? "%%" : callRequest.getPhoneNo()));
+//		predicates.add(criteriaBuilder.like(root.get("phoneNo"),
+//				(callRequest.getPhoneNo() == null) ? "%%" : callRequest.getPhoneNo()));
+		
+		if (callRequest.getPhoneNo() != null) {
+			predicates.add(criteriaBuilder.equal(root.get("phoneNo"), callRequest.getPhoneNo()));
+		}
 
 		if (callRequest.getInboundOutbound() != null) {
 			callRequest.setIsOutbound(callRequest.getInboundOutbound().equalsIgnoreCase("outbound") ? true : false);

From d959dbefd71e73b68b3defc6fe13af9b470ca9a7 Mon Sep 17 00:00:00 2001
From: indraniBan <133205641+indraniBan@users.noreply.github.com>
Date: Mon, 15 Apr 2024 11:36:00 +0530
Subject: [PATCH 13/23] Mapper class modified (#101)

Co-authored-by: IN40068837 <IN40068837@L-156289031.wipro.com>
---
 .../BenCompleteDetailMapperDecorator.java     | 21 ++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java b/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
index a9d7f947..4e6e0943 100644
--- a/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
+++ b/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
@@ -76,27 +76,32 @@ public BeneficiaryDemographicsModel createBenDemographicsModel(BeneficiariesDTO
 
 		BeneficiaryDemographicsModel demographicsModel = new BeneficiaryDemographicsModel();
 		demographicsModel.setBeneficiaryRegID(Long.parseLong(benRegID.toString()));
-		demographicsModel.setStateID(address.getStateId());
-		if (address.getStateId() != null)
+		
+		
+		if (address != null && address.getStateId() != null)
 		{
+			demographicsModel.setStateID(address.getStateId());
 			demographicsModel.setM_state(stateMapper.StateToModelByID(address.getStateId()));
 			demographicsModel.setStateName(demographicsModel.getM_state().getStateName());
 		}
-		demographicsModel.setDistrictID(address.getDistrictId());
-		if (address.getDistrictId() != null)
+		
+		if (address != null && address.getDistrictId() != null)
 		{
+			demographicsModel.setDistrictID(address.getDistrictId());
 			demographicsModel.setM_district(districtMapper.districtToModelByID(address.getDistrictId()));
 			demographicsModel.setDistrictName(demographicsModel.getM_district().getDistrictName());
 		}
-		demographicsModel.setBlockID(address.getSubDistrictId());
-		if (address.getSubDistrictId() != null)
+		
+		if (address != null && address.getSubDistrictId() != null)
 		{
+			demographicsModel.setBlockID(address.getSubDistrictId());
 			demographicsModel.setM_districtblock(blockMapper.districtBlockToModelByID(address.getSubDistrictId()));
 			demographicsModel.setBlockName(demographicsModel.getM_districtblock().getBlockName());
 		}
-		demographicsModel.setDistrictBranchID(address.getVillageId());
-		if (address.getVillageId() != null)
+		
+		if (address != null && address.getVillageId() != null)
 		{
+			demographicsModel.setDistrictBranchID(address.getVillageId());
 			demographicsModel
 					.setM_districtbranchmapping(branchMapper.districtBranchToModelByID(address.getVillageId()));
 			demographicsModel.setDistrictBranchName(demographicsModel.getM_districtbranchmapping().getVillageName());

From 888f239e1be675d1b3643f5c5279fd7728b657db Mon Sep 17 00:00:00 2001
From: indraniBan <133205641+indraniBan@users.noreply.github.com>
Date: Mon, 15 Apr 2024 13:21:12 +0530
Subject: [PATCH 14/23] SearchUserById api logic corrected (#102)

* Mapper class modified

* searchUserById api logic corrected

---------

Co-authored-by: IN40068837 <IN40068837@L-156289031.wipro.com>
Co-authored-by: appuser <appuser@amritwprdev.piramalswasthya.org>
---
 .../BenCompleteDetailMapperDecorator.java     | 96 ++++++++-----------
 1 file changed, 40 insertions(+), 56 deletions(-)

diff --git a/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java b/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
index 4e6e0943..34d4abba 100644
--- a/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
+++ b/src/main/java/com/iemr/common/mapper/BenCompleteDetailMapperDecorator.java
@@ -31,8 +31,7 @@
 import com.iemr.common.model.beneficiary.BeneficiaryDemographicsModel;
 import com.iemr.common.model.userbeneficiary.LanguageModel;
 
-public abstract class BenCompleteDetailMapperDecorator implements BenCompleteDetailMapper
-{
+public abstract class BenCompleteDetailMapperDecorator implements BenCompleteDetailMapper {
 	@Autowired
 	StateMapper stateMapper;
 	@Autowired
@@ -67,60 +66,52 @@ public abstract class BenCompleteDetailMapperDecorator implements BenCompleteDet
 	MaritalStatusMapper maritalStatusMapper;
 
 	@Override
-	public BeneficiaryDemographicsModel createBenDemographicsModel(BeneficiariesDTO beneficiariesDTO)
-	{
+	public BeneficiaryDemographicsModel createBenDemographicsModel(BeneficiariesDTO beneficiariesDTO) {
 		Address address = beneficiariesDTO.getCurrentAddress();
 		BigInteger benRegID = beneficiariesDTO.getBenRegId();
 		String createdBy = beneficiariesDTO.getCreatedBy();
 		BenDetailDTO benDetails = beneficiariesDTO.getBeneficiaryDetails();
 
 		BeneficiaryDemographicsModel demographicsModel = new BeneficiaryDemographicsModel();
-		demographicsModel.setBeneficiaryRegID(Long.parseLong(benRegID.toString()));
-		
-		
-		if (address != null && address.getStateId() != null)
-		{
+		if (benRegID != null)
+			demographicsModel.setBeneficiaryRegID(Long.parseLong(benRegID.toString()));
+
+		if (address != null && address.getStateId() != null) {
 			demographicsModel.setStateID(address.getStateId());
 			demographicsModel.setM_state(stateMapper.StateToModelByID(address.getStateId()));
 			demographicsModel.setStateName(demographicsModel.getM_state().getStateName());
 		}
-		
-		if (address != null && address.getDistrictId() != null)
-		{
+
+		if (address != null && address.getDistrictId() != null) {
 			demographicsModel.setDistrictID(address.getDistrictId());
 			demographicsModel.setM_district(districtMapper.districtToModelByID(address.getDistrictId()));
 			demographicsModel.setDistrictName(demographicsModel.getM_district().getDistrictName());
 		}
-		
-		if (address != null && address.getSubDistrictId() != null)
-		{
+
+		if (address != null && address.getSubDistrictId() != null) {
 			demographicsModel.setBlockID(address.getSubDistrictId());
 			demographicsModel.setM_districtblock(blockMapper.districtBlockToModelByID(address.getSubDistrictId()));
 			demographicsModel.setBlockName(demographicsModel.getM_districtblock().getBlockName());
 		}
-		
-		if (address != null && address.getVillageId() != null)
-		{
+
+		if (address != null && address.getVillageId() != null) {
 			demographicsModel.setDistrictBranchID(address.getVillageId());
 			demographicsModel
 					.setM_districtbranchmapping(branchMapper.districtBranchToModelByID(address.getVillageId()));
 			demographicsModel.setDistrictBranchName(demographicsModel.getM_districtbranchmapping().getVillageName());
 		}
 		demographicsModel.setEducationID(benDetails.getEducationId());
-		if (benDetails.getEducationId() != null)
-		{
+		if (benDetails.getEducationId() != null) {
 			demographicsModel.setI_beneficiaryeducation(
 					educationMapper.educationToModelByID(Long.parseLong(benDetails.getEducationId().toString())));
 			demographicsModel.setEducationName(demographicsModel.getI_beneficiaryeducation().getEducationType());
 		}
 		demographicsModel.setCommunityID(benDetails.getCommunityId());
-		if (benDetails.getCommunityId() != null)
-		{
+		if (benDetails.getCommunityId() != null) {
 			demographicsModel.setM_community(communityMapper.communityToLoginResponseByID(benDetails.getCommunityId()));
 			demographicsModel.setCommunityName(demographicsModel.getM_community().getCommunityType());
 		}
-		if (benDetails.getOccupationId() != null)
-		{
+		if (benDetails.getOccupationId() != null) {
 			demographicsModel.setOccupationID(benDetails.getOccupationId());
 			demographicsModel.setOccupationName(benDetails.getOccupation());
 		}
@@ -129,13 +120,11 @@ public BeneficiaryDemographicsModel createBenDemographicsModel(BeneficiariesDTO
 		demographicsModel.setIncomeStatus(benDetails.getIncomeStatus());
 		demographicsModel.setIncomeStatusName(benDetails.getIncomeStatus());
 		// }
-		if (benDetails.getReligionId() != null)
-		{
+		if (benDetails.getReligionId() != null) {
 			demographicsModel.setReligionID(benDetails.getReligionId());
 			demographicsModel.setReligionName(benDetails.getReligion());
 		}
-		if (benDetails.getIncomeStatusId() != null)
-		{
+		if (benDetails.getIncomeStatusId() != null) {
 			demographicsModel.setIncomeStatusID(benDetails.getIncomeStatusId());
 			demographicsModel.setIncomeStatusName(benDetails.getIncomeStatus());
 			demographicsModel.setIncomeStatus(benDetails.getIncomeStatus());
@@ -144,33 +133,32 @@ public BeneficiaryDemographicsModel createBenDemographicsModel(BeneficiariesDTO
 			demographicsModel.setMonthlyFamilyIncome(benDetails.getMonthlyFamilyIncome());
 		}
 		demographicsModel.setCreatedBy(createdBy);
-		demographicsModel.setPinCode(address.getPinCode());
-		demographicsModel.setAddressLine1(address.getAddrLine1());
-		demographicsModel.setAddressLine2(address.getAddrLine2());
-		demographicsModel.setAddressLine3(address.getAddrLine3());
-		demographicsModel.setHealthCareWorkerID(benDetails.getHealthCareWorkerId());
-		demographicsModel.setZoneID(address.getZoneID());
-		demographicsModel.setZoneName(address.getZoneName());
-		demographicsModel.setParkingPlaceID(address.getParkingPlaceID());
-		demographicsModel.setParkingPlaceName(address.getParkingPlaceName());
-		demographicsModel.setServicePointID(address.getServicePointID());
-		demographicsModel.setServicePointName(address.getServicePointName());
-		demographicsModel.setHabitation(address.getHabitation());
+		if (address != null) {
+			demographicsModel.setPinCode(address.getPinCode());
+			demographicsModel.setAddressLine1(address.getAddrLine1());
+			demographicsModel.setAddressLine2(address.getAddrLine2());
+			demographicsModel.setAddressLine3(address.getAddrLine3());
+			demographicsModel.setHealthCareWorkerID(benDetails.getHealthCareWorkerId());
+			demographicsModel.setZoneID(address.getZoneID());
+			demographicsModel.setZoneName(address.getZoneName());
+			demographicsModel.setParkingPlaceID(address.getParkingPlaceID());
+			demographicsModel.setParkingPlaceName(address.getParkingPlaceName());
+			demographicsModel.setServicePointID(address.getServicePointID());
+			demographicsModel.setServicePointName(address.getServicePointName());
+			demographicsModel.setHabitation(address.getHabitation());
+		}
 		demographicsModel.setPreferredLangID(beneficiariesDTO.getBeneficiaryDetails().getPreferredLanguageId());
-		LanguageModel lang =
-				languageMapper.languageToModelByID(beneficiariesDTO.getBeneficiaryDetails().getPreferredLanguageId());
+		LanguageModel lang = languageMapper
+				.languageToModelByID(beneficiariesDTO.getBeneficiaryDetails().getPreferredLanguageId());
 		demographicsModel.setM_language(lang);
-		if (lang != null)
-		{
+		if (lang != null) {
 			demographicsModel.setPreferredLangName(lang.getLanguageName());
 		}
 		return demographicsModel;
 	}
 
-	protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel)
-	{
-		if (beneficiaryDemographicsModel == null)
-		{
+	protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsModel beneficiaryDemographicsModel) {
+		if (beneficiaryDemographicsModel == null) {
 			return null;
 		}
 
@@ -181,15 +169,13 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
 		address.setParkingPlaceName(beneficiaryDemographicsModel.getParkingPlaceName());
 		address.setStateId(beneficiaryDemographicsModel.getStateID());
 		address.setDistrictId(beneficiaryDemographicsModel.getDistrictID());
-		if (beneficiaryDemographicsModel.getDistrictID() != null)
-		{
+		if (beneficiaryDemographicsModel.getDistrictID() != null) {
 			address.setDistrict(
 					districtMapper.districtToModelByID(beneficiaryDemographicsModel.getDistrictID()).getDistrictName());
 		}
 		address.setServicePointName(beneficiaryDemographicsModel.getServicePointName());
 		address.setCountry(beneficiaryDemographicsModel.getCountryName());
-		if (beneficiaryDemographicsModel.getStateID() != null)
-		{
+		if (beneficiaryDemographicsModel.getStateID() != null) {
 			address.setState(stateMapper.StateToModelByID(beneficiaryDemographicsModel.getStateID()).getStateName());
 		}
 		address.setZoneName(beneficiaryDemographicsModel.getZoneName());
@@ -200,15 +186,13 @@ protected Address beneficiaryDemographicsModelToAddress(BeneficiaryDemographicsM
 		address.setPinCode(beneficiaryDemographicsModel.getPinCode());
 		address.setParkingPlaceID(beneficiaryDemographicsModel.getParkingPlaceID());
 		address.setServicePointID(beneficiaryDemographicsModel.getServicePointID());
-		if (beneficiaryDemographicsModel.getDistrictBranchID() != null)
-		{
+		if (beneficiaryDemographicsModel.getDistrictBranchID() != null) {
 			address.setVillage(branchMapper
 					.districtBranchToModelByID(beneficiaryDemographicsModel.getDistrictBranchID()).getVillageName());
 		}
 		address.setSubDistrictId(beneficiaryDemographicsModel.getBlockID());
 		address.setCountryId(beneficiaryDemographicsModel.getCountryID());
-		if (beneficiaryDemographicsModel.getBlockID() != null)
-		{
+		if (beneficiaryDemographicsModel.getBlockID() != null) {
 			address.setSubDistrict(
 					blockMapper.districtBlockToModelByID(beneficiaryDemographicsModel.getBlockID()).getBlockName());
 		}

From 39f683be9063b867eaa181fd447af6abf7247c40 Mon Sep 17 00:00:00 2001
From: devikasuresh20 <57424483+devikasuresh20@users.noreply.github.com>
Date: Tue, 23 Apr 2024 09:58:55 +0530
Subject: [PATCH 15/23] CTI-datasync scheduler changes (#103)

* Added limit condition while fetching Item stock entry details in eaushadha API

* Minor modifications in 1097 referral sms template

* Added institute name along with referral SMS

* Removed myapp propeties and minor change in interceptor.

* Change in Phone No comparison while fetching call audit details

* Corrected empty array response in JsonObject - editBenCommunity

* Reverted - update community education changes

* Added cti data sync scheduler execution time change and start date and end date change for last two days

* Added cti data sync scheduler execution time change and start date and end date change for last two days

* Added cti data sync scheduler execution time

* Removed commented code

---------

Co-authored-by: Devika <de40034072@wipro.com>
---
 src/main/environment/common_dev.properties    |  3 +-
 src/main/environment/common_test.properties   |  4 +-
 .../ctiCall/CallCentreDataSyncImpl.java       | 47 +++++++++----------
 3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/src/main/environment/common_dev.properties b/src/main/environment/common_dev.properties
index 7b8521f1..2bd12f14 100644
--- a/src/main/environment/common_dev.properties
+++ b/src/main/environment/common_dev.properties
@@ -63,8 +63,9 @@ start-email-scheduler=false
 cron-scheduler-email=0 0/1 * * * ? *
 
 ###cti data sync Scheduler configurations
+#Runs at every alternative days at 2AM
 start-ctidatasync-scheduler=false
-cron-scheduler-ctidatasync=0 00 01 * * ? *
+cron-scheduler-ctidatasync=0 0 2 */2 * ?
 
 ###cti data check with call detail report Scheduler
 #Runs at everyday 12:10AM 
diff --git a/src/main/environment/common_test.properties b/src/main/environment/common_test.properties
index 1e51a0c3..6f25e1a3 100644
--- a/src/main/environment/common_test.properties
+++ b/src/main/environment/common_test.properties
@@ -58,8 +58,10 @@ start-email-scheduler=false
 cron-scheduler-email=0 0/1 * * * ? *
 ##-------------------------------###cti data sync Scheduler configurations------------------------------------------------------
 
+#Runs at every alternative days at 2AM
 start-ctidatasync-scheduler=false
-cron-scheduler-ctidatasync=0 00 01 * * ? *
+cron-scheduler-ctidatasync=0 0 2 */2 * ?
+
 
 ##-------------------------------###cti data check with call detail report Scheduler------------------------------------------------------
 
diff --git a/src/main/java/com/iemr/common/service/ctiCall/CallCentreDataSyncImpl.java b/src/main/java/com/iemr/common/service/ctiCall/CallCentreDataSyncImpl.java
index 14cf3d48..55f2273b 100644
--- a/src/main/java/com/iemr/common/service/ctiCall/CallCentreDataSyncImpl.java
+++ b/src/main/java/com/iemr/common/service/ctiCall/CallCentreDataSyncImpl.java
@@ -22,6 +22,8 @@
 package com.iemr.common.service.ctiCall;
 
 import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
@@ -86,24 +88,29 @@ public String callUrl(String urlRequest) {
 	@Override
 	public void ctiDataSync() {
 		List<Objects[]> resultSet = null;
-		Date date = new Date();
-		java.sql.Date sqlDate = new java.sql.Date(date.getTime());
-		String text = sqlDate.toString();
-		Timestamp endDate = new Timestamp(sqlDate.getTime());
-		Calendar calendar = Calendar.getInstance();
-		calendar.setTime(sqlDate);
-		logger.info("CZduration: " + CZduration);
-		calendar.add(Calendar.DATE, -(Integer.parseInt(CZduration)));
-		Date beforeDate = calendar.getTime();
-		Timestamp startDate = new Timestamp(beforeDate.getTime());
+
+		
+		 // Get the current date
+	       LocalDate currentDate = LocalDate.now();
+	       // Calculate three days before the current date
+	       LocalDate startDate = currentDate.minusDays(3);
+	       // Calculate two days before the current date
+	       LocalDate endDate = currentDate.minusDays(2);
+	       // Convert LocalDate to LocalDateTime to set time as 00:00:00
+	       LocalDateTime startDateTime = startDate.atTime(0, 0, 0);
+	       LocalDateTime endDateTime = endDate.atTime(23, 59, 59);
+	       // Convert LocalDateTime to Timestamp
+	       Timestamp startTimeStamp = Timestamp.valueOf(startDateTime);
+	       Timestamp endTimeStamp = Timestamp.valueOf(endDateTime);
+		
 		// application properties will have a config date variable.
-		logger.info("startDate: " + startDate);
-		logger.info("endDate: " + endDate);
-		List<BeneficiaryCall> list = callReportRepo.getAllBenCallIDetails(startDate, endDate);
+		logger.info("startDate: " + startTimeStamp);
+		logger.info("endDate: " + endTimeStamp);
+		List<BeneficiaryCall> list = callReportRepo.getAllBenCallIDetails(startTimeStamp, endTimeStamp);
 
 		if (!list.isEmpty()) {
 			
-			// List<Long> benList = new ArrayList<>();
+		
 			String callDuartion = null;
 			String filePath = null;
 			String URL = null;
@@ -119,22 +126,14 @@ public void ctiDataSync() {
 						JSONObject requestFile = new JSONObject();
 						requestFile.put("agent_id", call.getAgentID());
 						requestFile.put("session_id", call.getCallID());
-//						OutputResponse response1 = ctiService.getVoiceFile(requestFile.toString(), "extra parameter");
-//						if (response1.getStatusCode() == OutputResponse.SUCCESS) {
-//							CTIVoiceFile getVoiceFile = InputMapper.gson().fromJson(response1.getData(),
-//									CTIVoiceFile.class);
-//							String recordingFilePath = getVoiceFile.getPath() + "/" + getVoiceFile.getFilename();
-////						beneficiaryCallRepository.updateVoiceFilePathNew(benificiaryCall.getAgentID(),
-////								benificiaryCall.getCallID(), recordingFilePath, null);
-//							recordingPath = ctiLoggerURL + "/" + recordingFilePath;
+
 						OutputResponse response1 = ctiService.getVoiceFileNew(requestFile.toString(), "extra parameter");
 						if(response1 != null && response1.getStatusCode() == 200) {
 							
 							CTIResponse ctiResponsePath = InputMapper.gson().fromJson(response1.getData(),
 									CTIResponse.class);
 							String recordingFilePath = ctiResponsePath.getResponse().toString();
-//							beneficiaryCallRepository.updateVoiceFilePathNew(call.getAgentID(),
-//									call.getCallID(), recordingFilePath.substring(20), null);
+
 							if(recordingFilePath.length() > 20)
 								recordingPath = recordingFilePath.substring(20);
 							logger.info("recordingPath: " + recordingPath);

From 7232eef3c051c09419312fd8bb471e38e584bf48 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Fri, 17 May 2024 11:43:26 +0530
Subject: [PATCH 16/23] cough file changes

---
 .../lungassessment/LungAssessmentService.java |  2 +-
 .../LungAssessmentServiceImpl.java            | 22 +++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentService.java b/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentService.java
index 7ed527b1..5fc1cc48 100644
--- a/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentService.java
+++ b/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentService.java
@@ -27,7 +27,7 @@ public interface LungAssessmentService {
 
 	public String getLungAssessmentAdminLogin(String email, String password) throws Exception;
 
-	public Boolean verifyCough(MultipartFile file, String authToken, Long patientId) throws Exception;
+	public Boolean verifyCough(MultipartFile file, String authToken, Long patientId, String tempFileName) throws Exception;
 
 	String getAssesment(String assesmentId) throws Exception;
 
diff --git a/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentServiceImpl.java b/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentServiceImpl.java
index 8903cd3f..320c7a0a 100644
--- a/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/lungassessment/LungAssessmentServiceImpl.java
@@ -26,7 +26,7 @@
 import java.io.FileOutputStream;
 import java.util.List;
 
-import javax.xml.ws.http.HTTPException;
+//import javax.xml.ws.http.HTTPException;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -126,10 +126,11 @@ public String getLungAssessmentAdminLogin(String email, String password) throws
 
 			logger.info("Lung assessment authentication response: " + lungAssessmentToken);
 
-		} catch (HTTPException e) {
-			logger.error("Lung assessment authentication error : " + e.getMessage(), e);
-			throw new RuntimeException("get authentication failed with error", e);
-		} catch (Exception e) {
+		} /*
+			 * catch (HTTPException e) {
+			 * logger.error("Lung assessment authentication error : " + e.getMessage(), e);
+			 * throw new RuntimeException("get authentication failed with error", e); }
+			 */catch (Exception e) {
 			logger.error("Lung assessment authentication error : " + e.getMessage(), e);
 			throw new RuntimeException("get authentication failed with error", e);
 		}
@@ -137,7 +138,7 @@ public String getLungAssessmentAdminLogin(String email, String password) throws
 	}
 
 	@Override
-	public Boolean verifyCough(MultipartFile file, String authToken, Long patientId) throws Exception {
+	public Boolean verifyCough(MultipartFile file, String authToken, Long patientId, String tempFileName) throws Exception {
 
 		try {
 
@@ -157,7 +158,6 @@ public Boolean verifyCough(MultipartFile file, String authToken, Long patientId)
 			headers.add("accessToken", authToken);
 
 			byte[] bytes = file.getBytes();
-			String tempFileName = "coughSoundVerify" + patientId + System.currentTimeMillis() + ".wav";
 			BufferedOutputStream stream = new BufferedOutputStream(
 					new FileOutputStream(new File(lungAssessmentPath + tempFileName)));
 			stream.write(bytes);
@@ -228,7 +228,9 @@ public String initiateAssesment(String request, MultipartFile file) throws Excep
 			if (lungAssessmentToken == null || (((currTime - authCreatedAt) / (60 * 1000))) > 110)
 				lungAssessmentToken = getLungAssessmentAdminLogin(decryptlungAssessmentEmail, decryptlungAssessmentPassword);
 
-			Boolean isCoughValidateSuccess = verifyCough(file, lungAssessmentToken, lungAssessmentAssessmentRequestObj.getPatientId());
+			String tempFileName = "coughSoundAssessment" + lungAssessmentAssessmentRequestObj.getPatientId()
+			+ System.currentTimeMillis() + ".wav";
+			Boolean isCoughValidateSuccess = verifyCough(file, lungAssessmentToken, lungAssessmentAssessmentRequestObj.getPatientId(), tempFileName);
 
 			if (isCoughValidateSuccess) {
 				RestTemplate restTemplate = new RestTemplate();
@@ -241,8 +243,6 @@ public String initiateAssesment(String request, MultipartFile file) throws Excep
 				resultSet = lungAssessmentRepository.save(lungAssessmentAssessmentRequestObj);
 
 				byte[] bytes = file.getBytes();
-				String tempFileName = "coughSoundAssessment" + lungAssessmentAssessmentRequestObj.getPatientId()
-						+ System.currentTimeMillis() + ".wav";
 				BufferedOutputStream stream = new BufferedOutputStream(
 						new FileOutputStream(new File("lungAssessmentPath" + tempFileName)));
 				stream.write(bytes);
@@ -255,7 +255,7 @@ public String initiateAssesment(String request, MultipartFile file) throws Excep
 				bodyMap.add("gender", lungAssessmentAssessmentRequestObj.getGender());
 				bodyMap.add("assessmentId", lungAssessmentAssessmentRequestObj.getAssessmentId());
 				bodyMap.add("patientId", lungAssessmentAssessmentRequestObj.getPatientId());
-				bodyMap.add("coughsoundfile", new FileSystemResource("swaasaPath" + tempFileName));
+				bodyMap.add("coughsoundfile", new FileSystemResource(lungAssessmentPath + tempFileName));
 
 				HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(bodyMap, headers);
 

From 3934e5793d66598032172dc18bc38ec49f542d76 Mon Sep 17 00:00:00 2001
From: Ancy Riju <AN40085822@wipro.com>
Date: Thu, 23 May 2024 12:46:52 +0530
Subject: [PATCH 17/23] discarding biometric changes

---
 pom.xml                                       |  13 -
 src/main/environment/common_test.properties   |   3 -
 .../biometric/BiometricController.java        |  44 ----
 .../service/biometric/BiometricService.java   |   7 -
 .../biometric/BiometricServiceImpl.java       | 223 ------------------
 5 files changed, 290 deletions(-)
 delete mode 100644 src/main/java/com/iemr/common/controller/biometric/BiometricController.java
 delete mode 100644 src/main/java/com/iemr/common/service/biometric/BiometricService.java
 delete mode 100644 src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java

diff --git a/pom.xml b/pom.xml
index 3a9bb7d1..b56a968d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,19 +48,6 @@
 		</repository>
 	</repositories>
 	<dependencies>
-
-		<dependency>
-		<groupId>org.apache.httpcomponents</groupId>
-		<artifactId>httpclient</artifactId>
-		
-		</dependency>
-		<!-- https://mvnrepository.com/artifact/xmlpull/xmlpull -->
-<dependency>
-    <groupId>xmlpull</groupId>
-    <artifactId>xmlpull</artifactId>
-    <version>1.1.3.1</version>
-</dependency>
-
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter</artifactId>
diff --git a/src/main/environment/common_test.properties b/src/main/environment/common_test.properties
index 6f25e1a3..5c5514bb 100644
--- a/src/main/environment/common_test.properties
+++ b/src/main/environment/common_test.properties
@@ -157,9 +157,6 @@ eSanjeevani.source: 11001
 eSanjeevani.registerPatient: https://preprod.esanjeevaniopd.xyz/uat/ps/api/v1/Patient
 eSanjeevani.routeUrl: https://uat.esanjeevani.in/user/signin
 
-biometric.discover.url = http://127.0.0.1:port/
-biometric.deviceInfo.url = http://127.0.0.1:port/rd/info
-biometric.capture.url = http://127.0.0.1:port/rd/capture
 eAusadhaUrl=https://dlc.kar.nic.in/e-services/api/DWInstituteInward
 
 eausadhaAuthorization=<Enter eausadha authorization key>
diff --git a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java b/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
deleted file mode 100644
index 79546c87..00000000
--- a/src/main/java/com/iemr/common/controller/biometric/BiometricController.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.iemr.common.controller.biometric;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.CrossOrigin;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestHeader;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
- 
-
-import com.iemr.common.service.biometric.BiometricService;
-import com.iemr.common.utils.response.OutputResponse;
-
- 
-
-import io.swagger.annotations.ApiOperation;
-
-@CrossOrigin
-@RestController
-@RequestMapping(value = "/biometric")
-public class BiometricController {
-	private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
-	@Autowired
-	private BiometricService biometricService;
-	@CrossOrigin
-	@RequestMapping(value = { "/getBiometricData/{pid}" }, method = { RequestMethod.GET }, headers = "Authorization")
-	public String saveBenNurseDataCAC(@PathVariable("pid") String pid,
-			@RequestHeader(value = "Authorization") String Authorization) {
-		OutputResponse response = new OutputResponse();
-		try {
-			String pidResponse = biometricService.getBioData(pid);
-			response.setResponse(pidResponse);
-		}catch (Exception e) {
-			logger.error("Error while fetching Biometric data : "+e.getMessage());
-		}
-		return response.toString();
-	}
-}
\ No newline at end of file
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricService.java b/src/main/java/com/iemr/common/service/biometric/BiometricService.java
deleted file mode 100644
index af3d400d..00000000
--- a/src/main/java/com/iemr/common/service/biometric/BiometricService.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.iemr.common.service.biometric;
-
-public interface BiometricService {
-
-	String getBioData(String pid);
-
-}
diff --git a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java b/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
deleted file mode 100644
index 0789ee86..00000000
--- a/src/main/java/com/iemr/common/service/biometric/BiometricServiceImpl.java
+++ /dev/null
@@ -1,223 +0,0 @@
-package com.iemr.common.service.biometric;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URI;
-import java.net.URL;
-import java.util.Base64;
-import java.util.stream.Collectors;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHeaders;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONObject;
-import org.json.XML;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Text;
-
-@Service
-public class BiometricServiceImpl implements BiometricService {
-	private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
-
-	@Value("${biometric.discover.url}")
-	String discoverUrl;
-
-	@Value("${biometric.deviceInfo.url}")
-	private String deviceInfoUrl;
-
-	@Value("${biometric.capture.url}")
-	private String captureUrl;
-	
-	@Override
-	public String getBioData(String env) {
-		String pidRes = null;
-		try {
-			String portNumber = null;
-			for (int i = 11100; i <= 11120; i++) {
-				String port = String.valueOf(i);
-				String apiUrl = discoverUrl.replace("port", port);
-
-				String httpMethod = "RDSERVICE";
-				HttpClient httpClient = HttpClientBuilder.create().build();
-
-				HttpRequestBase request = new HttpRequestBase() {
-					@Override
-					public String getMethod() {
-						return httpMethod;
-					}
-				};
-				request.setURI(URI.create(apiUrl));
-				request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
-				try {
-					HttpResponse response = httpClient.execute((HttpUriRequest) request);
-
-					HttpEntity entity = response.getEntity();
-					String responseString = EntityUtils.toString(entity, "UTF-8");
-					if (!responseString.contains("NOTREADY")) {
-						portNumber = port;
-						break;
-					}
-				} catch (Exception e) {
-					logger.error("Error while checking biometric status: " + e.getMessage());
-				}
-			}
-			String xmlResponse = getDeviceInfo(portNumber, env);
-			if(xmlResponse != null) {
-				pidRes = Base64.getEncoder().encodeToString(xmlResponse.getBytes());
-			}
-		} catch (Exception e) {
-			logger.error("Error while getting biometric data: " + e.getMessage());
-		}
-		return pidRes;
-	}
-
-	private String getDeviceInfo(String portNumber, String env) {
-		String deviceRes = null;
-		String deviceInforURL = deviceInfoUrl.replace("port", portNumber);
-
-		String httpMethod = "DEVICEINFO";
-		HttpClient httpClient = HttpClientBuilder.create().build();
-
-		HttpRequestBase request = new HttpRequestBase() {
-			@Override
-			public String getMethod() {
-				return httpMethod;
-			}
-		};
-		request.setURI(URI.create(deviceInforURL));
-		request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
-		try {
-			HttpResponse response = httpClient.execute((HttpUriRequest) request);
-
-			HttpEntity entity = response.getEntity();
-			String responseString = EntityUtils.toString(entity, "UTF-8");
-
-			if (null != response && response.getStatusLine().getStatusCode() == 200) {
-				deviceRes = getCaptureInfo(portNumber, env);
-			}
-		} catch (Exception e) {
-			logger.error("Error while getting biometric device info : " + e.getMessage());
-		}
-		return deviceRes;
-	}
-
-	private String getCaptureInfo(String portNumber, String env) throws Exception {
-		String captureRes = null;
-		if (null != portNumber) {
-			try {
-				// Create a new DocumentBuilder
-				DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
-				DocumentBuilder docBuilder = dbFactory.newDocumentBuilder();
-
-				// Create a new Document
-				Document doc = docBuilder.newDocument();
-
-				// Create the root element <PidOptions>
-				Element pidOptionsElement = doc.createElement("PidOptions");
-				pidOptionsElement.setAttribute("ver", "1.0");
-				doc.appendChild(pidOptionsElement);
-
-				// Create the <Opts> element and its attributes
-				Element optsElement = doc.createElement("Opts");
-				optsElement.setAttribute("fCount", "1");
-				optsElement.setAttribute("fType", "2");
-				optsElement.setAttribute("iCount", "0");
-				optsElement.setAttribute("pCount", "0");
-				optsElement.setAttribute("pgCount", "2");
-				optsElement.setAttribute("format", "0");
-				optsElement.setAttribute("pidVer", "2.0");
-				optsElement.setAttribute("timeout", "10000");
-				optsElement.setAttribute("pTimeout", "20000");
-				optsElement.setAttribute("wadh", "E0jzJ/P8UopUHAieZn8CKqS4WPMi5ZSYXgfnlfkWjrc=");
-				optsElement.setAttribute("posh", "UNKNOWN");
-				optsElement.setAttribute("env", env);
-				pidOptionsElement.appendChild(optsElement);
-
-				// Create the <CustOpts> element
-				Element custOptsElement = doc.createElement("CustOpts");
-				pidOptionsElement.appendChild(custOptsElement);
-
-				// Create the <Param> element inside <CustOpts> with its attributes
-				Element paramElement = doc.createElement("Param");
-				paramElement.setAttribute("name", "mantrakey");
-				paramElement.setAttribute("value", "");
-				custOptsElement.appendChild(paramElement);
-
-				// Create a text node for indentation
-				Text text = doc.createTextNode("\n");
-				pidOptionsElement.insertBefore(text, optsElement);
-
-				// Print the XML content to the console
-				String xml = XMLToString(doc);
-				
-				String capturingURL = captureUrl.replace("port", portNumber);
-				URL url = new URL(capturingURL);
-
-				String httpMethod = "CAPTURE";
-				HttpClient httpClient = HttpClients.createDefault();
-
-				HttpEntityEnclosingRequestBase request = new HttpEntityEnclosingRequestBase() {
-					@Override
-					public String getMethod() {
-						return httpMethod;
-					}
-				};
-				request.setURI(URI.create(capturingURL));
-				StringEntity entity2 = new StringEntity(xml);
-				request.setEntity(entity2);
-				request.setHeader(HttpHeaders.CONTENT_TYPE, "TEXT/XML");
-				
-				HttpResponse response = httpClient.execute(request);
-				response.setHeader("Content-Type", "TEXT/XML");
-				InputStream entity1 = response.getEntity().getContent();
-				String result = new BufferedReader(new InputStreamReader(entity1))
-						   .lines().collect(Collectors.joining("\n"));
-				if(result.contains("Success")) {
-					captureRes = result;
-				} else {
-					throw new Exception("Capture timed out");
-				}
-				
-		} catch (ParserConfigurationException e) {
-			logger.error("Error while capturing fingerprint: " + e.getMessage());
-		}
-		}
-		return captureRes;
-	}
-
-	private String XMLToString(Document doc) {
-		String response = null;
-		try {
-			javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
-			javax.xml.transform.Transformer transformer = tf.newTransformer();
-			transformer.setOutputProperty(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
-			javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(
-					new java.io.StringWriter());
-			javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(doc);
-			transformer.transform(source, result);
-			response = result.getWriter().toString();
-		} catch (Exception e) {
-			logger.error("Error while converting XML to String: " + e.getMessage());
-		}
-		return response;
-	}
-
-}

From 77a84d5aafa7333725293706add123003a2e2dbc Mon Sep 17 00:00:00 2001
From: devikasuresh20 <57424483+devikasuresh20@users.noreply.github.com>
Date: Mon, 3 Jun 2024 17:40:05 +0530
Subject: [PATCH 18/23] CTI data check scheduler changes - callTypeId null
 issue (#105)

* Added limit condition while fetching Item stock entry details in eaushadha API

* Minor modifications in 1097 referral sms template

* Added institute name along with referral SMS

* Removed myapp propeties and minor change in interceptor.

* Change in Phone No comparison while fetching call audit details

* Corrected empty array response in JsonObject - editBenCommunity

* Reverted - update community education changes

* Added cti data sync scheduler execution time change and start date and end date change for last two days

* Added cti data sync scheduler execution time change and start date and end date change for last two days

* Added cti data sync scheduler execution time

* Removed commented code

* cti-datacheck changes - calltype Id updation if it's null

---------

Co-authored-by: Devika <de40034072@wipro.com>
---
 src/main/environment/common_test.properties   |  1 +
 .../NHMDetailCallReportScheduler.java         | 89 +++++++++++++++++--
 .../repository/report/CallReportRepo.java     |  9 +-
 3 files changed, 88 insertions(+), 11 deletions(-)

diff --git a/src/main/environment/common_test.properties b/src/main/environment/common_test.properties
index 5c5514bb..2fae65eb 100644
--- a/src/main/environment/common_test.properties
+++ b/src/main/environment/common_test.properties
@@ -13,6 +13,7 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 secondary.datasource.username=<Enter your DB_REPORTING username>
 secondary.datasource.password=<Enter your DB_REPORTING password>
 secondary.datasource.url=<Enter DB_REPORTING URL here>
+secondary.datasource.driver-class-name=com.mysql.jdbc.Drive
 
 encDbUserName=zFlYsp9Z0s+lRvLM15A3g/Ba0w8VGs/1usuW7EsGF3k=
 encDbPass=JGGAGn5wTlrbTLUHY+5BzfBa0w8VGs/1usuW7EsGF3k=
diff --git a/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java b/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java
index 8a9d4aed..3451d56f 100644
--- a/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java
+++ b/src/main/java/com/iemr/common/controller/nhmdashboard/NHMDetailCallReportScheduler.java
@@ -4,9 +4,13 @@
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
+import java.util.Set;
 
 import org.apache.xml.security.stax.config.ConfigurationProperties;
+import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,6 +21,7 @@
 
 import com.iemr.common.data.callhandling.BeneficiaryCall;
 import com.iemr.common.data.nhm_dashboard.DetailedCallReport;
+import com.iemr.common.repository.callhandling.IEMRCalltypeRepositoryImplCustom;
 import com.iemr.common.repository.nhm_dashboard.DetailedCallReportRepo;
 import com.iemr.common.repository.report.CallReportRepo;
 import com.iemr.common.utils.config.ConfigProperties;
@@ -31,12 +36,14 @@ public class NHMDetailCallReportScheduler {
 	@Autowired
 	private CallReportRepo callReportRepo;
 
+	@Autowired
+	private IEMRCalltypeRepositoryImplCustom iEMRCalltypeRepositoryImplCustom;
+
 	Logger logger = LoggerFactory.getLogger(this.getClass().getName());
 
 	@Value("${start-ctidatacheck-scheduler}")
 	private boolean startCtiDataCheckFlag;
 
-
 	@Scheduled(cron = "${cron-scheduler-ctidatacheck}")
 	public void detailedCallReport() {
 		if (startCtiDataCheckFlag) {
@@ -48,7 +55,7 @@ public void detailedCallReport() {
 				String[] dateArr = date.toString().split("T");
 				endDate = dateArr[0].concat(" 23:59:59");
 				fromDate = dateArr[0].concat(" 00:00:01");
-
+                
 				Timestamp fromTime = Timestamp.valueOf(fromDate);
 				Timestamp endTime = Timestamp.valueOf(endDate);
 				logger.info("Call detailed report check request - FromTime -" + fromTime + "Endtime - " + endTime);
@@ -57,19 +64,52 @@ public void detailedCallReport() {
 				for (DetailedCallReport detailedCallReport : findByCallStartTimeBetween) {
 					String phoneNo = detailedCallReport.getPHONE();
 					String sessionID = detailedCallReport.getSession_ID();
-					int existRecord = callReportRepo.getBenCallDetailsBySessionIDAndPhone(sessionID, phoneNo);
-					if (existRecord != 0) {
+					BeneficiaryCall existRecord = callReportRepo.getBenCallDetailsBySessionIDAndPhone(sessionID,phoneNo);
+					if (existRecord != null) {
 						logger.info("Record already present in t_bencall table with sessionID : " + sessionID
 								+ " phoneNo : " + phoneNo);
+						logger.info("Existing record from t_bencall: " + existRecord);
 						if (null != detailedCallReport.getOrientation_Type()
 								&& detailedCallReport.getOrientation_Type().equalsIgnoreCase("OUTBOUND")) {
-							callReportRepo.updateIsOutboundForCall(true, sessionID, phoneNo );
+							
+							if(existRecord.getCallTypeID() == null) {
+								logger.info("Called Service Id: " + existRecord.getCalledServiceID());
+							// Fetching callTypeId
+							Integer callTypeId = getCallTypeId(true, existRecord.getCalledServiceID(),
+									detailedCallReport);
+							
+							logger.info("CallTypeId after comparison: " + callTypeId);
+							if (callTypeId != null) {
+								callReportRepo.updateIsOutboundForCallWithCallType(true, sessionID, phoneNo,callTypeId);
+							} else {
+								callReportRepo.updateIsOutboundForCall(true, sessionID, phoneNo);
+							}
+							}
+							else {
+								callReportRepo.updateIsOutboundForCall(true, sessionID, phoneNo);
+							}
 						} else {
-							callReportRepo.updateIsOutboundForCall(false, sessionID, phoneNo );
+							if(existRecord.getCallTypeID() == null) {
+								
+								logger.info("Called Service Id: " + existRecord.getCalledServiceID());
+							// Fetching callTypeId
+							Integer callTypeId = getCallTypeId(false, existRecord.getCalledServiceID(),
+									detailedCallReport);
+
+							logger.info("CallTypeId after comparison: " + callTypeId);
+							if (callTypeId != null) {
+								callReportRepo.updateIsOutboundForCallWithCallType(false, sessionID, phoneNo, callTypeId);
+							} else {
+								callReportRepo.updateIsOutboundForCall(false, sessionID, phoneNo);
+							}
+							
+						}
+							else {
+								callReportRepo.updateIsOutboundForCall(false, sessionID, phoneNo);
+							}
 						}
 					} else {
-						logger.info("Record missed in t_bencall table with sessionID : " + sessionID + " phoneNo : "
-								+ phoneNo);
+						logger.info("Record missed in t_bencall table with sessionID : " + sessionID + " phoneNo : " + phoneNo);
 						BeneficiaryCall callDetail = getCallDetail(detailedCallReport);
 						callReportRepo.save(callDetail);
 					}
@@ -82,6 +122,36 @@ public void detailedCallReport() {
 
 	}
 
+	private Integer getCallTypeId(Boolean isOutbound, Integer calledServiceId, DetailedCallReport detailedCallReport) {
+		Set<Objects[]> callTypesArray = new HashSet<Objects[]>();
+
+		if (detailedCallReport.getAgent_Disposition_Category() != null
+				&& detailedCallReport.getAgent_Disposition() != null) {
+			if (isOutbound == true) {
+				callTypesArray = iEMRCalltypeRepositoryImplCustom.getOutboundCallTypes(calledServiceId, true);
+			} else {
+				callTypesArray = iEMRCalltypeRepositoryImplCustom.getInboundCallTypes(calledServiceId, true);
+			}
+
+			for (Object[] object : callTypesArray) {
+				String callGroupType = (String) object[3];
+				String callType = (String) object[0];
+				String detailedCallGroupType = detailedCallReport.getAgent_Disposition_Category().replace("_", " ");
+				String detailedCallType = detailedCallReport.getAgent_Disposition().replace("_", " ");
+				logger.info("Detailed Call - CallGroupType: " + detailedCallGroupType);
+				logger.info("Detailed Call - CallType: " + detailedCallType);
+				
+				if (callGroupType.equalsIgnoreCase(detailedCallGroupType)
+						&& callType.equalsIgnoreCase(detailedCallType)) {
+					return (Integer) object[1];
+				}
+			}
+		}
+
+		return null;
+
+	}
+
 	private BeneficiaryCall getCallDetail(DetailedCallReport detailedCallReport) {
 		BeneficiaryCall beneficiaryCall = new BeneficiaryCall();
 		beneficiaryCall.setCallID(detailedCallReport.getSession_ID());
@@ -104,7 +174,8 @@ private BeneficiaryCall getCallDetail(DetailedCallReport detailedCallReport) {
 		beneficiaryCall.setCreatedBy("Admin");
 
 		beneficiaryCall.setCallDuration(String.valueOf(detailedCallReport.getCall_Duration()));
-
+		
+		
 		return beneficiaryCall;
 
 	}
diff --git a/src/main/java/com/iemr/common/repository/report/CallReportRepo.java b/src/main/java/com/iemr/common/repository/report/CallReportRepo.java
index 3104427e..2e1e4dba 100644
--- a/src/main/java/com/iemr/common/repository/report/CallReportRepo.java
+++ b/src/main/java/com/iemr/common/repository/report/CallReportRepo.java
@@ -44,13 +44,18 @@ public interface CallReportRepo extends CrudRepository<BeneficiaryCall, Integer>
 			+ "and report.createdDate >= :startDate and report.createdDate <= :endDate ")
 	public List<BeneficiaryCall> getAllBenCallIDetails(@Param("startDate") Timestamp startDate, @Param("endDate") Timestamp endDate);//start date and end date as param for x days.
 
-	@Query("SELECT COUNT(*) FROM BeneficiaryCall call WHERE call.callID = :sessionID and call.phoneNo = :phoneNo")
-	public int getBenCallDetailsBySessionIDAndPhone(@Param("sessionID") String sessionID,@Param("phoneNo") String phoneNo);
+	@Query("SELECT call FROM BeneficiaryCall call WHERE call.callID = :sessionID and call.phoneNo = :phoneNo")
+	public BeneficiaryCall getBenCallDetailsBySessionIDAndPhone(@Param("sessionID") String sessionID,@Param("phoneNo") String phoneNo);
 	
 	@Transactional
 	@Modifying
 	@Query("update BeneficiaryCall set isOutbound= :isOutbound where callID = :callID and phoneNo= :phoneNo")
 	public int updateIsOutboundForCall(@Param("isOutbound") boolean isOutbound, @Param("callID") String callID, @Param("phoneNo") String phoneNo );
+	
+	@Transactional
+	@Modifying
+	@Query("update BeneficiaryCall set isOutbound= :isOutbound, callTypeID= :callTypeID where callID = :callID and phoneNo= :phoneNo")
+	public int updateIsOutboundForCallWithCallType(@Param("isOutbound") boolean isOutbound, @Param("callID") String callID, @Param("phoneNo") String phoneNo, @Param("callTypeID") Integer callTypeID );
 }
 
 

From d9dd235e3000b1a86135c1cf177bb993cde78194 Mon Sep 17 00:00:00 2001
From: ravishanigarapu <133210792+ravishanigarapu@users.noreply.github.com>
Date: Tue, 6 Aug 2024 17:29:50 +0530
Subject: [PATCH 19/23] Abha search change (#109)

---
 .../IEMRSearchUserServiceImpl.java            | 32 +++++++++++++++----
 1 file changed, 26 insertions(+), 6 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 159f2b1f..43d56e94 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/IEMRSearchUserServiceImpl.java
@@ -188,22 +188,42 @@ public List<BeneficiaryModel> userExitsCheckWithHealthId_ABHAId(String healthID,
 			throws Exception {
 		// result list
 		List<BeneficiaryModel> beneficiaryList = new ArrayList<BeneficiaryModel>();
-		// search patient by ben id, call Identity API
-		List<BeneficiariesDTO> listBen = identityBeneficiaryService.getBeneficiaryListByHealthID_ABHAAddress(healthID,
-				auth, is1097);
+		List<BeneficiariesDTO> listBen = null;
+		if (healthID.contains("@")) {
+			listBen = identityBeneficiaryService.getBeneficiaryListByHealthID_ABHAAddress(healthID, auth, is1097);
+		} else {
+			String healthIdNumber = getHealthId(healthID);
+			listBen = identityBeneficiaryService.getBeneficiaryListByHealthIDNo_ABHAIDNo(healthIdNumber, auth, is1097);
+		}
 
 		beneficiaryList = getBeneficiaryListFromMapper(listBen);
 		return beneficiaryList;
 	}
-
+	private String getHealthId(String healthID) {
+		String healthIdNumber = null;
+		if (null != healthID) {
+			if (healthID.length() == 17) {
+				healthIdNumber = healthID;
+			} else {
+				StringBuilder stringBuilder = new StringBuilder();
+				stringBuilder.append(healthID.substring(0, 2)).append("-");
+				stringBuilder.append(healthID.substring(2, 6)).append("-");
+				stringBuilder.append(healthID.substring(6, 10)).append("-");
+				stringBuilder.append(healthID.substring(10));
+				String formattedHealthID = stringBuilder.toString();
+				healthIdNumber = formattedHealthID;
+			}
+		}
+		return healthIdNumber;
+	}
 	// search patient by healthidNo / ABHA Id No
 	@Override
 	public List<BeneficiaryModel> userExitsCheckWithHealthIdNo_ABHAIdNo(String healthIDNo, String auth, Boolean is1097)
 			throws Exception {
 		// result list
 		List<BeneficiaryModel> beneficiaryList = new ArrayList<BeneficiaryModel>();
-		// search patient by ben id, call Identity API
-		List<BeneficiariesDTO> listBen = identityBeneficiaryService.getBeneficiaryListByHealthIDNo_ABHAIDNo(healthIDNo,
+		String healthId = getHealthId(healthIDNo);
+		List<BeneficiariesDTO> listBen = identityBeneficiaryService.getBeneficiaryListByHealthIDNo_ABHAIDNo(healthId,
 				auth, is1097);
 
 		beneficiaryList = getBeneficiaryListFromMapper(listBen);

From f6a895e7e36fccb082dba7950391d7955c2f9b76 Mon Sep 17 00:00:00 2001
From: Helen Grace Karyamsetty
 <133211481+helenKaryamsetty@users.noreply.github.com>
Date: Tue, 20 Aug 2024 14:52:47 +0530
Subject: [PATCH 20/23] 104 Application- Time to consume is not showing in
 Prescription SMS (#110)

* cti changes- saving response in failure cases too

* call closure issue resolved

* WASA change

* bencall data check with call detail report data Scheduler and logs
addition

* pushed properties for cti data check scheduler

* pushed properties for cti data check

* added properties to cti properties

* 104 application Time to consume is not showing in prescription SMS -
AMM-868

---------

Co-authored-by: KA40094929 <KA40094929@L-158018332.wipro.com>
Co-authored-by: appuser <appuser@WIPRO-DEV>
Co-authored-by: appuser <appuser@amritwprdev.piramalswasthya.org>
---
 .../java/com/iemr/common/service/sms/SMSServiceImpl.java  | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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 0de15785..7a78c036 100644
--- a/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
@@ -1155,10 +1155,10 @@ private String getPrescriptionData(String className, String methodName, SMSReque
 					: "";
 			variableValue = drugForm;
 			break;
-//		case "frequency":
-//			String frequency = prescribedDrug.getFrequency() != null ? prescribedDrug.getFrequency() + " " : "";
-//			variableValue = frequency;
-//			break;
+		case "frequency":
+			String freq = prescribedDrug.getFrequency() != null ? prescribedDrug.getFrequency() + " " : "";
+			variableValue = freq;
+			break;
 		case "timeToConsume":
 			String frequency = prescribedDrug.getFrequency() != null ? prescribedDrug.getFrequency() + " " : "";
 			variableValue = frequency;

From 1c74b1bc40566854a14401c585f2270ca5c354d1 Mon Sep 17 00:00:00 2001
From: Thejas Elandassery <thejaselandassery@gmail.com>
Date: Sun, 25 Aug 2024 14:37:31 +0530
Subject: [PATCH 21/23] Added faceEmbedding field

---
 .../BeneficiaryRegistrationController.java    |  3 ++-
 .../common/data/beneficiary/Beneficiary.java  | 20 +++++++++++++++++++
 .../model/beneficiary/BeneficiaryModel.java   |  5 +++++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java b/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java
index 598a78d4..01da9a30 100644
--- a/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java
+++ b/src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java
@@ -188,7 +188,8 @@ public String createBeneficiary(
 					+ "\"healthCareWorkerID\":\"Short\",\"communityID\":\"Integer\",\"districtID\":\"Integer\",\"stateID\":\"Integer\","
 					+ "\"pinCode\":\"String\",\"blockID\":\"Integer\",\"districtBranchID\":\"Integer\",\"createdBy\":\"String\","
 					+ "\"addressLine1\":\"String\"},\"benPhoneMaps\":{\"parentBenRegID\":\"Long\",\"phoneNo\":\"String\","
-					+ "\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\",\"deleted\":\"Boolean\",\"createdBy\":\"String\"}}") @RequestBody BeneficiaryModel beneficiaryModel,
+					+ "\"phoneTypeID\":\"Integer\",\"benRelationshipID\":\"Integer\",\"deleted\":\"Boolean\",\"createdBy\":\"String\"},"
+					+ "\"faceEmbedding\":[\"Float\"]}") @RequestBody BeneficiaryModel beneficiaryModel,
 			HttpServletRequest httpRequest) {
 		OutputResponse response = new OutputResponse();
 
diff --git a/src/main/java/com/iemr/common/data/beneficiary/Beneficiary.java b/src/main/java/com/iemr/common/data/beneficiary/Beneficiary.java
index c8c1bf66..d66c8910 100644
--- a/src/main/java/com/iemr/common/data/beneficiary/Beneficiary.java
+++ b/src/main/java/com/iemr/common/data/beneficiary/Beneficiary.java
@@ -72,6 +72,8 @@ public class Beneficiary
 
 	private String titleName;
 
+	private List<Float> faceEmbedding;
+
 	@JsonIgnore
 
 	private Title m_title;
@@ -769,6 +771,23 @@ public Beneficiary(Long BeneficiaryRegID, String BeneficiaryID, String FirstName
 		this.benPhoneMaps = phoneMap;
 	}
 
+	public Beneficiary(Long BeneficiaryRegID, String BeneficiaryID, String FirstName, String MiddleName,
+			String LastName, Gender m_gender, Timestamp DOB, List<Float> faceEmbedding) {
+		this.beneficiaryRegID = BeneficiaryRegID;
+		this.beneficiaryID = BeneficiaryID;
+		this.firstName = FirstName;
+		this.middleName = MiddleName;
+		this.lastName = LastName;
+		this.m_gender = m_gender;
+		this.dOB = DOB;
+		if (DOB != null) {
+			this.age = Integer
+					.parseInt(formatYear.format(new Date(Calendar.getInstance().getTime().getTime() - DOB.getTime())))
+					- START_YEAR_1970;
+		}
+		this.faceEmbedding = faceEmbedding;
+	}
+
 	public Beneficiary(Long BeneficiaryRegID, String BeneficiaryID, String FirstName, String MiddleName,
 			String LastName, Gender m_gender, Timestamp DOB)
 	{
@@ -903,3 +922,4 @@ public Beneficiary()
 	// }
 
 }
+
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 ed0980a6..45a5bea7 100644
--- a/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
+++ b/src/main/java/com/iemr/common/model/beneficiary/BeneficiaryModel.java
@@ -242,6 +242,10 @@ public class BeneficiaryModel implements Comparable<BeneficiaryModel> {
 	private Boolean isD2D;
 
 	// END OF new column added for data sync
+	// new column added for face recognition
+	@Expose
+	private List<Float> faceEmbedding;
+	// END OF new column added for face recognition
 
 	// ABHA address
 	List<AbhaAddressDTO> abhaDetails;
@@ -376,3 +380,4 @@ public int compareTo(BeneficiaryModel ben) {
 		return this.beneficiaryRegID.compareTo(ben.beneficiaryRegID);
 	}
 }
+

From 7efa6789dde1fc0488051689f1073244d14b1933 Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Thu, 12 Sep 2024 16:43:00 +0530
Subject: [PATCH 22/23] faceEmbedding changes

---
 .../java/com/iemr/common/dto/identity/CommonIdentityDTO.java    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java b/src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java
index 52d63649..5efb2277 100644
--- a/src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java
+++ b/src/main/java/com/iemr/common/dto/identity/CommonIdentityDTO.java
@@ -89,6 +89,8 @@ public class CommonIdentityDTO {
 	private String title;
 	private Integer zoneId;
 	private String monthlyFamilyIncome;
+	
+	private List<Float> faceEmbedding;
 
 	// address
 	private Address currentAddress;

From 9f3a4d9523fad78c231756aab536616437383a7c Mon Sep 17 00:00:00 2001
From: Ravi Shanigarapu <ravi.shanigarapu@wipro.com>
Date: Tue, 17 Sep 2024 15:38:06 +0530
Subject: [PATCH 23/23] face Embedding changes

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

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 791bc51a..03478726 100644
--- a/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/beneficiary/RegisterBenificiaryServiceImpl.java
@@ -138,6 +138,7 @@ public String save(BeneficiaryModel beneficiaryModel, HttpServletRequest servlet
 //		logger.info("benificiaryDetails: " + beneficiaryModel);
 
 		CommonIdentityDTO identityDTO = identityMapper.beneficiaryModelCommonIdentityDTO(beneficiaryModel);
+		identityDTO.setFaceEmbedding(beneficiaryModel.getFaceEmbedding());
 		identityDTO.setEmergencyRegistration(beneficiaryModel.isEmergencyRegistration());
 		identityDTO
 				.setBenFamilyDTOs(identityMapper.benPhoneMapListToBenFamilyDTOList(beneficiaryModel.getBenPhoneMaps()));
