Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public interface ESanjeevaniRepo extends CrudRepository<V_doortodooruserdetails,
@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 GovSubDistrictID,GovVillageID,VillageName FROM db_iemr.m_districtbranchmapping WHERE DistrictBranchID = :subDistrictId ")
public List<Object[]> 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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
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.time.LocalDate;
Expand Down Expand Up @@ -80,13 +83,11 @@ public String getProviderLogin() throws Exception {
String token = null;

try {
String encryptedPassword = DigestUtils.sha512Hex(eSanjeevaniPassword).toLowerCase()
+ DigestUtils.sha512Hex(eSanjeevaniSalt).toLowerCase();
String encryptedPaasword = DigestUtils.sha512Hex(encryptedPassword);

String encryptedPaasword = encryptSHA512(encryptSHA512(eSanjeevaniPassword)+encryptSHA512(eSanjeevaniSalt));

ESanjeevaniProviderAuth reqObj = new ESanjeevaniProviderAuth();
reqObj.setUserName(eSanjeevaniUserName);
reqObj.setPassword(eSanjeevaniPassword);
reqObj.setPassword(encryptedPaasword);
reqObj.setSalt(eSanjeevaniSalt);
reqObj.setSource(eSanjeevaniSource);

Expand All @@ -110,6 +111,25 @@ public String getProviderLogin() throws Exception {
return token;

}
private String encryptSHA512(String string) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-512");
byte[] hashbytes = digest.digest(string.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : hashbytes) {
String hex = Integer.toHexString(0xff & b);
if(hex.length()==1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}catch (Exception e) {
return null;
}

}


@Override
public String registerPatient(Long benRegId) throws Exception {
Expand Down Expand Up @@ -153,6 +173,7 @@ public String registerPatient(Long benRegId) throws Exception {
}

String accessToken = getProviderLogin();
logger.info("getProviderLogin response - " + accessToken);
if (accessToken != null && !StringUtils.isEmpty(accessToken)) {
MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
String registryReqObj = new Gson().toJson(reqObj);
Expand Down Expand Up @@ -275,16 +296,21 @@ private void setBeneficiaryAddressDetails(BigInteger benAddressId,
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);

List<Object[]> govBlockCodeObj = eSanjeevaniRepo.getGovSubDistrictId(blockId);

Object[] objects = govBlockCodeObj.get(0);
Integer govBlockCode = (Integer)objects[0];
Integer govVillageID = (Integer)objects[1];
String govVillageName = objects[2].toString();

if (govVillageID != null)
addressObj.setCityCode(govVillageID);
if (govVillageName != null)
addressObj.setCityDisplay(govVillageName);
if (null != govCountryCode)
addressObj.setCountryCode(govCountryCode);
if (null != govtStateCode)
Expand All @@ -309,7 +335,6 @@ private void setBeneficiaryContactDetails(BigInteger benContactId,
contactObj.setContactPointStatus(true);
contactObj.setContactPointType("phone");
contactObj.setContactPointValue(beneficiaryContactDetails);

contactObjList.add(contactObj);
}
}
Expand Down