diff --git a/src/main/java/com/iemr/common/CommonApplication.java b/src/main/java/com/iemr/common/CommonApplication.java
index 689566bf..92d9e8f7 100644
--- a/src/main/java/com/iemr/common/CommonApplication.java
+++ b/src/main/java/com/iemr/common/CommonApplication.java
@@ -27,6 +27,7 @@
 import org.springframework.boot.web.support.SpringBootServletInitializer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.web.client.RestTemplate;
 
 import com.iemr.common.utils.IEMRApplBeans;
 
@@ -39,6 +40,11 @@ public IEMRApplBeans instantiateBeans() {
 		return new IEMRApplBeans();
 	}
 
+    @Bean
+    public RestTemplate restTemplate() {
+        return new RestTemplate();
+    }
+    
 	public static void main(String[] args) {
 		SpringApplication.run(CommonApplication.class, args);
 	}
diff --git a/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java b/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java
new file mode 100644
index 00000000..9d00c314
--- /dev/null
+++ b/src/main/java/com/iemr/common/controller/esanjeevani/ESanjeevaniController.java
@@ -0,0 +1,48 @@
+package com.iemr.common.controller.esanjeevani;
+
+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.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.esanjeevani.ESanjeevaniService;
+import com.iemr.common.utils.response.OutputResponse;
+
+import io.swagger.annotations.ApiOperation;
+
+@CrossOrigin
+@RestController
+@RequestMapping(value = "/esanjeevani", headers = "Authorization")
+public class ESanjeevaniController {
+
+	@Autowired
+	private ESanjeevaniService eSanjeevaniService;
+
+	private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
+	@CrossOrigin
+	@ApiOperation(value = "Register patient in E-Sanjeevani and send portal url to route", consumes = "application/json", produces = "application/json")
+	@RequestMapping(value = { "/getESanjeevaniUrl/{beneficiaryReqId}" }, method = { RequestMethod.GET })
+	public String registerESanjeevaniPatient(@PathVariable Long beneficiaryReqId) {
+		OutputResponse response = new OutputResponse();
+		try {
+			logger.info("E-Sangeevani register for benRegId - " + beneficiaryReqId);
+			String res = eSanjeevaniService.registerPatient(beneficiaryReqId);
+			if (res != null)
+				response.setResponse(res);
+			else 
+				response.setError(5000, "Error while fetching E-sanjeevani route URL");
+		} catch (Exception e) {
+			response.setError(5000, "Error while fetching E-sanjeevani route URL" + e.toString());
+		}
+
+		return response.toString();
+	}
+
+}
diff --git a/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java b/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java
index 073c5c5f..1eeebb26 100644
--- a/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java
+++ b/src/main/java/com/iemr/common/controller/users/IEMRAdminController.java
@@ -226,6 +226,7 @@ private String getConcurrentCheckSessionObjectAgainstUser(String userName) {
 
 	private void createUserMapping(User mUser, JSONObject resMap, JSONObject serviceRoleMultiMap,
 			JSONObject serviceRoleMap, JSONArray serviceRoleList, JSONObject previlegeObj) {
+		System.out.println(mUser);
 		String fName = mUser.getFirstName();
 		String lName = mUser.getLastName();
 		String mName = mUser.getMiddleName();
@@ -264,8 +265,11 @@ private void createUserMapping(User mUser, JSONObject resMap, JSONObject service
 				previlegeObj.getJSONObject(serv).put("agentID", m_UserServiceRoleMapping.getAgentID());
 				previlegeObj.getJSONObject(serv).put("agentPassword", m_UserServiceRoleMapping.getAgentPassword());
 			}
-			JSONArray roles = previlegeObj.getJSONObject(serv).getJSONArray("roles");
-			roles.put(new JSONObject(m_UserServiceRoleMapping.getM_Role().toString()));
+            JSONArray roles = previlegeObj.getJSONObject(serv).getJSONArray("roles");
+//            roles.put(new JSONObject(m_UserServiceRoleMapping.getM_Role().toString()));
+            JSONObject roleObject = new JSONObject(m_UserServiceRoleMapping.getM_Role().toString());
+            roleObject.put("isSanjeevani", m_UserServiceRoleMapping.getIsSanjeevani());
+            roles.put(roleObject);
 		}
 		Iterator<String> keySet = serviceRoleMultiMap.keys();
 		while (keySet.hasNext()) {
diff --git a/src/main/java/com/iemr/common/data/users/Role.java b/src/main/java/com/iemr/common/data/users/Role.java
index 3ef017a1..b1f59280 100644
--- a/src/main/java/com/iemr/common/data/users/Role.java
+++ b/src/main/java/com/iemr/common/data/users/Role.java
@@ -97,6 +97,10 @@ public class Role
 	@Expose
 	@Transient
 	private String agentID;
+	
+	@Expose
+	@Transient
+	private Boolean isSanjeevani;
 
 	// protected Role() {
 	// }
diff --git a/src/main/java/com/iemr/common/data/users/UserServiceRoleMapping.java b/src/main/java/com/iemr/common/data/users/UserServiceRoleMapping.java
index 785cc1a3..40a70daf 100644
--- a/src/main/java/com/iemr/common/data/users/UserServiceRoleMapping.java
+++ b/src/main/java/com/iemr/common/data/users/UserServiceRoleMapping.java
@@ -107,6 +107,10 @@ public class UserServiceRoleMapping
 	@Expose
 	@Column(name = "isOutbound")
 	private Boolean outbound;
+	
+	@Expose
+	@Column(name = "isSanjeevani")
+	private Boolean isSanjeevani;
 
 
 	// @Expose
@@ -297,7 +301,7 @@ public String toString()
 
 	public static UserServiceRoleMapping initializeUserRoleMappingObjs(Long USRMappingID, Long UserID, Integer roleID,
 			Role m_Role, Integer providerServiceMapID, ProviderServiceMapping m_ProviderServiceMapping,
-			String agentID,Boolean inbound, Boolean outbound, String agentPassword, Integer workingLocationID,
+			String agentID,Boolean inbound, Boolean outbound, Boolean isSanjeevani, String agentPassword, Integer workingLocationID,
 			ProviderServiceAddressMapping providerServiceAddressMapping)
 	{
 		UserServiceRoleMapping userRoleMapping = new UserServiceRoleMapping();
@@ -312,6 +316,7 @@ public static UserServiceRoleMapping initializeUserRoleMappingObjs(Long USRMappi
 		userRoleMapping.agentID = agentID;
 		userRoleMapping.inbound = inbound;
 		userRoleMapping.outbound = outbound;
+		userRoleMapping.isSanjeevani = isSanjeevani;
 		userRoleMapping.agentPassword = agentPassword;
 		userRoleMapping.workingLocationID = workingLocationID;
 		userRoleMapping.m_Role.setWorkingLocationID(workingLocationID);
diff --git a/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientAddress.java b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientAddress.java
new file mode 100644
index 00000000..14f3985b
--- /dev/null
+++ b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientAddress.java
@@ -0,0 +1,23 @@
+package com.iemr.common.model.esanjeevani;
+
+import lombok.Data;
+
+@Data
+public class ESanjeevaniPatientAddress {
+	
+    public String addressLine1;
+    public String addressType;
+    public String addressUse;
+    public int blockCode;
+    public String blockDisplay;
+    public int cityCode;
+    public String cityDisplay;
+    public String countryCode;
+    public String countryDisplay;
+    public int districtCode;
+    public String districtDisplay;
+    public String postalCode;
+    public int stateCode;
+    public String stateDisplay;
+
+}
diff --git a/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientContactDetail.java b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientContactDetail.java
new file mode 100644
index 00000000..bfe63102
--- /dev/null
+++ b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientContactDetail.java
@@ -0,0 +1,13 @@
+package com.iemr.common.model.esanjeevani;
+
+import lombok.Data;
+
+@Data
+public class ESanjeevaniPatientContactDetail {
+	
+    public boolean contactPointStatus;
+    public String contactPointType;
+    public String contactPointUse;
+    public String contactPointValue;
+
+}
diff --git a/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientRegistration.java b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientRegistration.java
new file mode 100644
index 00000000..cd1e3d90
--- /dev/null
+++ b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniPatientRegistration.java
@@ -0,0 +1,29 @@
+package com.iemr.common.model.esanjeevani;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import org.springframework.stereotype.Component;
+
+import lombok.Data;
+
+@Data
+public class ESanjeevaniPatientRegistration {
+
+    public String abhaAddress;
+    public String abhaNumber;
+    public int age;
+    public String birthdate;
+    public String displayName;
+    public String firstName;
+    public String middleName;
+    public String lastName;
+    public int genderCode;
+    public String genderDisplay;
+    public boolean isBlock;
+    public String source;
+    
+    public ArrayList<ESanjeevaniPatientAddress> lstPatientAddress;
+    public ArrayList<ESanjeevaniPatientContactDetail> lstPatientContactDetail;
+
+}
diff --git a/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniProviderAuth.java b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniProviderAuth.java
new file mode 100644
index 00000000..6b588daf
--- /dev/null
+++ b/src/main/java/com/iemr/common/model/esanjeevani/ESanjeevaniProviderAuth.java
@@ -0,0 +1,12 @@
+package com.iemr.common.model.esanjeevani;
+
+import lombok.Data;
+
+@Data
+public class ESanjeevaniProviderAuth {
+
+	private String userName;
+	private String password;
+	private String salt;
+	private String source;
+}
diff --git a/src/main/java/com/iemr/common/repo/esanjeevani/ESanjeevaniRepo.java b/src/main/java/com/iemr/common/repo/esanjeevani/ESanjeevaniRepo.java
new file mode 100644
index 00000000..1e9f826e
--- /dev/null
+++ b/src/main/java/com/iemr/common/repo/esanjeevani/ESanjeevaniRepo.java
@@ -0,0 +1,47 @@
+package com.iemr.common.repo.esanjeevani;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+import org.springframework.data.repository.query.Param;
+import org.springframework.data.rest.core.annotation.RestResource;
+import org.springframework.stereotype.Repository;
+
+import com.iemr.common.data.door_to_door_app.V_doortodooruserdetails;
+@Repository
+@RestResource(exported = false)
+public interface ESanjeevaniRepo extends CrudRepository<V_doortodooruserdetails, Integer>{
+	
+	@Query(nativeQuery = true, value = "SELECT BenDetailsId AS benDetailsId, BenAddressId AS benAddressId,  BenContactsId AS benContactsId  FROM db_identity.i_beneficiarymapping WHERE BenRegId = :benRegID")
+	public List<Object[]> getBeneficiaryMappingIds(@Param("benRegID") Long benRegID);
+
+
+	@Query(nativeQuery = true, value = "SELECT FirstName, LastName, MiddleName, Gender, DOB FROM db_identity.i_beneficiarydetails WHERE BeneficiaryDetailsId = :benDetailsId")
+	public List<Object[]> getBeneficiaryDeatils(@Param("benDetailsId") BigInteger benDetailsId);
+	
+	@Query(nativeQuery = true, value = "SELECT PreferredPhoneNum FROM db_identity.i_beneficiarycontacts WHERE BenContactsID = :benContactId")
+	public String getBeneficiaryContactDetails(@Param("benContactId") BigInteger benContactId);
+	
+	@Query(nativeQuery = true, value = "SELECT CurrCountryId, CurrCountry, CurrStateId, CurrState, CurrDistrictId, CurrDistrict, CurrSubDistrictId, CurrSubDistrict, "
+			+ "CurrAddrLine1, CurrPinCode FROM db_identity.i_beneficiaryaddress WHERE BenAddressID = :benAddressId")
+	public List<Object[]> getBeneficiaryAddressDetails(@Param("benAddressId") BigInteger benAddressId);
+	
+	@Query(nativeQuery = true, value = "SELECT HealthID AS healthId, HealthIDNumber AS healthIdNumber FROM db_iemr.m_benhealthidmapping WHERE BeneficiaryRegID = :benRegID")
+	public List<Object[]> getBeneficiaryHealthIdDeatils(@Param("benRegID") Long benRegID);
+	
+	@Query(nativeQuery = true, value = "SELECT GovtStateID FROM db_iemr.m_state WHERE StateID = :stateId ")
+	public Integer getGovStateId(@Param("stateId") Integer stateId);
+	
+	@Query(nativeQuery = true, value = "SELECT GovtDistrictID FROM db_iemr.m_district WHERE DistrictID = :districtId ")
+	public Integer getGovDistrictId(@Param("districtId") Integer districtId);
+	
+	@Query(nativeQuery = true, value = "SELECT GovSubDistrictID FROM db_iemr.m_districtbranchmapping WHERE DistrictBranchID = :subDistrictId ")
+	public Integer getGovSubDistrictId(@Param("subDistrictId") Integer subDistrictId);
+	
+	@Query(nativeQuery = true, value = "SELECT CountryCode FROM db_iemr.m_country WHERE CountryID = :countryID ")
+	public String getGovCountyId(@Param("countryID") Integer countryID);
+}
diff --git a/src/main/java/com/iemr/common/repository/users/UserRoleMappingRepository.java b/src/main/java/com/iemr/common/repository/users/UserRoleMappingRepository.java
index 2c48af0a..7e4f95a1 100644
--- a/src/main/java/com/iemr/common/repository/users/UserRoleMappingRepository.java
+++ b/src/main/java/com/iemr/common/repository/users/UserRoleMappingRepository.java
@@ -38,7 +38,7 @@
 public interface UserRoleMappingRepository extends CrudRepository<UserServiceRoleMapping, Long>
 {
 	@Query("select map.USRMappingID, map.UserID, map.RoleID, map.m_Role, map.providerServiceMapID, "
-			+ "map.agentID, map.inbound, map.outbound, map.agentPassword, map.workingLocationID, map.providerServiceAddressMapping from "
+			+ "map.agentID, map.inbound, map.outbound, map.isSanjeevani, map.agentPassword, map.workingLocationID, map.providerServiceAddressMapping from "
 			+ "UserServiceRoleMapping map left join map.m_ProviderServiceMapping psm left join psm.serviceProvider sp "
 			+ "left join map.m_Role left join map.providerServiceAddressMapping "
 			+ "where map.Deleted = false and UserID = :UserID and sp.statusID in (1,2) "
diff --git a/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniService.java b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniService.java
new file mode 100644
index 00000000..ffdd80fb
--- /dev/null
+++ b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniService.java
@@ -0,0 +1,6 @@
+package com.iemr.common.service.esanjeevani;
+
+public interface ESanjeevaniService {
+
+	public String registerPatient(Long benRegId) throws Exception;
+}
diff --git a/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java
new file mode 100644
index 00000000..62445665
--- /dev/null
+++ b/src/main/java/com/iemr/common/service/esanjeevani/ESanjeevaniServiceImpl.java
@@ -0,0 +1,308 @@
+package com.iemr.common.service.esanjeevani;
+
+import java.math.BigInteger;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+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 org.apache.commons.codec.digest.DigestUtils;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Service;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
+import org.springframework.util.ObjectUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.client.RestTemplate;
+
+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 {
+
+	@Autowired
+	RestTemplate restTemplate;
+	
+	private Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
+	@Autowired
+	ESanjeevaniRepo eSanjeevaniRepo;
+
+	@Value("${eSanjeevani.url}")
+	private String eSanjeevaniUrl;
+
+	@Value("${eSanjeevani.registerPatient}")
+	private String eSanjeevaniRegisterPatient;
+
+	@Value("${eSanjeevani.source}")
+	private String eSanjeevaniSource;
+
+	@Value("${eSanjeevani.salt}")
+	private String eSanjeevaniSalt;
+
+	@Value("${eSanjeevani.userName}")
+	private String eSanjeevaniUserName;
+
+	@Value("${eSanjeevani.password}")
+	private String eSanjeevaniPassword;
+
+	@Value("${eSanjeevani.routeUrl}")
+	private String eSanjeevaniRouteUrl;
+
+	public String getProviderLogin() throws Exception {
+		String token = null;
+
+		try {
+			String encryptedPassword = DigestUtils.sha512Hex(eSanjeevaniPassword).toLowerCase()
+					+ DigestUtils.sha512Hex(eSanjeevaniSalt).toLowerCase();
+			String encryptedPaasword = DigestUtils.sha512Hex(encryptedPassword);
+
+			ESanjeevaniProviderAuth reqObj = new ESanjeevaniProviderAuth();
+			reqObj.setUserName(eSanjeevaniUserName);
+			reqObj.setPassword(eSanjeevaniPassword);
+			reqObj.setSalt(eSanjeevaniSalt);
+			reqObj.setSource(eSanjeevaniSource);
+
+			logger.info("E-Sangeevani auth api reqObj - " + reqObj);
+			String response = restTemplate.postForObject(eSanjeevaniUrl, reqObj, String.class);
+			logger.info("E-Sangeevani auth api response - " + response);
+			if (response != null && !StringUtils.isEmpty(response)) {
+				JSONObject obj = new JSONObject(response);
+				String modelResponse = obj.getString("model");
+				JSONObject tokenResponse = new JSONObject(modelResponse);
+				token = tokenResponse.getString("access_token");
+				if (token != null && !StringUtils.isEmpty(token)) {
+					return token;
+				}
+			}
+		} catch (Exception e) {
+			return ("Error while fetching Authtoken for E-sanjeevani : " + e.getMessage());
+		}
+		return token;
+
+	}
+
+	@Override
+	public String registerPatient(Long benRegId) throws Exception {
+		try {
+			// String accessToken = getProviderLogin();
+			ESanjeevaniPatientRegistration reqObj = new ESanjeevaniPatientRegistration();
+			ArrayList<ESanjeevaniPatientAddress> addressObj = new ArrayList<>();
+			ArrayList<ESanjeevaniPatientContactDetail> contactObj = new ArrayList<>();
+
+			try {
+				List<Object[]> benMappingResponse = eSanjeevaniRepo.getBeneficiaryMappingIds(benRegId);
+				logger.info("Beneficiary mapping details - " + benMappingResponse);
+				List<Object[]> benAbhaDetailsResponse = eSanjeevaniRepo.getBeneficiaryHealthIdDeatils(benRegId);
+				logger.info("Beneficiary HealthId details - " + benAbhaDetailsResponse);
+				
+				if (!benAbhaDetailsResponse.isEmpty()) {
+					Object[] benAbhaDetails = benAbhaDetailsResponse.get(0);
+					reqObj.setAbhaAddress(benAbhaDetails[0].toString());
+					reqObj.setAbhaNumber(benAbhaDetails[1].toString());
+				}
+				if (!benMappingResponse.isEmpty()) {
+					Object[] benMappingIds = benMappingResponse.get(0);
+
+					BigInteger benDetailsId = (BigInteger) benMappingIds[0];
+					BigInteger benAddressId = (BigInteger) benMappingIds[1];
+					BigInteger benContactsId = (BigInteger) benMappingIds[2];
+
+					setBeneficiaryDetails(benDetailsId, reqObj);
+					setBeneficiaryAddressDetails(benAddressId, addressObj);
+					setBeneficiaryContactDetails(benContactsId, contactObj);
+					
+					if (!ObjectUtils.isEmpty(addressObj))
+						reqObj.setLstPatientAddress(addressObj);
+					if (!ObjectUtils.isEmpty(contactObj))
+						reqObj.setLstPatientContactDetail(contactObj);
+
+				} else {
+					return("No beneficiary Details found for benRegId : " + benRegId);
+				}
+			} catch (Exception e) {
+				return ("Issue while fetching mapping details : " + e.getMessage());
+			}
+
+			String accessToken = getProviderLogin();
+			if (accessToken != null && !StringUtils.isEmpty(accessToken)) {
+				MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
+				String registryReqObj = new Gson().toJson(reqObj);
+//				JSONObject registryReqObj = new JSONObject(reqObj);
+				headers.add("Authorization", "Bearer " + accessToken );
+				headers.add("Content-Type", "application/json");
+				HttpEntity<Object> requestOBJ = new HttpEntity<Object>(registryReqObj, headers);
+				logger.info("E-Sangeevani patient registery api request - " + requestOBJ);
+				ResponseEntity<String> response = restTemplate.exchange(eSanjeevaniRegisterPatient, HttpMethod.POST,
+						requestOBJ, String.class);
+				logger.info("E-Sangeevani patient registery api response - " + response);
+				if (response != null && response.getBody() != null) {
+					String res = response.getBody();
+					JSONObject obj = new JSONObject(res);
+					logger.info("E-Sangeevani patient  api response object - " + response);
+					if (obj.getBoolean("success")) {
+						if(obj.get("message") != null && ((String) obj.get("message")).equalsIgnoreCase("success") )
+						return eSanjeevaniRouteUrl;
+						else {
+							return ("Unable to register patient in e-sanjeevani " + obj.get("message"));
+						}
+					} else {
+						return ("Unable to register patient for routing to E-Sanjeevani due to : "
+								+ response.getBody());
+					}
+				}
+			} else {
+				return ("Empty response from E-sanjeevani Authorization API");
+			}
+		} catch (Exception e) {
+			throw new Exception("Error while E-Sanjeevani registering patient : " + e.getMessage());
+		}
+		return null;
+
+	}
+
+	private int calculateAge(String dob) {
+
+		LocalDate currentDate = LocalDate.now();
+		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+		LocalDate date = LocalDate.parse(dob, formatter);
+		Period period = Period.between(date, currentDate);
+		return period.getYears();
+
+	}
+
+	private void setBeneficiaryDetails(BigInteger benDetailsId, ESanjeevaniPatientRegistration reqObj) {
+		List<Object[]> beneficaryDetails = eSanjeevaniRepo.getBeneficiaryDeatils(benDetailsId);
+		if (beneficaryDetails != null) {
+			Object[] beneficaryObj = beneficaryDetails.get(0);
+			logger.info("Beneficiary details - " + beneficaryObj.toString());
+			// JSONObject beneficaryObj = new JSONObject(beneficaryDetails);
+			if (beneficaryObj[0] != null)
+			reqObj.setFirstName(beneficaryObj[0].toString());
+			if (beneficaryObj[1] != null)
+				reqObj.setLastName(beneficaryObj[1].toString());
+			if (beneficaryObj[2] != null)
+				reqObj.setMiddleName(beneficaryObj[2].toString());
+			if (beneficaryObj[3] != null) {
+				reqObj.setGenderDisplay(beneficaryObj[3].toString());
+				if (beneficaryObj[3].toString().equalsIgnoreCase("male"))
+					reqObj.setGenderCode(1);
+				else if (beneficaryObj[3].toString().equalsIgnoreCase("female"))
+					reqObj.setGenderCode(2);
+				else
+					reqObj.setGenderCode(3);
+			}
+			if (beneficaryObj[4] != null) {
+				String s = beneficaryObj[4].toString();
+				String dob = s.split(" ")[0];
+				reqObj.setAge(calculateAge(dob));
+				reqObj.setBirthdate(dob);
+			}
+			reqObj.setBlock(false);
+			reqObj.setSource(eSanjeevaniSource);
+		}
+
+	}
+
+	private void setBeneficiaryAddressDetails(BigInteger benAddressId,
+			ArrayList<ESanjeevaniPatientAddress> addressObjList) {
+		ESanjeevaniPatientAddress addressObj = new ESanjeevaniPatientAddress();
+		if (benAddressId != null) {
+			List<Object[]> beneficiaryAddDetails = eSanjeevaniRepo.getBeneficiaryAddressDetails(benAddressId);
+			if (null != beneficiaryAddDetails) {
+				Integer countryId = 0;
+				Integer stateId = 0;
+				Integer districtId = 0;
+				Integer blockId = 0;
+				Object[] addressDetails = beneficiaryAddDetails.get(0);
+				logger.info("address details fetch for beneficiary - " + addressDetails);
+//				JSONObject addressDetails = new JSONObject(beneficiaryAddDetails);
+				if (addressDetails[0] != null)
+					countryId = (int) addressDetails[0];
+				else 
+					countryId = 91;
+				if (addressDetails[1] != null)
+					addressObj.setCountryDisplay(addressDetails[1].toString());
+				else 
+					addressObj.setCountryDisplay("India");
+				if (addressDetails[2] != null)
+					stateId = (int) addressDetails[2];
+				if (addressDetails[3] != null)
+					addressObj.setStateDisplay(addressDetails[3].toString());
+				if (addressDetails[4] != null)
+					districtId = (int) addressDetails[4];
+				if (addressDetails[5] != null)
+					addressObj.setDistrictDisplay(addressDetails[5].toString());
+				if (addressDetails[6] != null)
+					blockId = (int) addressDetails[6];
+				if (addressDetails[7] != null)
+					addressObj.setBlockDisplay(addressDetails[7].toString());
+				if (addressDetails[8] != null)
+					addressObj.setAddressLine1(addressDetails[8].toString());
+				if (addressDetails[9] != null)
+					addressObj.setPostalCode(addressDetails[9].toString());
+				addressObj.setAddressType("Physical");
+				addressObj.setPostalCode("123456");
+				addressObj.setCityCode(233);
+				addressObj.setCityDisplay("kareemnagar");
+
+				String govCountryCode = eSanjeevaniRepo.getGovCountyId(countryId);
+				Integer govtStateCode = eSanjeevaniRepo.getGovStateId(stateId);
+				Integer govtDistrictCode = eSanjeevaniRepo.getGovDistrictId(districtId);
+				Integer govBlockCode = eSanjeevaniRepo.getGovSubDistrictId(blockId);
+
+				if (null != govCountryCode)
+					addressObj.setCountryCode(govCountryCode);
+				if (null != govtStateCode)
+					addressObj.setStateCode(govtStateCode);
+				if (null != govtDistrictCode)
+					addressObj.setDistrictCode(govtDistrictCode);
+				if (null != govBlockCode)
+					addressObj.setBlockCode(govBlockCode);
+
+				addressObjList.add(addressObj);
+			}
+		}
+	}
+
+	private void setBeneficiaryContactDetails(BigInteger benContactId,
+			ArrayList<ESanjeevaniPatientContactDetail> contactObjList) {
+		ESanjeevaniPatientContactDetail contactObj = new ESanjeevaniPatientContactDetail();
+		if (benContactId != null) {
+			String beneficiaryContactDetails = eSanjeevaniRepo.getBeneficiaryContactDetails(benContactId);
+			logger.info("contact details fetch for beneficiary - " + beneficiaryContactDetails);
+			if (null != beneficiaryContactDetails) {
+//				JSONObject contactDetails = new JSONObject(beneficiaryContactDetails);
+//				Object[] contactDetails = beneficiaryContactDetails.get(0);
+				contactObj.setContactPointStatus(true);
+				contactObj.setContactPointType("phone");
+				contactObj.setContactPointValue(beneficiaryContactDetails);
+
+				contactObjList.add(contactObj);
+			}
+		}
+
+	}
+
+}
diff --git a/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java b/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java
index fe20da49..d54d1d90 100644
--- a/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java
+++ b/src/main/java/com/iemr/common/service/users/IEMRAdminUserServiceImpl.java
@@ -470,8 +470,8 @@ public void updateCTIPasswordForUser(Long userID, String password) {
 								.initializeUserRoleMappingObjs((Long) object[0], (Long) object[1], (Integer) object[2],
 										(Role) object[3], (Integer) object[4],
 										getUserProviderServiceRoleMapping((Integer) object[4]), (String) object[5],
-										(Boolean) object[6], (Boolean) object[7], (String) object[8],
-										(Integer) object[9], (ProviderServiceAddressMapping) object[10]);
+										(Boolean) object[6], (Boolean) object[7], (Boolean) object[8], (String) object[9],
+										(Integer) object[10], (ProviderServiceAddressMapping) object[11]);
 						userRoles.add(userServiceRoleMapping);
 					}
 				}
@@ -667,8 +667,8 @@ private List<UserServiceRoleMapping> getUserServiceRoleMapping(Long userID) thro
 				UserServiceRoleMapping userServiceRoleMapping = UserServiceRoleMapping.initializeUserRoleMappingObjs(
 						(Long) object[0], (Long) object[1], (Integer) object[2], (Role) object[3], (Integer) object[4],
 						getUserProviderServiceRoleMapping((Integer) object[4]), (String) object[5], (Boolean) object[6],
-						(Boolean) object[7], (String) object[8], (Integer) object[9],
-						(ProviderServiceAddressMapping) object[10]);
+						(Boolean) object[7], (Boolean) object[8], (String) object[9], (Integer) object[10], 
+						(ProviderServiceAddressMapping) object[11]);
 				List<ServiceRoleScreenMapping> serviceRoleScreenMappings = getActiveScreenMappings(
 						userServiceRoleMapping.getProviderServiceMapID(), userServiceRoleMapping.getRoleID());
 				userServiceRoleMapping.getM_Role().setServiceRoleScreenMappings(serviceRoleScreenMappings);
