Skip to content

Commit

Permalink
Merge pull request #83 from bshivani7/develop
Browse files Browse the repository at this point in the history
1097 sms template
  • Loading branch information
devikasuresh20 authored Jan 30, 2024
2 parents 9c6bfb9 + 4c777fb commit 8f970f1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/main/java/com/iemr/common/service/sms/SMSServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f970f1

Please sign in to comment.