Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on asha update profile and get profile , lmp date #10

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<org.mapstruct.version>1.2.0.Final</org.mapstruct.version>
<org.projectlombok.version>1.16.18</org.projectlombok.version>
<environment>${ENV_VAR}</environment>
<environment>local</environment>
<target-properties>target/classes/application.properties</target-properties>
<source-properties>src/main/environment/common_${environment}.properties</source-properties>
<maven.test.skip>true</maven.test.skip>
Expand Down
27 changes: 18 additions & 9 deletions src/main/environment/common_local.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ fhir-url=<Enter your socket address here>/fhirapi-v1.0
tm-url=<Enter your socket address here>/tmapi-v1.0
##--------------------------------------------## Primary db-------------------------------------------------------------------

spring.datasource.url=<Enter AMRIT DB_IEMR URL here>
spring.datasource.username=<Enter your AMRIT DB_IEMR username>
spring.datasource.password=<Enter your AMRIT DB_IEMR password>
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
server.port=8082

spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr
spring.datasource.username=root
spring.datasource.password=YesBank@123#
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
Comment on lines +10 to +13
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security: Database credentials should not be hardcoded.

Database credentials should be externalized and not committed to version control.

Use environment variables or a secure configuration management system instead of hardcoding credentials.


##--------------------------------------------## Secondary db-------------------------------------------------------------------

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.Driver
secondary.datasource.url=jdbc:mysql://localhost:3306/db_identity
secondary.datasource.username=root
secondary.datasource.password=YesBank@123#
secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

springdoc.api-docs.enabled=true
springdoc.swagger-ui.enabled=true
springdoc.swagger-ui.enabled=true

spring.session.store-type=redis
spring.redis.host=localhost
spring.redis.password=123456
spring.redis.port=6379
Comment on lines +25 to +28
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Security: Redis configuration needs improvement.

The Redis password is weak and the configuration lacks SSL settings.

  1. Use a stronger password for Redis
  2. Consider enabling SSL for Redis connections
  3. Consider restricting Redis access to specific IP ranges

jakarta.persistence.schema-generation.database.action=create
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Warning: Schema generation action set to 'create'.

Setting jakarta.persistence.schema-generation.database.action=create will drop and recreate tables on startup, which is dangerous for production.

Change this to none or validate for production environments.

spring.jpa.defer-datasource-initialization=true
88 changes: 88 additions & 0 deletions src/main/java/com/iemr/flw/controller/AshaProfileController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.iemr.flw.controller;

import com.iemr.flw.domain.iemr.AshaWorker;
import com.iemr.flw.domain.iemr.M_User;
import com.iemr.flw.dto.iemr.UserServiceRoleDTO;
import com.iemr.flw.repo.iemr.UserServiceRoleRepo;
import com.iemr.flw.service.AshaProfileService;
import com.iemr.flw.service.EmployeeMasterInter;
import com.iemr.flw.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping(value = "/asha", headers = "Authorization", produces = "application/json")
public class AshaProfileController {
private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName());
@Autowired
AshaProfileService ashaProfileService;
private Map<String,Object> response = new HashMap<>();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix critical issues in error handling and response management.

Several critical issues need to be addressed:

  1. Shared mutable state with response map
  2. Incorrect error handling
  3. Debug logging using System.out.println
-    private Map<String,Object> response = new HashMap<>();
+    private static final Logger logger = LoggerFactory.getLogger(AshaProfileController.class);

     @RequestMapping(value = "editProfile", method = { RequestMethod.POST })
     public ResponseEntity<Map<String,Object>> editEmployee(@RequestBody AshaWorker editEmployee) {
+        Map<String,Object> response = new HashMap<>();
         try {
-            System.out.println(editEmployee.toString());
+            logger.debug("Editing employee profile: {}", editEmployee);
             AshaWorker editdata1 = ashaProfileService.saveEditData(editEmployee);
             response.put("data", editdata1);
             response.put("statusCode", 200);
             response.put("status", "Success");
             response.put("errorMessage", "Success");
+            return ResponseEntity.ok().body(response);
         } catch (Exception e) {
             logger.error("Unexpected error:", e);
-            ResponseEntity.status(500).body(e.getMessage());
+            response.put("statusCode", 500);
+            response.put("status", "Error");
+            response.put("errorMessage", e.getMessage());
+            return ResponseEntity.status(500).body(response);
         }
-        return ResponseEntity.ok().body(response);
     }

Also applies to: 39-56


@Autowired
private EmployeeMasterInter employeeMasterInter;
@CrossOrigin()
@Operation(summary = "Edit Asha Profile")


