Skip to content

Commit f487978

Browse files
vishwab15Amoghvanitha1822sac2kadamSauravBizbRolly
authored
Move code to 3.6.1 to 3.8.0 (#372)
* fix: cors spell fixes and import of packages updates * fix: deployment issue fix * feat: amm-1959 dhis token for cho report re-direction * fix: beneficiary history on revisit (#320) * fix: call type mapper (#322) * Elasticsearch implementation for Beneficiary Search (#324) * fix: implement functionality to search beneficiaries with Elasticsearch * fix: remove unwanted import * fix: update pom.xml * fix: change the response code * variable added * Elastic Search Implementation for Advanced Search (#327) * fix: cherry-pick commits for advanced search * fix: cherry-pick commit for token issue - mobile application * fix: add the missing properties * fix: add function to retrieve userid * fix: move the fetch Userid to jwtUtil * fix:signature check for mmu * fix: retrive any user without deleted * fix: update KM filepath * FLW-713 Remove All File Upload Options (#350) * FLW-713 Remove All File Upload Options * Fix UserServiceRoleRepo dependency issue and codeRabit comment * fixed coderabit comment * fix userMappingId issue * Add SMS functionality in release-3.6.1 (#358) * Enable SMS Functionality in MMU App to Send Prescriptions (#325) * fix: sms template save and map mmu (#306) * Vb/sms (#307) * fix: sms template save and map mmu * fix: enable mms for mmu prescription * Enable SMS Functionality in MMU App to Send Prescriptions (#325) * fix: sms template save and map mmu (#306) * Vb/sms (#307) * fix: sms template save and map mmu * fix: enable mms for mmu prescription --------- Co-authored-by: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com> --------- Co-authored-by: 5Amogh <amoghavarsh@navadhiti.com> Co-authored-by: Vanitha S <116701245+vanitha1822@users.noreply.github.com> Co-authored-by: Sachin Kadam <152252767+sac2kadam@users.noreply.github.com> Co-authored-by: vanitha1822 <vanitha@navadhiti.com> Co-authored-by: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com>
1 parent 44b8e84 commit f487978

47 files changed

Lines changed: 1652 additions & 294 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.compile.nullAnalysis.mode": "automatic"
3+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.iemr.common-API</groupId>
88
<artifactId>common-api</artifactId>
9-
<version>3.6.0</version>
9+
<version>3.6.1</version>
1010
<packaging>war</packaging>
1111

1212
<name>Common-API</name>

src/main/environment/common_ci.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ km-base-path=@env.KM_API_BASE_PATH@
1919
km-root-path=/okm:personal/users/
2020
km-guest-user=@env.KM_GUEST_USER@
2121
km-guest-password=@env.KM_GUEST_PASSWORD@
22+
tempFilePath=@env.TEMP_FILE_PATH@
2223

2324
# CTI Config
2425
cti-server-ip=@env.CTI_SERVER_IP@

src/main/environment/common_docker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ everwellRegisterBenficiary = ${COMMON_API_BASE_URL}/beneficiary/create
126126
## LungAssessment credentials
127127
lungAssessmentEmail = ${SWAASA_EMAIL}
128128
lungAssessmentPassword =${SWAASA_PASSWORD}
129-
129+
tempFilePath=${TEMP_FILE_PATH}
130130

131131
## SWASSA APIs
132132
lungAssessmentAdminLogin = ${SWAASA_BASE_URL}/api/adminLogin

src/main/environment/common_example.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ km-root-path=/okm:personal/users/
2525
km-guest-user=guest
2626
km-guest-password=guest
2727

28+
tempFilePath=/opt/openkm
29+
2830
# CTI Config
2931
cti-server-ip=10.208.122.99
3032
cti-logger_base_url=http://10.208.122.99/logger

src/main/java/com/iemr/common/config/CorsConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@Configuration
1010
public class CorsConfig implements WebMvcConfigurer {
1111

12-
@Value("${cors.allowed-origin}")
12+
@Value("${cors.allowed-origins}")
1313
private String allowedOrigins;
1414
@Override
1515
public void addCorsMappings(CorsRegistry registry) {

src/main/java/com/iemr/common/controller/beneficiary/BeneficiaryRegistrationController.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.slf4j.LoggerFactory;
3737
import org.springframework.beans.factory.annotation.Autowired;
3838
import org.springframework.web.bind.annotation.RequestBody;
39+
import org.springframework.web.bind.annotation.RequestHeader;
3940
import org.springframework.web.bind.annotation.RequestMapping;
4041
import org.springframework.web.bind.annotation.RequestMethod;
4142
import org.springframework.web.bind.annotation.RestController;
@@ -70,6 +71,8 @@
7071
import com.iemr.common.service.userbeneficiarydata.MaritalStatusService;
7172
import com.iemr.common.service.userbeneficiarydata.StatusService;
7273
import com.iemr.common.service.userbeneficiarydata.TitleService;
74+
import com.iemr.common.utils.CookieUtil;
75+
import com.iemr.common.utils.JwtUtil;
7376
import com.iemr.common.utils.mapper.InputMapper;
7477
import com.iemr.common.utils.mapper.OutputMapper;
7578
import com.iemr.common.utils.response.OutputResponse;
@@ -103,6 +106,8 @@ public class BeneficiaryRegistrationController {
103106
private BeneficiaryOccupationService beneficiaryOccupationService;
104107
private GovtIdentityTypeService govtIdentityTypeService;
105108

109+
@Autowired
110+
private JwtUtil jwtUtil;
106111

107112
@Autowired
108113
public void setBenRelationshipTypeService(BenRelationshipTypeService benRelationshipTypeService) {
@@ -342,6 +347,54 @@ public String searchUserByPhone(
342347
return response.toString();
343348
}
344349

350+
@Operation(summary = "Provide the list of beneficiaries using Elasticsearch")
351+
@RequestMapping(value = "/searchUser", method = RequestMethod.POST, headers = "Authorization")
352+
public String searchUser(@RequestBody String request, HttpServletRequest httpRequest) {
353+
OutputResponse response = new OutputResponse();
354+
try {
355+
logger.info("Universal search request received");
356+
357+
JsonParser parser = new JsonParser();
358+
JsonObject requestObj = parser.parse(request).getAsJsonObject();
359+
360+
String searchQuery = null;
361+
if (requestObj.has("search") && !requestObj.get("search").isJsonNull()) {
362+
searchQuery = requestObj.get("search").getAsString();
363+
}
364+
365+
if (searchQuery == null || searchQuery.trim().isEmpty()) {
366+
response.setError(400, "Search query is required");
367+
return response.toString();
368+
}
369+
370+
String auth = httpRequest.getHeader("Authorization");
371+
372+
Integer userID = jwtUtil.getUserIdFromRequest(httpRequest);
373+
374+
logger.info("ES search for userId: {}", userID);
375+
376+
Boolean is1097 = false;
377+
if (requestObj.has("is1097") && !requestObj.get("is1097").isJsonNull()) {
378+
is1097 = requestObj.get("is1097").getAsBoolean();
379+
}
380+
381+
logger.info("Searching with query: {}, userId: {}, is1097: {}", searchQuery, userID, is1097);
382+
String result = iemrSearchUserService.searchUser(searchQuery, userID, auth, is1097);
383+
384+
if (result == null || result.trim().isEmpty()) {
385+
response.setError(200, "No beneficiaries found");
386+
return response.toString();
387+
}
388+
389+
return result;
390+
391+
} catch (Exception e) {
392+
logger.error("Error in universal search: {}", e.getMessage(), e);
393+
response.setError(400, "Error searching beneficiaries: " + e.getMessage());
394+
return response.toString();
395+
}
396+
}
397+
345398
@Operation(summary = "Provide the list of beneficiaries based on search criteria")
346399
@RequestMapping(value = "/searchBeneficiary", method = RequestMethod.POST, headers = "Authorization")
347400
public String searchBeneficiary(
@@ -364,6 +417,41 @@ public String searchBeneficiary(
364417
return output.toString();
365418
}
366419

420+
/**
421+
* Elasticsearch-based advanced search endpoint
422+
*/
423+
@Operation(summary = "Advanced search beneficiaries using Elasticsearch")
424+
@RequestMapping(value = "/searchBeneficiaryES", method = RequestMethod.POST, headers = "Authorization")
425+
public String searchBeneficiaryES(
426+
@RequestBody BeneficiaryModel request,
427+
HttpServletRequest httpRequest) {
428+
429+
logger.info("searchBeneficiaryES request: {}", request);
430+
OutputResponse output = new OutputResponse();
431+
432+
try {
433+
434+
String auth = httpRequest.getHeader("Authorization");
435+
436+
Integer userID = jwtUtil.getUserIdFromRequest(httpRequest);
437+
438+
logger.info("ES Advanced search for userId: {}", userID);
439+
440+
String result = iemrSearchUserService.findBeneficiaryES(request, userID, auth);
441+
442+
return result;
443+
444+
} catch (NumberFormatException ne) {
445+
logger.error("searchBeneficiaryES failed with number format error: {}", ne.getMessage(), ne);
446+
output.setError(400, "Invalid number format in search criteria");
447+
return output.toString();
448+
} catch (Exception e) {
449+
logger.error("searchBeneficiaryES failed with error: {}", e.getMessage(), e);
450+
output.setError(500, "Error searching beneficiaries: " + e.getMessage());
451+
return output.toString();
452+
}
453+
}
454+
367455
@Operation(summary = "Provide all common data list needed for beneficiary registration")
368456
@RequestMapping(value = "/getRegistrationData", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
369457
public String getRegistrationData() {

src/main/java/com/iemr/common/controller/dynamicForm/DynamicFormController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public ResponseEntity<ApiResponse<?>> deleteField(@PathVariable Long fieldId) {
8484
}
8585

8686
@GetMapping(value = "form/{formId}/fields")
87-
public ResponseEntity<ApiResponse<?>> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang) {
87+
public ResponseEntity<ApiResponse<?>> getStructuredForm(@PathVariable String formId, @RequestParam(name = "lang", defaultValue = "en") String lang,@RequestHeader(value = "jwttoken") String token) {
8888
try {
89-
Object result = formMasterService.getStructuredFormByFormId(formId,lang);
89+
Object result = formMasterService.getStructuredFormByFormId(formId,lang,token);
9090
return ResponseEntity.status(HttpStatus.OK)
9191
.body(ApiResponse.success("Form structure fetched successfully", HttpStatus.OK.value(), result));
9292
} catch (Exception e) {

src/main/java/com/iemr/common/controller/platform_feedback/PlatformFeedbackController.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
* You should have received a copy of the GNU General Public License
2020
* along with this program. If not, see https://www.gnu.org/licenses/.
2121
*/
22-
package com.iemr.common.controller;
22+
package com.iemr.common.controller.platform_feedback;
2323

24-
import com.iemr.common.dto.*;
25-
import com.iemr.common.service.PlatformFeedbackService;
24+
import com.iemr.common.dto.platform_feedback.CategoryResponse;
25+
import com.iemr.common.dto.platform_feedback.FeedbackRequest;
26+
import com.iemr.common.dto.platform_feedback.FeedbackResponse;
27+
import com.iemr.common.service.platform_feedback.PlatformFeedbackService;
2628
import io.swagger.v3.oas.annotations.Operation;
2729
import io.swagger.v3.oas.annotations.tags.Tag;
2830
import io.swagger.v3.oas.annotations.Parameter;

src/main/java/com/iemr/common/controller/users/IEMRAdminController.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ private void createUserMapping(User mUser, JSONObject resMap, JSONObject service
392392
resMap.put("agentPassword", mUser.getAgentPassword());
393393
resMap.put("m_UserLangMappings", new JSONArray(mUser.getM_UserLangMappings().toString()));
394394
resMap.put("designationID", mUser.getDesignationID());
395+
resMap.put("dhistoken",mUser.getDhistoken());
395396
if (mUser.getDesignation() != null) {
396397
resMap.put("designation", new JSONObject(mUser.getDesignation().toString()));
397398
}
@@ -1223,7 +1224,25 @@ public ResponseEntity<?> getUserDetails(@PathVariable("userName") String userNam
12231224
return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND);
12241225
}
12251226
User user = users.get(0);
1226-
return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()), HttpStatus.OK);
1227+
return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()),
1228+
HttpStatus.OK);
1229+
} catch (Exception e) {
1230+
return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR);
1231+
}
1232+
1233+
}
1234+
1235+
@Operation(summary = "Get UserId based on userName")
1236+
@GetMapping(value = "/checkUserName/{userName}", produces = MediaType.APPLICATION_JSON, headers = "Authorization")
1237+
public ResponseEntity<?> checkUserDetails(@PathVariable("userName") String userName) {
1238+
try {
1239+
List<User> users = iemrAdminUserServiceImpl.findUserIdByUserName(userName);
1240+
if (users.isEmpty()) {
1241+
return new ResponseEntity<>(Map.of("error", "UserName Not Found"), HttpStatus.NOT_FOUND);
1242+
}
1243+
User user = users.get(0);
1244+
return new ResponseEntity<>(Map.of("userName", user.getUserName(), "userId", user.getUserID()),
1245+
HttpStatus.OK);
12271246
} catch (Exception e) {
12281247
return new ResponseEntity<>(Map.of("error", "Internal server error"), HttpStatus.INTERNAL_SERVER_ERROR);
12291248
}

0 commit comments

Comments
 (0)