@RequestMapping(value = "editProfile", method = { RequestMethod.POST }, produces = {
"application/json" },consumes = "application/json" )
public ResponseEntity<Map<String,Object>> editEmployee(@RequestBody AshaWorker editEmployee) {

try {
System.out.println(editEmployee.toString());


AshaWorker ashaWorker = ashaProfileService.saveEditData(editEmployee);
response.put("data",ashaWorker);
response.put("statusCode",200);
response.put("status","Success");
response.put("errorMessage","Success");




} catch (Exception e) {
logger.error("Unexpected error:", e);
ResponseEntity.status(500).body(e.getMessage());

}

return ResponseEntity.ok().body(response);

}
@Operation(summary = "Profile Detail")
@RequestMapping(value = "getProfile",method = RequestMethod.GET ,headers = "Authorization" )
public ResponseEntity<Map<String,Object>> getProfile(@RequestParam ("employeeId")Integer employeeId){
try {
AshaWorker ashaWorker = ashaProfileService.getProfileData(employeeId);
if(ashaWorker!=null){
response.put("data",ashaWorker);
response.put("statusCode",200);
response.put("status","Success");
response.put("errorMessage","Success");
}else {
response.put("data",ashaWorker);
response.put("statusCode",200);
response.put("status","Success");
response.put("errorMessage","Asha profile not found");
}

}catch (Exception e) {
logger.error("Unexpected error:", e);
ResponseEntity.status(500).body(e.getMessage());

}

return ResponseEntity.ok().body(response);


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.iemr.flw.controller;

import com.iemr.flw.domain.iemr.OtpBeneficiary;
import com.iemr.flw.dto.iemr.OTPRequestParsor;
import com.iemr.flw.dto.iemr.OtpRequestDTO;
import com.iemr.flw.mapper.InputMapper;
import com.iemr.flw.service.OTPHandler;
import com.iemr.flw.utils.response.OutputResponse;
import io.lettuce.core.dynamic.annotation.Param;
import io.swagger.v3.oas.annotations.Operation;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.core.MediaType;

@RestController
@RequestMapping("/beneficiary")
public class BeneficiaryOTPGatewayController {
final Logger logger = LoggerFactory.getLogger(this.getClass().getName());

@Autowired
private OTPHandler otpHandler;

@Operation(summary = "Send OTP")
@RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
public String sendOTP(@RequestParam String phoneNumber) {
OutputResponse response = new OutputResponse();

try {

String success = otpHandler.sendOTP(phoneNumber);

if (success.contains("success"))
response.setResponse(success);
else
response.setError(5000, "failure");

} catch (Exception e) {
logger.error("error in sending OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}
Comment on lines +28 to +46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add input validation for phone number.

The phone number parameter should be validated before processing to ensure it meets the required format and length.

 @RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
 public String sendOTP(@RequestParam String phoneNumber) {
     OutputResponse response = new OutputResponse();
 
     try {
+        if (phoneNumber == null || !phoneNumber.matches("^\\d{10}$")) {
+            response.setError(4000, "Invalid phone number format");
+            return response.toString();
+        }
 
         String success = otpHandler.sendOTP(phoneNumber);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
public String sendOTP(@RequestParam String phoneNumber) {
OutputResponse response = new OutputResponse();
try {
String success = otpHandler.sendOTP(phoneNumber);
if (success.contains("success"))
response.setResponse(success);
else
response.setError(5000, "failure");
} catch (Exception e) {
logger.error("error in sending OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}
@RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String sendOTP(@RequestParam String phoneNumber) {
OutputResponse response = new OutputResponse();
try {
if (phoneNumber == null || !phoneNumber.matches("^\\d{10}$")) {
response.setError(4000, "Invalid phone number format");
return response.toString();
}
String success = otpHandler.sendOTP(phoneNumber);
if (success.contains("success"))
response.setResponse(success);
else
response.setError(5000, "failure");
} catch (Exception e) {
logger.error("error in sending OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}


@CrossOrigin()
@Operation(summary = "Validate OTP")
@RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
public String validateOTP(@RequestBody OtpRequestDTO requestOBJ) {

OutputResponse response = new OutputResponse();

try {
// OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class);

JSONObject responseOBJ = otpHandler.validateOTP(requestOBJ);
if (responseOBJ != null)
response.setResponse(responseOBJ.toString());
else
response.setError(5000, "failure");

} catch (Exception e) {
logger.error("error in validating OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}
Comment on lines +48 to +69
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Enhance error handling for OTP validation.

The error handling should be more specific and provide better error messages.

 @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
 public String validateOTP(@RequestBody OtpRequestDTO requestOBJ) {
     OutputResponse response = new OutputResponse();
 
     try {
+        if (requestOBJ == null) {
+            response.setError(4000, "Invalid request: Request body is missing");
+            return response.toString();
+        }
 
         JSONObject responseOBJ = otpHandler.validateOTP(requestOBJ);
         if (responseOBJ != null)
             response.setResponse(responseOBJ.toString());
         else
-            response.setError(5000, "failure");
+            response.setError(5000, "OTP validation failed");
 
     } catch (Exception e) {
         logger.error("error in validating OTP : " + e);
-        response.setError(5000, "error : " + e);
+        response.setError(5000, "Error during OTP validation: " + e.getMessage());
     }
     return response.toString();
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@CrossOrigin()
@Operation(summary = "Validate OTP")
@RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
public String validateOTP(@RequestBody OtpRequestDTO requestOBJ) {
OutputResponse response = new OutputResponse();
try {
// OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class);
JSONObject responseOBJ = otpHandler.validateOTP(requestOBJ);
if (responseOBJ != null)
response.setResponse(responseOBJ.toString());
else
response.setError(5000, "failure");
} catch (Exception e) {
logger.error("error in validating OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}
@CrossOrigin()
@Operation(summary = "Validate OTP")
@RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON, headers = "Authorization")
public String validateOTP(@RequestBody OtpRequestDTO requestOBJ) {
OutputResponse response = new OutputResponse();
try {
if (requestOBJ == null) {
response.setError(4000, "Invalid request: Request body is missing");
return response.toString();
}
JSONObject responseOBJ = otpHandler.validateOTP(requestOBJ);
if (responseOBJ != null)
response.setResponse(responseOBJ.toString());
else
response.setError(5000, "OTP validation failed");
} catch (Exception e) {
logger.error("error in validating OTP : " + e);
response.setError(5000, "Error during OTP validation: " + e.getMessage());
}
return response.toString();
}


@CrossOrigin()
@Operation(summary = "Resend OTP")
@RequestMapping(value = "/resendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization")
public String resendOTP(@RequestParam String phoneNumber) {

OutputResponse response = new OutputResponse();

try {

String success = otpHandler.resendOTP(phoneNumber);
if (success.contains("success"))
response.setResponse(success);
else
response.setError(5000, "failure");

} catch (Exception e) {
logger.error("error in re-sending OTP : " + e);
response.setError(5000, "error : " + e);
}
return response.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import com.google.gson.Gson;
import com.iemr.flw.dto.identity.GetBenRequestHandler;
import com.iemr.flw.dto.iemr.*;
import com.iemr.flw.service.ChildService;
import com.iemr.flw.service.DeliveryOutcomeService;
import com.iemr.flw.service.InfantService;
import com.iemr.flw.service.MaternalHealthService;
import com.iemr.flw.service.*;
import com.iemr.flw.utils.response.OutputResponse;

import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.sql.Timestamp;
import java.util.List;
Expand All @@ -24,6 +26,8 @@
public class MaternalHealthController {

private final Logger logger = LoggerFactory.getLogger(CoupleController.class);
@Autowired
FileStorageService fileStorageService;

@Autowired
private MaternalHealthService maternalHealthService;
Expand Down Expand Up @@ -108,6 +112,49 @@ public String saveANCVisit(@RequestBody List<ANCVisitDTO> ancVisitDTOs,
return response.toString();
}

@CrossOrigin()
@Operation(summary = "save ANC visit details with file")
@RequestMapping(value = {"/ancVisit/saveAll"}, method = {RequestMethod.POST}, consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public ResponseEntity<OutputResponse> saveANCVisit(
@RequestPart("ancVisitDTOs") @Valid @RequestBody List<ANCVisitDTO> ancVisitDTOs,
@RequestPart(value = "file", required = false) MultipartFile file,
@RequestHeader(value = "Authorization") String Authorization) {

OutputResponse response = new OutputResponse();
try {
if (ancVisitDTOs.isEmpty()) {
response.setError(5000, "Invalid/NULL request obj");
return ResponseEntity.badRequest().body(response);
}

// Save File if provided
String filePath = null;
if (file != null && !file.isEmpty()) {
filePath = fileStorageService.storeFile(file); // Save the file
}

// Set the filePath in DTOs
for (ANCVisitDTO dto : ancVisitDTOs) {
dto.setFilePath(filePath);
}

logger.info("Saving ANC visits with timestamp : " + new Timestamp(System.currentTimeMillis()));
String s = maternalHealthService.saveANCVisit(ancVisitDTOs);

if (s != null) {
response.setResponse(s);
return ResponseEntity.ok(response);
} else {
response.setError(5000, "Saving ANC data to DB failed");
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
}
} catch (Exception e) {
logger.error("Error in saving ANC visit details : " + e);
response.setError(5000, "Error in saving ANC visit details: " + e.getMessage());
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
}
}
Comment on lines +115 to +156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Validate file content type and size.
While you handle optional files, ensure users can’t upload malicious content. Consider adding checks for MIME type, size, and expected file format, especially before calling fileStorageService.storeFile().


@CrossOrigin()
@Operation(summary = "get anc visit details")
@RequestMapping(value = {"/ancVisit/getAll"}, method = {RequestMethod.POST})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.iemr.flw.controller;

import com.iemr.flw.domain.iemr.MicroBirthPlan;
import com.iemr.flw.service.MicroBirthPlanService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Consider removing 'headers = "Authorization"' from @RequestMapping.

Instead of enforcing Authorization header at the mapping level, consider using Spring Security or an interceptor for authentication/authorization.

-@RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json")
+@RequestMapping(value = "/micro-birthPlan", produces = "application/json")
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json")
@RequestMapping(value = "/micro-birthPlan", produces = "application/json")

public class MicroBirthPlanController {
@Autowired
private MicroBirthPlanService service;
Comment on lines +15 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Replace field injection with constructor injection.

Field injection using @Autowired is discouraged as it makes the class harder to test and hides dependencies.

-    @Autowired
-    private  MicroBirthPlanService service;
+    private final MicroBirthPlanService service;
+
+    public MicroBirthPlanController(MicroBirthPlanService service) {
+        this.service = service;
+    }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Autowired
private MicroBirthPlanService service;
private final MicroBirthPlanService service;
public MicroBirthPlanController(MicroBirthPlanService service) {
this.service = service;
}

@CrossOrigin()
@Operation(summary = "Micro BirthPlan")

@RequestMapping(value = "save",method = RequestMethod.POST)
public ResponseEntity<MicroBirthPlan> createMicroBirthPlan(@RequestBody MicroBirthPlan birthPlan) {
return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan));
}
Comment on lines +20 to +23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Add input validation and proper error handling.

The endpoint should validate the input and handle potential errors gracefully.

     @RequestMapping(value = "save",method = RequestMethod.POST)
-    public ResponseEntity<MicroBirthPlan> createMicroBirthPlan(@RequestBody MicroBirthPlan birthPlan) {
-        return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan));
+    public ResponseEntity<MicroBirthPlan> createMicroBirthPlan(@Valid @RequestBody MicroBirthPlan birthPlan) {
+        try {
+            MicroBirthPlan created = service.createMicroBirthPlan(birthPlan);
+            return ResponseEntity.ok(created);
+        } catch (Exception e) {
+            return ResponseEntity.badRequest().build();
+        }
     }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@RequestMapping(value = "save",method = RequestMethod.POST)
public ResponseEntity<MicroBirthPlan> createMicroBirthPlan(@RequestBody MicroBirthPlan birthPlan) {
return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan));
}
@RequestMapping(value = "save",method = RequestMethod.POST)
public ResponseEntity<MicroBirthPlan> createMicroBirthPlan(@Valid @RequestBody MicroBirthPlan birthPlan) {
try {
MicroBirthPlan created = service.createMicroBirthPlan(birthPlan);
return ResponseEntity.ok(created);
} catch (Exception e) {
return ResponseEntity.badRequest().build();
}
}



@RequestMapping(value = "downSync",method = RequestMethod.GET)
public ResponseEntity<List<MicroBirthPlan>> getAllMicroBirthPlans() {
return ResponseEntity.ok(service.getAllMicroBirthPlans());
}

@RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET)
public ResponseEntity<MicroBirthPlan> getMicroBirthPlanById(@PathVariable Long id) {
return service.getMicroBirthPlanById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}


}
2 changes: 1 addition & 1 deletion src/main/java/com/iemr/flw/controller/UserController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ResponseEntity<?> getUserDetail(@RequestParam(value = "userId") Integer u
return new ResponseEntity<>(
new ApiResponse(true, null, result), HttpStatus.ACCEPTED);
} catch (Exception e) {
logger.error("Error in fetching user role, " + e);
logger.error("Error in fetching user role, " + e.getMessage());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ› οΈ Refactor suggestion

Improve error logging.

Error logging should include the stack trace for better debugging while keeping the user-facing message concise.

Apply this diff:

-            logger.error("Error in fetching user role, " + e.getMessage());
+            logger.error("Error in fetching user role for userId: {}", userId, e);
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.error("Error in fetching user role, " + e.getMessage());
logger.error("Error in fetching user role for userId: {}", userId, e);

return new ResponseEntity<>(
new ApiResponse(false, "Error in fetching user role, " + e.getMessage(), null), HttpStatus.INTERNAL_SERVER_ERROR);
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,8 @@ public class ANCVisit {

@Column(name = "updated_by")
private String updatedBy;

@Column(name = "file_path")
private String filePath;

}
Loading