From c1f861cbe8d807f22d57c1832ef5dbf3231dae03 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Feb 2025 12:35:41 +0530 Subject: [PATCH 001/792] work on otp Beneficiary --- .../BeneficiaryOTPGatewayController.java | 91 +++++++++ .../iemr/flw/dto/iemr/OTPRequestParsor.java | 9 + .../java/com/iemr/flw/service/OTPHandler.java | 14 ++ .../service/impl/OTPHandlerServiceImpl.java | 178 ++++++++++++++++++ .../utils/http/HTTPRequestInterceptor.java | 2 +- .../com/iemr/flw/utils/http/HttpUtils.java | 7 + .../iemr/flw/utils/redis/RedisStorage.java | 8 +- src/main/resources/application.properties | 36 ++++ 8 files changed, 341 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java create mode 100644 src/main/java/com/iemr/flw/service/OTPHandler.java create mode 100644 src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java new file mode 100644 index 00000000..2284e2ad --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java @@ -0,0 +1,91 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.OTPRequestParsor; +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) + 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(); + } + + @CrossOrigin() + @Operation(summary = "Validate OTP") + @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) + public String validateOTP( + @Param(value = "{\"mobNo\":\"String\",\"otp\":\"Integer\"}") @RequestBody String requestOBJ) { + + OutputResponse response = new OutputResponse(); + + try { + OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); + + JSONObject responseOBJ = otpHandler.validateOTP(obj); + 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 = "Resend OTP") + @RequestMapping(value = "/resendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) + 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(); + } + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java b/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java new file mode 100644 index 00000000..91dc1d19 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java @@ -0,0 +1,9 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OTPRequestParsor { + private String mobNo; + private int otp; +} diff --git a/src/main/java/com/iemr/flw/service/OTPHandler.java b/src/main/java/com/iemr/flw/service/OTPHandler.java new file mode 100644 index 00000000..787b76f4 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/OTPHandler.java @@ -0,0 +1,14 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.OTPRequestParsor; +import org.json.JSONObject; +import org.springframework.stereotype.Service; + +public interface OTPHandler { + public String sendOTP(String mobNo) throws Exception; + + public JSONObject validateOTP(OTPRequestParsor obj) throws Exception; + + public String resendOTP(String mobNo) throws Exception; + +} diff --git a/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java new file mode 100644 index 00000000..466574b2 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java @@ -0,0 +1,178 @@ +package com.iemr.flw.service.impl; + +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; +import com.google.common.primitives.Ints; +import com.iemr.flw.dto.iemr.OTPRequestParsor; +import com.iemr.flw.service.OTPHandler; +import com.iemr.flw.utils.config.ConfigProperties; +import com.iemr.flw.utils.http.HttpUtils; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.security.MessageDigest; +import java.security.SecureRandom; +import java.util.Random; +import java.util.concurrent.TimeUnit; + +@Service +public class OTPHandlerServiceImpl implements OTPHandler { + @Autowired + HttpUtils httpUtils; + + + final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + private LoadingCache otpCache; + + private static final Integer EXPIRE_MIN = 5; + + private static final String SMS_GATEWAY_URL = ConfigProperties.getPropertyByName("sms-gateway-url"); + + + // Constructor for new object creation + public OTPHandlerServiceImpl() { + otpCache = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_MIN, TimeUnit.MINUTES) + .build(new CacheLoader() { + public String load(String key) { + return "0"; + } + }); + } + + /*** + * @param + * @return success if OTP sent successfully + */ + @Override + public String sendOTP(String mobNo) throws Exception { + System.out.println("mobNo:"+mobNo); + int otp = generateOTP(mobNo); + // sendSMS(otp, mobNo, "OTP is "); + return "success+\n"+otp; + } + + /*** + * @param obj + * @return OTP verification success or failure + * + */ + @Override + public JSONObject validateOTP(OTPRequestParsor obj) throws Exception { + String cachedOTP = otpCache.get(obj.getMobNo()); + String inputOTPEncrypted = getEncryptedOTP(obj.getOtp()); + System.out.println(cachedOTP.toString() +" "+inputOTPEncrypted.toString()); + + if (cachedOTP.equalsIgnoreCase(inputOTPEncrypted)) { + JSONObject responseObj = new JSONObject(); + responseObj.put("userName", obj.getMobNo()); + responseObj.put("userID", obj.getMobNo()); + + + return responseObj; + } else { + throw new Exception("Please enter valid OTP"); + } + + } + + /*** + * @param + * @return success if OTP re-sent successfully + */ + @Override + public String resendOTP(String mobNo) throws Exception { + int otp = generateOTP(mobNo); + // sendSMS(otp, mobNo, "OTP is "); + return "success+\n"+otp; + } + + // generate 6 digit random no # + public int generateOTP(String authKey) throws Exception { + String generatedPassword = null; + +// Random random = new Random(); + Random random = SecureRandom.getInstanceStrong(); + int otp = 100000 + random.nextInt(900000); + + generatedPassword = getEncryptedOTP(otp); + + if (otpCache != null) + otpCache.put(authKey, generatedPassword); + else { + OTPHandlerServiceImpl obj = new OTPHandlerServiceImpl(); + obj.otpCache.put(authKey, generatedPassword); + } + return otp; + } + + // SHA-256 encoding logic implemented + private String getEncryptedOTP(int otp) throws Exception { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + byte[] bytes = md.digest(Ints.toByteArray(otp)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < bytes.length; i++) { + sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); + } + + return sb.toString(); + } + + // send SMS to user + private void sendSMS(int otp, String phoneNo, String msgText) throws Exception { + String sendSMSURL = ConfigProperties.getPropertyByName("send-message-url"); + String sendSMSAPI = SMS_GATEWAY_URL + "/" + sendSMSURL; + String senderName = ConfigProperties.getPropertyByName("sms-username"); + String senderPassword = ConfigProperties.getPropertyByName("sms-password"); + String senderNumber = ConfigProperties.getPropertyByName("sms-sender-number"); + System.out.println("OTP"+otp+"Phone"+phoneNo+"SMSURL"+sendSMSAPI+"sendName"+senderName+"senderPassword"+senderPassword+"senderNumber"+senderNumber); + + + sendSMSAPI = sendSMSAPI.replace("USERNAME", senderName).replace("PASSWORD", senderPassword) + .replace("SENDER_NUMBER", senderNumber); + + sendSMSAPI = sendSMSAPI + .replace("SMS_TEXT", + msgText.concat(String.valueOf(otp)) + .concat(" for Tele-consultation verification and validity is 5 mins")) + .replace("RECEIVER_NUMBER", phoneNo); + + ResponseEntity response = httpUtils.getV1(sendSMSAPI); + System.out.println("Otp Response"+response); + if (response.getStatusCodeValue() == 200) { + String smsResponse = response.getBody(); + // JSONObject obj = new JSONObject(smsResponse); + // String jobID = obj.getString("JobId"); + switch (smsResponse) { + case "0x200 - Invalid Username or Password": + case "0x201 - Account suspended due to one of several defined reasons": + case "0x202 - Invalid Source Address/Sender ID. As per GSM standard, the sender ID should " + + "be within 11 characters": + case "0x203 - Message length exceeded (more than 160 characters) if concat is set to 0": + case "0x204 - Message length exceeded (more than 459 characters) in concat is set to 1": + case "0x205 - DRL URL is not set": + case "0x206 - Only the subscribed service type can be accessed – " + + "make sure of the service type you are trying to connect with": + case "0x207 - Invalid Source IP – kindly check if the IP is responding": + case "0x208 - Account deactivated/expired": + case "0x209 - Invalid message length (less than 160 characters) if concat is set to 1": + case "0x210 - Invalid Parameter values": + case "0x211 - Invalid Message Length (more than 280 characters)": + case "0x212 - Invalid Message Length": + case "0x213 - Invalid Destination Number": + throw new Exception(smsResponse); + default: + logger.info("SMS Sent successfully by calling API " + sendSMSAPI); + logger.info("SMS Sent successfully sent to : " + phoneNo); + break; + } + } else { + throw new Exception(response.getStatusCodeValue() + " and error " + response.getStatusCode().toString()); + } + } +} diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..50658376 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + // validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { diff --git a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java index edc5930d..57281f22 100644 --- a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java +++ b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java @@ -111,4 +111,11 @@ public HttpStatus getStatus() { public void setStatus(HttpStatus status) { this.status = status; } + + public ResponseEntity getV1(String uri) { + System.out.println(uri.toString()); + HttpEntity requestEntity = new HttpEntity("", headers); + ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.GET, requestEntity, String.class); + return responseEntity; + } } diff --git a/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java b/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java index 5995b7cc..59a6f434 100644 --- a/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java +++ b/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java @@ -1,8 +1,8 @@ /* -* AMRIT – Accessible Medical Records via Integrated Technology -* Integrated EHR (Electronic Health Records) Solution +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution * -* Copyright (C) "Piramal Swasthya Management and Research Institute" +* Copyright (C) "Piramal Swasthya Management and Research Institute" * * This file is part of AMRIT. * @@ -49,6 +49,8 @@ public String setObject(String key, String value, int expirationTime) throws Red redCon.set(key.getBytes(), value.getBytes(), Expiration.seconds(expirationTime), SetOption.UPSERT); } return key; + + } public String getObject(String key, Boolean extendExpirationTime, int expirationTime) throws RedisSessionException { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 12a14942..775a9a28 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,10 @@ spring.main.banner-mode=off spring.data.jpa.repositories.enabled=true #spring.jpa.hibernate.ddl-auto=none +fhir-url=https://uatamrit.piramalswasthya.org/fhirapi-v1.0 +# TM Config +tm-url=https://uatamrit.piramalswasthya.org/tmapi-v1.0 # Naming strategies spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl @@ -45,7 +48,40 @@ get-HRP-Status=ANC/getHRPStatus #Get Beneficiary ABHA getHealthID=healthID/getBenhealthID +# FHIR Config +#fhir-url=/fhirapi-v1.0 +server.port=8086 +# TM Config +#tm-url=/tmapi-v1.0 +##--------------------------------------------## Primary db------------------------------------------------------------------- + +spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr +spring.datasource.username=root +spring.datasource.password=YesBank@123# +#spring.datasource.password=BizDev@24BB + +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +##--------------------------------------------## Secondary db------------------------------------------------------------------- + +secondary.datasource.url=jdbc:mysql://localhost:3306/db_identity +secondary.datasource.username=root +secondary.datasource.password=YesBank@123# +#secondary.datasource.password=BizDev@24BB + +secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +springdoc.api-docs.enabled=true +springdoc.swagger-ui.enabled=true + +sendSMSUrl = v1/send-sms +source-address=AIDSHL +sms-username=PIRAMAL_SW_AHxoyCXejeJba13oKHcv +sms-password=]Kt9GAp8}$S*@ +sms-sender-number ="9560618681" +send-message-url= v1/send-sms +sms-gateway-url= https://iqsms.airtel.in/api From de16a1d0aea200fc82123dd619d2edc269ca5e44 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Feb 2025 15:15:06 +0530 Subject: [PATCH 002/792] work on Asha edit get profile --- .../controller/EmployeeProfileController.java | 71 +++++++++ .../java/com/iemr/flw/domain/iemr/M_User.java | 143 ++++++++++++++++++ .../flw/repo/iemr/EmployeeProfileRepo.java | 11 ++ .../flw/service/EmployeeProfileService.java | 12 ++ .../flw/service/impl/EmployeeProfileImpl.java | 58 +++++++ .../utils/http/HTTPRequestInterceptor.java | 2 +- src/main/resources/application.properties | 36 +++++ 7 files changed, 332 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/iemr/flw/controller/EmployeeProfileController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/M_User.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java create mode 100644 src/main/java/com/iemr/flw/service/EmployeeProfileService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java diff --git a/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java b/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java new file mode 100644 index 00000000..56304996 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java @@ -0,0 +1,71 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.service.EmployeeProfileService; +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; + +@RestController +public class EmployeeProfileController { + private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + @Autowired + EmployeeProfileService employeeProfileService; + private Map response = new HashMap<>(); + + @CrossOrigin() + @Operation(summary = "Edit employee") + + + @RequestMapping(value = "employee/editProfile", method = { RequestMethod.POST }, produces = { + "application/json" }) + public ResponseEntity> editEmployee(@RequestBody M_User editEmployee) { + + try { + System.out.println(editEmployee.toString()); + + + + M_User editdata1 = employeeProfileService.saveEditData(editEmployee); + response.put("data",editdata1); + 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 = "employee/getProfile",method = RequestMethod.POST) + public ResponseEntity> getProfile(@RequestParam ("UserID")Integer userId){ + try { + response.put("data",employeeProfileService.getProfileData(userId)); + 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); + + + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/M_User.java b/src/main/java/com/iemr/flw/domain/iemr/M_User.java new file mode 100644 index 00000000..c87aeb89 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/M_User.java @@ -0,0 +1,143 @@ +package com.iemr.flw.domain.iemr; + +import com.google.gson.annotations.Expose; +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Date; +import java.sql.Timestamp; + +@Entity +@Table(name = "m_User",schema = "db_iemr") +@Data +public class M_User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Expose + @Column(name="UserID") + private Integer userID; + + @Expose + @Column(name="TitleID") + private Integer titleID; + @Expose + @Column(name="FirstName") + private String firstName; + @Expose + @Column(name="MiddleName") + private String middleName; + @Expose + @Column(name="LastName") + private String lastName; + @Expose + @Column(name="GenderID") + private Short genderID; + + @Expose + @Column(name="MaritalStatusID") + private Integer maritalStatusID; + @Expose + @Column(name="DesignationID") + private Integer designationID; + + @Expose + @Column(name="AadhaarNo") + private String aadhaarNo; + @Expose + @Column(name="PAN") + private String pAN; + @Expose + @Column(name="DOB") + private Date dOB; + @Expose + @Column(name="DOJ") + private Date dOJ; + @Expose + @Column(name="QualificationID") + private Integer qualificationID; + @Expose + @Column(name="HealthProfessionalID") + private String healthProfessionalID; + @Expose + @Column(name="UserName") + private String userName; + @Expose + @Column(name="Password") + private String password; + @Expose + @Column(name="IsExternal") + private Boolean isExternal; + @Expose + @Column(name="AgentID") + private String agentID; + @Expose + @Column(name="AgentPassword") + private String agentPassword; + @Expose + @Column(name="EmailID") + private String emailID; + @Expose + @Column(name="StatusID") + private Integer statusID; + @Expose + @Column(name="EmergencyContactPerson") + private String emergencyContactPerson; + @Expose + @Column(name="EmergencyContactNo") + private String emergencyContactNo; + @Expose + @Column(name="IsSupervisor") + private Boolean isSupervisor; + @Expose + @Column(name="Deleted",insertable = false, updatable = true) + private Boolean deleted; + @Expose + @Column(name="CreatedBy") + private String createdBy; + @Expose + @Column(name="EmployeeID") + private String employeeID; + @Expose + @Column(name="CreatedDate",insertable = false, updatable = false) + private Timestamp createdDate; + @Expose + @Column(name="ModifiedBy") + private String modifiedBy; + @Expose + @Column(name="LastModDate",insertable = false, updatable = false) + private Timestamp lastModDate; + + @Expose + @Column(name="Remarks") + private String remarks; + + @Expose + @Column(name="ContactNo") + private String contactNo; + + + @Expose + @Column(name="IsProviderAdmin") + private Boolean isProviderAdmin; + + @Expose + @Column(name="ServiceProviderID") + private Integer serviceProviderID; + + + + @Expose + @Column(name = "failed_attempt", insertable = false) + private Integer failedAttempt; + public M_User() { + // TODO Auto-generated constructor stub + } + + public M_User(Integer userID, String userName) { + // TODO Auto-generated constructor stub + this.userID=userID; + this.userName=userName; + } + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java new file mode 100644 index 00000000..6ac591b3 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java @@ -0,0 +1,11 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.M_User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EmployeeProfileRepo extends JpaRepository { + M_User findUserByUserID(Integer userID); + +} diff --git a/src/main/java/com/iemr/flw/service/EmployeeProfileService.java b/src/main/java/com/iemr/flw/service/EmployeeProfileService.java new file mode 100644 index 00000000..d045e2ee --- /dev/null +++ b/src/main/java/com/iemr/flw/service/EmployeeProfileService.java @@ -0,0 +1,12 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.M_User; +import org.springframework.stereotype.Service; + +@Service +public interface EmployeeProfileService { + + M_User saveEditData(M_User editdata); + M_User getProfileData(Integer UserID); + +} diff --git a/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java new file mode 100644 index 00000000..47aadc92 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java @@ -0,0 +1,58 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.repo.iemr.EmployeeProfileRepo; +import com.iemr.flw.service.EmployeeProfileService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class EmployeeProfileImpl implements EmployeeProfileService { + @Autowired + EmployeeProfileRepo employeeProfileRepo; + + + @Override + public M_User saveEditData(M_User editdata) { + return employeeProfileRepo.save(updateProfile(editdata)); + } + + @Override + public M_User getProfileData(Integer UserID) { + return employeeProfileRepo.findUserByUserID(UserID); + } + + + private M_User updateProfile(M_User editEmployee) { + System.out.println(editEmployee.toString()); + + M_User editdata = new M_User(); + editdata.setUserID(editEmployee.getUserID()); + editdata.setFirstName(editEmployee.getFirstName()); + editdata.setMiddleName(editEmployee.getMiddleName()); + editdata.setLastName(editEmployee.getLastName()); + editdata.setGenderID(editEmployee.getGenderID()); + editdata.setMaritalStatusID(editEmployee.getMaritalStatusID()); + editdata.setAadhaarNo(editEmployee.getAadhaarNo()); + editdata.setPAN(editEmployee.getPAN()); + editdata.setDOB(editEmployee.getDOB()); + editdata.setDOJ(editEmployee.getDOJ()); + editdata.setQualificationID(editEmployee.getQualificationID()); + editdata.setUserName(editEmployee.getUserName()); + editdata.setPassword(editEmployee.getPassword()); + editdata.setAgentID(editEmployee.getAgentID()); + editdata.setAgentPassword(editEmployee.getAgentPassword()); + editdata.setEmailID(editEmployee.getEmailID()); + editdata.setStatusID(editEmployee.getStatusID()); + editdata.setEmergencyContactPerson(editEmployee.getEmergencyContactPerson()); + editdata.setEmergencyContactNo(editEmployee.getEmergencyContactNo()); + editdata.setIsSupervisor(editEmployee.getIsSupervisor()); + editdata.setDeleted(editEmployee.getDeleted()); // Corrected line + editdata.setModifiedBy(editEmployee.getModifiedBy()); + editdata.setLastModDate(editEmployee.getLastModDate()); + editdata.setCreatedBy(editEmployee.getCreatedBy()); + + return editdata; + } + +} diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..50658376 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + // validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 12a14942..86161d92 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,7 +1,10 @@ spring.main.banner-mode=off spring.data.jpa.repositories.enabled=true #spring.jpa.hibernate.ddl-auto=none +fhir-url=https://uatamrit.piramalswasthya.org/fhirapi-v1.0 +# TM Config +tm-url=https://uatamrit.piramalswasthya.org/tmapi-v1.0 # Naming strategies spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl @@ -45,7 +48,40 @@ get-HRP-Status=ANC/getHRPStatus #Get Beneficiary ABHA getHealthID=healthID/getBenhealthID +# FHIR Config +#fhir-url=/fhirapi-v1.0 +server.port=8082 +# TM Config +#tm-url=/tmapi-v1.0 +##--------------------------------------------## Primary db------------------------------------------------------------------- + +spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr +spring.datasource.username=root +spring.datasource.password=YesBank@123# +#spring.datasource.password=BizDev@24BB + +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +##--------------------------------------------## Secondary db------------------------------------------------------------------- + +secondary.datasource.url=jdbc:mysql://localhost:3306/db_identity +secondary.datasource.username=root +secondary.datasource.password=YesBank@123# +#secondary.datasource.password=BizDev@24BB + +secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +springdoc.api-docs.enabled=true +springdoc.swagger-ui.enabled=true + +sendSMSUrl = v1/send-sms +source-address=AIDSHL +sms-username=PIRAMAL_SW_AHxoyCXejeJba13oKHcv +sms-password=]Kt9GAp8}$S*@ +sms-sender-number ="9560618681" +send-message-url= v1/send-sms +sms-gateway-url= https://iqsms.airtel.in/api From 5d3b66678c1069c49a2587b79c82905e68767124 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Feb 2025 15:22:07 +0530 Subject: [PATCH 003/792] work on Asha edit get profile --- .../com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 6 ++++++ .../com/iemr/flw/domain/iemr/EligibleCoupleTracking.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 3 +++ 3 files changed, 12 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index abe8313a..d5db1b4b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -157,4 +157,10 @@ public class EligibleCoupleRegister { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "lmp_date") + private Timestamp lmpDate; + + } + diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java index 2cde9438..729fa36a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java @@ -49,4 +49,7 @@ public class EligibleCoupleTracking { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "lmp_date") + private Timestamp lmpDate; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index e51bbb70..43b5ff4c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -105,4 +105,7 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp updatedDate; private String updatedBy; + + private Timestamp lmpDate; + } From 6edc6613ddf607214358eb77e7a203203df8e1ea Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Feb 2025 11:09:14 +0530 Subject: [PATCH 004/792] work on Asha edit get profile --- .../controller/BeneficiaryOTPGatewayController.java | 6 +++--- .../iemr/flw/controller/EmployeeProfileController.java | 4 ++-- src/main/resources/application.properties | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java index 2284e2ad..f1eab8a6 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java @@ -23,7 +23,7 @@ public class BeneficiaryOTPGatewayController { private OTPHandler otpHandler; @Operation(summary = "Send OTP") - @RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) + @RequestMapping(value = "/sendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization") public String sendOTP(@RequestParam String phoneNumber) { OutputResponse response = new OutputResponse(); @@ -44,7 +44,7 @@ public String sendOTP(@RequestParam String phoneNumber) { @CrossOrigin() @Operation(summary = "Validate OTP") - @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON) + @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,headers = "Authorization") public String validateOTP( @Param(value = "{\"mobNo\":\"String\",\"otp\":\"Integer\"}") @RequestBody String requestOBJ) { @@ -68,7 +68,7 @@ public String validateOTP( @CrossOrigin() @Operation(summary = "Resend OTP") - @RequestMapping(value = "/resendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON) + @RequestMapping(value = "/resendOTP", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON,headers = "Authorization") public String resendOTP(@RequestParam String phoneNumber) { OutputResponse response = new OutputResponse(); diff --git a/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java b/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java index 56304996..35bf254c 100644 --- a/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java +++ b/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java @@ -24,7 +24,7 @@ public class EmployeeProfileController { @RequestMapping(value = "employee/editProfile", method = { RequestMethod.POST }, produces = { - "application/json" }) + "application/json" },headers = "Authorization") public ResponseEntity> editEmployee(@RequestBody M_User editEmployee) { try { @@ -51,7 +51,7 @@ public ResponseEntity> editEmployee(@RequestBody M_User editE } @Operation(summary = "Profile Detail") - @RequestMapping(value = "employee/getProfile",method = RequestMethod.POST) + @RequestMapping(value = "employee/getProfile",method = RequestMethod.POST,headers = "Authorization") public ResponseEntity> getProfile(@RequestParam ("UserID")Integer userId){ try { response.put("data",employeeProfileService.getProfileData(userId)); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 86161d92..17783a97 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -50,7 +50,7 @@ getHealthID=healthID/getBenhealthID # FHIR Config #fhir-url=/fhirapi-v1.0 -server.port=8082 +#server.port=8082 # TM Config #tm-url=/tmapi-v1.0 @@ -58,8 +58,8 @@ server.port=8082 spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr spring.datasource.username=root -spring.datasource.password=YesBank@123# -#spring.datasource.password=BizDev@24BB +#spring.datasource.password=YesBank@123# +spring.datasource.password=BizDev@24BB spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver @@ -67,8 +67,8 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver secondary.datasource.url=jdbc:mysql://localhost:3306/db_identity secondary.datasource.username=root -secondary.datasource.password=YesBank@123# -#secondary.datasource.password=BizDev@24BB +#secondary.datasource.password=YesBank@123# +secondary.datasource.password=BizDev@24BB secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver From 8b7964079af786acab2dbe56b98ad72fb4edb71d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Feb 2025 11:16:29 +0530 Subject: [PATCH 005/792] work on Asha edit get profile --- pom.xml | 2 +- src/main/environment/common_local.properties | 27 +++-- ...roller.java => AshaProfileController.java} | 24 ++--- .../iemr/flw/controller/UserController.java | 2 +- .../com/iemr/flw/domain/iemr/AshaWorker.java | 99 +++++++++++++++++++ .../java/com/iemr/flw/domain/iemr/M_User.java | 1 - ...eProfileRepo.java => AshaProfileRepo.java} | 8 +- .../flw/repo/iemr/UserServiceRoleRepo.java | 3 +- .../iemr/flw/service/AshaProfileService.java | 11 +++ .../flw/service/EmployeeProfileService.java | 12 --- .../flw/service/impl/AshaProfileImpl.java | 75 ++++++++++++++ .../flw/service/impl/EmployeeProfileImpl.java | 58 ----------- 12 files changed, 222 insertions(+), 100 deletions(-) rename src/main/java/com/iemr/flw/controller/{EmployeeProfileController.java => AshaProfileController.java} (69%) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java rename src/main/java/com/iemr/flw/repo/iemr/{EmployeeProfileRepo.java => AshaProfileRepo.java} (51%) create mode 100644 src/main/java/com/iemr/flw/service/AshaProfileService.java delete mode 100644 src/main/java/com/iemr/flw/service/EmployeeProfileService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java delete mode 100644 src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java diff --git a/pom.xml b/pom.xml index b627d253..39ec3e3c 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ jdt_apt 1.2.0.Final 1.16.18 - ${ENV_VAR} + dev target/classes/application.properties src/main/environment/common_${environment}.properties true diff --git a/src/main/environment/common_local.properties b/src/main/environment/common_local.properties index e59c4f54..739894e8 100644 --- a/src/main/environment/common_local.properties +++ b/src/main/environment/common_local.properties @@ -5,17 +5,26 @@ fhir-url=/fhirapi-v1.0 tm-url=/tmapi-v1.0 ##--------------------------------------------## Primary db------------------------------------------------------------------- -spring.datasource.url= -spring.datasource.username= -spring.datasource.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 ##--------------------------------------------## Secondary db------------------------------------------------------------------- -secondary.datasource.username= -secondary.datasource.password= -secondary.datasource.url= -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 \ No newline at end of file +springdoc.swagger-ui.enabled=true + +spring.session.store-type=redis +spring.redis.host=localhost +spring.redis.password=123456 +spring.redis.port=6379 +jakarta.persistence.schema-generation.database.action=create +spring.jpa.defer-datasource-initialization=true \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java similarity index 69% rename from src/main/java/com/iemr/flw/controller/EmployeeProfileController.java rename to src/main/java/com/iemr/flw/controller/AshaProfileController.java index 56304996..aac81249 100644 --- a/src/main/java/com/iemr/flw/controller/EmployeeProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -1,7 +1,7 @@ package com.iemr.flw.controller; -import com.iemr.flw.domain.iemr.M_User; -import com.iemr.flw.service.EmployeeProfileService; +import com.iemr.flw.domain.iemr.AshaWorker; +import com.iemr.flw.service.AshaProfileService; import io.swagger.v3.oas.annotations.Operation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -13,26 +13,26 @@ import java.util.Map; @RestController -public class EmployeeProfileController { +@RequestMapping(value = "/employee", headers = "Authorization", produces = "application/json") +public class AshaProfileController { private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); @Autowired - EmployeeProfileService employeeProfileService; + AshaProfileService ashaProfileService; private Map response = new HashMap<>(); @CrossOrigin() @Operation(summary = "Edit employee") - @RequestMapping(value = "employee/editProfile", method = { RequestMethod.POST }, produces = { - "application/json" }) - public ResponseEntity> editEmployee(@RequestBody M_User editEmployee) { + @RequestMapping(value = "editProfile", method = { RequestMethod.POST }, produces = { + "application/json" },consumes = "application/json" ) + public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee) { try { System.out.println(editEmployee.toString()); - - M_User editdata1 = employeeProfileService.saveEditData(editEmployee); + AshaWorker editdata1 = ashaProfileService.saveEditData(editEmployee); response.put("data",editdata1); response.put("statusCode",200); response.put("status","Success"); @@ -51,10 +51,10 @@ public ResponseEntity> editEmployee(@RequestBody M_User editE } @Operation(summary = "Profile Detail") - @RequestMapping(value = "employee/getProfile",method = RequestMethod.POST) - public ResponseEntity> getProfile(@RequestParam ("UserID")Integer userId){ + @RequestMapping(value = "getProfile",method = RequestMethod.GET) + public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer userId){ try { - response.put("data",employeeProfileService.getProfileData(userId)); + response.put("data",ashaProfileService.getProfileData(userId)); response.put("statusCode",200); response.put("status","Success"); response.put("errorMessage","Success"); diff --git a/src/main/java/com/iemr/flw/controller/UserController.java b/src/main/java/com/iemr/flw/controller/UserController.java index 4a1a79fe..bf596bfd 100644 --- a/src/main/java/com/iemr/flw/controller/UserController.java +++ b/src/main/java/com/iemr/flw/controller/UserController.java @@ -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()); return new ResponseEntity<>( new ApiResponse(false, "Error in fetching user role, " + e.getMessage(), null), HttpStatus.INTERNAL_SERVER_ERROR); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java new file mode 100644 index 00000000..98882822 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java @@ -0,0 +1,99 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import jakarta.validation.constraints.*; +import lombok.*; + +import java.time.LocalDate; + +@Entity +@Data +@Table(name = "asha_worker",schema = "db_iemr") +public class AshaWorker { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "name") + private String name; + + @Column(name = "village") + private String village; + + @Column(name = "employee_id") + private Integer employeeId; // Changed from Integer to String + + @Column(name = "dob") + private LocalDate dob; // Changed from String to LocalDate + + @Transient + private int age; // Auto-calculated from DOB + + + @Column(name = "mobile_number") + private String mobileNumber; + + @Column(name = "alternate_mobile_number") + private String alternateMobileNumber; + + @Column(name = "father_or_spouse_name") + private String fatherOrSpouseName; + + @Column(name = "date_of_joining") + private LocalDate dateOfJoining; // Changed from String to LocalDate + + + @Column(name = "bank_account") + private String bankAccount; + + @Column(name = "ifsc") + private String ifsc; + + + @Column(name = "population_covered") + private Integer populationCovered; + + + @Column(name = "cho_name") + private String choName; + + + @Column(name = "cho_mobile") + private String choMobile; + + + @Column(name = "aww_name") + private String awwName; + + + @Column(name = "aww_mobile") + private String awwMobile; + + + @Column(name = "anm1_name") + private String anm1Name; + + + @Column(name = "anm1_mobile") + private String anm1Mobile; + + + @Column(name = "anm2_name") + private String anm2Name; + + + @Column(name = "anm2_mobile") + private String anm2Mobile; + + + @Column(name = "abha_number") + private String abhaNumber; + + @Column(name = "asha_household_registration") + private String ashaHouseholdRegistration; + + @Column(name = "asha_family_member") + private String ashaFamilyMember; +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/M_User.java b/src/main/java/com/iemr/flw/domain/iemr/M_User.java index c87aeb89..bfe7728b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/M_User.java +++ b/src/main/java/com/iemr/flw/domain/iemr/M_User.java @@ -17,7 +17,6 @@ public class M_User { @Expose @Column(name="UserID") private Integer userID; - @Expose @Column(name="TitleID") private Integer titleID; diff --git a/src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java similarity index 51% rename from src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java rename to src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java index 6ac591b3..9d67cda4 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/EmployeeProfileRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java @@ -1,11 +1,11 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.domain.iemr.AshaWorker; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; - @Repository -public interface EmployeeProfileRepo extends JpaRepository { - M_User findUserByUserID(Integer userID); +public interface AshaProfileRepo extends JpaRepository { + + AshaWorker findByEmployeeId(Integer employeeId); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java index 3fbfe0b0..be829bd9 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java @@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; - import java.util.List; @Repository @@ -15,8 +14,8 @@ public interface UserServiceRoleRepo extends JpaRepository getUserRole(@Param("userId") Integer userId); + List getUserRole(@Param("userId") Integer userId); @Query("select u.userId from UserServiceRole u where u.userName = :userName") Integer getUserIdByName(@Param("userName") String userName); diff --git a/src/main/java/com/iemr/flw/service/AshaProfileService.java b/src/main/java/com/iemr/flw/service/AshaProfileService.java new file mode 100644 index 00000000..3255ad10 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/AshaProfileService.java @@ -0,0 +1,11 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.AshaWorker; +import org.springframework.stereotype.Service; + +@Service +public interface AshaProfileService { + AshaWorker saveEditData(AshaWorker editdata); + AshaWorker getProfileData(Integer employeeId); + +} diff --git a/src/main/java/com/iemr/flw/service/EmployeeProfileService.java b/src/main/java/com/iemr/flw/service/EmployeeProfileService.java deleted file mode 100644 index d045e2ee..00000000 --- a/src/main/java/com/iemr/flw/service/EmployeeProfileService.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.iemr.flw.service; - -import com.iemr.flw.domain.iemr.M_User; -import org.springframework.stereotype.Service; - -@Service -public interface EmployeeProfileService { - - M_User saveEditData(M_User editdata); - M_User getProfileData(Integer UserID); - -} diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java new file mode 100644 index 00000000..104ba731 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -0,0 +1,75 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.AshaWorker; +import com.iemr.flw.repo.iemr.AshaProfileRepo; +import com.iemr.flw.service.AshaProfileService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Objects; +@Service +public class AshaProfileImpl implements AshaProfileService { + @Autowired + AshaProfileRepo ashaProfileRepo; + + private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); + + @Override + public AshaWorker saveEditData(AshaWorker ashaWorker) { + AshaWorker ashaWorker1; + if(Objects.equals(ashaProfileRepo.findByEmployeeId(ashaWorker.getEmployeeId()).getEmployeeId(), ashaWorker.getEmployeeId())){ + ashaWorker1 = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorker)); + + }else { + ashaWorker1 = ashaProfileRepo.saveAndFlush(ashaWorker); + + } + System.out.println("ashaWorker->>>"+ashaWorker1.toString()); + + return ashaWorker1; + + + } + + @Override + public AshaWorker getProfileData(Integer employeeId) { + return ashaProfileRepo.findByEmployeeId(employeeId); + } + + + private AshaWorker updateProfile(AshaWorker editEmployee) { + System.out.println(editEmployee.toString()); + + AshaWorker editdata = new AshaWorker(); + editdata.setId(editEmployee.getId()); + editdata.setAge(editEmployee.getAge()); + editdata.setAbhaNumber(editEmployee.getAbhaNumber()); + editdata.setEmployeeId(editEmployee.getEmployeeId()); + editdata.setDob(editEmployee.getDob()); + editdata.setAlternateMobileNumber(editEmployee.getAlternateMobileNumber()); + editdata.setAnm1Mobile(editEmployee.getAnm1Mobile()); + editdata.setAnm2Name(editEmployee.getAnm2Name()); + editdata.setIfsc(editEmployee.getIfsc()); + editdata.setAwwName(editEmployee.getAwwName()); + editdata.setName(editEmployee.getName()); + editdata.setVillage(editEmployee.getVillage()); + editdata.setBankAccount(editEmployee.getBankAccount()); + editdata.setChoMobile(editEmployee.getChoMobile()); + editdata.setAbhaNumber(editEmployee.getAbhaNumber()); + editdata.setAshaFamilyMember(editEmployee.getAshaFamilyMember()); + editdata.setAshaHouseholdRegistration(editEmployee.getAshaHouseholdRegistration()); + editdata.setFatherOrSpouseName(editEmployee.getFatherOrSpouseName()); + editdata.setPopulationCovered(editEmployee.getPopulationCovered()); + editdata.setAnm1Name(editEmployee.getAnm1Name()); + editdata.setAnm2Mobile(editEmployee.getAnm2Mobile()); // Corrected line + editdata.setAwwMobile(editEmployee.getAwwMobile()); + + return editdata; + + + + } + +} diff --git a/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java deleted file mode 100644 index 47aadc92..00000000 --- a/src/main/java/com/iemr/flw/service/impl/EmployeeProfileImpl.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.iemr.flw.service.impl; - -import com.iemr.flw.domain.iemr.M_User; -import com.iemr.flw.repo.iemr.EmployeeProfileRepo; -import com.iemr.flw.service.EmployeeProfileService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class EmployeeProfileImpl implements EmployeeProfileService { - @Autowired - EmployeeProfileRepo employeeProfileRepo; - - - @Override - public M_User saveEditData(M_User editdata) { - return employeeProfileRepo.save(updateProfile(editdata)); - } - - @Override - public M_User getProfileData(Integer UserID) { - return employeeProfileRepo.findUserByUserID(UserID); - } - - - private M_User updateProfile(M_User editEmployee) { - System.out.println(editEmployee.toString()); - - M_User editdata = new M_User(); - editdata.setUserID(editEmployee.getUserID()); - editdata.setFirstName(editEmployee.getFirstName()); - editdata.setMiddleName(editEmployee.getMiddleName()); - editdata.setLastName(editEmployee.getLastName()); - editdata.setGenderID(editEmployee.getGenderID()); - editdata.setMaritalStatusID(editEmployee.getMaritalStatusID()); - editdata.setAadhaarNo(editEmployee.getAadhaarNo()); - editdata.setPAN(editEmployee.getPAN()); - editdata.setDOB(editEmployee.getDOB()); - editdata.setDOJ(editEmployee.getDOJ()); - editdata.setQualificationID(editEmployee.getQualificationID()); - editdata.setUserName(editEmployee.getUserName()); - editdata.setPassword(editEmployee.getPassword()); - editdata.setAgentID(editEmployee.getAgentID()); - editdata.setAgentPassword(editEmployee.getAgentPassword()); - editdata.setEmailID(editEmployee.getEmailID()); - editdata.setStatusID(editEmployee.getStatusID()); - editdata.setEmergencyContactPerson(editEmployee.getEmergencyContactPerson()); - editdata.setEmergencyContactNo(editEmployee.getEmergencyContactNo()); - editdata.setIsSupervisor(editEmployee.getIsSupervisor()); - editdata.setDeleted(editEmployee.getDeleted()); // Corrected line - editdata.setModifiedBy(editEmployee.getModifiedBy()); - editdata.setLastModDate(editEmployee.getLastModDate()); - editdata.setCreatedBy(editEmployee.getCreatedBy()); - - return editdata; - } - -} From ea65636bf026bc106240840363d9bac6777d5916 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 21 Feb 2025 17:55:58 +0530 Subject: [PATCH 006/792] Upload feature in ANC visit MicroBirthPlan Otp Beneficiary Asha worker profile lmp date --- pom.xml | 2 +- .../flw/controller/AshaProfileController.java | 9 +++ .../BeneficiaryOTPGatewayController.java | 10 +-- .../controller/MaternalHealthController.java | 55 +++++++++++++-- .../controller/MicroBirthPlanController.java | 39 +++++++++++ .../com/iemr/flw/domain/iemr/ANCVisit.java | 3 + .../com/iemr/flw/domain/iemr/AshaWorker.java | 10 +-- .../java/com/iemr/flw/domain/iemr/M_User.java | 5 +- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 68 +++++++++++++++++++ .../iemr/flw/domain/iemr/OtpBeneficiary.java | 33 +++++++++ .../com/iemr/flw/dto/iemr/ANCVisitDTO.java | 4 ++ .../com/iemr/flw/dto/iemr/OtpRequestDTO.java | 10 +++ .../flw/repo/iemr/EmployeeMasterRepo.java | 11 +++ .../repo/iemr/MicroBirthPlanRepository.java | 9 +++ .../repo/iemr/OtpBeneficiaryRepository.java | 11 +++ .../iemr/flw/service/EmployeeMasterInter.java | 10 +++ .../iemr/flw/service/FileStorageService.java | 38 +++++++++++ .../flw/service/MicroBirthPlanService.java | 55 +++++++++++++++ .../java/com/iemr/flw/service/OTPHandler.java | 3 +- .../flw/service/impl/AshaProfileImpl.java | 44 +++++++++--- .../flw/service/impl/EmployeeMasterImpl.java | 18 +++++ .../service/impl/OTPHandlerServiceImpl.java | 42 ++++++++++-- 22 files changed, 458 insertions(+), 31 deletions(-) create mode 100644 src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java create mode 100644 src/main/java/com/iemr/flw/service/EmployeeMasterInter.java create mode 100644 src/main/java/com/iemr/flw/service/FileStorageService.java create mode 100644 src/main/java/com/iemr/flw/service/MicroBirthPlanService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java diff --git a/pom.xml b/pom.xml index 39ec3e3c..3bb0537b 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ jdt_apt 1.2.0.Final 1.16.18 - dev + local target/classes/application.properties src/main/environment/common_${environment}.properties true diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index aac81249..5c6479a7 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -1,7 +1,12 @@ 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; @@ -11,6 +16,7 @@ import java.util.HashMap; import java.util.Map; +import java.util.Objects; @RestController @RequestMapping(value = "/employee", headers = "Authorization", produces = "application/json") @@ -20,6 +26,8 @@ public class AshaProfileController { AshaProfileService ashaProfileService; private Map response = new HashMap<>(); + @Autowired + private EmployeeMasterInter employeeMasterInter; @CrossOrigin() @Operation(summary = "Edit employee") @@ -54,6 +62,7 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e @RequestMapping(value = "getProfile",method = RequestMethod.GET) public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer userId){ try { + response.put("data",ashaProfileService.getProfileData(userId)); response.put("statusCode",200); response.put("status","Success"); diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java index f1eab8a6..1ab99845 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java @@ -1,6 +1,8 @@ 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; @@ -30,6 +32,7 @@ public String sendOTP(@RequestParam String phoneNumber) { try { String success = otpHandler.sendOTP(phoneNumber); + if (success.contains("success")) response.setResponse(success); else @@ -45,15 +48,14 @@ public String sendOTP(@RequestParam String phoneNumber) { @CrossOrigin() @Operation(summary = "Validate OTP") @RequestMapping(value = "/validateOTP", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,headers = "Authorization") - public String validateOTP( - @Param(value = "{\"mobNo\":\"String\",\"otp\":\"Integer\"}") @RequestBody String requestOBJ) { + public String validateOTP(@RequestBody OtpRequestDTO requestOBJ) { OutputResponse response = new OutputResponse(); try { - OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); +// OTPRequestParsor obj = InputMapper.gson().fromJson(requestOBJ, OTPRequestParsor.class); - JSONObject responseOBJ = otpHandler.validateOTP(obj); + JSONObject responseOBJ = otpHandler.validateOTP(requestOBJ); if (responseOBJ != null) response.setResponse(responseOBJ.toString()); else diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 61476ef4..4fb2630a 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -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; @@ -24,6 +26,8 @@ public class MaternalHealthController { private final Logger logger = LoggerFactory.getLogger(CoupleController.class); + @Autowired + FileStorageService fileStorageService; @Autowired private MaternalHealthService maternalHealthService; @@ -108,6 +112,49 @@ public String saveANCVisit(@RequestBody List 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 saveANCVisit( + @RequestPart("ancVisitDTOs") @Valid @RequestBody List 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); + } + } + @CrossOrigin() @Operation(summary = "get anc visit details") @RequestMapping(value = {"/ancVisit/getAll"}, method = {RequestMethod.POST}) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java new file mode 100644 index 00000000..34103942 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -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") +public class MicroBirthPlanController { + @Autowired + private MicroBirthPlanService service; + @CrossOrigin() + @Operation(summary = "Micro BirthPlan") + + @RequestMapping(value = "save",method = RequestMethod.POST) + public ResponseEntity createMicroBirthPlan(@RequestBody MicroBirthPlan birthPlan) { + return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan)); + } + + + @RequestMapping(value = "downSync",method = RequestMethod.GET) + public ResponseEntity> getAllMicroBirthPlans() { + return ResponseEntity.ok(service.getAllMicroBirthPlans()); + } + + @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) + public ResponseEntity getMicroBirthPlanById(@PathVariable Long id) { + return service.getMicroBirthPlanById(id) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); + } + + +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 9aeb8878..19e2e562 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -112,4 +112,7 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "file_path") + private String filePath; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java index 98882822..6b1c5da9 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java @@ -8,7 +8,7 @@ @Entity @Data -@Table(name = "asha_worker",schema = "db_iemr") +@Table(name = "asha_profile",schema = "db_iemr") public class AshaWorker { @Id @@ -28,9 +28,6 @@ public class AshaWorker { @Column(name = "dob") private LocalDate dob; // Changed from String to LocalDate - @Transient - private int age; // Auto-calculated from DOB - @Column(name = "mobile_number") private String mobileNumber; @@ -56,7 +53,7 @@ public class AshaWorker { private Integer populationCovered; - @Column(name = "cho_name") + @Column(name = "cho_name",nullable = false) private String choName; @@ -96,4 +93,7 @@ public class AshaWorker { @Column(name = "asha_family_member") private String ashaFamilyMember; + + @Column(name = "ProviderServiceMapID") + private Integer ProviderServiceMapID; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/M_User.java b/src/main/java/com/iemr/flw/domain/iemr/M_User.java index bfe7728b..fbacff22 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/M_User.java +++ b/src/main/java/com/iemr/flw/domain/iemr/M_User.java @@ -6,6 +6,7 @@ import java.sql.Date; import java.sql.Timestamp; +import java.time.LocalDate; @Entity @Table(name = "m_User",schema = "db_iemr") @@ -48,10 +49,10 @@ public class M_User { private String pAN; @Expose @Column(name="DOB") - private Date dOB; + private LocalDate dOB; @Expose @Column(name="DOJ") - private Date dOJ; + private LocalDate dOJ; @Expose @Column(name="QualificationID") private Integer qualificationID; diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java new file mode 100644 index 00000000..89f97f67 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -0,0 +1,68 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Table(name = "t_micro_birth_plan", schema = "db_iemr") +@Data +public class MicroBirthPlan { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "pw_name") + private String pwName; // Auto-populated + + @Column(name = "age") + private Integer age; // Auto-populated + + @Column(name = "contact_no_1", length = 10) + private String contactNo1; // Auto-filled, must be 10 digits, starts with 6-9 + + @Column(name = "contact_no_2", length = 10) + private String contactNo2; // Optional, 10 digits, starts with 6-9 + + @Column(name = "sc_hwc_tg_hosp", length = 100) + private String scHwcTgHosp; // Alphanumeric, all caps + + @Column(name = "block", length = 100) + private String block; // Alphanumeric, all caps + + @Column(name = "husband_name") + private String husbandName; // Auto-populated + + @Column(name = "nearest_sc_hwc", length = 100) + private String nearestScHwc; // Alphanumeric, all caps + + @Column(name = "nearest_phc", length = 100) + private String nearestPhc; // Alphanumeric, all caps + + @Column(name = "nearest_fru", length = 100) + private String nearestFru; // Alphanumeric, all caps + + @Column(name = "nearest_usg", length = 100) + private String nearestUsg; // Alphanumeric, all caps + + @Column(name = "blood_group") + private String bloodGroup; // Spinner: A+, B+, etc. + + @Column(name = "blood_donors", length = 50) + private String bloodDonors; // Alphabets only, all caps + + @Column(name = "birth_companion", length = 50) + private String birthCompanion; // Alphabets only, all caps + + @Column(name = "child_caretaker", length = 50) + private String childCaretaker; // Alphabets only, all caps + + @Column(name = "community_support", length = 100) + private String communitySupport; // Alphabets only, all caps + + @Column(name = "transportation_mode", length = 100) + private String transportationMode; // Mode of transport + + @Column(name = "is_synced") + private Boolean isSynced; +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java b/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java new file mode 100644 index 00000000..15a87bd0 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java @@ -0,0 +1,33 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import java.sql.Timestamp; + +@Entity +@Table(name = "m_otp_beneficiary", schema = "db_iemr") +@Data +public class OtpBeneficiary { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "beneficiaryId", nullable = false) + private Long beneficiaryId; + + @Column(name = "phoneNumber", nullable = false, length = 45) + private String phoneNumber; + + @Column(name = "isOtpVerify") + private Boolean isOtpVerify = false; + + @Column(name = "otp", nullable = false) + private Integer otp; + + @Column(name = "isExpired") + private Boolean isExpired = false; + + @Column(name = "createdAt", updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + private Timestamp createdAt; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 83f1acef..0cd07846 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -2,6 +2,7 @@ import lombok.Data; +import java.io.File; import java.sql.Timestamp; @Data @@ -42,5 +43,8 @@ public class ANCVisitDTO { private Timestamp updatedDate; private String updatedBy; private Integer providerServiceMapID; + private String filePath; + + } diff --git a/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java new file mode 100644 index 00000000..b9be9650 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OtpRequestDTO { + private Long beneficiaryId; + private String phoneNumber; + private Integer otp; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java new file mode 100644 index 00000000..6b57efc3 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java @@ -0,0 +1,11 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.M_User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EmployeeMasterRepo extends JpaRepository { + M_User findByUserID(Integer userID); + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java new file mode 100644 index 00000000..489ddd7b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java @@ -0,0 +1,9 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MicroBirthPlanRepository extends JpaRepository { +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java b/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java new file mode 100644 index 00000000..bc223578 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java @@ -0,0 +1,11 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.OtpBeneficiary; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; +@Repository +public interface OtpBeneficiaryRepository extends JpaRepository { + Optional findByPhoneNumberAndOtp(String phoneNumber, Integer otp); +} diff --git a/src/main/java/com/iemr/flw/service/EmployeeMasterInter.java b/src/main/java/com/iemr/flw/service/EmployeeMasterInter.java new file mode 100644 index 00000000..c360c34b --- /dev/null +++ b/src/main/java/com/iemr/flw/service/EmployeeMasterInter.java @@ -0,0 +1,10 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.M_User; +import org.springframework.stereotype.Service; + +@Service +public interface EmployeeMasterInter { + public M_User getUserDetails(Integer userID); + +} diff --git a/src/main/java/com/iemr/flw/service/FileStorageService.java b/src/main/java/com/iemr/flw/service/FileStorageService.java new file mode 100644 index 00000000..d22352ce --- /dev/null +++ b/src/main/java/com/iemr/flw/service/FileStorageService.java @@ -0,0 +1,38 @@ +package com.iemr.flw.service; + +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.UUID; + +@Service +public class FileStorageService { + + private static final String UPLOAD_DIR = "uploads/"; // Define your upload directory + + public String storeFile(MultipartFile file) throws IOException { + if (file.isEmpty()) { + throw new IllegalStateException("Cannot store empty file."); + } + + // Create directories if they do not exist + File uploadDir = new File(UPLOAD_DIR); + if (!uploadDir.exists()) { + uploadDir.mkdirs(); + } + + // Generate a unique file name + String fileName = UUID.randomUUID().toString() + "_" + file.getOriginalFilename(); + Path filePath = Paths.get(UPLOAD_DIR + fileName); + + // Save file + Files.write(filePath, file.getBytes()); + + return filePath.toString(); // Return the saved file path + } +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java new file mode 100644 index 00000000..c3b8d507 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java @@ -0,0 +1,55 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import com.iemr.flw.repo.iemr.MicroBirthPlanRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class MicroBirthPlanService { + @Autowired + private MicroBirthPlanRepository repository; + + public MicroBirthPlan createMicroBirthPlan(MicroBirthPlan birthPlan) { + return repository.save(birthPlan); + } + + public List getAllMicroBirthPlans() { + return repository.findAll(); + } + + public Optional getMicroBirthPlanById(Long id) { + return repository.findById(id); + } + + public MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan) { + return repository.findById(id).map(existingPlan -> { + existingPlan.setPwName(updatedPlan.getPwName()); + existingPlan.setAge(updatedPlan.getAge()); + existingPlan.setContactNo1(updatedPlan.getContactNo1()); + existingPlan.setContactNo2(updatedPlan.getContactNo2()); + existingPlan.setScHwcTgHosp(updatedPlan.getScHwcTgHosp()); + existingPlan.setBlock(updatedPlan.getBlock()); + existingPlan.setHusbandName(updatedPlan.getHusbandName()); + existingPlan.setNearestScHwc(updatedPlan.getNearestScHwc()); + existingPlan.setNearestPhc(updatedPlan.getNearestPhc()); + existingPlan.setNearestFru(updatedPlan.getNearestFru()); + existingPlan.setNearestUsg(updatedPlan.getNearestUsg()); + existingPlan.setBloodGroup(updatedPlan.getBloodGroup()); + existingPlan.setBloodDonors(updatedPlan.getBloodDonors()); + existingPlan.setBirthCompanion(updatedPlan.getBirthCompanion()); + existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); + existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); + existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); + return repository.save(existingPlan); + }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); + } + + public void deleteMicroBirthPlan(Long id) { + repository.deleteById(id); + } +} diff --git a/src/main/java/com/iemr/flw/service/OTPHandler.java b/src/main/java/com/iemr/flw/service/OTPHandler.java index 787b76f4..0ab17b5b 100644 --- a/src/main/java/com/iemr/flw/service/OTPHandler.java +++ b/src/main/java/com/iemr/flw/service/OTPHandler.java @@ -1,13 +1,14 @@ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.OTPRequestParsor; +import com.iemr.flw.dto.iemr.OtpRequestDTO; import org.json.JSONObject; import org.springframework.stereotype.Service; public interface OTPHandler { public String sendOTP(String mobNo) throws Exception; - public JSONObject validateOTP(OTPRequestParsor obj) throws Exception; + public JSONObject validateOTP(OtpRequestDTO obj) throws Exception; public String resendOTP(String mobNo) throws Exception; diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 104ba731..ab5437a6 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -1,41 +1,65 @@ package com.iemr.flw.service.impl; import com.iemr.flw.domain.iemr.AshaWorker; +import com.iemr.flw.domain.iemr.M_User; import com.iemr.flw.repo.iemr.AshaProfileRepo; import com.iemr.flw.service.AshaProfileService; +import com.iemr.flw.service.EmployeeMasterInter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Objects; + @Service public class AshaProfileImpl implements AshaProfileService { @Autowired AshaProfileRepo ashaProfileRepo; + @Autowired + EmployeeMasterInter employeeMasterInter; private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); @Override public AshaWorker saveEditData(AshaWorker ashaWorker) { AshaWorker ashaWorker1; - if(Objects.equals(ashaProfileRepo.findByEmployeeId(ashaWorker.getEmployeeId()).getEmployeeId(), ashaWorker.getEmployeeId())){ - ashaWorker1 = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorker)); + if (ashaWorker.getId() != null) { + ashaWorker1 = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorker)); - }else { - ashaWorker1 = ashaProfileRepo.saveAndFlush(ashaWorker); + } else { + ashaWorker1 = ashaProfileRepo.saveAndFlush(ashaWorker); } - System.out.println("ashaWorker->>>"+ashaWorker1.toString()); + System.out.println("ashaWorker->>>" + ashaWorker1.toString()); - return ashaWorker1; + return ashaWorker1; } @Override public AshaWorker getProfileData(Integer employeeId) { - return ashaProfileRepo.findByEmployeeId(employeeId); + if (ashaProfileRepo.findByEmployeeId(employeeId)!=null) { + return ashaProfileRepo.findByEmployeeId(employeeId); + } else { + return getDetails(employeeId); + } + } + + private AshaWorker getDetails(Integer userID) { + AshaWorker ashaWorker = new AshaWorker(); + M_User m_user = employeeMasterInter.getUserDetails(userID); + + ashaWorker.setEmployeeId(m_user.getUserID()); + ashaWorker.setEmployeeId(m_user.getUserID()); + ashaWorker.setDob(m_user.getDOB()); + ashaWorker.setDateOfJoining(m_user.getDOJ()); + ashaWorker.setName(m_user.getFirstName() + " " + m_user.getLastName()); + ashaWorker.setMobileNumber(m_user.getContactNo()); + ashaWorker.setAlternateMobileNumber(m_user.getEmergencyContactNo()); + ashaWorker.setProviderServiceMapID(m_user.getServiceProviderID()); + return ashaWorker; } @@ -44,7 +68,6 @@ private AshaWorker updateProfile(AshaWorker editEmployee) { AshaWorker editdata = new AshaWorker(); editdata.setId(editEmployee.getId()); - editdata.setAge(editEmployee.getAge()); editdata.setAbhaNumber(editEmployee.getAbhaNumber()); editdata.setEmployeeId(editEmployee.getEmployeeId()); editdata.setDob(editEmployee.getDob()); @@ -56,20 +79,23 @@ private AshaWorker updateProfile(AshaWorker editEmployee) { editdata.setName(editEmployee.getName()); editdata.setVillage(editEmployee.getVillage()); editdata.setBankAccount(editEmployee.getBankAccount()); + editdata.setChoName(editEmployee.getChoName()); editdata.setChoMobile(editEmployee.getChoMobile()); editdata.setAbhaNumber(editEmployee.getAbhaNumber()); editdata.setAshaFamilyMember(editEmployee.getAshaFamilyMember()); + editdata.setDateOfJoining(editEmployee.getDateOfJoining()); + editdata.setMobileNumber(editEmployee.getMobileNumber()); editdata.setAshaHouseholdRegistration(editEmployee.getAshaHouseholdRegistration()); editdata.setFatherOrSpouseName(editEmployee.getFatherOrSpouseName()); editdata.setPopulationCovered(editEmployee.getPopulationCovered()); editdata.setAnm1Name(editEmployee.getAnm1Name()); editdata.setAnm2Mobile(editEmployee.getAnm2Mobile()); // Corrected line editdata.setAwwMobile(editEmployee.getAwwMobile()); + editdata.setProviderServiceMapID(editEmployee.getProviderServiceMapID()); return editdata; - } } diff --git a/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java new file mode 100644 index 00000000..cf542677 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java @@ -0,0 +1,18 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.repo.iemr.EmployeeMasterRepo; +import com.iemr.flw.service.EmployeeMasterInter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class EmployeeMasterImpl implements EmployeeMasterInter { + @Autowired + EmployeeMasterRepo employeeMasterRepo; + + @Override + public M_User getUserDetails(Integer userID) { + return employeeMasterRepo.findByUserID(userID); + } +} diff --git a/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java index 466574b2..ef311f01 100644 --- a/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java @@ -4,7 +4,10 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.primitives.Ints; +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.repo.iemr.OtpBeneficiaryRepository; import com.iemr.flw.service.OTPHandler; import com.iemr.flw.utils.config.ConfigProperties; import com.iemr.flw.utils.http.HttpUtils; @@ -17,6 +20,8 @@ import java.security.MessageDigest; import java.security.SecureRandom; +import java.sql.Timestamp; +import java.util.Optional; import java.util.Random; import java.util.concurrent.TimeUnit; @@ -24,6 +29,8 @@ public class OTPHandlerServiceImpl implements OTPHandler { @Autowired HttpUtils httpUtils; + @Autowired + OtpBeneficiaryRepository otpBeneficiaryRepository; final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); @@ -53,6 +60,7 @@ public String load(String key) { public String sendOTP(String mobNo) throws Exception { System.out.println("mobNo:"+mobNo); int otp = generateOTP(mobNo); + saveOtp(mobNo,otp); // sendSMS(otp, mobNo, "OTP is "); return "success+\n"+otp; } @@ -63,17 +71,17 @@ public String sendOTP(String mobNo) throws Exception { * */ @Override - public JSONObject validateOTP(OTPRequestParsor obj) throws Exception { - String cachedOTP = otpCache.get(obj.getMobNo()); + public JSONObject validateOTP(OtpRequestDTO obj) throws Exception { + String cachedOTP = otpCache.get(obj.getPhoneNumber()); String inputOTPEncrypted = getEncryptedOTP(obj.getOtp()); System.out.println(cachedOTP.toString() +" "+inputOTPEncrypted.toString()); if (cachedOTP.equalsIgnoreCase(inputOTPEncrypted)) { JSONObject responseObj = new JSONObject(); - responseObj.put("userName", obj.getMobNo()); - responseObj.put("userID", obj.getMobNo()); - + responseObj.put("userName", obj.getPhoneNumber()); + responseObj.put("userID", obj.getPhoneNumber()); + verifyOtp(obj.getPhoneNumber(),obj.getOtp(),obj.getBeneficiaryId()); return responseObj; } else { throw new Exception("Please enter valid OTP"); @@ -89,8 +97,23 @@ public JSONObject validateOTP(OTPRequestParsor obj) throws Exception { public String resendOTP(String mobNo) throws Exception { int otp = generateOTP(mobNo); // sendSMS(otp, mobNo, "OTP is "); + saveOtp(mobNo,otp); return "success+\n"+otp; } + public String verifyOtp(String phoneNumber, Integer otp,Long otpBeneficiaryId) { + Optional otpEntry = otpBeneficiaryRepository.findByPhoneNumberAndOtp(phoneNumber, otp); + + if (otpEntry.isPresent()) { + OtpBeneficiary otpBeneficiary = otpEntry.get(); + otpBeneficiary.setBeneficiaryId(otpBeneficiaryId); + otpBeneficiary.setIsOtpVerify(true); + otpBeneficiary.setIsExpired(true); + otpBeneficiaryRepository.save(otpBeneficiary); + return "OTP verified successfully."; + } else { + return "Invalid or expired OTP."; + } + } // generate 6 digit random no # public int generateOTP(String authKey) throws Exception { @@ -110,6 +133,15 @@ public int generateOTP(String authKey) throws Exception { } return otp; } + private void saveOtp(String phoneNo,Integer otp){ + OtpBeneficiary otpEntry = new OtpBeneficiary(); + otpEntry.setBeneficiaryId(null); + otpEntry.setPhoneNumber(phoneNo); + otpEntry.setOtp(otp); + otpEntry.setCreatedAt(new Timestamp(System.currentTimeMillis())); + + otpBeneficiaryRepository.save(otpEntry); + } // SHA-256 encoding logic implemented private String getEncryptedOTP(int otp) throws Exception { From 0a786a79698d5f54f07f0c4002e51d139af6b7f9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 21 Feb 2025 18:18:55 +0530 Subject: [PATCH 007/792] Asha profile lmp date --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 3 --- src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java | 1 + src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 19e2e562..9aeb8878 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -112,7 +112,4 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; - - @Column(name = "file_path") - private String filePath; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java index 6b1c5da9..5cf5bfd1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java @@ -6,6 +6,7 @@ import java.time.LocalDate; + @Entity @Data @Table(name = "asha_profile",schema = "db_iemr") diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 0cd07846..54e48fca 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -43,7 +43,6 @@ public class ANCVisitDTO { private Timestamp updatedDate; private String updatedBy; private Integer providerServiceMapID; - private String filePath; } From 93a335b746bc3a765674eb101fc13c8219716b25 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 23 Feb 2025 10:27:26 +0530 Subject: [PATCH 008/792] MicroBirthPlan --- .../controller/MicroBirthPlanController.java | 40 ++++++++++ .../iemr/flw/domain/iemr/MicroBirthPlan.java | 77 +++++++++++++++++++ .../iemr/flw/dto/iemr/MicroBirthPlanDTO.java | 11 +++ .../repo/iemr/MicroBirthPlanRepository.java | 11 +++ .../flw/service/MicroBirthPlanService.java | 22 ++++++ .../impl/MicroBirthPlanServiceImpl.java | 68 ++++++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java create mode 100644 src/main/java/com/iemr/flw/service/MicroBirthPlanService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java new file mode 100644 index 00000000..6d528e52 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -0,0 +1,40 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; +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") +public class MicroBirthPlanController { + @Autowired + private MicroBirthPlanService service; + @CrossOrigin() + @Operation(summary = "Micro BirthPlan") + + @RequestMapping(value = "saveAll",method = RequestMethod.POST) + public ResponseEntity createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { + return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan)); + } + + + @RequestMapping(value = "getAll",method = RequestMethod.GET) + public ResponseEntity> getAllMicroBirthPlans() { + return ResponseEntity.ok(service.getAllMicroBirthPlans()); + } + + @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) + public ResponseEntity getMicroBirthPlanById(@PathVariable Long id) { + return service.getMicroBirthPlanById(id) + .map(ResponseEntity::ok) + .orElse(ResponseEntity.notFound().build()); + } + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java new file mode 100644 index 00000000..ecbcbe9b --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -0,0 +1,77 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Table(name = "t_micro_birth_plan", schema = "db_iemr") +@Data +public class MicroBirthPlan { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "user_id") + private Integer UserId; + + @Column(name = "ben_id") + private Integer benId; + + @Column(name = "pw_name") + private String pwName; // Auto-populated + + @Column(name = "age") + private Integer age; // Auto-populated + + @Column(name = "contact_no_1", length = 10) + private String contactNo1; // Auto-filled, must be 10 digits, starts with 6-9 + + @Column(name = "contact_no_2", length = 10) + private String contactNo2; // Optional, 10 digits, starts with 6-9 + + @Column(name = "sc_hwc_tg_hosp", length = 100) + private String scHwcTgHosp; // Alphanumeric, all caps + + @Column(name = "block", length = 100) + private String block; // Alphanumeric, all caps + + @Column(name = "husband_name") + private String husbandName; // Auto-populated + + @Column(name = "nearest_sc_hwc", length = 100) + private String nearestScHwc; // Alphanumeric, all caps + + @Column(name = "nearest_phc", length = 100) + private String nearestPhc; // Alphanumeric, all caps + + @Column(name = "nearest_fru", length = 100) + private String nearestFru; // Alphanumeric, all caps + + @Column(name = "nearest_usg", length = 100) + private String nearestUsg; // Alphanumeric, all caps + + @Column(name = "blood_group") + private String bloodGroup; // Spinner: A+, B+, etc. + + @Column(name = "blood_donors", length = 50) + private String bloodDonors; // Alphabets only, all caps + + @Column(name = "birth_companion", length = 50) + private String birthCompanion; // Alphabets only, all caps + + @Column(name = "child_caretaker", length = 50) + private String childCaretaker; // Alphabets only, all caps + + @Column(name = "community_support", length = 100) + private String communitySupport; // Alphabets only, all caps + + @Column(name = "transportation_mode", length = 100) + private String transportationMode; // Mode of transport + + @Column(name = "is_synced") + private Boolean isSynced; + + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java new file mode 100644 index 00000000..8deca44d --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import lombok.Data; + +import java.util.List; +@Data +public class MicroBirthPlanDTO { + Integer userId; + List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java new file mode 100644 index 00000000..cffcc0d8 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java @@ -0,0 +1,11 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface MicroBirthPlanRepository extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java new file mode 100644 index 00000000..5e0bb3e3 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java @@ -0,0 +1,22 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; +import com.iemr.flw.repo.iemr.MicroBirthPlanRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public interface MicroBirthPlanService { + public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan); + public List getAllMicroBirthPlans(); + public Optional getMicroBirthPlanById(Long id) ; + + + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java new file mode 100644 index 00000000..affcd797 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -0,0 +1,68 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.MicroBirthPlan; +import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; +import com.iemr.flw.repo.iemr.MicroBirthPlanRepository; +import com.iemr.flw.service.MicroBirthPlanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Optional; + +@Service +public class MicroBirthPlanServiceImpl implements MicroBirthPlanService { + @Autowired + private MicroBirthPlanRepository repository; + + + @Override + public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan) { + MicroBirthPlan microBirthPlan = new MicroBirthPlan(); + for(int i =0 ;i< birthPlan.getEntries().size();i++){ + microBirthPlan = birthPlan.getEntries().get(i); + microBirthPlan.setUserId(birthPlan.getUserId()); + } + return repository.save(microBirthPlan); + } + + @Override + public List getAllMicroBirthPlans() { + return repository.findAll(); + } + + @Override + public Optional getMicroBirthPlanById(Long id) { + return Optional.empty(); + } + + + + + public MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan) { + return repository.findById(id).map(existingPlan -> { + existingPlan.setPwName(updatedPlan.getPwName()); + existingPlan.setAge(updatedPlan.getAge()); + existingPlan.setContactNo1(updatedPlan.getContactNo1()); + existingPlan.setContactNo2(updatedPlan.getContactNo2()); + existingPlan.setScHwcTgHosp(updatedPlan.getScHwcTgHosp()); + existingPlan.setBlock(updatedPlan.getBlock()); + existingPlan.setHusbandName(updatedPlan.getHusbandName()); + existingPlan.setNearestScHwc(updatedPlan.getNearestScHwc()); + existingPlan.setNearestPhc(updatedPlan.getNearestPhc()); + existingPlan.setNearestFru(updatedPlan.getNearestFru()); + existingPlan.setNearestUsg(updatedPlan.getNearestUsg()); + existingPlan.setBloodGroup(updatedPlan.getBloodGroup()); + existingPlan.setBloodDonors(updatedPlan.getBloodDonors()); + existingPlan.setBirthCompanion(updatedPlan.getBirthCompanion()); + existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); + existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); + existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); + return repository.save(existingPlan); + }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); + } + + public void deleteMicroBirthPlan(Long id) { + repository.deleteById(id); + } +} \ No newline at end of file From 9e76db2b938ff2463f3d8bcae7d98755591f667c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 24 Feb 2025 14:55:48 +0530 Subject: [PATCH 009/792] Micro BirthPlan --- .../controller/MicroBirthPlanController.java | 7 +++--- .../repo/iemr/MicroBirthPlanRepository.java | 2 +- .../flw/service/MicroBirthPlanService.java | 4 +-- .../impl/MicroBirthPlanServiceImpl.java | 25 ++++++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 6d528e52..8aa75541 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -5,6 +5,7 @@ import com.iemr.flw.service.MicroBirthPlanService; import io.swagger.v3.oas.annotations.Operation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.query.Param; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -25,12 +26,12 @@ public ResponseEntity createMicroBirthPlan(@RequestBody MicroBir @RequestMapping(value = "getAll",method = RequestMethod.GET) - public ResponseEntity> getAllMicroBirthPlans() { - return ResponseEntity.ok(service.getAllMicroBirthPlans()); + public ResponseEntity> getAllMicroBirthPlans(@Param("userId")Integer userId) { + return ResponseEntity.ok(service.getAllMicroBirthPlans(userId)); } @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) - public ResponseEntity getMicroBirthPlanById(@PathVariable Long id) { + public ResponseEntity getMicroBirthPlanById(@PathVariable Integer id) { return service.getMicroBirthPlanById(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java index cffcc0d8..27e90ca0 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java @@ -7,5 +7,5 @@ import java.util.List; @Repository -public interface MicroBirthPlanRepository extends JpaRepository { +public interface MicroBirthPlanRepository extends JpaRepository { } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java index 5e0bb3e3..5df29fdb 100644 --- a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java +++ b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java @@ -13,8 +13,8 @@ @Service public interface MicroBirthPlanService { public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan); - public List getAllMicroBirthPlans(); - public Optional getMicroBirthPlanById(Long id) ; + public List getAllMicroBirthPlans(Integer userId); + public Optional getMicroBirthPlanById(Integer id) ; diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index affcd797..5c22d85d 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -7,13 +7,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; @Service public class MicroBirthPlanServiceImpl implements MicroBirthPlanService { @Autowired - private MicroBirthPlanRepository repository; + private MicroBirthPlanRepository microBirthPlanRepository; @Override @@ -23,24 +26,22 @@ public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan) { microBirthPlan = birthPlan.getEntries().get(i); microBirthPlan.setUserId(birthPlan.getUserId()); } - return repository.save(microBirthPlan); + return microBirthPlanRepository.save(microBirthPlan); } @Override - public List getAllMicroBirthPlans() { - return repository.findAll(); + public List getAllMicroBirthPlans(Integer userId) { + return microBirthPlanRepository.findAll().stream().filter(microBirthPlan -> Objects.equals(microBirthPlan.getUserId(), userId)).collect(Collectors.toList()); } @Override - public Optional getMicroBirthPlanById(Long id) { + public Optional getMicroBirthPlanById(Integer id) { return Optional.empty(); } - - - public MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan) { - return repository.findById(id).map(existingPlan -> { + public MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedPlan) { + return microBirthPlanRepository.findById(id).map(existingPlan -> { existingPlan.setPwName(updatedPlan.getPwName()); existingPlan.setAge(updatedPlan.getAge()); existingPlan.setContactNo1(updatedPlan.getContactNo1()); @@ -58,11 +59,11 @@ public MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan) existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); - return repository.save(existingPlan); + return microBirthPlanRepository.save(existingPlan); }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); } - public void deleteMicroBirthPlan(Long id) { - repository.deleteById(id); + public void deleteMicroBirthPlan(Integer id) { + microBirthPlanRepository.deleteById(id); } } \ No newline at end of file From ddf10b8b3b6fdc8954d02293254c4c723b56d9c0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 24 Feb 2025 16:15:34 +0530 Subject: [PATCH 010/792] Micro BirthPlan --- .../controller/MicroBirthPlanController.java | 9 ++++-- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 2 +- .../iemr/flw/dto/iemr/EligibleCoupleDTO.java | 3 ++ .../impl/MicroBirthPlanServiceImpl.java | 28 +++++++++++++++---- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 8aa75541..28b861d0 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -9,7 +9,9 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.HashMap; import java.util.List; +import java.util.Map; @RestController @RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json") @@ -26,8 +28,11 @@ public ResponseEntity createMicroBirthPlan(@RequestBody MicroBir @RequestMapping(value = "getAll",method = RequestMethod.GET) - public ResponseEntity> getAllMicroBirthPlans(@Param("userId")Integer userId) { - return ResponseEntity.ok(service.getAllMicroBirthPlans(userId)); + public ResponseEntity> getAllMicroBirthPlans(@Param("userId")Integer userId) { + Map response = new HashMap<>(); + response.put("entries",service.getMicroBirthPlanById(userId)); + + return ResponseEntity.ok(response); } @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index ecbcbe9b..abbd866e 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -10,7 +10,7 @@ public class MicroBirthPlan { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; + private Integer id; @Column(name = "user_id") private Integer UserId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index e51bbb70..7798e954 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -105,4 +105,7 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp updatedDate; private String updatedBy; + + private Timestamp lmp_Date; + } diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index 5c22d85d..a0e06319 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -21,14 +21,26 @@ public class MicroBirthPlanServiceImpl implements MicroBirthPlanService { @Override public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan) { - MicroBirthPlan microBirthPlan = new MicroBirthPlan(); - for(int i =0 ;i< birthPlan.getEntries().size();i++){ - microBirthPlan = birthPlan.getEntries().get(i); - microBirthPlan.setUserId(birthPlan.getUserId()); + MicroBirthPlan microBirthPlan = null; + + for (MicroBirthPlan entry : birthPlan.getEntries()) { + // Check if the entry already exists in the database + Optional existingEntry = microBirthPlanRepository.findById(entry.getId()); + + if (existingEntry.isPresent()) { + updateMicroBirthPlan(entry.getId(),microBirthPlan); + continue; + } + + // Set user ID and prepare for saving + entry.setUserId(birthPlan.getUserId()); + microBirthPlan = microBirthPlanRepository.save(entry); } - return microBirthPlanRepository.save(microBirthPlan); + + return microBirthPlan; } + @Override public List getAllMicroBirthPlans(Integer userId) { return microBirthPlanRepository.findAll().stream().filter(microBirthPlan -> Objects.equals(microBirthPlan.getUserId(), userId)).collect(Collectors.toList()); @@ -40,7 +52,9 @@ public Optional getMicroBirthPlanById(Integer id) { } - public MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedPlan) { + + + private MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedPlan){ return microBirthPlanRepository.findById(id).map(existingPlan -> { existingPlan.setPwName(updatedPlan.getPwName()); existingPlan.setAge(updatedPlan.getAge()); @@ -59,6 +73,8 @@ public MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedPla existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); + existingPlan.setIsSynced(true); + existingPlan.setBenId(updatedPlan.getBenId()); return microBirthPlanRepository.save(existingPlan); }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); } From ce8674a2e6817841b58628d327e4efcbec5cd7da Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 25 Feb 2025 10:28:53 +0530 Subject: [PATCH 011/792] Fix code asha profile --- .../flw/controller/AshaProfileController.java | 26 ++++--- .../iemr/flw/repo/iemr/AshaProfileRepo.java | 1 - .../iemr/flw/service/AshaProfileService.java | 2 +- .../flw/service/impl/AshaProfileImpl.java | 68 +++++++++---------- 4 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index 5c6479a7..ead9f303 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -19,7 +19,7 @@ import java.util.Objects; @RestController -@RequestMapping(value = "/employee", headers = "Authorization", produces = "application/json") +@RequestMapping(value = "/asha", headers = "Authorization", produces = "application/json") public class AshaProfileController { private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); @Autowired @@ -29,7 +29,7 @@ public class AshaProfileController { @Autowired private EmployeeMasterInter employeeMasterInter; @CrossOrigin() - @Operation(summary = "Edit employee") + @Operation(summary = "Edit Asha Profile") @RequestMapping(value = "editProfile", method = { RequestMethod.POST }, produces = { @@ -40,8 +40,8 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e System.out.println(editEmployee.toString()); - AshaWorker editdata1 = ashaProfileService.saveEditData(editEmployee); - response.put("data",editdata1); + AshaWorker ashaWorker = ashaProfileService.saveEditData(editEmployee); + response.put("data",ashaWorker); response.put("statusCode",200); response.put("status","Success"); response.put("errorMessage","Success"); @@ -60,13 +60,21 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e } @Operation(summary = "Profile Detail") @RequestMapping(value = "getProfile",method = RequestMethod.GET) - public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer userId){ + public ResponseEntity> 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"); + } - response.put("data",ashaProfileService.getProfileData(userId)); - 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()); diff --git a/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java index 9d67cda4..c7ed26c7 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java @@ -5,7 +5,6 @@ import org.springframework.stereotype.Repository; @Repository public interface AshaProfileRepo extends JpaRepository { - AshaWorker findByEmployeeId(Integer employeeId); } diff --git a/src/main/java/com/iemr/flw/service/AshaProfileService.java b/src/main/java/com/iemr/flw/service/AshaProfileService.java index 3255ad10..c5761090 100644 --- a/src/main/java/com/iemr/flw/service/AshaProfileService.java +++ b/src/main/java/com/iemr/flw/service/AshaProfileService.java @@ -5,7 +5,7 @@ @Service public interface AshaProfileService { - AshaWorker saveEditData(AshaWorker editdata); + AshaWorker saveEditData(AshaWorker ashaWorkerRequest); AshaWorker getProfileData(Integer employeeId); } diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index ab5437a6..0673cc42 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -22,18 +22,18 @@ public class AshaProfileImpl implements AshaProfileService { private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); @Override - public AshaWorker saveEditData(AshaWorker ashaWorker) { - AshaWorker ashaWorker1; - if (ashaWorker.getId() != null) { - ashaWorker1 = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorker)); + public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { + AshaWorker ashaWorker; + if (ashaWorkerRequest.getId() != null) { + ashaWorker = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorkerRequest)); } else { - ashaWorker1 = ashaProfileRepo.saveAndFlush(ashaWorker); + ashaWorker = ashaProfileRepo.saveAndFlush(ashaWorkerRequest); } - System.out.println("ashaWorker->>>" + ashaWorker1.toString()); + System.out.println("ashaWorker->>>" + ashaWorker.toString()); - return ashaWorker1; + return ashaWorker; } @@ -63,35 +63,35 @@ private AshaWorker getDetails(Integer userID) { } - private AshaWorker updateProfile(AshaWorker editEmployee) { - System.out.println(editEmployee.toString()); + private AshaWorker updateProfile(AshaWorker editAshaWorkerRequest) { + System.out.println(editAshaWorkerRequest.toString()); AshaWorker editdata = new AshaWorker(); - editdata.setId(editEmployee.getId()); - editdata.setAbhaNumber(editEmployee.getAbhaNumber()); - editdata.setEmployeeId(editEmployee.getEmployeeId()); - editdata.setDob(editEmployee.getDob()); - editdata.setAlternateMobileNumber(editEmployee.getAlternateMobileNumber()); - editdata.setAnm1Mobile(editEmployee.getAnm1Mobile()); - editdata.setAnm2Name(editEmployee.getAnm2Name()); - editdata.setIfsc(editEmployee.getIfsc()); - editdata.setAwwName(editEmployee.getAwwName()); - editdata.setName(editEmployee.getName()); - editdata.setVillage(editEmployee.getVillage()); - editdata.setBankAccount(editEmployee.getBankAccount()); - editdata.setChoName(editEmployee.getChoName()); - editdata.setChoMobile(editEmployee.getChoMobile()); - editdata.setAbhaNumber(editEmployee.getAbhaNumber()); - editdata.setAshaFamilyMember(editEmployee.getAshaFamilyMember()); - editdata.setDateOfJoining(editEmployee.getDateOfJoining()); - editdata.setMobileNumber(editEmployee.getMobileNumber()); - editdata.setAshaHouseholdRegistration(editEmployee.getAshaHouseholdRegistration()); - editdata.setFatherOrSpouseName(editEmployee.getFatherOrSpouseName()); - editdata.setPopulationCovered(editEmployee.getPopulationCovered()); - editdata.setAnm1Name(editEmployee.getAnm1Name()); - editdata.setAnm2Mobile(editEmployee.getAnm2Mobile()); // Corrected line - editdata.setAwwMobile(editEmployee.getAwwMobile()); - editdata.setProviderServiceMapID(editEmployee.getProviderServiceMapID()); + editdata.setId(editAshaWorkerRequest.getId()); + editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); + editdata.setEmployeeId(editAshaWorkerRequest.getEmployeeId()); + editdata.setDob(editAshaWorkerRequest.getDob()); + editdata.setAlternateMobileNumber(editAshaWorkerRequest.getAlternateMobileNumber()); + editdata.setAnm1Mobile(editAshaWorkerRequest.getAnm1Mobile()); + editdata.setAnm2Name(editAshaWorkerRequest.getAnm2Name()); + editdata.setIfsc(editAshaWorkerRequest.getIfsc()); + editdata.setAwwName(editAshaWorkerRequest.getAwwName()); + editdata.setName(editAshaWorkerRequest.getName()); + editdata.setVillage(editAshaWorkerRequest.getVillage()); + editdata.setBankAccount(editAshaWorkerRequest.getBankAccount()); + editdata.setChoName(editAshaWorkerRequest.getChoName()); + editdata.setChoMobile(editAshaWorkerRequest.getChoMobile()); + editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); + editdata.setAshaFamilyMember(editAshaWorkerRequest.getAshaFamilyMember()); + editdata.setDateOfJoining(editAshaWorkerRequest.getDateOfJoining()); + editdata.setMobileNumber(editAshaWorkerRequest.getMobileNumber()); + editdata.setAshaHouseholdRegistration(editAshaWorkerRequest.getAshaHouseholdRegistration()); + editdata.setFatherOrSpouseName(editAshaWorkerRequest.getFatherOrSpouseName()); + editdata.setPopulationCovered(editAshaWorkerRequest.getPopulationCovered()); + editdata.setAnm1Name(editAshaWorkerRequest.getAnm1Name()); + editdata.setAnm2Mobile(editAshaWorkerRequest.getAnm2Mobile()); // Corrected line + editdata.setAwwMobile(editAshaWorkerRequest.getAwwMobile()); + editdata.setProviderServiceMapID(editAshaWorkerRequest.getProviderServiceMapID()); return editdata; From b6a23522076ea28b96e83e2b63cfd1c3cc411cf2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Feb 2025 09:40:10 +0530 Subject: [PATCH 012/792] Asha profile file path in anc visit --- .../java/com/iemr/flw/controller/AshaProfileController.java | 2 +- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index ead9f303..eb8dafff 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -59,7 +59,7 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e } @Operation(summary = "Profile Detail") - @RequestMapping(value = "getProfile",method = RequestMethod.GET) + @RequestMapping(value = "getProfile",method = RequestMethod.GET ,headers = "Authorization" ) public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer employeeId){ try { AshaWorker ashaWorker = ashaProfileService.getProfileData(employeeId); diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 9aeb8878..19e2e562 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -112,4 +112,7 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "file_path") + private String filePath; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 54e48fca..0cd07846 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -43,6 +43,7 @@ public class ANCVisitDTO { private Timestamp updatedDate; private String updatedBy; private Integer providerServiceMapID; + private String filePath; } From ad5c00ebc3f2ec637b697e2f5d19e0a75840a496 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Feb 2025 09:43:19 +0530 Subject: [PATCH 013/792] Asha profile file path in anc visit --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 19e2e562..4207e27d 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -115,4 +115,5 @@ public class ANCVisit { @Column(name = "file_path") private String filePath; + } From a7531722bcee72f18ce0933c573598943074cb9c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Feb 2025 16:56:52 +0530 Subject: [PATCH 014/792] birth cert upload --- .../flw/domain/identity/RMNCHBornBirthDetails.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHBornBirthDetails.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHBornBirthDetails.java index 27925716..6b5d4c3a 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHBornBirthDetails.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHBornBirthDetails.java @@ -314,4 +314,16 @@ public class RMNCHBornBirthDetails { @Column(name = "birthOPV") private Boolean birthOPV; + @Expose + @Column(name = "birthCertificateFileFrontView") + private String birthCertificateFileFrontView; + + @Expose + @Column(name = "birthCertificateFileBackView") + private String birthCertificateFileBackView; + + + + + } From 5b2464aa2370d68305a627b86e64db3c7d1fbd5f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Feb 2025 11:03:05 +0530 Subject: [PATCH 015/792] Micro birth plan --- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index abbd866e..bfcc98ed 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -25,13 +25,13 @@ public class MicroBirthPlan { private Integer age; // Auto-populated @Column(name = "contact_no_1", length = 10) - private String contactNo1; // Auto-filled, must be 10 digits, starts with 6-9 + private String contactNumber1; // Auto-filled, must be 10 digits, starts with 6-9 @Column(name = "contact_no_2", length = 10) - private String contactNo2; // Optional, 10 digits, starts with 6-9 + private String contactNumber2; // Optional, 10 digits, starts with 6-9 @Column(name = "sc_hwc_tg_hosp", length = 100) - private String scHwcTgHosp; // Alphanumeric, all caps + private String scHosp; // Alphanumeric, all caps @Column(name = "block", length = 100) private String block; // Alphanumeric, all caps @@ -40,7 +40,7 @@ public class MicroBirthPlan { private String husbandName; // Auto-populated @Column(name = "nearest_sc_hwc", length = 100) - private String nearestScHwc; // Alphanumeric, all caps + private String nearestSc; // Alphanumeric, all caps @Column(name = "nearest_phc", length = 100) private String nearestPhc; // Alphanumeric, all caps @@ -49,25 +49,28 @@ public class MicroBirthPlan { private String nearestFru; // Alphanumeric, all caps @Column(name = "nearest_usg", length = 100) - private String nearestUsg; // Alphanumeric, all caps + private String usg; // Alphanumeric, all caps @Column(name = "blood_group") private String bloodGroup; // Spinner: A+, B+, etc. @Column(name = "blood_donors", length = 50) - private String bloodDonors; // Alphabets only, all caps + private String bloodDonors2; // Alphabets only, all caps @Column(name = "birth_companion", length = 50) private String birthCompanion; // Alphabets only, all caps @Column(name = "child_caretaker", length = 50) - private String childCaretaker; // Alphabets only, all caps + private String careTaker; // Alphabets only, all caps @Column(name = "community_support", length = 100) - private String communitySupport; // Alphabets only, all caps + private String communityMember; // Alphabets only, all caps + + @Column(name = "community_support_contact", length = 100) + private String communityMemberContact; // Alphabets only, all caps @Column(name = "transportation_mode", length = 100) - private String transportationMode; // Mode of transport + private String modeOfTransportation; // Mode of transport @Column(name = "is_synced") private Boolean isSynced; From e961c0be90ef74f9af10d60b849b80fac6b6bd19 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Feb 2025 11:06:35 +0530 Subject: [PATCH 016/792] Micro birth plan --- .../java/com/iemr/flw/controller/MicroBirthPlanController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 28b861d0..421e4e66 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -27,6 +27,7 @@ public ResponseEntity createMicroBirthPlan(@RequestBody MicroBir } + @RequestMapping(value = "getAll",method = RequestMethod.GET) public ResponseEntity> getAllMicroBirthPlans(@Param("userId")Integer userId) { Map response = new HashMap<>(); From 53f31f28666fbfaffc487e8329f6604ba7d0e408 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Feb 2025 11:12:17 +0530 Subject: [PATCH 017/792] Micro birth plan --- .../impl/MicroBirthPlanServiceImpl.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index a0e06319..0759c840 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -58,21 +58,22 @@ private MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedP return microBirthPlanRepository.findById(id).map(existingPlan -> { existingPlan.setPwName(updatedPlan.getPwName()); existingPlan.setAge(updatedPlan.getAge()); - existingPlan.setContactNo1(updatedPlan.getContactNo1()); - existingPlan.setContactNo2(updatedPlan.getContactNo2()); - existingPlan.setScHwcTgHosp(updatedPlan.getScHwcTgHosp()); + existingPlan.setContactNumber1(updatedPlan.getContactNumber1()); + existingPlan.setContactNumber2(updatedPlan.getContactNumber2()); + existingPlan.setScHosp(updatedPlan.getScHosp()); existingPlan.setBlock(updatedPlan.getBlock()); existingPlan.setHusbandName(updatedPlan.getHusbandName()); - existingPlan.setNearestScHwc(updatedPlan.getNearestScHwc()); + existingPlan.setNearestSc(updatedPlan.getNearestSc()); existingPlan.setNearestPhc(updatedPlan.getNearestPhc()); existingPlan.setNearestFru(updatedPlan.getNearestFru()); - existingPlan.setNearestUsg(updatedPlan.getNearestUsg()); + existingPlan.setUsg(updatedPlan.getUsg()); existingPlan.setBloodGroup(updatedPlan.getBloodGroup()); - existingPlan.setBloodDonors(updatedPlan.getBloodDonors()); + existingPlan.setBloodDonors2(updatedPlan.getBloodDonors2()); existingPlan.setBirthCompanion(updatedPlan.getBirthCompanion()); - existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); - existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); - existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); + existingPlan.setCareTaker(updatedPlan.getCareTaker()); + existingPlan.setCommunityMember(updatedPlan.getCommunityMember()); + existingPlan.setCommunityMemberContact(updatedPlan.getCommunityMemberContact()); + existingPlan.setModeOfTransportation(updatedPlan.getModeOfTransportation()); existingPlan.setIsSynced(true); existingPlan.setBenId(updatedPlan.getBenId()); return microBirthPlanRepository.save(existingPlan); From b07ee5b071fcc3e37ee98c6520472069aa7d3e83 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Mar 2025 14:05:43 +0530 Subject: [PATCH 018/792] Micro birth plan --- .../controller/MicroBirthPlanController.java | 40 ++++++++++++++++--- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 13 +++--- .../repo/iemr/MicroBirthPlanRepository.java | 5 ++- .../flw/service/MicroBirthPlanService.java | 1 - .../impl/MicroBirthPlanServiceImpl.java | 19 +++------ 5 files changed, 49 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 421e4e66..9fb36d81 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -4,6 +4,8 @@ import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; import com.iemr.flw.service.MicroBirthPlanService; 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.data.repository.query.Param; import org.springframework.http.ResponseEntity; @@ -16,22 +18,48 @@ @RestController @RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json") public class MicroBirthPlanController { + private final Logger logger = LoggerFactory.getLogger(MicroBirthPlanController.class); + @Autowired private MicroBirthPlanService service; @CrossOrigin() @Operation(summary = "Micro BirthPlan") @RequestMapping(value = "saveAll",method = RequestMethod.POST) - public ResponseEntity createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { - return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan)); + public ResponseEntity> createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { + logger.info("Micro birth plan request "+birthPlan.toString()); + Map response = new HashMap<>(); + + + + Map data = new HashMap<>(); + data.put("userId", birthPlan.getUserId()); + data.put("entries", service.createMicroBirthPlan(birthPlan)); + + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); + + return ResponseEntity.ok(response); } - @RequestMapping(value = "getAll",method = RequestMethod.GET) - public ResponseEntity> getAllMicroBirthPlans(@Param("userId")Integer userId) { - Map response = new HashMap<>(); - response.put("entries",service.getMicroBirthPlanById(userId)); + @RequestMapping(value = "getAll", method = RequestMethod.GET) + public ResponseEntity> getAllMicroBirthPlans(@RequestParam("userId") Integer userId) { + + Map response = new HashMap<>(); + + + Map data = new HashMap<>(); + data.put("userId", userId); + data.put("entries", service.getAllMicroBirthPlans(userId)); + + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index bfcc98ed..c87097c0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -3,6 +3,8 @@ import jakarta.persistence.*; import lombok.Data; +import java.math.BigInteger; + @Entity @Table(name = "t_micro_birth_plan", schema = "db_iemr") @Data @@ -16,10 +18,9 @@ public class MicroBirthPlan { private Integer UserId; @Column(name = "ben_id") - private Integer benId; + private Long benId; + - @Column(name = "pw_name") - private String pwName; // Auto-populated @Column(name = "age") private Integer age; // Auto-populated @@ -36,8 +37,7 @@ public class MicroBirthPlan { @Column(name = "block", length = 100) private String block; // Alphanumeric, all caps - @Column(name = "husband_name") - private String husbandName; // Auto-populated + @Column(name = "nearest_sc_hwc", length = 100) private String nearestSc; // Alphanumeric, all caps @@ -72,8 +72,7 @@ public class MicroBirthPlan { @Column(name = "transportation_mode", length = 100) private String modeOfTransportation; // Mode of transport - @Column(name = "is_synced") - private Boolean isSynced; + diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java index 27e90ca0..5b5c2ceb 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java @@ -5,7 +5,10 @@ import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; @Repository -public interface MicroBirthPlanRepository extends JpaRepository { +public interface MicroBirthPlanRepository extends JpaRepository { + Optional findByBenId(Long benId); + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java index 5df29fdb..abaa8864 100644 --- a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java +++ b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java @@ -14,7 +14,6 @@ public interface MicroBirthPlanService { public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan); public List getAllMicroBirthPlans(Integer userId); - public Optional getMicroBirthPlanById(Integer id) ; diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index 0759c840..549948ec 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -25,10 +25,10 @@ public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan) { for (MicroBirthPlan entry : birthPlan.getEntries()) { // Check if the entry already exists in the database - Optional existingEntry = microBirthPlanRepository.findById(entry.getId()); + Optional existingEntry = microBirthPlanRepository.findByBenId(entry.getBenId()); if (existingEntry.isPresent()) { - updateMicroBirthPlan(entry.getId(),microBirthPlan); + updateMicroBirthPlan(entry.getBenId(),entry); continue; } @@ -46,23 +46,17 @@ public List getAllMicroBirthPlans(Integer userId) { return microBirthPlanRepository.findAll().stream().filter(microBirthPlan -> Objects.equals(microBirthPlan.getUserId(), userId)).collect(Collectors.toList()); } - @Override - public Optional getMicroBirthPlanById(Integer id) { - return Optional.empty(); - } - private MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedPlan){ - return microBirthPlanRepository.findById(id).map(existingPlan -> { - existingPlan.setPwName(updatedPlan.getPwName()); + private MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan){ + return microBirthPlanRepository.findByBenId(id).map(existingPlan -> { existingPlan.setAge(updatedPlan.getAge()); existingPlan.setContactNumber1(updatedPlan.getContactNumber1()); existingPlan.setContactNumber2(updatedPlan.getContactNumber2()); existingPlan.setScHosp(updatedPlan.getScHosp()); existingPlan.setBlock(updatedPlan.getBlock()); - existingPlan.setHusbandName(updatedPlan.getHusbandName()); existingPlan.setNearestSc(updatedPlan.getNearestSc()); existingPlan.setNearestPhc(updatedPlan.getNearestPhc()); existingPlan.setNearestFru(updatedPlan.getNearestFru()); @@ -74,13 +68,10 @@ private MicroBirthPlan updateMicroBirthPlan(Integer id, MicroBirthPlan updatedP existingPlan.setCommunityMember(updatedPlan.getCommunityMember()); existingPlan.setCommunityMemberContact(updatedPlan.getCommunityMemberContact()); existingPlan.setModeOfTransportation(updatedPlan.getModeOfTransportation()); - existingPlan.setIsSynced(true); existingPlan.setBenId(updatedPlan.getBenId()); return microBirthPlanRepository.save(existingPlan); }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); } - public void deleteMicroBirthPlan(Integer id) { - microBirthPlanRepository.deleteById(id); - } + } \ No newline at end of file From 37ff8b2125b793a1311066845f79ec759ceafcd8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Mar 2025 14:07:23 +0530 Subject: [PATCH 019/792] Micro birth plan --- .../com/iemr/flw/controller/MicroBirthPlanController.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 9fb36d81..30bddcdf 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -64,12 +64,7 @@ public ResponseEntity> getAllMicroBirthPlans(@RequestParam(" return ResponseEntity.ok(response); } - @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) - public ResponseEntity getMicroBirthPlanById(@PathVariable Integer id) { - return service.getMicroBirthPlanById(id) - .map(ResponseEntity::ok) - .orElse(ResponseEntity.notFound().build()); - } + } \ No newline at end of file From 401eab8125e51f47b6a9d7efb8d60d3b70dff66c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Mar 2025 14:17:42 +0530 Subject: [PATCH 020/792] Micro birth plan --- .../java/com/iemr/flw/domain/iemr/MicroBirthPlan.java | 8 -------- .../iemr/flw/service/impl/MicroBirthPlanServiceImpl.java | 1 - 2 files changed, 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index c87097c0..2203f4bb 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -21,10 +21,6 @@ public class MicroBirthPlan { private Long benId; - - @Column(name = "age") - private Integer age; // Auto-populated - @Column(name = "contact_no_1", length = 10) private String contactNumber1; // Auto-filled, must be 10 digits, starts with 6-9 @@ -38,7 +34,6 @@ public class MicroBirthPlan { private String block; // Alphanumeric, all caps - @Column(name = "nearest_sc_hwc", length = 100) private String nearestSc; // Alphanumeric, all caps @@ -73,7 +68,4 @@ public class MicroBirthPlan { private String modeOfTransportation; // Mode of transport - - - } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index 549948ec..6b20b01b 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -52,7 +52,6 @@ public List getAllMicroBirthPlans(Integer userId) { private MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan){ return microBirthPlanRepository.findByBenId(id).map(existingPlan -> { - existingPlan.setAge(updatedPlan.getAge()); existingPlan.setContactNumber1(updatedPlan.getContactNumber1()); existingPlan.setContactNumber2(updatedPlan.getContactNumber2()); existingPlan.setScHosp(updatedPlan.getScHosp()); From b298c94d5c0cfa500f5f3ded7b1ff66d744f238a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 4 Mar 2025 17:14:59 +0530 Subject: [PATCH 021/792] Enhancement --- .../controller/MicroBirthPlanController.java | 51 +++++++++++-------- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 1 - 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 30bddcdf..28bbdb15 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -16,36 +16,42 @@ import java.util.Map; @RestController -@RequestMapping(value = "/micro-birthPlan",headers = "Authorization", produces = "application/json") +@RequestMapping(value = "/micro-birthPlan", headers = "Authorization", produces = "application/json") public class MicroBirthPlanController { private final Logger logger = LoggerFactory.getLogger(MicroBirthPlanController.class); @Autowired - private MicroBirthPlanService service; + private MicroBirthPlanService service; + @CrossOrigin() @Operation(summary = "Micro BirthPlan") - @RequestMapping(value = "saveAll",method = RequestMethod.POST) + @RequestMapping(value = "saveAll", method = RequestMethod.POST) public ResponseEntity> createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { - logger.info("Micro birth plan request "+birthPlan.toString()); + logger.info("Micro birth plan request " + birthPlan.toString()); Map response = new HashMap<>(); + Map data = new HashMap<>(); + try { + data.put("userId", birthPlan.getUserId()); + data.put("entries", service.createMicroBirthPlan(birthPlan)); + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); + } catch (Exception e) { + response.put("statusCode", 500); + response.put("errorMessage", e.getMessage()); - Map data = new HashMap<>(); - data.put("userId", birthPlan.getUserId()); - data.put("entries", service.createMicroBirthPlan(birthPlan)); - response.put("data", data); - response.put("statusCode", 200); - response.put("errorMessage", "Success"); - response.put("status", "Success"); + } + return ResponseEntity.ok(response); } - @RequestMapping(value = "getAll", method = RequestMethod.GET) public ResponseEntity> getAllMicroBirthPlans(@RequestParam("userId") Integer userId) { @@ -53,18 +59,23 @@ public ResponseEntity> getAllMicroBirthPlans(@RequestParam(" Map data = new HashMap<>(); - data.put("userId", userId); - data.put("entries", service.getAllMicroBirthPlans(userId)); + try { + data.put("userId", userId); + data.put("entries", service.getAllMicroBirthPlans(userId)); + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); + } catch (Exception e) { + response.put("statusCode", 500); + response.put("errorMessage", e.getMessage()); - response.put("data", data); - response.put("statusCode", 200); - response.put("errorMessage", "Success"); - response.put("status", "Success"); - return ResponseEntity.ok(response); - } + } + return ResponseEntity.ok(response); + } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index 2203f4bb..cc237eb6 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -20,7 +20,6 @@ public class MicroBirthPlan { @Column(name = "ben_id") private Long benId; - @Column(name = "contact_no_1", length = 10) private String contactNumber1; // Auto-filled, must be 10 digits, starts with 6-9 From d564a36a749df5709a71bff2d4c002d4c863ebfb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 12:24:04 +0530 Subject: [PATCH 022/792] Enhancement --- .../iemr/flw/controller/MicroBirthPlanController.java | 3 --- .../java/com/iemr/flw/domain/iemr/MicroBirthPlan.java | 2 +- .../java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java | 2 +- .../iemr/flw/repo/iemr/MicroBirthPlanRepository.java | 1 + .../com/iemr/flw/service/MicroBirthPlanService.java | 1 - .../flw/service/impl/MicroBirthPlanServiceImpl.java | 11 ++++++----- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 28bbdb15..b33f1b0d 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -23,8 +23,6 @@ public class MicroBirthPlanController { @Autowired private MicroBirthPlanService service; - @CrossOrigin() - @Operation(summary = "Micro BirthPlan") @RequestMapping(value = "saveAll", method = RequestMethod.POST) public ResponseEntity> createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { @@ -35,7 +33,6 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic try { data.put("userId", birthPlan.getUserId()); data.put("entries", service.createMicroBirthPlan(birthPlan)); - response.put("data", data); response.put("statusCode", 200); response.put("errorMessage", "Success"); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index cc237eb6..a7a3717f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -15,7 +15,7 @@ public class MicroBirthPlan { private Integer id; @Column(name = "user_id") - private Integer UserId; + private Integer userId; @Column(name = "ben_id") private Long benId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java index 8deca44d..68c3df7c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java @@ -5,7 +5,7 @@ import java.util.List; @Data -public class MicroBirthPlanDTO { +public class MicroBirthPlanDTO { Integer userId; List entries; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java index 5b5c2ceb..0cec1fba 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java @@ -11,4 +11,5 @@ public interface MicroBirthPlanRepository extends JpaRepository { Optional findByBenId(Long benId); + List findByUserId(Integer userId); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java index abaa8864..9a6e422b 100644 --- a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java +++ b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Optional; -@Service public interface MicroBirthPlanService { public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan); public List getAllMicroBirthPlans(Integer userId); diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index 6b20b01b..42e3be9a 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -21,29 +21,30 @@ public class MicroBirthPlanServiceImpl implements MicroBirthPlanService { @Override public MicroBirthPlan createMicroBirthPlan(MicroBirthPlanDTO birthPlan) { - MicroBirthPlan microBirthPlan = null; + MicroBirthPlan lastProcessedPlan = new MicroBirthPlan(); for (MicroBirthPlan entry : birthPlan.getEntries()) { // Check if the entry already exists in the database Optional existingEntry = microBirthPlanRepository.findByBenId(entry.getBenId()); if (existingEntry.isPresent()) { - updateMicroBirthPlan(entry.getBenId(),entry); + lastProcessedPlan= updateMicroBirthPlan(entry.getBenId(),entry); continue; } // Set user ID and prepare for saving entry.setUserId(birthPlan.getUserId()); - microBirthPlan = microBirthPlanRepository.save(entry); + lastProcessedPlan = microBirthPlanRepository.save(entry); } - return microBirthPlan; + return lastProcessedPlan; } @Override public List getAllMicroBirthPlans(Integer userId) { - return microBirthPlanRepository.findAll().stream().filter(microBirthPlan -> Objects.equals(microBirthPlan.getUserId(), userId)).collect(Collectors.toList()); + return microBirthPlanRepository.findByUserId(userId); + } From 1715b2194ca903873eb7b4cf7fd268fbb596db07 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 12:31:27 +0530 Subject: [PATCH 023/792] Enhancement --- .../java/com/iemr/flw/controller/AshaProfileController.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index eb8dafff..e6541e02 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -28,9 +28,6 @@ public class AshaProfileController { @Autowired private EmployeeMasterInter employeeMasterInter; - @CrossOrigin() - @Operation(summary = "Edit Asha Profile") - @RequestMapping(value = "editProfile", method = { RequestMethod.POST }, produces = { "application/json" },consumes = "application/json" ) @@ -58,7 +55,6 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e return ResponseEntity.ok().body(response); } - @Operation(summary = "Profile Detail") @RequestMapping(value = "getProfile",method = RequestMethod.GET ,headers = "Authorization" ) public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer employeeId){ try { From 14f96a9c76898b8dbd3477311806b9990c3d861d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 12:37:49 +0530 Subject: [PATCH 024/792] Enhancement --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 3 +-- .../java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java | 2 -- src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index d5db1b4b..771cdad1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -158,8 +158,7 @@ public class EligibleCoupleRegister { @Column(name = "updated_by") private String updatedBy; - @Column(name = "lmp_date") - private Timestamp lmpDate; + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java index 729fa36a..aee3a01b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java @@ -50,6 +50,4 @@ public class EligibleCoupleTracking { @Column(name = "updated_by") private String updatedBy; - @Column(name = "lmp_date") - private Timestamp lmpDate; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index 43b5ff4c..4a633982 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -106,6 +106,5 @@ public class EligibleCoupleDTO implements Serializable { private String updatedBy; - private Timestamp lmpDate; } From 2e485937f3d1fff2564803e75ab2be116182f844 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 12:40:54 +0530 Subject: [PATCH 025/792] Add lmp date in eligible couple module --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 3 +++ .../java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 2 ++ .../java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java | 3 +++ 4 files changed, 11 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index abe8313a..eb8b0f8b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -157,4 +157,7 @@ public class EligibleCoupleRegister { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "lmp_date") + private String lmpDate; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java index 2cde9438..33e5df22 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java @@ -49,4 +49,7 @@ public class EligibleCoupleTracking { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "lmp_date") + private String lmpDate; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index e51bbb70..3ace1ab7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -105,4 +105,6 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp updatedDate; private String updatedBy; + + private String lmpDate; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java index 4eddee57..4631d79b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java @@ -33,4 +33,7 @@ public class EligibleCoupleTrackingDTO implements Serializable { private Timestamp updatedDate; private String updatedBy; + + private String lmpDate; + } From 428cfb7fedbc4457b4fef5b75de00a628e03c574 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 17:06:27 +0530 Subject: [PATCH 026/792] Disease control module --- .../controller/DiseaseControlController.java | 33 +++++++++ .../iemr/flw/domain/iemr/DiseaseControl.java | 71 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseControlDTO.java | 35 +++++++++ .../flw/repo/iemr/DiseaseControlRepo.java | 12 ++++ .../flw/service/DiseaseControlService.java | 9 +++ .../impl/DiseaseControlServiceImpl.java | 59 +++++++++++++++ 6 files changed, 219 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/DiseaseControlController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java create mode 100644 src/main/java/com/iemr/flw/service/DiseaseControlService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java new file mode 100644 index 00000000..de8e88b1 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -0,0 +1,33 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.DiseaseControlDTO; +import com.iemr.flw.service.DiseaseControlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +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.RestController; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping(value = "/disease", headers = "Authorization", consumes = "application/json", produces = "application/json") +public class DiseaseControlController { + @Autowired + private DiseaseControlService diseaseControlService; + + @RequestMapping(value = "save", method = RequestMethod.POST) + public ResponseEntity> saveDiseaseData(@RequestBody DiseaseControlDTO diseaseControlDTO) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.save(diseaseControlDTO)); + diseaseControlService.save(diseaseControlDTO); + + return ResponseEntity.ok(response); + } + + +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java new file mode 100644 index 00000000..dc6aa992 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java @@ -0,0 +1,71 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; +@Data +@Entity +@Table(name = "disease") +public class DiseaseControl { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "case_date", nullable = false) + private Timestamp caseDate ; // Auto-populated as today's date, non-editable + + @Enumerated(EnumType.STRING) + @Column(name = "case_status", nullable = false) + private Integer caseStatus; // Dropdown for case status + + @ElementCollection + @CollectionTable(name = "malaria_symptoms", joinColumns = @JoinColumn(name = "case_id")) + @Column(name = "symptom") + private List symptoms; // List of symptoms + + @Column(name = "malaria_case_count", nullable = false) + private int malariaCaseCount; // Auto-updated based on confirmed/treatment cases + + @Enumerated(EnumType.STRING) + @Column(name = "referred_to", nullable = false) + private Integer referredTo; // Dropdown for referral options + + @Column(name = "other_referred_to") + private String otherReferredTo; // Required if "Referred To" = "Other" + + @Column(name = "malaria_case_status_date") + private Timestamp malariaCaseStatusDate; // Auto-populated when status is updated + + @Column(name = "remarks") + private String remarks; // Optional field for additional notes + + @Column(name = "follow_up_point") + private Integer followUpPoint; // Single-select radio button (1-6) + + @Column(name = "follow_up_date") + private Timestamp followUpDate; // Follow-up date + + // Enums for case status and referral options + public enum CaseStatus { + SUSPECTED, + CONFIRMED, + NOT_CONFIRMED, + TREATMENT_GIVEN + } + + public enum ReferredTo { + PRIMARY_HEALTH_CENTRE, + COMMUNITY_HEALTH_CENTRE, + DISTRICT_HOSPITAL, + MEDICAL_COLLEGE_AND_HOSPITAL, + REFERRAL_HOSPITAL, + OTHER_PRIVATE_HOSPITAL, + OTHER, + NONE + } +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java new file mode 100644 index 00000000..3bb6fe38 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -0,0 +1,35 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Timestamp; +import java.util.List; + +@Data +public class DiseaseControlDTO { + private Integer id; + private Long benId; + private Timestamp caseDate; + + private Integer caseStatus; + + private List symptoms; + + private int malariaCaseCount; + + private Integer referredTo; + + private String otherReferredTo; + + private Timestamp malariaCaseStatusDate; + + private String remarks; + + private Integer followUpPoint; + + private Timestamp followUpDate; + + + +} + diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java new file mode 100644 index 00000000..75aa8130 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java @@ -0,0 +1,12 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseControl; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DiseaseControlRepo extends JpaRepository { + Optional findByBenId(Long benId); +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java new file mode 100644 index 00000000..3f34aa0a --- /dev/null +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -0,0 +1,9 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.DiseaseControl; +import com.iemr.flw.dto.iemr.DiseaseControlDTO; +import org.apache.commons.collections4.Put; + +public interface DiseaseControlService { + public DiseaseControl save(DiseaseControlDTO diseaseControlDTO); +} diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java new file mode 100644 index 00000000..cf8588e9 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -0,0 +1,59 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.DiseaseControl; +import com.iemr.flw.dto.iemr.DiseaseControlDTO; +import com.iemr.flw.repo.iemr.DiseaseControlRepo; +import com.iemr.flw.service.DiseaseControlService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class DiseaseControlServiceImpl implements DiseaseControlService { + @Autowired + private DiseaseControlRepo diseaseControlRepo; + + @Override + public DiseaseControl save(DiseaseControlDTO diseaseControlDTO) { + if(diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).isPresent()){ + return update(diseaseControlDTO); + }else { + return diseaseControlRepo.save(saveData(diseaseControlDTO)); + + } + } + + private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ + DiseaseControl diseaseControl = new DiseaseControl(); + diseaseControl.setBenId(diseaseControlDTO.getBenId()); + diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added + diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); + diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); + diseaseControl.setMalariaCaseCount(diseaseControlDTO.getMalariaCaseCount()); + diseaseControl.setReferredTo(diseaseControlDTO.getReferredTo()); // Added + diseaseControl.setOtherReferredTo(diseaseControlDTO.getOtherReferredTo()); + diseaseControl.setMalariaCaseStatusDate(diseaseControlDTO.getMalariaCaseStatusDate()); // Added + diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); + diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); + diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + return diseaseControlRepo.save(diseaseControl); + + } + private DiseaseControl update(DiseaseControlDTO diseaseControlDTO){ + return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { + diseaseControl.setBenId(diseaseControlDTO.getBenId()); + diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added + diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); + diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); + diseaseControl.setMalariaCaseCount(diseaseControlDTO.getMalariaCaseCount()); + diseaseControl.setReferredTo(diseaseControlDTO.getReferredTo()); // Added + diseaseControl.setOtherReferredTo(diseaseControlDTO.getOtherReferredTo()); + diseaseControl.setMalariaCaseStatusDate(diseaseControlDTO.getMalariaCaseStatusDate()); // Added + diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); + diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); + diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + return diseaseControlRepo.save(diseaseControl); + + }).orElseThrow(()->new RuntimeException("Data not found")); + + } +} From 703b57d36c20963ad115d1672800ea1afa879390 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 17:18:15 +0530 Subject: [PATCH 027/792] Disease control module --- .../iemr/flw/domain/iemr/DiseaseControl.java | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java index dc6aa992..9c863da5 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java @@ -19,19 +19,16 @@ public class DiseaseControl { @Column(name = "case_date", nullable = false) private Timestamp caseDate ; // Auto-populated as today's date, non-editable - @Enumerated(EnumType.STRING) @Column(name = "case_status", nullable = false) private Integer caseStatus; // Dropdown for case status - @ElementCollection - @CollectionTable(name = "malaria_symptoms", joinColumns = @JoinColumn(name = "case_id")) + @Column(name = "symptom") - private List symptoms; // List of symptoms + private String symptoms; // List of symptoms @Column(name = "malaria_case_count", nullable = false) private int malariaCaseCount; // Auto-updated based on confirmed/treatment cases - @Enumerated(EnumType.STRING) @Column(name = "referred_to", nullable = false) private Integer referredTo; // Dropdown for referral options @@ -50,22 +47,5 @@ public class DiseaseControl { @Column(name = "follow_up_date") private Timestamp followUpDate; // Follow-up date - // Enums for case status and referral options - public enum CaseStatus { - SUSPECTED, - CONFIRMED, - NOT_CONFIRMED, - TREATMENT_GIVEN - } - - public enum ReferredTo { - PRIMARY_HEALTH_CENTRE, - COMMUNITY_HEALTH_CENTRE, - DISTRICT_HOSPITAL, - MEDICAL_COLLEGE_AND_HOSPITAL, - REFERRAL_HOSPITAL, - OTHER_PRIVATE_HOSPITAL, - OTHER, - NONE - } + } From 760f7f4dd836e131e119a0dfd5d000e331523809 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 17:20:33 +0530 Subject: [PATCH 028/792] Disease control module --- src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java index 3bb6fe38..2f02f50c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -13,7 +13,7 @@ public class DiseaseControlDTO { private Integer caseStatus; - private List symptoms; + private String symptoms; private int malariaCaseCount; From 351c2ed4c295d7c196a9b7758409b1902a867e44 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 17:45:58 +0530 Subject: [PATCH 029/792] Disease control module --- .../controller/DiseaseControlController.java | 3 ++- .../flw/service/DiseaseControlService.java | 4 ++- .../impl/DiseaseControlServiceImpl.java | 26 ++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index de8e88b1..69070fc9 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; +import java.util.List; import java.util.Map; @RestController @@ -19,7 +20,7 @@ public class DiseaseControlController { private DiseaseControlService diseaseControlService; @RequestMapping(value = "save", method = RequestMethod.POST) - public ResponseEntity> saveDiseaseData(@RequestBody DiseaseControlDTO diseaseControlDTO) { + public ResponseEntity> saveDiseaseData(@RequestBody List diseaseControlDTO) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 3f34aa0a..9c1f2487 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -4,6 +4,8 @@ import com.iemr.flw.dto.iemr.DiseaseControlDTO; import org.apache.commons.collections4.Put; +import java.util.List; + public interface DiseaseControlService { - public DiseaseControl save(DiseaseControlDTO diseaseControlDTO); + public String save(List diseaseControlDTO); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index cf8588e9..422227f5 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -7,22 +7,30 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; + @Service public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private DiseaseControlRepo diseaseControlRepo; @Override - public DiseaseControl save(DiseaseControlDTO diseaseControlDTO) { - if(diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).isPresent()){ - return update(diseaseControlDTO); - }else { - return diseaseControlRepo.save(saveData(diseaseControlDTO)); + public String save(List diseaseControlDTO) { + for(DiseaseControlDTO diseaseControlData: diseaseControlDTO){ + if(diseaseControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()){ + return update(diseaseControlData); + }else { + diseaseControlRepo.save(saveData(diseaseControlData)); + return "Data add successfully"; + } } + return "Fail"; + + } - private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ + private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ DiseaseControl diseaseControl = new DiseaseControl(); diseaseControl.setBenId(diseaseControlDTO.getBenId()); diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added @@ -35,10 +43,10 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); - return diseaseControlRepo.save(diseaseControl); + return diseaseControl; } - private DiseaseControl update(DiseaseControlDTO diseaseControlDTO){ + private String update(DiseaseControlDTO diseaseControlDTO){ return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { diseaseControl.setBenId(diseaseControlDTO.getBenId()); diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added @@ -51,7 +59,7 @@ private DiseaseControl update(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); - return diseaseControlRepo.save(diseaseControl); + return "Data update successfully"; }).orElseThrow(()->new RuntimeException("Data not found")); From 66366a5247060bed482110b8024d7020355a8ea7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Mar 2025 18:21:27 +0530 Subject: [PATCH 030/792] Disease control module --- .../flw/controller/DiseaseControlController.java | 13 +++++++++++-- .../com/iemr/flw/service/DiseaseControlService.java | 1 + .../flw/service/impl/DiseaseControlServiceImpl.java | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 69070fc9..c06f0875 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -14,12 +14,12 @@ import java.util.Map; @RestController -@RequestMapping(value = "/disease", headers = "Authorization", consumes = "application/json", produces = "application/json") +@RequestMapping(value = "/disease", consumes = "application/json", produces = "application/json") public class DiseaseControlController { @Autowired private DiseaseControlService diseaseControlService; - @RequestMapping(value = "save", method = RequestMethod.POST) + @RequestMapping(value = "saveAll", method = RequestMethod.POST) public ResponseEntity> saveDiseaseData(@RequestBody List diseaseControlDTO) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -30,5 +30,14 @@ public ResponseEntity> saveDiseaseData(@RequestBody List> getAllData(){ + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.getAll()); + return ResponseEntity.ok(response); + } + } diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 9c1f2487..3b692efe 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -8,4 +8,5 @@ public interface DiseaseControlService { public String save(List diseaseControlDTO); + public List getAll(); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 422227f5..f8d7a45b 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -30,6 +30,11 @@ public String save(List diseaseControlDTO) { } + @Override + public List getAll() { + return diseaseControlRepo.findAll(); + } + private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ DiseaseControl diseaseControl = new DiseaseControl(); diseaseControl.setBenId(diseaseControlDTO.getBenId()); @@ -48,7 +53,6 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ } private String update(DiseaseControlDTO diseaseControlDTO){ return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { - diseaseControl.setBenId(diseaseControlDTO.getBenId()); diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); @@ -59,6 +63,8 @@ private String update(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + diseaseControlRepo.save(diseaseControl); + return "Data update successfully"; }).orElseThrow(()->new RuntimeException("Data not found")); From 54752b38ef14320e5ecf0754d55e9f23032582ea Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 9 Mar 2025 10:11:57 +0530 Subject: [PATCH 031/792] Disease control module --- .../controller/DiseaseControlController.java | 6 +++--- .../iemr/flw/domain/iemr/DiseaseControl.java | 21 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseControlDTO.java | 14 ++++++++++++- .../impl/DiseaseControlServiceImpl.java | 15 +++++++++++++ 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index c06f0875..badaecd9 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -14,12 +14,12 @@ import java.util.Map; @RestController -@RequestMapping(value = "/disease", consumes = "application/json", produces = "application/json") +@RequestMapping(value = "/disease" ,headers = "Authorization") public class DiseaseControlController { @Autowired private DiseaseControlService diseaseControlService; - @RequestMapping(value = "saveAll", method = RequestMethod.POST) + @RequestMapping(value = "saveAll", method = RequestMethod.POST,consumes = "application/json",produces = "application/json") public ResponseEntity> saveDiseaseData(@RequestBody List diseaseControlDTO) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -30,7 +30,7 @@ public ResponseEntity> saveDiseaseData(@RequestBody List> getAllData(){ Map response = new HashMap<>(); response.put("status", "Success"); diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java index 9c863da5..0e96221c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java @@ -47,5 +47,26 @@ public class DiseaseControl { @Column(name = "follow_up_date") private Timestamp followUpDate; // Follow-up date + @Column(name = "status") + private String status; + + @Column(name = "other_status") + private String otherStatus; + + @Column(name = "body_part") + private String bodyPart; + + @Column(name = "suffering_from_filariasis") + private Boolean sufferingFromFilariasis; + + @Column(name = "home_visit_date") + private Timestamp homeVisitDate; + + @Column(name = "leprosy_status_date") + private Timestamp LeprosyStatusDate; + + @Column(name = "medicine_side_effect") + private String MedicineSideEffect; + } diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java index 2f02f50c..1d0d01a4 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -3,7 +3,6 @@ import lombok.Data; import java.sql.Timestamp; -import java.util.List; @Data public class DiseaseControlDTO { @@ -29,6 +28,19 @@ public class DiseaseControlDTO { private Timestamp followUpDate; + private String status; + + private String otherStatus; + + private String body_part; + + private Boolean sufferingFromFilariasis; + + private Timestamp homeVisitDate; + + private Timestamp LeprosyStatusDate; + + private String MedicineSideEffect; } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index f8d7a45b..cb8a6630 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -48,6 +48,13 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + diseaseControl.setStatus(diseaseControlDTO.getStatus()); + diseaseControl.setBodyPart(diseaseControlDTO.getBody_part()); + diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); + diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); + diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); + diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); + diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); return diseaseControl; } @@ -63,6 +70,14 @@ private String update(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); + diseaseControl.setStatus(diseaseControlDTO.getStatus()); + diseaseControl.setBodyPart(diseaseControlDTO.getBody_part()); + diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); + diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); + diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); + diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); + diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); diseaseControlRepo.save(diseaseControl); return "Data update successfully"; From c17d9d8ec8d5213dfd52e44a157a45ac650af9a7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 9 Mar 2025 10:14:01 +0530 Subject: [PATCH 032/792] Disease control module --- src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java | 2 +- .../com/iemr/flw/service/impl/DiseaseControlServiceImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java index 1d0d01a4..4d82215a 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -32,7 +32,7 @@ public class DiseaseControlDTO { private String otherStatus; - private String body_part; + private String bodyPart; private Boolean sufferingFromFilariasis; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index cb8a6630..7dfa46ef 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -49,7 +49,7 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); diseaseControl.setStatus(diseaseControlDTO.getStatus()); - diseaseControl.setBodyPart(diseaseControlDTO.getBody_part()); + diseaseControl.setBodyPart(diseaseControlDTO.getBodyPart()); diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); @@ -72,7 +72,7 @@ private String update(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); diseaseControl.setStatus(diseaseControlDTO.getStatus()); - diseaseControl.setBodyPart(diseaseControlDTO.getBody_part()); + diseaseControl.setBodyPart(diseaseControlDTO.getBodyPart()); diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); From 79f5670581c8225676d6806a572608cfdb49ff46 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 13:04:47 +0530 Subject: [PATCH 033/792] Disease control module --- .../com/iemr/flw/domain/iemr/DiseaseControl.java | 15 ++++++++++----- .../com/iemr/flw/dto/iemr/DiseaseControlDTO.java | 5 ++++- .../service/impl/DiseaseControlServiceImpl.java | 2 ++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java index 0e96221c..73d4479f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java @@ -3,8 +3,10 @@ import jakarta.persistence.*; import lombok.Data; +import java.math.BigInteger; import java.sql.Timestamp; import java.util.List; + @Data @Entity @Table(name = "disease") @@ -17,10 +19,10 @@ public class DiseaseControl { private Long benId; @Column(name = "case_date", nullable = false) - private Timestamp caseDate ; // Auto-populated as today's date, non-editable + private Timestamp caseDate; // Auto-populated as today's date, non-editable @Column(name = "case_status", nullable = false) - private Integer caseStatus; // Dropdown for case status + private String caseStatus; // Dropdown for case status @Column(name = "symptom") @@ -29,7 +31,7 @@ public class DiseaseControl { @Column(name = "malaria_case_count", nullable = false) private int malariaCaseCount; // Auto-updated based on confirmed/treatment cases - @Column(name = "referred_to", nullable = false) + @Column(name = "InstitutionID", nullable = false) private Integer referredTo; // Dropdown for referral options @Column(name = "other_referred_to") @@ -48,7 +50,7 @@ public class DiseaseControl { private Timestamp followUpDate; // Follow-up date @Column(name = "status") - private String status; + private String status; @Column(name = "other_status") private String otherStatus; @@ -66,7 +68,10 @@ public class DiseaseControl { private Timestamp LeprosyStatusDate; @Column(name = "medicine_side_effect") - private String MedicineSideEffect; + private String MedicineSideEffect; + + @Column(name = "typeId") + private BigInteger diseaseTypeId; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java index 4d82215a..c8d9367d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -2,6 +2,7 @@ import lombok.Data; +import java.math.BigInteger; import java.sql.Timestamp; @Data @@ -10,7 +11,7 @@ public class DiseaseControlDTO { private Long benId; private Timestamp caseDate; - private Integer caseStatus; + private String caseStatus; private String symptoms; @@ -42,6 +43,8 @@ public class DiseaseControlDTO { private String MedicineSideEffect; + private BigInteger diseaseTypeId; + } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 7dfa46ef..8dceabf4 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -55,6 +55,7 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); + diseaseControl.setDiseaseTypeId(diseaseControlDTO.getDiseaseTypeId()); return diseaseControl; } @@ -78,6 +79,7 @@ private String update(DiseaseControlDTO diseaseControlDTO){ diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); + diseaseControl.setDiseaseTypeId(diseaseControlDTO.getDiseaseTypeId()); diseaseControlRepo.save(diseaseControl); return "Data update successfully"; From e231025815dc2d9005bb07aa60ae6cdb4e9144f6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 14:43:32 +0530 Subject: [PATCH 034/792] Disease control module --- .../BeneficiaryOTPGatewayController.java | 93 -------- .../controller/MicroBirthPlanController.java | 39 ---- .../iemr/flw/domain/iemr/MicroBirthPlan.java | 68 ------ .../iemr/flw/dto/iemr/OTPRequestParsor.java | 9 - .../com/iemr/flw/dto/iemr/OtpRequestDTO.java | 10 - .../repo/iemr/MicroBirthPlanRepository.java | 9 - .../repo/iemr/OtpBeneficiaryRepository.java | 11 - .../flw/service/MicroBirthPlanService.java | 55 ----- .../java/com/iemr/flw/service/OTPHandler.java | 15 -- .../service/impl/OTPHandlerServiceImpl.java | 210 ------------------ 10 files changed, 519 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java delete mode 100644 src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java delete mode 100644 src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java delete mode 100644 src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java delete mode 100644 src/main/java/com/iemr/flw/service/MicroBirthPlanService.java delete mode 100644 src/main/java/com/iemr/flw/service/OTPHandler.java delete mode 100644 src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java deleted file mode 100644 index 1ab99845..00000000 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryOTPGatewayController.java +++ /dev/null @@ -1,93 +0,0 @@ -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(); - } - - @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 = "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(); - } - -} diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java deleted file mode 100644 index 34103942..00000000 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ /dev/null @@ -1,39 +0,0 @@ -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") -public class MicroBirthPlanController { - @Autowired - private MicroBirthPlanService service; - @CrossOrigin() - @Operation(summary = "Micro BirthPlan") - - @RequestMapping(value = "save",method = RequestMethod.POST) - public ResponseEntity createMicroBirthPlan(@RequestBody MicroBirthPlan birthPlan) { - return ResponseEntity.ok(service.createMicroBirthPlan(birthPlan)); - } - - - @RequestMapping(value = "downSync",method = RequestMethod.GET) - public ResponseEntity> getAllMicroBirthPlans() { - return ResponseEntity.ok(service.getAllMicroBirthPlans()); - } - - @RequestMapping(value = "getAllMicroBirthPlansBy{id}",method = RequestMethod.GET) - public ResponseEntity getMicroBirthPlanById(@PathVariable Long id) { - return service.getMicroBirthPlanById(id) - .map(ResponseEntity::ok) - .orElse(ResponseEntity.notFound().build()); - } - - -} diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java deleted file mode 100644 index 89f97f67..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -@Entity -@Table(name = "t_micro_birth_plan", schema = "db_iemr") -@Data -public class MicroBirthPlan { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "pw_name") - private String pwName; // Auto-populated - - @Column(name = "age") - private Integer age; // Auto-populated - - @Column(name = "contact_no_1", length = 10) - private String contactNo1; // Auto-filled, must be 10 digits, starts with 6-9 - - @Column(name = "contact_no_2", length = 10) - private String contactNo2; // Optional, 10 digits, starts with 6-9 - - @Column(name = "sc_hwc_tg_hosp", length = 100) - private String scHwcTgHosp; // Alphanumeric, all caps - - @Column(name = "block", length = 100) - private String block; // Alphanumeric, all caps - - @Column(name = "husband_name") - private String husbandName; // Auto-populated - - @Column(name = "nearest_sc_hwc", length = 100) - private String nearestScHwc; // Alphanumeric, all caps - - @Column(name = "nearest_phc", length = 100) - private String nearestPhc; // Alphanumeric, all caps - - @Column(name = "nearest_fru", length = 100) - private String nearestFru; // Alphanumeric, all caps - - @Column(name = "nearest_usg", length = 100) - private String nearestUsg; // Alphanumeric, all caps - - @Column(name = "blood_group") - private String bloodGroup; // Spinner: A+, B+, etc. - - @Column(name = "blood_donors", length = 50) - private String bloodDonors; // Alphabets only, all caps - - @Column(name = "birth_companion", length = 50) - private String birthCompanion; // Alphabets only, all caps - - @Column(name = "child_caretaker", length = 50) - private String childCaretaker; // Alphabets only, all caps - - @Column(name = "community_support", length = 100) - private String communitySupport; // Alphabets only, all caps - - @Column(name = "transportation_mode", length = 100) - private String transportationMode; // Mode of transport - - @Column(name = "is_synced") - private Boolean isSynced; -} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java b/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java deleted file mode 100644 index 91dc1d19..00000000 --- a/src/main/java/com/iemr/flw/dto/iemr/OTPRequestParsor.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iemr.flw.dto.iemr; - -import lombok.Data; - -@Data -public class OTPRequestParsor { - private String mobNo; - private int otp; -} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java deleted file mode 100644 index b9be9650..00000000 --- a/src/main/java/com/iemr/flw/dto/iemr/OtpRequestDTO.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.iemr.flw.dto.iemr; - -import lombok.Data; - -@Data -public class OtpRequestDTO { - private Long beneficiaryId; - private String phoneNumber; - private Integer otp; -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java deleted file mode 100644 index 489ddd7b..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/MicroBirthPlanRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.MicroBirthPlan; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface MicroBirthPlanRepository extends JpaRepository { -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java b/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java deleted file mode 100644 index bc223578..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/OtpBeneficiaryRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.OtpBeneficiary; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; -@Repository -public interface OtpBeneficiaryRepository extends JpaRepository { - Optional findByPhoneNumberAndOtp(String phoneNumber, Integer otp); -} diff --git a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java b/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java deleted file mode 100644 index c3b8d507..00000000 --- a/src/main/java/com/iemr/flw/service/MicroBirthPlanService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.iemr.flw.service; - -import com.iemr.flw.domain.iemr.MicroBirthPlan; -import com.iemr.flw.repo.iemr.MicroBirthPlanRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Optional; - -@Service -public class MicroBirthPlanService { - @Autowired - private MicroBirthPlanRepository repository; - - public MicroBirthPlan createMicroBirthPlan(MicroBirthPlan birthPlan) { - return repository.save(birthPlan); - } - - public List getAllMicroBirthPlans() { - return repository.findAll(); - } - - public Optional getMicroBirthPlanById(Long id) { - return repository.findById(id); - } - - public MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan) { - return repository.findById(id).map(existingPlan -> { - existingPlan.setPwName(updatedPlan.getPwName()); - existingPlan.setAge(updatedPlan.getAge()); - existingPlan.setContactNo1(updatedPlan.getContactNo1()); - existingPlan.setContactNo2(updatedPlan.getContactNo2()); - existingPlan.setScHwcTgHosp(updatedPlan.getScHwcTgHosp()); - existingPlan.setBlock(updatedPlan.getBlock()); - existingPlan.setHusbandName(updatedPlan.getHusbandName()); - existingPlan.setNearestScHwc(updatedPlan.getNearestScHwc()); - existingPlan.setNearestPhc(updatedPlan.getNearestPhc()); - existingPlan.setNearestFru(updatedPlan.getNearestFru()); - existingPlan.setNearestUsg(updatedPlan.getNearestUsg()); - existingPlan.setBloodGroup(updatedPlan.getBloodGroup()); - existingPlan.setBloodDonors(updatedPlan.getBloodDonors()); - existingPlan.setBirthCompanion(updatedPlan.getBirthCompanion()); - existingPlan.setChildCaretaker(updatedPlan.getChildCaretaker()); - existingPlan.setCommunitySupport(updatedPlan.getCommunitySupport()); - existingPlan.setTransportationMode(updatedPlan.getTransportationMode()); - return repository.save(existingPlan); - }).orElseThrow(() -> new RuntimeException("Micro Birth Plan not found")); - } - - public void deleteMicroBirthPlan(Long id) { - repository.deleteById(id); - } -} diff --git a/src/main/java/com/iemr/flw/service/OTPHandler.java b/src/main/java/com/iemr/flw/service/OTPHandler.java deleted file mode 100644 index 0ab17b5b..00000000 --- a/src/main/java/com/iemr/flw/service/OTPHandler.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.iemr.flw.service; - -import com.iemr.flw.dto.iemr.OTPRequestParsor; -import com.iemr.flw.dto.iemr.OtpRequestDTO; -import org.json.JSONObject; -import org.springframework.stereotype.Service; - -public interface OTPHandler { - public String sendOTP(String mobNo) throws Exception; - - public JSONObject validateOTP(OtpRequestDTO obj) throws Exception; - - public String resendOTP(String mobNo) throws Exception; - -} diff --git a/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java deleted file mode 100644 index ef311f01..00000000 --- a/src/main/java/com/iemr/flw/service/impl/OTPHandlerServiceImpl.java +++ /dev/null @@ -1,210 +0,0 @@ -package com.iemr.flw.service.impl; - -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; -import com.google.common.cache.LoadingCache; -import com.google.common.primitives.Ints; -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.repo.iemr.OtpBeneficiaryRepository; -import com.iemr.flw.service.OTPHandler; -import com.iemr.flw.utils.config.ConfigProperties; -import com.iemr.flw.utils.http.HttpUtils; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - -import java.security.MessageDigest; -import java.security.SecureRandom; -import java.sql.Timestamp; -import java.util.Optional; -import java.util.Random; -import java.util.concurrent.TimeUnit; - -@Service -public class OTPHandlerServiceImpl implements OTPHandler { - @Autowired - HttpUtils httpUtils; - @Autowired - OtpBeneficiaryRepository otpBeneficiaryRepository; - - - final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - - private LoadingCache otpCache; - - private static final Integer EXPIRE_MIN = 5; - - private static final String SMS_GATEWAY_URL = ConfigProperties.getPropertyByName("sms-gateway-url"); - - - // Constructor for new object creation - public OTPHandlerServiceImpl() { - otpCache = CacheBuilder.newBuilder().expireAfterWrite(EXPIRE_MIN, TimeUnit.MINUTES) - .build(new CacheLoader() { - public String load(String key) { - return "0"; - } - }); - } - - /*** - * @param - * @return success if OTP sent successfully - */ - @Override - public String sendOTP(String mobNo) throws Exception { - System.out.println("mobNo:"+mobNo); - int otp = generateOTP(mobNo); - saveOtp(mobNo,otp); - // sendSMS(otp, mobNo, "OTP is "); - return "success+\n"+otp; - } - - /*** - * @param obj - * @return OTP verification success or failure - * - */ - @Override - public JSONObject validateOTP(OtpRequestDTO obj) throws Exception { - String cachedOTP = otpCache.get(obj.getPhoneNumber()); - String inputOTPEncrypted = getEncryptedOTP(obj.getOtp()); - System.out.println(cachedOTP.toString() +" "+inputOTPEncrypted.toString()); - - if (cachedOTP.equalsIgnoreCase(inputOTPEncrypted)) { - JSONObject responseObj = new JSONObject(); - responseObj.put("userName", obj.getPhoneNumber()); - responseObj.put("userID", obj.getPhoneNumber()); - - verifyOtp(obj.getPhoneNumber(),obj.getOtp(),obj.getBeneficiaryId()); - return responseObj; - } else { - throw new Exception("Please enter valid OTP"); - } - - } - - /*** - * @param - * @return success if OTP re-sent successfully - */ - @Override - public String resendOTP(String mobNo) throws Exception { - int otp = generateOTP(mobNo); - // sendSMS(otp, mobNo, "OTP is "); - saveOtp(mobNo,otp); - return "success+\n"+otp; - } - public String verifyOtp(String phoneNumber, Integer otp,Long otpBeneficiaryId) { - Optional otpEntry = otpBeneficiaryRepository.findByPhoneNumberAndOtp(phoneNumber, otp); - - if (otpEntry.isPresent()) { - OtpBeneficiary otpBeneficiary = otpEntry.get(); - otpBeneficiary.setBeneficiaryId(otpBeneficiaryId); - otpBeneficiary.setIsOtpVerify(true); - otpBeneficiary.setIsExpired(true); - otpBeneficiaryRepository.save(otpBeneficiary); - return "OTP verified successfully."; - } else { - return "Invalid or expired OTP."; - } - } - - // generate 6 digit random no # - public int generateOTP(String authKey) throws Exception { - String generatedPassword = null; - -// Random random = new Random(); - Random random = SecureRandom.getInstanceStrong(); - int otp = 100000 + random.nextInt(900000); - - generatedPassword = getEncryptedOTP(otp); - - if (otpCache != null) - otpCache.put(authKey, generatedPassword); - else { - OTPHandlerServiceImpl obj = new OTPHandlerServiceImpl(); - obj.otpCache.put(authKey, generatedPassword); - } - return otp; - } - private void saveOtp(String phoneNo,Integer otp){ - OtpBeneficiary otpEntry = new OtpBeneficiary(); - otpEntry.setBeneficiaryId(null); - otpEntry.setPhoneNumber(phoneNo); - otpEntry.setOtp(otp); - otpEntry.setCreatedAt(new Timestamp(System.currentTimeMillis())); - - otpBeneficiaryRepository.save(otpEntry); - } - - // SHA-256 encoding logic implemented - private String getEncryptedOTP(int otp) throws Exception { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - byte[] bytes = md.digest(Ints.toByteArray(otp)); - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < bytes.length; i++) { - sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1)); - } - - return sb.toString(); - } - - // send SMS to user - private void sendSMS(int otp, String phoneNo, String msgText) throws Exception { - String sendSMSURL = ConfigProperties.getPropertyByName("send-message-url"); - String sendSMSAPI = SMS_GATEWAY_URL + "/" + sendSMSURL; - String senderName = ConfigProperties.getPropertyByName("sms-username"); - String senderPassword = ConfigProperties.getPropertyByName("sms-password"); - String senderNumber = ConfigProperties.getPropertyByName("sms-sender-number"); - System.out.println("OTP"+otp+"Phone"+phoneNo+"SMSURL"+sendSMSAPI+"sendName"+senderName+"senderPassword"+senderPassword+"senderNumber"+senderNumber); - - - sendSMSAPI = sendSMSAPI.replace("USERNAME", senderName).replace("PASSWORD", senderPassword) - .replace("SENDER_NUMBER", senderNumber); - - sendSMSAPI = sendSMSAPI - .replace("SMS_TEXT", - msgText.concat(String.valueOf(otp)) - .concat(" for Tele-consultation verification and validity is 5 mins")) - .replace("RECEIVER_NUMBER", phoneNo); - - ResponseEntity response = httpUtils.getV1(sendSMSAPI); - System.out.println("Otp Response"+response); - if (response.getStatusCodeValue() == 200) { - String smsResponse = response.getBody(); - // JSONObject obj = new JSONObject(smsResponse); - // String jobID = obj.getString("JobId"); - switch (smsResponse) { - case "0x200 - Invalid Username or Password": - case "0x201 - Account suspended due to one of several defined reasons": - case "0x202 - Invalid Source Address/Sender ID. As per GSM standard, the sender ID should " - + "be within 11 characters": - case "0x203 - Message length exceeded (more than 160 characters) if concat is set to 0": - case "0x204 - Message length exceeded (more than 459 characters) in concat is set to 1": - case "0x205 - DRL URL is not set": - case "0x206 - Only the subscribed service type can be accessed – " - + "make sure of the service type you are trying to connect with": - case "0x207 - Invalid Source IP – kindly check if the IP is responding": - case "0x208 - Account deactivated/expired": - case "0x209 - Invalid message length (less than 160 characters) if concat is set to 1": - case "0x210 - Invalid Parameter values": - case "0x211 - Invalid Message Length (more than 280 characters)": - case "0x212 - Invalid Message Length": - case "0x213 - Invalid Destination Number": - throw new Exception(smsResponse); - default: - logger.info("SMS Sent successfully by calling API " + sendSMSAPI); - logger.info("SMS Sent successfully sent to : " + phoneNo); - break; - } - } else { - throw new Exception(response.getStatusCodeValue() + " and error " + response.getStatusCode().toString()); - } - } -} From 777263d3340f1cb6ab228715f408b08c23bf3af2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 14:45:14 +0530 Subject: [PATCH 035/792] Work on asha update profile and get profile --- .../flw/controller/AshaProfileController.java | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index e6541e02..8d2f4cb5 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -24,26 +24,23 @@ public class AshaProfileController { private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); @Autowired AshaProfileService ashaProfileService; - private Map response = new HashMap<>(); + private Map response = new HashMap<>(); @Autowired private EmployeeMasterInter employeeMasterInter; - @RequestMapping(value = "editProfile", method = { RequestMethod.POST }, produces = { - "application/json" },consumes = "application/json" ) - public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee) { + @RequestMapping(value = "editProfile", method = {RequestMethod.POST}, produces = { + "application/json"}, consumes = "application/json") + public ResponseEntity> 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"); - - + response.put("data", ashaWorker); + response.put("statusCode", 200); + response.put("status", "Success"); + response.put("errorMessage", "Success"); } catch (Exception e) { @@ -55,29 +52,30 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker e return ResponseEntity.ok().body(response); } - @RequestMapping(value = "getProfile",method = RequestMethod.GET ,headers = "Authorization" ) - public ResponseEntity> getProfile(@RequestParam ("employeeId")Integer employeeId){ + + @RequestMapping(value = "getProfile", method = RequestMethod.GET, headers = "Authorization") + public ResponseEntity> 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"); + 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) { + } catch (Exception e) { logger.error("Unexpected error:", e); ResponseEntity.status(500).body(e.getMessage()); } - return ResponseEntity.ok().body(response); + return ResponseEntity.ok().body(response); } From 38da1dae307452cf58ba4157511ea2923cca84a8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 15:12:37 +0530 Subject: [PATCH 036/792] fix code issue in asha profile --- .../iemr/flw/repo/iemr/AshaProfileRepo.java | 5 +- .../flw/service/impl/AshaProfileImpl.java | 132 ++++++++++-------- 2 files changed, 81 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java index c7ed26c7..e93ed801 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AshaProfileRepo.java @@ -3,8 +3,11 @@ import com.iemr.flw.domain.iemr.AshaWorker; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; + +import java.util.Optional; + @Repository public interface AshaProfileRepo extends JpaRepository { - AshaWorker findByEmployeeId(Integer employeeId); + Optional findByEmployeeId(Integer employeeId); } diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 0673cc42..b3804c83 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -5,6 +5,7 @@ import com.iemr.flw.repo.iemr.AshaProfileRepo; import com.iemr.flw.service.AshaProfileService; import com.iemr.flw.service.EmployeeMasterInter; +import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,79 +22,100 @@ public class AshaProfileImpl implements AshaProfileService { private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); + @Transactional @Override public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { - AshaWorker ashaWorker; - if (ashaWorkerRequest.getId() != null) { - ashaWorker = ashaProfileRepo.saveAndFlush(updateProfile(ashaWorkerRequest)); - - } else { - ashaWorker = ashaProfileRepo.saveAndFlush(ashaWorkerRequest); - + try { + Objects.requireNonNull(ashaWorkerRequest, "ashaWorker must not be null"); + AshaWorker savedWorker = ashaWorkerRequest.getId() != null + ? ashaProfileRepo.saveAndFlush(updateProfile(ashaWorkerRequest)) + : ashaProfileRepo.saveAndFlush(ashaWorkerRequest); + logger.info("ASHA worker profile saved successfully: {}", savedWorker); + return savedWorker; + } catch (Exception e) { + logger.error("Error saving ASHA worker profile: {}", e.getMessage(), e); + throw new RuntimeException("Failed to save ASHA worker profile", e); } - System.out.println("ashaWorker->>>" + ashaWorker.toString()); - - return ashaWorker; - } @Override public AshaWorker getProfileData(Integer employeeId) { - if (ashaProfileRepo.findByEmployeeId(employeeId)!=null) { - return ashaProfileRepo.findByEmployeeId(employeeId); - } else { - return getDetails(employeeId); + + try { + Objects.requireNonNull(employeeId, "employeeId must not be null"); + return ashaProfileRepo.findByEmployeeId(employeeId) + .orElseGet(() -> getDetails(employeeId)); + } catch (Exception e) { + logger.error("Error retrieving ASHA worker profile for employeeId {}: {}", employeeId, e.getMessage(), e); + throw new RuntimeException("Failed to retrieve ASHA worker profile", e); } } private AshaWorker getDetails(Integer userID) { - AshaWorker ashaWorker = new AshaWorker(); - M_User m_user = employeeMasterInter.getUserDetails(userID); - - ashaWorker.setEmployeeId(m_user.getUserID()); - ashaWorker.setEmployeeId(m_user.getUserID()); - ashaWorker.setDob(m_user.getDOB()); - ashaWorker.setDateOfJoining(m_user.getDOJ()); - ashaWorker.setName(m_user.getFirstName() + " " + m_user.getLastName()); - ashaWorker.setMobileNumber(m_user.getContactNo()); - ashaWorker.setAlternateMobileNumber(m_user.getEmergencyContactNo()); - ashaWorker.setProviderServiceMapID(m_user.getServiceProviderID()); - return ashaWorker; + + try { + M_User m_user = Objects.requireNonNull( + employeeMasterInter.getUserDetails(userID), + "User details not found for ID: " + userID + ); + + AshaWorker ashaWorker = new AshaWorker(); + ashaWorker.setEmployeeId(m_user.getUserID()); + ashaWorker.setDob(m_user.getDOB()); + ashaWorker.setDateOfJoining(m_user.getDOJ()); + ashaWorker.setName(String.format("%s %s", + Objects.toString(m_user.getFirstName(), ""), + Objects.toString(m_user.getLastName(), "")).trim()); + ashaWorker.setMobileNumber(m_user.getContactNo()); + ashaWorker.setAlternateMobileNumber(m_user.getEmergencyContactNo()); + ashaWorker.setProviderServiceMapID(m_user.getServiceProviderID()); + return ashaWorker; + } catch (Exception e) { + logger.error("Error creating ASHA worker profile from user details for ID {}: {}", userID, e.getMessage(), e); + throw new RuntimeException("Failed to create ASHA worker profile from user details", e); + } } private AshaWorker updateProfile(AshaWorker editAshaWorkerRequest) { System.out.println(editAshaWorkerRequest.toString()); + try { + Objects.requireNonNull(editAshaWorkerRequest, "editEmployee must not be null"); + logger.debug("Updating ASHA worker profile: {}", editAshaWorkerRequest); + AshaWorker editdata = new AshaWorker(); + editdata.setId(editAshaWorkerRequest.getId()); + editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); + editdata.setEmployeeId(editAshaWorkerRequest.getEmployeeId()); + editdata.setDob(editAshaWorkerRequest.getDob()); + editdata.setAlternateMobileNumber(editAshaWorkerRequest.getAlternateMobileNumber()); + editdata.setAnm1Mobile(editAshaWorkerRequest.getAnm1Mobile()); + editdata.setAnm2Name(editAshaWorkerRequest.getAnm2Name()); + editdata.setIfsc(editAshaWorkerRequest.getIfsc()); + editdata.setAwwName(editAshaWorkerRequest.getAwwName()); + editdata.setName(editAshaWorkerRequest.getName()); + editdata.setVillage(editAshaWorkerRequest.getVillage()); + editdata.setBankAccount(editAshaWorkerRequest.getBankAccount()); + editdata.setChoName(editAshaWorkerRequest.getChoName()); + editdata.setChoMobile(editAshaWorkerRequest.getChoMobile()); + editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); + editdata.setAshaFamilyMember(editAshaWorkerRequest.getAshaFamilyMember()); + editdata.setDateOfJoining(editAshaWorkerRequest.getDateOfJoining()); + editdata.setMobileNumber(editAshaWorkerRequest.getMobileNumber()); + editdata.setAshaHouseholdRegistration(editAshaWorkerRequest.getAshaHouseholdRegistration()); + editdata.setFatherOrSpouseName(editAshaWorkerRequest.getFatherOrSpouseName()); + editdata.setPopulationCovered(editAshaWorkerRequest.getPopulationCovered()); + editdata.setAnm1Name(editAshaWorkerRequest.getAnm1Name()); + editdata.setAnm2Mobile(editAshaWorkerRequest.getAnm2Mobile()); // Corrected line + editdata.setAwwMobile(editAshaWorkerRequest.getAwwMobile()); + editdata.setProviderServiceMapID(editAshaWorkerRequest.getProviderServiceMapID()); + return editdata; + + } catch (Exception e) { + logger.error("Error creating updated ASHA worker profile: {}", e.getMessage(), e); + throw new RuntimeException("Failed to create updated ASHA worker profile", e); - AshaWorker editdata = new AshaWorker(); - editdata.setId(editAshaWorkerRequest.getId()); - editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); - editdata.setEmployeeId(editAshaWorkerRequest.getEmployeeId()); - editdata.setDob(editAshaWorkerRequest.getDob()); - editdata.setAlternateMobileNumber(editAshaWorkerRequest.getAlternateMobileNumber()); - editdata.setAnm1Mobile(editAshaWorkerRequest.getAnm1Mobile()); - editdata.setAnm2Name(editAshaWorkerRequest.getAnm2Name()); - editdata.setIfsc(editAshaWorkerRequest.getIfsc()); - editdata.setAwwName(editAshaWorkerRequest.getAwwName()); - editdata.setName(editAshaWorkerRequest.getName()); - editdata.setVillage(editAshaWorkerRequest.getVillage()); - editdata.setBankAccount(editAshaWorkerRequest.getBankAccount()); - editdata.setChoName(editAshaWorkerRequest.getChoName()); - editdata.setChoMobile(editAshaWorkerRequest.getChoMobile()); - editdata.setAbhaNumber(editAshaWorkerRequest.getAbhaNumber()); - editdata.setAshaFamilyMember(editAshaWorkerRequest.getAshaFamilyMember()); - editdata.setDateOfJoining(editAshaWorkerRequest.getDateOfJoining()); - editdata.setMobileNumber(editAshaWorkerRequest.getMobileNumber()); - editdata.setAshaHouseholdRegistration(editAshaWorkerRequest.getAshaHouseholdRegistration()); - editdata.setFatherOrSpouseName(editAshaWorkerRequest.getFatherOrSpouseName()); - editdata.setPopulationCovered(editAshaWorkerRequest.getPopulationCovered()); - editdata.setAnm1Name(editAshaWorkerRequest.getAnm1Name()); - editdata.setAnm2Mobile(editAshaWorkerRequest.getAnm2Mobile()); // Corrected line - editdata.setAwwMobile(editAshaWorkerRequest.getAwwMobile()); - editdata.setProviderServiceMapID(editAshaWorkerRequest.getProviderServiceMapID()); - - return editdata; + } } From 047fa0135147447cc26b85ba1f9481a975336904 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 15:17:37 +0530 Subject: [PATCH 037/792] fix code issue in asha profile --- src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java index 68c3df7c..8ab54673 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java @@ -3,9 +3,10 @@ import com.iemr.flw.domain.iemr.MicroBirthPlan; import lombok.Data; +import java.io.Serializable; import java.util.List; @Data -public class MicroBirthPlanDTO { +public class MicroBirthPlanDTO implements Serializable { Integer userId; List entries; } \ No newline at end of file From 86d6e7b33b6047bb3351c556097e57d1547828f5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 15:17:58 +0530 Subject: [PATCH 038/792] fix code --- src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java index a7a3717f..9b145899 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MicroBirthPlan.java @@ -9,7 +9,6 @@ @Table(name = "t_micro_birth_plan", schema = "db_iemr") @Data public class MicroBirthPlan { - @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; From 14efdf97b90dda31c8009cddf33ce001890f4591 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Mar 2025 15:49:03 +0530 Subject: [PATCH 039/792] fix code --- .../iemr/flw/dto/iemr/MicroBirthPlanDTO.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java index 8ab54673..bce35321 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java @@ -9,4 +9,25 @@ public class MicroBirthPlanDTO implements Serializable { Integer userId; List entries; + + @Data + public static class Entry implements Serializable { + private Integer id; + private Long benId; + private String contactNumber1; + private String contactNumber2; + private String scHosp; + private String block; + private String nearestSc; + private String nearestPhc; + private String nearestFru; + private String usg; + private String bloodGroup; + private String bloodDonors2; + private String birthCompanion; + private String careTaker; + private String communityMember; + private String communityMemberContact; + private String modeOfTransportation; + } } \ No newline at end of file From bda193946fa08ea4d39b3b014c8160f825edff14 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 13:14:30 +0530 Subject: [PATCH 040/792] fix code --- .../java/com/iemr/flw/controller/AshaProfileController.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index 8d2f4cb5..fcf82853 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -21,7 +21,7 @@ @RestController @RequestMapping(value = "/asha", headers = "Authorization", produces = "application/json") public class AshaProfileController { - private Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); @Autowired AshaProfileService ashaProfileService; private Map response = new HashMap<>(); @@ -40,8 +40,6 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker response.put("data", ashaWorker); response.put("statusCode", 200); response.put("status", "Success"); - response.put("errorMessage", "Success"); - } catch (Exception e) { logger.error("Unexpected error:", e); @@ -61,7 +59,6 @@ public ResponseEntity> getProfile(@RequestParam("employeeId" 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); From 287b4705c540de951ca91e923f00561f2fda7e73 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 14:20:24 +0530 Subject: [PATCH 041/792] Asha profile edit and get api --- src/main/java/com/iemr/flw/controller/AshaProfileController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index fcf82853..ae08ef3b 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -76,4 +76,5 @@ public ResponseEntity> getProfile(@RequestParam("employeeId" } + } From c079b11c390c472cac27ef77e42e9fcbfd0db326 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 15:44:14 +0530 Subject: [PATCH 042/792] Micro birth plan --- .../flw/controller/MicroBirthPlanController.java | 12 +++++------- .../com/iemr/flw/dto/iemr/GetMicroPlanHandler.java | 8 ++++++++ 2 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/GetMicroPlanHandler.java diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index b33f1b0d..505b1e02 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -1,6 +1,7 @@ package com.iemr.flw.controller; import com.iemr.flw.domain.iemr.MicroBirthPlan; +import com.iemr.flw.dto.iemr.GetMicroPlanHandler; import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; import com.iemr.flw.service.MicroBirthPlanService; import io.swagger.v3.oas.annotations.Operation; @@ -35,7 +36,6 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic data.put("entries", service.createMicroBirthPlan(birthPlan)); response.put("data", data); response.put("statusCode", 200); - response.put("errorMessage", "Success"); response.put("status", "Success"); } catch (Exception e) { response.put("statusCode", 500); @@ -49,19 +49,18 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic } - @RequestMapping(value = "getAll", method = RequestMethod.GET) - public ResponseEntity> getAllMicroBirthPlans(@RequestParam("userId") Integer userId) { + @RequestMapping(value = "getAll", method = RequestMethod.POST) + public ResponseEntity> getAllMicroBirthPlans(@RequestBody GetMicroPlanHandler getMicroPlanHandler, @RequestHeader(value = "Authorization") String Authorization) { Map response = new HashMap<>(); Map data = new HashMap<>(); try { - data.put("userId", userId); - data.put("entries", service.getAllMicroBirthPlans(userId)); + data.put("userId", getMicroPlanHandler.getUserId()); + data.put("entries", service.getAllMicroBirthPlans(getMicroPlanHandler.getUserId())); response.put("data", data); response.put("statusCode", 200); - response.put("errorMessage", "Success"); response.put("status", "Success"); } catch (Exception e) { response.put("statusCode", 500); @@ -70,7 +69,6 @@ public ResponseEntity> getAllMicroBirthPlans(@RequestParam(" } - return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetMicroPlanHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetMicroPlanHandler.java new file mode 100644 index 00000000..93d8ef0e --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/GetMicroPlanHandler.java @@ -0,0 +1,8 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class GetMicroPlanHandler { + private Integer userId; +} From aa67f4bee6002afc3a4a1ffe6fb1950685a32a78 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 15:49:55 +0530 Subject: [PATCH 043/792] Micro birth plan --- .../iemr/flw/dto/iemr/MicroBirthPlanDTO.java | 21 +------------------ 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java index bce35321..882cee35 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MicroBirthPlanDTO.java @@ -10,24 +10,5 @@ public class MicroBirthPlanDTO implements Serializable { Integer userId; List entries; - @Data - public static class Entry implements Serializable { - private Integer id; - private Long benId; - private String contactNumber1; - private String contactNumber2; - private String scHosp; - private String block; - private String nearestSc; - private String nearestPhc; - private String nearestFru; - private String usg; - private String bloodGroup; - private String bloodDonors2; - private String birthCompanion; - private String careTaker; - private String communityMember; - private String communityMemberContact; - private String modeOfTransportation; - } + } \ No newline at end of file From 0add4f4b3f960f6a7732ed080021eeb68005bc28 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 16:20:44 +0530 Subject: [PATCH 044/792] fix asha profile issue --- .../java/com/iemr/flw/controller/AshaProfileController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index fcf82853..c028e9a9 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -31,7 +31,7 @@ public class AshaProfileController { @RequestMapping(value = "editProfile", method = {RequestMethod.POST}, produces = { "application/json"}, consumes = "application/json") - public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee) { + public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee,@RequestHeader(value = "Authorization") String authorization) { try { System.out.println(editEmployee.toString()); From c1dfc59f8cd1dc621981e2f752981e65af50d7bf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 16:52:42 +0530 Subject: [PATCH 045/792] fix asha profile issue --- src/main/java/com/iemr/flw/controller/AshaProfileController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index ae08ef3b..fcf82853 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -76,5 +76,4 @@ public ResponseEntity> getProfile(@RequestParam("employeeId" } - } From 846f20fb270a44e147156e76bef326c2ba0c0bf3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:15:28 +0530 Subject: [PATCH 046/792] fixed pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 3bb0537b..69fca265 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ jdt_apt 1.2.0.Final 1.16.18 - local + ${ENV_VAR} target/classes/application.properties src/main/environment/common_${environment}.properties true @@ -261,7 +261,7 @@ flw-0.0.1 - + org.apache.maven.plugins maven-jar-plugin From ce2747c85ea9e1f6d2570a07cbb1cbce8c7b6d30 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:16:28 +0530 Subject: [PATCH 047/792] fixed pom.xml --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index 69fca265..e0cc4167 100644 --- a/pom.xml +++ b/pom.xml @@ -261,7 +261,6 @@ flw-0.0.1 - org.apache.maven.plugins maven-jar-plugin From 88823fb67a4e27479cbd30b41a0a92288871061e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:18:05 +0530 Subject: [PATCH 048/792] fixed pom.xml --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e0cc4167..2b1e1351 100644 --- a/pom.xml +++ b/pom.xml @@ -261,7 +261,8 @@ flw-0.0.1 - + + org.apache.maven.plugins maven-jar-plugin 3.0.2 From 7f2b26ed40ab715625bbfcf86a7e1d77c0bc5188 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:21:29 +0530 Subject: [PATCH 049/792] fixed pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2b1e1351..69fca265 100644 --- a/pom.xml +++ b/pom.xml @@ -262,7 +262,7 @@ flw-0.0.1 - + org.apache.maven.plugins maven-jar-plugin 3.0.2 From 6bada21c223661174f9f0ff11a072e432bbae211 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:25:22 +0530 Subject: [PATCH 050/792] fixed pom.xml --- src/main/environment/common_local.properties | 30 -------------------- 1 file changed, 30 deletions(-) delete mode 100644 src/main/environment/common_local.properties diff --git a/src/main/environment/common_local.properties b/src/main/environment/common_local.properties deleted file mode 100644 index 739894e8..00000000 --- a/src/main/environment/common_local.properties +++ /dev/null @@ -1,30 +0,0 @@ -# FHIR Config -fhir-url=/fhirapi-v1.0 - - # TM Config -tm-url=/tmapi-v1.0 -##--------------------------------------------## Primary db------------------------------------------------------------------- - -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 - -##--------------------------------------------## Secondary db------------------------------------------------------------------- - -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 - -spring.session.store-type=redis -spring.redis.host=localhost -spring.redis.password=123456 -spring.redis.port=6379 -jakarta.persistence.schema-generation.database.action=create -spring.jpa.defer-datasource-initialization=true \ No newline at end of file From cb8c73d55d302efc33e8c4e95a59243a4252eca4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:28:08 +0530 Subject: [PATCH 051/792] fixed properties file --- src/main/resources/application.properties | 36 ----------------------- 1 file changed, 36 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 17783a97..12a14942 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,10 +1,7 @@ spring.main.banner-mode=off spring.data.jpa.repositories.enabled=true #spring.jpa.hibernate.ddl-auto=none -fhir-url=https://uatamrit.piramalswasthya.org/fhirapi-v1.0 -# TM Config -tm-url=https://uatamrit.piramalswasthya.org/tmapi-v1.0 # Naming strategies spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl @@ -48,40 +45,7 @@ get-HRP-Status=ANC/getHRPStatus #Get Beneficiary ABHA getHealthID=healthID/getBenhealthID -# FHIR Config -#fhir-url=/fhirapi-v1.0 -#server.port=8082 -# TM Config -#tm-url=/tmapi-v1.0 -##--------------------------------------------## Primary db------------------------------------------------------------------- - -spring.datasource.url=jdbc:mysql://localhost:3306/db_iemr -spring.datasource.username=root -#spring.datasource.password=YesBank@123# -spring.datasource.password=BizDev@24BB - -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -##--------------------------------------------## Secondary db------------------------------------------------------------------- - -secondary.datasource.url=jdbc:mysql://localhost:3306/db_identity -secondary.datasource.username=root -#secondary.datasource.password=YesBank@123# -secondary.datasource.password=BizDev@24BB - -secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - -springdoc.api-docs.enabled=true -springdoc.swagger-ui.enabled=true - -sendSMSUrl = v1/send-sms -source-address=AIDSHL -sms-username=PIRAMAL_SW_AHxoyCXejeJba13oKHcv -sms-password=]Kt9GAp8}$S*@ -sms-sender-number ="9560618681" -send-message-url= v1/send-sms -sms-gateway-url= https://iqsms.airtel.in/api From fd4bd95042031f664ae0e19e84edd4aaa8aa654f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:29:45 +0530 Subject: [PATCH 052/792] fixed code --- .../iemr/flw/domain/iemr/OtpBeneficiary.java | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java b/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java deleted file mode 100644 index 15a87bd0..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/OtpBeneficiary.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; -import java.sql.Timestamp; - -@Entity -@Table(name = "m_otp_beneficiary", schema = "db_iemr") -@Data -public class OtpBeneficiary { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "beneficiaryId", nullable = false) - private Long beneficiaryId; - - @Column(name = "phoneNumber", nullable = false, length = 45) - private String phoneNumber; - - @Column(name = "isOtpVerify") - private Boolean isOtpVerify = false; - - @Column(name = "otp", nullable = false) - private Integer otp; - - @Column(name = "isExpired") - private Boolean isExpired = false; - - @Column(name = "createdAt", updatable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") - private Timestamp createdAt; -} From 8d0d504b1bacb0b03dffb89b4790c19d97ec7cdc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:31:31 +0530 Subject: [PATCH 053/792] fixed code --- .../controller/MaternalHealthController.java | 57 ++----------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 4fb2630a..87aa8810 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -3,20 +3,18 @@ import com.google.gson.Gson; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; -import com.iemr.flw.service.*; +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.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; @@ -26,8 +24,6 @@ public class MaternalHealthController { private final Logger logger = LoggerFactory.getLogger(CoupleController.class); - @Autowired - FileStorageService fileStorageService; @Autowired private MaternalHealthService maternalHealthService; @@ -112,49 +108,6 @@ public String saveANCVisit(@RequestBody List 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 saveANCVisit( - @RequestPart("ancVisitDTOs") @Valid @RequestBody List 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); - } - } - @CrossOrigin() @Operation(summary = "get anc visit details") @RequestMapping(value = {"/ancVisit/getAll"}, method = {RequestMethod.POST}) @@ -329,7 +282,7 @@ public String saveAllChildDetails(@RequestBody List childRegis @Operation(summary = "get PMSMA data of all beneficiaries registered with given user id") @RequestMapping(value = {"/pmsma/getAll"}, method = {RequestMethod.POST}) public String getAllPmsmaDetails(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { if (requestDTO != null) { From 91eae315abf32074656551150298a963ca211435 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:33:46 +0530 Subject: [PATCH 054/792] fixed code --- .../java/com/iemr/flw/controller/MaternalHealthController.java | 3 +-- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 2 -- src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 1 - 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 87aa8810..2ca084e9 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -111,8 +111,7 @@ public String saveANCVisit(@RequestBody List ancVisitDTOs, @CrossOrigin() @Operation(summary = "get anc visit details") @RequestMapping(value = {"/ancVisit/getAll"}, method = {RequestMethod.POST}) - public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { if (requestDTO != null) { diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 4207e27d..6d07b506 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -113,7 +113,5 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; - @Column(name = "file_path") - private String filePath; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 0cd07846..54e48fca 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -43,7 +43,6 @@ public class ANCVisitDTO { private Timestamp updatedDate; private String updatedBy; private Integer providerServiceMapID; - private String filePath; } From 78d1b8700a4e0062e639b26b0b555649df165c38 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:36:46 +0530 Subject: [PATCH 055/792] fixed code --- .../com/iemr/flw/domain/iemr/ANCVisit.java | 2 +- .../iemr/flw/service/FileStorageService.java | 38 ------------------- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/service/FileStorageService.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 6d07b506..0459d664 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -3,6 +3,7 @@ import lombok.Data; import jakarta.persistence.*; + import java.sql.Timestamp; @Entity @@ -113,5 +114,4 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; - } diff --git a/src/main/java/com/iemr/flw/service/FileStorageService.java b/src/main/java/com/iemr/flw/service/FileStorageService.java deleted file mode 100644 index d22352ce..00000000 --- a/src/main/java/com/iemr/flw/service/FileStorageService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.iemr.flw.service; - -import org.springframework.stereotype.Service; -import org.springframework.web.multipart.MultipartFile; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.UUID; - -@Service -public class FileStorageService { - - private static final String UPLOAD_DIR = "uploads/"; // Define your upload directory - - public String storeFile(MultipartFile file) throws IOException { - if (file.isEmpty()) { - throw new IllegalStateException("Cannot store empty file."); - } - - // Create directories if they do not exist - File uploadDir = new File(UPLOAD_DIR); - if (!uploadDir.exists()) { - uploadDir.mkdirs(); - } - - // Generate a unique file name - String fileName = UUID.randomUUID().toString() + "_" + file.getOriginalFilename(); - Path filePath = Paths.get(UPLOAD_DIR + fileName); - - // Save file - Files.write(filePath, file.getBytes()); - - return filePath.toString(); // Return the saved file path - } -} \ No newline at end of file From 3eeac6b5b072e3782d396e87c5c89a14c0deec8f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:45:27 +0530 Subject: [PATCH 056/792] fixed code --- src/main/java/com/iemr/flw/utils/http/HttpUtils.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java index 57281f22..c995245b 100644 --- a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java +++ b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java @@ -112,10 +112,5 @@ public void setStatus(HttpStatus status) { this.status = status; } - public ResponseEntity getV1(String uri) { - System.out.println(uri.toString()); - HttpEntity requestEntity = new HttpEntity("", headers); - ResponseEntity responseEntity = rest.exchange(uri, HttpMethod.GET, requestEntity, String.class); - return responseEntity; - } + } From 4e8edf90a97c0601bd8c8849d450072ce01faa1c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:46:43 +0530 Subject: [PATCH 057/792] fixed code --- src/main/java/com/iemr/flw/utils/http/HttpUtils.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java index c995245b..edc5930d 100644 --- a/src/main/java/com/iemr/flw/utils/http/HttpUtils.java +++ b/src/main/java/com/iemr/flw/utils/http/HttpUtils.java @@ -111,6 +111,4 @@ public HttpStatus getStatus() { public void setStatus(HttpStatus status) { this.status = status; } - - } From db75176e3c7cbcec6ce97e6ab0e4f5becebafdda Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:47:30 +0530 Subject: [PATCH 058/792] fixed code --- .../com/iemr/flw/controller/MaternalHealthController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 2ca084e9..61476ef4 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -111,7 +111,8 @@ public String saveANCVisit(@RequestBody List ancVisitDTOs, @CrossOrigin() @Operation(summary = "get anc visit details") @RequestMapping(value = {"/ancVisit/getAll"}, method = {RequestMethod.POST}) - public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "Authorization") String Authorization) { + public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { if (requestDTO != null) { @@ -281,7 +282,7 @@ public String saveAllChildDetails(@RequestBody List childRegis @Operation(summary = "get PMSMA data of all beneficiaries registered with given user id") @RequestMapping(value = {"/pmsma/getAll"}, method = {RequestMethod.POST}) public String getAllPmsmaDetails(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { if (requestDTO != null) { From 24edee835ef5f76fc07f3674ee6c6aebfa599b6f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:48:43 +0530 Subject: [PATCH 059/792] fixed code --- src/main/java/com/iemr/flw/controller/UserController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/UserController.java b/src/main/java/com/iemr/flw/controller/UserController.java index bf596bfd..4a1a79fe 100644 --- a/src/main/java/com/iemr/flw/controller/UserController.java +++ b/src/main/java/com/iemr/flw/controller/UserController.java @@ -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.getMessage()); + logger.error("Error in fetching user role, " + e); return new ResponseEntity<>( new ApiResponse(false, "Error in fetching user role, " + e.getMessage(), null), HttpStatus.INTERNAL_SERVER_ERROR); } From e751a573cd1e5adbec4f6a48c6ddf12f5cc704ed Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:49:39 +0530 Subject: [PATCH 060/792] fixed code --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 0459d664..9aeb8878 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -3,7 +3,6 @@ import lombok.Data; import jakarta.persistence.*; - import java.sql.Timestamp; @Entity @@ -113,5 +112,4 @@ public class ANCVisit { @Column(name = "updated_by") private String updatedBy; - } From 84ebf5bfdde42b78c7af37621b7f229eeaa96a5f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:51:20 +0530 Subject: [PATCH 061/792] fixed code --- .../com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index 771cdad1..abe8313a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -157,9 +157,4 @@ public class EligibleCoupleRegister { @Column(name = "updated_by") private String updatedBy; - - - - } - From 261fd33fa2e96fe14a9d90d801f0a1e1a43ae320 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:53:22 +0530 Subject: [PATCH 062/792] fixed code --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java | 1 - src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 3 --- src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java index aee3a01b..2cde9438 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java @@ -49,5 +49,4 @@ public class EligibleCoupleTracking { @Column(name = "updated_by") private String updatedBy; - } diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 54e48fca..83f1acef 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -2,7 +2,6 @@ import lombok.Data; -import java.io.File; import java.sql.Timestamp; @Data @@ -43,7 +42,5 @@ public class ANCVisitDTO { private Timestamp updatedDate; private String updatedBy; private Integer providerServiceMapID; - - } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index 4a633982..e51bbb70 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -105,6 +105,4 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp updatedDate; private String updatedBy; - - } From 6dd1e3972229329705b5bcd0c4f45c94fc7dd863 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 17:55:30 +0530 Subject: [PATCH 063/792] fixed code --- src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java | 3 ++- .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- src/main/java/com/iemr/flw/utils/redis/RedisStorage.java | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java index be829bd9..3fbfe0b0 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java @@ -6,6 +6,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; + import java.util.List; @Repository @@ -14,9 +15,9 @@ public interface UserServiceRoleRepo extends JpaRepository getUserRole(@Param("userId") Integer userId); + @Query("select u.userId from UserServiceRole u where u.userName = :userName") Integer getUserIdByName(@Param("userName") String userName); } diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 50658376..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - // validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { diff --git a/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java b/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java index 59a6f434..8495bb8f 100644 --- a/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java +++ b/src/main/java/com/iemr/flw/utils/redis/RedisStorage.java @@ -49,8 +49,6 @@ public String setObject(String key, String value, int expirationTime) throws Red redCon.set(key.getBytes(), value.getBytes(), Expiration.seconds(expirationTime), SetOption.UPSERT); } return key; - - } public String getObject(String key, Boolean extendExpirationTime, int expirationTime) throws RedisSessionException { From 704dbc8643922feac17535774ebb52c48f504b5a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Mar 2025 18:05:34 +0530 Subject: [PATCH 064/792] fixed code --- .../flw/service/impl/EmployeeMasterImpl.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java index cf542677..76ee5b0a 100644 --- a/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java @@ -3,16 +3,29 @@ import com.iemr.flw.domain.iemr.M_User; import com.iemr.flw.repo.iemr.EmployeeMasterRepo; import com.iemr.flw.service.EmployeeMasterInter; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class EmployeeMasterImpl implements EmployeeMasterInter { +public class EmployeeMasterImpl implements EmployeeMasterInter { @Autowired - EmployeeMasterRepo employeeMasterRepo; + EmployeeMasterRepo employeeMasterRepo; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + @Override public M_User getUserDetails(Integer userID) { - return employeeMasterRepo.findByUserID(userID); + logger.debug("Fetching user details for userID: {}", userID); + try { + if (userID == null) { + throw new IllegalArgumentException("UserID cannot be null"); + } + return employeeMasterRepo.findByUserID(userID); + } catch (Exception e) { + logger.error("Error fetching user details for userID: {}", userID, e); + throw e; + } } } From b2295554875faf81fd5f27de13f46d47413a3c74 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Mar 2025 15:42:14 +0530 Subject: [PATCH 065/792] Implement jwt token in AshaProfileController --- .../flw/controller/AshaProfileController.java | 8 +- .../flw/repo/iemr/EmployeeMasterRepo.java | 1 + .../iemr/flw/service/AshaProfileService.java | 2 +- .../flw/service/impl/AshaProfileImpl.java | 34 ++++- .../java/com/iemr/flw/utils/CommonMain.java | 47 +++++++ .../java/com/iemr/flw/utils/CookieUtil.java | 42 ++++++ .../iemr/flw/utils/JwtAuthenticationUtil.java | 124 ++++++++++++++++++ .../flw/utils/JwtUserIdValidationFilter.java | 106 +++++++++++++++ src/main/java/com/iemr/flw/utils/JwtUtil.java | 82 ++++++++++++ 9 files changed, 438 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/iemr/flw/utils/CommonMain.java create mode 100644 src/main/java/com/iemr/flw/utils/CookieUtil.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtUtil.java diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index c028e9a9..a0518ef9 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -7,6 +7,10 @@ import com.iemr.flw.service.AshaProfileService; import com.iemr.flw.service.EmployeeMasterInter; import com.iemr.flw.service.UserService; +import com.iemr.flw.utils.JwtAuthenticationUtil; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; import io.swagger.v3.oas.annotations.Operation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,9 +56,9 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker } @RequestMapping(value = "getProfile", method = RequestMethod.GET, headers = "Authorization") - public ResponseEntity> getProfile(@RequestParam("employeeId") Integer employeeId) { + public ResponseEntity> getProfile(@RequestHeader("Authorization") String authorization) throws IEMRException { try { - AshaWorker ashaWorker = ashaProfileService.getProfileData(employeeId); + AshaWorker ashaWorker = ashaProfileService.getProfileData(authorization); if (ashaWorker != null) { response.put("data", ashaWorker); response.put("statusCode", 200); diff --git a/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java index 6b57efc3..1fc0f88c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java @@ -8,4 +8,5 @@ public interface EmployeeMasterRepo extends JpaRepository { M_User findByUserID(Integer userID); + M_User getUserByUserID(Integer parseLong); } diff --git a/src/main/java/com/iemr/flw/service/AshaProfileService.java b/src/main/java/com/iemr/flw/service/AshaProfileService.java index c5761090..ab38ccdf 100644 --- a/src/main/java/com/iemr/flw/service/AshaProfileService.java +++ b/src/main/java/com/iemr/flw/service/AshaProfileService.java @@ -6,6 +6,6 @@ @Service public interface AshaProfileService { AshaWorker saveEditData(AshaWorker ashaWorkerRequest); - AshaWorker getProfileData(Integer employeeId); + AshaWorker getProfileData(String authorization ); } diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index b3804c83..67b935ca 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -3,15 +3,22 @@ import com.iemr.flw.domain.iemr.AshaWorker; import com.iemr.flw.domain.iemr.M_User; import com.iemr.flw.repo.iemr.AshaProfileRepo; +import com.iemr.flw.repo.iemr.EmployeeMasterRepo; import com.iemr.flw.service.AshaProfileService; import com.iemr.flw.service.EmployeeMasterInter; +import com.iemr.flw.utils.JwtAuthenticationUtil; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; import java.util.Objects; +import java.util.concurrent.TimeUnit; @Service public class AshaProfileImpl implements AshaProfileService { @@ -19,6 +26,15 @@ public class AshaProfileImpl implements AshaProfileService { AshaProfileRepo ashaProfileRepo; @Autowired EmployeeMasterInter employeeMasterInter; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private EmployeeMasterRepo userLoginRepo; + @Autowired + JwtUtil jwtUtil; + + @Autowired + JwtAuthenticationUtil jwtAuthenticationUtil ; private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); @@ -40,14 +56,20 @@ public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { } @Override - public AshaWorker getProfileData(Integer employeeId) { + public AshaWorker getProfileData(String authorization) { try { - Objects.requireNonNull(employeeId, "employeeId must not be null"); - return ashaProfileRepo.findByEmployeeId(employeeId) - .orElseGet(() -> getDetails(employeeId)); + Objects.requireNonNull(jwtUtil.extractUserId(authorization), "employeeId must not be null"); + return ashaProfileRepo.findByEmployeeId(jwtUtil.extractUserId(authorization)) + .orElseGet(() -> { + try { + return getDetails(jwtUtil.extractUserId(authorization)); + } catch (IEMRException e) { + throw new RuntimeException(e); + } + }); } catch (Exception e) { - logger.error("Error retrieving ASHA worker profile for employeeId {}: {}", employeeId, e.getMessage(), e); + logger.error("Error retrieving ASHA worker profile for employeeId {}: {}", getProfileData(authorization), e.getMessage(), e); throw new RuntimeException("Failed to retrieve ASHA worker profile", e); } } @@ -120,4 +142,6 @@ private AshaWorker updateProfile(AshaWorker editAshaWorkerRequest) { } + + } diff --git a/src/main/java/com/iemr/flw/utils/CommonMain.java b/src/main/java/com/iemr/flw/utils/CommonMain.java new file mode 100644 index 00000000..a3193f9e --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/CommonMain.java @@ -0,0 +1,47 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.flw.utils; + +import com.iemr.flw.utils.config.ConfigProperties; +import com.iemr.flw.utils.redis.RedisStorage; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration; + +@EnableAutoConfiguration +public class CommonMain { + @Bean + public ConfigProperties configProperties() { + return new ConfigProperties(); + } + + @Bean + public RedisHttpSessionConfiguration redisSession() { + return new RedisHttpSessionConfiguration(); + } + + @Bean + public RedisStorage redisStorage() { + return new RedisStorage(); + } + +} diff --git a/src/main/java/com/iemr/flw/utils/CookieUtil.java b/src/main/java/com/iemr/flw/utils/CookieUtil.java new file mode 100644 index 00000000..c97ddc50 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/CookieUtil.java @@ -0,0 +1,42 @@ +package com.iemr.flw.utils; + +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Optional; + +@Service +public class CookieUtil { + + public Optional getCookieValue(HttpServletRequest request, String cookieName) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookieName.equals(cookie.getName())) { + return Optional.of(cookie.getValue()); + } + } + } + return Optional.empty(); + } + + public void addJwtTokenToCookie(String Jwttoken, HttpServletResponse response, HttpServletRequest request) { + // Create a new cookie with the JWT token + Cookie cookie = new Cookie("Jwttoken", Jwttoken); + cookie.setHttpOnly(true); // Prevent JavaScript access for security + cookie.setMaxAge(60 * 60 * 24); // 1 day expiration time + cookie.setPath("/"); // Make the cookie available for the entire application + if ("https".equalsIgnoreCase(request.getScheme())) { + cookie.setSecure(true); // Secure flag only on HTTPS + } + response.addCookie(cookie); // Add the cookie to the response + } + + public String getJwtTokenFromCookie(HttpServletRequest request) { + return Arrays.stream(request.getCookies()).filter(cookie -> "Jwttoken".equals(cookie.getName())) + .map(Cookie::getValue).findFirst().orElse(null); + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java new file mode 100644 index 00000000..8aac9ed5 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java @@ -0,0 +1,124 @@ +package com.iemr.flw.utils; + +import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.repo.iemr.EmployeeMasterRepo; +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; +import jakarta.servlet.http.HttpServletRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +@Component +public class JwtAuthenticationUtil { + + @Autowired + private CookieUtil cookieUtil; + @Autowired + private JwtUtil jwtUtil; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private EmployeeMasterRepo userLoginRepo; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + public JwtAuthenticationUtil(CookieUtil cookieUtil, JwtUtil jwtUtil) { + this.cookieUtil = cookieUtil; + this.jwtUtil = jwtUtil; + } + + public ResponseEntity validateJwtToken(HttpServletRequest request) { + Optional jwtTokenOpt = cookieUtil.getCookieValue(request, "Jwttoken"); + + if (jwtTokenOpt.isEmpty()) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED) + .body("Error 401: Unauthorized - JWT Token is not set!"); + } + + String jwtToken = jwtTokenOpt.get(); + + // Validate the token + Claims claims = jwtUtil.validateToken(jwtToken); + if (claims == null) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Error 401: Unauthorized - Invalid JWT Token!"); + } + + // Extract username from token + String usernameFromToken = claims.getSubject(); + if (usernameFromToken == null || usernameFromToken.isEmpty()) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED) + .body("Error 401: Unauthorized - Username is missing!"); + } + + // Return the username if valid + return ResponseEntity.ok(usernameFromToken); + } + + public boolean validateUserIdAndJwtToken(String jwtToken) throws IEMRException { + try { + // Validate JWT token and extract claims + Claims claims = jwtUtil.validateToken(jwtToken); + + if (claims == null) { + throw new IEMRException("Invalid JWT token."); + } + + String userId = claims.get("userId", String.class); + + // Check if user data is present in Redis + M_User user = getUserFromCache(userId); + if (user == null) { + // If not in Redis, fetch from DB and cache the result + user = fetchUserFromDB(userId); + } + if (user == null) { + throw new IEMRException("Invalid User ID."); + } + + return true; // Valid userId and JWT token + } catch (Exception e) { + logger.error("Validation failed: " + e.getMessage(), e); + throw new IEMRException("Validation error: " + e.getMessage(), e); + } + } + + private M_User getUserFromCache(String userId) { + String redisKey = "user_" + userId; // The Redis key format + M_User user = (M_User) redisTemplate.opsForValue().get(redisKey); + + if (user == null) { + logger.warn("User not found in Redis. Will try to fetch from DB."); + } else { + logger.info("User fetched successfully from Redis."); + } + + return user; // Returns null if not found + } + + private M_User fetchUserFromDB(String userId) { + // This method will only be called if the user is not found in Redis. + String redisKey = "user_" + userId; // Redis key format + + // Fetch user from DB + M_User user = userLoginRepo.getUserByUserID(Integer.parseInt(userId)); + + if (user != null) { + // Cache the user in Redis for future requests (cache for 30 minutes) + redisTemplate.opsForValue().set(redisKey, user, 30, TimeUnit.MINUTES); + + // Log that the user has been stored in Redis + logger.info("User stored in Redis with key: " + redisKey); + } else { + logger.warn("User not found for userId: " + userId); + } + + return user; + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java new file mode 100644 index 00000000..d1eab50e --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -0,0 +1,106 @@ +package com.iemr.flw.utils; + +import jakarta.servlet.*; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Component +public class JwtUserIdValidationFilter implements Filter { + + private final JwtAuthenticationUtil jwtAuthenticationUtil; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + public JwtUserIdValidationFilter(JwtAuthenticationUtil jwtAuthenticationUtil) { + this.jwtAuthenticationUtil = jwtAuthenticationUtil; + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; + + String path = request.getRequestURI(); + String contextPath = request.getContextPath(); + logger.info("JwtUserIdValidationFilter invoked for path: " + path); + + // Log cookies for debugging + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if ("userId".equals(cookie.getName())) { + logger.warn("userId found in cookies! Clearing it..."); + clearUserIdCookie(response); // Explicitly remove userId cookie + } + } + } else { + logger.info("No cookies found in the request"); + } + + // Log headers for debugging + String jwtTokenFromHeader = request.getHeader("Jwttoken"); + logger.info("JWT token from header: "); + + // Skip login and public endpoints + if (path.equals(contextPath + "/user/userAuthenticate") + || path.equalsIgnoreCase(contextPath + "/user/logOutUserFromConcurrentSession") + || path.startsWith(contextPath + "/public")) { + logger.info("Skipping filter for path: " + path); + filterChain.doFilter(servletRequest, servletResponse); + return; + } + + try { + // Retrieve JWT token from cookies + String jwtTokenFromCookie = getJwtTokenFromCookies(request); + logger.info("JWT token from cookie: "); + + // Determine which token (cookie or header) to validate + String jwtToken = jwtTokenFromCookie != null ? jwtTokenFromCookie : jwtTokenFromHeader; + if (jwtToken == null) { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "JWT token not found in cookies or headers"); + return; + } + + // Validate JWT token and userId + boolean isValid = jwtAuthenticationUtil.validateUserIdAndJwtToken(jwtToken); + + if (isValid) { + // If token is valid, allow the request to proceed + filterChain.doFilter(servletRequest, servletResponse); + } else { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid JWT token"); + } + } catch (Exception e) { + logger.error("Authorization error: ", e); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: "); + } + } + + private String getJwtTokenFromCookies(HttpServletRequest request) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("Jwttoken")) { + return cookie.getValue(); + } + } + } + return null; + } + + private void clearUserIdCookie(HttpServletResponse response) { + Cookie cookie = new Cookie("userId", null); + cookie.setPath("/"); + cookie.setHttpOnly(true); + cookie.setSecure(true); + cookie.setMaxAge(0); // Invalidate the cookie + response.addCookie(cookie); + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUtil.java b/src/main/java/com/iemr/flw/utils/JwtUtil.java new file mode 100644 index 00000000..01bbc693 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtUtil.java @@ -0,0 +1,82 @@ +package com.iemr.flw.utils; + +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.security.Key; +import java.util.Date; +import java.util.function.Function; + +@Component +public class JwtUtil { + + @Value("${jwt.secret}") + private String SECRET_KEY; + + private static final long EXPIRATION_TIME = 24L * 60 * 60 * 1000; // 1 day in milliseconds + + // Generate a key using the secret + private Key getSigningKey() { + if (SECRET_KEY == null || SECRET_KEY.isEmpty()) { + throw new IllegalStateException("JWT secret key is not set in application.properties"); + } + return Keys.hmacShaKeyFor(SECRET_KEY.getBytes()); + } + + // Generate JWT Token + public String generateToken(String username, String userId) { + Date now = new Date(); + Date expiryDate = new Date(now.getTime() + EXPIRATION_TIME); + + // Include the userId in the JWT claims + return Jwts.builder().setSubject(username).claim("userId", userId) // Add userId as a claim + .setIssuedAt(now).setExpiration(expiryDate).signWith(getSigningKey(), SignatureAlgorithm.HS256) + .compact(); + } + + // Validate and parse JWT Token + public Claims validateToken(String token) { + try { + return Jwts.parser().setSigningKey(getSigningKey()).build().parseClaimsJws(token).getBody(); + } catch (Exception e) { + return null; // Handle token parsing/validation errors + } + } + + public String extractUsername(String token) { + return extractClaim(token, Claims::getSubject); + } + public Integer extractUserId(String jwtToken) throws IEMRException { + try { + // Validate JWT token and extract claims + Claims claims = validateToken(jwtToken); + + if (claims == null) { + throw new IEMRException("Invalid JWT token."); + } + + String userId = claims.get("userId", String.class); + + return Integer.parseInt(userId); + + } catch (Exception e) { + throw new IEMRException("Validation error: " + e.getMessage(), e); + } + + + } + + public T extractClaim(String token, Function claimsResolver) { + final Claims claims = extractAllClaims(token); + return claimsResolver.apply(claims); + } + + private Claims extractAllClaims(String token) { + return Jwts.parser().setSigningKey(getSigningKey()).build().parseClaimsJws(token).getBody(); + } +} From 89621f25b89094dae6ea66873bb37d7d1c9beaa8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Mar 2025 15:46:22 +0530 Subject: [PATCH 066/792] Implement jwt token in getAll MicroBirthPlan --- .../controller/MicroBirthPlanController.java | 11 +- .../java/com/iemr/flw/domain/iemr/M_User.java | 142 ++++++++++++++++++ .../flw/repo/iemr/EmployeeMasterRepo.java | 12 ++ .../java/com/iemr/flw/utils/CommonMain.java | 47 ++++++ .../java/com/iemr/flw/utils/CookieUtil.java | 42 ++++++ .../iemr/flw/utils/JwtAuthenticationUtil.java | 124 +++++++++++++++ .../flw/utils/JwtUserIdValidationFilter.java | 106 +++++++++++++ src/main/java/com/iemr/flw/utils/JwtUtil.java | 83 ++++++++++ 8 files changed, 564 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/M_User.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java create mode 100644 src/main/java/com/iemr/flw/utils/CommonMain.java create mode 100644 src/main/java/com/iemr/flw/utils/CookieUtil.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java create mode 100644 src/main/java/com/iemr/flw/utils/JwtUtil.java diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index 505b1e02..b5478529 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -4,6 +4,8 @@ import com.iemr.flw.dto.iemr.GetMicroPlanHandler; import com.iemr.flw.dto.iemr.MicroBirthPlanDTO; import com.iemr.flw.service.MicroBirthPlanService; +import com.iemr.flw.utils.JwtUtil; +import io.jsonwebtoken.Jwe; import io.swagger.v3.oas.annotations.Operation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -24,6 +26,9 @@ public class MicroBirthPlanController { @Autowired private MicroBirthPlanService service; + @Autowired + JwtUtil jwtUtil; + @RequestMapping(value = "saveAll", method = RequestMethod.POST) public ResponseEntity> createMicroBirthPlan(@RequestBody MicroBirthPlanDTO birthPlan) { @@ -50,15 +55,15 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic @RequestMapping(value = "getAll", method = RequestMethod.POST) - public ResponseEntity> getAllMicroBirthPlans(@RequestBody GetMicroPlanHandler getMicroPlanHandler, @RequestHeader(value = "Authorization") String Authorization) { + public ResponseEntity> getAllMicroBirthPlans(@RequestHeader(value = "Authorization") String authorization) { Map response = new HashMap<>(); Map data = new HashMap<>(); try { - data.put("userId", getMicroPlanHandler.getUserId()); - data.put("entries", service.getAllMicroBirthPlans(getMicroPlanHandler.getUserId())); + data.put("userId", jwtUtil.extractUserId(authorization)); + data.put("entries", service.getAllMicroBirthPlans(jwtUtil.extractUserId(authorization))); response.put("data", data); response.put("statusCode", 200); response.put("status", "Success"); diff --git a/src/main/java/com/iemr/flw/domain/iemr/M_User.java b/src/main/java/com/iemr/flw/domain/iemr/M_User.java new file mode 100644 index 00000000..c95ec793 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/M_User.java @@ -0,0 +1,142 @@ +package com.iemr.flw.domain.iemr; + +import com.google.gson.annotations.Expose; +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Timestamp; +import java.time.LocalDate; + +@Entity +@Table(name = "m_User",schema = "db_iemr") +@Data +public class M_User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Expose + @Column(name="UserID") + private Integer userID; + @Expose + @Column(name="TitleID") + private Integer titleID; + @Expose + @Column(name="FirstName") + private String firstName; + @Expose + @Column(name="MiddleName") + private String middleName; + @Expose + @Column(name="LastName") + private String lastName; + @Expose + @Column(name="GenderID") + private Short genderID; + + @Expose + @Column(name="MaritalStatusID") + private Integer maritalStatusID; + @Expose + @Column(name="DesignationID") + private Integer designationID; + + @Expose + @Column(name="AadhaarNo") + private String aadhaarNo; + @Expose + @Column(name="PAN") + private String pAN; + @Expose + @Column(name="DOB") + private LocalDate dOB; + @Expose + @Column(name="DOJ") + private LocalDate dOJ; + @Expose + @Column(name="QualificationID") + private Integer qualificationID; + @Expose + @Column(name="HealthProfessionalID") + private String healthProfessionalID; + @Expose + @Column(name="UserName") + private String userName; + @Expose + @Column(name="Password") + private String password; + @Expose + @Column(name="IsExternal") + private Boolean isExternal; + @Expose + @Column(name="AgentID") + private String agentID; + @Expose + @Column(name="AgentPassword") + private String agentPassword; + @Expose + @Column(name="EmailID") + private String emailID; + @Expose + @Column(name="StatusID") + private Integer statusID; + @Expose + @Column(name="EmergencyContactPerson") + private String emergencyContactPerson; + @Expose + @Column(name="EmergencyContactNo") + private String emergencyContactNo; + @Expose + @Column(name="IsSupervisor") + private Boolean isSupervisor; + @Expose + @Column(name="Deleted",insertable = false, updatable = true) + private Boolean deleted; + @Expose + @Column(name="CreatedBy") + private String createdBy; + @Expose + @Column(name="EmployeeID") + private String employeeID; + @Expose + @Column(name="CreatedDate",insertable = false, updatable = false) + private Timestamp createdDate; + @Expose + @Column(name="ModifiedBy") + private String modifiedBy; + @Expose + @Column(name="LastModDate",insertable = false, updatable = false) + private Timestamp lastModDate; + + @Expose + @Column(name="Remarks") + private String remarks; + + @Expose + @Column(name="ContactNo") + private String contactNo; + + + @Expose + @Column(name="IsProviderAdmin") + private Boolean isProviderAdmin; + + @Expose + @Column(name="ServiceProviderID") + private Integer serviceProviderID; + + + + @Expose + @Column(name = "failed_attempt", insertable = false) + private Integer failedAttempt; + public M_User() { + // TODO Auto-generated constructor stub + } + + public M_User(Integer userID, String userName) { + // TODO Auto-generated constructor stub + this.userID=userID; + this.userName=userName; + } + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java new file mode 100644 index 00000000..1fc0f88c --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/EmployeeMasterRepo.java @@ -0,0 +1,12 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.M_User; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface EmployeeMasterRepo extends JpaRepository { + M_User findByUserID(Integer userID); + + M_User getUserByUserID(Integer parseLong); +} diff --git a/src/main/java/com/iemr/flw/utils/CommonMain.java b/src/main/java/com/iemr/flw/utils/CommonMain.java new file mode 100644 index 00000000..a3193f9e --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/CommonMain.java @@ -0,0 +1,47 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.flw.utils; + +import com.iemr.flw.utils.config.ConfigProperties; +import com.iemr.flw.utils.redis.RedisStorage; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration; + +@EnableAutoConfiguration +public class CommonMain { + @Bean + public ConfigProperties configProperties() { + return new ConfigProperties(); + } + + @Bean + public RedisHttpSessionConfiguration redisSession() { + return new RedisHttpSessionConfiguration(); + } + + @Bean + public RedisStorage redisStorage() { + return new RedisStorage(); + } + +} diff --git a/src/main/java/com/iemr/flw/utils/CookieUtil.java b/src/main/java/com/iemr/flw/utils/CookieUtil.java new file mode 100644 index 00000000..c97ddc50 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/CookieUtil.java @@ -0,0 +1,42 @@ +package com.iemr.flw.utils; + +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.Optional; + +@Service +public class CookieUtil { + + public Optional getCookieValue(HttpServletRequest request, String cookieName) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookieName.equals(cookie.getName())) { + return Optional.of(cookie.getValue()); + } + } + } + return Optional.empty(); + } + + public void addJwtTokenToCookie(String Jwttoken, HttpServletResponse response, HttpServletRequest request) { + // Create a new cookie with the JWT token + Cookie cookie = new Cookie("Jwttoken", Jwttoken); + cookie.setHttpOnly(true); // Prevent JavaScript access for security + cookie.setMaxAge(60 * 60 * 24); // 1 day expiration time + cookie.setPath("/"); // Make the cookie available for the entire application + if ("https".equalsIgnoreCase(request.getScheme())) { + cookie.setSecure(true); // Secure flag only on HTTPS + } + response.addCookie(cookie); // Add the cookie to the response + } + + public String getJwtTokenFromCookie(HttpServletRequest request) { + return Arrays.stream(request.getCookies()).filter(cookie -> "Jwttoken".equals(cookie.getName())) + .map(Cookie::getValue).findFirst().orElse(null); + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java new file mode 100644 index 00000000..8aac9ed5 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java @@ -0,0 +1,124 @@ +package com.iemr.flw.utils; + +import com.iemr.flw.domain.iemr.M_User; +import com.iemr.flw.repo.iemr.EmployeeMasterRepo; +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; +import jakarta.servlet.http.HttpServletRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; + +import java.util.Optional; +import java.util.concurrent.TimeUnit; + +@Component +public class JwtAuthenticationUtil { + + @Autowired + private CookieUtil cookieUtil; + @Autowired + private JwtUtil jwtUtil; + @Autowired + private RedisTemplate redisTemplate; + @Autowired + private EmployeeMasterRepo userLoginRepo; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + public JwtAuthenticationUtil(CookieUtil cookieUtil, JwtUtil jwtUtil) { + this.cookieUtil = cookieUtil; + this.jwtUtil = jwtUtil; + } + + public ResponseEntity validateJwtToken(HttpServletRequest request) { + Optional jwtTokenOpt = cookieUtil.getCookieValue(request, "Jwttoken"); + + if (jwtTokenOpt.isEmpty()) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED) + .body("Error 401: Unauthorized - JWT Token is not set!"); + } + + String jwtToken = jwtTokenOpt.get(); + + // Validate the token + Claims claims = jwtUtil.validateToken(jwtToken); + if (claims == null) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("Error 401: Unauthorized - Invalid JWT Token!"); + } + + // Extract username from token + String usernameFromToken = claims.getSubject(); + if (usernameFromToken == null || usernameFromToken.isEmpty()) { + return ResponseEntity.status(HttpStatus.UNAUTHORIZED) + .body("Error 401: Unauthorized - Username is missing!"); + } + + // Return the username if valid + return ResponseEntity.ok(usernameFromToken); + } + + public boolean validateUserIdAndJwtToken(String jwtToken) throws IEMRException { + try { + // Validate JWT token and extract claims + Claims claims = jwtUtil.validateToken(jwtToken); + + if (claims == null) { + throw new IEMRException("Invalid JWT token."); + } + + String userId = claims.get("userId", String.class); + + // Check if user data is present in Redis + M_User user = getUserFromCache(userId); + if (user == null) { + // If not in Redis, fetch from DB and cache the result + user = fetchUserFromDB(userId); + } + if (user == null) { + throw new IEMRException("Invalid User ID."); + } + + return true; // Valid userId and JWT token + } catch (Exception e) { + logger.error("Validation failed: " + e.getMessage(), e); + throw new IEMRException("Validation error: " + e.getMessage(), e); + } + } + + private M_User getUserFromCache(String userId) { + String redisKey = "user_" + userId; // The Redis key format + M_User user = (M_User) redisTemplate.opsForValue().get(redisKey); + + if (user == null) { + logger.warn("User not found in Redis. Will try to fetch from DB."); + } else { + logger.info("User fetched successfully from Redis."); + } + + return user; // Returns null if not found + } + + private M_User fetchUserFromDB(String userId) { + // This method will only be called if the user is not found in Redis. + String redisKey = "user_" + userId; // Redis key format + + // Fetch user from DB + M_User user = userLoginRepo.getUserByUserID(Integer.parseInt(userId)); + + if (user != null) { + // Cache the user in Redis for future requests (cache for 30 minutes) + redisTemplate.opsForValue().set(redisKey, user, 30, TimeUnit.MINUTES); + + // Log that the user has been stored in Redis + logger.info("User stored in Redis with key: " + redisKey); + } else { + logger.warn("User not found for userId: " + userId); + } + + return user; + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java new file mode 100644 index 00000000..d1eab50e --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -0,0 +1,106 @@ +package com.iemr.flw.utils; + +import jakarta.servlet.*; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +@Component +public class JwtUserIdValidationFilter implements Filter { + + private final JwtAuthenticationUtil jwtAuthenticationUtil; + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + public JwtUserIdValidationFilter(JwtAuthenticationUtil jwtAuthenticationUtil) { + this.jwtAuthenticationUtil = jwtAuthenticationUtil; + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; + + String path = request.getRequestURI(); + String contextPath = request.getContextPath(); + logger.info("JwtUserIdValidationFilter invoked for path: " + path); + + // Log cookies for debugging + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if ("userId".equals(cookie.getName())) { + logger.warn("userId found in cookies! Clearing it..."); + clearUserIdCookie(response); // Explicitly remove userId cookie + } + } + } else { + logger.info("No cookies found in the request"); + } + + // Log headers for debugging + String jwtTokenFromHeader = request.getHeader("Jwttoken"); + logger.info("JWT token from header: "); + + // Skip login and public endpoints + if (path.equals(contextPath + "/user/userAuthenticate") + || path.equalsIgnoreCase(contextPath + "/user/logOutUserFromConcurrentSession") + || path.startsWith(contextPath + "/public")) { + logger.info("Skipping filter for path: " + path); + filterChain.doFilter(servletRequest, servletResponse); + return; + } + + try { + // Retrieve JWT token from cookies + String jwtTokenFromCookie = getJwtTokenFromCookies(request); + logger.info("JWT token from cookie: "); + + // Determine which token (cookie or header) to validate + String jwtToken = jwtTokenFromCookie != null ? jwtTokenFromCookie : jwtTokenFromHeader; + if (jwtToken == null) { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "JWT token not found in cookies or headers"); + return; + } + + // Validate JWT token and userId + boolean isValid = jwtAuthenticationUtil.validateUserIdAndJwtToken(jwtToken); + + if (isValid) { + // If token is valid, allow the request to proceed + filterChain.doFilter(servletRequest, servletResponse); + } else { + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid JWT token"); + } + } catch (Exception e) { + logger.error("Authorization error: ", e); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: "); + } + } + + private String getJwtTokenFromCookies(HttpServletRequest request) { + Cookie[] cookies = request.getCookies(); + if (cookies != null) { + for (Cookie cookie : cookies) { + if (cookie.getName().equals("Jwttoken")) { + return cookie.getValue(); + } + } + } + return null; + } + + private void clearUserIdCookie(HttpServletResponse response) { + Cookie cookie = new Cookie("userId", null); + cookie.setPath("/"); + cookie.setHttpOnly(true); + cookie.setSecure(true); + cookie.setMaxAge(0); // Invalidate the cookie + response.addCookie(cookie); + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUtil.java b/src/main/java/com/iemr/flw/utils/JwtUtil.java new file mode 100644 index 00000000..7ef67e55 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/JwtUtil.java @@ -0,0 +1,83 @@ +package com.iemr.flw.utils; + +import com.iemr.flw.utils.exception.IEMRException; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.jsonwebtoken.security.Keys; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.security.Key; +import java.util.Date; +import java.util.function.Function; + +@Component +public class JwtUtil { + + @Value("${jwt.secret}") + private String SECRET_KEY; + + private static final long EXPIRATION_TIME = 24L * 60 * 60 * 1000; // 1 day in milliseconds + + // Generate a key using the secret + private Key getSigningKey() { + if (SECRET_KEY == null || SECRET_KEY.isEmpty()) { + throw new IllegalStateException("JWT secret key is not set in application.properties"); + } + return Keys.hmacShaKeyFor(SECRET_KEY.getBytes()); + } + + // Generate JWT Token + public String generateToken(String username, String userId) { + Date now = new Date(); + Date expiryDate = new Date(now.getTime() + EXPIRATION_TIME); + + // Include the userId in the JWT claims + return Jwts.builder().setSubject(username).claim("userId", userId) // Add userId as a claim + .setIssuedAt(now).setExpiration(expiryDate).signWith(getSigningKey(), SignatureAlgorithm.HS256) + .compact(); + } + + // Validate and parse JWT Token + public Claims validateToken(String token) { + try { + return Jwts.parser().setSigningKey(getSigningKey()).build().parseClaimsJws(token).getBody(); + } catch (Exception e) { + return null; // Handle token parsing/validation errors + } + } + + public Integer extractUserId(String jwtToken) throws IEMRException { + try { + // Validate JWT token and extract claims + Claims claims = validateToken(jwtToken); + + if (claims == null) { + throw new IEMRException("Invalid JWT token."); + } + + String userId = claims.get("userId", String.class); + + return Integer.parseInt(userId); + + } catch (Exception e) { + throw new IEMRException("Validation error: " + e.getMessage(), e); + } + + + } + + public String extractUsername(String token) { + return extractClaim(token, Claims::getSubject); + } + + public T extractClaim(String token, Function claimsResolver) { + final Claims claims = extractAllClaims(token); + return claimsResolver.apply(claims); + } + + private Claims extractAllClaims(String token) { + return Jwts.parser().setSigningKey(getSigningKey()).build().parseClaimsJws(token).getBody(); + } +} From c56caee42da21c40ed5366ecbd4b4c1137885855 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Mar 2025 15:47:51 +0530 Subject: [PATCH 067/792] Implement jwt token in getAll MicroBirthPlan --- pom.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pom.xml b/pom.xml index b627d253..a89c197f 100644 --- a/pom.xml +++ b/pom.xml @@ -134,6 +134,22 @@ jackson-datatype-joda 2.17.0 + + + + + io.jsonwebtoken + jjwt-api + 0.12.6 + + + + io.jsonwebtoken + jjwt-impl + 0.12.6 + runtime + + From 69e12a48ee18e142cf41b76dc4fe9a6a43c61039 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Mar 2025 15:59:51 +0530 Subject: [PATCH 068/792] Implement jwt token in AshaProfileController --- .../com/iemr/flw/service/impl/AshaProfileImpl.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 67b935ca..f6dc44ba 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -59,17 +59,14 @@ public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { public AshaWorker getProfileData(String authorization) { try { - Objects.requireNonNull(jwtUtil.extractUserId(authorization), "employeeId must not be null"); - return ashaProfileRepo.findByEmployeeId(jwtUtil.extractUserId(authorization)) + Integer userId = jwtUtil.extractUserId(authorization); + + Objects.requireNonNull(userId, "employeeId must not be null"); + return ashaProfileRepo.findByEmployeeId(userId) .orElseGet(() -> { - try { - return getDetails(jwtUtil.extractUserId(authorization)); - } catch (IEMRException e) { - throw new RuntimeException(e); - } + return getDetails(userId); }); } catch (Exception e) { - logger.error("Error retrieving ASHA worker profile for employeeId {}: {}", getProfileData(authorization), e.getMessage(), e); throw new RuntimeException("Failed to retrieve ASHA worker profile", e); } } From 5f78208f478cfc4bef433730a5337f2d96cf40a8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Mar 2025 16:02:29 +0530 Subject: [PATCH 069/792] Implement jwt token in getAll MicroBirthPlan --- .../flw/controller/MicroBirthPlanController.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index b5478529..c62138b9 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -62,11 +62,15 @@ public ResponseEntity> getAllMicroBirthPlans(@RequestHeader( Map data = new HashMap<>(); try { - data.put("userId", jwtUtil.extractUserId(authorization)); - data.put("entries", service.getAllMicroBirthPlans(jwtUtil.extractUserId(authorization))); - response.put("data", data); - response.put("statusCode", 200); - response.put("status", "Success"); + Integer userID = jwtUtil.extractUserId(authorization); + if (userID != null) { + data.put("userId", userID); + data.put("entries", service.getAllMicroBirthPlans(userID)); + response.put("data", data); + response.put("statusCode", 200); + response.put("status", "Success"); + } + } catch (Exception e) { response.put("statusCode", 500); response.put("errorMessage", e.getMessage()); From 3dfa85f49333a278408a91e8ed784e5d3c059e4c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Mar 2025 11:03:46 +0530 Subject: [PATCH 070/792] Implement jwt token in getAll MicroBirthPlan --- .../java/com/iemr/flw/controller/MicroBirthPlanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index c62138b9..796e74f3 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -54,7 +54,7 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic } - @RequestMapping(value = "getAll", method = RequestMethod.POST) + @RequestMapping(value = "getAll", method = RequestMethod.GET) public ResponseEntity> getAllMicroBirthPlans(@RequestHeader(value = "Authorization") String authorization) { Map response = new HashMap<>(); From c5885b5fc1ad0af5532735e522b09249022f297b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 31 Mar 2025 11:00:03 +0530 Subject: [PATCH 071/792] update asha profile code --- src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java | 10 ++++++++++ .../com/iemr/flw/service/impl/AshaProfileImpl.java | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java index 5cf5bfd1..86358be0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AshaWorker.java @@ -97,4 +97,14 @@ public class AshaWorker { @Column(name = "ProviderServiceMapID") private Integer ProviderServiceMapID; + + @Column(name = "profileImage") + private String profileImage; + + @Column(name = "isFatherOrSpouse") + private Boolean isFatherOrSpouse; + @Column(name = "supervisorName") + private String supervisorName; + @Column(name = "supervisorMobile") + private String supervisorMobile; } diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index b3804c83..aff8136f 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -109,6 +109,10 @@ private AshaWorker updateProfile(AshaWorker editAshaWorkerRequest) { editdata.setAnm2Mobile(editAshaWorkerRequest.getAnm2Mobile()); // Corrected line editdata.setAwwMobile(editAshaWorkerRequest.getAwwMobile()); editdata.setProviderServiceMapID(editAshaWorkerRequest.getProviderServiceMapID()); + editdata.setProfileImage(editAshaWorkerRequest.getProfileImage()); + editdata.setIsFatherOrSpouse(editAshaWorkerRequest.getIsFatherOrSpouse()); + editdata.setSupervisorName(editAshaWorkerRequest.getSupervisorName()); + editdata.setSupervisorMobile(editAshaWorkerRequest.getSupervisorMobile()); return editdata; } catch (Exception e) { From eb443bdb449d3503c68324e8c384e04807de406e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 31 Mar 2025 12:34:22 +0530 Subject: [PATCH 072/792] update disease control --- .../controller/DiseaseControlController.java | 3 +- .../iemr/flw/dto/iemr/DiseaseControlDTO.java | 40 ++----------------- .../flw/service/DiseaseControlService.java | 2 +- .../impl/DiseaseControlServiceImpl.java | 8 ++-- 4 files changed, 10 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index badaecd9..55813988 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -20,12 +20,11 @@ public class DiseaseControlController { private DiseaseControlService diseaseControlService; @RequestMapping(value = "saveAll", method = RequestMethod.POST,consumes = "application/json",produces = "application/json") - public ResponseEntity> saveDiseaseData(@RequestBody List diseaseControlDTO) { + public ResponseEntity> saveDiseaseData(@RequestBody DiseaseControlDTO diseaseControlDTO) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.save(diseaseControlDTO)); - diseaseControlService.save(diseaseControlDTO); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java index c8d9367d..301fec04 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java @@ -1,49 +1,17 @@ package com.iemr.flw.dto.iemr; +import com.iemr.flw.domain.iemr.DiseaseControl; import lombok.Data; import java.math.BigInteger; import java.sql.Timestamp; +import java.util.List; @Data public class DiseaseControlDTO { - private Integer id; - private Long benId; - private Timestamp caseDate; + Integer userId; + List diseaseControlList; - private String caseStatus; - - private String symptoms; - - private int malariaCaseCount; - - private Integer referredTo; - - private String otherReferredTo; - - private Timestamp malariaCaseStatusDate; - - private String remarks; - - private Integer followUpPoint; - - private Timestamp followUpDate; - - private String status; - - private String otherStatus; - - private String bodyPart; - - private Boolean sufferingFromFilariasis; - - private Timestamp homeVisitDate; - - private Timestamp LeprosyStatusDate; - - private String MedicineSideEffect; - - private BigInteger diseaseTypeId; } diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 3b692efe..b1dd45c3 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -7,6 +7,6 @@ import java.util.List; public interface DiseaseControlService { - public String save(List diseaseControlDTO); + public String save(DiseaseControlDTO diseaseControlDTO); public List getAll(); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 8dceabf4..f3c64de0 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -15,8 +15,8 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { private DiseaseControlRepo diseaseControlRepo; @Override - public String save(List diseaseControlDTO) { - for(DiseaseControlDTO diseaseControlData: diseaseControlDTO){ + public String save(DiseaseControlDTO diseaseControlDTO) { + for(DiseaseControl diseaseControlData: diseaseControlDTO.getDiseaseControlList()){ if(diseaseControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()){ return update(diseaseControlData); }else { @@ -35,7 +35,7 @@ public List getAll() { return diseaseControlRepo.findAll(); } - private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ + private DiseaseControl saveData(DiseaseControl diseaseControlDTO){ DiseaseControl diseaseControl = new DiseaseControl(); diseaseControl.setBenId(diseaseControlDTO.getBenId()); diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added @@ -59,7 +59,7 @@ private DiseaseControl saveData(DiseaseControlDTO diseaseControlDTO){ return diseaseControl; } - private String update(DiseaseControlDTO diseaseControlDTO){ + private String update(DiseaseControl diseaseControlDTO){ return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); From d3e5b5d6b07d622de6f4d5c54e6138298acde03e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 1 Apr 2025 13:25:56 +0530 Subject: [PATCH 073/792] update disease control --- .../controller/DiseaseControlController.java | 68 +++++- .../com/iemr/flw/domain/iemr/AesJeData.java | 34 +++ .../com/iemr/flw/domain/iemr/FilariaData.java | 44 ++++ .../iemr/flw/domain/iemr/KalaAzarData.java | 57 +++++ .../com/iemr/flw/domain/iemr/LeprosyData.java | 55 +++++ .../com/iemr/flw/domain/iemr/MalariaData.java | 57 +++++ .../java/com/iemr/flw/dto/iemr/AesJeDTO.java | 13 + .../com/iemr/flw/dto/iemr/FilariaDTO.java | 13 + .../com/iemr/flw/dto/iemr/KalaAzarDTO.java | 13 + .../com/iemr/flw/dto/iemr/LeprosyDTO.java | 16 ++ .../com/iemr/flw/dto/iemr/MalariaDTO.java | 18 ++ .../iemr/flw/repo/iemr/AesJeControlRepo.java | 14 ++ .../flw/repo/iemr/FilariaControlRepo.java | 14 ++ .../flw/repo/iemr/KalazarControlRepo.java | 14 ++ .../flw/repo/iemr/LeprosyControlRepo.java | 14 ++ .../flw/repo/iemr/MalariaControlRepo.java | 14 ++ .../flw/service/DiseaseControlService.java | 10 +- .../impl/DiseaseControlServiceImpl.java | 227 ++++++++++++++++-- 18 files changed, 669 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/AesJeData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/FilariaData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MalariaData.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 55813988..c0a1c502 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -1,41 +1,91 @@ package com.iemr.flw.controller; -import com.iemr.flw.dto.iemr.DiseaseControlDTO; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.DiseaseControlService; +import org.apache.commons.lang3.function.Failable; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.repository.query.Param; import org.springframework.http.ResponseEntity; 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.RestController; +import java.math.BigInteger; import java.util.HashMap; import java.util.List; import java.util.Map; @RestController -@RequestMapping(value = "/disease" ,headers = "Authorization") +@RequestMapping(value = "/disease", headers = "Authorization") public class DiseaseControlController { @Autowired private DiseaseControlService diseaseControlService; - @RequestMapping(value = "saveAll", method = RequestMethod.POST,consumes = "application/json",produces = "application/json") - public ResponseEntity> saveDiseaseData(@RequestBody DiseaseControlDTO diseaseControlDTO) { + + + @RequestMapping(value = "Malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public ResponseEntity> saveMalaria(@RequestBody MalariaDTO malariaDTO) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveMalaria(malariaDTO)); + + return ResponseEntity.ok(response); + + } + + @RequestMapping(value = "KalaAzar/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public ResponseEntity> saveMalaria(@RequestBody KalaAzarDTO kalaAzarDTO) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); + + return ResponseEntity.ok(response); + + } + + @RequestMapping(value = "AesJe/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public ResponseEntity> saveMalaria(@RequestBody AesJeDTO aesJeDTO) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", diseaseControlService.save(diseaseControlDTO)); + response.put("data", diseaseControlService.saveAES(aesJeDTO)); return ResponseEntity.ok(response); + + } + + @RequestMapping(value = "Filaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public ResponseEntity> saveMalaria(@RequestBody FilariaDTO filariaDTO) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveFilaria(filariaDTO)); + + return ResponseEntity.ok(response); + } - @RequestMapping(value = "getAll",method = RequestMethod.GET,produces = "application/json") - public ResponseEntity> getAllData(){ + @RequestMapping(value = "Leprosy/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + public ResponseEntity> saveMalaria(@RequestBody LeprosyDTO leprosyDTO) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", diseaseControlService.getAll()); - return ResponseEntity.ok(response); + response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); + + return ResponseEntity.ok(response); + + } + + @RequestMapping(value = "getAll", method = RequestMethod.GET, produces = "application/json") + public ResponseEntity> getAllData(@Param("diseaseTypeID") BigInteger diseaseTypeID) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.getAll(diseaseTypeID)); + return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java b/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java new file mode 100644 index 00000000..f124485a --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java @@ -0,0 +1,34 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "disease_aesje",schema = "db_iemr") +public class AesJeData { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private BigInteger id; + + @Column(name = "case_date") + private Date caseDate; + + @Column(name = "aesje_case_status") + private Boolean aesjeCaseStatus; + + @Column(name = "referred_to") + private Integer referredTo; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeID; + + @Column(name = "ben_id") + private BigInteger benId; + + @Column(name = "userID") + Integer userID; +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java b/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java new file mode 100644 index 00000000..e785a1e3 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java @@ -0,0 +1,44 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "disease_filariasis",schema = "db_iemr") +public class FilariaData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private BigInteger id; + + @Column(name = "suffering_from_filariasis") + private Boolean sufferingFromFilariasis; + + @Column(name = "which_part_of_body") + private String whichPartOfBody; + + @Column(name = "home_visit_date") + private Date homeVisitDate; + + @Column(name = "dec_and_albendazole_dose_status") + private String decAndAlbendazoleDoseStatus; + + @Column(name = "medicine_side_effect") + private String medicineSideEffect; + + @Column(name = "other") + private String other; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeID; + + @Column(name = "ben_id") + private BigInteger benId; + @Column(name = "userID") + Integer userID; +} + diff --git a/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java b/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java new file mode 100644 index 00000000..2e33b221 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java @@ -0,0 +1,57 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "disease_kalaazar",schema = "db_iemr") +public class KalaAzarData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "ben_id") + BigInteger benId; + + @Column(name = "case_date") + private Date caseDate; + + @Column(name = "case_status", length = 225) + private String caseStatus; + + @Column(name = "symptoms", length = 225) + private String symptoms; + + @Column(name = "malaria_case_count", length = 225) + private String malariaCaseCount; + + @Column(name = "referred_to") + private Long referredTo; + + @Column(name = "kalaAzar_case_status_date") + private Date kalaAzarCaseStatusDate; + + @Column(name = "remarks", length = 225) + private String remarks; + + @Column(name = "follow_up_point", length = 225) + private String followUpPoint; + + @Column(name = "follow_up_date") + private Date followUpDate; + + @Column(name = "disease_status", length = 22) + private String status; + + @Column(name = "DiseaseTypeID") + Integer diseaseTypeID; + + @Column(name = "userID") + Integer userID; + +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java b/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java new file mode 100644 index 00000000..56e5496a --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java @@ -0,0 +1,55 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Date; + + + +@Entity +@Data +@Table(name = "disease_leprosy",schema = "db_iemr") +public class LeprosyData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "date_of_home_visit") + private Date dateOfHomeVisit; + + @Column(name = "leprosy_status") + private String leprosyStatus; + + @Column(name = "referred_to") + private Integer referredTo; + + @Column(name = "other") + private String other; + + @Column(name = "leprosy_status_date") + private Date leprosyStatusDate; + + @Column(name = "type_of_leprosy") + private String typeOfLeprosy; + + @Column(name = "follow_up_date") + private String followUpDate; + + @Column(name = "status") + private String status; + + @Column(name = "remark") + private String remark; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeID; + + @Column(name = "ben_id") + private BigInteger benId; + @Column(name = "userID") + Integer userID; +} + diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java new file mode 100644 index 00000000..1217142d --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java @@ -0,0 +1,57 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "disease_malaria",schema = "db_iemr") +public class MalariaData { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + Integer id; + @Column(name = "ben_id") + BigInteger benId; + + @Column(name = "case_date") + Date caseDate; + + @Column(name = "case_status") + String caseStatus; + + @Column(name = "symptoms") + String symptoms; + + @Column(name = "malaria_case_count") + String malariaCaseCount; + + @Column(name = "referred_to") + Integer ReferredTo; + + @Column(name = "malaria_case_status_date") + Date malariaCaseStatusDate; + + @Column(name = "remarks") + String Remarks; + + @Column(name = "follow_up") + Integer followUp; + + @Column(name = "irs_date") + Date irsDate; + + @Column(name = "rounds") + Integer rounds; + + @Column(name = "DiseaseTypeID") + Integer diseaseTypeID; + + @Column(name = "userID") + Integer userID; +} + + + diff --git a/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java new file mode 100644 index 00000000..45ca7244 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.AesJeData; +import lombok.Data; + +import java.sql.Date; +import java.util.List; +@Data +public class AesJeDTO { + Integer userId; + List aesJeLists; +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java new file mode 100644 index 00000000..5670a60f --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.FilariaData; +import lombok.Data; + +import java.sql.Date; +import java.util.List; +@Data +public class FilariaDTO { + Integer userId; + List filariaLists; +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java new file mode 100644 index 00000000..b3aa2045 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.KalaAzarData; +import lombok.Data; + +import java.sql.Date; +import java.util.List; +@Data +public class KalaAzarDTO { + Integer userId; + List kalaAzarLists; +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java new file mode 100644 index 00000000..4ccf523c --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.LeprosyData; +import lombok.Data; + +import java.sql.Date; +import java.util.List; +@Data +public class LeprosyDTO { + Integer userId; + List leprosyLists; + + + +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java new file mode 100644 index 00000000..2f9b19b9 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java @@ -0,0 +1,18 @@ +package com.iemr.flw.dto.iemr; + + +import com.iemr.flw.domain.iemr.MalariaData; +import lombok.Data; + +import java.sql.Date; +import java.util.List; +@Data +public class MalariaDTO { + Integer userId; + List malariaLists; + + + +} + + diff --git a/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java new file mode 100644 index 00000000..68714ccc --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.AesJeData; +import com.iemr.flw.domain.iemr.KalaAzarData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface AesJeControlRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java new file mode 100644 index 00000000..324d0c4e --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.FilariaData; +import com.iemr.flw.domain.iemr.KalaAzarData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface FilariaControlRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java new file mode 100644 index 00000000..f2c744c5 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.KalaAzarData; +import com.iemr.flw.domain.iemr.MalariaData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface KalazarControlRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java new file mode 100644 index 00000000..366cce84 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.KalaAzarData; +import com.iemr.flw.domain.iemr.LeprosyData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface LeprosyControlRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java new file mode 100644 index 00000000..64d94e88 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseControl; +import com.iemr.flw.domain.iemr.MalariaData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface MalariaControlRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index b1dd45c3..09df3353 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -1,12 +1,18 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.DiseaseControl; -import com.iemr.flw.dto.iemr.DiseaseControlDTO; +import com.iemr.flw.dto.iemr.*; import org.apache.commons.collections4.Put; +import java.math.BigInteger; import java.util.List; public interface DiseaseControlService { public String save(DiseaseControlDTO diseaseControlDTO); - public List getAll(); + public String saveMalaria(MalariaDTO diseaseControlDTO); + public String saveKalaAzar(KalaAzarDTO diseaseControlDTO); + public String saveAES(AesJeDTO diseaseControlDTO); + public String saveFilaria(FilariaDTO diseaseControlDTO); + public String saveLeprosy(LeprosyDTO diseaseControlDTO); + public List getAll(BigInteger diseaseTypeID); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index f3c64de0..037f65e5 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1,41 +1,145 @@ package com.iemr.flw.service.impl; -import com.iemr.flw.domain.iemr.DiseaseControl; -import com.iemr.flw.dto.iemr.DiseaseControlDTO; -import com.iemr.flw.repo.iemr.DiseaseControlRepo; +import com.iemr.flw.domain.iemr.*; +import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; +import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.math.BigInteger; import java.util.List; +import java.util.stream.Collectors; @Service public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private DiseaseControlRepo diseaseControlRepo; + @Autowired + private MalariaControlRepo malariaControlRepo; + + @Autowired + private KalazarControlRepo kalazarControlRepo; + + @Autowired + private AesJeControlRepo aesJeControlRepo; + + @Autowired + private FilariaControlRepo filariaControlRepo; + @Autowired + private LeprosyControlRepo leprosyControlRepo; @Override public String save(DiseaseControlDTO diseaseControlDTO) { - for(DiseaseControl diseaseControlData: diseaseControlDTO.getDiseaseControlList()){ - if(diseaseControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()){ - return update(diseaseControlData); - }else { + for (DiseaseControl diseaseControlData : diseaseControlDTO.getDiseaseControlList()) { + if (diseaseControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return update(diseaseControlData); + } else { + diseaseControlRepo.save(saveData(diseaseControlData)); - return "Data add successfully"; + return "Data add successfully"; + + } + } + return "Fail"; + + + } + + @Override + public String saveMalaria(MalariaDTO diseaseControlDTO) { + for (MalariaData diseaseControlData : diseaseControlDTO.getMalariaLists()) { + if (malariaControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateMalaria(diseaseControlData); + } else { + if(diseaseControlDTO.getUserId()!=null){ + diseaseControlData.setUserID(diseaseControlData.getUserID()); + } + malariaControlRepo.save(diseaseControlData); + return "Data add successfully"; } } return "Fail"; + } + @Override + public String saveKalaAzar(KalaAzarDTO diseaseControlDTO) { + for (KalaAzarData diseaseControlData : diseaseControlDTO.getKalaAzarLists()) { + if (kalazarControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateKalaAzar(diseaseControlData); + } else { + if(diseaseControlDTO.getUserId()!=null){ + diseaseControlData.setUserID(diseaseControlData.getUserID()); + } + kalazarControlRepo.save(diseaseControlData); + return "Data add successfully"; + + } + } + return "Fail"; + } @Override - public List getAll() { - return diseaseControlRepo.findAll(); + public String saveAES(AesJeDTO diseaseControlDTO) { + for (AesJeData diseaseControlData : diseaseControlDTO.getAesJeLists()) { + if (aesJeControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateAesJe(diseaseControlData); + } else { + if(diseaseControlDTO.getUserId()!=null){ + diseaseControlData.setUserID(diseaseControlData.getUserID()); + } + aesJeControlRepo.save(diseaseControlData); + return "Data add successfully"; + + } + } + return "Fail"; } - private DiseaseControl saveData(DiseaseControl diseaseControlDTO){ + @Override + public String saveFilaria(FilariaDTO diseaseControlDTO) { + for (FilariaData diseaseControlData : diseaseControlDTO.getFilariaLists()) { + if (filariaControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateFilaria(diseaseControlData); + } else { + if(diseaseControlDTO.getUserId()!=null){ + diseaseControlData.setUserID(diseaseControlData.getUserID()); + } + filariaControlRepo.save(diseaseControlData); + return "Data add successfully"; + + } + } + return "Fail"; + } + + @Override + public String saveLeprosy(LeprosyDTO diseaseControlDTO) { + for (LeprosyData diseaseControlData : diseaseControlDTO.getLeprosyLists()) { + if (leprosyControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateLeprosy(diseaseControlData); + } else { + if(diseaseControlDTO.getUserId()!=null){ + diseaseControlData.setUserID(diseaseControlData.getUserID()); + } + leprosyControlRepo.save(diseaseControlData); + return "Data add successfully"; + + } + } + return "Fail"; + } + + @Override + public List getAll(BigInteger diseaseTypeID) { + return diseaseControlRepo.findAll().stream().filter(diseaseControl -> diseaseControl.getDiseaseTypeId()==diseaseTypeID).collect(Collectors.toList()); + } + + private DiseaseControl saveData(DiseaseControl diseaseControlDTO) { DiseaseControl diseaseControl = new DiseaseControl(); diseaseControl.setBenId(diseaseControlDTO.getBenId()); diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added @@ -59,8 +163,101 @@ private DiseaseControl saveData(DiseaseControl diseaseControlDTO){ return diseaseControl; } - private String update(DiseaseControl diseaseControlDTO){ - return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { + + private String updateMalaria(MalariaData updatedMalariaData) { + return malariaControlRepo.findByBenId(updatedMalariaData.getBenId()).map(malariaData -> { + malariaData.setId(updatedMalariaData.getId()); + malariaData.setBenId(updatedMalariaData.getBenId()); + malariaData.setIrsDate(updatedMalariaData.getIrsDate()); + malariaData.setFollowUp(updatedMalariaData.getFollowUp()); + malariaData.setRounds(updatedMalariaData.getRounds()); + malariaData.setRemarks(updatedMalariaData.getRemarks()); + malariaData.setMalariaCaseCount(updatedMalariaData.getMalariaCaseCount()); + malariaData.setMalariaCaseStatusDate(updatedMalariaData.getMalariaCaseStatusDate()); + malariaControlRepo.save(malariaData); + return "Data update successfully"; + + }).orElseThrow(() -> new RuntimeException("Data not found")); + } + + private String updateKalaAzar(KalaAzarData updatedData) { + return kalazarControlRepo.findByBenId(updatedData.getBenId()).map(kalaAzarData -> { + kalaAzarData.setId(updatedData.getId()); + kalaAzarData.setBenId(updatedData.getBenId()); + kalaAzarData.setCaseDate(updatedData.getCaseDate()); + kalaAzarData.setCaseStatus(updatedData.getCaseStatus()); + kalaAzarData.setSymptoms(updatedData.getSymptoms()); + kalaAzarData.setMalariaCaseCount(updatedData.getMalariaCaseCount()); + kalaAzarData.setReferredTo(updatedData.getReferredTo()); + kalaAzarData.setKalaAzarCaseStatusDate(updatedData.getKalaAzarCaseStatusDate()); + kalaAzarData.setRemarks(updatedData.getRemarks()); + kalaAzarData.setFollowUpPoint(updatedData.getFollowUpPoint()); + kalaAzarData.setFollowUpDate(updatedData.getFollowUpDate()); + kalaAzarData.setStatus(updatedData.getStatus()); + kalazarControlRepo.save(kalaAzarData); + return "Data updated successfully"; + }).orElseThrow(() -> new RuntimeException("Data not found")); + } + private String updateLeprosy(LeprosyData updateData) { + return leprosyControlRepo.findByBenId(updateData.getBenId()).map(leprosyData -> { + leprosyData.setId(updateData.getId()); + leprosyData.setDateOfHomeVisit(updateData.getDateOfHomeVisit()); + leprosyData.setLeprosyStatus(updateData.getLeprosyStatus()); + leprosyData.setReferredTo(updateData.getReferredTo()); + leprosyData.setOther(updateData.getOther()); + leprosyData.setLeprosyStatusDate(updateData.getLeprosyStatusDate()); + leprosyData.setTypeOfLeprosy(updateData.getTypeOfLeprosy()); + leprosyData.setFollowUpDate(updateData.getFollowUpDate()); + leprosyData.setStatus(updateData.getStatus()); + leprosyData.setRemark(updateData.getRemark()); + leprosyData.setDiseaseTypeID(updateData.getDiseaseTypeID()); + leprosyData.setBenId(updateData.getBenId()); + + leprosyControlRepo.save(leprosyData); + + return "Data updated successfully"; + }).orElseThrow(() -> new RuntimeException("Data not found")); + } + + private String updateAesJe(AesJeData updateData) { + return aesJeControlRepo.findByBenId(updateData.getBenId()).map(aesJeData -> { + aesJeData.setId(updateData.getId()); + aesJeData.setCaseDate(updateData.getCaseDate()); + aesJeData.setAesjeCaseStatus(updateData.getAesjeCaseStatus()); + aesJeData.setReferredTo(updateData.getReferredTo()); + aesJeData.setDiseaseTypeID(updateData.getDiseaseTypeID()); + aesJeData.setBenId(updateData.getBenId()); + + // Save the updated data (if required, depending on your repo) + aesJeControlRepo.save(aesJeData); + + return "Data updated successfully"; + }).orElseThrow(() -> new RuntimeException("Data not found")); + } + + private String updateFilaria(FilariaData updateData) { + return filariaControlRepo.findByBenId(updateData.getBenId()).map(filariaData -> { + filariaData.setId(updateData.getId()); + filariaData.setSufferingFromFilariasis(updateData.getSufferingFromFilariasis()); + filariaData.setWhichPartOfBody(updateData.getWhichPartOfBody()); + filariaData.setHomeVisitDate(updateData.getHomeVisitDate()); + filariaData.setDecAndAlbendazoleDoseStatus(updateData.getDecAndAlbendazoleDoseStatus()); + filariaData.setMedicineSideEffect(updateData.getMedicineSideEffect()); + filariaData.setOther(updateData.getOther()); + filariaData.setDiseaseTypeID(updateData.getDiseaseTypeID()); + filariaData.setBenId(updateData.getBenId()); + + // Save the updated data (if required, depending on your repo) + filariaControlRepo.save(filariaData); + + return "Data updated successfully"; + }).orElseThrow(() -> new RuntimeException("Data not found")); + } + + + + private String update(DiseaseControl diseaseControlDTO) { + return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); @@ -81,10 +278,10 @@ private String update(DiseaseControl diseaseControlDTO){ diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); diseaseControl.setDiseaseTypeId(diseaseControlDTO.getDiseaseTypeId()); diseaseControlRepo.save(diseaseControl); - + return "Data update successfully"; - }).orElseThrow(()->new RuntimeException("Data not found")); + }).orElseThrow(() -> new RuntimeException("Data not found")); } } From 4e69b351c0d4a0b6a656e31c6ecfe36d55915e89 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 1 Apr 2025 15:32:32 +0530 Subject: [PATCH 074/792] adolesencent health --- .../AdolescentHealthController.java | 45 ++++++++++++ .../flw/domain/iemr/AdolescentHealth.java | 68 +++++++++++++++++++ .../flw/dto/iemr/AdolescentHealthDTO.java | 11 +++ .../flw/repo/iemr/AdolescentHealthRepo.java | 13 ++++ .../flw/service/AdolescentHealthService.java | 10 +++ .../impl/AdolescentHealthServiceImpl.java | 59 ++++++++++++++++ 6 files changed, 206 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/AdolescentHealthController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java create mode 100644 src/main/java/com/iemr/flw/service/AdolescentHealthService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java new file mode 100644 index 00000000..492359df --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java @@ -0,0 +1,45 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.AdolescentHealthDTO; +import com.iemr.flw.service.AdolescentHealthService; +import com.iemr.flw.utils.response.OutputResponse; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +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.RestController; + + +@RestController +@RequestMapping(value = "/adolescentHealth", headers = "Authorization") + +public class AdolescentHealthController { + private final org.slf4j.Logger logger = LoggerFactory.getLogger(AdolescentHealthController.class); + + @Autowired + private AdolescentHealthService adolescentHealthService; + + @RequestMapping(name = "/savAll", method = RequestMethod.POST) + public String saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHealthDTO) { + OutputResponse response = new OutputResponse(); + response.setResponse(adolescentHealthService.saveAll(adolescentHealthDTO)); + try { + if (adolescentHealthDTO.getAdolescentHealths().size() != 0) { + String result = adolescentHealthService.saveAll(adolescentHealthDTO); + if (result != null) { + response.setResponse(result); + + } + + } else + response.setError(500, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in get data : " + e); + response.setError(500, "Error in get data : " + e); + } + return response.toString(); + + } + +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java new file mode 100644 index 00000000..78c71f60 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java @@ -0,0 +1,68 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "adolescent_health") +public class AdolescentHealth { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "ben_id") + private BigInteger benId; + + @Column(name = "userID") + private Long userID; + + @Column(name = "visit_date") + private Date visitDate; + + @Column(name = "health_status") + private String healthStatus; + + @Column(name = "ifa_tablet_distribution") + private Boolean ifaTabletDistribution; + + @Column(name = "quantity_of_ifa_tablets") + private Integer quantityOfIfaTablets; + + @Column(name = "menstrual_hygiene_awareness_given") + private Boolean menstrualHygieneAwarenessGiven; + + @Column(name = "sanitary_napkin_distributed") + private Boolean sanitaryNapkinDistributed; + + @Column(name = "no_of_packets_distributed") + private Integer noOfPacketsDistributed; + + @Column(name = "place") + private String place; + + @Column(name = "referred_to_health_facility") + private String referredToHealthFacility; + + @Column(name = "counseling_provided") + private Boolean counselingProvided; + + @Column(name = "counseling_type") + private String counselingType; + + @Column(name = "follow_up_date") + private Date followUpDate; + + @Column(name = "referral_status") + private String referralStatus; + + @Column(name = "incentive_amount") + private BigDecimal incentiveAmount; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java new file mode 100644 index 00000000..e7df0e41 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.AdolescentHealth; +import lombok.Data; + +import java.util.List; +@Data +public class AdolescentHealthDTO { + Integer userId; + List adolescentHealths; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java new file mode 100644 index 00000000..f52967d4 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.AdolescentHealth; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface AdolescentHealthRepo extends JpaRepository { + Optional findByBenId(BigInteger benId); +} diff --git a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java new file mode 100644 index 00000000..df8aaa1c --- /dev/null +++ b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java @@ -0,0 +1,10 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.AdolescentHealthDTO; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +public interface AdolescentHealthService { + String saveAll(AdolescentHealthDTO adolescentHealthDTO); +} diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java new file mode 100644 index 00000000..1afde982 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -0,0 +1,59 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.AdolescentHealth; +import com.iemr.flw.dto.iemr.AdolescentHealthDTO; +import com.iemr.flw.repo.iemr.AdolescentHealthRepo; +import com.iemr.flw.service.AdolescentHealthService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Optional; + +@Service +public class AdolescentHealthServiceImpl implements AdolescentHealthService { + @Autowired + private AdolescentHealthRepo adolescentHealthRepo; + + @Override + public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { + for (AdolescentHealth adolescentHealth : adolescentHealthDTO.getAdolescentHealths()) { + // Check if a record with the same benId already exists in the database + Optional existingRecord = adolescentHealthRepo.findByBenId(adolescentHealth.getBenId()); + + if (existingRecord.isPresent()) { + // If record exists, update the existing one + updateAdolescentHealth(existingRecord,adolescentHealth); + } else { + // If the record does not exist, create a new one + adolescentHealthRepo.save(adolescentHealth); + } + } + + return "Records updated/added successfully!"; + } + + private void updateAdolescentHealth(Optional existingRecord, AdolescentHealth adolescentHealth) { + AdolescentHealth existingAdolescentHealth = existingRecord.get(); + + // Update fields of the existing record with values from the DTO + existingAdolescentHealth.setUserID(adolescentHealth.getUserID()); + existingAdolescentHealth.setVisitDate(adolescentHealth.getVisitDate()); + existingAdolescentHealth.setHealthStatus(adolescentHealth.getHealthStatus()); + existingAdolescentHealth.setIfaTabletDistribution(adolescentHealth.getIfaTabletDistribution()); + existingAdolescentHealth.setQuantityOfIfaTablets(adolescentHealth.getQuantityOfIfaTablets()); + existingAdolescentHealth.setMenstrualHygieneAwarenessGiven(adolescentHealth.getMenstrualHygieneAwarenessGiven()); + existingAdolescentHealth.setSanitaryNapkinDistributed(adolescentHealth.getSanitaryNapkinDistributed()); + existingAdolescentHealth.setNoOfPacketsDistributed(adolescentHealth.getNoOfPacketsDistributed()); + existingAdolescentHealth.setPlace(adolescentHealth.getPlace()); + existingAdolescentHealth.setReferredToHealthFacility(adolescentHealth.getReferredToHealthFacility()); + existingAdolescentHealth.setCounselingProvided(adolescentHealth.getCounselingProvided()); + existingAdolescentHealth.setCounselingType(adolescentHealth.getCounselingType()); + existingAdolescentHealth.setFollowUpDate(adolescentHealth.getFollowUpDate()); + existingAdolescentHealth.setReferralStatus(adolescentHealth.getReferralStatus()); + existingAdolescentHealth.setIncentiveAmount(adolescentHealth.getIncentiveAmount()); + + // Save the updated record back to the database + adolescentHealthRepo.save(existingAdolescentHealth); + } +} + From 8449e5880d6fc28287916f53981ec0a18c75b761 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 1 Apr 2025 15:43:17 +0530 Subject: [PATCH 075/792] add module adolesencent health --- .../AdolescentHealthController.java | 19 ++++++++++ .../flw/service/AdolescentHealthService.java | 3 ++ .../impl/AdolescentHealthServiceImpl.java | 37 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java index 492359df..695e741c 100644 --- a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java +++ b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java @@ -10,6 +10,8 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController @RequestMapping(value = "/adolescentHealth", headers = "Authorization") @@ -42,4 +44,21 @@ public String saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHe } + @RequestMapping(name = "/getAll",method = RequestMethod.GET) + public String getAllAdolescentHealth() { + OutputResponse response = new OutputResponse(); + try { + if (adolescentHealthService.getAllAdolescentHealth().size() != 0) { + response.setResponse(adolescentHealthService.getAllAdolescentHealth().toString()); + + + } else + response.setError(500, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in get data : " + e); + response.setError(500, "Error in get data : " + e); + } + return response.toString(); + } + } diff --git a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java index df8aaa1c..a2bd148e 100644 --- a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java +++ b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java @@ -1,5 +1,6 @@ package com.iemr.flw.service; +import com.iemr.flw.domain.iemr.AdolescentHealth; import com.iemr.flw.dto.iemr.AdolescentHealthDTO; import org.springframework.stereotype.Service; @@ -7,4 +8,6 @@ @Service public interface AdolescentHealthService { String saveAll(AdolescentHealthDTO adolescentHealthDTO); + List getAllAdolescentHealth(); + } diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index 1afde982..cce2f618 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -7,7 +7,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; @Service public class AdolescentHealthServiceImpl implements AdolescentHealthService { @@ -32,6 +34,19 @@ public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { return "Records updated/added successfully!"; } + + + + public List getAllAdolescentHealth() { + // Fetch all records from the database + List adolescentHealths = adolescentHealthRepo.findAll(); + + // Convert the list of entity objects to DTO objects + return adolescentHealths.stream() + .map(this::convertToDTO) + .collect(Collectors.toList()); + } + private void updateAdolescentHealth(Optional existingRecord, AdolescentHealth adolescentHealth) { AdolescentHealth existingAdolescentHealth = existingRecord.get(); @@ -55,5 +70,27 @@ private void updateAdolescentHealth(Optional existingRecord, A // Save the updated record back to the database adolescentHealthRepo.save(existingAdolescentHealth); } + + private AdolescentHealth convertToDTO(AdolescentHealth adolescentHealth) { + AdolescentHealth dto = new AdolescentHealth(); + dto.setId(adolescentHealth.getId()); + dto.setBenId(adolescentHealth.getBenId()); + dto.setUserID(adolescentHealth.getUserID()); + dto.setVisitDate(adolescentHealth.getVisitDate()); + dto.setHealthStatus(adolescentHealth.getHealthStatus()); + dto.setIfaTabletDistribution(adolescentHealth.getIfaTabletDistribution()); + dto.setQuantityOfIfaTablets(adolescentHealth.getQuantityOfIfaTablets()); + dto.setMenstrualHygieneAwarenessGiven(adolescentHealth.getMenstrualHygieneAwarenessGiven()); + dto.setSanitaryNapkinDistributed(adolescentHealth.getSanitaryNapkinDistributed()); + dto.setNoOfPacketsDistributed(adolescentHealth.getNoOfPacketsDistributed()); + dto.setPlace(adolescentHealth.getPlace()); + dto.setReferredToHealthFacility(adolescentHealth.getReferredToHealthFacility()); + dto.setCounselingProvided(adolescentHealth.getCounselingProvided()); + dto.setCounselingType(adolescentHealth.getCounselingType()); + dto.setFollowUpDate(adolescentHealth.getFollowUpDate()); + dto.setReferralStatus(adolescentHealth.getReferralStatus()); + dto.setIncentiveAmount(adolescentHealth.getIncentiveAmount()); + return dto; + } } From ee7922cc9cbdd929e3940a66212c8802233383c8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 1 Apr 2025 15:48:19 +0530 Subject: [PATCH 076/792] update diseaseControl --- .../controller/DiseaseControlController.java | 6 +++--- .../flw/dto/iemr/GetDiseaseRequestHandler.java | 17 +++++++++++++++++ .../iemr/flw/service/DiseaseControlService.java | 2 +- .../service/impl/DiseaseControlServiceImpl.java | 4 ++-- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index c0a1c502..1dbcc091 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -79,12 +79,12 @@ public ResponseEntity> saveMalaria(@RequestBody LeprosyDTO l } - @RequestMapping(value = "getAll", method = RequestMethod.GET, produces = "application/json") - public ResponseEntity> getAllData(@Param("diseaseTypeID") BigInteger diseaseTypeID) { + @RequestMapping(value = "getAll", method = RequestMethod.POST, produces = "application/json") + public ResponseEntity> getAllData(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", diseaseControlService.getAll(diseaseTypeID)); + response.put("data", diseaseControlService.getAll(getDiseaseRequestHandler)); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java new file mode 100644 index 00000000..d17f9a7a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.math.BigInteger; +import java.sql.Timestamp; +@Data +public class GetDiseaseRequestHandler { + private Integer villageID; + private Timestamp fromDate; + private Timestamp toDate; + private Integer pageNo; + private Integer userId; + private String userName; + private Integer ashaId; + private BigInteger diseaseTypeID; +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 09df3353..9cb97b70 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -14,5 +14,5 @@ public interface DiseaseControlService { public String saveAES(AesJeDTO diseaseControlDTO); public String saveFilaria(FilariaDTO diseaseControlDTO); public String saveLeprosy(LeprosyDTO diseaseControlDTO); - public List getAll(BigInteger diseaseTypeID); + public List getAll(GetDiseaseRequestHandler getDiseaseRequestHandler); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 037f65e5..4396880d 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -135,8 +135,8 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { } @Override - public List getAll(BigInteger diseaseTypeID) { - return diseaseControlRepo.findAll().stream().filter(diseaseControl -> diseaseControl.getDiseaseTypeId()==diseaseTypeID).collect(Collectors.toList()); + public List getAll(GetDiseaseRequestHandler getDiseaseRequestHandler) { + return diseaseControlRepo.findAll().stream().filter(diseaseControl -> diseaseControl.getDiseaseTypeId()==getDiseaseRequestHandler.getDiseaseTypeID()).collect(Collectors.toList()); } private DiseaseControl saveData(DiseaseControl diseaseControlDTO) { From f70f8c2f2691eeccc7a74edaef0621aec81dc1e1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 2 Apr 2025 11:45:37 +0530 Subject: [PATCH 077/792] update diseaseControl --- .../java/com/iemr/flw/controller/DiseaseControlController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 1dbcc091..806b9316 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -19,11 +19,11 @@ @RestController @RequestMapping(value = "/disease", headers = "Authorization") public class DiseaseControlController { + @Autowired private DiseaseControlService diseaseControlService; - @RequestMapping(value = "Malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public ResponseEntity> saveMalaria(@RequestBody MalariaDTO malariaDTO) { Map response = new HashMap<>(); From c12342104a692ebc2d9a5188def3f30928faaba9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 2 Apr 2025 12:09:51 +0530 Subject: [PATCH 078/792] update diseaseControl --- .../flw/controller/IRSRoundController.java | 49 +++++++++++++++++++ .../com/iemr/flw/domain/iemr/IRSRound.java | 27 ++++++++++ .../com/iemr/flw/dto/iemr/IRSRoundDTO.java | 18 +++++++ .../iemr/flw/dto/iemr/IRSRoundListDTO.java | 15 ++++++ .../com/iemr/flw/repo/iemr/IRSRoundRepo.java | 14 ++++++ .../com/iemr/flw/service/IRSRoundService.java | 14 ++++++ .../flw/service/impl/IRSRoundServiceImpl.java | 31 ++++++++++++ 7 files changed, 168 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/IRSRoundController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/IRSRound.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IRSRoundListDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/IRSRoundRepo.java create mode 100644 src/main/java/com/iemr/flw/service/IRSRoundService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java new file mode 100644 index 00000000..2aec1194 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -0,0 +1,49 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.domain.iemr.IRSRound; +import com.iemr.flw.dto.iemr.IRSRoundDTO; +import com.iemr.flw.dto.iemr.IRSRoundListDTO; +import com.iemr.flw.service.IRSRoundService; +import com.iemr.flw.utils.response.OutputResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.lang.reflect.Method; +import java.sql.Timestamp; +import java.util.List; + +@RestController +@RequestMapping(value = "/irsRound", headers = "Authorization") + +public class IRSRoundController { + @Autowired + private IRSRoundService irsRoundService; + + @RequestMapping(name = "/add", method = RequestMethod.POST) + public String addRound(@RequestBody IRSRoundListDTO dto) { + OutputResponse response = new OutputResponse(); + try { + if (dto.getRounds().size() != 0) { + List s = irsRoundService.addRounds(dto.getRounds()); + if (s.size() != 0) { + response.setResponse(s.toString()); + + } else { + response.setError(500, "Invalid/NULL request obj"); + + } + + } else + response.setError(500, "Invalid/NULL request obj"); + } catch (Exception e) { + response.setError(500, "Error in saving cbac details : " + e); + } + return response.toString(); + + } + + @RequestMapping(name = "/list/{householdId}", method = RequestMethod.GET) + public List getRounds(@PathVariable Long householdId) { + return irsRoundService.getRounds(householdId); + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java new file mode 100644 index 00000000..d7826b5e --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java @@ -0,0 +1,27 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigInteger; +import java.sql.Date; + +@Entity +@Data +@Table(name = "irs_round",schema = "db_iemr") +@AllArgsConstructor +public class IRSRound { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @Column(name = "round") + private Date date; + + @Column(name = "irs_date") + private int rounds; + + @Column(name = "householdId") + private BigInteger household; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java new file mode 100644 index 00000000..412d9f59 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java @@ -0,0 +1,18 @@ +package com.iemr.flw.dto.iemr; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigInteger; +import java.sql.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class IRSRoundDTO { + private Long id; + private Date date; + private int rounds; + private BigInteger householdId; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/IRSRoundListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundListDTO.java new file mode 100644 index 00000000..e0780514 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundListDTO.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public +class IRSRoundListDTO { + private List rounds; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/IRSRoundRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IRSRoundRepo.java new file mode 100644 index 00000000..e083fed4 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/IRSRoundRepo.java @@ -0,0 +1,14 @@ + +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.IRSRound; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public +interface IRSRoundRepo extends JpaRepository { + List findByHouseholdId(Long householdId); +} diff --git a/src/main/java/com/iemr/flw/service/IRSRoundService.java b/src/main/java/com/iemr/flw/service/IRSRoundService.java new file mode 100644 index 00000000..d45cd621 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/IRSRoundService.java @@ -0,0 +1,14 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.IRSRound; +import com.iemr.flw.dto.iemr.IRSRoundDTO; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface IRSRoundService { + List addRounds(List dtos); + + List getRounds(Long householdId); +} diff --git a/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java new file mode 100644 index 00000000..a5d66223 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java @@ -0,0 +1,31 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.IRSRound; +import com.iemr.flw.dto.iemr.IRSRoundDTO; +import com.iemr.flw.repo.iemr.IRSRoundRepo; +import com.iemr.flw.service.IRSRoundService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +@Service +public class IRSRoundServiceImpl implements IRSRoundService { + @Autowired + private IRSRoundRepo irsRoundRepository; + @Override + public List addRounds(List dtos) { + List rounds = new ArrayList<>(); + for (IRSRoundDTO dto : dtos) { + + IRSRound round = new IRSRound(null, dto.getDate(), dto.getRounds(), dto.getHouseholdId()); + rounds.add(round); + } + return irsRoundRepository.saveAll(rounds); + } + + @Override + public List getRounds(Long householdId) { + return irsRoundRepository.findByHouseholdId(householdId); + } +} From a5f9fd1d49196c31aba7c12b04c3e6054380b8d5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 2 Apr 2025 12:10:20 +0530 Subject: [PATCH 079/792] work on irs round add and get --- src/main/java/com/iemr/flw/controller/IRSRoundController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java index 2aec1194..d8a4faed 100644 --- a/src/main/java/com/iemr/flw/controller/IRSRoundController.java +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -46,4 +46,5 @@ public String addRound(@RequestBody IRSRoundListDTO dto) { public List getRounds(@PathVariable Long householdId) { return irsRoundService.getRounds(householdId); } + } From 2a9d4e5feeabb21ecb3134788e019acae77fa0fd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 2 Apr 2025 12:10:40 +0530 Subject: [PATCH 080/792] work on irs round add and get --- src/main/java/com/iemr/flw/controller/IRSRoundController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java index d8a4faed..e5a5bc23 100644 --- a/src/main/java/com/iemr/flw/controller/IRSRoundController.java +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -47,4 +47,5 @@ public List getRounds(@PathVariable Long householdId) { return irsRoundService.getRounds(householdId); } + } From f8ad01db7f7709f8151b14efaa9b63b17bdc5a2b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 2 Apr 2025 12:14:59 +0530 Subject: [PATCH 081/792] update code --- src/main/java/com/iemr/flw/domain/iemr/MalariaData.java | 5 ----- .../com/iemr/flw/service/impl/DiseaseControlServiceImpl.java | 2 -- 2 files changed, 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java index 1217142d..85901368 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java @@ -40,11 +40,6 @@ public class MalariaData { @Column(name = "follow_up") Integer followUp; - @Column(name = "irs_date") - Date irsDate; - - @Column(name = "rounds") - Integer rounds; @Column(name = "DiseaseTypeID") Integer diseaseTypeID; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 4396880d..862af213 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -168,9 +168,7 @@ private String updateMalaria(MalariaData updatedMalariaData) { return malariaControlRepo.findByBenId(updatedMalariaData.getBenId()).map(malariaData -> { malariaData.setId(updatedMalariaData.getId()); malariaData.setBenId(updatedMalariaData.getBenId()); - malariaData.setIrsDate(updatedMalariaData.getIrsDate()); malariaData.setFollowUp(updatedMalariaData.getFollowUp()); - malariaData.setRounds(updatedMalariaData.getRounds()); malariaData.setRemarks(updatedMalariaData.getRemarks()); malariaData.setMalariaCaseCount(updatedMalariaData.getMalariaCaseCount()); malariaData.setMalariaCaseStatusDate(updatedMalariaData.getMalariaCaseStatusDate()); From aad608263d378d396e3c7991cb2fa515b5e50ee1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 8 Apr 2025 12:21:13 +0530 Subject: [PATCH 082/792] village form --- .../flw/controller/VhndFormController.java | 21 ++++++ .../flw/domain/iemr/VillageFormEntry.java | 47 ++++++++++++++ .../com/iemr/flw/dto/iemr/VhndFormDto.java | 15 +++++ .../flw/repo/iemr/VillageFormRepository.java | 7 ++ .../com/iemr/flw/service/VhndFormService.java | 18 +++++ .../flw/service/impl/VhndFormServiceImpl.java | 65 +++++++++++++++++++ 6 files changed, 173 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/VhndFormController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java create mode 100644 src/main/java/com/iemr/flw/service/VhndFormService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/VhndFormController.java b/src/main/java/com/iemr/flw/controller/VhndFormController.java new file mode 100644 index 00000000..a6a1b661 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/VhndFormController.java @@ -0,0 +1,21 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.VhndFormDto; +import com.iemr.flw.service.VhndFormService; +import com.iemr.flw.service.impl.VhndFormServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/api/forms/vhnd") +public class VhndFormController { + + @Autowired + private VhndFormService vhndFormService; + + @PostMapping + public ResponseEntity submitVhndForm(@RequestBody VhndFormDto dto) { + return vhndFormService.submitForm(dto); + } +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java new file mode 100644 index 00000000..440bd492 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java @@ -0,0 +1,47 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.sql.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "village_form_entry") +@Data +@AllArgsConstructor +@NoArgsConstructor +public class VillageFormEntry { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "asha_id") + private String ashaId; + + @Column(name = "form_type") + private String formType; + @Column(name = "VHND_date") + private Date date; + @Column(name = "place") + private String place; + + @Column(name = "participant_count") + private int participantCount; + + @Column(name = "image_urls") + private String imageUrls; + + @Column(name = "incentive_amount") + private double incentiveAmount; + + @Column(name = "fmr_code") + private String fmrCode; + + @Column(name = "submitted_at") + private LocalDateTime submittedAt; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java new file mode 100644 index 00000000..e543dd7a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Date; + +@Data +public class VhndFormDto { + private String ashaId; + private Date date; + private String place; + private int participantCount; + private String imageUrls; // Comma separated URLs or Base64 if needed +} + diff --git a/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java b/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java new file mode 100644 index 00000000..c4638a3b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java @@ -0,0 +1,7 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.VillageFormEntry; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface VillageFormRepository extends JpaRepository { +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java new file mode 100644 index 00000000..b5466802 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/VhndFormService.java @@ -0,0 +1,18 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.VillageFormEntry; +import com.iemr.flw.dto.iemr.VhndFormDto; +import com.iemr.flw.repo.iemr.VillageFormRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Service +public interface VhndFormService { + + + public ResponseEntity submitForm(VhndFormDto dto) ; +} diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java new file mode 100644 index 00000000..93c64767 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java @@ -0,0 +1,65 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.VillageFormEntry; +import com.iemr.flw.dto.iemr.VhndFormDto; +import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.VillageFormRepository; +import com.iemr.flw.service.IncentiveService; +import com.iemr.flw.service.VhndFormService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; + +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Service +public class VhndFormServiceImpl implements VhndFormService { + + @Autowired + private VillageFormRepository repository; + @Autowired + private IncentivesRepo incentivesRepo; + @Autowired + private IncentiveService incentiveService; + + public ResponseEntity submitForm(VhndFormDto dto) { + if (dto.getAshaId() == null || dto.getDate() == null || dto.getPlace() == null || dto.getParticipantCount() <= 0) { + return ResponseEntity.badRequest().body("Missing or invalid fields"); + } + + IncentiveActivity existing = incentivesRepo.findIncentiveMasterByNameAndGroup("VHND", "ASHA"); + + + VillageFormEntry entry = new VillageFormEntry(); + entry.setAshaId(dto.getAshaId()); + entry.setFormType("VHND"); + entry.setDate(dto.getDate()); + entry.setPlace(dto.getPlace()); + entry.setParticipantCount(dto.getParticipantCount()); + entry.setImageUrls(dto.getImageUrls()); + entry.setIncentiveAmount(200); + entry.setFmrCode("3.1.1.6.1"); + entry.setSubmittedAt(LocalDateTime.now()); + + repository.save(entry); + // Call IncentiveService to save to master + + if (existing == null) { + IncentiveActivity activity = new IncentiveActivity(); + activity.setName("VHND"); + activity.setGroup("ASHA"); + activity.setRate(200); + activity.setFmrCode("3.1.1.6.1"); + activity.setCreatedBy("system"); + activity.setCreatedDate(Timestamp.valueOf(LocalDateTime.now())); + activity.setIsDeleted(false); + incentivesRepo.save(activity); + } + + + return ResponseEntity.ok().body("Form submitted successfully. Incentive: Rs. 200"); + } +} From 0173ca4b3800e0481e2425dd94ef1355a7a8c32d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 8 Apr 2025 15:09:25 +0530 Subject: [PATCH 083/792] General opd --- .../flw/controller/GeneralOPDController.java | 22 +++++++++ .../iemr/flw/domain/iemr/GeneralOpdEntry.java | 45 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/GeneralOpdDto.java | 17 +++++++ .../flw/repo/iemr/BeneficiaryRepository.java | 10 +++++ .../iemr/flw/service/GeneralOpdService.java | 9 ++++ .../service/impl/GeneralOpdServiceImpl.java | 37 +++++++++++++++ 6 files changed, 140 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/GeneralOPDController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/GeneralOpdEntry.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/GeneralOpdDto.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/BeneficiaryRepository.java create mode 100644 src/main/java/com/iemr/flw/service/GeneralOpdService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java new file mode 100644 index 00000000..6b405a52 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -0,0 +1,22 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.GeneralOpdDto; +import com.iemr.flw.service.GeneralOpdService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/general-opd") +public class GeneralOPDController { + + @Autowired + private GeneralOpdService generalOpdService; + + @GetMapping("/beneficiaries/{ashaId}") + public ResponseEntity> getOpdBeneficiaries(@PathVariable String ashaId) { + return ResponseEntity.ok(generalOpdService.getOpdListForAsha(ashaId)); + } +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdEntry.java b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdEntry.java new file mode 100644 index 00000000..2e68c9fe --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdEntry.java @@ -0,0 +1,45 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Data +@Table(name = "general_opd_entry") // Updated table name +public class GeneralOpdEntry { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "asha_id") + private String ashaId; + + @Column(name = "name") + private String name; + + @Column(name = "age") + private String age; + + @Column(name = "gender") + private String gender; + + @Column(name = "registration_date") + private String registrationDate; + + @Column(name = "mobile_number") + private String mobileNumber; + + @Column(name = "beneficiary_id") + private String beneficiaryId; + + @Column(name = "visit_date") + private String visitDate; + + @Column(name = "referred_to") + private String referredTo; + + @Column(name = "follow_up_date") + private String followUpDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/GeneralOpdDto.java b/src/main/java/com/iemr/flw/dto/iemr/GeneralOpdDto.java new file mode 100644 index 00000000..69f0dfc5 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/GeneralOpdDto.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class GeneralOpdDto { + private String beneficiaryName; + private String age; + private String gender; + private String registrationDate; + private String mobileNumber; + private String beneficiaryId; + private String visitDate; + private String referredTo; + private String followUpDate; + private boolean callButtonEnabled; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/BeneficiaryRepository.java b/src/main/java/com/iemr/flw/repo/iemr/BeneficiaryRepository.java new file mode 100644 index 00000000..fe3175a9 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/BeneficiaryRepository.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.GeneralOpdEntry; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface BeneficiaryRepository extends JpaRepository { + List findByAshaIdOrderByVisitDateDesc(String ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/GeneralOpdService.java b/src/main/java/com/iemr/flw/service/GeneralOpdService.java new file mode 100644 index 00000000..aab88afb --- /dev/null +++ b/src/main/java/com/iemr/flw/service/GeneralOpdService.java @@ -0,0 +1,9 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.GeneralOpdDto; + +import java.util.List; + +public interface GeneralOpdService { + List getOpdListForAsha(String ashaId); +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java new file mode 100644 index 00000000..fa2c1c49 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java @@ -0,0 +1,37 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.GeneralOpdEntry; +import com.iemr.flw.dto.iemr.GeneralOpdDto; +import com.iemr.flw.repo.iemr.BeneficiaryRepository; +import com.iemr.flw.service.GeneralOpdService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class GeneralOpdServiceImpl implements GeneralOpdService { + + @Autowired + private BeneficiaryRepository repository; + + @Override + public List getOpdListForAsha(String ashaId) { + List beneficiaries = repository.findByAshaIdOrderByVisitDateDesc(ashaId); + return beneficiaries.stream().map(b -> { + GeneralOpdDto dto = new GeneralOpdDto(); + dto.setBeneficiaryName(b.getName()); + dto.setAge(b.getAge()); + dto.setGender(b.getGender()); + dto.setRegistrationDate(b.getRegistrationDate()); + dto.setMobileNumber(b.getMobileNumber()); + dto.setBeneficiaryId(b.getBeneficiaryId()); + dto.setVisitDate(b.getVisitDate()); + dto.setReferredTo(b.getReferredTo()); + dto.setFollowUpDate(b.getFollowUpDate()); + dto.setCallButtonEnabled(b.getMobileNumber() != null && !b.getMobileNumber().isEmpty()); + return dto; + }).collect(Collectors.toList()); + } +} \ No newline at end of file From 4781173eda3d01571deba7d7f16eb4045e44b93b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 15 Apr 2025 12:24:59 +0530 Subject: [PATCH 084/792] disease module --- .../controller/DiseaseControlController.java | 26 +- .../controller/MalariaFollowUpController.java | 45 ++ .../com/iemr/flw/domain/iemr/AesJeData.java | 34 - .../iemr/flw/domain/iemr/DiseaseAesje.java | 75 ++ .../flw/domain/iemr/DiseaseFilariasis.java | 60 ++ .../iemr/flw/domain/iemr/DiseaseKalaAzar.java | 80 ++ .../iemr/flw/domain/iemr/DiseaseLeprosy.java | 59 ++ .../iemr/flw/domain/iemr/DiseaseMalaria.java | 112 +++ .../com/iemr/flw/domain/iemr/FilariaData.java | 44 -- .../iemr/flw/domain/iemr/KalaAzarData.java | 57 -- .../com/iemr/flw/domain/iemr/LeprosyData.java | 55 -- .../com/iemr/flw/domain/iemr/MalariaData.java | 52 -- .../iemr/flw/domain/iemr/MalariaFollowUp.java | 68 ++ .../java/com/iemr/flw/dto/iemr/AesJeDTO.java | 4 +- .../iemr/flw/dto/iemr/DiseaseAesjeDto.java | 30 + .../flw/dto/iemr/DiseaseFilariasisDTO.java | 26 + .../iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java | 32 + .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 25 + .../iemr/flw/dto/iemr/DiseaseMalariaDTO.java | 51 ++ .../com/iemr/flw/dto/iemr/FilariaDTO.java | 4 +- .../dto/iemr/GetDiseaseRequestHandler.java | 2 +- .../com/iemr/flw/dto/iemr/KalaAzarDTO.java | 4 +- .../com/iemr/flw/dto/iemr/LeprosyDTO.java | 4 +- .../com/iemr/flw/dto/iemr/MalariaDTO.java | 4 +- .../flw/dto/iemr/MalariaFollowListUpDTO.java | 28 + .../iemr/flw/dto/iemr/MalariaFollowUpDTO.java | 10 + .../iemr/flw/dto/iemr/MalariaSymptomsDTO.java | 20 + .../iemr/flw/repo/iemr/AesJeControlRepo.java | 14 - .../flw/repo/iemr/DiseaseAESJERepository.java | 14 + .../iemr/DiseaseFilariasisRepository.java | 13 + .../repo/iemr/DiseaseKalaAzarRepository.java | 13 + .../repo/iemr/DiseaseLeprosyRepository.java | 13 + .../repo/iemr/DiseaseMalariaRepository.java | 13 + .../flw/repo/iemr/FilariaControlRepo.java | 14 - .../flw/repo/iemr/KalazarControlRepo.java | 14 - .../flw/repo/iemr/LeprosyControlRepo.java | 14 - .../flw/repo/iemr/MalariaControlRepo.java | 14 - .../repo/iemr/MalariaFollowUpRepository.java | 13 + .../flw/service/DiseaseControlService.java | 14 +- .../flw/service/MalariaFollowUpService.java | 17 + .../impl/DiseaseControlServiceImpl.java | 743 +++++++++++++----- .../impl/MalariaFollowUpServiceImpl.java | 64 ++ .../utils/http/HTTPRequestInterceptor.java | 2 +- 43 files changed, 1479 insertions(+), 521 deletions(-) create mode 100644 src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/AesJeData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/FilariaData.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/MalariaData.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java create mode 100644 src/main/java/com/iemr/flw/service/MalariaFollowUpService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 806b9316..e9e392cd 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -2,22 +2,18 @@ import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.DiseaseControlService; -import org.apache.commons.lang3.function.Failable; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.repository.query.Param; import org.springframework.http.ResponseEntity; 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.RestController; -import java.math.BigInteger; import java.util.HashMap; -import java.util.List; import java.util.Map; @RestController -@RequestMapping(value = "/disease", headers = "Authorization") +@RequestMapping(value = "/disease") public class DiseaseControlController { @Autowired @@ -84,9 +80,25 @@ public ResponseEntity> getAllData(@RequestBody GetDiseaseReq Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", diseaseControlService.getAll(getDiseaseRequestHandler)); + if (getDiseaseRequestHandler.getDiseaseTypeID() == 1) { + response.put("data", diseaseControlService.getAllMalaria(getDiseaseRequestHandler)); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 2) { + response.put("data", diseaseControlService.getAllKalaAzar(getDiseaseRequestHandler)); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 3) { + response.put("data", diseaseControlService.getAllKalaAES(getDiseaseRequestHandler)); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 4) { + response.put("data", diseaseControlService.getAllFilaria(getDiseaseRequestHandler)); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 5) { + response.put("data", diseaseControlService.getAllLeprosy(getDiseaseRequestHandler)); + + } + return ResponseEntity.ok(response); } -} +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java new file mode 100644 index 00000000..ba278262 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -0,0 +1,45 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.GetDiseaseRequestHandler; +import com.iemr.flw.dto.iemr.MalariaFollowListUpDTO; +import com.iemr.flw.dto.iemr.MalariaFollowUpDTO; +import com.iemr.flw.service.MalariaFollowUpService; +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.List; +import java.util.Map; + +@RestController +@RequestMapping(value = "/api/follow-up") +public class MalariaFollowUpController { + + @Autowired + private MalariaFollowUpService followUpService; + + @RequestMapping(value = "save",method = RequestMethod.POST) + public ResponseEntity> save(@RequestBody MalariaFollowUpDTO dto) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("msg", followUpService.saveFollowUp(dto)); + + return ResponseEntity.ok(response); + } + + @RequestMapping(value = "get",method = RequestMethod.POST) + public ResponseEntity> getFollowUpsByUserId(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { + Map response = new HashMap<>(); + + List data = followUpService.getByUserId(getDiseaseRequestHandler.getUserId()); + if(!data.isEmpty()){ + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data",data); + } + + return ResponseEntity.ok(response); + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java b/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java deleted file mode 100644 index f124485a..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/AesJeData.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Date; - -@Entity -@Data -@Table(name = "disease_aesje",schema = "db_iemr") -public class AesJeData { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private BigInteger id; - - @Column(name = "case_date") - private Date caseDate; - - @Column(name = "aesje_case_status") - private Boolean aesjeCaseStatus; - - @Column(name = "referred_to") - private Integer referredTo; - - @Column(name = "diseaseTypeID") - private Integer diseaseTypeID; - - @Column(name = "ben_id") - private BigInteger benId; - - @Column(name = "userID") - Integer userID; -} diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java new file mode 100644 index 00000000..7af81951 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java @@ -0,0 +1,75 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "disease_aesje", schema = "db_iemr") +@Data +public class DiseaseAesje { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "houseHoldDetailsId") + private Long houseHoldDetailsId; + + @Temporal(TemporalType.DATE) + @Column(name = "visit_date") + private Date visitDate; + + @Column(name = "beneficiary_status") + private String beneficiaryStatus = "Not Applicable"; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_death") + private Date dateOfDeath; + + @Column(name = "place_of_death") + private String placeOfDeath; + + @Column(name = "other_place_of_death") + private String otherPlaceOfDeath; + + @Column(name = "reason_for_death") + private String reasonForDeath; + + @Column(name = "other_reason_for_death") + private String otherReasonForDeath; + + @Column(name = "aes_je_case_status") + private String aesJeCaseStatus; + + @Column(name = "aes_je_case_count") + private Integer aesJeCaseCount = 0; + + @Column(name = "follow_up_point", columnDefinition = "INT CHECK (follow_up_point between 1 and 6)") + private Integer followUpPoint; + + @Column(name = "referred_to") + private String referredTo; + + @Column(name = "other_referred_facility") + private String otherReferredFacility; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_date") + private Date createdDate = new Date(); + + @Column(name = "created_by") + private String createdBy; + + + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeId; + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java new file mode 100644 index 00000000..f33a1f87 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java @@ -0,0 +1,60 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "disease_filariasis", schema = "db_iemr") +@Data +public class DiseaseFilariasis { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "houseHoldDetailsId") + private Long houseHoldDetailsId; + + @Column(name = "suffering_from_filariasis") + private Boolean sufferingFromFilariasis; + + @Column(name = "affected_body_part", length = 50) + private String affectedBodyPart; + + @Temporal(TemporalType.DATE) + @Column(name = "mda_home_visit_date") + private Date mdaHomeVisitDate; + + @Column(name = "dose_status", length = 5) + private String doseStatus; + + @Column(name = "filariasis_case_count") + private Integer filariasisCaseCount; + + @Column(name = "other_dose_status_details", columnDefinition = "TEXT") + private String otherDoseStatusDetails; + + @Column(name = "medicine_side_effect", length = 5) + private String medicineSideEffect; + + @Column(name = "other_side_effect_details", columnDefinition = "TEXT") + private String otherSideEffectDetails; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "created_by", length = 100) + private String createdBy; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeId; + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java new file mode 100644 index 00000000..d8b3efa1 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java @@ -0,0 +1,80 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "disease_kala_azar", schema = "db_iemr") +@Data +public class DiseaseKalaAzar { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "houseHoldDetailsId") + private Long houseHoldDetailsId; + + + @Temporal(TemporalType.DATE) + @Column(name = "visit_date") + private Date visitDate; + + @Column(name = "beneficiary_status", length = 50) + private String beneficiaryStatus; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_death") + private Date dateOfDeath; + + @Column(name = "place_of_death", length = 50) + private String placeOfDeath; + + @Column(name = "other_place_of_death", columnDefinition = "TEXT") + private String otherPlaceOfDeath; + + @Column(name = "reason_for_death", length = 50) + private String reasonForDeath; + + @Column(name = "other_reason_for_death", columnDefinition = "TEXT") + private String otherReasonForDeath; + + @Column(name = "kala_azar_case_status", length = 50) + private String kalaAzarCaseStatus; + + @Column(name = "kala_azar_case_count") + private Integer kalaAzarCaseCount; + + @Column(name = "rapid_diagnostic_test", length = 20) + private String rapidDiagnosticTest; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_rdt") + private Date dateOfRdt; + + @Column(name = "follow_up_point") + private Integer followUpPoint; + + @Column(name = "referred_to", length = 100) + private String referredTo; + + @Column(name = "other_referred_facility", columnDefinition = "TEXT") + private String otherReferredFacility; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "created_by", length = 100) + private String createdBy; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeId; + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java new file mode 100644 index 00000000..2528e204 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java @@ -0,0 +1,59 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "disease_leprosy", schema = "db_iemr") +@Data +public class DiseaseLeprosy { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "houseHoldDetailsId") + private Long houseHoldDetailsId; + + @Temporal(TemporalType.DATE) + @Column(name = "home_visit_date") + private Date homeVisitDate; + + @Column(name = "leprosy_status", length = 225) + private String leprosyStatus; + + @Column(name = "referred_to", length = 225) + private String referredTo; + + @Column(name = "other_referred_to", columnDefinition = "TEXT") + private String otherReferredTo; + + @Temporal(TemporalType.DATE) + @Column(name = "leprosy_status_date") + private Date leprosyStatusDate; + + @Column(name = "type_of_leprosy", length = 225) + private String typeOfLeprosy; + + @Temporal(TemporalType.DATE) + @Column(name = "follow_up_date") + private Date followUpDate; + + @Column(name = "disease_status", length = 225) + private String diseaseStatus; + + @Column(name = "remark", length = 225) + private String remark; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeId; + + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java new file mode 100644 index 00000000..558ce0be --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java @@ -0,0 +1,112 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "disease_malaria", schema = "db_iemr") +@Data +public class DiseaseMalaria { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "houseHoldDetailsId") + private Long houseHoldDetailsId; + + @Temporal(TemporalType.DATE) + @Column(name = "screening_date") + private Date screeningDate; + + @Column(name = "beneficiary_status") + private String beneficiaryStatus; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_death") + private Date dateOfDeath; + + @Column(name = "place_of_death") + private String placeOfDeath; + + @Column(name = "other_place_of_death") + private String otherPlaceOfDeath; + + @Column(name = "reason_for_death") + private String reasonForDeath; + + @Column(name = "other_reason_for_death") + private String otherReasonForDeath; + + @Column(name = "symptoms") + private String symptoms; + + @Column(name = "case_status") + private String caseStatus; + + @Column(name = "rapid_diagnostic_test") + private String rapidDiagnosticTest; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_rdt") + private Date dateOfRdt; + + @Column(name = "slide_test_pf") + private String slideTestPf; + + @Column(name = "slide_test_pv") + private String slideTestPv; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_slide_test") + private Date dateOfSlideTest; + + @Column(name = "slide_no") + private String slideNo; + + @Column(name = "referred_to") + private Integer referredTo; + + @Column(name = "other_referred_facility") + private String otherReferredFacility; + + @Column(name = "remarks") + private String remarks; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_visit_by_supervisor") + private Date dateOfVisitBySupervisor; + + @Column(name = "diseaseTypeID") + private Integer diseaseTypeId; + + @Column(name = "userID") + private Integer userId; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "created_by") + private String createdBy; + + @Temporal(TemporalType.DATE) + @Column(name = "date_of_visit_supervisor") + private Date dateOfVisitSupervisor; + + @Column(name = "refer_to_name") + private String referToName; + + @Column(name = "caseStatusId") + private Integer caseStatusId; + + + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java b/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java deleted file mode 100644 index e785a1e3..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/FilariaData.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Date; - -@Entity -@Data -@Table(name = "disease_filariasis",schema = "db_iemr") -public class FilariaData { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private BigInteger id; - - @Column(name = "suffering_from_filariasis") - private Boolean sufferingFromFilariasis; - - @Column(name = "which_part_of_body") - private String whichPartOfBody; - - @Column(name = "home_visit_date") - private Date homeVisitDate; - - @Column(name = "dec_and_albendazole_dose_status") - private String decAndAlbendazoleDoseStatus; - - @Column(name = "medicine_side_effect") - private String medicineSideEffect; - - @Column(name = "other") - private String other; - - @Column(name = "diseaseTypeID") - private Integer diseaseTypeID; - - @Column(name = "ben_id") - private BigInteger benId; - @Column(name = "userID") - Integer userID; -} - diff --git a/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java b/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java deleted file mode 100644 index 2e33b221..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/KalaAzarData.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Date; - -@Entity -@Data -@Table(name = "disease_kalaazar",schema = "db_iemr") -public class KalaAzarData { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Column(name = "ben_id") - BigInteger benId; - - @Column(name = "case_date") - private Date caseDate; - - @Column(name = "case_status", length = 225) - private String caseStatus; - - @Column(name = "symptoms", length = 225) - private String symptoms; - - @Column(name = "malaria_case_count", length = 225) - private String malariaCaseCount; - - @Column(name = "referred_to") - private Long referredTo; - - @Column(name = "kalaAzar_case_status_date") - private Date kalaAzarCaseStatusDate; - - @Column(name = "remarks", length = 225) - private String remarks; - - @Column(name = "follow_up_point", length = 225) - private String followUpPoint; - - @Column(name = "follow_up_date") - private Date followUpDate; - - @Column(name = "disease_status", length = 22) - private String status; - - @Column(name = "DiseaseTypeID") - Integer diseaseTypeID; - - @Column(name = "userID") - Integer userID; - -} diff --git a/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java b/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java deleted file mode 100644 index 56e5496a..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/LeprosyData.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Date; - - - -@Entity -@Data -@Table(name = "disease_leprosy",schema = "db_iemr") -public class LeprosyData { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "date_of_home_visit") - private Date dateOfHomeVisit; - - @Column(name = "leprosy_status") - private String leprosyStatus; - - @Column(name = "referred_to") - private Integer referredTo; - - @Column(name = "other") - private String other; - - @Column(name = "leprosy_status_date") - private Date leprosyStatusDate; - - @Column(name = "type_of_leprosy") - private String typeOfLeprosy; - - @Column(name = "follow_up_date") - private String followUpDate; - - @Column(name = "status") - private String status; - - @Column(name = "remark") - private String remark; - - @Column(name = "diseaseTypeID") - private Integer diseaseTypeID; - - @Column(name = "ben_id") - private BigInteger benId; - @Column(name = "userID") - Integer userID; -} - diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java deleted file mode 100644 index 85901368..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/MalariaData.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Date; - -@Entity -@Data -@Table(name = "disease_malaria",schema = "db_iemr") -public class MalariaData { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - Integer id; - @Column(name = "ben_id") - BigInteger benId; - - @Column(name = "case_date") - Date caseDate; - - @Column(name = "case_status") - String caseStatus; - - @Column(name = "symptoms") - String symptoms; - - @Column(name = "malaria_case_count") - String malariaCaseCount; - - @Column(name = "referred_to") - Integer ReferredTo; - - @Column(name = "malaria_case_status_date") - Date malariaCaseStatusDate; - - @Column(name = "remarks") - String Remarks; - - @Column(name = "follow_up") - Integer followUp; - - - @Column(name = "DiseaseTypeID") - Integer diseaseTypeID; - - @Column(name = "userID") - Integer userID; -} - - - diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java new file mode 100644 index 00000000..acddbcd7 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java @@ -0,0 +1,68 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.Date; + +@Entity +@Table(name = "malaria_follow_up", schema = "db_iemr") +@Data +public class MalariaFollowUp { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "ben_id", nullable = false) + private Long benId; + + @Column(name = "houseHoldDetailsId", nullable = false) + private Long houseHoldDetailsId; + + @Column(name = "userId") + private Integer userId; + + @Column(name = "diseaseId", nullable = false) + private Long diseaseId; + + @Column(name = "date_of_diagnosis", nullable = false) + @Temporal(TemporalType.DATE) + private Date dateOfDiagnosis; + + @Column(name = "treatment_start_date", nullable = false) + @Temporal(TemporalType.DATE) + private Date treatmentStartDate; + + @Column(name = "treatment_given", nullable = false) + private String treatmentGiven; + + @Column(name = "pf_day_1") + private Boolean pfDay1; + + @Column(name = "pf_day_2") + private Boolean pfDay2; + + @Column(name = "pf_day_3") + private Boolean pfDay3; + + @Column(name = "pv_day_1") + private Boolean pvDay1; + + @Column(name = "pv_day_2") + private Boolean pvDay2; + + @Column(name = "pv_day_3") + private Boolean pvDay3; + + @Column(name = "pv_day_4") + private Boolean pvDay4; + + @Column(name = "treatment_completion_date") + @Temporal(TemporalType.DATE) + private Date treatmentCompletionDate; + + @Column(name = "referral_date") + @Temporal(TemporalType.DATE) + private Date referralDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java index 45ca7244..85fdb417 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java @@ -1,13 +1,11 @@ package com.iemr.flw.dto.iemr; -import com.iemr.flw.domain.iemr.AesJeData; import lombok.Data; -import java.sql.Date; import java.util.List; @Data public class AesJeDTO { Integer userId; - List aesJeLists; + List aesJeLists; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java new file mode 100644 index 00000000..42289436 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java @@ -0,0 +1,30 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Date; +@Data +public class DiseaseAesjeDto { + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Date visitDate; + private String beneficiaryStatus; + private Date dateOfDeath; + private String placeOfDeath; + private String otherPlaceOfDeath; + private String reasonForDeath; + private String otherReasonForDeath; + private String aesJeCaseStatus; + private Integer aesJeCaseCount; + private Integer followUpPoint; + private String referredTo; + private String otherReferredFacility; + private Date createdDate; + private String createdBy; + private Integer userId; + private Integer diseaseTypeId; + + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java new file mode 100644 index 00000000..da068817 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java @@ -0,0 +1,26 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Date; +@Data +public class DiseaseFilariasisDTO { + + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Boolean sufferingFromFilariasis; + private String affectedBodyPart; + private Date mdaHomeVisitDate; + private String doseStatus; + private Integer filariasisCaseCount; + private String otherDoseStatusDetails; + private String medicineSideEffect; + private String otherSideEffectDetails; + private Date createdDate; + private String createdBy; + private Integer userId; + private Integer diseaseTypeId; + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java new file mode 100644 index 00000000..7dda95d5 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java @@ -0,0 +1,32 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Date; +@Data +public class DiseaseKalaAzarDTO { + + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Date visitDate; + private String beneficiaryStatus; + private Date dateOfDeath; + private String placeOfDeath; + private String otherPlaceOfDeath; + private String reasonForDeath; + private String otherReasonForDeath; + private String kalaAzarCaseStatus; + private Integer kalaAzarCaseCount; + private String rapidDiagnosticTest; + private Date dateOfRdt; + private Integer followUpPoint; + private String referredTo; + private String otherReferredFacility; + private Date createdDate; + private String createdBy; + private Integer userId; + private Integer diseaseTypeId; + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java new file mode 100644 index 00000000..73a8a117 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -0,0 +1,25 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Date; +@Data +public class DiseaseLeprosyDTO { + + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Date homeVisitDate; + private String leprosyStatus; + private String referredTo; + private String otherReferredTo; + private Date leprosyStatusDate; + private String typeOfLeprosy; + private Date followUpDate; + private String diseaseStatus; + private String remark; + private Integer userId; + private Integer diseaseTypeId; + + // Getters and Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java new file mode 100644 index 00000000..375d2e2a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java @@ -0,0 +1,51 @@ +package com.iemr.flw.dto.iemr; + +import jakarta.persistence.Column; +import lombok.Data; + +import java.util.Date; +@Data +public class DiseaseMalariaDTO { + + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Date screeningDate; + private String beneficiaryStatus; + private Date dateOfDeath; + private String placeOfDeath; + private String otherPlaceOfDeath; + private String reasonForDeath; + private String otherReasonForDeath; + private String symptoms; + private String caseStatus; + private String rapidDiagnosticTest; + private Date dateOfRdt; + private String slideTestPf; + private String slideTestPv; + private Date dateOfSlideTest; + private String slideNo; + private Integer referredTo; + private String otherReferredFacility; + private String remarks; + private Date dateOfVisitBySupervisor; + private Integer diseaseTypeId; + private Integer userId; + private Date createdDate; + private String createdBy; + private Date dateOfVisitSupervisor; + private boolean feverMoreThanTwoWeeks; + private boolean fluLikeIllness; + private boolean shakingChills; + private boolean headache; + private boolean muscleAches; + private boolean tiredness; + private boolean nausea; + private boolean vomiting; + private boolean diarrhea; + private String referToName; + private Integer caseStatusId; + + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java index 5670a60f..85088918 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java @@ -1,13 +1,11 @@ package com.iemr.flw.dto.iemr; -import com.iemr.flw.domain.iemr.FilariaData; import lombok.Data; -import java.sql.Date; import java.util.List; @Data public class FilariaDTO { Integer userId; - List filariaLists; + List filariaLists; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java index d17f9a7a..5029c19f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java +++ b/src/main/java/com/iemr/flw/dto/iemr/GetDiseaseRequestHandler.java @@ -13,5 +13,5 @@ public class GetDiseaseRequestHandler { private Integer userId; private String userName; private Integer ashaId; - private BigInteger diseaseTypeID; + private Integer diseaseTypeID; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java index b3aa2045..1a51fcff 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java @@ -1,13 +1,11 @@ package com.iemr.flw.dto.iemr; -import com.iemr.flw.domain.iemr.KalaAzarData; import lombok.Data; -import java.sql.Date; import java.util.List; @Data public class KalaAzarDTO { Integer userId; - List kalaAzarLists; + List kalaAzarLists; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java index 4ccf523c..b8362002 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java @@ -1,14 +1,12 @@ package com.iemr.flw.dto.iemr; -import com.iemr.flw.domain.iemr.LeprosyData; import lombok.Data; -import java.sql.Date; import java.util.List; @Data public class LeprosyDTO { Integer userId; - List leprosyLists; + List leprosyLists; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java index 2f9b19b9..af2146b0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java @@ -1,15 +1,13 @@ package com.iemr.flw.dto.iemr; -import com.iemr.flw.domain.iemr.MalariaData; import lombok.Data; -import java.sql.Date; import java.util.List; @Data public class MalariaDTO { Integer userId; - List malariaLists; + List malariaLists; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java new file mode 100644 index 00000000..abf53b46 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java @@ -0,0 +1,28 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import java.util.Date; + +@Data +public class MalariaFollowListUpDTO { + private Long id; + private Long benId; + private Long houseHoldDetailsId; + private Integer userId ; + private Long diseaseId; + private Date dateOfDiagnosis; + private Date treatmentStartDate; + private String treatmentGiven; + + private Boolean pfDay1; + private Boolean pfDay2; + private Boolean pfDay3; + + private Boolean pvDay1; + private Boolean pvDay2; + private Boolean pvDay3; + private Boolean pvDay4; + + private Date treatmentCompletionDate; + private Date referralDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java new file mode 100644 index 00000000..a0be541e --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; +@Data +public class MalariaFollowUpDTO { + private Integer userId; + private List malariaFollowListUp; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java new file mode 100644 index 00000000..6b9f2cde --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java @@ -0,0 +1,20 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import lombok.Data; + +@JsonIgnoreProperties(ignoreUnknown = true) +@Data +public class MalariaSymptomsDTO { + private boolean nausea; + private boolean diarrhea; + private boolean tiredness; + private boolean vomiting; + private boolean headache; + private boolean feverMoreThanTwoWeeks; + private boolean fluLikeIllness; + private boolean shakingChills; + private boolean muscleAches; + + // Getters & Setters +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java deleted file mode 100644 index 68714ccc..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/AesJeControlRepo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.AesJeData; -import com.iemr.flw.domain.iemr.KalaAzarData; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.math.BigInteger; -import java.util.Optional; - -@Repository -public interface AesJeControlRepo extends JpaRepository { - Optional findByBenId(BigInteger benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java new file mode 100644 index 00000000..a9a41f7b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseAesje; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.math.BigInteger; +import java.util.Optional; + +@Repository +public interface DiseaseAESJERepository extends JpaRepository { + Optional findByBenId(Long benId); + // Custom queries can be added here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java new file mode 100644 index 00000000..54f58741 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseFilariasis; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DiseaseFilariasisRepository extends JpaRepository { + Optional findByBenId(Long benId); + // Custom queries can be added here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java new file mode 100644 index 00000000..d76aca63 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseKalaAzar; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DiseaseKalaAzarRepository extends JpaRepository { + Optional findByBenId(Long benId); + // Custom queries can be added here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java new file mode 100644 index 00000000..8ed51a96 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseLeprosy; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DiseaseLeprosyRepository extends JpaRepository { + Optional findByBenId(Long benId); + // Custom queries can be added here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java new file mode 100644 index 00000000..d05f8a70 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DiseaseMalaria; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.Optional; + +@Repository +public interface DiseaseMalariaRepository extends JpaRepository { + Optional findByBenId(Long benId); + // Custom queries can be added here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java deleted file mode 100644 index 324d0c4e..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/FilariaControlRepo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.FilariaData; -import com.iemr.flw.domain.iemr.KalaAzarData; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.math.BigInteger; -import java.util.Optional; - -@Repository -public interface FilariaControlRepo extends JpaRepository { - Optional findByBenId(BigInteger benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java deleted file mode 100644 index f2c744c5..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/KalazarControlRepo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.KalaAzarData; -import com.iemr.flw.domain.iemr.MalariaData; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.math.BigInteger; -import java.util.Optional; - -@Repository -public interface KalazarControlRepo extends JpaRepository { - Optional findByBenId(BigInteger benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java deleted file mode 100644 index 366cce84..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/LeprosyControlRepo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.KalaAzarData; -import com.iemr.flw.domain.iemr.LeprosyData; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.math.BigInteger; -import java.util.Optional; - -@Repository -public interface LeprosyControlRepo extends JpaRepository { - Optional findByBenId(BigInteger benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java deleted file mode 100644 index 64d94e88..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/MalariaControlRepo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.DiseaseControl; -import com.iemr.flw.domain.iemr.MalariaData; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.math.BigInteger; -import java.util.Optional; - -@Repository -public interface MalariaControlRepo extends JpaRepository { - Optional findByBenId(BigInteger benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java new file mode 100644 index 00000000..cea3d281 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.MalariaFollowUp; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.Collection; +import java.util.List; + +public interface MalariaFollowUpRepository extends JpaRepository { + List findByBenId(Long benId); + + Collection findByUserId(Integer userId); +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 9cb97b70..363f50b0 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -1,18 +1,16 @@ package com.iemr.flw.service; -import com.iemr.flw.domain.iemr.DiseaseControl; import com.iemr.flw.dto.iemr.*; -import org.apache.commons.collections4.Put; - -import java.math.BigInteger; -import java.util.List; public interface DiseaseControlService { - public String save(DiseaseControlDTO diseaseControlDTO); public String saveMalaria(MalariaDTO diseaseControlDTO); public String saveKalaAzar(KalaAzarDTO diseaseControlDTO); public String saveAES(AesJeDTO diseaseControlDTO); public String saveFilaria(FilariaDTO diseaseControlDTO); public String saveLeprosy(LeprosyDTO diseaseControlDTO); - public List getAll(GetDiseaseRequestHandler getDiseaseRequestHandler); -} + public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler); + public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler); + public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler); + public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler); + public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler); +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java new file mode 100644 index 00000000..62a6a322 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java @@ -0,0 +1,17 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.MalariaFollowListUpDTO; +import com.iemr.flw.dto.iemr.MalariaFollowUpDTO; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface MalariaFollowUpService { + + + public String saveFollowUp(MalariaFollowUpDTO dto) ; + + + List getByUserId(Integer userId); +} diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 862af213..f97deb48 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1,62 +1,54 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; -import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.math.BigInteger; -import java.util.List; +import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.util.*; import java.util.stream.Collectors; @Service public class DiseaseControlServiceImpl implements DiseaseControlService { - @Autowired - private DiseaseControlRepo diseaseControlRepo; - @Autowired - private MalariaControlRepo malariaControlRepo; @Autowired - private KalazarControlRepo kalazarControlRepo; + private DiseaseMalariaRepository diseaseMalariaRepository; @Autowired - private AesJeControlRepo aesJeControlRepo; - + private DiseaseAESJERepository diseaseAESJERepository; @Autowired - private FilariaControlRepo filariaControlRepo; + private DiseaseFilariasisRepository diseaseFilariasisRepository; @Autowired - private LeprosyControlRepo leprosyControlRepo; + private DiseaseKalaAzarRepository diseaseKalaAzarRepository; - @Override - public String save(DiseaseControlDTO diseaseControlDTO) { - for (DiseaseControl diseaseControlData : diseaseControlDTO.getDiseaseControlList()) { - if (diseaseControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { - return update(diseaseControlData); - } else { + @Autowired + private DiseaseLeprosyRepository diseaseLeprosyRepository; - diseaseControlRepo.save(saveData(diseaseControlData)); - return "Data add successfully"; - } - } - return "Fail"; + @Autowired + private IncentiveRecordRepo recordRepo; + @Autowired + private UserServiceRoleRepo userRepo; + @Autowired + private IncentivesRepo incentivesRepo; - } @Override public String saveMalaria(MalariaDTO diseaseControlDTO) { - for (MalariaData diseaseControlData : diseaseControlDTO.getMalariaLists()) { - if (malariaControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { - return updateMalaria(diseaseControlData); + for (DiseaseMalariaDTO diseaseControlData : diseaseControlDTO.getMalariaLists()) { + if (diseaseMalariaRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateMalariaDisease(diseaseControlData); } else { - if(diseaseControlDTO.getUserId()!=null){ - diseaseControlData.setUserID(diseaseControlData.getUserID()); + if (diseaseControlDTO.getUserId() != null) { + diseaseControlData.setUserId(diseaseControlData.getUserId()); } - malariaControlRepo.save(diseaseControlData); + diseaseMalariaRepository.save(saveMalariaDisease(diseaseControlData)); return "Data add successfully"; } @@ -67,14 +59,14 @@ public String saveMalaria(MalariaDTO diseaseControlDTO) { @Override public String saveKalaAzar(KalaAzarDTO diseaseControlDTO) { - for (KalaAzarData diseaseControlData : diseaseControlDTO.getKalaAzarLists()) { - if (kalazarControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { - return updateKalaAzar(diseaseControlData); + for (DiseaseKalaAzarDTO diseaseControlData : diseaseControlDTO.getKalaAzarLists()) { + if (diseaseKalaAzarRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateKalaAzarDisease(diseaseControlData); } else { - if(diseaseControlDTO.getUserId()!=null){ - diseaseControlData.setUserID(diseaseControlData.getUserID()); + if (diseaseControlDTO.getUserId() != null) { + diseaseControlData.setUserId(diseaseControlData.getUserId()); } - kalazarControlRepo.save(diseaseControlData); + diseaseKalaAzarRepository.save(saveKalaAzarDisease(diseaseControlData)); return "Data add successfully"; } @@ -83,16 +75,17 @@ public String saveKalaAzar(KalaAzarDTO diseaseControlDTO) { } + @Override public String saveAES(AesJeDTO diseaseControlDTO) { - for (AesJeData diseaseControlData : diseaseControlDTO.getAesJeLists()) { - if (aesJeControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { - return updateAesJe(diseaseControlData); + for (DiseaseAesjeDto diseaseControlData : diseaseControlDTO.getAesJeLists()) { + if (diseaseAESJERepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateASEDisease(diseaseControlData); } else { - if(diseaseControlDTO.getUserId()!=null){ - diseaseControlData.setUserID(diseaseControlData.getUserID()); + if (diseaseControlDTO.getUserId() != null) { + diseaseControlData.setUserId(diseaseControlData.getUserId()); } - aesJeControlRepo.save(diseaseControlData); + diseaseAESJERepository.save(saveASEDisease(diseaseControlData)); return "Data add successfully"; } @@ -102,14 +95,14 @@ public String saveAES(AesJeDTO diseaseControlDTO) { @Override public String saveFilaria(FilariaDTO diseaseControlDTO) { - for (FilariaData diseaseControlData : diseaseControlDTO.getFilariaLists()) { - if (filariaControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { + for (DiseaseFilariasisDTO diseaseControlData : diseaseControlDTO.getFilariaLists()) { + if (diseaseFilariasisRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { return updateFilaria(diseaseControlData); } else { - if(diseaseControlDTO.getUserId()!=null){ - diseaseControlData.setUserID(diseaseControlData.getUserID()); + if (diseaseControlDTO.getUserId() != null) { + diseaseControlData.setUserId(diseaseControlData.getUserId()); } - filariaControlRepo.save(diseaseControlData); + diseaseFilariasisRepository.save(saveFilariasisData(diseaseControlData)); return "Data add successfully"; } @@ -117,16 +110,122 @@ public String saveFilaria(FilariaDTO diseaseControlDTO) { return "Fail"; } + private DiseaseAesje saveASEDisease(DiseaseAesjeDto diseaseControlData) { + // Create a new DiseaseAesje entity from the DTO data + DiseaseAesje diseaseAesje = new DiseaseAesje(); + + // Set the fields from DTO to entity + diseaseAesje.setBenId(diseaseControlData.getBenId()); + diseaseAesje.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + diseaseAesje.setVisitDate(diseaseControlData.getVisitDate()); + diseaseAesje.setBeneficiaryStatus(diseaseControlData.getBeneficiaryStatus()); + diseaseAesje.setDateOfDeath(diseaseControlData.getDateOfDeath()); + diseaseAesje.setPlaceOfDeath(diseaseControlData.getPlaceOfDeath()); + diseaseAesje.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + diseaseAesje.setOtherPlaceOfDeath(diseaseControlData.getOtherPlaceOfDeath()); + diseaseAesje.setReasonForDeath(diseaseControlData.getReasonForDeath()); + diseaseAesje.setOtherReasonForDeath(diseaseControlData.getOtherReasonForDeath()); + diseaseAesje.setAesJeCaseStatus(diseaseControlData.getAesJeCaseStatus()); + diseaseAesje.setAesJeCaseCount(diseaseControlData.getAesJeCaseCount()); + diseaseAesje.setFollowUpPoint(diseaseControlData.getFollowUpPoint()); + diseaseAesje.setReferredTo(diseaseControlData.getReferredTo()); + diseaseAesje.setOtherReferredFacility(diseaseControlData.getOtherReferredFacility()); + diseaseAesje.setCreatedDate(new Timestamp(System.currentTimeMillis())); // Set current timestamp + diseaseAesje.setCreatedBy(diseaseControlData.getCreatedBy()); + + // Return the new entity to be saved + return diseaseAesje; + } + + private String updateASEDisease(DiseaseAesjeDto diseaseControlData) { + // Fetch the existing record from the database using benId + DiseaseAesje existingDiseaseAesje = diseaseAESJERepository.findByBenId(diseaseControlData.getBenId()) + .orElseThrow(() -> new RuntimeException("AES/JE record not found for benId: " + diseaseControlData.getBenId())); + + // Update the existing entity with new values from the DTO + existingDiseaseAesje.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + existingDiseaseAesje.setVisitDate(diseaseControlData.getVisitDate()); + existingDiseaseAesje.setBeneficiaryStatus(diseaseControlData.getBeneficiaryStatus()); + existingDiseaseAesje.setDateOfDeath(diseaseControlData.getDateOfDeath()); + existingDiseaseAesje.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + existingDiseaseAesje.setPlaceOfDeath(diseaseControlData.getPlaceOfDeath()); + existingDiseaseAesje.setOtherPlaceOfDeath(diseaseControlData.getOtherPlaceOfDeath()); + existingDiseaseAesje.setReasonForDeath(diseaseControlData.getReasonForDeath()); + existingDiseaseAesje.setOtherReasonForDeath(diseaseControlData.getOtherReasonForDeath()); + existingDiseaseAesje.setAesJeCaseStatus(diseaseControlData.getAesJeCaseStatus()); + existingDiseaseAesje.setAesJeCaseCount(diseaseControlData.getAesJeCaseCount()); + existingDiseaseAesje.setFollowUpPoint(diseaseControlData.getFollowUpPoint()); + existingDiseaseAesje.setReferredTo(diseaseControlData.getReferredTo()); + existingDiseaseAesje.setOtherReferredFacility(diseaseControlData.getOtherReferredFacility()); + + // If the userId is present, update it as well + + + // Save the updated entity + diseaseAESJERepository.save(existingDiseaseAesje); + + return "AES/JE data updated successfully"; + } + + + private DiseaseFilariasis saveFilariasisData(DiseaseFilariasisDTO diseaseControlData) { + // Create a new DiseaseFilariasis entity from the DTO data + DiseaseFilariasis diseaseFilariasis = new DiseaseFilariasis(); + + diseaseFilariasis.setBenId(diseaseControlData.getBenId()); + diseaseFilariasis.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + diseaseFilariasis.setSufferingFromFilariasis(diseaseControlData.getSufferingFromFilariasis()); + diseaseFilariasis.setAffectedBodyPart(diseaseControlData.getAffectedBodyPart()); + diseaseFilariasis.setMdaHomeVisitDate(diseaseControlData.getMdaHomeVisitDate()); + diseaseFilariasis.setDoseStatus(diseaseControlData.getDoseStatus()); + diseaseFilariasis.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + diseaseFilariasis.setFilariasisCaseCount(diseaseControlData.getFilariasisCaseCount()); + diseaseFilariasis.setOtherDoseStatusDetails(diseaseControlData.getOtherDoseStatusDetails()); + diseaseFilariasis.setMedicineSideEffect(diseaseControlData.getMedicineSideEffect()); + diseaseFilariasis.setOtherSideEffectDetails(diseaseControlData.getOtherSideEffectDetails()); + diseaseFilariasis.setCreatedDate(new Timestamp(System.currentTimeMillis())); // Set current timestamp + diseaseFilariasis.setCreatedBy(diseaseControlData.getCreatedBy()); + + // Return the new entity to be saved + return diseaseFilariasis; + } + + + private String updateFilaria(DiseaseFilariasisDTO diseaseControlData) { + // Fetch the existing record from the database using benId + DiseaseFilariasis existingDiseaseFilariasis = diseaseFilariasisRepository.findByBenId(diseaseControlData.getBenId()) + .orElseThrow(() -> new RuntimeException("Filariasis record not found for benId: " + diseaseControlData.getBenId())); + + // Update the existing entity with the new values from the DTO + existingDiseaseFilariasis.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + existingDiseaseFilariasis.setSufferingFromFilariasis(diseaseControlData.getSufferingFromFilariasis()); + existingDiseaseFilariasis.setAffectedBodyPart(diseaseControlData.getAffectedBodyPart()); + existingDiseaseFilariasis.setMdaHomeVisitDate(diseaseControlData.getMdaHomeVisitDate()); + existingDiseaseFilariasis.setDoseStatus(diseaseControlData.getDoseStatus()); + existingDiseaseFilariasis.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + existingDiseaseFilariasis.setFilariasisCaseCount(diseaseControlData.getFilariasisCaseCount()); + existingDiseaseFilariasis.setOtherDoseStatusDetails(diseaseControlData.getOtherDoseStatusDetails()); + existingDiseaseFilariasis.setMedicineSideEffect(diseaseControlData.getMedicineSideEffect()); + existingDiseaseFilariasis.setOtherSideEffectDetails(diseaseControlData.getOtherSideEffectDetails()); + + + // Save the updated entity + diseaseFilariasisRepository.save(existingDiseaseFilariasis); + + return "Filariasis data updated successfully"; + } + + @Override public String saveLeprosy(LeprosyDTO diseaseControlDTO) { - for (LeprosyData diseaseControlData : diseaseControlDTO.getLeprosyLists()) { - if (leprosyControlRepo.findByBenId(diseaseControlData.getBenId()).isPresent()) { - return updateLeprosy(diseaseControlData); + for (DiseaseLeprosyDTO diseaseControlData : diseaseControlDTO.getLeprosyLists()) { + if (diseaseLeprosyRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { + return updateLeprosyData(diseaseControlData); } else { - if(diseaseControlDTO.getUserId()!=null){ - diseaseControlData.setUserID(diseaseControlData.getUserID()); + if (diseaseControlDTO.getUserId() != null) { + diseaseControlData.setUserId(diseaseControlData.getUserId()); } - leprosyControlRepo.save(diseaseControlData); + diseaseLeprosyRepository.save(saveLeprosyData(diseaseControlData)); return "Data add successfully"; } @@ -135,151 +234,441 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { } @Override - public List getAll(GetDiseaseRequestHandler getDiseaseRequestHandler) { - return diseaseControlRepo.findAll().stream().filter(diseaseControl -> diseaseControl.getDiseaseTypeId()==getDiseaseRequestHandler.getDiseaseTypeID()).collect(Collectors.toList()); - } + public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { + ObjectMapper objectMapper = new ObjectMapper(); + + // Fetch and filter malaria disease records + List filteredList = diseaseMalariaRepository.findAll().stream() + .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .collect(Collectors.toList()); + + // Check if the list is empty + if (filteredList.isEmpty()) { + return Collections.singletonMap("message", "No data found for Malaria."); + } - private DiseaseControl saveData(DiseaseControl diseaseControlDTO) { - DiseaseControl diseaseControl = new DiseaseControl(); - diseaseControl.setBenId(diseaseControlDTO.getBenId()); - diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added - diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); - diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); - diseaseControl.setMalariaCaseCount(diseaseControlDTO.getMalariaCaseCount()); - diseaseControl.setReferredTo(diseaseControlDTO.getReferredTo()); // Added - diseaseControl.setOtherReferredTo(diseaseControlDTO.getOtherReferredTo()); - diseaseControl.setMalariaCaseStatusDate(diseaseControlDTO.getMalariaCaseStatusDate()); // Added - diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); - diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); - diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); - diseaseControl.setStatus(diseaseControlDTO.getStatus()); - diseaseControl.setBodyPart(diseaseControlDTO.getBodyPart()); - diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); - diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); - diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); - diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); - diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); - diseaseControl.setDiseaseTypeId(diseaseControlDTO.getDiseaseTypeId()); - return diseaseControl; + // Map to DTOs + List dtoList = filteredList.stream().map(disease -> { + DiseaseMalariaDTO dto = new DiseaseMalariaDTO(); + + // Map fields from DiseaseMalaria to DTO + dto.setId(disease.getId()); + dto.setBenId(disease.getBenId()); + dto.setHouseHoldDetailsId(disease.getHouseHoldDetailsId()); + dto.setScreeningDate(disease.getScreeningDate()); + dto.setBeneficiaryStatus(disease.getBeneficiaryStatus()); + dto.setDateOfDeath(disease.getDateOfDeath()); + dto.setPlaceOfDeath(disease.getPlaceOfDeath()); + dto.setOtherPlaceOfDeath(disease.getOtherPlaceOfDeath()); + dto.setReasonForDeath(disease.getReasonForDeath()); + dto.setOtherReasonForDeath(disease.getOtherReasonForDeath()); + dto.setCaseStatus(disease.getCaseStatus()); + dto.setRapidDiagnosticTest(disease.getRapidDiagnosticTest()); + dto.setDateOfRdt(disease.getDateOfRdt()); + dto.setSlideTestPf(disease.getSlideTestPf()); + dto.setSlideTestPv(disease.getSlideTestPv()); + dto.setDateOfSlideTest(disease.getDateOfSlideTest()); + dto.setSlideNo(disease.getSlideNo()); + dto.setReferredTo(disease.getReferredTo()); + dto.setOtherReferredFacility(disease.getOtherReferredFacility()); + dto.setRemarks(disease.getRemarks()); + dto.setDateOfVisitBySupervisor(disease.getDateOfVisitBySupervisor()); + dto.setUserId(disease.getUserId()); + dto.setDiseaseTypeId(disease.getDiseaseTypeId()); + + // Parse symptoms (if present) + try { + if (disease.getSymptoms() != null && !disease.getSymptoms().isEmpty()) { + MalariaSymptomsDTO symptomsDTO = objectMapper.readValue(disease.getSymptoms(), MalariaSymptomsDTO.class); + dto.setFeverMoreThanTwoWeeks(symptomsDTO.isFeverMoreThanTwoWeeks()); + dto.setFluLikeIllness(symptomsDTO.isFluLikeIllness()); + dto.setShakingChills(symptomsDTO.isShakingChills()); + dto.setHeadache(symptomsDTO.isHeadache()); + dto.setMuscleAches(symptomsDTO.isMuscleAches()); + dto.setTiredness(symptomsDTO.isTiredness()); + dto.setNausea(symptomsDTO.isNausea()); + dto.setVomiting(symptomsDTO.isVomiting()); + dto.setDiarrhea(symptomsDTO.isDiarrhea()); + } + } catch (Exception e) { + throw new RuntimeException("Error parsing symptoms JSON for Malaria Disease ID: " + disease.getId(), e); + } + + return dto; + }).collect(Collectors.toList()); + return dtoList; } - private String updateMalaria(MalariaData updatedMalariaData) { - return malariaControlRepo.findByBenId(updatedMalariaData.getBenId()).map(malariaData -> { - malariaData.setId(updatedMalariaData.getId()); - malariaData.setBenId(updatedMalariaData.getBenId()); - malariaData.setFollowUp(updatedMalariaData.getFollowUp()); - malariaData.setRemarks(updatedMalariaData.getRemarks()); - malariaData.setMalariaCaseCount(updatedMalariaData.getMalariaCaseCount()); - malariaData.setMalariaCaseStatusDate(updatedMalariaData.getMalariaCaseStatusDate()); - malariaControlRepo.save(malariaData); - return "Data update successfully"; + @Override + public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) { + ObjectMapper objectMapper = new ObjectMapper(); - }).orElseThrow(() -> new RuntimeException("Data not found")); + // Fetch and filter Kala Azar disease records + List filteredList = diseaseKalaAzarRepository.findAll().stream() + .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .collect(Collectors.toList()); + + // Check if the list is empty + if (filteredList.isEmpty()) { + return Collections.singletonMap("message", "No data found for Kala Azar."); + } + + // Map to DTOs + List dtoList = filteredList.stream().map(disease -> { + DiseaseKalaAzarDTO dto = new DiseaseKalaAzarDTO(); + dto.setId(disease.getId()); + dto.setBenId(disease.getBenId()); + dto.setHouseHoldDetailsId(disease.getHouseHoldDetailsId()); + dto.setVisitDate(disease.getVisitDate()); + dto.setBeneficiaryStatus(disease.getBeneficiaryStatus()); + dto.setDateOfDeath(disease.getDateOfDeath()); + dto.setPlaceOfDeath(disease.getPlaceOfDeath()); + dto.setOtherPlaceOfDeath(disease.getOtherPlaceOfDeath()); + dto.setReasonForDeath(disease.getReasonForDeath()); + dto.setOtherReasonForDeath(disease.getOtherReasonForDeath()); + dto.setKalaAzarCaseStatus(disease.getKalaAzarCaseStatus()); + dto.setKalaAzarCaseCount(disease.getKalaAzarCaseCount()); + dto.setRapidDiagnosticTest(disease.getRapidDiagnosticTest()); + dto.setDateOfRdt(disease.getDateOfRdt()); + dto.setFollowUpPoint(disease.getFollowUpPoint()); + dto.setReferredTo(disease.getReferredTo()); + dto.setOtherReferredFacility(disease.getOtherReferredFacility()); + dto.setCreatedDate(disease.getCreatedDate()); + dto.setCreatedBy(disease.getCreatedBy()); + + return dto; + }).collect(Collectors.toList()); + + return dtoList; } - private String updateKalaAzar(KalaAzarData updatedData) { - return kalazarControlRepo.findByBenId(updatedData.getBenId()).map(kalaAzarData -> { - kalaAzarData.setId(updatedData.getId()); - kalaAzarData.setBenId(updatedData.getBenId()); - kalaAzarData.setCaseDate(updatedData.getCaseDate()); - kalaAzarData.setCaseStatus(updatedData.getCaseStatus()); - kalaAzarData.setSymptoms(updatedData.getSymptoms()); - kalaAzarData.setMalariaCaseCount(updatedData.getMalariaCaseCount()); - kalaAzarData.setReferredTo(updatedData.getReferredTo()); - kalaAzarData.setKalaAzarCaseStatusDate(updatedData.getKalaAzarCaseStatusDate()); - kalaAzarData.setRemarks(updatedData.getRemarks()); - kalaAzarData.setFollowUpPoint(updatedData.getFollowUpPoint()); - kalaAzarData.setFollowUpDate(updatedData.getFollowUpDate()); - kalaAzarData.setStatus(updatedData.getStatus()); - kalazarControlRepo.save(kalaAzarData); - return "Data updated successfully"; - }).orElseThrow(() -> new RuntimeException("Data not found")); + + @Override + public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler) { + + return diseaseAESJERepository.findAll(); } - private String updateLeprosy(LeprosyData updateData) { - return leprosyControlRepo.findByBenId(updateData.getBenId()).map(leprosyData -> { - leprosyData.setId(updateData.getId()); - leprosyData.setDateOfHomeVisit(updateData.getDateOfHomeVisit()); - leprosyData.setLeprosyStatus(updateData.getLeprosyStatus()); - leprosyData.setReferredTo(updateData.getReferredTo()); - leprosyData.setOther(updateData.getOther()); - leprosyData.setLeprosyStatusDate(updateData.getLeprosyStatusDate()); - leprosyData.setTypeOfLeprosy(updateData.getTypeOfLeprosy()); - leprosyData.setFollowUpDate(updateData.getFollowUpDate()); - leprosyData.setStatus(updateData.getStatus()); - leprosyData.setRemark(updateData.getRemark()); - leprosyData.setDiseaseTypeID(updateData.getDiseaseTypeID()); - leprosyData.setBenId(updateData.getBenId()); - - leprosyControlRepo.save(leprosyData); - - return "Data updated successfully"; - }).orElseThrow(() -> new RuntimeException("Data not found")); + + + @Override + public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { + ObjectMapper objectMapper = new ObjectMapper(); + + // Fetch and filter Filaria disease records + List filteredList = diseaseFilariasisRepository.findAll().stream() + .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .collect(Collectors.toList()); + + // Check if the list is empty + if (filteredList.isEmpty()) { + return Collections.singletonMap("message", "No data found for Filaria."); + } + + // Map to DTOs + List dtoList = filteredList.stream().map(disease -> { + DiseaseFilariasisDTO dto = new DiseaseFilariasisDTO(); + dto.setId(disease.getId()); + dto.setBenId(disease.getBenId()); + dto.setHouseHoldDetailsId(disease.getHouseHoldDetailsId()); + dto.setSufferingFromFilariasis(disease.getSufferingFromFilariasis()); + dto.setAffectedBodyPart(disease.getAffectedBodyPart()); + dto.setMdaHomeVisitDate(disease.getMdaHomeVisitDate()); + dto.setDoseStatus(disease.getDoseStatus()); + dto.setFilariasisCaseCount(disease.getFilariasisCaseCount()); + dto.setOtherDoseStatusDetails(disease.getOtherDoseStatusDetails()); + dto.setMedicineSideEffect(disease.getMedicineSideEffect()); + dto.setOtherSideEffectDetails(disease.getOtherSideEffectDetails()); + dto.setCreatedDate(disease.getCreatedDate()); + dto.setCreatedBy(disease.getCreatedBy()); + + return dto; + }).collect(Collectors.toList()); + + return dtoList; } - private String updateAesJe(AesJeData updateData) { - return aesJeControlRepo.findByBenId(updateData.getBenId()).map(aesJeData -> { - aesJeData.setId(updateData.getId()); - aesJeData.setCaseDate(updateData.getCaseDate()); - aesJeData.setAesjeCaseStatus(updateData.getAesjeCaseStatus()); - aesJeData.setReferredTo(updateData.getReferredTo()); - aesJeData.setDiseaseTypeID(updateData.getDiseaseTypeID()); - aesJeData.setBenId(updateData.getBenId()); - // Save the updated data (if required, depending on your repo) - aesJeControlRepo.save(aesJeData); + @Override + public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { + ObjectMapper objectMapper = new ObjectMapper(); - return "Data updated successfully"; - }).orElseThrow(() -> new RuntimeException("Data not found")); + // Fetch and filter Leprosy disease records + List filteredList = diseaseLeprosyRepository.findAll().stream() + .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .collect(Collectors.toList()); + + // Check if the list is empty + if (filteredList.isEmpty()) { + return Collections.singletonMap("message", "No data found for Leprosy."); + } + + // Map to DTOs + List dtoList = filteredList.stream().map(disease -> { + DiseaseLeprosyDTO dto = new DiseaseLeprosyDTO(); + dto.setId(disease.getId()); + dto.setBenId(disease.getBenId()); + dto.setHouseHoldDetailsId(disease.getHouseHoldDetailsId()); + dto.setHomeVisitDate(disease.getHomeVisitDate()); + dto.setLeprosyStatus(disease.getLeprosyStatus()); + dto.setReferredTo(disease.getReferredTo()); + dto.setOtherReferredTo(disease.getOtherReferredTo()); + dto.setLeprosyStatusDate(disease.getLeprosyStatusDate()); + dto.setTypeOfLeprosy(disease.getTypeOfLeprosy()); + dto.setFollowUpDate(disease.getFollowUpDate()); + dto.setDiseaseStatus(disease.getDiseaseStatus()); + dto.setRemark(disease.getRemark()); + + return dto; + }).collect(Collectors.toList()); + + return dtoList; } - private String updateFilaria(FilariaData updateData) { - return filariaControlRepo.findByBenId(updateData.getBenId()).map(filariaData -> { - filariaData.setId(updateData.getId()); - filariaData.setSufferingFromFilariasis(updateData.getSufferingFromFilariasis()); - filariaData.setWhichPartOfBody(updateData.getWhichPartOfBody()); - filariaData.setHomeVisitDate(updateData.getHomeVisitDate()); - filariaData.setDecAndAlbendazoleDoseStatus(updateData.getDecAndAlbendazoleDoseStatus()); - filariaData.setMedicineSideEffect(updateData.getMedicineSideEffect()); - filariaData.setOther(updateData.getOther()); - filariaData.setDiseaseTypeID(updateData.getDiseaseTypeID()); - filariaData.setBenId(updateData.getBenId()); - - // Save the updated data (if required, depending on your repo) - filariaControlRepo.save(filariaData); - - return "Data updated successfully"; - }).orElseThrow(() -> new RuntimeException("Data not found")); + + private DiseaseKalaAzar saveKalaAzarDisease(DiseaseKalaAzarDTO dto) { + DiseaseKalaAzar entity = new DiseaseKalaAzar(); + + entity.setBenId(dto.getBenId()); + entity.setHouseHoldDetailsId(dto.getHouseHoldDetailsId()); + entity.setVisitDate(dto.getVisitDate()); + entity.setBeneficiaryStatus(dto.getBeneficiaryStatus()); + entity.setDateOfDeath(dto.getDateOfDeath()); + entity.setPlaceOfDeath(dto.getPlaceOfDeath()); + entity.setOtherPlaceOfDeath(dto.getOtherPlaceOfDeath()); + entity.setReasonForDeath(dto.getReasonForDeath()); + entity.setOtherReasonForDeath(dto.getOtherReasonForDeath()); + entity.setKalaAzarCaseStatus(dto.getKalaAzarCaseStatus()); + entity.setDiseaseTypeId(dto.getDiseaseTypeId()); + entity.setKalaAzarCaseCount(dto.getKalaAzarCaseCount()); + entity.setRapidDiagnosticTest(dto.getRapidDiagnosticTest()); + entity.setDateOfRdt(dto.getDateOfRdt()); + entity.setFollowUpPoint(dto.getFollowUpPoint()); + entity.setReferredTo(dto.getReferredTo()); + entity.setOtherReferredFacility(dto.getOtherReferredFacility()); + entity.setCreatedDate(new Timestamp(System.currentTimeMillis())); // or dto.getCreatedDate() + entity.setCreatedBy(dto.getCreatedBy()); + + DiseaseKalaAzar saved = diseaseKalaAzarRepository.save(entity); + + return saved; // You can also return a custom response or DTO + } + + + private String updateKalaAzarDisease(DiseaseKalaAzarDTO dto) { + Optional optional = diseaseKalaAzarRepository.findByBenId(dto.getBenId()); + + if (!optional.isPresent()) { + return "Record not found with ID: " + dto.getId(); + } + + DiseaseKalaAzar entity = optional.get(); + + // Update fields + entity.setBenId(dto.getBenId()); + entity.setHouseHoldDetailsId(dto.getHouseHoldDetailsId()); + entity.setVisitDate(dto.getVisitDate()); + entity.setBeneficiaryStatus(dto.getBeneficiaryStatus()); + entity.setDateOfDeath(dto.getDateOfDeath()); + entity.setPlaceOfDeath(dto.getPlaceOfDeath()); + entity.setDiseaseTypeId(dto.getDiseaseTypeId()); + entity.setOtherPlaceOfDeath(dto.getOtherPlaceOfDeath()); + entity.setReasonForDeath(dto.getReasonForDeath()); + entity.setOtherReasonForDeath(dto.getOtherReasonForDeath()); + entity.setKalaAzarCaseStatus(dto.getKalaAzarCaseStatus()); + entity.setKalaAzarCaseCount(dto.getKalaAzarCaseCount()); + entity.setRapidDiagnosticTest(dto.getRapidDiagnosticTest()); + entity.setDateOfRdt(dto.getDateOfRdt()); + entity.setFollowUpPoint(dto.getFollowUpPoint()); + entity.setReferredTo(dto.getReferredTo()); + entity.setOtherReferredFacility(dto.getOtherReferredFacility()); + entity.setCreatedBy(dto.getCreatedBy()); + // You can also update createdDate if required + entity.setCreatedDate(new Timestamp(System.currentTimeMillis())); + + diseaseKalaAzarRepository.save(entity); + + return "Kala Azar record updated successfully!"; } + private DiseaseLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { + DiseaseLeprosy diseaseLeprosy = new DiseaseLeprosy(); - private String update(DiseaseControl diseaseControlDTO) { - return diseaseControlRepo.findByBenId(diseaseControlDTO.getBenId()).map(diseaseControl -> { - diseaseControl.setCaseDate(diseaseControlDTO.getCaseDate()); // Added - diseaseControl.setCaseStatus(diseaseControlDTO.getCaseStatus()); - diseaseControl.setSymptoms(diseaseControlDTO.getSymptoms()); - diseaseControl.setMalariaCaseCount(diseaseControlDTO.getMalariaCaseCount()); - diseaseControl.setReferredTo(diseaseControlDTO.getReferredTo()); // Added - diseaseControl.setOtherReferredTo(diseaseControlDTO.getOtherReferredTo()); - diseaseControl.setMalariaCaseStatusDate(diseaseControlDTO.getMalariaCaseStatusDate()); // Added - diseaseControl.setRemarks(diseaseControlDTO.getRemarks()); - diseaseControl.setFollowUpPoint(diseaseControlDTO.getFollowUpPoint()); - diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); - diseaseControl.setFollowUpDate(diseaseControlDTO.getFollowUpDate()); - diseaseControl.setStatus(diseaseControlDTO.getStatus()); - diseaseControl.setBodyPart(diseaseControlDTO.getBodyPart()); - diseaseControl.setSufferingFromFilariasis(diseaseControlDTO.getSufferingFromFilariasis()); - diseaseControl.setOtherStatus(diseaseControlDTO.getOtherStatus()); - diseaseControl.setHomeVisitDate(diseaseControlDTO.getHomeVisitDate()); - diseaseControl.setLeprosyStatusDate(diseaseControlDTO.getLeprosyStatusDate()); - diseaseControl.setMedicineSideEffect(diseaseControlDTO.getMedicineSideEffect()); - diseaseControl.setDiseaseTypeId(diseaseControlDTO.getDiseaseTypeId()); - diseaseControlRepo.save(diseaseControl); + // Setting the values from the DTO to the entity + diseaseLeprosy.setBenId(diseaseControlData.getBenId()); + diseaseLeprosy.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + diseaseLeprosy.setHomeVisitDate(diseaseControlData.getHomeVisitDate()); + diseaseLeprosy.setLeprosyStatus(diseaseControlData.getLeprosyStatus()); + diseaseLeprosy.setReferredTo(diseaseControlData.getReferredTo()); + diseaseLeprosy.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + diseaseLeprosy.setOtherReferredTo(diseaseControlData.getOtherReferredTo()); + diseaseLeprosy.setLeprosyStatusDate(diseaseControlData.getLeprosyStatusDate()); + diseaseLeprosy.setTypeOfLeprosy(diseaseControlData.getTypeOfLeprosy()); + diseaseLeprosy.setFollowUpDate(diseaseControlData.getFollowUpDate()); + diseaseLeprosy.setDiseaseStatus(diseaseControlData.getDiseaseStatus()); + diseaseLeprosy.setRemark(diseaseControlData.getRemark()); + + return diseaseLeprosy; + } + + private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { + // Fetch the existing record from the database using the benId + DiseaseLeprosy existingDiseaseLeprosy = diseaseLeprosyRepository.findByBenId(diseaseControlData.getBenId()) + .orElseThrow(() -> new RuntimeException("Leprosy record not found for benId: " + diseaseControlData.getBenId())); + + // Update the fields from the DTO to the existing entity + existingDiseaseLeprosy.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); + existingDiseaseLeprosy.setHomeVisitDate(diseaseControlData.getHomeVisitDate()); + existingDiseaseLeprosy.setLeprosyStatus(diseaseControlData.getLeprosyStatus()); + existingDiseaseLeprosy.setReferredTo(diseaseControlData.getReferredTo()); + existingDiseaseLeprosy.setDiseaseTypeId(diseaseControlData.getDiseaseTypeId()); + existingDiseaseLeprosy.setOtherReferredTo(diseaseControlData.getOtherReferredTo()); + existingDiseaseLeprosy.setLeprosyStatusDate(diseaseControlData.getLeprosyStatusDate()); + existingDiseaseLeprosy.setTypeOfLeprosy(diseaseControlData.getTypeOfLeprosy()); + existingDiseaseLeprosy.setFollowUpDate(diseaseControlData.getFollowUpDate()); + existingDiseaseLeprosy.setDiseaseStatus(diseaseControlData.getDiseaseStatus()); + existingDiseaseLeprosy.setRemark(diseaseControlData.getRemark()); + + diseaseLeprosyRepository.save(existingDiseaseLeprosy); + // Return the updated entity + return "Data update successfully"; + } + + // Save Malaria + private DiseaseMalaria saveMalariaDisease(DiseaseMalariaDTO requestData) { + DiseaseMalaria diseaseScreening = new DiseaseMalaria(); + + diseaseScreening.setBenId(requestData.getBenId()); + diseaseScreening.setHouseHoldDetailsId(requestData.getHouseHoldDetailsId()); + diseaseScreening.setScreeningDate(requestData.getScreeningDate()); + diseaseScreening.setBeneficiaryStatus(requestData.getBeneficiaryStatus()); + diseaseScreening.setDateOfDeath(requestData.getDateOfDeath()); + diseaseScreening.setPlaceOfDeath(requestData.getPlaceOfDeath()); + diseaseScreening.setOtherPlaceOfDeath(requestData.getOtherPlaceOfDeath()); + diseaseScreening.setReasonForDeath(requestData.getReasonForDeath()); + diseaseScreening.setOtherReasonForDeath(requestData.getOtherReasonForDeath()); + diseaseScreening.setDiseaseTypeId(requestData.getDiseaseTypeId()); + diseaseScreening.setSymptoms(convertSelecteddiseaseScreeningToJson(requestData)); // Convert specific fields to JSON + diseaseScreening.setUserId(requestData.getUserId()); + diseaseScreening.setCaseStatus(requestData.getCaseStatus()); + diseaseScreening.setRapidDiagnosticTest(requestData.getRapidDiagnosticTest()); + diseaseScreening.setDateOfRdt(requestData.getDateOfRdt()); + diseaseScreening.setSlideTestPf(requestData.getSlideTestPf()); + diseaseScreening.setSlideTestPv(requestData.getSlideTestPv()); + diseaseScreening.setDateOfSlideTest(requestData.getDateOfSlideTest()); + diseaseScreening.setSlideNo(requestData.getSlideNo()); + diseaseScreening.setReferredTo(requestData.getReferredTo()); + diseaseScreening.setOtherReferredFacility(requestData.getOtherReferredFacility()); + diseaseScreening.setRemarks(requestData.getRemarks()); + diseaseScreening.setDateOfVisitBySupervisor(requestData.getDateOfVisitBySupervisor()); + diseaseScreening.setCreatedDate(Timestamp.valueOf(LocalDateTime.now())); + checkAndAddIncentives(diseaseScreening); + + return diseaseMalariaRepository.save(diseaseScreening); + } + + // Update Malaria + private String updateMalariaDisease(DiseaseMalariaDTO requestData) { + return diseaseMalariaRepository.findByBenId(requestData.getBenId()).map(diseaseScreening -> { + diseaseScreening.setBenId(requestData.getBenId()); + diseaseScreening.setHouseHoldDetailsId(requestData.getHouseHoldDetailsId()); + diseaseScreening.setScreeningDate(requestData.getScreeningDate()); + diseaseScreening.setBeneficiaryStatus(requestData.getBeneficiaryStatus()); + diseaseScreening.setDateOfDeath(requestData.getDateOfDeath()); + diseaseScreening.setPlaceOfDeath(requestData.getPlaceOfDeath()); + diseaseScreening.setOtherPlaceOfDeath(requestData.getOtherPlaceOfDeath()); + diseaseScreening.setReasonForDeath(requestData.getReasonForDeath()); + diseaseScreening.setOtherReasonForDeath(requestData.getOtherReasonForDeath()); + diseaseScreening.setDiseaseTypeId(requestData.getDiseaseTypeId()); + diseaseScreening.setSymptoms(convertSelecteddiseaseScreeningToJson(requestData)); // Convert specific fields to JSON + diseaseScreening.setUserId(requestData.getUserId()); + diseaseScreening.setCaseStatus(requestData.getCaseStatus()); + diseaseScreening.setRapidDiagnosticTest(requestData.getRapidDiagnosticTest()); + diseaseScreening.setDateOfRdt(requestData.getDateOfRdt()); + diseaseScreening.setSlideTestPf(requestData.getSlideTestPf()); + diseaseScreening.setSlideTestPv(requestData.getSlideTestPv()); + diseaseScreening.setDateOfSlideTest(requestData.getDateOfSlideTest()); + diseaseScreening.setSlideNo(requestData.getSlideNo()); + diseaseScreening.setReferredTo(requestData.getReferredTo()); + diseaseScreening.setOtherReferredFacility(requestData.getOtherReferredFacility()); + diseaseScreening.setRemarks(requestData.getRemarks()); + diseaseScreening.setCreatedDate(Timestamp.valueOf(LocalDateTime.now())); + diseaseScreening.setDateOfVisitBySupervisor(requestData.getDateOfVisitBySupervisor()); + diseaseMalariaRepository.save(diseaseScreening); return "Data update successfully"; }).orElseThrow(() -> new RuntimeException("Data not found")); + } + + + private String convertSelecteddiseaseScreeningToJson(DiseaseMalariaDTO requestData) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + Map diseaseScreeningMap = new HashMap<>(); + diseaseScreeningMap.put("nausea", requestData.isNausea()); + diseaseScreeningMap.put("diarrhea", requestData.isDiarrhea()); + diseaseScreeningMap.put("tiredness", requestData.isTiredness()); + diseaseScreeningMap.put("vomiting", requestData.isVomiting()); + diseaseScreeningMap.put("headache", requestData.isHeadache()); + diseaseScreeningMap.put("feverMoreThanTwoWeeks", requestData.isFeverMoreThanTwoWeeks()); + diseaseScreeningMap.put("fluLikeIllness", requestData.isFluLikeIllness()); + diseaseScreeningMap.put("shakingChills", requestData.isShakingChills()); + + return objectMapper.writeValueAsString(diseaseScreeningMap); + } catch (Exception e) { + throw new RuntimeException("Error converting selected diseaseScreening fields to JSON", e); + } + } + + + private void checkAndAddIncentives(DiseaseMalaria diseaseScreening) { + IncentiveActivity diseaseScreeningActivity; + if (Objects.equals(diseaseScreening.getCaseStatus(), "Confirmed Case")) { + diseaseScreeningActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MALARIA_1", "DISEASECONTROL"); + + } else { + diseaseScreeningActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MALARIA_2", "DISEASECONTROL"); + + } + + if (diseaseScreeningActivity != null) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(diseaseScreeningActivity.getId(), Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()), diseaseScreening.getBenId().longValue()); + if (record == null) { + if (Objects.equals(diseaseScreening.getCaseStatus(), "Confirmed Case")) { + record = new IncentiveActivityRecord(); + record.setActivityId(diseaseScreeningActivity.getId()); + record.setCreatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setCreatedBy(diseaseScreening.getCreatedBy()); + record.setStartDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setEndDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setUpdatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setUpdatedBy(diseaseScreening.getCreatedBy()); + record.setBenId(diseaseScreening.getBenId().longValue()); + record.setAshaId(diseaseScreening.getUserId()); + record.setName(diseaseScreeningActivity.getName()); + record.setAmount(Long.valueOf(diseaseScreeningActivity.getRate())); + recordRepo.save(record); + } else { + record = new IncentiveActivityRecord(); + record.setActivityId(diseaseScreeningActivity.getId()); + record.setCreatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setCreatedBy(diseaseScreening.getCreatedBy()); + record.setStartDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setEndDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setUpdatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString())); + record.setUpdatedBy(diseaseScreening.getCreatedBy()); + record.setBenId(diseaseScreening.getBenId().longValue()); + record.setName(diseaseScreeningActivity.getName()); + record.setAshaId(diseaseScreening.getUserId()); + record.setAmount(Long.valueOf(diseaseScreeningActivity.getRate())); + recordRepo.save(record); + } + + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java new file mode 100644 index 00000000..926f8d90 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java @@ -0,0 +1,64 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.MalariaFollowUp; +import com.iemr.flw.dto.iemr.MalariaFollowListUpDTO; +import com.iemr.flw.dto.iemr.MalariaFollowUpDTO; +import com.iemr.flw.repo.iemr.MalariaFollowUpRepository; +import com.iemr.flw.service.MalariaFollowUpService; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class MalariaFollowUpServiceImpl implements MalariaFollowUpService { + + @Autowired + private MalariaFollowUpRepository repository; + + public String saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO) { + for(MalariaFollowListUpDTO dto : malariaFollowUpDTO.getMalariaFollowListUp()){ + if (dto.getTreatmentStartDate().after(new Date())) { + return "Treatment start date cannot be in the future."; + } + + if (dto.getTreatmentCompletionDate() != null && + dto.getTreatmentCompletionDate().before(dto.getTreatmentStartDate())) { + return "Completion date cannot be before treatment start date."; + } + + if (dto.getReferralDate() != null && + dto.getReferralDate().before(dto.getTreatmentStartDate())) { + return "Referral date must be after treatment start date."; + } + + if ("Pf".equalsIgnoreCase(dto.getTreatmentGiven()) && + !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3())) { + return "At least one Pf day must be selected."; + } + + if ("Pv".equalsIgnoreCase(dto.getTreatmentGiven()) && + !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3()|| dto.getPvDay4())) { + return "At least one Pv day must be selected."; + } + + MalariaFollowUp entity = new MalariaFollowUp(); + BeanUtils.copyProperties(dto, entity); + repository.save(entity); + return "Follow-up saved successfully"; + } + return "Fail"; + } + + public List getByUserId(Integer userId) { + return repository.findByUserId(userId).stream().map(entity -> { + MalariaFollowListUpDTO dto = new MalariaFollowListUpDTO(); + BeanUtils.copyProperties(entity, dto); + return dto; + }).collect(Collectors.toList()); + } + +} diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..571348ed 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + //validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From 138be464f2b48346612b1d8a55013e6dc4d92c05 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 15 Apr 2025 15:16:26 +0530 Subject: [PATCH 085/792] Village level module --- .../flw/controller/VhndFormController.java | 21 ---- .../controller/VilageLevelFormController.java | 41 +++++++ .../flw/domain/iemr/IncentiveActivity.java | 2 + .../flw/domain/iemr/VillageFormEntry.java | 19 ++-- .../iemr/flw/dto/iemr/VilageLevelFormDto.java | 13 +++ ...rmDto.java => VilageLevelFormListDto.java} | 6 +- .../com/iemr/flw/service/VhndFormService.java | 6 +- .../flw/service/impl/VhndFormServiceImpl.java | 105 ++++++++++++------ .../utils/http/HTTPRequestInterceptor.java | 2 +- 9 files changed, 146 insertions(+), 69 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/controller/VhndFormController.java create mode 100644 src/main/java/com/iemr/flw/controller/VilageLevelFormController.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java rename src/main/java/com/iemr/flw/dto/iemr/{VhndFormDto.java => VilageLevelFormListDto.java} (65%) diff --git a/src/main/java/com/iemr/flw/controller/VhndFormController.java b/src/main/java/com/iemr/flw/controller/VhndFormController.java deleted file mode 100644 index a6a1b661..00000000 --- a/src/main/java/com/iemr/flw/controller/VhndFormController.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.iemr.flw.controller; - -import com.iemr.flw.dto.iemr.VhndFormDto; -import com.iemr.flw.service.VhndFormService; -import com.iemr.flw.service.impl.VhndFormServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/api/forms/vhnd") -public class VhndFormController { - - @Autowired - private VhndFormService vhndFormService; - - @PostMapping - public ResponseEntity submitVhndForm(@RequestBody VhndFormDto dto) { - return vhndFormService.submitForm(dto); - } -} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java new file mode 100644 index 00000000..cb7275d8 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -0,0 +1,41 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.VilageLevelFormDto; +import com.iemr.flw.service.VhndFormService; +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; + +@RestController +@RequestMapping(value = "/forms/vilageLevel") +public class VilageLevelFormController { + + @Autowired + private VhndFormService vhndFormService; + + @RequestMapping(value = "saveAll",method = RequestMethod.POST) + public ResponseEntity> submitLevelForm(@RequestBody VilageLevelFormDto dto) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("msg", vhndFormService.submitForm(dto)); + return ResponseEntity.ok(response); + } + + + @RequestMapping(value = "getAll",method = RequestMethod.POST) + public ResponseEntity> getVilageLevelFormData(@RequestBody GetBenRequestHandler getBenRequestHandler) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", vhndFormService.getAll(getBenRequestHandler.getUserId())); + return ResponseEntity.ok(response); + } + + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java index 8972c331..1368fe04 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java @@ -4,6 +4,7 @@ import jakarta.persistence.*; import java.sql.Timestamp; +import java.util.Date; @Entity @Table(name = "incentive_activity", schema = "db_iemr") @@ -55,4 +56,5 @@ public class IncentiveActivity { @Column(name = "is_deleted") private Boolean isDeleted; + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java index 440bd492..f78661a4 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java @@ -20,12 +20,14 @@ public class VillageFormEntry { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "asha_id") - private String ashaId; + @Column(name = "ben_id") + private Long benId; + @Column(name = "userId") + private Integer userId; @Column(name = "form_type") private String formType; - @Column(name = "VHND_date") + @Column(name = "form_date") private Date date; @Column(name = "place") private String place; @@ -36,12 +38,13 @@ public class VillageFormEntry { @Column(name = "image_urls") private String imageUrls; - @Column(name = "incentive_amount") - private double incentiveAmount; - - @Column(name = "fmr_code") - private String fmrCode; @Column(name = "submitted_at") private LocalDateTime submittedAt; + + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "created_by") + private String createdBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java new file mode 100644 index 00000000..6f79415f --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Date; +import java.util.List; + +@Data +public class VilageLevelFormDto { + private Integer userId; + private List vilageLevelFormList; +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java similarity index 65% rename from src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java rename to src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java index e543dd7a..3826aa0f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhndFormDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java @@ -5,11 +5,13 @@ import java.sql.Date; @Data -public class VhndFormDto { - private String ashaId; +public class VilageLevelFormListDto { + private String formType; + private Integer userId; private Date date; private String place; private int participantCount; private String imageUrls; // Comma separated URLs or Base64 if needed + private String createdBy; } diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java index b5466802..19030684 100644 --- a/src/main/java/com/iemr/flw/service/VhndFormService.java +++ b/src/main/java/com/iemr/flw/service/VhndFormService.java @@ -1,7 +1,7 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.VillageFormEntry; -import com.iemr.flw.dto.iemr.VhndFormDto; +import com.iemr.flw.dto.iemr.VilageLevelFormDto; import com.iemr.flw.repo.iemr.VillageFormRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -9,10 +9,12 @@ import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; @Service public interface VhndFormService { - public ResponseEntity submitForm(VhndFormDto dto) ; + public String submitForm(VilageLevelFormDto dto) ; + public List getAll(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java index 93c64767..b6359bcb 100644 --- a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java @@ -1,9 +1,13 @@ package com.iemr.flw.service.impl; import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.domain.iemr.VillageFormEntry; -import com.iemr.flw.dto.iemr.VhndFormDto; +import com.iemr.flw.dto.iemr.VilageLevelFormDto; +import com.iemr.flw.dto.iemr.VilageLevelFormListDto; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.repo.iemr.VillageFormRepository; import com.iemr.flw.service.IncentiveService; import com.iemr.flw.service.VhndFormService; @@ -11,9 +15,13 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import java.sql.Date; import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; @Service public class VhndFormServiceImpl implements VhndFormService { @@ -21,45 +29,72 @@ public class VhndFormServiceImpl implements VhndFormService { @Autowired private VillageFormRepository repository; @Autowired - private IncentivesRepo incentivesRepo; + private IncentiveRecordRepo recordRepo; @Autowired - private IncentiveService incentiveService; + private UserServiceRoleRepo userRepo; + + @Autowired + private IncentivesRepo incentivesRepo; + + + public String submitForm(VilageLevelFormDto vilageLevelFormDto) { + for(VilageLevelFormListDto dto : vilageLevelFormDto.getVilageLevelFormList()){ + if (dto.getUserId() == null || dto.getDate() == null || dto.getPlace() == null || dto.getParticipantCount() <= 0) { + return "Missing or invalid fields"; + } + + + VillageFormEntry entry = new VillageFormEntry(); + entry.setUserId(dto.getUserId()); + entry.setFormType(dto.getFormType()); + entry.setDate(dto.getDate()); + entry.setPlace(dto.getPlace()); + entry.setParticipantCount(dto.getParticipantCount()); + entry.setImageUrls(dto.getImageUrls()); + entry.setSubmittedAt(LocalDateTime.now()); + entry.setCreatedDate(Date.valueOf(LocalDate.now())); + entry.setCreatedBy(dto.getCreatedBy()); + + repository.save(entry); + checkAndAddIncentives(entry); + return "Form submitted successfully"; - public ResponseEntity submitForm(VhndFormDto dto) { - if (dto.getAshaId() == null || dto.getDate() == null || dto.getPlace() == null || dto.getParticipantCount() <= 0) { - return ResponseEntity.badRequest().body("Missing or invalid fields"); - } - IncentiveActivity existing = incentivesRepo.findIncentiveMasterByNameAndGroup("VHND", "ASHA"); - - - VillageFormEntry entry = new VillageFormEntry(); - entry.setAshaId(dto.getAshaId()); - entry.setFormType("VHND"); - entry.setDate(dto.getDate()); - entry.setPlace(dto.getPlace()); - entry.setParticipantCount(dto.getParticipantCount()); - entry.setImageUrls(dto.getImageUrls()); - entry.setIncentiveAmount(200); - entry.setFmrCode("3.1.1.6.1"); - entry.setSubmittedAt(LocalDateTime.now()); - - repository.save(entry); - // Call IncentiveService to save to master - - if (existing == null) { - IncentiveActivity activity = new IncentiveActivity(); - activity.setName("VHND"); - activity.setGroup("ASHA"); - activity.setRate(200); - activity.setFmrCode("3.1.1.6.1"); - activity.setCreatedBy("system"); - activity.setCreatedDate(Timestamp.valueOf(LocalDateTime.now())); - activity.setIsDeleted(false); - incentivesRepo.save(activity); } + return "Fail"; + + } + + @Override + public List getAll(Integer userId) { + return repository.findAll().stream().filter(villageFormEntry -> villageFormEntry.getUserId().equals(userId)).collect(Collectors.toList()); + } - return ResponseEntity.ok().body("Form submitted successfully. Incentive: Rs. 200"); + + private void checkAndAddIncentives(VillageFormEntry villageFormEntry) { + IncentiveActivity villageFormEntryActivity; + villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(villageFormEntry.getFormType(), "VILLAGELEVEL"); + + if (villageFormEntryActivity != null) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), Timestamp.valueOf(villageFormEntry.getCreatedDate().toString()), villageFormEntry.getBenId().longValue()); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(villageFormEntryActivity.getId()); + record.setCreatedDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setCreatedBy(villageFormEntry.getCreatedBy()); + record.setStartDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setEndDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setUpdatedDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setUpdatedBy(villageFormEntry.getCreatedBy()); + record.setBenId(villageFormEntry.getBenId().longValue()); + record.setAshaId(villageFormEntry.getUserId()); + record.setName(villageFormEntryActivity.getName()); + record.setAmount(Long.valueOf(villageFormEntryActivity.getRate())); + recordRepo.save(record); + + } + } } } diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..1be92c65 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); +// validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From cc42cf5934d596d043bf4eb96fe3ca9c171e2738 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 15 Apr 2025 16:01:14 +0530 Subject: [PATCH 086/792] disease module --- .../iemr/flw/domain/iemr/DiseaseAesje.java | 4 +++ .../flw/domain/iemr/DiseaseFilariasis.java | 3 +- .../iemr/flw/domain/iemr/DiseaseKalaAzar.java | 10 +++++- .../iemr/flw/domain/iemr/DiseaseLeprosy.java | 3 +- .../iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java | 2 ++ .../impl/DiseaseControlServiceImpl.java | 31 +++++++++++-------- 6 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java index 7af81951..8e91e4ad 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java @@ -2,6 +2,7 @@ import jakarta.persistence.*; import lombok.Data; +import org.checkerframework.checker.units.qual.N; import java.util.Date; @@ -71,5 +72,8 @@ public class DiseaseAesje { @Column(name = "diseaseTypeID") private Integer diseaseTypeId; + @Column(name = "userID") + private Integer userId; + // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java index f33a1f87..7df88f2f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java @@ -56,5 +56,6 @@ public class DiseaseFilariasis { @Column(name = "diseaseTypeID") private Integer diseaseTypeId; - // Getters and Setters + @Column(name = "userID") + private Integer userId; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java index d8b3efa1..afef7750 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java @@ -76,5 +76,13 @@ public class DiseaseKalaAzar { @Column(name = "diseaseTypeID") private Integer diseaseTypeId; - // Getters and Setters + + @Column(name = "userID") + private Integer userId; + + @Column(name = "refer_to_name") + private String referToName; + + @Column(name = "beneficiary_statusId") + private Integer beneficiaryStatusId; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java index 2528e204..d5245f96 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java @@ -54,6 +54,7 @@ public class DiseaseLeprosy { @Column(name = "diseaseTypeID") private Integer diseaseTypeId; + @Column(name = "userID") + private Integer userId; - // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java index 7dda95d5..1f4398e2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java @@ -27,6 +27,8 @@ public class DiseaseKalaAzarDTO { private String createdBy; private Integer userId; private Integer diseaseTypeId; + private String referToName; + private Integer beneficiaryStatusId; // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index f97deb48..22f974f7 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -46,7 +46,7 @@ public String saveMalaria(MalariaDTO diseaseControlDTO) { return updateMalariaDisease(diseaseControlData); } else { if (diseaseControlDTO.getUserId() != null) { - diseaseControlData.setUserId(diseaseControlData.getUserId()); + diseaseControlData.setUserId(diseaseControlDTO.getUserId()); } diseaseMalariaRepository.save(saveMalariaDisease(diseaseControlData)); return "Data add successfully"; @@ -64,7 +64,7 @@ public String saveKalaAzar(KalaAzarDTO diseaseControlDTO) { return updateKalaAzarDisease(diseaseControlData); } else { if (diseaseControlDTO.getUserId() != null) { - diseaseControlData.setUserId(diseaseControlData.getUserId()); + diseaseControlData.setUserId(diseaseControlDTO.getUserId()); } diseaseKalaAzarRepository.save(saveKalaAzarDisease(diseaseControlData)); return "Data add successfully"; @@ -83,7 +83,7 @@ public String saveAES(AesJeDTO diseaseControlDTO) { return updateASEDisease(diseaseControlData); } else { if (diseaseControlDTO.getUserId() != null) { - diseaseControlData.setUserId(diseaseControlData.getUserId()); + diseaseControlData.setUserId(diseaseControlDTO.getUserId()); } diseaseAESJERepository.save(saveASEDisease(diseaseControlData)); return "Data add successfully"; @@ -100,7 +100,7 @@ public String saveFilaria(FilariaDTO diseaseControlDTO) { return updateFilaria(diseaseControlData); } else { if (diseaseControlDTO.getUserId() != null) { - diseaseControlData.setUserId(diseaseControlData.getUserId()); + diseaseControlData.setUserId(diseaseControlDTO.getUserId()); } diseaseFilariasisRepository.save(saveFilariasisData(diseaseControlData)); return "Data add successfully"; @@ -223,7 +223,7 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { return updateLeprosyData(diseaseControlData); } else { if (diseaseControlDTO.getUserId() != null) { - diseaseControlData.setUserId(diseaseControlData.getUserId()); + diseaseControlData.setUserId(diseaseControlDTO.getUserId()); } diseaseLeprosyRepository.save(saveLeprosyData(diseaseControlData)); return "Data add successfully"; @@ -239,7 +239,7 @@ public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter malaria disease records List filteredList = diseaseMalariaRepository.findAll().stream() - .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) .collect(Collectors.toList()); // Check if the list is empty @@ -302,11 +302,10 @@ public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { @Override public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) { - ObjectMapper objectMapper = new ObjectMapper(); // Fetch and filter Kala Azar disease records List filteredList = diseaseKalaAzarRepository.findAll().stream() - .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .filter(disease -> (Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId()))) .collect(Collectors.toList()); // Check if the list is empty @@ -336,6 +335,8 @@ public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) dto.setOtherReferredFacility(disease.getOtherReferredFacility()); dto.setCreatedDate(disease.getCreatedDate()); dto.setCreatedBy(disease.getCreatedBy()); + dto.setBeneficiaryStatusId(disease.getBeneficiaryStatusId()); + dto.setReferToName(disease.getReferToName()); return dto; }).collect(Collectors.toList()); @@ -347,17 +348,16 @@ public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) @Override public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler) { - return diseaseAESJERepository.findAll(); + return diseaseAESJERepository.findAll().stream().filter(diseaseAesje -> Objects.equals(diseaseAesje.getUserId(), getDiseaseRequestHandler.getUserId())).collect(Collectors.toList()); } @Override public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { - ObjectMapper objectMapper = new ObjectMapper(); // Fetch and filter Filaria disease records List filteredList = diseaseFilariasisRepository.findAll().stream() - .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) .collect(Collectors.toList()); // Check if the list is empty @@ -391,11 +391,10 @@ public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { @Override public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { - ObjectMapper objectMapper = new ObjectMapper(); // Fetch and filter Leprosy disease records List filteredList = diseaseLeprosyRepository.findAll().stream() - .filter(disease -> disease.getDiseaseTypeId() == getDiseaseRequestHandler.getDiseaseTypeID()) + .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) .collect(Collectors.toList()); // Check if the list is empty @@ -448,6 +447,9 @@ private DiseaseKalaAzar saveKalaAzarDisease(DiseaseKalaAzarDTO dto) { entity.setOtherReferredFacility(dto.getOtherReferredFacility()); entity.setCreatedDate(new Timestamp(System.currentTimeMillis())); // or dto.getCreatedDate() entity.setCreatedBy(dto.getCreatedBy()); + entity.setBeneficiaryStatusId(dto.getBeneficiaryStatusId()); + entity.setReferToName(dto.getReferToName()); + entity.setUserId(dto.getUserId()); DiseaseKalaAzar saved = diseaseKalaAzarRepository.save(entity); @@ -485,6 +487,9 @@ private String updateKalaAzarDisease(DiseaseKalaAzarDTO dto) { entity.setCreatedBy(dto.getCreatedBy()); // You can also update createdDate if required entity.setCreatedDate(new Timestamp(System.currentTimeMillis())); + entity.setReferToName(dto.getReferToName()); + entity.setBeneficiaryStatusId(dto.getBeneficiaryStatusId()); + entity.setUserId(dto.getUserId()); diseaseKalaAzarRepository.save(entity); From b106104c3ce08198ceab8e63c60c73a2706a505e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 16 Apr 2025 14:34:32 +0530 Subject: [PATCH 087/792] Adolescence health --- .../AdolescentHealthController.java | 11 ++-- .../flw/domain/iemr/AdolescentHealth.java | 12 ++++- .../flw/repo/iemr/AdolescentHealthRepo.java | 2 + .../flw/service/AdolescentHealthService.java | 3 +- .../impl/AdolescentHealthServiceImpl.java | 50 +++++++++++++++++-- 5 files changed, 66 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java index 695e741c..4584d8fa 100644 --- a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java +++ b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java @@ -1,5 +1,6 @@ package com.iemr.flw.controller; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.AdolescentHealthDTO; import com.iemr.flw.service.AdolescentHealthService; import com.iemr.flw.utils.response.OutputResponse; @@ -22,7 +23,7 @@ public class AdolescentHealthController { @Autowired private AdolescentHealthService adolescentHealthService; - @RequestMapping(name = "/savAll", method = RequestMethod.POST) + @RequestMapping(name = "/savAll", method = RequestMethod.POST,headers = "Authorization") public String saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHealthDTO) { OutputResponse response = new OutputResponse(); response.setResponse(adolescentHealthService.saveAll(adolescentHealthDTO)); @@ -44,12 +45,12 @@ public String saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHe } - @RequestMapping(name = "/getAll",method = RequestMethod.GET) - public String getAllAdolescentHealth() { + @RequestMapping(name = "/getAll",method = RequestMethod.POST,headers = "Authorization") + public String getAllAdolescentHealth(@RequestBody GetBenRequestHandler getBenRequestHandler) { OutputResponse response = new OutputResponse(); try { - if (adolescentHealthService.getAllAdolescentHealth().size() != 0) { - response.setResponse(adolescentHealthService.getAllAdolescentHealth().toString()); + if (adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler).size() != 0) { + response.setResponse(adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler).toString()); } else diff --git a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java index 78c71f60..948a3ab4 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java @@ -61,8 +61,16 @@ public class AdolescentHealth { @Column(name = "referral_status") private String referralStatus; - @Column(name = "incentive_amount") - private BigDecimal incentiveAmount; + @Column(name = "userID") + private Integer userId; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "created_by") + private String createdBy; + } diff --git a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java index f52967d4..17be21d8 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java @@ -5,9 +5,11 @@ import org.springframework.stereotype.Repository; import java.math.BigInteger; +import java.util.List; import java.util.Optional; @Repository public interface AdolescentHealthRepo extends JpaRepository { Optional findByBenId(BigInteger benId); + List findByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java index a2bd148e..647bac51 100644 --- a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java +++ b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java @@ -1,6 +1,7 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.AdolescentHealth; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.AdolescentHealthDTO; import org.springframework.stereotype.Service; @@ -8,6 +9,6 @@ @Service public interface AdolescentHealthService { String saveAll(AdolescentHealthDTO adolescentHealthDTO); - List getAllAdolescentHealth(); + List getAllAdolescentHealth(GetBenRequestHandler getBenRequestHandler); } diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index cce2f618..3e70c2ca 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -1,13 +1,21 @@ package com.iemr.flw.service.impl; import com.iemr.flw.domain.iemr.AdolescentHealth; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.AdolescentHealthDTO; import com.iemr.flw.repo.iemr.AdolescentHealthRepo; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.AdolescentHealthService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.sql.Timestamp; import java.util.List; +import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -16,6 +24,15 @@ public class AdolescentHealthServiceImpl implements AdolescentHealthService { @Autowired private AdolescentHealthRepo adolescentHealthRepo; + @Autowired + private IncentiveRecordRepo recordRepo; + @Autowired + private UserServiceRoleRepo userRepo; + + @Autowired + private IncentivesRepo incentivesRepo; + + @Override public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { for (AdolescentHealth adolescentHealth : adolescentHealthDTO.getAdolescentHealths()) { @@ -28,6 +45,7 @@ public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { } else { // If the record does not exist, create a new one adolescentHealthRepo.save(adolescentHealth); + checkAndAddIncentives(adolescentHealth); } } @@ -37,9 +55,9 @@ public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { - public List getAllAdolescentHealth() { + public List getAllAdolescentHealth(GetBenRequestHandler getBenRequestHandler) { // Fetch all records from the database - List adolescentHealths = adolescentHealthRepo.findAll(); + List adolescentHealths = adolescentHealthRepo.findByUserId(getBenRequestHandler.getUserId()); // Convert the list of entity objects to DTO objects return adolescentHealths.stream() @@ -65,7 +83,6 @@ private void updateAdolescentHealth(Optional existingRecord, A existingAdolescentHealth.setCounselingType(adolescentHealth.getCounselingType()); existingAdolescentHealth.setFollowUpDate(adolescentHealth.getFollowUpDate()); existingAdolescentHealth.setReferralStatus(adolescentHealth.getReferralStatus()); - existingAdolescentHealth.setIncentiveAmount(adolescentHealth.getIncentiveAmount()); // Save the updated record back to the database adolescentHealthRepo.save(existingAdolescentHealth); @@ -89,8 +106,33 @@ private AdolescentHealth convertToDTO(AdolescentHealth adolescentHealth) { dto.setCounselingType(adolescentHealth.getCounselingType()); dto.setFollowUpDate(adolescentHealth.getFollowUpDate()); dto.setReferralStatus(adolescentHealth.getReferralStatus()); - dto.setIncentiveAmount(adolescentHealth.getIncentiveAmount()); return dto; } + + private void checkAndAddIncentives(AdolescentHealth adolescentHealth) { + IncentiveActivity incentiveActivity; + incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("AHD", "ADOLESCENT_HEALTH"); + + + if (incentiveActivity != null) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(adolescentHealth.getCreatedDate().toString()), adolescentHealth.getBenId().longValue()); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setCreatedBy(adolescentHealth.getCreatedBy()); + record.setStartDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setEndDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setUpdatedDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setUpdatedBy(adolescentHealth.getCreatedBy()); + record.setBenId(adolescentHealth.getBenId().longValue()); + record.setAshaId(adolescentHealth.getUserId()); + record.setName(incentiveActivity.getName()); + record.setAmount(Long.valueOf(incentiveActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); + recordRepo.save(record); + } + } + } } From a6cb468cd744a723c9e64d3c25103e6f42bdee9b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 16 Apr 2025 17:21:46 +0530 Subject: [PATCH 088/792] Adolescence health --- .../AdolescentHealthController.java | 43 +++++++++++-------- .../flw/domain/iemr/AdolescentHealth.java | 12 ++---- .../flw/repo/iemr/AdolescentHealthRepo.java | 2 +- .../impl/AdolescentHealthServiceImpl.java | 18 ++++---- .../utils/http/HTTPRequestInterceptor.java | 2 +- 5 files changed, 41 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java index 4584d8fa..1844dfe2 100644 --- a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java +++ b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java @@ -6,60 +6,67 @@ import com.iemr.flw.utils.response.OutputResponse; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; 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.RestController; +import java.util.HashMap; import java.util.List; +import java.util.Map; @RestController @RequestMapping(value = "/adolescentHealth", headers = "Authorization") - public class AdolescentHealthController { private final org.slf4j.Logger logger = LoggerFactory.getLogger(AdolescentHealthController.class); @Autowired private AdolescentHealthService adolescentHealthService; - @RequestMapping(name = "/savAll", method = RequestMethod.POST,headers = "Authorization") - public String saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHealthDTO) { - OutputResponse response = new OutputResponse(); - response.setResponse(adolescentHealthService.saveAll(adolescentHealthDTO)); + @RequestMapping(value = "/savAll", method = RequestMethod.POST, headers = "Authorization") + public ResponseEntity> saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHealthDTO) { + Map response = new HashMap<>(); + try { if (adolescentHealthDTO.getAdolescentHealths().size() != 0) { String result = adolescentHealthService.saveAll(adolescentHealthDTO); if (result != null) { - response.setResponse(result); + response.put("statusCode",200); + response.put("message",result); } } else - response.setError(500, "Invalid/NULL request obj"); + response.put("statusCode",500); + response.put("error","Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in get data : " + e); - response.setError(500, "Error in get data : " + e); + response.put("statusCode",500); + response.put("error","Error in get data : " + e); } - return response.toString(); + return ResponseEntity.ok(response); } - @RequestMapping(name = "/getAll",method = RequestMethod.POST,headers = "Authorization") - public String getAllAdolescentHealth(@RequestBody GetBenRequestHandler getBenRequestHandler) { - OutputResponse response = new OutputResponse(); + @RequestMapping(value = "/getAll",method = RequestMethod.POST, headers = "Authorization") + public ResponseEntity> getAllAdolescentHealth(@RequestBody GetBenRequestHandler getBenRequestHandler) { + Map response = new HashMap<>(); try { if (adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler).size() != 0) { - response.setResponse(adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler).toString()); - - + response.put("statusCode",200); + response.put("data",adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler)); } else - response.setError(500, "Invalid/NULL request obj"); + response.put("statusCode",500); + response.put("error","Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in get data : " + e); - response.setError(500, "Error in get data : " + e); + response.put("statusCode",500); + response.put("error","Error in get data : " + e); + } - return response.toString(); + return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java index 948a3ab4..8fd4027b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java @@ -6,6 +6,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.sql.Date; +import java.sql.Timestamp; @Entity @Data @@ -20,10 +21,10 @@ public class AdolescentHealth { private BigInteger benId; @Column(name = "userID") - private Long userID; + private Integer userID; @Column(name = "visit_date") - private Date visitDate; + private Timestamp visitDate; @Column(name = "health_status") private String healthStatus; @@ -61,16 +62,11 @@ public class AdolescentHealth { @Column(name = "referral_status") private String referralStatus; - @Column(name = "userID") - private Integer userId; - - @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_date") - private Date createdDate; + private Timestamp createdDate; @Column(name = "created_by") private String createdBy; - } diff --git a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java index 17be21d8..7ec1fd5c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java @@ -11,5 +11,5 @@ @Repository public interface AdolescentHealthRepo extends JpaRepository { Optional findByBenId(BigInteger benId); - List findByUserId(Integer userId); + List findByUserID(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index 3e70c2ca..e665e9a3 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -10,10 +10,13 @@ import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.AdolescentHealthService; +import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.sql.Date; import java.sql.Timestamp; +import java.time.LocalDate; import java.util.List; import java.util.Objects; import java.util.Optional; @@ -57,7 +60,7 @@ public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { public List getAllAdolescentHealth(GetBenRequestHandler getBenRequestHandler) { // Fetch all records from the database - List adolescentHealths = adolescentHealthRepo.findByUserId(getBenRequestHandler.getUserId()); + List adolescentHealths = adolescentHealthRepo.findByUserID(getBenRequestHandler.getUserId()); // Convert the list of entity objects to DTO objects return adolescentHealths.stream() @@ -113,21 +116,20 @@ private void checkAndAddIncentives(AdolescentHealth adolescentHealth) { IncentiveActivity incentiveActivity; incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("AHD", "ADOLESCENT_HEALTH"); - if (incentiveActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(adolescentHealth.getCreatedDate().toString()), adolescentHealth.getBenId().longValue()); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); - record.setCreatedDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setCreatedDate(adolescentHealth.getCreatedDate()); record.setCreatedBy(adolescentHealth.getCreatedBy()); - record.setStartDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); - record.setEndDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); - record.setUpdatedDate(Timestamp.valueOf(adolescentHealth.getCreatedDate().toString())); + record.setStartDate(adolescentHealth.getCreatedDate()); + record.setEndDate(adolescentHealth.getCreatedDate()); + record.setUpdatedDate(adolescentHealth.getCreatedDate()); record.setUpdatedBy(adolescentHealth.getCreatedBy()); record.setBenId(adolescentHealth.getBenId().longValue()); - record.setAshaId(adolescentHealth.getUserId()); + record.setAshaId(adolescentHealth.getUserID()); record.setName(incentiveActivity.getName()); record.setAmount(Long.valueOf(incentiveActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); recordRepo.save(record); diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..571348ed 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + //validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From 30f158cb218fe23be691508f14f629068bc56136 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 17 Apr 2025 14:21:02 +0530 Subject: [PATCH 089/792] AdolescentHealth module --- .../com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index e665e9a3..4857dd24 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -86,6 +86,8 @@ private void updateAdolescentHealth(Optional existingRecord, A existingAdolescentHealth.setCounselingType(adolescentHealth.getCounselingType()); existingAdolescentHealth.setFollowUpDate(adolescentHealth.getFollowUpDate()); existingAdolescentHealth.setReferralStatus(adolescentHealth.getReferralStatus()); + existingAdolescentHealth.setCreatedBy(adolescentHealth.getCreatedBy()); + existingAdolescentHealth.setCreatedDate(adolescentHealth.getCreatedDate()); // Save the updated record back to the database adolescentHealthRepo.save(existingAdolescentHealth); From e2142d9586e8c37f59b2954cf549320d2a12ee98 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 17 Apr 2025 14:31:01 +0530 Subject: [PATCH 090/792] AdolescentHealth module --- .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 571348ed..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - //validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From f42749c739505ba885afb8deeb6436ca17f18975 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 17 Apr 2025 18:14:43 +0530 Subject: [PATCH 091/792] AdolescentHealth module --- .../impl/AdolescentHealthServiceImpl.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index 4857dd24..65ff23e1 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -115,15 +115,15 @@ private AdolescentHealth convertToDTO(AdolescentHealth adolescentHealth) { } private void checkAndAddIncentives(AdolescentHealth adolescentHealth) { - IncentiveActivity incentiveActivity; - incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("AHD", "ADOLESCENT_HEALTH"); + IncentiveActivity sellingSanitaryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SELLING_SANITARY", "ADOLESCENT_HEALTH"); + IncentiveActivity mobilizingADHActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILIZING_ADOLESCENTS", "ADOLESCENT_HEALTH"); - if (incentiveActivity != null) { + if (sellingSanitaryActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); + .findRecordByActivityIdCreatedDateBenId(sellingSanitaryActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); if (record == null) { record = new IncentiveActivityRecord(); - record.setActivityId(incentiveActivity.getId()); + record.setActivityId(sellingSanitaryActivity.getId()); record.setCreatedDate(adolescentHealth.getCreatedDate()); record.setCreatedBy(adolescentHealth.getCreatedBy()); record.setStartDate(adolescentHealth.getCreatedDate()); @@ -132,8 +132,29 @@ record = new IncentiveActivityRecord(); record.setUpdatedBy(adolescentHealth.getCreatedBy()); record.setBenId(adolescentHealth.getBenId().longValue()); record.setAshaId(adolescentHealth.getUserID()); - record.setName(incentiveActivity.getName()); - record.setAmount(Long.valueOf(incentiveActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); + record.setName(sellingSanitaryActivity.getName()); + record.setAmount(Long.valueOf(sellingSanitaryActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); + recordRepo.save(record); + } + } + + + if (mobilizingADHActivity != null) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(mobilizingADHActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(mobilizingADHActivity.getId()); + record.setCreatedDate(adolescentHealth.getCreatedDate()); + record.setCreatedBy(adolescentHealth.getCreatedBy()); + record.setStartDate(adolescentHealth.getCreatedDate()); + record.setEndDate(adolescentHealth.getCreatedDate()); + record.setUpdatedDate(adolescentHealth.getCreatedDate()); + record.setUpdatedBy(adolescentHealth.getCreatedBy()); + record.setBenId(adolescentHealth.getBenId().longValue()); + record.setAshaId(adolescentHealth.getUserID()); + record.setName(mobilizingADHActivity.getName()); + record.setAmount(Long.valueOf(mobilizingADHActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); recordRepo.save(record); } } From a0042cbacfa96e8909358bf6a4c4aa04816c1bc4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 18 Apr 2025 15:06:24 +0530 Subject: [PATCH 092/792] Disease control module --- .../controller/DiseaseControlController.java | 122 ++++++++++++------ .../controller/MalariaFollowUpController.java | 6 +- .../iemr/flw/domain/iemr/DiseaseControl.java | 77 ----------- ...{DiseaseAesje.java => ScreeningAesje.java} | 18 +-- ...lariasis.java => ScreeningFilariasis.java} | 5 +- ...seKalaAzar.java => ScreeningKalaAzar.java} | 37 +++--- ...easeLeprosy.java => ScreeningLeprosy.java} | 31 ++++- ...easeMalaria.java => ScreeningMalaria.java} | 7 +- .../iemr/flw/dto/iemr/DiseaseAesjeDto.java | 5 +- .../iemr/flw/dto/iemr/DiseaseControlDTO.java | 18 --- .../iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java | 1 - .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 9 +- .../iemr/flw/dto/iemr/DiseaseMalariaDTO.java | 2 - .../com/iemr/flw/masterEnum/DiseaseType.java | 31 +++++ .../flw/repo/iemr/DiseaseAESJERepository.java | 7 +- .../flw/repo/iemr/DiseaseControlRepo.java | 12 -- .../iemr/DiseaseFilariasisRepository.java | 6 +- .../repo/iemr/DiseaseKalaAzarRepository.java | 6 +- .../repo/iemr/DiseaseLeprosyRepository.java | 6 +- .../repo/iemr/DiseaseMalariaRepository.java | 6 +- .../flw/service/DiseaseControlService.java | 15 +-- .../impl/DiseaseControlServiceImpl.java | 113 +++++++++++----- 22 files changed, 284 insertions(+), 256 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java rename src/main/java/com/iemr/flw/domain/iemr/{DiseaseAesje.java => ScreeningAesje.java} (85%) rename src/main/java/com/iemr/flw/domain/iemr/{DiseaseFilariasis.java => ScreeningFilariasis.java} (94%) rename src/main/java/com/iemr/flw/domain/iemr/{DiseaseKalaAzar.java => ScreeningKalaAzar.java} (64%) rename src/main/java/com/iemr/flw/domain/iemr/{DiseaseLeprosy.java => ScreeningLeprosy.java} (61%) rename src/main/java/com/iemr/flw/domain/iemr/{DiseaseMalaria.java => ScreeningMalaria.java} (92%) delete mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java create mode 100644 src/main/java/com/iemr/flw/masterEnum/DiseaseType.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index e9e392cd..85a48599 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -1,7 +1,15 @@ package com.iemr.flw.controller; -import com.iemr.flw.dto.iemr.*; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.dto.iemr.AesJeDTO; +import com.iemr.flw.dto.iemr.FilariaDTO; +import com.iemr.flw.dto.iemr.KalaAzarDTO; +import com.iemr.flw.dto.iemr.MalariaDTO; +import com.iemr.flw.dto.iemr.LeprosyDTO; +import com.iemr.flw.dto.iemr.GetDiseaseRequestHandler; import com.iemr.flw.service.DiseaseControlService; +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.RequestBody; @@ -13,90 +21,120 @@ import java.util.Map; @RestController -@RequestMapping(value = "/disease") +@RequestMapping(value = "/disease",headers = "Authorization") public class DiseaseControlController { + private final Logger logger = LoggerFactory.getLogger(CoupleController.class); @Autowired private DiseaseControlService diseaseControlService; - @RequestMapping(value = "Malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") + @RequestMapping(value = "Malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveMalaria(@RequestBody MalariaDTO malariaDTO) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveMalaria(malariaDTO)); + try { + + logger.info("Malaria DTO: {}", new ObjectMapper().writeValueAsString(malariaDTO)); + if(!malariaDTO.getMalariaLists().isEmpty()){ + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveMalaria(malariaDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 200); + } + + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } return ResponseEntity.ok(response); } - @RequestMapping(value = "KalaAzar/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public ResponseEntity> saveMalaria(@RequestBody KalaAzarDTO kalaAzarDTO) { + @RequestMapping(value = "KalaAzar/saveAll", method = RequestMethod.POST,consumes = "application/json", produces = "application/json",headers = "Authorization") + public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO kalaAzarDTO) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); + try { + logger.info("KalaAzar DTO: {}", new ObjectMapper().writeValueAsString(kalaAzarDTO)); + + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } return ResponseEntity.ok(response); } - @RequestMapping(value = "AesJe/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public ResponseEntity> saveMalaria(@RequestBody AesJeDTO aesJeDTO) { + @RequestMapping(value = "AesJe/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJeDTO) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveAES(aesJeDTO)); + try { + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveAES(aesJeDTO)); + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } return ResponseEntity.ok(response); } - @RequestMapping(value = "Filaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public ResponseEntity> saveMalaria(@RequestBody FilariaDTO filariaDTO) { + @RequestMapping(value = "Filaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + public ResponseEntity> saveFilaria(@RequestBody FilariaDTO filariaDTO) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveFilaria(filariaDTO)); + try { + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveFilaria(filariaDTO)); + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } return ResponseEntity.ok(response); } - @RequestMapping(value = "Leprosy/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public ResponseEntity> saveMalaria(@RequestBody LeprosyDTO leprosyDTO) { + @RequestMapping(value = "Leprosy/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO leprosyDTO) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); + try { + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } + return ResponseEntity.ok(response); } - @RequestMapping(value = "getAll", method = RequestMethod.POST, produces = "application/json") + @RequestMapping(value = "getAll", method = RequestMethod.POST, produces = "application/json",headers = "Authorization") public ResponseEntity> getAllData(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - if (getDiseaseRequestHandler.getDiseaseTypeID() == 1) { - response.put("data", diseaseControlService.getAllMalaria(getDiseaseRequestHandler)); - - } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 2) { - response.put("data", diseaseControlService.getAllKalaAzar(getDiseaseRequestHandler)); - - } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 3) { - response.put("data", diseaseControlService.getAllKalaAES(getDiseaseRequestHandler)); + try { + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.getAllScreeningData(getDiseaseRequestHandler)); - } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 4) { - response.put("data", diseaseControlService.getAllFilaria(getDiseaseRequestHandler)); - - } else if (getDiseaseRequestHandler.getDiseaseTypeID() == 5) { - response.put("data", diseaseControlService.getAllLeprosy(getDiseaseRequestHandler)); + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); } + return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index ba278262..db564a95 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -13,13 +13,13 @@ import java.util.Map; @RestController -@RequestMapping(value = "/api/follow-up") +@RequestMapping(value = "/api/follow-up",headers = "Authorization") public class MalariaFollowUpController { @Autowired private MalariaFollowUpService followUpService; - @RequestMapping(value = "save",method = RequestMethod.POST) + @RequestMapping(value = "save",method = RequestMethod.POST,headers = "Authorization") public ResponseEntity> save(@RequestBody MalariaFollowUpDTO dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -29,7 +29,7 @@ public ResponseEntity> save(@RequestBody MalariaFollowUpDTO return ResponseEntity.ok(response); } - @RequestMapping(value = "get",method = RequestMethod.POST) + @RequestMapping(value = "get",method = RequestMethod.POST,headers = "Authorization") public ResponseEntity> getFollowUpsByUserId(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java b/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java deleted file mode 100644 index 73d4479f..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseControl.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Timestamp; -import java.util.List; - -@Data -@Entity -@Table(name = "disease") -public class DiseaseControl { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "ben_id") - private Long benId; - - @Column(name = "case_date", nullable = false) - private Timestamp caseDate; // Auto-populated as today's date, non-editable - - @Column(name = "case_status", nullable = false) - private String caseStatus; // Dropdown for case status - - - @Column(name = "symptom") - private String symptoms; // List of symptoms - - @Column(name = "malaria_case_count", nullable = false) - private int malariaCaseCount; // Auto-updated based on confirmed/treatment cases - - @Column(name = "InstitutionID", nullable = false) - private Integer referredTo; // Dropdown for referral options - - @Column(name = "other_referred_to") - private String otherReferredTo; // Required if "Referred To" = "Other" - - @Column(name = "malaria_case_status_date") - private Timestamp malariaCaseStatusDate; // Auto-populated when status is updated - - @Column(name = "remarks") - private String remarks; // Optional field for additional notes - - @Column(name = "follow_up_point") - private Integer followUpPoint; // Single-select radio button (1-6) - - @Column(name = "follow_up_date") - private Timestamp followUpDate; // Follow-up date - - @Column(name = "status") - private String status; - - @Column(name = "other_status") - private String otherStatus; - - @Column(name = "body_part") - private String bodyPart; - - @Column(name = "suffering_from_filariasis") - private Boolean sufferingFromFilariasis; - - @Column(name = "home_visit_date") - private Timestamp homeVisitDate; - - @Column(name = "leprosy_status_date") - private Timestamp LeprosyStatusDate; - - @Column(name = "medicine_side_effect") - private String MedicineSideEffect; - - @Column(name = "typeId") - private BigInteger diseaseTypeId; - - -} diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java similarity index 85% rename from src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java rename to src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java index 8e91e4ad..cb694fb3 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseAesje.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java @@ -2,14 +2,13 @@ import jakarta.persistence.*; import lombok.Data; -import org.checkerframework.checker.units.qual.N; import java.util.Date; @Entity -@Table(name = "disease_aesje", schema = "db_iemr") +@Table(name = "screening_aesje", schema = "db_iemr") @Data -public class DiseaseAesje { +public class ScreeningAesje { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -51,7 +50,7 @@ public class DiseaseAesje { @Column(name = "aes_je_case_count") private Integer aesJeCaseCount = 0; - @Column(name = "follow_up_point", columnDefinition = "INT CHECK (follow_up_point between 1 and 6)") + @Column(name = "follow_up_point") private Integer followUpPoint; @Column(name = "referred_to") @@ -60,20 +59,23 @@ public class DiseaseAesje { @Column(name = "other_referred_facility") private String otherReferredFacility; - @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_date") private Date createdDate = new Date(); @Column(name = "created_by") private String createdBy; - + @Column(name = "userID") + private Integer userId; @Column(name = "diseaseTypeID") private Integer diseaseTypeId; - @Column(name = "userID") - private Integer userId; + @Column(name = "refer_to_name") + private String referToName; + + @Column(name = "beneficiary_statusId") + private Integer beneficiaryStatusId; // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java similarity index 94% rename from src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java rename to src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java index 7df88f2f..3efa2864 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseFilariasis.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java @@ -6,9 +6,9 @@ import java.util.Date; @Entity -@Table(name = "disease_filariasis", schema = "db_iemr") +@Table(name = "screening_filaria", schema = "db_iemr") @Data -public class DiseaseFilariasis { +public class ScreeningFilariasis { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -58,4 +58,5 @@ public class DiseaseFilariasis { @Column(name = "userID") private Integer userId; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java similarity index 64% rename from src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java rename to src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java index afef7750..a99cb40c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseKalaAzar.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java @@ -6,9 +6,9 @@ import java.util.Date; @Entity -@Table(name = "disease_kala_azar", schema = "db_iemr") +@Table(name = "screening_kala_azar", schema = "db_iemr") @Data -public class DiseaseKalaAzar { +public class ScreeningKalaAzar { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -21,68 +21,63 @@ public class DiseaseKalaAzar { @Column(name = "houseHoldDetailsId") private Long houseHoldDetailsId; + @Column(name = "userID") + private Integer userId; - @Temporal(TemporalType.DATE) @Column(name = "visit_date") private Date visitDate; - @Column(name = "beneficiary_status", length = 50) - private String beneficiaryStatus; - - @Temporal(TemporalType.DATE) @Column(name = "date_of_death") private Date dateOfDeath; - @Column(name = "place_of_death", length = 50) + @Column(name = "place_of_death") private String placeOfDeath; - @Column(name = "other_place_of_death", columnDefinition = "TEXT") + @Column(name = "other_place_of_death") private String otherPlaceOfDeath; - @Column(name = "reason_for_death", length = 50) + @Column(name = "reason_for_death") private String reasonForDeath; - @Column(name = "other_reason_for_death", columnDefinition = "TEXT") + @Column(name = "other_reason_for_death") private String otherReasonForDeath; - @Column(name = "kala_azar_case_status", length = 50) + @Column(name = "kala_azar_case_status") private String kalaAzarCaseStatus; @Column(name = "kala_azar_case_count") private Integer kalaAzarCaseCount; - @Column(name = "rapid_diagnostic_test", length = 20) + @Column(name = "rapid_diagnostic_test") private String rapidDiagnosticTest; - @Temporal(TemporalType.DATE) @Column(name = "date_of_rdt") private Date dateOfRdt; @Column(name = "follow_up_point") private Integer followUpPoint; - @Column(name = "referred_to", length = 100) + @Column(name = "referred_to") private String referredTo; - @Column(name = "other_referred_facility", columnDefinition = "TEXT") + @Column(name = "other_referred_facility") private String otherReferredFacility; - @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_date") private Date createdDate; - @Column(name = "created_by", length = 100) + @Column(name = "created_by") private String createdBy; @Column(name = "diseaseTypeID") private Integer diseaseTypeId; - @Column(name = "userID") - private Integer userId; - @Column(name = "refer_to_name") private String referToName; @Column(name = "beneficiary_statusId") private Integer beneficiaryStatusId; + + @Column(name = "beneficiary_status") + private String beneficiaryStatus; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java similarity index 61% rename from src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java rename to src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index d5245f96..0b488ab3 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -6,10 +6,9 @@ import java.util.Date; @Entity -@Table(name = "disease_leprosy", schema = "db_iemr") +@Table(name = "screening_leprosy", schema = "db_iemr") @Data -public class DiseaseLeprosy { - +public class ScreeningLeprosy { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") @@ -45,9 +44,6 @@ public class DiseaseLeprosy { @Column(name = "follow_up_date") private Date followUpDate; - @Column(name = "disease_status", length = 225) - private String diseaseStatus; - @Column(name = "remark", length = 225) private String remark; @@ -57,4 +53,27 @@ public class DiseaseLeprosy { @Column(name = "userID") private Integer userId; + @Column(name = "refer_to_name") + private String referToName; + + @Column(name = "beneficiary_statusId") + private Integer beneficiaryStatusId; + + @Column(name = "beneficiary_status", length = 50) + private String beneficiaryStatus; + + @Column(name = "date_of_death") + private Date dateOfDeath; + + @Column(name = "place_of_death", length = 50) + private String placeOfDeath; + + @Column(name = "other_place_of_death", columnDefinition = "TEXT") + private String otherPlaceOfDeath; + + @Column(name = "reason_for_death", length = 50) + private String reasonForDeath; + + @Column(name = "other_reason_for_death", columnDefinition = "TEXT") + private String otherReasonForDeath; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java similarity index 92% rename from src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java rename to src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java index 558ce0be..2631b9b5 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DiseaseMalaria.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java @@ -6,9 +6,9 @@ import java.util.Date; @Entity -@Table(name = "disease_malaria", schema = "db_iemr") +@Table(name = "screening_malaria", schema = "db_iemr") @Data -public class DiseaseMalaria { +public class ScreeningMalaria { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -79,7 +79,6 @@ public class DiseaseMalaria { @Column(name = "remarks") private String remarks; - @Temporal(TemporalType.DATE) @Column(name = "date_of_visit_by_supervisor") private Date dateOfVisitBySupervisor; @@ -89,14 +88,12 @@ public class DiseaseMalaria { @Column(name = "userID") private Integer userId; - @Temporal(TemporalType.TIMESTAMP) @Column(name = "created_date") private Date createdDate; @Column(name = "created_by") private String createdBy; - @Temporal(TemporalType.DATE) @Column(name = "date_of_visit_supervisor") private Date dateOfVisitSupervisor; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java index 42289436..99514ed3 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java @@ -24,7 +24,6 @@ public class DiseaseAesjeDto { private String createdBy; private Integer userId; private Integer diseaseTypeId; - - - // Getters and Setters + private String referToName; + private Integer beneficiaryStatusId; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java deleted file mode 100644 index 301fec04..00000000 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseControlDTO.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.iemr.flw.dto.iemr; - -import com.iemr.flw.domain.iemr.DiseaseControl; -import lombok.Data; - -import java.math.BigInteger; -import java.sql.Timestamp; -import java.util.List; - -@Data -public class DiseaseControlDTO { - Integer userId; - List diseaseControlList; - - - -} - diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java index 1f4398e2..7db5c064 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java @@ -30,5 +30,4 @@ public class DiseaseKalaAzarDTO { private String referToName; private Integer beneficiaryStatusId; - // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index 73a8a117..28906ca0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -16,10 +16,17 @@ public class DiseaseLeprosyDTO { private Date leprosyStatusDate; private String typeOfLeprosy; private Date followUpDate; - private String diseaseStatus; + private String beneficiaryStatus; private String remark; private Integer userId; private Integer diseaseTypeId; + private String referToName; + private Integer beneficiaryStatusId; + private Date dateOfDeath; + private String placeOfDeath; + private String otherPlaceOfDeath; + private String reasonForDeath; + private String otherReasonForDeath; // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java index 375d2e2a..6f95f24e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java @@ -46,6 +46,4 @@ public class DiseaseMalariaDTO { private String referToName; private Integer caseStatusId; - - } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/masterEnum/DiseaseType.java b/src/main/java/com/iemr/flw/masterEnum/DiseaseType.java new file mode 100644 index 00000000..c182f5fa --- /dev/null +++ b/src/main/java/com/iemr/flw/masterEnum/DiseaseType.java @@ -0,0 +1,31 @@ +package com.iemr.flw.masterEnum; + + +public enum DiseaseType { + MALARIA(1), + KALA_AZAR(2), + AES_JE(3), + FILARIA(4), + LEPROSY(5); + + private final int id; + + DiseaseType(int id) { + this.id = id; + } + + public int getId() { + return id; + } + + + + public static DiseaseType fromId(int id) { + for (DiseaseType disease : values()) { + if (disease.id == id) { + return disease; + } + } + throw new IllegalArgumentException("Invalid Disease ID: " + id); + } +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java index a9a41f7b..03cc8fd0 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseAESJERepository.java @@ -1,14 +1,13 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.DiseaseAesje; +import com.iemr.flw.domain.iemr.ScreeningAesje; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.math.BigInteger; import java.util.Optional; @Repository -public interface DiseaseAESJERepository extends JpaRepository { - Optional findByBenId(Long benId); +public interface DiseaseAESJERepository extends JpaRepository { + Optional findByBenId(Long benId); // Custom queries can be added here if needed } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java deleted file mode 100644 index 75aa8130..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseControlRepo.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.DiseaseControl; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.Optional; - -@Repository -public interface DiseaseControlRepo extends JpaRepository { - Optional findByBenId(Long benId); -} diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java index 54f58741..4e2e88b8 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseFilariasisRepository.java @@ -1,13 +1,13 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.DiseaseFilariasis; +import com.iemr.flw.domain.iemr.ScreeningFilariasis; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; @Repository -public interface DiseaseFilariasisRepository extends JpaRepository { - Optional findByBenId(Long benId); +public interface DiseaseFilariasisRepository extends JpaRepository { + Optional findByBenId(Long benId); // Custom queries can be added here if needed } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java index d76aca63..caa0fa64 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseKalaAzarRepository.java @@ -1,13 +1,13 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.DiseaseKalaAzar; +import com.iemr.flw.domain.iemr.ScreeningKalaAzar; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; @Repository -public interface DiseaseKalaAzarRepository extends JpaRepository { - Optional findByBenId(Long benId); +public interface DiseaseKalaAzarRepository extends JpaRepository { + Optional findByBenId(Long benId); // Custom queries can be added here if needed } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java index 8ed51a96..fdcd5641 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java @@ -1,13 +1,13 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.DiseaseLeprosy; +import com.iemr.flw.domain.iemr.ScreeningLeprosy; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; @Repository -public interface DiseaseLeprosyRepository extends JpaRepository { - Optional findByBenId(Long benId); +public interface DiseaseLeprosyRepository extends JpaRepository { + Optional findByBenId(Long benId); // Custom queries can be added here if needed } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java index d05f8a70..80c1c1bb 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseMalariaRepository.java @@ -1,13 +1,13 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.domain.iemr.DiseaseMalaria; +import com.iemr.flw.domain.iemr.ScreeningMalaria; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; @Repository -public interface DiseaseMalariaRepository extends JpaRepository { - Optional findByBenId(Long benId); +public interface DiseaseMalariaRepository extends JpaRepository { + Optional findByBenId(Long benId); // Custom queries can be added here if needed } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 363f50b0..1a0025ff 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -4,13 +4,10 @@ public interface DiseaseControlService { public String saveMalaria(MalariaDTO diseaseControlDTO); - public String saveKalaAzar(KalaAzarDTO diseaseControlDTO); - public String saveAES(AesJeDTO diseaseControlDTO); - public String saveFilaria(FilariaDTO diseaseControlDTO); - public String saveLeprosy(LeprosyDTO diseaseControlDTO); - public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler); - public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler); - public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler); - public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler); - public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler); + public String saveKalaAzar(KalaAzarDTO kalaAzarDTO); + public String saveAES(AesJeDTO aesJeDTO); + public String saveFilaria(FilariaDTO filariaDTO); + public String saveLeprosy(LeprosyDTO leprosyDTO); + public Object getAllScreeningData(GetDiseaseRequestHandler getDiseaseRequestHandler); + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 22f974f7..4848f418 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1,10 +1,14 @@ package com.iemr.flw.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.controller.CoupleController; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.masterEnum.DiseaseType; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -38,6 +42,7 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private IncentivesRepo incentivesRepo; + private final Logger logger = LoggerFactory.getLogger(CoupleController.class); @Override public String saveMalaria(MalariaDTO diseaseControlDTO) { @@ -59,6 +64,7 @@ public String saveMalaria(MalariaDTO diseaseControlDTO) { @Override public String saveKalaAzar(KalaAzarDTO diseaseControlDTO) { + logger.info("Save request: "+diseaseControlDTO.toString()); for (DiseaseKalaAzarDTO diseaseControlData : diseaseControlDTO.getKalaAzarLists()) { if (diseaseKalaAzarRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { return updateKalaAzarDisease(diseaseControlData); @@ -110,9 +116,9 @@ public String saveFilaria(FilariaDTO diseaseControlDTO) { return "Fail"; } - private DiseaseAesje saveASEDisease(DiseaseAesjeDto diseaseControlData) { + private ScreeningAesje saveASEDisease(DiseaseAesjeDto diseaseControlData) { // Create a new DiseaseAesje entity from the DTO data - DiseaseAesje diseaseAesje = new DiseaseAesje(); + ScreeningAesje diseaseAesje = new ScreeningAesje(); // Set the fields from DTO to entity diseaseAesje.setBenId(diseaseControlData.getBenId()); @@ -132,6 +138,9 @@ private DiseaseAesje saveASEDisease(DiseaseAesjeDto diseaseControlData) { diseaseAesje.setOtherReferredFacility(diseaseControlData.getOtherReferredFacility()); diseaseAesje.setCreatedDate(new Timestamp(System.currentTimeMillis())); // Set current timestamp diseaseAesje.setCreatedBy(diseaseControlData.getCreatedBy()); + diseaseAesje.setBeneficiaryStatusId(diseaseControlData.getBeneficiaryStatusId()); + diseaseAesje.setReferToName(diseaseControlData.getReferToName()); + diseaseAesje.setUserId(diseaseControlData.getUserId()); // Return the new entity to be saved return diseaseAesje; @@ -139,7 +148,7 @@ private DiseaseAesje saveASEDisease(DiseaseAesjeDto diseaseControlData) { private String updateASEDisease(DiseaseAesjeDto diseaseControlData) { // Fetch the existing record from the database using benId - DiseaseAesje existingDiseaseAesje = diseaseAESJERepository.findByBenId(diseaseControlData.getBenId()) + ScreeningAesje existingDiseaseAesje = diseaseAESJERepository.findByBenId(diseaseControlData.getBenId()) .orElseThrow(() -> new RuntimeException("AES/JE record not found for benId: " + diseaseControlData.getBenId())); // Update the existing entity with new values from the DTO @@ -157,6 +166,8 @@ private String updateASEDisease(DiseaseAesjeDto diseaseControlData) { existingDiseaseAesje.setFollowUpPoint(diseaseControlData.getFollowUpPoint()); existingDiseaseAesje.setReferredTo(diseaseControlData.getReferredTo()); existingDiseaseAesje.setOtherReferredFacility(diseaseControlData.getOtherReferredFacility()); + existingDiseaseAesje.setBeneficiaryStatusId(diseaseControlData.getBeneficiaryStatusId()); + existingDiseaseAesje.setReferToName(diseaseControlData.getReferToName()); // If the userId is present, update it as well @@ -168,9 +179,9 @@ private String updateASEDisease(DiseaseAesjeDto diseaseControlData) { } - private DiseaseFilariasis saveFilariasisData(DiseaseFilariasisDTO diseaseControlData) { + private ScreeningFilariasis saveFilariasisData(DiseaseFilariasisDTO diseaseControlData) { // Create a new DiseaseFilariasis entity from the DTO data - DiseaseFilariasis diseaseFilariasis = new DiseaseFilariasis(); + ScreeningFilariasis diseaseFilariasis = new ScreeningFilariasis(); diseaseFilariasis.setBenId(diseaseControlData.getBenId()); diseaseFilariasis.setHouseHoldDetailsId(diseaseControlData.getHouseHoldDetailsId()); @@ -185,6 +196,7 @@ private DiseaseFilariasis saveFilariasisData(DiseaseFilariasisDTO diseaseControl diseaseFilariasis.setOtherSideEffectDetails(diseaseControlData.getOtherSideEffectDetails()); diseaseFilariasis.setCreatedDate(new Timestamp(System.currentTimeMillis())); // Set current timestamp diseaseFilariasis.setCreatedBy(diseaseControlData.getCreatedBy()); + diseaseFilariasis.setUserId(diseaseControlData.getUserId()); // Return the new entity to be saved return diseaseFilariasis; @@ -193,7 +205,7 @@ private DiseaseFilariasis saveFilariasisData(DiseaseFilariasisDTO diseaseControl private String updateFilaria(DiseaseFilariasisDTO diseaseControlData) { // Fetch the existing record from the database using benId - DiseaseFilariasis existingDiseaseFilariasis = diseaseFilariasisRepository.findByBenId(diseaseControlData.getBenId()) + ScreeningFilariasis existingDiseaseFilariasis = diseaseFilariasisRepository.findByBenId(diseaseControlData.getBenId()) .orElseThrow(() -> new RuntimeException("Filariasis record not found for benId: " + diseaseControlData.getBenId())); // Update the existing entity with the new values from the DTO @@ -233,12 +245,11 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { return "Fail"; } - @Override public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { ObjectMapper objectMapper = new ObjectMapper(); // Fetch and filter malaria disease records - List filteredList = diseaseMalariaRepository.findAll().stream() + List filteredList = diseaseMalariaRepository.findAll().stream() .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) .collect(Collectors.toList()); @@ -301,10 +312,32 @@ public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { } @Override + public Object getAllScreeningData(GetDiseaseRequestHandler getDiseaseRequestHandler) { + + + if (getDiseaseRequestHandler.getDiseaseTypeID() == DiseaseType.MALARIA.getId()) { + return getAllMalaria(getDiseaseRequestHandler); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == DiseaseType.KALA_AZAR.getId()) { + return getAllKalaAzar(getDiseaseRequestHandler); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == DiseaseType.AES_JE.getId()) { + return getAllKalaAES(getDiseaseRequestHandler); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == DiseaseType.FILARIA.getId()) { + return getAllFilaria(getDiseaseRequestHandler); + + } else if (getDiseaseRequestHandler.getDiseaseTypeID() == DiseaseType.LEPROSY.getId()) { + return getAllLeprosy(getDiseaseRequestHandler); + + } + return "No data found"; + } + public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter Kala Azar disease records - List filteredList = diseaseKalaAzarRepository.findAll().stream() + List filteredList = diseaseKalaAzarRepository.findAll().stream() .filter(disease -> (Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId()))) .collect(Collectors.toList()); @@ -337,6 +370,8 @@ public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) dto.setCreatedBy(disease.getCreatedBy()); dto.setBeneficiaryStatusId(disease.getBeneficiaryStatusId()); dto.setReferToName(disease.getReferToName()); + dto.setUserId(disease.getUserId()); + dto.setDiseaseTypeId(disease.getDiseaseTypeId()); return dto; }).collect(Collectors.toList()); @@ -345,20 +380,19 @@ public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) } - @Override public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler) { + if (diseaseAESJERepository.findAll().isEmpty()) { + return Collections.singletonMap("message", "No data found for AES."); + } return diseaseAESJERepository.findAll().stream().filter(diseaseAesje -> Objects.equals(diseaseAesje.getUserId(), getDiseaseRequestHandler.getUserId())).collect(Collectors.toList()); } - @Override public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter Filaria disease records - List filteredList = diseaseFilariasisRepository.findAll().stream() - .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) - .collect(Collectors.toList()); + List filteredList = diseaseFilariasisRepository.findAll().stream().filter(screeningFilariasis -> Objects.equals(screeningFilariasis.getUserId(), getDiseaseRequestHandler.getUserId())).collect(Collectors.toList()); // Check if the list is empty if (filteredList.isEmpty()) { @@ -381,6 +415,7 @@ public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { dto.setOtherSideEffectDetails(disease.getOtherSideEffectDetails()); dto.setCreatedDate(disease.getCreatedDate()); dto.setCreatedBy(disease.getCreatedBy()); + dto.setUserId(disease.getUserId()); return dto; }).collect(Collectors.toList()); @@ -389,11 +424,10 @@ public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { } - @Override public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter Leprosy disease records - List filteredList = diseaseLeprosyRepository.findAll().stream() + List filteredList = diseaseLeprosyRepository.findAll().stream() .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) .collect(Collectors.toList()); @@ -415,8 +449,10 @@ public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { dto.setLeprosyStatusDate(disease.getLeprosyStatusDate()); dto.setTypeOfLeprosy(disease.getTypeOfLeprosy()); dto.setFollowUpDate(disease.getFollowUpDate()); - dto.setDiseaseStatus(disease.getDiseaseStatus()); + dto.setBeneficiaryStatus(disease.getLeprosyStatus()); dto.setRemark(disease.getRemark()); + dto.setUserId(disease.getUserId()); + return dto; }).collect(Collectors.toList()); @@ -425,8 +461,9 @@ public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { } - private DiseaseKalaAzar saveKalaAzarDisease(DiseaseKalaAzarDTO dto) { - DiseaseKalaAzar entity = new DiseaseKalaAzar(); + private ScreeningKalaAzar saveKalaAzarDisease(DiseaseKalaAzarDTO dto) { + logger.info("KalaAzarRequest: "+dto); + ScreeningKalaAzar entity = new ScreeningKalaAzar(); entity.setBenId(dto.getBenId()); entity.setHouseHoldDetailsId(dto.getHouseHoldDetailsId()); @@ -451,20 +488,21 @@ private DiseaseKalaAzar saveKalaAzarDisease(DiseaseKalaAzarDTO dto) { entity.setReferToName(dto.getReferToName()); entity.setUserId(dto.getUserId()); - DiseaseKalaAzar saved = diseaseKalaAzarRepository.save(entity); + + ScreeningKalaAzar saved = diseaseKalaAzarRepository.save(entity); return saved; // You can also return a custom response or DTO } private String updateKalaAzarDisease(DiseaseKalaAzarDTO dto) { - Optional optional = diseaseKalaAzarRepository.findByBenId(dto.getBenId()); + Optional optional = diseaseKalaAzarRepository.findByBenId(dto.getBenId()); if (!optional.isPresent()) { return "Record not found with ID: " + dto.getId(); } - DiseaseKalaAzar entity = optional.get(); + ScreeningKalaAzar entity = optional.get(); // Update fields entity.setBenId(dto.getBenId()); @@ -497,8 +535,8 @@ private String updateKalaAzarDisease(DiseaseKalaAzarDTO dto) { } - private DiseaseLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { - DiseaseLeprosy diseaseLeprosy = new DiseaseLeprosy(); + private ScreeningLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { + ScreeningLeprosy diseaseLeprosy = new ScreeningLeprosy(); // Setting the values from the DTO to the entity diseaseLeprosy.setBenId(diseaseControlData.getBenId()); @@ -511,8 +549,15 @@ private DiseaseLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { diseaseLeprosy.setLeprosyStatusDate(diseaseControlData.getLeprosyStatusDate()); diseaseLeprosy.setTypeOfLeprosy(diseaseControlData.getTypeOfLeprosy()); diseaseLeprosy.setFollowUpDate(diseaseControlData.getFollowUpDate()); - diseaseLeprosy.setDiseaseStatus(diseaseControlData.getDiseaseStatus()); + diseaseLeprosy.setBeneficiaryStatus(diseaseControlData.getBeneficiaryStatus()); + diseaseLeprosy.setBeneficiaryStatusId(diseaseControlData.getBeneficiaryStatusId()); + diseaseLeprosy.setReferToName(diseaseControlData.getReferToName()); + diseaseLeprosy.setPlaceOfDeath(diseaseControlData.getPlaceOfDeath()); + diseaseLeprosy.setDateOfDeath(diseaseControlData.getDateOfDeath()); + diseaseLeprosy.setOtherPlaceOfDeath(diseaseControlData.getOtherPlaceOfDeath()); + diseaseLeprosy.setOtherReasonForDeath(diseaseControlData.getOtherReasonForDeath()); diseaseLeprosy.setRemark(diseaseControlData.getRemark()); + diseaseLeprosy.setUserId(diseaseControlData.getUserId()); return diseaseLeprosy; @@ -520,7 +565,7 @@ private DiseaseLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { // Fetch the existing record from the database using the benId - DiseaseLeprosy existingDiseaseLeprosy = diseaseLeprosyRepository.findByBenId(diseaseControlData.getBenId()) + ScreeningLeprosy existingDiseaseLeprosy = diseaseLeprosyRepository.findByBenId(diseaseControlData.getBenId()) .orElseThrow(() -> new RuntimeException("Leprosy record not found for benId: " + diseaseControlData.getBenId())); // Update the fields from the DTO to the existing entity @@ -533,7 +578,13 @@ private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { existingDiseaseLeprosy.setLeprosyStatusDate(diseaseControlData.getLeprosyStatusDate()); existingDiseaseLeprosy.setTypeOfLeprosy(diseaseControlData.getTypeOfLeprosy()); existingDiseaseLeprosy.setFollowUpDate(diseaseControlData.getFollowUpDate()); - existingDiseaseLeprosy.setDiseaseStatus(diseaseControlData.getDiseaseStatus()); + existingDiseaseLeprosy.setBeneficiaryStatus(diseaseControlData.getBeneficiaryStatus()); + existingDiseaseLeprosy.setBeneficiaryStatusId(diseaseControlData.getBeneficiaryStatusId()); + existingDiseaseLeprosy.setReferToName(diseaseControlData.getReferToName()); + existingDiseaseLeprosy.setPlaceOfDeath(diseaseControlData.getPlaceOfDeath()); + existingDiseaseLeprosy.setDateOfDeath(diseaseControlData.getDateOfDeath()); + existingDiseaseLeprosy.setOtherPlaceOfDeath(diseaseControlData.getOtherPlaceOfDeath()); + existingDiseaseLeprosy.setOtherReasonForDeath(diseaseControlData.getOtherReasonForDeath()); existingDiseaseLeprosy.setRemark(diseaseControlData.getRemark()); diseaseLeprosyRepository.save(existingDiseaseLeprosy); @@ -542,8 +593,8 @@ private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { } // Save Malaria - private DiseaseMalaria saveMalariaDisease(DiseaseMalariaDTO requestData) { - DiseaseMalaria diseaseScreening = new DiseaseMalaria(); + private ScreeningMalaria saveMalariaDisease(DiseaseMalariaDTO requestData) { + ScreeningMalaria diseaseScreening = new ScreeningMalaria(); diseaseScreening.setBenId(requestData.getBenId()); diseaseScreening.setHouseHoldDetailsId(requestData.getHouseHoldDetailsId()); @@ -601,6 +652,8 @@ private String updateMalariaDisease(DiseaseMalariaDTO requestData) { diseaseScreening.setRemarks(requestData.getRemarks()); diseaseScreening.setCreatedDate(Timestamp.valueOf(LocalDateTime.now())); diseaseScreening.setDateOfVisitBySupervisor(requestData.getDateOfVisitBySupervisor()); + diseaseScreening.setReferToName(requestData.getReferToName()); + diseaseScreening.setCaseStatusId(requestData.getCaseStatusId()); diseaseMalariaRepository.save(diseaseScreening); return "Data update successfully"; @@ -628,7 +681,7 @@ private String convertSelecteddiseaseScreeningToJson(DiseaseMalariaDTO requestDa } - private void checkAndAddIncentives(DiseaseMalaria diseaseScreening) { + private void checkAndAddIncentives(ScreeningMalaria diseaseScreening) { IncentiveActivity diseaseScreeningActivity; if (Objects.equals(diseaseScreening.getCaseStatus(), "Confirmed Case")) { diseaseScreeningActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MALARIA_1", "DISEASECONTROL"); From 1fa11f2e39b426490852686a73af31fa4a82adc7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 18 Apr 2025 15:14:22 +0530 Subject: [PATCH 093/792] Disease control module --- .../controller/DiseaseControlController.java | 51 ++++++++++++++----- .../impl/DiseaseControlServiceImpl.java | 1 + 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 85a48599..5014a1f4 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -36,13 +36,13 @@ public ResponseEntity> saveMalaria(@RequestBody MalariaDTO m try { logger.info("Malaria DTO: {}", new ObjectMapper().writeValueAsString(malariaDTO)); - if(!malariaDTO.getMalariaLists().isEmpty()){ + if(malariaDTO!=null){ response.put("message", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveMalaria(malariaDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 200); + response.put("statusCode", 400); } } catch (Exception e) { @@ -59,10 +59,15 @@ public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO try { logger.info("KalaAzar DTO: {}", new ObjectMapper().writeValueAsString(kalaAzarDTO)); + if(kalaAzarDTO!=null){ + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 400); + } - response.put("message", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); } catch (Exception e) { response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); @@ -76,9 +81,15 @@ public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJe Map response = new HashMap<>(); try { - response.put("message", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveAES(aesJeDTO)); + if(aesJeDTO!=null){ + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveAES(aesJeDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 400); + } + } catch (Exception e) { response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); @@ -92,9 +103,15 @@ public ResponseEntity> saveFilaria(@RequestBody FilariaDTO f Map response = new HashMap<>(); try { - response.put("message", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveFilaria(filariaDTO)); + if(filariaDTO!=null){ + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveFilaria(filariaDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 400); + } + } catch (Exception e) { response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); @@ -107,9 +124,15 @@ public ResponseEntity> saveFilaria(@RequestBody FilariaDTO f public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO leprosyDTO) { Map response = new HashMap<>(); try { - response.put("message", "Success"); - response.put("statusCode", 200); - response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); + if(leprosyDTO!=null){ + response.put("message", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 400); + } + } catch (Exception e) { response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 4848f418..cce7e5fa 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -101,6 +101,7 @@ public String saveAES(AesJeDTO diseaseControlDTO) { @Override public String saveFilaria(FilariaDTO diseaseControlDTO) { + for (DiseaseFilariasisDTO diseaseControlData : diseaseControlDTO.getFilariaLists()) { if (diseaseFilariasisRepository.findByBenId(diseaseControlData.getBenId()).isPresent()) { return updateFilaria(diseaseControlData); From 24993e20d0315e1b46c9abb26c2258f4445cc23f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 22 Apr 2025 15:32:08 +0530 Subject: [PATCH 094/792] OPD module --- .../flw/controller/GeneralOPDController.java | 35 +- .../flw/repo/iemr/BenVisitDetailsRepo.java | 4 +- .../iemr/flw/service/GeneralOpdService.java | 3 +- .../service/impl/BeneficiaryServiceImpl.java | 17 + .../service/impl/GeneralOpdServiceImpl.java | 449 +++++++++++++++++- 5 files changed, 485 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index 6b405a52..97cdfe5e 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -1,22 +1,51 @@ package com.iemr.flw.controller; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.GeneralOpdDto; +import com.iemr.flw.service.BeneficiaryService; import com.iemr.flw.service.GeneralOpdService; +import com.iemr.flw.utils.response.OutputResponse; +import io.swagger.v3.oas.annotations.Operation; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.sql.Timestamp; import java.util.List; @RestController @RequestMapping("/api/general-opd") public class GeneralOPDController { + private final org.slf4j.Logger logger = LoggerFactory.getLogger(BeneficiaryController.class); @Autowired private GeneralOpdService generalOpdService; - @GetMapping("/beneficiaries/{ashaId}") - public ResponseEntity> getOpdBeneficiaries(@PathVariable String ashaId) { - return ResponseEntity.ok(generalOpdService.getOpdListForAsha(ashaId)); + + + + @RequestMapping(value = "/getData", method = RequestMethod.POST) + @Operation(summary = "get beneficiary data for given user ") + public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, + @RequestHeader(value = "Authorization") String authorization) { + OutputResponse response = new OutputResponse(); + try { + if (requestDTO != null) { + logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + + requestDTO); + String s = generalOpdService.getOpdListForAsha(requestDTO, authorization); + if (s != null) + response.setResponse(s); + else + response.setError(5000, "No record found"); + } else + response.setError(5000, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in get data : " + e); + response.setError(5000, "Error in get data : " + e); + } + return response.toString(); + } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/BenVisitDetailsRepo.java b/src/main/java/com/iemr/flw/repo/iemr/BenVisitDetailsRepo.java index 0c8ae89e..dfd605ef 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/BenVisitDetailsRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/BenVisitDetailsRepo.java @@ -4,6 +4,8 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface BenVisitDetailsRepo extends JpaRepository { -} + public List findByBeneficiaryRegId(Long benRegID);} diff --git a/src/main/java/com/iemr/flw/service/GeneralOpdService.java b/src/main/java/com/iemr/flw/service/GeneralOpdService.java index aab88afb..7c307772 100644 --- a/src/main/java/com/iemr/flw/service/GeneralOpdService.java +++ b/src/main/java/com/iemr/flw/service/GeneralOpdService.java @@ -1,9 +1,10 @@ package com.iemr.flw.service; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.GeneralOpdDto; import java.util.List; public interface GeneralOpdService { - List getOpdListForAsha(String ashaId); + String getOpdListForAsha(GetBenRequestHandler getBenRequestHandler,String authorisation) throws Exception; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 027235f2..dc018304 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -353,6 +353,7 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("beneficiaryDetails", benDetailsRMNCH_OBJ); resultMap.put("abhaHealthDetails", healthDetails); + resultMap.put("visitDate", healthDetails); resultMap.put("houseoldId", benDetailsRMNCH_OBJ.getHouseoldId()); resultMap.put("benficieryid", benDetailsRMNCH_OBJ.getBenficieryid()); resultMap.put("BenRegId", m.getBenRegId()); @@ -402,6 +403,22 @@ private Map getBenHealthDetails(BigInteger benRegId) { return healthDetails; } + private Map getBenBenVisitDetails(BigInteger benRegId) { + Map healthDetails = new HashMap<>(); + if (null != benRegId) { + String benHealthIdNumber = beneficiaryRepo.getBenHealthIdNumber(benRegId); + if (null != benHealthIdNumber) { + ArrayList health = beneficiaryRepo.getBenHealthDetails(benHealthIdNumber); + for (Object[] objects : health) { + healthDetails.put("HealthID", objects[0]); + healthDetails.put("HealthIdNumber", objects[1]); + healthDetails.put("isNewAbha", objects[2]); + } + } + } + return healthDetails; + } + public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map resultMap) { Map requestMap = new HashMap(); requestMap.put("beneficiaryRegID", benRegID); diff --git a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java index fa2c1c49..5d275f7c 100644 --- a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java @@ -1,37 +1,450 @@ package com.iemr.flw.service.impl; +import com.google.gson.*; +import com.iemr.flw.domain.identity.*; +import com.iemr.flw.domain.iemr.BenVisitDetail; import com.iemr.flw.domain.iemr.GeneralOpdEntry; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.GeneralOpdDto; +import com.iemr.flw.mapper.InputMapper; +import com.iemr.flw.repo.identity.BeneficiaryRepo; +import com.iemr.flw.repo.identity.HouseHoldRepo; +import com.iemr.flw.repo.iemr.BenVisitDetailsRepo; import com.iemr.flw.repo.iemr.BeneficiaryRepository; import com.iemr.flw.service.GeneralOpdService; +import com.iemr.flw.utils.config.ConfigProperties; +import com.iemr.flw.utils.http.HttpUtils; +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.data.domain.Page; +import org.springframework.data.domain.PageRequest; import org.springframework.stereotype.Service; -import java.util.List; +import java.math.BigInteger; +import java.sql.Date; +import java.time.Period; +import java.util.*; import java.util.stream.Collectors; @Service public class GeneralOpdServiceImpl implements GeneralOpdService { + private final Logger logger = LoggerFactory.getLogger(BeneficiaryServiceImpl.class); + @Value("${door-to-door-page-size}") + private String door_to_door_page_size; @Autowired - private BeneficiaryRepository repository; + private BeneficiaryRepo beneficiaryRepo; + + @Autowired + private HouseHoldRepo houseHoldRepo; + + @Autowired + private BenVisitDetailsRepo benVisitDetailsRepo; + @Override - public List getOpdListForAsha(String ashaId) { - List beneficiaries = repository.findByAshaIdOrderByVisitDateDesc(ashaId); - return beneficiaries.stream().map(b -> { - GeneralOpdDto dto = new GeneralOpdDto(); - dto.setBeneficiaryName(b.getName()); - dto.setAge(b.getAge()); - dto.setGender(b.getGender()); - dto.setRegistrationDate(b.getRegistrationDate()); - dto.setMobileNumber(b.getMobileNumber()); - dto.setBeneficiaryId(b.getBeneficiaryId()); - dto.setVisitDate(b.getVisitDate()); - dto.setReferredTo(b.getReferredTo()); - dto.setFollowUpDate(b.getFollowUpDate()); - dto.setCallButtonEnabled(b.getMobileNumber() != null && !b.getMobileNumber().isEmpty()); - return dto; - }).collect(Collectors.toList()); + public String getOpdListForAsha(GetBenRequestHandler request, String authorisation) throws Exception { + String outputResponse = null; + int totalPage = 0; + + try { + if (request != null && request.getAshaId() != null) { + List resultSet; + Integer pageSize = Integer.valueOf(door_to_door_page_size); + if (request.getPageNo() != null) { + String userName = beneficiaryRepo.getUserName(request.getAshaId()); + if (userName == null || userName.isEmpty()) + throw new Exception("Asha details not found, please contact administrator"); + + request.setUserName(userName); + + PageRequest pr = PageRequest.of(request.getPageNo(), pageSize); + if (request.getFromDate() != null && request.getToDate() != null) { + Page p = beneficiaryRepo.getBenDataWithinDates( + request.getUserName(), request.getFromDate(), request.getToDate(), pr); + resultSet = p.getContent(); + totalPage = p.getTotalPages(); + } else { + Page p = beneficiaryRepo.getBenDataByUser(request.getUserName(), + pr); + resultSet = p.getContent(); + totalPage = p.getTotalPages(); + } + if (resultSet != null && resultSet.size() > 0) { + outputResponse = getMappingsForAddressIDs(resultSet, totalPage, authorisation); + } + } else { + // page no not invalid + throw new Exception("Invalid page no"); + } + } else + throw new Exception("Invalid/missing village details"); + } catch (Exception e) { + throw new Exception(e.getMessage()); + } + + return outputResponse; + } + + private String getMappingsForAddressIDs(List addressList, int totalPage, + String authorisation) { + RMNCHHouseHoldDetails benHouseHoldRMNCH_ROBJ; + RMNCHBeneficiaryDetailsRmnch benDetailsRMNCH_OBJ; + RMNCHBornBirthDetails benBotnBirthRMNCH_ROBJ; + + RMNCHMBeneficiarydetail benDetailsOBJ; + RMNCHMBeneficiaryAccount benAccountOBJ; + RMNCHMBeneficiaryImage benImageOBJ; + RMNCHMBeneficiaryaddress benAddressOBJ; + RMNCHMBeneficiarycontact benContactOBJ; + + Map resultMap; + ArrayList> resultList = new ArrayList<>(); + + for (RMNCHMBeneficiaryaddress a : addressList) { + // exception by-passing + try { + RMNCHMBeneficiarymapping m = beneficiaryRepo.getByAddressID(a.getId()); + if (m != null) { + benHouseHoldRMNCH_ROBJ = new RMNCHHouseHoldDetails(); + benDetailsRMNCH_OBJ = new RMNCHBeneficiaryDetailsRmnch(); + benBotnBirthRMNCH_ROBJ = new RMNCHBornBirthDetails(); + + benDetailsOBJ = new RMNCHMBeneficiarydetail(); + benAccountOBJ = new RMNCHMBeneficiaryAccount(); + benImageOBJ = new RMNCHMBeneficiaryImage(); + benAddressOBJ = new RMNCHMBeneficiaryaddress(); + benContactOBJ = new RMNCHMBeneficiarycontact(); + Map healthDetails = getBenHealthDetails(m.getBenRegId()); + System.out.println("BenId:"+m.getBenRegId()); + Map benVisitthDetails = getBenBenVisitDetails(m.getBenRegId()); + if (m.getBenDetailsId() != null) { + benDetailsOBJ = beneficiaryRepo.getDetailsById(m.getBenDetailsId()); + } + if (m.getBenAccountID() != null) { + benAccountOBJ = beneficiaryRepo.getAccountById(m.getBenAccountID()); + } + if (m.getBenImageId() != null) { + benImageOBJ = beneficiaryRepo.getImageById(m.getBenImageId().longValue()); + } + if (m.getBenAddressId() != null) { + benAddressOBJ = beneficiaryRepo.getAddressById(m.getBenAddressId()); + } + if (m.getBenContactsId() != null) { + benContactOBJ = beneficiaryRepo.getContactById(m.getBenContactsId()); + } + + BigInteger benID = null; + if (m.getBenRegId() != null) + benID = beneficiaryRepo.getBenIdFromRegID(m.getBenRegId().longValue()); + + if (m.getBenRegId() != null) { + benDetailsRMNCH_OBJ = beneficiaryRepo + .getDetailsByRegID((m.getBenRegId()).longValue()); + benBotnBirthRMNCH_ROBJ = beneficiaryRepo.getBornBirthByRegID((m.getBenRegId()).longValue()); + + if (benDetailsRMNCH_OBJ != null && benDetailsRMNCH_OBJ.getHouseoldId() != null) + benHouseHoldRMNCH_ROBJ = houseHoldRepo + .getByHouseHoldID(benDetailsRMNCH_OBJ.getHouseoldId()); + + } + if (benDetailsRMNCH_OBJ == null) + benDetailsRMNCH_OBJ = new RMNCHBeneficiaryDetailsRmnch(); + + // new mapping 30-06-2021 + if (benDetailsOBJ.getMotherName() != null) + benDetailsRMNCH_OBJ.setMotherName(benDetailsOBJ.getMotherName()); + if (benDetailsOBJ.getLiteracyStatus() != null) + benDetailsRMNCH_OBJ.setLiteracyStatus(benDetailsOBJ.getLiteracyStatus()); + + // bank + if (benAccountOBJ.getNameOfBank() != null) + benDetailsRMNCH_OBJ.setNameOfBank(benAccountOBJ.getNameOfBank()); + if (benAccountOBJ.getBranchName() != null) + benDetailsRMNCH_OBJ.setBranchName(benAccountOBJ.getBranchName()); + if (benAccountOBJ.getIfscCode() != null) + benDetailsRMNCH_OBJ.setIfscCode(benAccountOBJ.getIfscCode()); + if (benAccountOBJ.getBankAccount() != null) + benDetailsRMNCH_OBJ.setBankAccount(benAccountOBJ.getBankAccount()); + + // location + if (benAddressOBJ.getCountyid() != null) + benDetailsRMNCH_OBJ.setCountryId(benAddressOBJ.getCountyid()); + if (benAddressOBJ.getPermCountry() != null) + benDetailsRMNCH_OBJ.setCountryName(benAddressOBJ.getPermCountry()); + + if (benAddressOBJ.getStatePerm() != null) + benDetailsRMNCH_OBJ.setStateId(benAddressOBJ.getStatePerm()); + if (benAddressOBJ.getPermState() != null) + benDetailsRMNCH_OBJ.setStateName(benAddressOBJ.getPermState()); + + if (benAddressOBJ.getDistrictidPerm() != null) { + benDetailsRMNCH_OBJ.setDistrictid(benAddressOBJ.getDistrictidPerm()); + + } + if (benAddressOBJ.getDistrictnamePerm() != null) { + benDetailsRMNCH_OBJ.setDistrictname(benAddressOBJ.getDistrictnamePerm()); + + } + + if (benAddressOBJ.getPermSubDistrictId() != null) + benDetailsRMNCH_OBJ.setBlockId(benAddressOBJ.getPermSubDistrictId()); + if (benAddressOBJ.getPermSubDistrict() != null) + benDetailsRMNCH_OBJ.setBlockName(benAddressOBJ.getPermSubDistrict()); + + if (benAddressOBJ.getVillageidPerm() != null) + benDetailsRMNCH_OBJ.setVillageId(benAddressOBJ.getVillageidPerm()); + if (benAddressOBJ.getVillagenamePerm() != null) + benDetailsRMNCH_OBJ.setVillageName(benAddressOBJ.getVillagenamePerm()); + + if (benAddressOBJ.getPermServicePointId() != null) + benDetailsRMNCH_OBJ.setServicePointID(benAddressOBJ.getPermServicePointId()); + if (benAddressOBJ.getPermServicePoint() != null) + benDetailsRMNCH_OBJ.setServicePointName(benAddressOBJ.getPermServicePoint()); + + if (benAddressOBJ.getPermZoneID() != null) + benDetailsRMNCH_OBJ.setZoneID(benAddressOBJ.getPermZoneID()); + if (benAddressOBJ.getPermZone() != null) + benDetailsRMNCH_OBJ.setZoneName(benAddressOBJ.getPermZone()); + + if (benAddressOBJ.getPermAddrLine1() != null) + benDetailsRMNCH_OBJ.setAddressLine1(benAddressOBJ.getPermAddrLine1()); + if (benAddressOBJ.getPermAddrLine2() != null) + benDetailsRMNCH_OBJ.setAddressLine2(benAddressOBJ.getPermAddrLine2()); + if (benAddressOBJ.getPermAddrLine3() != null) + benDetailsRMNCH_OBJ.setAddressLine3(benAddressOBJ.getPermAddrLine3()); + + // ----------------------------------------------------------------------------- + + // related benids + if (benDetailsRMNCH_OBJ.getRelatedBeneficiaryIdsDB() != null) { + + String[] relatedBenIDsString = benDetailsRMNCH_OBJ.getRelatedBeneficiaryIdsDB().split(","); + Long[] relatedBenIDs = new Long[relatedBenIDsString.length]; + int pointer = 0; + for (String s : relatedBenIDsString) { + relatedBenIDs[pointer] = Long.valueOf(s); + pointer++; + } + + benDetailsRMNCH_OBJ.setRelatedBeneficiaryIds(relatedBenIDs); + } + // ------------------------------------------------------------------------------ + + if (benDetailsOBJ.getCommunity() != null) + benDetailsRMNCH_OBJ.setCommunity(benDetailsOBJ.getCommunity()); + if (benDetailsOBJ.getCommunityId() != null) + benDetailsRMNCH_OBJ.setCommunityId(benDetailsOBJ.getCommunityId()); + if (benContactOBJ.getPreferredPhoneNum() != null) + benDetailsRMNCH_OBJ.setContact_number(benContactOBJ.getPreferredPhoneNum()); + + if (benDetailsOBJ.getDob() != null) + benDetailsRMNCH_OBJ.setDob(benDetailsOBJ.getDob()); + if (benDetailsOBJ.getFatherName() != null) + benDetailsRMNCH_OBJ.setFatherName(benDetailsOBJ.getFatherName()); + if (benDetailsOBJ.getFirstName() != null) + benDetailsRMNCH_OBJ.setFirstName(benDetailsOBJ.getFirstName()); + if (benDetailsOBJ.getGender() != null) + benDetailsRMNCH_OBJ.setGender(benDetailsOBJ.getGender()); + if (benDetailsOBJ.getGenderId() != null) + benDetailsRMNCH_OBJ.setGenderId(benDetailsOBJ.getGenderId()); + + if (benDetailsOBJ.getMaritalstatus() != null) + benDetailsRMNCH_OBJ.setMaritalstatus(benDetailsOBJ.getMaritalstatus()); + if (benDetailsOBJ.getMaritalstatusId() != null) + benDetailsRMNCH_OBJ.setMaritalstatusId(benDetailsOBJ.getMaritalstatusId()); + if (benDetailsOBJ.getMarriageDate() != null) + benDetailsRMNCH_OBJ.setMarriageDate(benDetailsOBJ.getMarriageDate()); + + if (benDetailsOBJ.getReligion() != null) + benDetailsRMNCH_OBJ.setReligion(benDetailsOBJ.getReligion()); + if (benDetailsOBJ.getReligionID() != null) + benDetailsRMNCH_OBJ.setReligionID(benDetailsOBJ.getReligionID()); + if (benDetailsOBJ.getSpousename() != null) + benDetailsRMNCH_OBJ.setSpousename(benDetailsOBJ.getSpousename()); + + if (benImageOBJ != null && benImageOBJ.getUser_image() != null) + benDetailsRMNCH_OBJ.setUser_image(benImageOBJ.getUser_image()); + + // new fields +// benDetailsRMNCH_OBJ.setRegistrationDate(benDetailsOBJ.getCreatedDate()); + if (benID != null) + benDetailsRMNCH_OBJ.setBenficieryid(benID.longValue()); + + if (benDetailsOBJ.getLastName() != null) + benDetailsRMNCH_OBJ.setLastName(benDetailsOBJ.getLastName()); + + if (benDetailsRMNCH_OBJ.getCreatedBy() == null) + if (benDetailsOBJ.getCreatedBy() != null) + benDetailsRMNCH_OBJ.setCreatedBy(benDetailsOBJ.getCreatedBy()); + + // age calculation + String ageDetails = ""; + int age_val = 0; + String ageUnit = null; + if (benDetailsOBJ.getDob() != null) { + + Date date = new Date(benDetailsOBJ.getDob().getTime()); + Calendar cal = Calendar.getInstance(); + + cal.setTime(date); + + int year = cal.get(Calendar.YEAR); + int month = cal.get(Calendar.MONTH) + 1; + int day = cal.get(Calendar.DAY_OF_MONTH); + + java.time.LocalDate todayDate = java.time.LocalDate.now(); + java.time.LocalDate birthdate = java.time.LocalDate.of(year, month, day); + Period p = Period.between(birthdate, todayDate); + + int d = p.getDays(); + int mo = p.getMonths(); + int y = p.getYears(); + + if (y > 0) { + ageDetails = y + " years - " + mo + " months"; + age_val = y; + ageUnit = (age_val > 1) ? "Years" : "Year"; + } else { + if (mo > 0) { + ageDetails = mo + " months - " + d + " days"; + age_val = mo; + ageUnit = (age_val > 1) ? "Months" : "Month"; + } else { + ageDetails = d + " days"; + age_val = d; + ageUnit = (age_val > 1) ? "Days" : "Day"; + } + } + + } + + benDetailsRMNCH_OBJ.setAgeFull(ageDetails); + benDetailsRMNCH_OBJ.setAge(age_val); + if (ageUnit != null) + benDetailsRMNCH_OBJ.setAge_unit(ageUnit); + + resultMap = new HashMap<>(); + if (benHouseHoldRMNCH_ROBJ != null) { + resultMap.put("householdDetails", benHouseHoldRMNCH_ROBJ); + resultMap.put("benVisitDate", benVisitthDetails); + + } else { + + resultMap.put("householdDetails", new HashMap()); + } + + + if (benBotnBirthRMNCH_ROBJ != null) + resultMap.put("bornbirthDeatils", benBotnBirthRMNCH_ROBJ); + else + resultMap.put("bornbirthDeatils", new HashMap()); + + resultMap.put("beneficiaryDetails", benDetailsRMNCH_OBJ); + resultMap.put("abhaHealthDetails", healthDetails); + resultMap.put("visitDate", healthDetails); + resultMap.put("houseoldId", benDetailsRMNCH_OBJ.getHouseoldId()); + resultMap.put("benficieryid", benDetailsRMNCH_OBJ.getBenficieryid()); + resultMap.put("BenRegId", m.getBenRegId()); + + // adding asha id / created by - user id + if (benAddressOBJ.getCreatedBy() != null) { + Integer userID = beneficiaryRepo.getUserIDByUserName(benAddressOBJ.getCreatedBy()); + if (userID != null && userID > 0) + resultMap.put("ashaId", userID); + } + // get HealthID of ben + if (m.getBenRegId() != null) { + fetchHealthIdByBenRegID(m.getBenRegId().longValue(), authorisation, resultMap); + } + + resultList.add(resultMap); + + } else { + // mapping not available + } + } catch (Exception e) { + logger.error("error for addressID :" + a.getId() + " and vanID : " + a.getVanID()); + } + } + + Map response = new HashMap<>(); + response.put("data", resultList); + response.put("pageSize", Integer.parseInt(door_to_door_page_size)); + response.put("totalPage", totalPage); + Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy HH:mm:ss a").create(); + return gson.toJson(response); + } + + private Map getBenHealthDetails(BigInteger benRegId) { + Map healthDetails = new HashMap<>(); + if (null != benRegId) { + String benHealthIdNumber = beneficiaryRepo.getBenHealthIdNumber(benRegId); + if (null != benHealthIdNumber) { + ArrayList health = beneficiaryRepo.getBenHealthDetails(benHealthIdNumber); + for (Object[] objects : health) { + healthDetails.put("HealthID", objects[0]); + healthDetails.put("HealthIdNumber", objects[1]); + healthDetails.put("isNewAbha", objects[2]); + } + } + } + return healthDetails; + } + + private Map getBenBenVisitDetails(BigInteger benRegId) { + Map healthDetails = new HashMap<>(); + if (null != benRegId) { + List< BenVisitDetail> benVisitDetail = benVisitDetailsRepo.findByBeneficiaryRegId(benRegId.longValue()); + if (null != benVisitDetail) { + for(BenVisitDetail benVisitDetail1 : benVisitDetail){ + healthDetails.put("HWCVisitDate", benVisitDetail1.getVisitDateTime()); + healthDetails.put("referredto", benVisitDetail1.getHealthFacilityLocation()); + healthDetails.put("followUpDate",benVisitDetail1.getVisitDateTime()); + } + } + + } + return healthDetails; + } + + public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map resultMap) { + Map requestMap = new HashMap(); + requestMap.put("beneficiaryRegID", benRegID); + requestMap.put("beneficiaryID", null); + JsonParser jsnParser = new JsonParser(); + HttpUtils utils = new HttpUtils(); + List result = null; + try { + HashMap header = new HashMap(); + header.put("Authorization", authorization); + String responseStr = utils.post(ConfigProperties.getPropertyByName("fhir-url") + "/" + + ConfigProperties.getPropertyByName("getHealthID"), new Gson().toJson(requestMap), header); + JsonElement jsnElmnt = jsnParser.parse(responseStr); + JsonObject jsnOBJ = new JsonObject(); + jsnOBJ = jsnElmnt.getAsJsonObject(); + if (jsnOBJ.get("data") != null && jsnOBJ.get("data").getAsJsonObject().get("BenHealthDetails") != null) { + result = new ArrayList(); + BenHealthIDDetails[] ben = InputMapper.gson().fromJson( + new Gson().toJson(jsnOBJ.get("data").getAsJsonObject().get("BenHealthDetails")), + BenHealthIDDetails[].class); + for (BenHealthIDDetails value : ben) { + if (value.getHealthId() != null) + resultMap.put("healthId", value.getHealthId()); + if (value.getHealthIdNumber() != null) + resultMap.put("healthIdNumber", value.getHealthIdNumber()); + } + + } + + } catch (Exception e) { + logger.info("Error while fetching ABHA" + e.getMessage()); +// return null; + } + +// return result; + } } \ No newline at end of file From 572cb2cf26e736b03bf7fbee949639e4469f34cc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 25 Apr 2025 17:32:42 +0530 Subject: [PATCH 095/792] Vilage level form --- .../com/iemr/flw/domain/iemr/VillageFormEntry.java | 11 ++++++++++- .../com/iemr/flw/dto/iemr/VilageLevelFormListDto.java | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java index f78661a4..09336296 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java @@ -10,7 +10,7 @@ import java.time.LocalDateTime; @Entity -@Table(name = "village_form_entry") +@Table(name = "village_form_entry",schema = "db_iemr") @Data @AllArgsConstructor @NoArgsConstructor @@ -47,4 +47,13 @@ public class VillageFormEntry { @Column(name = "created_by") private String createdBy; + + @Column(name = "age_group") + private Integer age; + + @Column(name = "location") + private String location; + + @Column(name = "dewormingRound") + private Boolean dewormingRound; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java index 3826aa0f..85fd963c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java @@ -13,5 +13,9 @@ public class VilageLevelFormListDto { private int participantCount; private String imageUrls; // Comma separated URLs or Base64 if needed private String createdBy; + private boolean dewormingRound; + private Integer age; + + } From d19f57fd4456187252858a3da0087ee8b2032835 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 28 Apr 2025 15:15:46 +0530 Subject: [PATCH 096/792] vilage level --- .../controller/VilageLevelFormController.java | 5 +- .../java/com/iemr/flw/dto/iemr/VHNDForm.java | 41 ++++++++++++++ .../com/iemr/flw/dto/iemr/VHNDFormDTO.java | 14 +++++ .../java/com/iemr/flw/dto/iemr/VhndDto.java | 10 ++++ .../flw/repo/iemr/IncentiveRecordRepo.java | 4 +- .../java/com/iemr/flw/repo/iemr/VhndRepo.java | 8 +++ .../com/iemr/flw/service/VhndFormService.java | 3 +- .../flw/service/impl/VhndFormServiceImpl.java | 54 +++++++++++++------ 8 files changed, 118 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VhndDto.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index cb7275d8..33c07e88 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -1,6 +1,7 @@ package com.iemr.flw.controller; import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.VhndDto; import com.iemr.flw.dto.iemr.VilageLevelFormDto; import com.iemr.flw.service.VhndFormService; import org.springframework.beans.factory.annotation.Autowired; @@ -17,8 +18,8 @@ public class VilageLevelFormController { @Autowired private VhndFormService vhndFormService; - @RequestMapping(value = "saveAll",method = RequestMethod.POST) - public ResponseEntity> submitLevelForm(@RequestBody VilageLevelFormDto dto) { + @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST) + public ResponseEntity> submitLevelForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); diff --git a/src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java b/src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java new file mode 100644 index 00000000..d8f89b62 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java @@ -0,0 +1,41 @@ +package com.iemr.flw.dto.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Table(name = "VHND_form",schema = "db_iemr") +@Data +public class VHNDForm { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private int id; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "vhnd_date") + private String vhndDate; + + @Column(name = "place") + private String place; + + @Column(name = "no_of_beneficiaries_attended") + private Integer noOfBeneficiariesAttended; + + @Column(name = "image1") + private String image1; + + @Column(name = "image2") + private String image2; + + @Column(name = "form_type") + private String formType; + + @Column(name = "created_by") + private String createdBy; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java new file mode 100644 index 00000000..64ea4791 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java @@ -0,0 +1,14 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class VHNDFormDTO { + private String vhndDate; + private String place; + private Integer noOfBeneficiariesAttended; + private String image1; + private String image2; +} + + diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java new file mode 100644 index 00000000..053265b1 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; +@Data +public class VhndDto { + private Integer userId; + private List entires; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 4d473911..39834636 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -13,8 +13,8 @@ @Repository public interface IncentiveRecordRepo extends JpaRepository { - @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") - IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate") + IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate); @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java new file mode 100644 index 00000000..14c0002d --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java @@ -0,0 +1,8 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.dto.iemr.VHNDForm; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface VhndRepo extends JpaRepository { + +} diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java index 19030684..d0cffcd4 100644 --- a/src/main/java/com/iemr/flw/service/VhndFormService.java +++ b/src/main/java/com/iemr/flw/service/VhndFormService.java @@ -1,6 +1,7 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.VillageFormEntry; +import com.iemr.flw.dto.iemr.VhndDto; import com.iemr.flw.dto.iemr.VilageLevelFormDto; import com.iemr.flw.repo.iemr.VillageFormRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +16,6 @@ public interface VhndFormService { - public String submitForm(VilageLevelFormDto dto) ; + public String submitForm(VhndDto dto) ; public List getAll(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java index b6359bcb..cf2c0ab8 100644 --- a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java @@ -3,12 +3,8 @@ import com.iemr.flw.domain.iemr.IncentiveActivity; import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.domain.iemr.VillageFormEntry; -import com.iemr.flw.dto.iemr.VilageLevelFormDto; -import com.iemr.flw.dto.iemr.VilageLevelFormListDto; -import com.iemr.flw.repo.iemr.IncentiveRecordRepo; -import com.iemr.flw.repo.iemr.IncentivesRepo; -import com.iemr.flw.repo.iemr.UserServiceRoleRepo; -import com.iemr.flw.repo.iemr.VillageFormRepository; +import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.IncentiveService; import com.iemr.flw.service.VhndFormService; import org.springframework.beans.factory.annotation.Autowired; @@ -36,9 +32,12 @@ public class VhndFormServiceImpl implements VhndFormService { @Autowired private IncentivesRepo incentivesRepo; + @Autowired + private VhndRepo vhndRepo; + - public String submitForm(VilageLevelFormDto vilageLevelFormDto) { - for(VilageLevelFormListDto dto : vilageLevelFormDto.getVilageLevelFormList()){ + public String submitForm(VilageLevelFormDto vilageLevelFormDto) { + for (VilageLevelFormListDto dto : vilageLevelFormDto.getVilageLevelFormList()) { if (dto.getUserId() == null || dto.getDate() == null || dto.getPlace() == null || dto.getParticipantCount() <= 0) { return "Missing or invalid fields"; } @@ -56,7 +55,7 @@ public String submitForm(VilageLevelFormDto vilageLevelFormDto) { entry.setCreatedBy(dto.getCreatedBy()); repository.save(entry); - checkAndAddIncentives(entry); + //checkAndAddIncentives(entry); return "Form submitted successfully"; @@ -64,6 +63,30 @@ public String submitForm(VilageLevelFormDto vilageLevelFormDto) { return "Fail"; + } + + @Override + public String submitForm(VhndDto dto) { + for (VHNDFormDTO vhndFormDTO : dto.getEntires()) { + saveVhndFormData(vhndFormDTO); + + } + return "Fail" ; + } + + private String saveVhndFormData(VHNDFormDTO vhndFormDTO) { + VHNDForm vhndForm = new VHNDForm(); + vhndForm.setVhndDate(vhndFormDTO.getVhndDate()); + vhndForm.setImage2(vhndFormDTO.getImage2()); + vhndForm.setImage1(vhndFormDTO.getImage1()); + vhndForm.setPlace(vhndFormDTO.getPlace()); + vhndForm.setNoOfBeneficiariesAttended(vhndFormDTO.getNoOfBeneficiariesAttended()); + vhndForm.setFormType("VHND"); + vhndRepo.save(vhndForm); + checkAndAddIncentives(vhndForm); + return "Save Vhnd Form successfully"; + + } @Override @@ -72,23 +95,22 @@ public List getAll(Integer userId) { } - private void checkAndAddIncentives(VillageFormEntry villageFormEntry) { + private void checkAndAddIncentives(VHNDForm villageFormEntry) { IncentiveActivity villageFormEntryActivity; villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(villageFormEntry.getFormType(), "VILLAGELEVEL"); if (villageFormEntryActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), Timestamp.valueOf(villageFormEntry.getCreatedDate().toString()), villageFormEntry.getBenId().longValue()); + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivity.getId()); - record.setCreatedDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setCreatedDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); record.setCreatedBy(villageFormEntry.getCreatedBy()); - record.setStartDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); - record.setEndDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); - record.setUpdatedDate(Timestamp.valueOf(villageFormEntry.getCreatedDate().toString())); + record.setStartDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); + record.setEndDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); + record.setUpdatedDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); record.setUpdatedBy(villageFormEntry.getCreatedBy()); - record.setBenId(villageFormEntry.getBenId().longValue()); record.setAshaId(villageFormEntry.getUserId()); record.setName(villageFormEntryActivity.getName()); record.setAmount(Long.valueOf(villageFormEntryActivity.getRate())); From c4fd68aeae578e64473d0de163abd5e5be70abd0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 29 Apr 2025 12:50:44 +0530 Subject: [PATCH 097/792] General OPD --- .../iemr/flw/domain/iemr/GeneralOpdData.java | 212 +++++++++ .../iemr/flw/repo/iemr/GeneralOpdRepo.java | 9 + .../service/impl/BeneficiaryServiceImpl.java | 9 + .../service/impl/GeneralOpdServiceImpl.java | 406 +----------------- .../utils/http/HTTPRequestInterceptor.java | 2 +- 5 files changed, 237 insertions(+), 401 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java new file mode 100644 index 00000000..41f06a30 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.flw.domain.iemr; + +import java.sql.Timestamp; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.persistence.Transient; + +import com.google.gson.annotations.Expose; +import lombok.Data; + +@Data +@Entity +@Table(name = "i_ben_flow_outreach") +public class GeneralOpdData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Expose + @Column(name = "ben_flow_id") + private Long benFlowID; + + @Expose + @Column(name = "beneficiary_reg_id") + private Long beneficiaryRegID; + + @Expose + @Column(name = "beneficiary_visit_id") + private Long benVisitID; + + @Expose + @Column(name = "beneficiary_visit_code") + private Long visitCode; + + @Expose + @Column(name = "visit_reason") + private String VisitReason; + + @Expose + @Column(name = "visit_category") + private String VisitCategory; + + @Expose + @Column(name = "visit_no") + private Short benVisitNo; + + @Expose + @Column(name = "nurse_flag") + private Short nurseFlag; + + @Expose + @Column(name = "doctor_flag") + private Short doctorFlag; + + @Expose + @Column(name = "pharmacist_flag") + private Short pharmacist_flag; + + @Expose + @Column(name = "lab_technician_flag") + private Short lab_technician_flag; + + @Expose + @Column(name = "radiologist_flag") + private Short radiologist_flag; + + @Expose + @Column(name = "oncologist_flag") + private Short oncologist_flag; + + @Expose + @Column(name = "specialist_flag") + private Short specialist_flag; + + @Expose + @Column(name = "TC_SpecialistLabFlag") + private Short tC_SpecialistLabFlag; + + @Expose + @Column(name = "created_by") + private String agentId; + + @Expose + @Column(name = "created_date", insertable = false, updatable = false) + private Timestamp visitDate; + + @Expose + @Column(name = "modified_by") + private String modified_by; + + @Expose + @Column(name = "modified_date", insertable = false) + private Timestamp modified_date; + + @Expose + @Column(name = "ben_name") + private String benName; + + @Expose + @Column(name = "deleted", insertable = false) + private Boolean deleted; + + @Transient + private String firstName; + @Transient + private String lastName; + + @Expose + @Column(name = "ben_age") + private String age; + + @Expose + @Column(name = "ben_age_val") + private Integer ben_age_val; + + @Expose + @Column(name = "ben_dob") + private Timestamp dOB; + + @Expose + @Column(name = "ben_gender_val") + private Short genderID; + @Expose + @Column(name = "ben_gender") + private String genderName; + @Expose + @Column(name = "ben_phone_no") + private String preferredPhoneNum; + @Expose + @Column(name = "father_name") + private String fatherName; +// @Expose +// @Column(name = "benQuickbloxID") +// private Long benQuickbloxID; + @Expose + @Column(name = "spouse_name") + private String spouseName; + + @Expose + @Column(name = "district") + private String districtName; + @Expose + @Column(name = "servicePoint") + private String servicePointName; + + @Expose + @Column(name = "registrationDate") + private Timestamp registrationDate; + + @Expose + @Column(name = "visitDate") + private Timestamp benVisitDate; + + @Expose + @Column(name = "consultationDate") + private Timestamp consultationDate; + + @Expose + @Column(name = "consultantID") + private Integer consultantID; + + @Expose + @Column(name = "consultantName") + private String consultantName; + + @Expose + @Column(name = "visitSession") + private Integer visitSession; + + @Expose + @Column(name = "servicePointID") + private Integer servicePointID; + + @Expose + @Column(name = "districtID") + private Integer districtID; + + @Expose + @Column(name = "villageID") + private Integer villageID; + + @Expose + @Column(name = "vanID") + private Integer vanID; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java b/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java new file mode 100644 index 00000000..b97ebff7 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java @@ -0,0 +1,9 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.GeneralOpdData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface GeneralOpdRepo extends JpaRepository { +} diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index dc018304..d1933029 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -9,7 +9,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import com.iemr.flw.repo.iemr.GeneralOpdRepo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -58,6 +60,8 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { @Autowired private HouseHoldRepo houseHoldRepo; + @Autowired + private GeneralOpdRepo generalOpdRepo; @Override @@ -356,6 +360,9 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("visitDate", healthDetails); resultMap.put("houseoldId", benDetailsRMNCH_OBJ.getHouseoldId()); resultMap.put("benficieryid", benDetailsRMNCH_OBJ.getBenficieryid()); + RMNCHBeneficiaryDetailsRmnch finalBenDetailsRMNCH_OBJ = benDetailsRMNCH_OBJ; + resultMap.put("generalOpdData", generalOpdRepo.findAll().stream().filter(generalOpdData -> generalOpdData.getBeneficiaryRegID().equals(finalBenDetailsRMNCH_OBJ.getBenficieryid())).collect(Collectors.toList())); + resultMap.put("BenRegId", m.getBenRegId()); // adding asha id / created by - user id @@ -456,4 +463,6 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map resultSet; - Integer pageSize = Integer.valueOf(door_to_door_page_size); - if (request.getPageNo() != null) { - String userName = beneficiaryRepo.getUserName(request.getAshaId()); - if (userName == null || userName.isEmpty()) - throw new Exception("Asha details not found, please contact administrator"); - - request.setUserName(userName); - - PageRequest pr = PageRequest.of(request.getPageNo(), pageSize); - if (request.getFromDate() != null && request.getToDate() != null) { - Page p = beneficiaryRepo.getBenDataWithinDates( - request.getUserName(), request.getFromDate(), request.getToDate(), pr); - resultSet = p.getContent(); - totalPage = p.getTotalPages(); - } else { - Page p = beneficiaryRepo.getBenDataByUser(request.getUserName(), - pr); - resultSet = p.getContent(); - totalPage = p.getTotalPages(); - } - if (resultSet != null && resultSet.size() > 0) { - outputResponse = getMappingsForAddressIDs(resultSet, totalPage, authorisation); - } - } else { - // page no not invalid - throw new Exception("Invalid page no"); - } - } else - throw new Exception("Invalid/missing village details"); - } catch (Exception e) { - throw new Exception(e.getMessage()); - } - - return outputResponse; - } - - private String getMappingsForAddressIDs(List addressList, int totalPage, - String authorisation) { - RMNCHHouseHoldDetails benHouseHoldRMNCH_ROBJ; - RMNCHBeneficiaryDetailsRmnch benDetailsRMNCH_OBJ; - RMNCHBornBirthDetails benBotnBirthRMNCH_ROBJ; - - RMNCHMBeneficiarydetail benDetailsOBJ; - RMNCHMBeneficiaryAccount benAccountOBJ; - RMNCHMBeneficiaryImage benImageOBJ; - RMNCHMBeneficiaryaddress benAddressOBJ; - RMNCHMBeneficiarycontact benContactOBJ; - - Map resultMap; - ArrayList> resultList = new ArrayList<>(); - - for (RMNCHMBeneficiaryaddress a : addressList) { - // exception by-passing - try { - RMNCHMBeneficiarymapping m = beneficiaryRepo.getByAddressID(a.getId()); - if (m != null) { - benHouseHoldRMNCH_ROBJ = new RMNCHHouseHoldDetails(); - benDetailsRMNCH_OBJ = new RMNCHBeneficiaryDetailsRmnch(); - benBotnBirthRMNCH_ROBJ = new RMNCHBornBirthDetails(); - - benDetailsOBJ = new RMNCHMBeneficiarydetail(); - benAccountOBJ = new RMNCHMBeneficiaryAccount(); - benImageOBJ = new RMNCHMBeneficiaryImage(); - benAddressOBJ = new RMNCHMBeneficiaryaddress(); - benContactOBJ = new RMNCHMBeneficiarycontact(); - Map healthDetails = getBenHealthDetails(m.getBenRegId()); - System.out.println("BenId:"+m.getBenRegId()); - Map benVisitthDetails = getBenBenVisitDetails(m.getBenRegId()); - if (m.getBenDetailsId() != null) { - benDetailsOBJ = beneficiaryRepo.getDetailsById(m.getBenDetailsId()); - } - if (m.getBenAccountID() != null) { - benAccountOBJ = beneficiaryRepo.getAccountById(m.getBenAccountID()); - } - if (m.getBenImageId() != null) { - benImageOBJ = beneficiaryRepo.getImageById(m.getBenImageId().longValue()); - } - if (m.getBenAddressId() != null) { - benAddressOBJ = beneficiaryRepo.getAddressById(m.getBenAddressId()); - } - if (m.getBenContactsId() != null) { - benContactOBJ = beneficiaryRepo.getContactById(m.getBenContactsId()); - } - - BigInteger benID = null; - if (m.getBenRegId() != null) - benID = beneficiaryRepo.getBenIdFromRegID(m.getBenRegId().longValue()); - - if (m.getBenRegId() != null) { - benDetailsRMNCH_OBJ = beneficiaryRepo - .getDetailsByRegID((m.getBenRegId()).longValue()); - benBotnBirthRMNCH_ROBJ = beneficiaryRepo.getBornBirthByRegID((m.getBenRegId()).longValue()); - - if (benDetailsRMNCH_OBJ != null && benDetailsRMNCH_OBJ.getHouseoldId() != null) - benHouseHoldRMNCH_ROBJ = houseHoldRepo - .getByHouseHoldID(benDetailsRMNCH_OBJ.getHouseoldId()); - - } - if (benDetailsRMNCH_OBJ == null) - benDetailsRMNCH_OBJ = new RMNCHBeneficiaryDetailsRmnch(); - - // new mapping 30-06-2021 - if (benDetailsOBJ.getMotherName() != null) - benDetailsRMNCH_OBJ.setMotherName(benDetailsOBJ.getMotherName()); - if (benDetailsOBJ.getLiteracyStatus() != null) - benDetailsRMNCH_OBJ.setLiteracyStatus(benDetailsOBJ.getLiteracyStatus()); - - // bank - if (benAccountOBJ.getNameOfBank() != null) - benDetailsRMNCH_OBJ.setNameOfBank(benAccountOBJ.getNameOfBank()); - if (benAccountOBJ.getBranchName() != null) - benDetailsRMNCH_OBJ.setBranchName(benAccountOBJ.getBranchName()); - if (benAccountOBJ.getIfscCode() != null) - benDetailsRMNCH_OBJ.setIfscCode(benAccountOBJ.getIfscCode()); - if (benAccountOBJ.getBankAccount() != null) - benDetailsRMNCH_OBJ.setBankAccount(benAccountOBJ.getBankAccount()); - - // location - if (benAddressOBJ.getCountyid() != null) - benDetailsRMNCH_OBJ.setCountryId(benAddressOBJ.getCountyid()); - if (benAddressOBJ.getPermCountry() != null) - benDetailsRMNCH_OBJ.setCountryName(benAddressOBJ.getPermCountry()); - - if (benAddressOBJ.getStatePerm() != null) - benDetailsRMNCH_OBJ.setStateId(benAddressOBJ.getStatePerm()); - if (benAddressOBJ.getPermState() != null) - benDetailsRMNCH_OBJ.setStateName(benAddressOBJ.getPermState()); - - if (benAddressOBJ.getDistrictidPerm() != null) { - benDetailsRMNCH_OBJ.setDistrictid(benAddressOBJ.getDistrictidPerm()); - - } - if (benAddressOBJ.getDistrictnamePerm() != null) { - benDetailsRMNCH_OBJ.setDistrictname(benAddressOBJ.getDistrictnamePerm()); - - } - - if (benAddressOBJ.getPermSubDistrictId() != null) - benDetailsRMNCH_OBJ.setBlockId(benAddressOBJ.getPermSubDistrictId()); - if (benAddressOBJ.getPermSubDistrict() != null) - benDetailsRMNCH_OBJ.setBlockName(benAddressOBJ.getPermSubDistrict()); - - if (benAddressOBJ.getVillageidPerm() != null) - benDetailsRMNCH_OBJ.setVillageId(benAddressOBJ.getVillageidPerm()); - if (benAddressOBJ.getVillagenamePerm() != null) - benDetailsRMNCH_OBJ.setVillageName(benAddressOBJ.getVillagenamePerm()); - - if (benAddressOBJ.getPermServicePointId() != null) - benDetailsRMNCH_OBJ.setServicePointID(benAddressOBJ.getPermServicePointId()); - if (benAddressOBJ.getPermServicePoint() != null) - benDetailsRMNCH_OBJ.setServicePointName(benAddressOBJ.getPermServicePoint()); - - if (benAddressOBJ.getPermZoneID() != null) - benDetailsRMNCH_OBJ.setZoneID(benAddressOBJ.getPermZoneID()); - if (benAddressOBJ.getPermZone() != null) - benDetailsRMNCH_OBJ.setZoneName(benAddressOBJ.getPermZone()); - - if (benAddressOBJ.getPermAddrLine1() != null) - benDetailsRMNCH_OBJ.setAddressLine1(benAddressOBJ.getPermAddrLine1()); - if (benAddressOBJ.getPermAddrLine2() != null) - benDetailsRMNCH_OBJ.setAddressLine2(benAddressOBJ.getPermAddrLine2()); - if (benAddressOBJ.getPermAddrLine3() != null) - benDetailsRMNCH_OBJ.setAddressLine3(benAddressOBJ.getPermAddrLine3()); - - // ----------------------------------------------------------------------------- - - // related benids - if (benDetailsRMNCH_OBJ.getRelatedBeneficiaryIdsDB() != null) { - - String[] relatedBenIDsString = benDetailsRMNCH_OBJ.getRelatedBeneficiaryIdsDB().split(","); - Long[] relatedBenIDs = new Long[relatedBenIDsString.length]; - int pointer = 0; - for (String s : relatedBenIDsString) { - relatedBenIDs[pointer] = Long.valueOf(s); - pointer++; - } - - benDetailsRMNCH_OBJ.setRelatedBeneficiaryIds(relatedBenIDs); - } - // ------------------------------------------------------------------------------ - - if (benDetailsOBJ.getCommunity() != null) - benDetailsRMNCH_OBJ.setCommunity(benDetailsOBJ.getCommunity()); - if (benDetailsOBJ.getCommunityId() != null) - benDetailsRMNCH_OBJ.setCommunityId(benDetailsOBJ.getCommunityId()); - if (benContactOBJ.getPreferredPhoneNum() != null) - benDetailsRMNCH_OBJ.setContact_number(benContactOBJ.getPreferredPhoneNum()); - - if (benDetailsOBJ.getDob() != null) - benDetailsRMNCH_OBJ.setDob(benDetailsOBJ.getDob()); - if (benDetailsOBJ.getFatherName() != null) - benDetailsRMNCH_OBJ.setFatherName(benDetailsOBJ.getFatherName()); - if (benDetailsOBJ.getFirstName() != null) - benDetailsRMNCH_OBJ.setFirstName(benDetailsOBJ.getFirstName()); - if (benDetailsOBJ.getGender() != null) - benDetailsRMNCH_OBJ.setGender(benDetailsOBJ.getGender()); - if (benDetailsOBJ.getGenderId() != null) - benDetailsRMNCH_OBJ.setGenderId(benDetailsOBJ.getGenderId()); - - if (benDetailsOBJ.getMaritalstatus() != null) - benDetailsRMNCH_OBJ.setMaritalstatus(benDetailsOBJ.getMaritalstatus()); - if (benDetailsOBJ.getMaritalstatusId() != null) - benDetailsRMNCH_OBJ.setMaritalstatusId(benDetailsOBJ.getMaritalstatusId()); - if (benDetailsOBJ.getMarriageDate() != null) - benDetailsRMNCH_OBJ.setMarriageDate(benDetailsOBJ.getMarriageDate()); - - if (benDetailsOBJ.getReligion() != null) - benDetailsRMNCH_OBJ.setReligion(benDetailsOBJ.getReligion()); - if (benDetailsOBJ.getReligionID() != null) - benDetailsRMNCH_OBJ.setReligionID(benDetailsOBJ.getReligionID()); - if (benDetailsOBJ.getSpousename() != null) - benDetailsRMNCH_OBJ.setSpousename(benDetailsOBJ.getSpousename()); - - if (benImageOBJ != null && benImageOBJ.getUser_image() != null) - benDetailsRMNCH_OBJ.setUser_image(benImageOBJ.getUser_image()); - - // new fields -// benDetailsRMNCH_OBJ.setRegistrationDate(benDetailsOBJ.getCreatedDate()); - if (benID != null) - benDetailsRMNCH_OBJ.setBenficieryid(benID.longValue()); - - if (benDetailsOBJ.getLastName() != null) - benDetailsRMNCH_OBJ.setLastName(benDetailsOBJ.getLastName()); - - if (benDetailsRMNCH_OBJ.getCreatedBy() == null) - if (benDetailsOBJ.getCreatedBy() != null) - benDetailsRMNCH_OBJ.setCreatedBy(benDetailsOBJ.getCreatedBy()); - - // age calculation - String ageDetails = ""; - int age_val = 0; - String ageUnit = null; - if (benDetailsOBJ.getDob() != null) { - - Date date = new Date(benDetailsOBJ.getDob().getTime()); - Calendar cal = Calendar.getInstance(); - - cal.setTime(date); - - int year = cal.get(Calendar.YEAR); - int month = cal.get(Calendar.MONTH) + 1; - int day = cal.get(Calendar.DAY_OF_MONTH); - - java.time.LocalDate todayDate = java.time.LocalDate.now(); - java.time.LocalDate birthdate = java.time.LocalDate.of(year, month, day); - Period p = Period.between(birthdate, todayDate); - - int d = p.getDays(); - int mo = p.getMonths(); - int y = p.getYears(); - - if (y > 0) { - ageDetails = y + " years - " + mo + " months"; - age_val = y; - ageUnit = (age_val > 1) ? "Years" : "Year"; - } else { - if (mo > 0) { - ageDetails = mo + " months - " + d + " days"; - age_val = mo; - ageUnit = (age_val > 1) ? "Months" : "Month"; - } else { - ageDetails = d + " days"; - age_val = d; - ageUnit = (age_val > 1) ? "Days" : "Day"; - } - } - - } - - benDetailsRMNCH_OBJ.setAgeFull(ageDetails); - benDetailsRMNCH_OBJ.setAge(age_val); - if (ageUnit != null) - benDetailsRMNCH_OBJ.setAge_unit(ageUnit); - - resultMap = new HashMap<>(); - if (benHouseHoldRMNCH_ROBJ != null) { - resultMap.put("householdDetails", benHouseHoldRMNCH_ROBJ); - resultMap.put("benVisitDate", benVisitthDetails); - - } else { - - resultMap.put("householdDetails", new HashMap()); - } - - - if (benBotnBirthRMNCH_ROBJ != null) - resultMap.put("bornbirthDeatils", benBotnBirthRMNCH_ROBJ); - else - resultMap.put("bornbirthDeatils", new HashMap()); - - resultMap.put("beneficiaryDetails", benDetailsRMNCH_OBJ); - resultMap.put("abhaHealthDetails", healthDetails); - resultMap.put("visitDate", healthDetails); - resultMap.put("houseoldId", benDetailsRMNCH_OBJ.getHouseoldId()); - resultMap.put("benficieryid", benDetailsRMNCH_OBJ.getBenficieryid()); - resultMap.put("BenRegId", m.getBenRegId()); - - // adding asha id / created by - user id - if (benAddressOBJ.getCreatedBy() != null) { - Integer userID = beneficiaryRepo.getUserIDByUserName(benAddressOBJ.getCreatedBy()); - if (userID != null && userID > 0) - resultMap.put("ashaId", userID); - } - // get HealthID of ben - if (m.getBenRegId() != null) { - fetchHealthIdByBenRegID(m.getBenRegId().longValue(), authorisation, resultMap); - } - - resultList.add(resultMap); - - } else { - // mapping not available - } - } catch (Exception e) { - logger.error("error for addressID :" + a.getId() + " and vanID : " + a.getVanID()); - } - } - - Map response = new HashMap<>(); - response.put("data", resultList); - response.put("pageSize", Integer.parseInt(door_to_door_page_size)); - response.put("totalPage", totalPage); - Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy HH:mm:ss a").create(); - return gson.toJson(response); - } - - private Map getBenHealthDetails(BigInteger benRegId) { - Map healthDetails = new HashMap<>(); - if (null != benRegId) { - String benHealthIdNumber = beneficiaryRepo.getBenHealthIdNumber(benRegId); - if (null != benHealthIdNumber) { - ArrayList health = beneficiaryRepo.getBenHealthDetails(benHealthIdNumber); - for (Object[] objects : health) { - healthDetails.put("HealthID", objects[0]); - healthDetails.put("HealthIdNumber", objects[1]); - healthDetails.put("isNewAbha", objects[2]); - } - } - } - return healthDetails; - } - - private Map getBenBenVisitDetails(BigInteger benRegId) { - Map healthDetails = new HashMap<>(); - if (null != benRegId) { - List< BenVisitDetail> benVisitDetail = benVisitDetailsRepo.findByBeneficiaryRegId(benRegId.longValue()); - if (null != benVisitDetail) { - for(BenVisitDetail benVisitDetail1 : benVisitDetail){ - healthDetails.put("HWCVisitDate", benVisitDetail1.getVisitDateTime()); - healthDetails.put("referredto", benVisitDetail1.getHealthFacilityLocation()); - healthDetails.put("followUpDate",benVisitDetail1.getVisitDateTime()); - } - } - - } - return healthDetails; - } - - public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map resultMap) { - Map requestMap = new HashMap(); - requestMap.put("beneficiaryRegID", benRegID); - requestMap.put("beneficiaryID", null); - JsonParser jsnParser = new JsonParser(); - HttpUtils utils = new HttpUtils(); - List result = null; - try { - HashMap header = new HashMap(); - header.put("Authorization", authorization); - String responseStr = utils.post(ConfigProperties.getPropertyByName("fhir-url") + "/" - + ConfigProperties.getPropertyByName("getHealthID"), new Gson().toJson(requestMap), header); - JsonElement jsnElmnt = jsnParser.parse(responseStr); - JsonObject jsnOBJ = new JsonObject(); - jsnOBJ = jsnElmnt.getAsJsonObject(); - if (jsnOBJ.get("data") != null && jsnOBJ.get("data").getAsJsonObject().get("BenHealthDetails") != null) { - result = new ArrayList(); - BenHealthIDDetails[] ben = InputMapper.gson().fromJson( - new Gson().toJson(jsnOBJ.get("data").getAsJsonObject().get("BenHealthDetails")), - BenHealthIDDetails[].class); - for (BenHealthIDDetails value : ben) { - if (value.getHealthId() != null) - resultMap.put("healthId", value.getHealthId()); - if (value.getHealthIdNumber() != null) - resultMap.put("healthIdNumber", value.getHealthIdNumber()); - } - - } - - } catch (Exception e) { - logger.info("Error while fetching ABHA" + e.getMessage()); -// return null; - } -// return result; + @Override + public String getOpdListForAsha(GetBenRequestHandler request, String authorisation) throws Exception { + return generalOpdRepo.findAll().toString(); } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..571348ed 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + //validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From 99e3df1e7dfb919385d47a13ab99a116c23b99b5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 13:45:30 +0530 Subject: [PATCH 098/792] Village leve form and asha incentive logic --- .../controller/VilageLevelFormController.java | 55 ++++- .../com/iemr/flw/domain/iemr/AHDForm.java | 47 ++++ .../iemr/flw/domain/iemr/DewormingForm.java | 50 ++++ .../iemr/flw/domain/iemr/PHCReviewForm.java | 47 ++++ .../flw/{dto => domain}/iemr/VHNDForm.java | 11 +- .../com/iemr/flw/domain/iemr/VhncForm.java | 46 ++++ .../iemr/flw/dto/iemr/AhDMeetingFormDTO.java | 13 ++ .../com/iemr/flw/dto/iemr/AhdMeetingDto.java | 11 + .../com/iemr/flw/dto/iemr/DewormingDto.java | 11 + .../iemr/flw/dto/iemr/DewormingFormDTO.java | 14 ++ .../iemr/GetVillageLevelRequestHandler.java | 20 ++ .../flw/dto/iemr/PhcReviewMeetingDTO.java | 10 + .../flw/dto/iemr/PhcReviewMeetingFormDTO.java | 15 ++ .../java/com/iemr/flw/dto/iemr/VhncDto.java | 11 + .../com/iemr/flw/dto/iemr/VhncFormDTO.java | 13 ++ .../java/com/iemr/flw/dto/iemr/VhndDto.java | 4 +- .../com/iemr/flw/repo/iemr/AHDFormRepo.java | 10 + .../iemr/flw/repo/iemr/DewormingFormRepo.java | 10 + .../flw/repo/iemr/IncentiveRecordRepo.java | 7 +- .../iemr/flw/repo/iemr/PHCReviewFormRepo.java | 10 + .../com/iemr/flw/repo/iemr/VhncFormRepo.java | 10 + .../java/com/iemr/flw/repo/iemr/VhndRepo.java | 6 +- .../com/iemr/flw/service/VhndFormService.java | 13 +- .../flw/service/impl/VhndFormServiceImpl.java | 219 ++++++++++++++---- 24 files changed, 600 insertions(+), 63 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/AHDForm.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/DewormingForm.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java rename src/main/java/com/iemr/flw/{dto => domain}/iemr/VHNDForm.java (76%) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/VhncForm.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AhDMeetingFormDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AhdMeetingDto.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DewormingDto.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DewormingFormDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VhncDto.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index 33c07e88..7c575578 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -1,39 +1,80 @@ package com.iemr.flw.controller; import com.iemr.flw.dto.identity.GetBenRequestHandler; -import com.iemr.flw.dto.iemr.VhndDto; -import com.iemr.flw.dto.iemr.VilageLevelFormDto; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.VhndFormService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.Map; @RestController -@RequestMapping(value = "/forms/vilageLevel") +@RequestMapping(value = "/forms/villageLevel") public class VilageLevelFormController { @Autowired private VhndFormService vhndFormService; @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST) - public ResponseEntity> submitLevelForm(@RequestBody VhndDto dto) { + public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); response.put("msg", vhndFormService.submitForm(dto)); return ResponseEntity.ok(response); } + @RequestMapping(value = "vhnc/saveAll",method = RequestMethod.POST) + public ResponseEntity> submitVhncForm(@RequestBody VhncDto dto) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("msg", vhndFormService.submitVhncForm(dto)); + return ResponseEntity.ok(response); + } + @RequestMapping(value = "phc/saveAll",method = RequestMethod.POST) + public ResponseEntity> submitPhcForm(@RequestBody PhcReviewMeetingDTO dto) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("msg", vhndFormService.submitPhcForm(dto)); + return ResponseEntity.ok(response); + } - @RequestMapping(value = "getAll",method = RequestMethod.POST) - public ResponseEntity> getVilageLevelFormData(@RequestBody GetBenRequestHandler getBenRequestHandler) { + @RequestMapping(value = "ahd/saveAll",method = RequestMethod.POST) + public ResponseEntity> submitAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", vhndFormService.getAll(getBenRequestHandler.getUserId())); + response.put("msg", vhndFormService.submitAdhForm(dto)); + return ResponseEntity.ok(response); + } + + @RequestMapping(value = "deworming/saveAll",method = RequestMethod.POST) + public ResponseEntity> submitDewormingForm(@RequestBody DewormingDto dto) { + Map response = new HashMap<>(); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("msg", vhndFormService.submitDewormingForm(dto)); + return ResponseEntity.ok(response); + } + + + @RequestMapping(value = "getAll",method = RequestMethod.POST) + public ResponseEntity> getVilageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { + Map data = new HashMap<>(); + data.put("userId", getVillageLevelRequestHandler.getUserId()); + data.put("entries", vhndFormService.getAll(getVillageLevelRequestHandler)); + + Map response = new LinkedHashMap<>(); + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/AHDForm.java b/src/main/java/com/iemr/flw/domain/iemr/AHDForm.java new file mode 100644 index 00000000..a9a20dfb --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/AHDForm.java @@ -0,0 +1,47 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; + +import java.sql.Timestamp; + +import static jakarta.persistence.GenerationType.IDENTITY; + +@Entity +@Table(name = "ahd_form", schema = "db_iemr") +@Data +public class AHDForm { + + @Id + @GeneratedValue(strategy = IDENTITY) + private int id; + + @Column(name = "mobilized_for_ahd") + private String mobilizedForAHD; + + @Column(name = "ahd_place") + private String ahdPlace; + + @Column(name = "ahd_date") + private String ahdDate; + + @Column(name = "image1") + private String image1; + + @Column(name = "image2") + private String image2; + + @Column(name = "user_id") + private Long userId; + + @Column(name = "created_by") + private String createdBy; + + @CreationTimestamp + @Column(name = "created_date", updatable = false) + private Timestamp createdDate; + + @Column(name = "form_type") + private String formType; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/DewormingForm.java b/src/main/java/com/iemr/flw/domain/iemr/DewormingForm.java new file mode 100644 index 00000000..631dbfd5 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/DewormingForm.java @@ -0,0 +1,50 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; + +import java.sql.Timestamp; + +import static jakarta.persistence.GenerationType.IDENTITY; + +@Entity +@Table(name = "deworming_form", schema = "db_iemr") +@Data +public class DewormingForm { + + @Id + @GeneratedValue(strategy = IDENTITY) + private int id; + + @Column(name = "deworming_done") + private String dewormingDone; + + @Column(name = "deworming_date") + private String dewormingDate; + + @Column(name = "deworming_location") + private String dewormingLocation; + + @Column(name = "age_group") + private Integer ageGroup; + + @Column(name = "image1") + private String image1; + + @Column(name = "image2") + private String image2; + + @Column(name = "user_id") + private Long userId; + + @Column(name = "created_by") + private String createdBy; + + @CreationTimestamp + @Column(name = "created_date", updatable = false) + private Timestamp createdDate; + + @Column(name = "form_type") + private String formType; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java new file mode 100644 index 00000000..50ec3375 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java @@ -0,0 +1,47 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; + +import java.sql.Timestamp; + +import static jakarta.persistence.GenerationType.IDENTITY; + +@Entity +@Table(name = "phc_review_meeting", schema = "db_iemr") +@Data +public class PHCReviewForm { + + @Id + @GeneratedValue(strategy = IDENTITY) + private int id; + + @Column(name = "phc_review_date") + private String phcReviewDate; + + @Column(name = "place") + private String place; + + @Column(name = "no_of_beneficiaries_attended") + private Integer noOfBeneficiariesAttended; + + @Column(name = "image1") + private String image1; + + @Column(name = "image2") + private String image2; + + @Column(name = "user_id") + private Long userId; + + @Column(name = "created_by") + private String createdBy; + + @CreationTimestamp + @Column(name = "created_date", updatable = false) + private Timestamp createdDate; + + @Column(name = "form_type") + private String formType; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java b/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java similarity index 76% rename from src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java rename to src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java index d8f89b62..488b33c4 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VHNDForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java @@ -1,7 +1,10 @@ -package com.iemr.flw.dto.iemr; +package com.iemr.flw.domain.iemr; import jakarta.persistence.*; import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; + +import java.sql.Timestamp; @Entity @Table(name = "VHND_form",schema = "db_iemr") @@ -37,5 +40,9 @@ public class VHNDForm { @Column(name = "created_by") private String createdBy; + @CreationTimestamp + @Column(name = "created_date", updatable = false) + private Timestamp createdDate; + -} +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java new file mode 100644 index 00000000..8d646095 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java @@ -0,0 +1,46 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import org.hibernate.annotations.CreationTimestamp; + +import java.sql.Timestamp; + +import static jakarta.persistence.GenerationType.*; + +@Entity +@Table(name = "vhnc_form",schema = "iemr") +@Data +public class VhncForm { + @Id + @GeneratedValue(strategy = IDENTITY) + private int id; + + @Column(name = "vhnc_date") + private String vhncDate; + + @Column(name = "place") + private String place; + + @Column(name = "no_of_beneficiaries_attended") + private Integer noOfBeneficiariesAttended; + + @Column(name = "image1") + private String image1; + + @Column(name = "image2") + private String image2; + + @Column(name = "user_id") + private Long userId; + + @Column(name = "created_by") + private String createdBy; + + @CreationTimestamp + @Column(name = "created_date", updatable = false) + private Timestamp createdDate; + + @Column(name = "form_type") + private String formType; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/AhDMeetingFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AhDMeetingFormDTO.java new file mode 100644 index 00000000..0ecc31be --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AhDMeetingFormDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class AhDMeetingFormDTO { + private int id = 0; + private String mobilizedForAHD; + private String ahdPlace; + private String ahdDate; + private String image1; + private String image2; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/AhdMeetingDto.java b/src/main/java/com/iemr/flw/dto/iemr/AhdMeetingDto.java new file mode 100644 index 00000000..fc5e7a26 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AhdMeetingDto.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; + +@Data +public class AhdMeetingDto { + private Integer userId; + private List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DewormingDto.java b/src/main/java/com/iemr/flw/dto/iemr/DewormingDto.java new file mode 100644 index 00000000..f95598c8 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DewormingDto.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; + +@Data +public class DewormingDto { + private Integer userId; + private List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DewormingFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DewormingFormDTO.java new file mode 100644 index 00000000..bf77cd65 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DewormingFormDTO.java @@ -0,0 +1,14 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class DewormingFormDTO { + private int id = 0; + private String dewormingDone; + private String dewormingDate; + private String dewormingLocation; + private Integer ageGroup; + private String image1; + private String image2; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java new file mode 100644 index 00000000..446d1059 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java @@ -0,0 +1,20 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Timestamp; +@Data +public class GetVillageLevelRequestHandler { + private String formType; + private Integer villageID; + private Timestamp fromDate; + private Timestamp toDate; + private Integer pageNo; + private Integer userId; + private String userName; + + private Integer ashaId; + + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingDTO.java new file mode 100644 index 00000000..7d265b81 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; +@Data +public class PhcReviewMeetingDTO { + private Integer userId; + private List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java new file mode 100644 index 00000000..00830988 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class PhcReviewMeetingFormDTO { + private int id; + private String phcReviewDate; + private String place; + private Integer noOfBeneficiariesAttended; + private String image1; + private String image2; + + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java new file mode 100644 index 00000000..8fe45ef2 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; + +@Data +public class VhncDto { + private Integer userId; + private List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java new file mode 100644 index 00000000..d7352ed5 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class VhncFormDTO { + private int id; + private String vhncDate; + private String place; + private Integer noOfBeneficiariesAttended; + private String image1; + private String image2; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java index 053265b1..3f53e65b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java @@ -6,5 +6,5 @@ @Data public class VhndDto { private Integer userId; - private List entires; -} + private List entries; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java new file mode 100644 index 00000000..a13150e1 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.AHDForm; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AHDFormRepo extends JpaRepository { + // You can add custom query methods here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java new file mode 100644 index 00000000..32257b1b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.DewormingForm; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface DewormingFormRepo extends JpaRepository { + // You can add custom query methods here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 39834636..989e6e24 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -13,9 +13,12 @@ @Repository public interface IncentiveRecordRepo extends JpaRepository { - @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate") - IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") + IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); + + @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId") + List findRecordsByAsha(@Param("ashaId") Integer ashaId); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java new file mode 100644 index 00000000..470677ef --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.PHCReviewForm; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PHCReviewFormRepo extends JpaRepository { + // You can add custom query methods here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java new file mode 100644 index 00000000..e1dfb985 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.VhncForm; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface VhncFormRepo extends JpaRepository { + // You can add custom query methods here if needed +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java index 14c0002d..2e41ce3f 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java @@ -1,8 +1,10 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.dto.iemr.VHNDForm; +import com.iemr.flw.domain.iemr.VHNDForm; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +@Repository public interface VhndRepo extends JpaRepository { -} +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java index d0cffcd4..03b03051 100644 --- a/src/main/java/com/iemr/flw/service/VhndFormService.java +++ b/src/main/java/com/iemr/flw/service/VhndFormService.java @@ -1,8 +1,7 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.VillageFormEntry; -import com.iemr.flw.dto.iemr.VhndDto; -import com.iemr.flw.dto.iemr.VilageLevelFormDto; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.repo.iemr.VillageFormRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -16,6 +15,10 @@ public interface VhndFormService { - public String submitForm(VhndDto dto) ; - public List getAll(Integer userId); -} + public String submitForm(VhndDto dto); + public String submitVhncForm(VhncDto dto); + public String submitPhcForm(PhcReviewMeetingDTO dto); + public String submitAdhForm(AhdMeetingDto dto); + public String submitDewormingForm(DewormingDto dto); + public Object getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler); +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java index cf2c0ab8..06b4f9f8 100644 --- a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java @@ -1,26 +1,28 @@ package com.iemr.flw.service.impl; -import com.iemr.flw.domain.iemr.IncentiveActivity; -import com.iemr.flw.domain.iemr.IncentiveActivityRecord; -import com.iemr.flw.domain.iemr.VillageFormEntry; +import com.iemr.flw.controller.CoupleController; +import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.repo.iemr.*; -import com.iemr.flw.service.IncentiveService; import com.iemr.flw.service.VhndFormService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import java.sql.Date; import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.List; +import java.time.format.DateTimeFormatter; +import java.util.Collections; import java.util.Objects; import java.util.stream.Collectors; @Service public class VhndFormServiceImpl implements VhndFormService { + private final Logger logger = LoggerFactory.getLogger(CoupleController.class); + @Autowired private VillageFormRepository repository; @@ -32,50 +34,142 @@ public class VhndFormServiceImpl implements VhndFormService { @Autowired private IncentivesRepo incentivesRepo; + @Autowired + private PHCReviewFormRepo phcReviewFormRepo; + + @Autowired + private DewormingFormRepo dewormingFormRepo; + + @Autowired + private VhncFormRepo vhndFormRepo; + @Autowired private VhndRepo vhndRepo; + @Autowired + private VhncFormRepo vhncFormRepo; - public String submitForm(VilageLevelFormDto vilageLevelFormDto) { - for (VilageLevelFormListDto dto : vilageLevelFormDto.getVilageLevelFormList()) { - if (dto.getUserId() == null || dto.getDate() == null || dto.getPlace() == null || dto.getParticipantCount() <= 0) { - return "Missing or invalid fields"; - } + @Autowired + private AHDFormRepo ahdFormRepo; - VillageFormEntry entry = new VillageFormEntry(); - entry.setUserId(dto.getUserId()); - entry.setFormType(dto.getFormType()); - entry.setDate(dto.getDate()); - entry.setPlace(dto.getPlace()); - entry.setParticipantCount(dto.getParticipantCount()); - entry.setImageUrls(dto.getImageUrls()); - entry.setSubmittedAt(LocalDateTime.now()); - entry.setCreatedDate(Date.valueOf(LocalDate.now())); - entry.setCreatedBy(dto.getCreatedBy()); - repository.save(entry); - //checkAndAddIncentives(entry); - return "Form submitted successfully"; + @Override + public String submitForm(VhndDto dto) { + for (VHNDFormDTO vhndFormDTO : dto.getEntries()) { + saveVhndFormData(vhndFormDTO, dto.getUserId()); + } + return "Fail"; + } + @Override + public String submitVhncForm(VhncDto dto) { + for (VhncFormDTO vhncFormDTO : dto.getEntries()) { + saveVhncFormData(vhncFormDTO, dto.getUserId()); } return "Fail"; + } + + + @Override + public String submitPhcForm(PhcReviewMeetingDTO dto) { + for (PhcReviewMeetingFormDTO phcReviewMeetingDTO : dto.getEntries()) { + submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); + } + return "Fail"; + } + + @Override + public String submitAdhForm(AhdMeetingDto dto) { + for (AhDMeetingFormDTO ahDMeetingFormDTO : dto.getEntries()) { + submitAhdForm(ahDMeetingFormDTO, dto.getUserId()); + } + return "Fail"; } @Override - public String submitForm(VhndDto dto) { - for (VHNDFormDTO vhndFormDTO : dto.getEntires()) { - saveVhndFormData(vhndFormDTO); + public String submitDewormingForm(DewormingDto dto) { + for (DewormingFormDTO dewormingFormDTO : dto.getEntries()) { + submitDewormingForm(dewormingFormDTO, dto.getUserId()); + } + return "Fail"; + } + + private String saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { + VhncForm vhncForm = new VhncForm(); + vhncForm.setUserId(Long.valueOf(userID)); + vhncForm.setVhncDate(vhncFormDTO.getVhncDate()); + vhncForm.setImage2(vhncFormDTO.getImage2()); + vhncForm.setImage1(vhncFormDTO.getImage1()); + vhncForm.setPlace(vhncFormDTO.getPlace()); + vhncForm.setNoOfBeneficiariesAttended(vhncFormDTO.getNoOfBeneficiariesAttended()); + + vhncForm.setFormType("VHNC"); + vhncFormRepo.save(vhncForm); + checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), vhncForm.getFormType(),vhncForm.getCreatedBy()); + + return "Save Vhnd Form successfully"; + } + + + private String submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { + PHCReviewForm phcReviewForm = new PHCReviewForm(); + phcReviewForm.setUserId(Long.valueOf(userID)); + phcReviewForm.setPhcReviewDate(dto.getPhcReviewDate()); + phcReviewForm.setPlace(dto.getPlace()); + phcReviewForm.setNoOfBeneficiariesAttended(dto.getNoOfBeneficiariesAttended()); + phcReviewForm.setImage1(dto.getImage1()); + phcReviewForm.setImage2(dto.getImage2()); + phcReviewForm.setFormType("PHC"); + phcReviewFormRepo.save(phcReviewForm); + checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), phcReviewForm.getFormType(),phcReviewForm.getCreatedBy()); + + return "Save PHC Review Form successfully"; + } + + private String submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { + AHDForm ahdForm = new AHDForm(); + ahdForm.setUserId(Long.valueOf(userID)); + ahdForm.setMobilizedForAHD(dto.getMobilizedForAHD()); + ahdForm.setAhdPlace(dto.getAhdPlace()); + ahdForm.setAhdDate(dto.getAhdDate()); + ahdForm.setImage1(dto.getImage1()); + ahdForm.setImage2(dto.getImage2()); + ahdForm.setFormType("AHD"); + ahdFormRepo.save(ahdForm); + if(Objects.equals(dto.getMobilizedForAHD(),"Yes")){ + checkAndAddIncentives(ahdForm.getAhdDate(), Math.toIntExact(ahdForm.getUserId()), ahdForm.getFormType(),ahdForm.getCreatedBy()); + + } + + return "Save AHD Form successfully"; + } + + private String submitDewormingForm(DewormingFormDTO dto, Integer userID) { + DewormingForm dewormingForm = new DewormingForm(); + dewormingForm.setUserId(Long.valueOf(userID)); + dewormingForm.setDewormingDone(dto.getDewormingDone()); + dewormingForm.setDewormingDate(dto.getDewormingDate()); + dewormingForm.setDewormingLocation(dto.getDewormingLocation()); + dewormingForm.setAgeGroup(dto.getAgeGroup()); + dewormingForm.setImage1(dto.getImage1()); + dewormingForm.setImage2(dto.getImage2()); + dewormingForm.setFormType("Deworming"); + dewormingFormRepo.save(dewormingForm); + if(Objects.equals(dewormingForm.getDewormingDone(), "Yes")){ + checkAndAddIncentives(dewormingForm.getDewormingDate(), Math.toIntExact(dewormingForm.getUserId()), dewormingForm.getFormType(),dewormingForm.getCreatedBy()); } - return "Fail" ; + return "Save Deworming Form successfully"; } - private String saveVhndFormData(VHNDFormDTO vhndFormDTO) { + + private String saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { VHNDForm vhndForm = new VHNDForm(); + vhndForm.setUserId(userID); vhndForm.setVhndDate(vhndFormDTO.getVhndDate()); vhndForm.setImage2(vhndFormDTO.getImage2()); vhndForm.setImage1(vhndFormDTO.getImage1()); @@ -83,35 +177,71 @@ private String saveVhndFormData(VHNDFormDTO vhndFormDTO) { vhndForm.setNoOfBeneficiariesAttended(vhndFormDTO.getNoOfBeneficiariesAttended()); vhndForm.setFormType("VHND"); vhndRepo.save(vhndForm); - checkAndAddIncentives(vhndForm); + checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), vhndForm.getFormType(),vhndForm.getCreatedBy()); return "Save Vhnd Form successfully"; } @Override - public List getAll(Integer userId) { - return repository.findAll().stream().filter(villageFormEntry -> villageFormEntry.getUserId().equals(userId)).collect(Collectors.toList()); + public Object getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler) { + if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "VHND")) { + return vhndRepo.findAll().stream() + .filter(vhndForm -> Objects.equals(vhndForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) + .collect(Collectors.toList()); + + } else if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "VHNC")) { + return vhncFormRepo.findAll().stream() + .filter(vhncForm -> Objects.equals(vhncForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) + .collect(Collectors.toList()); + + } else if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "PHC")) { + return phcReviewFormRepo.findAll().stream() + .filter(phcReviewForm -> Objects.equals(phcReviewForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) + .collect(Collectors.toList()); + + } else if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "Deworming")) { + return dewormingFormRepo.findAll().stream() + .filter(dewormingForm -> Objects.equals(dewormingForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) + .collect(Collectors.toList()); + + } else if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "AHD")) { + return ahdFormRepo.findAll().stream() + .filter(ahdForm -> Objects.equals(ahdForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) + .collect(Collectors.toList()); + } + + return Collections.emptyList(); // In case no condition matches + } - private void checkAndAddIncentives(VHNDForm villageFormEntry) { + private void checkAndAddIncentives(String date,Integer userID,String formType,String createdBY) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Parse to LocalDate + LocalDate localDate = LocalDate.parse(date, formatter); + + // Convert to Timestamp at start of day (00:00:00) + Timestamp timestamp = Timestamp.valueOf(localDate.atStartOfDay()); + logger.info("timestamp"+timestamp); + IncentiveActivity villageFormEntryActivity; - villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(villageFormEntry.getFormType(), "VILLAGELEVEL"); + villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(formType, "VILLAGELEVEL"); if (villageFormEntryActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), timestamp, null); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivity.getId()); - record.setCreatedDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); - record.setCreatedBy(villageFormEntry.getCreatedBy()); - record.setStartDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); - record.setEndDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); - record.setUpdatedDate(Timestamp.valueOf(villageFormEntry.getVhndDate().toString())); - record.setUpdatedBy(villageFormEntry.getCreatedBy()); - record.setAshaId(villageFormEntry.getUserId()); + record.setCreatedDate(timestamp); + record.setCreatedBy(createdBY); + record.setStartDate(timestamp); + record.setEndDate(timestamp); + record.setUpdatedDate(timestamp); + record.setUpdatedBy(createdBY); + record.setAshaId(userID); record.setName(villageFormEntryActivity.getName()); record.setAmount(Long.valueOf(villageFormEntryActivity.getRate())); recordRepo.save(record); @@ -119,4 +249,7 @@ record = new IncentiveActivityRecord(); } } } -} + + + +} \ No newline at end of file From 13b27ce816be78aa16b39140938c267e1f5c7425 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 13:48:08 +0530 Subject: [PATCH 099/792] Village leve form and asha incentive logic --- .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 1be92c65..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } -// validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From ef3781436c5dea9af119061b51d0f95215dd2fa5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 13:50:12 +0530 Subject: [PATCH 100/792] Village leve form and asha incentive logic --- .../iemr/flw/dto/iemr/VilageLevelFormDto.java | 13 ------------ .../flw/dto/iemr/VilageLevelFormListDto.java | 21 ------------------- .../flw/repo/iemr/VillageFormRepository.java | 7 ------- .../com/iemr/flw/service/VhndFormService.java | 2 -- .../flw/service/impl/VhndFormServiceImpl.java | 2 -- 5 files changed, 45 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java delete mode 100644 src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java delete mode 100644 src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java diff --git a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java deleted file mode 100644 index 6f79415f..00000000 --- a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormDto.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.iemr.flw.dto.iemr; - -import lombok.Data; - -import java.sql.Date; -import java.util.List; - -@Data -public class VilageLevelFormDto { - private Integer userId; - private List vilageLevelFormList; -} - diff --git a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java b/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java deleted file mode 100644 index 85fd963c..00000000 --- a/src/main/java/com/iemr/flw/dto/iemr/VilageLevelFormListDto.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.iemr.flw.dto.iemr; - -import lombok.Data; - -import java.sql.Date; - -@Data -public class VilageLevelFormListDto { - private String formType; - private Integer userId; - private Date date; - private String place; - private int participantCount; - private String imageUrls; // Comma separated URLs or Base64 if needed - private String createdBy; - private boolean dewormingRound; - private Integer age; - - -} - diff --git a/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java b/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java deleted file mode 100644 index c4638a3b..00000000 --- a/src/main/java/com/iemr/flw/repo/iemr/VillageFormRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.iemr.flw.repo.iemr; - -import com.iemr.flw.domain.iemr.VillageFormEntry; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface VillageFormRepository extends JpaRepository { -} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java index 03b03051..c4c3ef64 100644 --- a/src/main/java/com/iemr/flw/service/VhndFormService.java +++ b/src/main/java/com/iemr/flw/service/VhndFormService.java @@ -2,7 +2,6 @@ import com.iemr.flw.domain.iemr.VillageFormEntry; import com.iemr.flw.dto.iemr.*; -import com.iemr.flw.repo.iemr.VillageFormRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; @@ -14,7 +13,6 @@ @Service public interface VhndFormService { - public String submitForm(VhndDto dto); public String submitVhncForm(VhncDto dto); public String submitPhcForm(PhcReviewMeetingDTO dto); diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java index 06b4f9f8..5d77c3d9 100644 --- a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java @@ -24,8 +24,6 @@ public class VhndFormServiceImpl implements VhndFormService { private final Logger logger = LoggerFactory.getLogger(CoupleController.class); - @Autowired - private VillageFormRepository repository; @Autowired private IncentiveRecordRepo recordRepo; @Autowired From 20195bdd80df8bb66fc1ad348b8a0730cdea0bb5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 13:51:59 +0530 Subject: [PATCH 101/792] Village leve form and asha incentive logic --- .../controller/VilageLevelFormController.java | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index 7c575578..2f424660 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -13,13 +13,13 @@ import java.util.Map; @RestController -@RequestMapping(value = "/forms/villageLevel") +@RequestMapping(value = "/forms/villageLevel", headers = "Authorization") public class VilageLevelFormController { @Autowired private VhndFormService vhndFormService; - @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST) + @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -27,7 +27,7 @@ public ResponseEntity> submitVhndForm(@RequestBody VhndDto d response.put("msg", vhndFormService.submitForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "vhnc/saveAll",method = RequestMethod.POST) + @RequestMapping(value = "vhnc/saveAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhncForm(@RequestBody VhncDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -36,7 +36,7 @@ public ResponseEntity> submitVhncForm(@RequestBody VhncDto d return ResponseEntity.ok(response); } - @RequestMapping(value = "phc/saveAll",method = RequestMethod.POST) + @RequestMapping(value = "phc/saveAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitPhcForm(@RequestBody PhcReviewMeetingDTO dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -45,7 +45,7 @@ public ResponseEntity> submitPhcForm(@RequestBody PhcReviewM return ResponseEntity.ok(response); } - @RequestMapping(value = "ahd/saveAll",method = RequestMethod.POST) + @RequestMapping(value = "ahd/saveAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -54,7 +54,7 @@ public ResponseEntity> submitAhdForm(@RequestBody AhdMeeting return ResponseEntity.ok(response); } - @RequestMapping(value = "deworming/saveAll",method = RequestMethod.POST) + @RequestMapping(value = "deworming/saveAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitDewormingForm(@RequestBody DewormingDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); @@ -64,17 +64,25 @@ public ResponseEntity> submitDewormingForm(@RequestBody Dewo } - @RequestMapping(value = "getAll",method = RequestMethod.POST) + @RequestMapping(value = "getAll",method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> getVilageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { - Map data = new HashMap<>(); - data.put("userId", getVillageLevelRequestHandler.getUserId()); - data.put("entries", vhndFormService.getAll(getVillageLevelRequestHandler)); - Map response = new LinkedHashMap<>(); - response.put("data", data); - response.put("statusCode", 200); - response.put("errorMessage", "Success"); - response.put("status", "Success"); + + try { + Map data = new HashMap<>(); + data.put("userId", getVillageLevelRequestHandler.getUserId()); + data.put("entries", vhndFormService.getAll(getVillageLevelRequestHandler)); + + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); + }catch (Exception e){ + response.put("statusCode", 500); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); } From 881174c8bcf8a0563a2fd042e70578ace9ec0466 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 13:52:13 +0530 Subject: [PATCH 102/792] Village leve form and asha incentive logic --- .../java/com/iemr/flw/controller/VilageLevelFormController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index 2f424660..ce186e84 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -65,7 +65,7 @@ public ResponseEntity> submitDewormingForm(@RequestBody Dewo @RequestMapping(value = "getAll",method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> getVilageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { + public ResponseEntity> getVillageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { Map response = new LinkedHashMap<>(); try { From 03e351abde26f8a6e426e049e483bad22a22642e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 14:08:43 +0530 Subject: [PATCH 103/792] IRS round --- .../flw/controller/IRSRoundController.java | 27 ++++++++++++++++--- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java index e5a5bc23..efe63430 100644 --- a/src/main/java/com/iemr/flw/controller/IRSRoundController.java +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -6,11 +6,15 @@ import com.iemr.flw.service.IRSRoundService; import com.iemr.flw.utils.response.OutputResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.lang.reflect.Method; import java.sql.Timestamp; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; @RestController @RequestMapping(value = "/irsRound", headers = "Authorization") @@ -19,7 +23,7 @@ public class IRSRoundController { @Autowired private IRSRoundService irsRoundService; - @RequestMapping(name = "/add", method = RequestMethod.POST) + @RequestMapping(name = "/add", method = RequestMethod.POST, headers = "Authorization") public String addRound(@RequestBody IRSRoundListDTO dto) { OutputResponse response = new OutputResponse(); try { @@ -42,9 +46,24 @@ public String addRound(@RequestBody IRSRoundListDTO dto) { } - @RequestMapping(name = "/list/{householdId}", method = RequestMethod.GET) - public List getRounds(@PathVariable Long householdId) { - return irsRoundService.getRounds(householdId); + @RequestMapping(name = "/list/{householdId}", method = RequestMethod.GET, headers = "Authorization") + public ResponseEntity> getRounds(@PathVariable Long householdId) { + + Map response = new LinkedHashMap<>(); + + try { + Map data = new HashMap<>(); + data.put("entries", irsRoundService.getRounds(householdId)); + response.put("data", data); + response.put("statusCode", 200); + response.put("message", "Success"); + } catch (Exception e) { + response.put("statusCode", 500); + response.put("errorMessage", e.getMessage()); + + } + + return ResponseEntity.ok(response); } From e1a02b99633418ceaca1d317e0262ec395f7ffbe Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 14:09:34 +0530 Subject: [PATCH 104/792] Village level --- .../com/iemr/flw/controller/VilageLevelFormController.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index ce186e84..09f0f22b 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -75,8 +75,7 @@ public ResponseEntity> getVillageLevelFormData(@RequestBody response.put("data", data); response.put("statusCode", 200); - response.put("errorMessage", "Success"); - response.put("status", "Success"); + response.put("message", "Success"); }catch (Exception e){ response.put("statusCode", 500); response.put("errorMessage", e.getMessage()); From 48782c9c3695081d21f6ad527f09e94ae83ebd41 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 30 Apr 2025 14:10:01 +0530 Subject: [PATCH 105/792] Village level --- .../java/com/iemr/flw/controller/VilageLevelFormController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java index 09f0f22b..73bcb671 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java @@ -72,7 +72,6 @@ public ResponseEntity> getVillageLevelFormData(@RequestBody Map data = new HashMap<>(); data.put("userId", getVillageLevelRequestHandler.getUserId()); data.put("entries", vhndFormService.getAll(getVillageLevelRequestHandler)); - response.put("data", data); response.put("statusCode", 200); response.put("message", "Success"); From b3f0e8f273bb2048fbebdad6bcb14754a016b8c7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 May 2025 12:58:18 +0530 Subject: [PATCH 106/792] Fix coderabbit comments --- .../AdolescentHealthController.java | 27 ++++++---- .../flw/domain/iemr/AdolescentHealth.java | 12 ++--- .../flw/dto/iemr/AdolescentHealthDTO.java | 5 ++ .../flw/repo/iemr/AdolescentHealthRepo.java | 2 +- .../flw/service/AdolescentHealthService.java | 1 - .../impl/AdolescentHealthServiceImpl.java | 52 +++++++++++-------- .../utils/http/HTTPRequestInterceptor.java | 2 +- 7 files changed, 60 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java index 1844dfe2..65bf04e3 100644 --- a/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java +++ b/src/main/java/com/iemr/flw/controller/AdolescentHealthController.java @@ -1,5 +1,6 @@ package com.iemr.flw.controller; +import com.iemr.flw.domain.iemr.AdolescentHealth; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.AdolescentHealthDTO; import com.iemr.flw.service.AdolescentHealthService; @@ -25,7 +26,7 @@ public class AdolescentHealthController { @Autowired private AdolescentHealthService adolescentHealthService; - @RequestMapping(value = "/savAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> saveAdolescentHealth(@RequestBody AdolescentHealthDTO adolescentHealthDTO) { Map response = new HashMap<>(); @@ -38,13 +39,14 @@ public ResponseEntity> saveAdolescentHealth(@RequestBody Ado } - } else - response.put("statusCode",500); - response.put("error","Invalid/NULL request obj"); + } else { + response.put("statusCode", 500); + response.put("error", "Invalid/NULL request obj"); + } } catch (Exception e) { - logger.error("Error in get data : " + e); + logger.error("Error in saving adolescent health data : " + e); response.put("statusCode",500); - response.put("error","Error in get data : " + e); + response.put("error","Error in saving adolescent health data : " + e); } return ResponseEntity.ok(response); @@ -54,12 +56,15 @@ public ResponseEntity> saveAdolescentHealth(@RequestBody Ado public ResponseEntity> getAllAdolescentHealth(@RequestBody GetBenRequestHandler getBenRequestHandler) { Map response = new HashMap<>(); try { - if (adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler).size() != 0) { + List resultList = adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler); + + if (resultList != null && !resultList.isEmpty()) { response.put("statusCode",200); - response.put("data",adolescentHealthService.getAllAdolescentHealth(getBenRequestHandler)); - } else - response.put("statusCode",500); - response.put("error","Invalid/NULL request obj"); + response.put("data", resultList); + } else { + response.put("statusCode", 500); + response.put("error", "Invalid/NULL request obj"); + } } catch (Exception e) { logger.error("Error in get data : " + e); response.put("statusCode",500); diff --git a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java index 8fd4027b..14008706 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java +++ b/src/main/java/com/iemr/flw/domain/iemr/AdolescentHealth.java @@ -21,12 +21,12 @@ public class AdolescentHealth { private BigInteger benId; @Column(name = "userID") - private Integer userID; + private Integer userId; @Column(name = "visit_date") private Timestamp visitDate; - @Column(name = "health_status") + @Column(name = "health_status",length = 50) private String healthStatus; @Column(name = "ifa_tablet_distribution") @@ -44,22 +44,22 @@ public class AdolescentHealth { @Column(name = "no_of_packets_distributed") private Integer noOfPacketsDistributed; - @Column(name = "place") + @Column(name = "place",length = 100) private String place; - @Column(name = "referred_to_health_facility") + @Column(name = "referred_to_health_facility",length = 100) private String referredToHealthFacility; @Column(name = "counseling_provided") private Boolean counselingProvided; - @Column(name = "counseling_type") + @Column(name = "counseling_type",length = 50) private String counselingType; @Column(name = "follow_up_date") private Date followUpDate; - @Column(name = "referral_status") + @Column(name = "referral_status",length = 50) private String referralStatus; @Column(name = "created_date") diff --git a/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java index e7df0e41..b59bb8ea 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/AdolescentHealthDTO.java @@ -1,11 +1,16 @@ package com.iemr.flw.dto.iemr; import com.iemr.flw.domain.iemr.AdolescentHealth; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.Data; import java.util.List; @Data public class AdolescentHealthDTO { + @NotNull(message = "User ID cannot be null") Integer userId; + @NotNull(message = "Adolescent health records cannot be null") + @Size(min = 1, message = "At least one adolescent health record is required") List adolescentHealths; } diff --git a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java index 7ec1fd5c..17be21d8 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AdolescentHealthRepo.java @@ -11,5 +11,5 @@ @Repository public interface AdolescentHealthRepo extends JpaRepository { Optional findByBenId(BigInteger benId); - List findByUserID(Integer userId); + List findByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java index 647bac51..522b40d6 100644 --- a/src/main/java/com/iemr/flw/service/AdolescentHealthService.java +++ b/src/main/java/com/iemr/flw/service/AdolescentHealthService.java @@ -6,7 +6,6 @@ import org.springframework.stereotype.Service; import java.util.List; -@Service public interface AdolescentHealthService { String saveAll(AdolescentHealthDTO adolescentHealthDTO); List getAllAdolescentHealth(GetBenRequestHandler getBenRequestHandler); diff --git a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java index 65ff23e1..43986a8c 100644 --- a/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AdolescentHealthServiceImpl.java @@ -10,15 +10,11 @@ import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.AdolescentHealthService; -import lombok.Data; +import jakarta.transaction.Transactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.sql.Date; -import java.sql.Timestamp; -import java.time.LocalDate; import java.util.List; -import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; @@ -35,16 +31,24 @@ public class AdolescentHealthServiceImpl implements AdolescentHealthService { @Autowired private IncentivesRepo incentivesRepo; + private static final String INCENTIVE_GROUP = "ADOLESCENT_HEALTH"; + @Override + @Transactional public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { + if (adolescentHealthDTO == null || adolescentHealthDTO.getAdolescentHealths() == null + || adolescentHealthDTO.getAdolescentHealths().isEmpty()) { + return "No records to process"; + } + for (AdolescentHealth adolescentHealth : adolescentHealthDTO.getAdolescentHealths()) { // Check if a record with the same benId already exists in the database Optional existingRecord = adolescentHealthRepo.findByBenId(adolescentHealth.getBenId()); if (existingRecord.isPresent()) { // If record exists, update the existing one - updateAdolescentHealth(existingRecord,adolescentHealth); + updateAdolescentHealth(existingRecord, adolescentHealth); } else { // If the record does not exist, create a new one adolescentHealthRepo.save(adolescentHealth); @@ -56,15 +60,13 @@ public String saveAll(AdolescentHealthDTO adolescentHealthDTO) { } - - public List getAllAdolescentHealth(GetBenRequestHandler getBenRequestHandler) { // Fetch all records from the database - List adolescentHealths = adolescentHealthRepo.findByUserID(getBenRequestHandler.getUserId()); + List adolescentHealths = adolescentHealthRepo.findByUserId(getBenRequestHandler.getUserId()); // Convert the list of entity objects to DTO objects return adolescentHealths.stream() - .map(this::convertToDTO) + .map(this::copyEntity) .collect(Collectors.toList()); } @@ -72,7 +74,7 @@ private void updateAdolescentHealth(Optional existingRecord, A AdolescentHealth existingAdolescentHealth = existingRecord.get(); // Update fields of the existing record with values from the DTO - existingAdolescentHealth.setUserID(adolescentHealth.getUserID()); + existingAdolescentHealth.setUserId(adolescentHealth.getUserId()); existingAdolescentHealth.setVisitDate(adolescentHealth.getVisitDate()); existingAdolescentHealth.setHealthStatus(adolescentHealth.getHealthStatus()); existingAdolescentHealth.setIfaTabletDistribution(adolescentHealth.getIfaTabletDistribution()); @@ -93,11 +95,11 @@ private void updateAdolescentHealth(Optional existingRecord, A adolescentHealthRepo.save(existingAdolescentHealth); } - private AdolescentHealth convertToDTO(AdolescentHealth adolescentHealth) { + private AdolescentHealth copyEntity(AdolescentHealth adolescentHealth) { AdolescentHealth dto = new AdolescentHealth(); dto.setId(adolescentHealth.getId()); dto.setBenId(adolescentHealth.getBenId()); - dto.setUserID(adolescentHealth.getUserID()); + dto.setUserId(adolescentHealth.getUserId()); dto.setVisitDate(adolescentHealth.getVisitDate()); dto.setHealthStatus(adolescentHealth.getHealthStatus()); dto.setIfaTabletDistribution(adolescentHealth.getIfaTabletDistribution()); @@ -115,12 +117,16 @@ private AdolescentHealth convertToDTO(AdolescentHealth adolescentHealth) { } private void checkAndAddIncentives(AdolescentHealth adolescentHealth) { - IncentiveActivity sellingSanitaryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SELLING_SANITARY", "ADOLESCENT_HEALTH"); - IncentiveActivity mobilizingADHActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILIZING_ADOLESCENTS", "ADOLESCENT_HEALTH"); + if (adolescentHealth == null || adolescentHealth.getBenId() == null) { + return; + } + + IncentiveActivity sellingSanitaryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SELLING_SANITARY", INCENTIVE_GROUP); + IncentiveActivity mobilizingADHActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILIZING_ADOLESCENTS", INCENTIVE_GROUP); if (sellingSanitaryActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(sellingSanitaryActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); + .findRecordByActivityIdCreatedDateBenId(sellingSanitaryActivity.getId(), adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(sellingSanitaryActivity.getId()); @@ -131,9 +137,13 @@ record = new IncentiveActivityRecord(); record.setUpdatedDate(adolescentHealth.getCreatedDate()); record.setUpdatedBy(adolescentHealth.getCreatedBy()); record.setBenId(adolescentHealth.getBenId().longValue()); - record.setAshaId(adolescentHealth.getUserID()); + record.setAshaId(adolescentHealth.getUserId()); record.setName(sellingSanitaryActivity.getName()); - record.setAmount(Long.valueOf(sellingSanitaryActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); + // Validate packets number before calculation + Integer packetsDistributed = adolescentHealth.getNoOfPacketsDistributed(); + long rate = sellingSanitaryActivity.getRate() != null ? sellingSanitaryActivity.getRate() : 0; + long amount = rate * (packetsDistributed != null ? packetsDistributed : 0); + record.setAmount(amount); recordRepo.save(record); } } @@ -141,7 +151,7 @@ record = new IncentiveActivityRecord(); if (mobilizingADHActivity != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(mobilizingADHActivity.getId(),adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); + .findRecordByActivityIdCreatedDateBenId(mobilizingADHActivity.getId(), adolescentHealth.getCreatedDate(), adolescentHealth.getBenId().longValue()); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(mobilizingADHActivity.getId()); @@ -152,9 +162,9 @@ record = new IncentiveActivityRecord(); record.setUpdatedDate(adolescentHealth.getCreatedDate()); record.setUpdatedBy(adolescentHealth.getCreatedBy()); record.setBenId(adolescentHealth.getBenId().longValue()); - record.setAshaId(adolescentHealth.getUserID()); + record.setAshaId(adolescentHealth.getUserId()); record.setName(mobilizingADHActivity.getName()); - record.setAmount(Long.valueOf(mobilizingADHActivity.getRate())*adolescentHealth.getNoOfPacketsDistributed()); + record.setAmount(Long.valueOf(mobilizingADHActivity.getRate()) * adolescentHealth.getNoOfPacketsDistributed()); recordRepo.save(record); } } diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 23a79426..571348ed 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - validator.checkKeyExists(authorization, remoteAddress); + //validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From b9444e8deab44a69287d81446c18fcae38c07a44 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 May 2025 12:58:37 +0530 Subject: [PATCH 107/792] Fix coderabbit comments --- .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 571348ed..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - //validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From afa522b2a4c40b73500870263092a555804cfbde Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 May 2025 12:18:27 +0530 Subject: [PATCH 108/792] Fix uncomment validator checkKeyExists validation --- .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 571348ed..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - //validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From 016bad46bfc75cc1929eb0b282a00f757ba031d0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 20 May 2025 11:44:48 +0530 Subject: [PATCH 109/792] fix issue in code --- ...r.java => VillageLevelFormController.java} | 36 +++++++------- .../java/com/iemr/flw/repo/iemr/VhndRepo.java | 4 ++ .../com/iemr/flw/service/VhndFormService.java | 22 --------- .../flw/service/VillageLevelFormService.java | 22 +++++++++ ....java => VillageLevelFormServiceImpl.java} | 49 ++++++++----------- 5 files changed, 63 insertions(+), 70 deletions(-) rename src/main/java/com/iemr/flw/controller/{VilageLevelFormController.java => VillageLevelFormController.java} (68%) delete mode 100644 src/main/java/com/iemr/flw/service/VhndFormService.java create mode 100644 src/main/java/com/iemr/flw/service/VillageLevelFormService.java rename src/main/java/com/iemr/flw/service/impl/{VhndFormServiceImpl.java => VillageLevelFormServiceImpl.java} (89%) diff --git a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java similarity index 68% rename from src/main/java/com/iemr/flw/controller/VilageLevelFormController.java rename to src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index 73bcb671..ab6dcdd8 100644 --- a/src/main/java/com/iemr/flw/controller/VilageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -1,81 +1,80 @@ package com.iemr.flw.controller; -import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; -import com.iemr.flw.service.VhndFormService; +import com.iemr.flw.service.VillageLevelFormService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; @RestController @RequestMapping(value = "/forms/villageLevel", headers = "Authorization") -public class VilageLevelFormController { +public class VillageLevelFormController { @Autowired - private VhndFormService vhndFormService; + private VillageLevelFormService villageLevelFormService; - @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "vhnd/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("msg", vhndFormService.submitForm(dto)); + response.put("message", villageLevelFormService.submitForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "vhnc/saveAll",method = RequestMethod.POST, headers = "Authorization") + + @RequestMapping(value = "vhnc/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhncForm(@RequestBody VhncDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("msg", vhndFormService.submitVhncForm(dto)); + response.put("message", villageLevelFormService.submitVhncForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "phc/saveAll",method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "phc/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitPhcForm(@RequestBody PhcReviewMeetingDTO dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("msg", vhndFormService.submitPhcForm(dto)); + response.put("message", villageLevelFormService.submitPhcForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "ahd/saveAll",method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "ahd/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("msg", vhndFormService.submitAdhForm(dto)); + response.put("message", villageLevelFormService.submitAhdForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "deworming/saveAll",method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "deworming/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitDewormingForm(@RequestBody DewormingDto dto) { Map response = new HashMap<>(); response.put("status", "Success"); response.put("statusCode", 200); - response.put("msg", vhndFormService.submitDewormingForm(dto)); + response.put("message", villageLevelFormService.submitDewormingForm(dto)); return ResponseEntity.ok(response); } - @RequestMapping(value = "getAll",method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "getAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> getVillageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { Map response = new LinkedHashMap<>(); try { Map data = new HashMap<>(); data.put("userId", getVillageLevelRequestHandler.getUserId()); - data.put("entries", vhndFormService.getAll(getVillageLevelRequestHandler)); + data.put("entries", villageLevelFormService.getAll(getVillageLevelRequestHandler)); response.put("data", data); response.put("statusCode", 200); response.put("message", "Success"); - }catch (Exception e){ + } catch (Exception e) { response.put("statusCode", 500); response.put("errorMessage", e.getMessage()); @@ -85,5 +84,4 @@ public ResponseEntity> getVillageLevelFormData(@RequestBody } - } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java index 2e41ce3f..3d40fd94 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java @@ -4,7 +4,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface VhndRepo extends JpaRepository { + + List findByUserId(long longValue); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/VhndFormService.java b/src/main/java/com/iemr/flw/service/VhndFormService.java deleted file mode 100644 index c4c3ef64..00000000 --- a/src/main/java/com/iemr/flw/service/VhndFormService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.iemr.flw.service; - -import com.iemr.flw.domain.iemr.VillageFormEntry; -import com.iemr.flw.dto.iemr.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Service; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.util.List; - -@Service -public interface VhndFormService { - - public String submitForm(VhndDto dto); - public String submitVhncForm(VhncDto dto); - public String submitPhcForm(PhcReviewMeetingDTO dto); - public String submitAdhForm(AhdMeetingDto dto); - public String submitDewormingForm(DewormingDto dto); - public Object getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler); -} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/VillageLevelFormService.java b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java new file mode 100644 index 00000000..6d926c6b --- /dev/null +++ b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java @@ -0,0 +1,22 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.*; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface VillageLevelFormService { + + String submitForm(VhndDto dto); + + String submitVhncForm(VhncDto dto); + + String submitPhcForm(PhcReviewMeetingDTO dto); + + String submitAhdForm(AhdMeetingDto dto); + + String submitDewormingForm(DewormingDto dto); + + List getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler); +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java similarity index 89% rename from src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java rename to src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 5d77c3d9..8d28efe5 100644 --- a/src/main/java/com/iemr/flw/service/impl/VhndFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -4,26 +4,24 @@ import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.repo.iemr.*; -import com.iemr.flw.service.VhndFormService; +import com.iemr.flw.service.VillageLevelFormService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.sql.Date; import java.sql.Timestamp; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Collections; +import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @Service -public class VhndFormServiceImpl implements VhndFormService { +public class VillageLevelFormServiceImpl implements VillageLevelFormService { private final Logger logger = LoggerFactory.getLogger(CoupleController.class); - @Autowired private IncentiveRecordRepo recordRepo; @Autowired @@ -38,9 +36,6 @@ public class VhndFormServiceImpl implements VhndFormService { @Autowired private DewormingFormRepo dewormingFormRepo; - @Autowired - private VhncFormRepo vhndFormRepo; - @Autowired private VhndRepo vhndRepo; @@ -51,14 +46,13 @@ public class VhndFormServiceImpl implements VhndFormService { private AHDFormRepo ahdFormRepo; - @Override public String submitForm(VhndDto dto) { for (VHNDFormDTO vhndFormDTO : dto.getEntries()) { saveVhndFormData(vhndFormDTO, dto.getUserId()); } - return "Fail"; + return "Success"; } @Override @@ -66,26 +60,24 @@ public String submitVhncForm(VhncDto dto) { for (VhncFormDTO vhncFormDTO : dto.getEntries()) { saveVhncFormData(vhncFormDTO, dto.getUserId()); } - return "Fail"; + return "Success"; } - - @Override public String submitPhcForm(PhcReviewMeetingDTO dto) { for (PhcReviewMeetingFormDTO phcReviewMeetingDTO : dto.getEntries()) { submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); } - return "Fail"; + return "Success"; } @Override - public String submitAdhForm(AhdMeetingDto dto) { + public String submitAhdForm(AhdMeetingDto dto) { for (AhDMeetingFormDTO ahDMeetingFormDTO : dto.getEntries()) { submitAhdForm(ahDMeetingFormDTO, dto.getUserId()); } - return "Fail"; + return "Success"; } @Override @@ -93,7 +85,7 @@ public String submitDewormingForm(DewormingDto dto) { for (DewormingFormDTO dewormingFormDTO : dto.getEntries()) { submitDewormingForm(dewormingFormDTO, dto.getUserId()); } - return "Fail"; + return "Success"; } private String saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { @@ -107,9 +99,9 @@ private String saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { vhncForm.setFormType("VHNC"); vhncFormRepo.save(vhncForm); - checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), vhncForm.getFormType(),vhncForm.getCreatedBy()); + checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), vhncForm.getFormType(), vhncForm.getCreatedBy()); - return "Save Vhnd Form successfully"; + return "Save VHNC Form successfully"; } @@ -123,7 +115,7 @@ private String submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { phcReviewForm.setImage2(dto.getImage2()); phcReviewForm.setFormType("PHC"); phcReviewFormRepo.save(phcReviewForm); - checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), phcReviewForm.getFormType(),phcReviewForm.getCreatedBy()); + checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), phcReviewForm.getFormType(), phcReviewForm.getCreatedBy()); return "Save PHC Review Form successfully"; } @@ -138,8 +130,8 @@ private String submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { ahdForm.setImage2(dto.getImage2()); ahdForm.setFormType("AHD"); ahdFormRepo.save(ahdForm); - if(Objects.equals(dto.getMobilizedForAHD(),"Yes")){ - checkAndAddIncentives(ahdForm.getAhdDate(), Math.toIntExact(ahdForm.getUserId()), ahdForm.getFormType(),ahdForm.getCreatedBy()); + if (Objects.equals(dto.getMobilizedForAHD(), "Yes")) { + checkAndAddIncentives(ahdForm.getAhdDate(), Math.toIntExact(ahdForm.getUserId()), ahdForm.getFormType(), ahdForm.getCreatedBy()); } @@ -157,8 +149,8 @@ private String submitDewormingForm(DewormingFormDTO dto, Integer userID) { dewormingForm.setImage2(dto.getImage2()); dewormingForm.setFormType("Deworming"); dewormingFormRepo.save(dewormingForm); - if(Objects.equals(dewormingForm.getDewormingDone(), "Yes")){ - checkAndAddIncentives(dewormingForm.getDewormingDate(), Math.toIntExact(dewormingForm.getUserId()), dewormingForm.getFormType(),dewormingForm.getCreatedBy()); + if (Objects.equals(dewormingForm.getDewormingDone(), "Yes")) { + checkAndAddIncentives(dewormingForm.getDewormingDate(), Math.toIntExact(dewormingForm.getUserId()), dewormingForm.getFormType(), dewormingForm.getCreatedBy()); } return "Save Deworming Form successfully"; @@ -175,14 +167,14 @@ private String saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { vhndForm.setNoOfBeneficiariesAttended(vhndFormDTO.getNoOfBeneficiariesAttended()); vhndForm.setFormType("VHND"); vhndRepo.save(vhndForm); - checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), vhndForm.getFormType(),vhndForm.getCreatedBy()); + checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), vhndForm.getFormType(), vhndForm.getCreatedBy()); return "Save Vhnd Form successfully"; } @Override - public Object getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler) { + public List getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler) { if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "VHND")) { return vhndRepo.findAll().stream() .filter(vhndForm -> Objects.equals(vhndForm.getUserId().toString(), getVillageLevelRequestHandler.getUserId().toString())) @@ -214,7 +206,7 @@ public Object getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler } - private void checkAndAddIncentives(String date,Integer userID,String formType,String createdBY) { + private void checkAndAddIncentives(String date, Integer userID, String formType, String createdBY) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Parse to LocalDate @@ -222,7 +214,7 @@ private void checkAndAddIncentives(String date,Integer userID,String formType,St // Convert to Timestamp at start of day (00:00:00) Timestamp timestamp = Timestamp.valueOf(localDate.atStartOfDay()); - logger.info("timestamp"+timestamp); + logger.info("timestamp" + timestamp); IncentiveActivity villageFormEntryActivity; villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(formType, "VILLAGELEVEL"); @@ -249,5 +241,4 @@ record = new IncentiveActivityRecord(); } - } \ No newline at end of file From 1c38cebb433714f64a7d7b570401ae08b5ab4872 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 20 May 2025 11:48:16 +0530 Subject: [PATCH 110/792] fix issue in code --- src/main/java/com/iemr/flw/domain/iemr/VhncForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java index 8d646095..5b53b27e 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java @@ -9,7 +9,7 @@ import static jakarta.persistence.GenerationType.*; @Entity -@Table(name = "vhnc_form",schema = "iemr") +@Table(name = "vhnc_form",schema = "db_iemr") @Data public class VhncForm { @Id From 495df0ae143e36944ad1b3dfafa5f1e78fa103ac Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 20 May 2025 12:07:38 +0530 Subject: [PATCH 111/792] fix issue in code --- .../flw/domain/iemr/VillageFormEntry.java | 59 ------------------- .../iemr/GetVillageLevelRequestHandler.java | 1 - 2 files changed, 60 deletions(-) delete mode 100644 src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java b/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java deleted file mode 100644 index 09336296..00000000 --- a/src/main/java/com/iemr/flw/domain/iemr/VillageFormEntry.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.iemr.flw.domain.iemr; - -import jakarta.persistence.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.sql.Date; -import java.time.LocalDate; -import java.time.LocalDateTime; - -@Entity -@Table(name = "village_form_entry",schema = "db_iemr") -@Data -@AllArgsConstructor -@NoArgsConstructor -public class VillageFormEntry { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "ben_id") - private Long benId; - @Column(name = "userId") - private Integer userId; - - @Column(name = "form_type") - private String formType; - @Column(name = "form_date") - private Date date; - @Column(name = "place") - private String place; - - @Column(name = "participant_count") - private int participantCount; - - @Column(name = "image_urls") - private String imageUrls; - - - @Column(name = "submitted_at") - private LocalDateTime submittedAt; - - @Column(name = "created_date") - private Date createdDate; - - @Column(name = "created_by") - private String createdBy; - - @Column(name = "age_group") - private Integer age; - - @Column(name = "location") - private String location; - - @Column(name = "dewormingRound") - private Boolean dewormingRound; -} diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java index 446d1059..7bdadc41 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java +++ b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java @@ -12,7 +12,6 @@ public class GetVillageLevelRequestHandler { private Integer pageNo; private Integer userId; private String userName; - private Integer ashaId; From b466d636bbc1316302d13a3dd24d7b37f137796d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 21 May 2025 14:36:48 +0530 Subject: [PATCH 112/792] fix issue in code --- .../VillageLevelFormController.java | 103 ++++++++--- .../iemr/GetVillageLevelRequestHandler.java | 2 + .../impl/VillageLevelFormServiceImpl.java | 6 +- .../iemr/flw/utils/validator/Validator.java | 170 +++++++++--------- 4 files changed, 173 insertions(+), 108 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index ab6dcdd8..8c115791 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -3,6 +3,7 @@ import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.VillageLevelFormService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -20,46 +21,108 @@ public class VillageLevelFormController { @RequestMapping(value = "vhnd/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", villageLevelFormService.submitForm(dto)); - return ResponseEntity.ok(response); + if (!dto.getEntries().isEmpty()) { + String msg = villageLevelFormService.submitForm(dto); + boolean ok = "Success".equalsIgnoreCase(msg); + response.put("status", ok ? "Success" : "Fail"); + response.put("statusCode", ok ? 200 : 500); + response.put("message", msg); + return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); + + } else { + response.put("status", "Fail"); + response.put("statusCode", 400); + response.put("message", "Invalid Request Object"); + return ResponseEntity.ok(response); + + } + + } @RequestMapping(value = "vhnc/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitVhncForm(@RequestBody VhncDto dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", villageLevelFormService.submitVhncForm(dto)); - return ResponseEntity.ok(response); + + if (!dto.getEntries().isEmpty()) { + String msg = villageLevelFormService.submitVhncForm(dto); + boolean ok = "Success".equalsIgnoreCase(msg); + response.put("status", ok ? "Success" : "Fail"); + response.put("statusCode", ok ? 200 : 500); + response.put("message", msg); + return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); + } else { + response.put("status", "Fail"); + response.put("statusCode", 400); + response.put("message", "Invalid Request Object"); + return ResponseEntity.ok(response); + + + } + + } @RequestMapping(value = "phc/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitPhcForm(@RequestBody PhcReviewMeetingDTO dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", villageLevelFormService.submitPhcForm(dto)); - return ResponseEntity.ok(response); + + if (!dto.getEntries().isEmpty()) { + String msg = villageLevelFormService.submitPhcForm(dto); + boolean ok = "Success".equalsIgnoreCase(msg); + response.put("status", ok ? "Success" : "Fail"); + response.put("statusCode", ok ? 200 : 500); + response.put("message", msg); + return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); + } else { + response.put("status", "Fail"); + response.put("statusCode", 400); + response.put("message", "Invalid Request Object"); + return ResponseEntity.ok(response); + + } + + } @RequestMapping(value = "ahd/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", villageLevelFormService.submitAhdForm(dto)); - return ResponseEntity.ok(response); + + if(!dto.getEntries().isEmpty()){ + String msg = villageLevelFormService.submitAhdForm(dto); + boolean ok = "Success".equalsIgnoreCase(msg); + response.put("status", ok ? "Success" : "Fail"); + response.put("statusCode", ok ? 200 : 500); + response.put("message", msg); + return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); + }else { + response.put("status", "Fail"); + response.put("statusCode", 400); + response.put("message", "Invalid Request Object"); + return ResponseEntity.ok(response); + } + } @RequestMapping(value = "deworming/saveAll", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> submitDewormingForm(@RequestBody DewormingDto dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", villageLevelFormService.submitDewormingForm(dto)); - return ResponseEntity.ok(response); + + if(!dto.getEntries().isEmpty()){ + String msg = villageLevelFormService.submitDewormingForm(dto); + boolean ok = "Success".equalsIgnoreCase(msg); + response.put("status", ok ? "Success" : "Fail"); + response.put("statusCode", ok ? 200 : 500); + response.put("message", msg); + return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); + }else { + response.put("status", "Fail"); + response.put("statusCode", 400); + response.put("message", "Invalid Request Object"); + return ResponseEntity.ok(response); + } + } diff --git a/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java index 7bdadc41..0e0e05ca 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java +++ b/src/main/java/com/iemr/flw/dto/iemr/GetVillageLevelRequestHandler.java @@ -1,10 +1,12 @@ package com.iemr.flw.dto.iemr; +import jakarta.validation.constraints.NotNull; import lombok.Data; import java.sql.Timestamp; @Data public class GetVillageLevelRequestHandler { + @NotNull(message = "Form type is required") private String formType; private Integer villageID; private Timestamp fromDate; diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 8d28efe5..b41ccfb8 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -58,7 +58,7 @@ public String submitForm(VhndDto dto) { @Override public String submitVhncForm(VhncDto dto) { for (VhncFormDTO vhncFormDTO : dto.getEntries()) { - saveVhncFormData(vhncFormDTO, dto.getUserId()); + saveVhncFormData(vhncFormDTO, dto.getUserId()); } return "Success"; } @@ -67,7 +67,7 @@ public String submitVhncForm(VhncDto dto) { @Override public String submitPhcForm(PhcReviewMeetingDTO dto) { for (PhcReviewMeetingFormDTO phcReviewMeetingDTO : dto.getEntries()) { - submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); + submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); } return "Success"; } @@ -83,7 +83,7 @@ public String submitAhdForm(AhdMeetingDto dto) { @Override public String submitDewormingForm(DewormingDto dto) { for (DewormingFormDTO dewormingFormDTO : dto.getEntries()) { - submitDewormingForm(dewormingFormDTO, dto.getUserId()); + submitDewormingForm(dewormingFormDTO, dto.getUserId()); } return "Success"; } diff --git a/src/main/java/com/iemr/flw/utils/validator/Validator.java b/src/main/java/com/iemr/flw/utils/validator/Validator.java index e021eff1..207cbc03 100644 --- a/src/main/java/com/iemr/flw/utils/validator/Validator.java +++ b/src/main/java/com/iemr/flw/utils/validator/Validator.java @@ -1,24 +1,24 @@ /* -* AMRIT – Accessible Medical Records via Integrated Technology -* Integrated EHR (Electronic Health Records) Solution -* -* Copyright (C) "Piramal Swasthya Management and Research Institute" -* -* This file is part of AMRIT. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see https://www.gnu.org/licenses/. -*/ + * AMRIT – Accessible Medical Records via Integrated Technology + * Integrated EHR (Electronic Health Records) Solution + * + * Copyright (C) "Piramal Swasthya Management and Research Institute" + * + * This file is part of AMRIT. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see https://www.gnu.org/licenses/. + */ package com.iemr.flw.utils.validator; import com.iemr.flw.utils.config.ConfigProperties; @@ -34,76 +34,76 @@ @Service public class Validator { - private SessionObject session; + private SessionObject session; - private static Boolean enableIPValidation = false; + private static Boolean enableIPValidation = false; - @Autowired(required = true) - public void setSessionObject(SessionObject sessionObject) { - this.session = sessionObject; - } + @Autowired(required = true) + public void setSessionObject(SessionObject sessionObject) { + this.session = sessionObject; + } - public Validator() { - if (!enableIPValidation) { - enableIPValidation = ConfigProperties.getBoolean("enableIPValidation"); - } - } + public Validator() { + if (!enableIPValidation) { + enableIPValidation = ConfigProperties.getBoolean("enableIPValidation"); + } + } - private Logger logger = LoggerFactory.getLogger(Validator.class); + private Logger logger = LoggerFactory.getLogger(Validator.class); - public JSONObject updateCacheObj(JSONObject responseObj, String key, String ipKey) { - try { - Boolean loggedFromDifferentIP = false; - String loginKey = key; - String status = "login failed"; - try { - responseObj.put("sessionStatus", "session creation failed"); - String sessionData = session.getSessionObject(key); - if (enableIPValidation) { - if (sessionData != null && sessionData.trim().length() > 0) { - JSONObject sessionObj = new JSONObject(sessionData); - if (!sessionObj.getString("loginIPAddress").equals(responseObj.getString("loginIPAddress"))) { - logger.error("Logged in IP : " + sessionObj.getString("loginIPAddress") + "\tRequest IP : " - + responseObj.getString("loginIPAddress")); - loggedFromDifferentIP = true; - status = "login success, but user logged in from " + sessionObj.getString("loginIPAddress"); - } - } - } - } catch (RedisSessionException e) { - logger.error("Session validation failed with exception", e); - } - if (!loggedFromDifferentIP) { - status = "login success"; - session.setSessionObject(key, responseObj.toString()); - } else { - responseObj = new JSONObject(); - } - responseObj.put("key", loginKey); - responseObj.put("sessionStatus", status); - } catch (RedisSessionException | JSONException e) { - logger.error("Session validation failed with exception", e); - } - return responseObj; - } + public JSONObject updateCacheObj(JSONObject responseObj, String key, String ipKey) { + try { + Boolean loggedFromDifferentIP = false; + String loginKey = key; + String status = "login failed"; + try { + responseObj.put("sessionStatus", "session creation failed"); + String sessionData = session.getSessionObject(key); + if (enableIPValidation) { + if (sessionData != null && sessionData.trim().length() > 0) { + JSONObject sessionObj = new JSONObject(sessionData); + if (!sessionObj.getString("loginIPAddress").equals(responseObj.getString("loginIPAddress"))) { + logger.error("Logged in IP : " + sessionObj.getString("loginIPAddress") + "\tRequest IP : " + + responseObj.getString("loginIPAddress")); + loggedFromDifferentIP = true; + status = "login success, but user logged in from " + sessionObj.getString("loginIPAddress"); + } + } + } + } catch (RedisSessionException e) { + logger.error("Session validation failed with exception", e); + } + if (!loggedFromDifferentIP) { + status = "login success"; + session.setSessionObject(key, responseObj.toString()); + } else { + responseObj = new JSONObject(); + } + responseObj.put("key", loginKey); + responseObj.put("sessionStatus", status); + } catch (RedisSessionException | JSONException e) { + logger.error("Session validation failed with exception", e); + } + return responseObj; + } - public String getSessionObject(String key) throws RedisSessionException { - return session.getSessionObject(key); - } + public String getSessionObject(String key) throws RedisSessionException { + return session.getSessionObject(key); + } - public void checkKeyExists(String loginKey, String ipAddress) throws IEMRException { - try { - String sessionString = session.getSessionObject(loginKey); - JSONObject sessionObj = new JSONObject(sessionString); - if (enableIPValidation) { - if (!sessionObj.getString("loginIPAddress").equals(ipAddress)) { - logger.error( - "Logged in IP : " + sessionObj.getString("loginIPAddress") + "\tRequest IP : " + ipAddress); - throw new Exception(); - } - } - } catch (Exception e) { - throw new IEMRException("Invalid login key or session is expired"); - } - } + public void checkKeyExists(String loginKey, String ipAddress) throws IEMRException { + try { + String sessionString = session.getSessionObject(loginKey); + JSONObject sessionObj = new JSONObject(sessionString); + if (enableIPValidation) { + if (!sessionObj.getString("loginIPAddress").equals(ipAddress)) { + logger.error( + "Logged in IP : " + sessionObj.getString("loginIPAddress") + "\tRequest IP : " + ipAddress); + throw new Exception(); + } + } + } catch (Exception e) { + throw new IEMRException("Invalid login key or session is expired"); + } + } } From e04bb8322eab644c7451bfba4464e15a9bd184b3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 3 Jun 2025 16:40:00 +0530 Subject: [PATCH 113/792] fix code --- .../controller/DiseaseControlController.java | 12 +++--- .../controller/MalariaFollowUpController.java | 41 ++++++++++++++----- .../iemr/flw/domain/iemr/MalariaFollowUp.java | 6 +-- .../iemr/flw/domain/iemr/ScreeningAesje.java | 8 ++-- .../flw/domain/iemr/ScreeningFilariasis.java | 6 +-- .../flw/domain/iemr/ScreeningKalaAzar.java | 6 ++- .../flw/domain/iemr/ScreeningLeprosy.java | 6 +-- .../flw/domain/iemr/ScreeningMalaria.java | 12 +++--- .../iemr/flw/dto/iemr/DiseaseMalariaDTO.java | 1 - .../impl/DiseaseControlServiceImpl.java | 1 - 10 files changed, 60 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 5014a1f4..af03fd6b 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -23,7 +23,7 @@ @RestController @RequestMapping(value = "/disease",headers = "Authorization") public class DiseaseControlController { - private final Logger logger = LoggerFactory.getLogger(CoupleController.class); + private final Logger logger = LoggerFactory.getLogger(DiseaseControlController.class); @Autowired private DiseaseControlService diseaseControlService; @@ -37,7 +37,7 @@ public ResponseEntity> saveMalaria(@RequestBody MalariaDTO m logger.info("Malaria DTO: {}", new ObjectMapper().writeValueAsString(malariaDTO)); if(malariaDTO!=null){ - response.put("message", "Success"); + response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveMalaria(malariaDTO)); }else { @@ -60,7 +60,7 @@ public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO try { logger.info("KalaAzar DTO: {}", new ObjectMapper().writeValueAsString(kalaAzarDTO)); if(kalaAzarDTO!=null){ - response.put("message", "Success"); + response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); }else { @@ -82,7 +82,7 @@ public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJe try { if(aesJeDTO!=null){ - response.put("message", "Success"); + response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveAES(aesJeDTO)); }else { @@ -104,7 +104,7 @@ public ResponseEntity> saveFilaria(@RequestBody FilariaDTO f try { if(filariaDTO!=null){ - response.put("message", "Success"); + response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveFilaria(filariaDTO)); }else { @@ -125,7 +125,7 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l Map response = new HashMap<>(); try { if(leprosyDTO!=null){ - response.put("message", "Success"); + response.put("status", "Success"); response.put("statusCode", 200); response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); }else { diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index db564a95..e738961f 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -13,33 +13,52 @@ import java.util.Map; @RestController -@RequestMapping(value = "/api/follow-up",headers = "Authorization") +@RequestMapping(value = "/follow-up", headers = "Authorization") public class MalariaFollowUpController { @Autowired private MalariaFollowUpService followUpService; - @RequestMapping(value = "save",method = RequestMethod.POST,headers = "Authorization") + @RequestMapping(value = "save", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> save(@RequestBody MalariaFollowUpDTO dto) { Map response = new HashMap<>(); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("msg", followUpService.saveFollowUp(dto)); + try { + String result = followUpService.saveFollowUp(dto); + if (result.equals("Follow-up saved successfully")) { + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("message", result); + } else { + response.put("status", "Failed"); + response.put("statusCode", 400); + response.put("message", result); + } + } catch (Exception e) { + response.put("status", "Error: " + e.getMessage()); + response.put("statusCode", 500); + } return ResponseEntity.ok(response); } - @RequestMapping(value = "get",method = RequestMethod.POST,headers = "Authorization") + @RequestMapping(value = "get", method = RequestMethod.POST, headers = "Authorization") public ResponseEntity> getFollowUpsByUserId(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); - - List data = followUpService.getByUserId(getDiseaseRequestHandler.getUserId()); - if(!data.isEmpty()){ + + try { + List data = followUpService.getByUserId(getDiseaseRequestHandler.getUserId()); response.put("status", "Success"); response.put("statusCode", 200); - response.put("data",data); + response.put("data", data); + if (data.isEmpty()) { + response.put("message", "No records found"); + } + } catch (Exception e) { + response.put("status", "Error: " + e.getMessage()); + response.put("statusCode", 500); } - return ResponseEntity.ok(response); + + } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java index acddbcd7..e881b066 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java @@ -17,13 +17,13 @@ public class MalariaFollowUp { @Column(name = "ben_id", nullable = false) private Long benId; - @Column(name = "houseHoldDetailsId", nullable = false) + @Column(name = "house_hold_details_id", nullable = false) private Long houseHoldDetailsId; - @Column(name = "userId") + @Column(name = "user_Id") private Integer userId; - @Column(name = "diseaseId", nullable = false) + @Column(name = "disease_Id", nullable = false) private Long diseaseId; @Column(name = "date_of_diagnosis", nullable = false) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java index cb694fb3..eb074a84 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java @@ -18,7 +18,7 @@ public class ScreeningAesje { @Column(name = "ben_id") private Long benId; - @Column(name = "houseHoldDetailsId") + @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; @Temporal(TemporalType.DATE) @@ -65,16 +65,16 @@ public class ScreeningAesje { @Column(name = "created_by") private String createdBy; - @Column(name = "userID") + @Column(name = "user_id") private Integer userId; - @Column(name = "diseaseTypeID") + @Column(name = "disease_type_id") private Integer diseaseTypeId; @Column(name = "refer_to_name") private String referToName; - @Column(name = "beneficiary_statusId") + @Column(name = "beneficiary_status_id") private Integer beneficiaryStatusId; // Getters and Setters diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java index 3efa2864..516aa1f0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java @@ -18,7 +18,7 @@ public class ScreeningFilariasis { @Column(name = "ben_id") private Long benId; - @Column(name = "houseHoldDetailsId") + @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; @Column(name = "suffering_from_filariasis") @@ -53,10 +53,10 @@ public class ScreeningFilariasis { @Column(name = "created_by", length = 100) private String createdBy; - @Column(name = "diseaseTypeID") + @Column(name = "disease_type_id") private Integer diseaseTypeId; - @Column(name = "userID") + @Column(name = "user_id") private Integer userId; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java index a99cb40c..a36d889b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java @@ -18,15 +18,17 @@ public class ScreeningKalaAzar { @Column(name = "ben_id") private Long benId; - @Column(name = "houseHoldDetailsId") + @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; @Column(name = "userID") private Integer userId; + @Temporal(TemporalType.DATE) @Column(name = "visit_date") private Date visitDate; + @Temporal(TemporalType.DATE) @Column(name = "date_of_death") private Date dateOfDeath; @@ -51,6 +53,7 @@ public class ScreeningKalaAzar { @Column(name = "rapid_diagnostic_test") private String rapidDiagnosticTest; + @Temporal(TemporalType.DATE) @Column(name = "date_of_rdt") private Date dateOfRdt; @@ -63,6 +66,7 @@ public class ScreeningKalaAzar { @Column(name = "other_referred_facility") private String otherReferredFacility; + @Temporal(TemporalType.DATE) @Column(name = "created_date") private Date createdDate; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index 0b488ab3..bf84f2e9 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -17,7 +17,7 @@ public class ScreeningLeprosy { @Column(name = "ben_id") private Long benId; - @Column(name = "houseHoldDetailsId") + @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; @Temporal(TemporalType.DATE) @@ -47,10 +47,10 @@ public class ScreeningLeprosy { @Column(name = "remark", length = 225) private String remark; - @Column(name = "diseaseTypeID") + @Column(name = "disease_type_id") private Integer diseaseTypeId; - @Column(name = "userID") + @Column(name = "user_id") private Integer userId; @Column(name = "refer_to_name") diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java index 2631b9b5..85362363 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java @@ -18,7 +18,7 @@ public class ScreeningMalaria { @Column(name = "ben_id") private Long benId; - @Column(name = "houseHoldDetailsId") + @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; @Temporal(TemporalType.DATE) @@ -79,28 +79,28 @@ public class ScreeningMalaria { @Column(name = "remarks") private String remarks; + @Temporal(TemporalType.DATE) @Column(name = "date_of_visit_by_supervisor") private Date dateOfVisitBySupervisor; - @Column(name = "diseaseTypeID") + @Column(name = "disease_type_id") private Integer diseaseTypeId; - @Column(name = "userID") + @Column(name = "user_id") private Integer userId; + @Temporal(TemporalType.DATE) @Column(name = "created_date") private Date createdDate; @Column(name = "created_by") private String createdBy; - @Column(name = "date_of_visit_supervisor") - private Date dateOfVisitSupervisor; @Column(name = "refer_to_name") private String referToName; - @Column(name = "caseStatusId") + @Column(name = "case_status_id") private Integer caseStatusId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java index 6f95f24e..6e4d41bd 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java @@ -33,7 +33,6 @@ public class DiseaseMalariaDTO { private Integer userId; private Date createdDate; private String createdBy; - private Date dateOfVisitSupervisor; private boolean feverMoreThanTwoWeeks; private boolean fluLikeIllness; private boolean shakingChills; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index cce7e5fa..3e717dfa 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -33,7 +33,6 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private DiseaseLeprosyRepository diseaseLeprosyRepository; - @Autowired private IncentiveRecordRepo recordRepo; @Autowired From 82951f66915c933e7622272535bfe1c0f7cd509f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 12 Jun 2025 16:57:10 +0530 Subject: [PATCH 114/792] Fix asha profile code --- .../flw/controller/AshaProfileController.java | 59 ++++++++++++++----- .../flw/service/impl/EmployeeMasterImpl.java | 2 +- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index fcf82853..39ed91b9 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -7,10 +7,13 @@ import com.iemr.flw.service.AshaProfileService; import com.iemr.flw.service.EmployeeMasterInter; import com.iemr.flw.service.UserService; +import com.iemr.flw.utils.JwtUtil; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -26,6 +29,9 @@ public class AshaProfileController { AshaProfileService ashaProfileService; private Map response = new HashMap<>(); + @Autowired + private JwtUtil jwtUtil; + @Autowired private EmployeeMasterInter employeeMasterInter; @@ -52,28 +58,51 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker } @RequestMapping(value = "getProfile", method = RequestMethod.GET, headers = "Authorization") - public ResponseEntity> getProfile(@RequestParam("employeeId") Integer employeeId) { + public ResponseEntity> getProfile(HttpServletRequest request) { + Map response = new HashMap<>(); + try { - AshaWorker ashaWorker = ashaProfileService.getProfileData(employeeId); - if (ashaWorker != null) { - response.put("data", ashaWorker); - response.put("statusCode", 200); - response.put("status", "Success"); - } else { - response.put("data", ashaWorker); - response.put("statusCode", 200); - response.put("status", "Success"); + String jwtFromHeader = request.getHeader("JwtToken"); + + // Validate JWT header presence + if (jwtFromHeader == null || jwtFromHeader.trim().isEmpty()) { + response.put("statusCode", 401); + response.put("status", "Unauthorized"); + response.put("errorMessage", "JWT token is missing"); + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); + } + + // Extract and validate user ID from JWT + int userId = jwtUtil.extractUserId(jwtFromHeader); // Make sure this returns 0 or throws for invalid token + + if (userId == 0) { + response.put("statusCode", 401); + response.put("status", "Unauthorized"); + response.put("errorMessage", "Invalid JWT token"); + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); + } + + // Business logic + AshaWorker ashaWorker = ashaProfileService.getProfileData(userId); + + response.put("statusCode", 200); + response.put("status", "Success"); + response.put("data", ashaWorker); + + if (ashaWorker == null) { response.put("errorMessage", "Asha profile not found"); } + 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(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - - return ResponseEntity.ok().body(response); + } - } } diff --git a/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java index cf542677..b10359b3 100644 --- a/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/EmployeeMasterImpl.java @@ -13,6 +13,6 @@ public class EmployeeMasterImpl implements EmployeeMasterInter { @Override public M_User getUserDetails(Integer userID) { - return employeeMasterRepo.findByUserID(userID); + return employeeMasterRepo.getUserByUserID(userID); } } From a1ed641f2dd8ca161ed66c50c050afa21aac8640 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 17 Jun 2025 11:47:37 +0530 Subject: [PATCH 115/792] fix code --- .../com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java | 4 +--- .../java/com/iemr/flw/service/MalariaFollowUpService.java | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java index cea3d281..b10665d9 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java @@ -7,7 +7,5 @@ import java.util.List; public interface MalariaFollowUpRepository extends JpaRepository { - List findByBenId(Long benId); - - Collection findByUserId(Integer userId); + List findByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java index 62a6a322..69f9c9d0 100644 --- a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java +++ b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java @@ -6,7 +6,6 @@ import java.util.List; -@Service public interface MalariaFollowUpService { From e3c22da12da7076e33ba3b3e9af640ecca7dfcfa Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 17 Jun 2025 12:01:50 +0530 Subject: [PATCH 116/792] fix code --- .../flw/controller/IRSRoundController.java | 35 ++++++++++++------- .../com/iemr/flw/domain/iemr/IRSRound.java | 13 ++++--- .../com/iemr/flw/dto/iemr/IRSRoundDTO.java | 10 ++++-- .../flw/service/impl/IRSRoundServiceImpl.java | 17 ++++++--- 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java index efe63430..f05b1f7e 100644 --- a/src/main/java/com/iemr/flw/controller/IRSRoundController.java +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -6,6 +6,7 @@ import com.iemr.flw.service.IRSRoundService; import com.iemr.flw.utils.response.OutputResponse; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -23,30 +24,38 @@ public class IRSRoundController { @Autowired private IRSRoundService irsRoundService; - @RequestMapping(name = "/add", method = RequestMethod.POST, headers = "Authorization") - public String addRound(@RequestBody IRSRoundListDTO dto) { - OutputResponse response = new OutputResponse(); + @PostMapping(value = "/add", headers = "Authorization") + public ResponseEntity> addRound(@RequestBody IRSRoundListDTO dto) { + Map response = new LinkedHashMap<>(); try { if (dto.getRounds().size() != 0) { List s = irsRoundService.addRounds(dto.getRounds()); if (s.size() != 0) { - response.setResponse(s.toString()); - + Map data = new HashMap<>(); + data.put("entries", s); + response.put("data", data); + response.put("statusCode", 200); + response.put("message", "Success"); + return ResponseEntity.ok(response); } else { - response.setError(500, "Invalid/NULL request obj"); - + response.put("statusCode", 500); + response.put("errorMessage", "Invalid/NULL request obj"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } else - response.setError(500, "Invalid/NULL request obj"); + response.put("statusCode", 400); + response.put("errorMessage", "Invalid/NULL request obj"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } catch (Exception e) { - response.setError(500, "Error in saving cbac details : " + e); + response.put("statusCode", 500); + response.put("errorMessage", "Error in saving IRS round details: " + e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return response.toString(); } - @RequestMapping(name = "/list/{householdId}", method = RequestMethod.GET, headers = "Authorization") + @GetMapping(value = "/list/{householdId}", headers = "Authorization") public ResponseEntity> getRounds(@PathVariable Long householdId) { Map response = new LinkedHashMap<>(); @@ -57,13 +66,15 @@ public ResponseEntity> getRounds(@PathVariable Long househol response.put("data", data); response.put("statusCode", 200); response.put("message", "Success"); + return ResponseEntity.ok(response); + } catch (Exception e) { response.put("statusCode", 500); response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return ResponseEntity.ok(response); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java index d7826b5e..78c4a9d5 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java @@ -7,21 +7,24 @@ import java.math.BigInteger; import java.sql.Date; +import java.time.LocalDate; @Entity @Data -@Table(name = "irs_round",schema = "db_iemr") +@Table(name = "irs_round", schema = "db_iemr") @AllArgsConstructor +@NoArgsConstructor public class IRSRound { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "round") - private Date date; @Column(name = "irs_date") + private LocalDate date; + + @Column(name = "round") private int rounds; - + @Column(name = "householdId") - private BigInteger household; + private Long household; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java index 412d9f59..f2d48716 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IRSRoundDTO.java @@ -1,18 +1,24 @@ package com.iemr.flw.dto.iemr; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import java.math.BigInteger; import java.sql.Date; +import java.time.LocalDate; @Data @NoArgsConstructor @AllArgsConstructor public class IRSRoundDTO { private Long id; - private Date date; + @NotNull(message = "Date cannot be null") + private LocalDate date; + @Min(value = 1, message = "Rounds must be at least 1") private int rounds; - private BigInteger householdId; + @NotNull(message = "Household ID cannot be null") + private Long householdId; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java index a5d66223..b294a3dc 100644 --- a/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java @@ -9,19 +9,26 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; + @Service public class IRSRoundServiceImpl implements IRSRoundService { @Autowired private IRSRoundRepo irsRoundRepository; + @Override public List addRounds(List dtos) { - List rounds = new ArrayList<>(); + // Validate input DTOs for (IRSRoundDTO dto : dtos) { - - IRSRound round = new IRSRound(null, dto.getDate(), dto.getRounds(), dto.getHouseholdId()); - rounds.add(round); + if (dto.getDate() == null || dto.getHouseholdId() == null) { + throw new IllegalArgumentException("Date and household ID are required"); + } } - return irsRoundRepository.saveAll(rounds); + return irsRoundRepository.saveAll( + dtos.stream() + .map(dto -> new IRSRound(null, dto.getDate(), dto.getRounds(), dto.getHouseholdId())) + .collect(Collectors.toList()) + ); } @Override From 315d5ae0c41391bb12a0646cd7f52406067bfb58 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 17 Jun 2025 12:13:03 +0530 Subject: [PATCH 117/792] General OPD Module --- src/main/java/com/iemr/flw/controller/GeneralOPDController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index 97cdfe5e..ed715d40 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -23,8 +23,6 @@ public class GeneralOPDController { private GeneralOpdService generalOpdService; - - @RequestMapping(value = "/getData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, From 296041274a309da3825feb8c316973bc3a64e811 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 17 Jun 2025 12:13:31 +0530 Subject: [PATCH 118/792] General OPD Module --- .../java/com/iemr/flw/controller/GeneralOPDController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index ed715d40..294a01b8 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -36,12 +36,12 @@ public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler request if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in get data : " + e); - response.setError(5000, "Error in get data : " + e); + response.setError(500, "Error in get data : " + e); } return response.toString(); From 7e927026b11cc87925392ecd11b85bf7bb30a48e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 17 Jun 2025 12:17:00 +0530 Subject: [PATCH 119/792] General OPD Module --- .../flw/controller/GeneralOPDController.java | 35 +++++++++--------- .../iemr/flw/service/GeneralOpdService.java | 2 +- .../service/impl/GeneralOpdServiceImpl.java | 37 +++++++------------ 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index 294a01b8..7762ad0f 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -12,10 +12,13 @@ import org.springframework.web.bind.annotation.*; import java.sql.Timestamp; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; @RestController -@RequestMapping("/api/general-opd") +@RequestMapping(value = "/general-opd") public class GeneralOPDController { private final org.slf4j.Logger logger = LoggerFactory.getLogger(BeneficiaryController.class); @@ -23,27 +26,25 @@ public class GeneralOPDController { private GeneralOpdService generalOpdService; - @RequestMapping(value = "/getData", method = RequestMethod.POST) + @RequestMapping(value = "getData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") - public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String authorization) { - OutputResponse response = new OutputResponse(); + public ResponseEntity> getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, + @RequestHeader(value = "Authorization") String authorization) { + Map response = new LinkedHashMap<>(); try { - if (requestDTO != null) { - logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " - + requestDTO); - String s = generalOpdService.getOpdListForAsha(requestDTO, authorization); - if (s != null) - response.setResponse(s); - else - response.setError(500, "No record found"); - } else - response.setError(500, "Invalid/NULL request obj"); + Map data = new HashMap<>(); + data.put("userId", requestDTO.getUserId()); + data.put("entries", generalOpdService.getOpdListForAsha(requestDTO, authorization)); + response.put("data", data); + response.put("statusCode", 200); + response.put("errorMessage", "Success"); + response.put("status", "Success"); } catch (Exception e) { logger.error("Error in get data : " + e); - response.setError(500, "Error in get data : " + e); + response.put("status", 500); + response.put("message", "Error in get data : " + e); } - return response.toString(); + return ResponseEntity.ok(response); } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/GeneralOpdService.java b/src/main/java/com/iemr/flw/service/GeneralOpdService.java index 7c307772..6bb4a303 100644 --- a/src/main/java/com/iemr/flw/service/GeneralOpdService.java +++ b/src/main/java/com/iemr/flw/service/GeneralOpdService.java @@ -6,5 +6,5 @@ import java.util.List; public interface GeneralOpdService { - String getOpdListForAsha(GetBenRequestHandler getBenRequestHandler,String authorisation) throws Exception; + Object getOpdListForAsha(GetBenRequestHandler getBenRequestHandler,String authorisation) throws Exception; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java index f2c9b5ca..6c14a02c 100644 --- a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java @@ -1,31 +1,18 @@ package com.iemr.flw.service.impl; -import com.google.gson.*; import com.iemr.flw.domain.identity.*; -import com.iemr.flw.domain.iemr.BenVisitDetail; -import com.iemr.flw.domain.iemr.GeneralOpdEntry; +import com.iemr.flw.domain.iemr.GeneralOpdData; import com.iemr.flw.dto.identity.GetBenRequestHandler; -import com.iemr.flw.dto.iemr.GeneralOpdDto; -import com.iemr.flw.mapper.InputMapper; import com.iemr.flw.repo.identity.BeneficiaryRepo; -import com.iemr.flw.repo.identity.HouseHoldRepo; -import com.iemr.flw.repo.iemr.BenVisitDetailsRepo; -import com.iemr.flw.repo.iemr.BeneficiaryRepository; import com.iemr.flw.repo.iemr.GeneralOpdRepo; import com.iemr.flw.service.GeneralOpdService; -import com.iemr.flw.utils.config.ConfigProperties; -import com.iemr.flw.utils.http.HttpUtils; 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.data.domain.Page; import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; - -import java.math.BigInteger; -import java.sql.Date; -import java.time.Period; import java.util.*; import java.util.stream.Collectors; @@ -39,18 +26,22 @@ public class GeneralOpdServiceImpl implements GeneralOpdService { private BeneficiaryRepo beneficiaryRepo; @Autowired - private HouseHoldRepo houseHoldRepo; + private GeneralOpdRepo generalOpdRepo; - @Autowired - private BenVisitDetailsRepo benVisitDetailsRepo; + @Override + public Object getOpdListForAsha(GetBenRequestHandler request, String authorisation) throws Exception { + List filteredList; - @Autowired - private GeneralOpdRepo generalOpdRepo; + do { + filteredList = generalOpdRepo.findAll().stream() + .filter(generalOpdData -> + generalOpdData.getVisitCategory() != null && + generalOpdData.getVisitCategory().equals("General OPD") && generalOpdData.getVisitCode()!=0) + .collect(Collectors.toList()); - @Override - public String getOpdListForAsha(GetBenRequestHandler request, String authorisation) throws Exception { + } while (filteredList.isEmpty()); - return generalOpdRepo.findAll().toString(); + return filteredList.stream().filter(data-> data.getAgentId().equals(request.getUserName())).collect(Collectors.toList()); } } \ No newline at end of file From 74f1a92b9177a7deec1afb91252d70532ffd734d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 18 Jun 2025 10:23:55 +0530 Subject: [PATCH 120/792] General OPD Module --- src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java | 4 ++++ .../java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java index 41f06a30..23793f8e 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/GeneralOpdData.java @@ -18,7 +18,11 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see https://www.gnu.org/licenses/. +* @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology */ + package com.iemr.flw.domain.iemr; import java.sql.Timestamp; diff --git a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java index 571348ed..23a79426 100644 --- a/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java +++ b/src/main/java/com/iemr/flw/utils/http/HTTPRequestInterceptor.java @@ -87,7 +87,7 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons if (remoteAddress == null || remoteAddress.trim().length() == 0) { remoteAddress = request.getRemoteAddr(); } - //validator.checkKeyExists(authorization, remoteAddress); + validator.checkKeyExists(authorization, remoteAddress); break; } } catch (Exception e) { From beae9219e634b60963db5ed99c60013a843561fe Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 18 Jun 2025 15:30:59 +0530 Subject: [PATCH 121/792] General OPD Module --- .../flw/controller/GeneralOPDController.java | 42 +++++++++++++++---- .../iemr/flw/repo/iemr/GeneralOpdRepo.java | 24 +++++++++++ .../iemr/flw/service/GeneralOpdService.java | 24 +++++++++++ .../service/impl/GeneralOpdServiceImpl.java | 24 +++++++++++ 4 files changed, 106 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index 7762ad0f..c45d999e 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -1,11 +1,38 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.controller; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.GeneralOpdDto; import com.iemr.flw.service.BeneficiaryService; import com.iemr.flw.service.GeneralOpdService; +import com.iemr.flw.utils.CookieUtil; +import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -14,24 +41,24 @@ import java.sql.Timestamp; import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.List; import java.util.Map; @RestController -@RequestMapping(value = "/general-opd") +@RequestMapping(value = "/generalOpd") public class GeneralOPDController { - private final org.slf4j.Logger logger = LoggerFactory.getLogger(BeneficiaryController.class); + private final org.slf4j.Logger logger = LoggerFactory.getLogger(GeneralOPDController.class); + @Autowired + private JwtUtil jwtUtil; @Autowired private GeneralOpdService generalOpdService; - - @RequestMapping(value = "getData", method = RequestMethod.POST) + @RequestMapping(value = "getBeneficiaries", method = RequestMethod.POST, headers = "Authorization") @Operation(summary = "get beneficiary data for given user ") - public ResponseEntity> getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String authorization) { + public ResponseEntity> getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "Authorization") String authorization) { Map response = new LinkedHashMap<>(); try { + Map data = new HashMap<>(); data.put("userId", requestDTO.getUserId()); data.put("entries", generalOpdService.getOpdListForAsha(requestDTO, authorization)); @@ -45,6 +72,5 @@ public ResponseEntity> getBeneficiaryDataByAsha(@RequestBody response.put("message", "Error in get data : " + e); } return ResponseEntity.ok(response); - } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java b/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java index b97ebff7..89692fbb 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/GeneralOpdRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.GeneralOpdData; diff --git a/src/main/java/com/iemr/flw/service/GeneralOpdService.java b/src/main/java/com/iemr/flw/service/GeneralOpdService.java index 6bb4a303..2e943070 100644 --- a/src/main/java/com/iemr/flw/service/GeneralOpdService.java +++ b/src/main/java/com/iemr/flw/service/GeneralOpdService.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service; import com.iemr.flw.dto.identity.GetBenRequestHandler; diff --git a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java index 6c14a02c..82cf0192 100644 --- a/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/GeneralOpdServiceImpl.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* @@ -0,0 +1,212 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service.impl; import com.iemr.flw.domain.identity.*; From 4492b444929393dcd272af38cebb8ae768a7f20c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 18 Jun 2025 17:59:00 +0530 Subject: [PATCH 122/792] Fix code --- .../controller/DiseaseControlController.java | 12 ++++++------ .../controller/MalariaFollowUpController.java | 7 +++---- .../flw/service/MalariaFollowUpService.java | 2 +- .../impl/MalariaFollowUpServiceImpl.java | 17 +++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index af03fd6b..10018df3 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -29,7 +29,7 @@ public class DiseaseControlController { private DiseaseControlService diseaseControlService; - @RequestMapping(value = "Malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + @RequestMapping(value = "malaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveMalaria(@RequestBody MalariaDTO malariaDTO) { Map response = new HashMap<>(); @@ -53,7 +53,7 @@ public ResponseEntity> saveMalaria(@RequestBody MalariaDTO m } - @RequestMapping(value = "KalaAzar/saveAll", method = RequestMethod.POST,consumes = "application/json", produces = "application/json",headers = "Authorization") + @RequestMapping(value = "kalaAzar/saveAll", method = RequestMethod.POST,consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO kalaAzarDTO) { Map response = new HashMap<>(); @@ -76,7 +76,7 @@ public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO } - @RequestMapping(value = "AesJe/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + @RequestMapping(value = "aesJe/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJeDTO) { Map response = new HashMap<>(); @@ -98,7 +98,7 @@ public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJe } - @RequestMapping(value = "Filaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + @RequestMapping(value = "filaria/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveFilaria(@RequestBody FilariaDTO filariaDTO) { Map response = new HashMap<>(); @@ -120,7 +120,7 @@ public ResponseEntity> saveFilaria(@RequestBody FilariaDTO f } - @RequestMapping(value = "Leprosy/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + @RequestMapping(value = "leprosy/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO leprosyDTO) { Map response = new HashMap<>(); try { @@ -143,7 +143,7 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l } - @RequestMapping(value = "getAll", method = RequestMethod.POST, produces = "application/json",headers = "Authorization") + @RequestMapping(value = "getAllDisease", method = RequestMethod.GET, produces = "application/json",headers = "Authorization") public ResponseEntity> getAllData(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); try { diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index e738961f..606bd5e2 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -24,15 +24,14 @@ public ResponseEntity> save(@RequestBody MalariaFollowUpDTO Map response = new HashMap<>(); try { - String result = followUpService.saveFollowUp(dto); - if (result.equals("Follow-up saved successfully")) { + Boolean result = followUpService.saveFollowUp(dto); + if (result) { response.put("status", "Success"); response.put("statusCode", 200); - response.put("message", result); + response.put("message", "Follow-up saved successfully"); } else { response.put("status", "Failed"); response.put("statusCode", 400); - response.put("message", result); } } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); diff --git a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java index 69f9c9d0..eb979318 100644 --- a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java +++ b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java @@ -9,7 +9,7 @@ public interface MalariaFollowUpService { - public String saveFollowUp(MalariaFollowUpDTO dto) ; + public Boolean saveFollowUp(MalariaFollowUpDTO dto) ; List getByUserId(Integer userId); diff --git a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java index 926f8d90..6a1a5bf9 100644 --- a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java @@ -19,38 +19,39 @@ public class MalariaFollowUpServiceImpl implements MalariaFollowUpService { @Autowired private MalariaFollowUpRepository repository; - public String saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO) { + public Boolean saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO) { + for(MalariaFollowListUpDTO dto : malariaFollowUpDTO.getMalariaFollowListUp()){ if (dto.getTreatmentStartDate().after(new Date())) { - return "Treatment start date cannot be in the future."; + return false; } if (dto.getTreatmentCompletionDate() != null && dto.getTreatmentCompletionDate().before(dto.getTreatmentStartDate())) { - return "Completion date cannot be before treatment start date."; + return false; } if (dto.getReferralDate() != null && dto.getReferralDate().before(dto.getTreatmentStartDate())) { - return "Referral date must be after treatment start date."; + return false; } if ("Pf".equalsIgnoreCase(dto.getTreatmentGiven()) && !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3())) { - return "At least one Pf day must be selected."; + return false; } if ("Pv".equalsIgnoreCase(dto.getTreatmentGiven()) && !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3()|| dto.getPvDay4())) { - return "At least one Pv day must be selected."; + return false; } MalariaFollowUp entity = new MalariaFollowUp(); BeanUtils.copyProperties(dto, entity); repository.save(entity); - return "Follow-up saved successfully"; + return true; } - return "Fail"; + return false; } public List getByUserId(Integer userId) { From 75e6aa3e4bff9f0b013f9f786add4514690435cd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 18 Jun 2025 18:13:47 +0530 Subject: [PATCH 123/792] fix spacing issue --- .../com/iemr/flw/controller/DiseaseControlController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 10018df3..7ae6501a 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -137,8 +137,6 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); } - - return ResponseEntity.ok(response); } @@ -154,10 +152,7 @@ public ResponseEntity> getAllData(@RequestBody GetDiseaseReq } catch (Exception e) { response.put("status", "Error" + e.getMessage()); response.put("statusCode", 500); - } - - return ResponseEntity.ok(response); } From 28efaf298cb7a0da5586a168497f5a441906f902 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 18 Jun 2025 18:19:12 +0530 Subject: [PATCH 124/792] Add GPL license --- .../controller/DiseaseControlController.java | 24 +++++++++++++++++++ .../repo/iemr/MalariaFollowUpRepository.java | 24 +++++++++++++++++++ .../flw/service/DiseaseControlService.java | 24 +++++++++++++++++++ .../impl/DiseaseControlServiceImpl.java | 24 +++++++++++++++++++ 4 files changed, 96 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 7ae6501a..0a584f1c 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.controller; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java index b10665d9..743d2631 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MalariaFollowUpRepository.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.MalariaFollowUp; diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 1a0025ff..b575501b 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.*; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 3e717dfa..d6c2c46a 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; From 1831e8f722718ca981c28bc56a4c9845070559a5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Jun 2025 11:15:58 +0530 Subject: [PATCH 125/792] Add GPL license --- .../controller/MalariaFollowUpController.java | 24 +++++++++++++++++++ .../iemr/flw/domain/iemr/ScreeningAesje.java | 24 +++++++++++++++++++ .../flw/domain/iemr/ScreeningFilariasis.java | 24 +++++++++++++++++++ .../flw/domain/iemr/ScreeningKalaAzar.java | 24 +++++++++++++++++++ .../flw/domain/iemr/ScreeningLeprosy.java | 24 +++++++++++++++++++ .../flw/domain/iemr/ScreeningMalaria.java | 24 +++++++++++++++++++ .../java/com/iemr/flw/dto/iemr/AesJeDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseAesjeDto.java | 24 +++++++++++++++++++ .../flw/dto/iemr/DiseaseFilariasisDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseMalariaDTO.java | 24 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/FilariaDTO.java | 24 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/KalaAzarDTO.java | 24 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/LeprosyDTO.java | 24 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/MalariaDTO.java | 24 +++++++++++++++++++ .../flw/dto/iemr/MalariaFollowListUpDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/MalariaFollowUpDTO.java | 24 +++++++++++++++++++ .../iemr/flw/dto/iemr/MalariaSymptomsDTO.java | 24 +++++++++++++++++++ 19 files changed, 456 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index 606bd5e2..95bb527d 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.controller; import com.iemr.flw.dto.iemr.GetDiseaseRequestHandler; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java index eb074a84..372908f9 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningAesje.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java index 516aa1f0..e75cb046 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningFilariasis.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java index a36d889b..eb8b0107 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index bf84f2e9..3723afec 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java index 85362363..1f6b9f48 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; diff --git a/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java index 85fdb417..ee444826 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/AesJeDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java index 99514ed3..1a503e5a 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseAesjeDto.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java index da068817..a834fdba 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseFilariasisDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java index 7db5c064..f70aa04d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseKalaAzarDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index 28906ca0..f6074e24 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java index 6e4d41bd..cae348ff 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import jakarta.persistence.Column; diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java index 85088918..821b16e0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariaDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java index 1a51fcff..6048f636 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/KalaAzarDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java index b8362002..396048c4 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java index af2146b0..6570c7c5 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java index abf53b46..5be38876 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java index a0be541e..f47da8ed 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowUpDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java index 6b9f2cde..b140a72b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaSymptomsDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; From 4354943f71c4ac9f68859e72253e4af0d5d5c97e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Jun 2025 11:23:54 +0530 Subject: [PATCH 126/792] Add GPL license --- .../VillageLevelFormController.java | 24 +++++++ .../com/iemr/flw/dto/iemr/VHNDFormDTO.java | 24 +++++++ .../java/com/iemr/flw/dto/iemr/VhncDto.java | 24 +++++++ .../com/iemr/flw/dto/iemr/VhncFormDTO.java | 24 +++++++ .../java/com/iemr/flw/dto/iemr/VhndDto.java | 24 +++++++ .../com/iemr/flw/repo/iemr/AHDFormRepo.java | 24 +++++++ .../iemr/flw/repo/iemr/DewormingFormRepo.java | 24 +++++++ .../iemr/flw/repo/iemr/PHCReviewFormRepo.java | 24 +++++++ .../com/iemr/flw/repo/iemr/VhncFormRepo.java | 24 +++++++ .../java/com/iemr/flw/repo/iemr/VhndRepo.java | 24 +++++++ .../flw/service/VillageLevelFormService.java | 35 ++++++++-- .../impl/VillageLevelFormServiceImpl.java | 66 +++++++++++++------ 12 files changed, 314 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index 8c115791..295c082b 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.controller; import com.iemr.flw.dto.iemr.*; diff --git a/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java index 64ea4791..0dec7976 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java index 8fe45ef2..54f6f92c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VhncDto.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java index d7352ed5..8a12be96 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java index 3f53e65b..60c68d07 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VhndDto.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.dto.iemr; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java index a13150e1..8f8b2188 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AHDFormRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.AHDForm; diff --git a/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java index 32257b1b..a1b3ee7c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DewormingFormRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.DewormingForm; diff --git a/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java index 470677ef..5f59e90f 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/PHCReviewFormRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.PHCReviewForm; diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java index e1dfb985..4b7ed3cf 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/VhncFormRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.VhncForm; diff --git a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java index 3d40fd94..e792cfb8 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/VhndRepo.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.VHNDForm; diff --git a/src/main/java/com/iemr/flw/service/VillageLevelFormService.java b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java index 6d926c6b..6559603f 100644 --- a/src/main/java/com/iemr/flw/service/VillageLevelFormService.java +++ b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java @@ -1,22 +1,45 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.*; import org.springframework.stereotype.Service; import java.util.List; - @Service public interface VillageLevelFormService { - String submitForm(VhndDto dto); + Boolean submitForm(VhndDto dto); - String submitVhncForm(VhncDto dto); + Boolean submitVhncForm(VhncDto dto); - String submitPhcForm(PhcReviewMeetingDTO dto); + Boolean submitPhcForm(PhcReviewMeetingDTO dto); - String submitAhdForm(AhdMeetingDto dto); + Boolean submitAhdForm(AhdMeetingDto dto); - String submitDewormingForm(DewormingDto dto); + Boolean submitDewormingForm(DewormingDto dto); List getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index b41ccfb8..4c9f0ed5 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -1,3 +1,27 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ package com.iemr.flw.service.impl; import com.iemr.flw.controller.CoupleController; @@ -20,7 +44,7 @@ @Service public class VillageLevelFormServiceImpl implements VillageLevelFormService { - private final Logger logger = LoggerFactory.getLogger(CoupleController.class); + private final Logger logger = LoggerFactory.getLogger(VillageLevelFormServiceImpl.class); @Autowired private IncentiveRecordRepo recordRepo; @@ -47,48 +71,48 @@ public class VillageLevelFormServiceImpl implements VillageLevelFormService { @Override - public String submitForm(VhndDto dto) { + public Boolean submitForm(VhndDto dto) { for (VHNDFormDTO vhndFormDTO : dto.getEntries()) { saveVhndFormData(vhndFormDTO, dto.getUserId()); } - return "Success"; + return true; } @Override - public String submitVhncForm(VhncDto dto) { + public Boolean submitVhncForm(VhncDto dto) { for (VhncFormDTO vhncFormDTO : dto.getEntries()) { saveVhncFormData(vhncFormDTO, dto.getUserId()); } - return "Success"; + return true; } @Override - public String submitPhcForm(PhcReviewMeetingDTO dto) { + public Boolean submitPhcForm(PhcReviewMeetingDTO dto) { for (PhcReviewMeetingFormDTO phcReviewMeetingDTO : dto.getEntries()) { submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); } - return "Success"; + return true; } @Override - public String submitAhdForm(AhdMeetingDto dto) { + public Boolean submitAhdForm(AhdMeetingDto dto) { for (AhDMeetingFormDTO ahDMeetingFormDTO : dto.getEntries()) { submitAhdForm(ahDMeetingFormDTO, dto.getUserId()); } - return "Success"; + return true; } @Override - public String submitDewormingForm(DewormingDto dto) { + public Boolean submitDewormingForm(DewormingDto dto) { for (DewormingFormDTO dewormingFormDTO : dto.getEntries()) { submitDewormingForm(dewormingFormDTO, dto.getUserId()); } - return "Success"; + return true; } - private String saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { + private Boolean saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { VhncForm vhncForm = new VhncForm(); vhncForm.setUserId(Long.valueOf(userID)); vhncForm.setVhncDate(vhncFormDTO.getVhncDate()); @@ -101,11 +125,11 @@ private String saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { vhncFormRepo.save(vhncForm); checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), vhncForm.getFormType(), vhncForm.getCreatedBy()); - return "Save VHNC Form successfully"; + return true; } - private String submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { + private Boolean submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { PHCReviewForm phcReviewForm = new PHCReviewForm(); phcReviewForm.setUserId(Long.valueOf(userID)); phcReviewForm.setPhcReviewDate(dto.getPhcReviewDate()); @@ -117,10 +141,10 @@ private String submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { phcReviewFormRepo.save(phcReviewForm); checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), phcReviewForm.getFormType(), phcReviewForm.getCreatedBy()); - return "Save PHC Review Form successfully"; + return true; } - private String submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { + private Boolean submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { AHDForm ahdForm = new AHDForm(); ahdForm.setUserId(Long.valueOf(userID)); ahdForm.setMobilizedForAHD(dto.getMobilizedForAHD()); @@ -135,10 +159,10 @@ private String submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { } - return "Save AHD Form successfully"; + return true; } - private String submitDewormingForm(DewormingFormDTO dto, Integer userID) { + private Boolean submitDewormingForm(DewormingFormDTO dto, Integer userID) { DewormingForm dewormingForm = new DewormingForm(); dewormingForm.setUserId(Long.valueOf(userID)); dewormingForm.setDewormingDone(dto.getDewormingDone()); @@ -153,11 +177,11 @@ private String submitDewormingForm(DewormingFormDTO dto, Integer userID) { checkAndAddIncentives(dewormingForm.getDewormingDate(), Math.toIntExact(dewormingForm.getUserId()), dewormingForm.getFormType(), dewormingForm.getCreatedBy()); } - return "Save Deworming Form successfully"; + return true; } - private String saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { + private Boolean saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { VHNDForm vhndForm = new VHNDForm(); vhndForm.setUserId(userID); vhndForm.setVhndDate(vhndFormDTO.getVhndDate()); @@ -168,7 +192,7 @@ private String saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { vhndForm.setFormType("VHND"); vhndRepo.save(vhndForm); checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), vhndForm.getFormType(), vhndForm.getCreatedBy()); - return "Save Vhnd Form successfully"; + return true; } From 7a94a2bab728eb8d03981c151662f32ab8daf46e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Jun 2025 14:17:49 +0530 Subject: [PATCH 127/792] Add GPL license --- .../VillageLevelFormController.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index 295c082b..f3f7186b 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -46,11 +46,11 @@ public class VillageLevelFormController { public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - String msg = villageLevelFormService.submitForm(dto); - boolean ok = "Success".equalsIgnoreCase(msg); + Boolean isSaved = villageLevelFormService.submitForm(dto); + boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); - response.put("message", msg); + response.put("message", "Save Successfully"); return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); } else { @@ -69,11 +69,11 @@ public ResponseEntity> submitVhncForm(@RequestBody VhncDto d Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - String msg = villageLevelFormService.submitVhncForm(dto); - boolean ok = "Success".equalsIgnoreCase(msg); + Boolean isSaved = villageLevelFormService.submitVhncForm(dto); + boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); - response.put("message", msg); + response.put("message", "Save Successfully"); return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); } else { response.put("status", "Fail"); @@ -92,11 +92,11 @@ public ResponseEntity> submitPhcForm(@RequestBody PhcReviewM Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - String msg = villageLevelFormService.submitPhcForm(dto); - boolean ok = "Success".equalsIgnoreCase(msg); + Boolean isSaved = villageLevelFormService.submitPhcForm(dto); + boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); - response.put("message", msg); + response.put("message", "Save Successfully"); return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); } else { response.put("status", "Fail"); @@ -114,11 +114,11 @@ public ResponseEntity> submitAhdForm(@RequestBody AhdMeeting Map response = new HashMap<>(); if(!dto.getEntries().isEmpty()){ - String msg = villageLevelFormService.submitAhdForm(dto); - boolean ok = "Success".equalsIgnoreCase(msg); + Boolean isSaved = villageLevelFormService.submitAhdForm(dto); + boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); - response.put("message", msg); + response.put("message", "Save Successfully"); return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); }else { response.put("status", "Fail"); @@ -134,11 +134,11 @@ public ResponseEntity> submitDewormingForm(@RequestBody Dewo Map response = new HashMap<>(); if(!dto.getEntries().isEmpty()){ - String msg = villageLevelFormService.submitDewormingForm(dto); - boolean ok = "Success".equalsIgnoreCase(msg); + Boolean isSaved = villageLevelFormService.submitDewormingForm(dto); + boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); - response.put("message", msg); + response.put("message", "Save Successfully"); return new ResponseEntity<>(response, ok ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR); }else { response.put("status", "Fail"); From f70655b698f5c4f0e2ccc53eb7e50bea25993e0d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Jun 2025 14:21:51 +0530 Subject: [PATCH 128/792] Add GPL license --- .../VillageLevelFormController.java | 20 +++++------ .../flw/service/VillageLevelFormService.java | 10 +++--- .../impl/VillageLevelFormServiceImpl.java | 36 ++++++++++++------- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index f3f7186b..ddbb7a76 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -43,10 +43,10 @@ public class VillageLevelFormController { private VillageLevelFormService villageLevelFormService; @RequestMapping(value = "vhnd/saveAll", method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> submitVhndForm(@RequestBody VhndDto dto) { + public ResponseEntity> saveVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - Boolean isSaved = villageLevelFormService.submitForm(dto); + Boolean isSaved = villageLevelFormService.saveForm(dto); boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); @@ -65,11 +65,11 @@ public ResponseEntity> submitVhndForm(@RequestBody VhndDto d } @RequestMapping(value = "vhnc/saveAll", method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> submitVhncForm(@RequestBody VhncDto dto) { + public ResponseEntity> saveVhncForm(@RequestBody VhncDto dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - Boolean isSaved = villageLevelFormService.submitVhncForm(dto); + Boolean isSaved = villageLevelFormService.saveVhncForm(dto); boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); @@ -88,11 +88,11 @@ public ResponseEntity> submitVhncForm(@RequestBody VhncDto d } @RequestMapping(value = "phc/saveAll", method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> submitPhcForm(@RequestBody PhcReviewMeetingDTO dto) { + public ResponseEntity> savePhcForm(@RequestBody PhcReviewMeetingDTO dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { - Boolean isSaved = villageLevelFormService.submitPhcForm(dto); + Boolean isSaved = villageLevelFormService.savePhcForm(dto); boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); @@ -110,11 +110,11 @@ public ResponseEntity> submitPhcForm(@RequestBody PhcReviewM } @RequestMapping(value = "ahd/saveAll", method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> submitAhdForm(@RequestBody AhdMeetingDto dto) { + public ResponseEntity> saveAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); if(!dto.getEntries().isEmpty()){ - Boolean isSaved = villageLevelFormService.submitAhdForm(dto); + Boolean isSaved = villageLevelFormService.saveAhdForm(dto); boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); @@ -130,11 +130,11 @@ public ResponseEntity> submitAhdForm(@RequestBody AhdMeeting } @RequestMapping(value = "deworming/saveAll", method = RequestMethod.POST, headers = "Authorization") - public ResponseEntity> submitDewormingForm(@RequestBody DewormingDto dto) { + public ResponseEntity> saveDewormingForm(@RequestBody DewormingDto dto) { Map response = new HashMap<>(); if(!dto.getEntries().isEmpty()){ - Boolean isSaved = villageLevelFormService.submitDewormingForm(dto); + Boolean isSaved = villageLevelFormService.saveDewormingForm(dto); boolean ok = isSaved; response.put("status", ok ? "Success" : "Fail"); response.put("statusCode", ok ? 200 : 500); diff --git a/src/main/java/com/iemr/flw/service/VillageLevelFormService.java b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java index 6559603f..2227acaa 100644 --- a/src/main/java/com/iemr/flw/service/VillageLevelFormService.java +++ b/src/main/java/com/iemr/flw/service/VillageLevelFormService.java @@ -31,15 +31,15 @@ @Service public interface VillageLevelFormService { - Boolean submitForm(VhndDto dto); + Boolean saveForm(VhndDto dto); - Boolean submitVhncForm(VhncDto dto); + Boolean saveVhncForm(VhncDto dto); - Boolean submitPhcForm(PhcReviewMeetingDTO dto); + Boolean savePhcForm(PhcReviewMeetingDTO dto); - Boolean submitAhdForm(AhdMeetingDto dto); + Boolean saveAhdForm(AhdMeetingDto dto); - Boolean submitDewormingForm(DewormingDto dto); + Boolean saveDewormingForm(DewormingDto dto); List getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 4c9f0ed5..4808be39 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -71,7 +71,10 @@ public class VillageLevelFormServiceImpl implements VillageLevelFormService { @Override - public Boolean submitForm(VhndDto dto) { + public Boolean saveForm(VhndDto dto) { + if (dto == null || dto.getEntries() == null) { + return false; + } for (VHNDFormDTO vhndFormDTO : dto.getEntries()) { saveVhndFormData(vhndFormDTO, dto.getUserId()); @@ -80,34 +83,43 @@ public Boolean submitForm(VhndDto dto) { } @Override - public Boolean submitVhncForm(VhncDto dto) { + public Boolean saveVhncForm(VhncDto dto) { + if (dto == null || dto.getEntries() == null) { + return false; + } for (VhncFormDTO vhncFormDTO : dto.getEntries()) { - saveVhncFormData(vhncFormDTO, dto.getUserId()); + saveVhncFormData(vhncFormDTO, dto.getUserId()); } return true; } @Override - public Boolean submitPhcForm(PhcReviewMeetingDTO dto) { + public Boolean savePhcForm(PhcReviewMeetingDTO dto) { + if (dto == null || dto.getEntries() == null) { + return false; + } for (PhcReviewMeetingFormDTO phcReviewMeetingDTO : dto.getEntries()) { - submitPhcForm(phcReviewMeetingDTO, dto.getUserId()); + savePhcForm(phcReviewMeetingDTO, dto.getUserId()); } return true; } @Override - public Boolean submitAhdForm(AhdMeetingDto dto) { + public Boolean saveAhdForm(AhdMeetingDto dto) { + if (dto == null || dto.getEntries() == null) { + return false; + } for (AhDMeetingFormDTO ahDMeetingFormDTO : dto.getEntries()) { - submitAhdForm(ahDMeetingFormDTO, dto.getUserId()); + saveAhdForm(ahDMeetingFormDTO, dto.getUserId()); } return true; } @Override - public Boolean submitDewormingForm(DewormingDto dto) { + public Boolean saveDewormingForm(DewormingDto dto) { for (DewormingFormDTO dewormingFormDTO : dto.getEntries()) { - submitDewormingForm(dewormingFormDTO, dto.getUserId()); + saveDewormingForm(dewormingFormDTO, dto.getUserId()); } return true; } @@ -129,7 +141,7 @@ private Boolean saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { } - private Boolean submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { + private Boolean savePhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { PHCReviewForm phcReviewForm = new PHCReviewForm(); phcReviewForm.setUserId(Long.valueOf(userID)); phcReviewForm.setPhcReviewDate(dto.getPhcReviewDate()); @@ -144,7 +156,7 @@ private Boolean submitPhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { return true; } - private Boolean submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { + private Boolean saveAhdForm(AhDMeetingFormDTO dto, Integer userID) { AHDForm ahdForm = new AHDForm(); ahdForm.setUserId(Long.valueOf(userID)); ahdForm.setMobilizedForAHD(dto.getMobilizedForAHD()); @@ -162,7 +174,7 @@ private Boolean submitAhdForm(AhDMeetingFormDTO dto, Integer userID) { return true; } - private Boolean submitDewormingForm(DewormingFormDTO dto, Integer userID) { + private Boolean saveDewormingForm(DewormingFormDTO dto, Integer userID) { DewormingForm dewormingForm = new DewormingForm(); dewormingForm.setUserId(Long.valueOf(userID)); dewormingForm.setDewormingDone(dto.getDewormingDone()); From a233e7045bf4aaae5cab4465e013101d08df22d9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Jun 2025 14:26:21 +0530 Subject: [PATCH 129/792] Add GPL license --- .../java/com/iemr/flw/domain/iemr/IncentiveActivity.java | 1 + src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java index 1368fe04..0c032650 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivity.java @@ -57,4 +57,5 @@ public class IncentiveActivity { @Column(name = "is_deleted") private Boolean isDeleted; + } diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index ff169687..e7157096 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -17,8 +17,8 @@ public interface IncentivesRepo extends JpaRepository { @Query("select inc from IncentiveActivity inc where inc.name = :name and inc.group = :group and inc.isDeleted = false") IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); -// @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") -// IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); -// -// List getByUserId(Integer ashaId, Timestamp fromDate, Timestamp toDate); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") + IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); + + List getByUserId(Integer ashaId, Timestamp fromDate, Timestamp toDate); } From 353c8fef90cd56533a45e4257c522ccb049bdbfe Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 21 Jun 2025 10:10:00 +0530 Subject: [PATCH 130/792] Fix POM.xml format issue --- pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/pom.xml b/pom.xml index f2a7d506..0af26e8c 100644 --- a/pom.xml +++ b/pom.xml @@ -134,7 +134,6 @@ 2.17.0 - io.jsonwebtoken From 9885940638eb75800f63688e7ad4ba912547b80d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 21 Jun 2025 10:21:11 +0530 Subject: [PATCH 131/792] Fix POM.xml format issue --- pom.xml | 279 +++++++++--------- .../flw/repo/iemr/EmployeeMasterRepo.java | 8 - .../iemr/flw/utils/JwtAuthenticationUtil.java | 18 +- .../flw/utils/JwtUserIdValidationFilter.java | 48 +-- src/main/java/com/iemr/flw/utils/JwtUtil.java | 69 +---- 5 files changed, 145 insertions(+), 277 deletions(-) diff --git a/pom.xml b/pom.xml index 0af26e8c..3cbdbc6a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,39 +1,39 @@ - 4.0.0 + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.iemr.common.flw - flw-api - 3.1.0 - war + com.iemr.common.flw + flw-api + 3.1.0 + war - FLW-API - Iemr Flw Service + FLW-API + Iemr Flw Service - - org.springframework.boot - spring-boot-starter-parent - 3.2.2 - - - - UTF-8 - UTF-8 - ${maven.build.timestamp} - yyyy-MM-dd HH:mm - 17 - jdt_apt - 1.2.0.Final - 1.16.18 - local - target/classes/application.properties - target/classes/common_${environment}.properties - true - target - - + + org.springframework.boot + spring-boot-starter-parent + 3.2.2 + + + + UTF-8 + UTF-8 + ${maven.build.timestamp} + yyyy-MM-dd HH:mm + 17 + jdt_apt + 1.2.0.Final + 1.16.18 + ${ENV_VAR} + target/classes/application.properties + target/classes/common_${environment}.properties + true + target + + org.springframework.boot spring-boot-starter-data-jpa @@ -56,10 +56,10 @@ org.springframework.boot spring-boot-starter - - co.elastic.logging - logback-ecs-encoder - 1.3.2 + + co.elastic.logging + logback-ecs-encoder + 1.3.2 org.springframework.boot @@ -133,21 +133,6 @@ jackson-datatype-joda 2.17.0 - - - - io.jsonwebtoken - jjwt-api - 0.12.6 - - - - io.jsonwebtoken - jjwt-impl - 0.12.6 - runtime - - @@ -249,10 +234,10 @@ tomcat-jdbc - org.modelmapper - modelmapper - 2.4.4 - + org.modelmapper + modelmapper + 2.4.4 + @@ -269,56 +254,56 @@ - - - 1097_flw - - 1097flwapi-v1.0 - target/classes/application.properties - src/main/environment/1097_${environment}.properties - - - 1097flwapi-v1.0 - - - + + + 1097_flw + + 1097flwapi-v1.0 + target/classes/application.properties + src/main/environment/1097_${environment}.properties + + + 1097flwapi-v1.0 + + + - - ${artifactId}-${version} - + + ${artifactId}-${version} + - - org.apache.maven.plugins - maven-jar-plugin - 3.0.2 - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - ${java.version} - ${java.version} - - - org.projectlombok - lombok - ${lombok.version} - - - org.mapstruct - mapstruct-processor - ${org.mapstruct.version} - - - - + + org.apache.maven.plugins + maven-jar-plugin + 3.0.2 + + + org.springframework.boot + spring-boot-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + ${java.version} + ${java.version} + + + org.projectlombok + lombok + ${lombok.version} + + + org.mapstruct + mapstruct-processor + ${org.mapstruct.version} + + + + org.apache.maven.plugins maven-resources-plugin @@ -345,31 +330,31 @@ - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - process-resources - - run - - properties-updated - - - - concatinating properties file ${target-properties} and - ${source-properties} - - - - - - - - + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + process-resources + + run + + properties-updated + + + + concatinating properties file ${target-properties} and + ${source-properties} + + + + + + + + process-resources @@ -384,16 +369,16 @@ - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - + + io.jsonwebtoken + jjwt-jackson + 0.12.6 + runtime + diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index 7cc17200..fcefd712 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -89,7 +89,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo if (jwtToken != null) { logger.info("Validating JWT token from cookie"); - if (jwtAuthenticationUtil.validateUserIdAndJwtToken(jwtFromCookie)) { + if (jwtAuthenticationUtil.validateUserIdAndJwtToken(jwtToken)) { AuthorizationHeaderRequestWrapper authorizationHeaderRequestWrapper = new AuthorizationHeaderRequestWrapper( request, ""); diff --git a/src/main/java/com/iemr/flw/utils/redis/RedisConfig.java b/src/main/java/com/iemr/flw/utils/redis/RedisConfig.java index 873a6fc9..0a279319 100644 --- a/src/main/java/com/iemr/flw/utils/redis/RedisConfig.java +++ b/src/main/java/com/iemr/flw/utils/redis/RedisConfig.java @@ -4,13 +4,25 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import com.iemr.flw.domain.iemr.M_User; @Configuration public class RedisConfig { @Bean - public RedisTemplate redisTemplate(RedisConnectionFactory connectionFactory) { - RedisTemplate template = new RedisTemplate<>(); - template.setConnectionFactory(connectionFactory); - return template; - } + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + RedisTemplate template = new RedisTemplate<>(); + template.setConnectionFactory(factory); + + // Use StringRedisSerializer for keys (userId) + template.setKeySerializer(new StringRedisSerializer()); + + // Use Jackson2JsonRedisSerializer for values (Users objects) + Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer<>(M_User.class); + template.setValueSerializer(serializer); + + return template; + } } From bf3b4935f11389e6afb49c679fbbbd92a2569a63 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Sep 2025 18:35:24 +0530 Subject: [PATCH 309/792] add column in pnc and incentive --- .../com/iemr/flw/domain/iemr/PNCVisit.java | 15 +++++ .../com/iemr/flw/dto/iemr/PNCVisitDTO.java | 6 ++ .../impl/MaternalHealthServiceImpl.java | 64 +++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java index 2ff6c24c..08fe54b0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java @@ -79,4 +79,19 @@ public class PNCVisit { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "steilisation_date") + private Timestamp steilisationDate; + + @Column(name = "delivery_discharge_summary_image1") + private String deliveryDischargeSummary1; + + @Column(name = "delivery_discharge_summary_image2") + private String deliveryDischargeSummary2; + + @Column(name = "delivery_discharge_summary_image3") + private String deliveryDischargeSummary3; + + @Column(name = "delivery_discharge_summary_image3") + private String deliveryDischargeSummary4; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PNCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PNCVisitDTO.java index a1a4ad27..9bfc4fc7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PNCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PNCVisitDTO.java @@ -29,4 +29,10 @@ public class PNCVisitDTO { private String createdBy; private Timestamp updatedDate; private String updatedBy; + private Timestamp sterilisationDate; + private String deliveryDischargeSummary1; + private String deliveryDischargeSummary2; + private String deliveryDischargeSummary3; + private String deliveryDischargeSummary4; + } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 3039a682..99d96c96 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -303,6 +303,7 @@ public String savePNCVisit(List pncVisitDTOs) { pncCare.setLastModDate(it.getUpdatedDate()); pncCare.setProcessed("N"); pncCareList.add(pncCare); + checkAndAddAntaraIncentive(pncList,pncVisit); } pncList.add(pncVisit); }); @@ -316,6 +317,69 @@ public String savePNCVisit(List pncVisitDTOs) { return null; } + private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) { + Integer userId = userRepo.getUserIdByName(ect.getCreatedBy()); + logger.info("ContraceptionMethod:"+ect.getContraceptionMethod()); + if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")){ + + IncentiveActivity maleSterilizationActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", "FAMILY PLANNING"); + if (maleSterilizationActivity != null) { + addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); + } + }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("FEMALE STERILIZATION")){ + + IncentiveActivity femaleSterilizationActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", "FAMILY PLANNING"); + if (femaleSterilizationActivity != null) { + addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); + } + }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MiniLap")){ + + IncentiveActivity miniLapActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MINILAP", "FAMILY PLANNING"); + if (miniLapActivity != null) { + addIncenticeRecord(recordList, ect, userId, miniLapActivity); + } + }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Condom")){ + + IncentiveActivity comdomActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); + if (comdomActivity != null) { + addIncenticeRecord(recordList, ect, userId, comdomActivity); + } + }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Copper T (IUCD)")){ + + IncentiveActivity copperTActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); + if (copperTActivity != null) { + addIncenticeRecord(recordList, ect, userId, copperTActivity); + } + } + } + + private void addIncenticeRecord(List recordList, PNCVisit ect, Integer userId, IncentiveActivity antaraActivity) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(antaraActivity.getId(), ect.getCreatedDate(), ect.getBenId()); + // get bene details + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(antaraActivity.getId()); + record.setCreatedDate(ect.getPncDate()); + record.setCreatedBy(ect.getCreatedBy()); + record.setStartDate(ect.getPncDate()); + record.setEndDate(ect.getPncDate()); + record.setUpdatedDate(ect.getPncDate()); + record.setUpdatedBy(ect.getCreatedBy()); + record.setBenId(ect.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(antaraActivity.getRate())); + recordRepo.save(record); + } + } + + private void checkAndAddIncentives(List ancList) { IncentiveActivity anc1Activity = From 6b8c2f05bb74df9588566b055dbf06c2cfd1ad14 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 1 Oct 2025 17:05:01 +0530 Subject: [PATCH 310/792] add column in pnc and incentive --- src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java | 2 +- .../iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java index 08fe54b0..e06c243a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java @@ -92,6 +92,6 @@ public class PNCVisit { @Column(name = "delivery_discharge_summary_image3") private String deliveryDischargeSummary3; - @Column(name = "delivery_discharge_summary_image3") + @Column(name = "delivery_discharge_summary_image4") private String deliveryDischargeSummary4; } diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index c943e983..107a7914 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -56,6 +56,7 @@ public class DeliveryOutcomeServiceImpl implements DeliveryOutcomeService { @Autowired private HouseHoldRepo houseHoldRepo; + private boolean isJsyBeneficiary; private Gson gson = new Gson(); @@ -124,7 +125,10 @@ public void checkAndAddJsyIncentive(List delOutList){ // Determine delivery number int deliveryNumber = deliveryOutcome.getDeliveryOutcome(); // 1,2,3,4 - boolean isJsyBeneficiary = deliveryOutcome.getIsJSYBenificiary(); + if(deliveryOutcome.getIsJSYBenificiary()!=null){ + isJsyBeneficiary = deliveryOutcome.getIsJSYBenificiary(); + + } if(deliveryOutcome.getPlaceOfDelivery()!=null && !deliveryOutcome.getPlaceOfDelivery().isEmpty()){ institutionalDelivery = true; From 613e576aae264126ccd25309907840de5527c80f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 1 Oct 2025 17:39:57 +0530 Subject: [PATCH 311/792] add column in pnc and incentive --- .../iemr/IncentiveActivityLangMapping.java | 23 +++---------------- .../com/iemr/flw/domain/iemr/PNCVisit.java | 2 +- .../service/impl/IncentiveServiceImpl.java | 11 +++++++++ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityLangMapping.java b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityLangMapping.java index 1dd3ad6d..0c81338c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityLangMapping.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityLangMapping.java @@ -26,39 +26,22 @@ public class IncentiveActivityLangMapping { @Column(name = "rate_per_activity") private Integer rate; - @Column(name = "state_code") - private Integer state; - - @Column(name = "district_code") - private Integer district; - @Column(name = "group_name") private String group; - @Column(name = "fmr_code") - private String fmrCode; - - @Column(name = "fmr_code_old") - private String fmrCodeOld; - @Column(name = "created_date") private Timestamp createdDate; - @Column(name = "created_by") - private String createdBy; @Column(name = "updated_date") private Timestamp updatedDate; - @Column(name = "updated_by") - private String updatedBy; - - @Column(name = "is_deleted") - private Boolean isDeleted; - @Column(name = "assame_activity_description") private String assameActivityDescription; + @Column(name = "hindi_activity_description") + private String hindiActivityDescription; + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java index e06c243a..04eb6f4a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PNCVisit.java @@ -81,7 +81,7 @@ public class PNCVisit { private String updatedBy; @Column(name = "steilisation_date") - private Timestamp steilisationDate; + private Timestamp sterilisationDate; @Column(name = "delivery_discharge_summary_image1") private String deliveryDischargeSummary1; diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 26d324d0..6c7c9f70 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -83,6 +83,8 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { IncentiveActivityLangMapping mapping = incentiveActivityLangMappingRepo .findByIdAndName(inc.getId(),inc.getName()); + + if (mapping != null) { dto.setName(mapping.getName()); dto.setGroupName(mapping.getGroup()); @@ -98,6 +100,15 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { } + }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "hi")){ + if(mapping.getHindiActivityDescription()!=null){ + dto.setDescription(mapping.getHindiActivityDescription()); + + }else { + dto.setDescription(mapping.getDescription()); + + } + } }else { From 91d40c3c3a39d1dd71f25e89106ba7b9b0bf5f12 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 3 Oct 2025 17:31:01 +0530 Subject: [PATCH 312/792] Backend api for Saas Bahu Sammelan Recording & Incentive Calculation --- .../flw/controller/SammelanController.java | 43 +++++++ .../flw/domain/iemr/SammelanAttachment.java | 28 ++++ .../iemr/flw/domain/iemr/SammelanRecord.java | 52 ++++++++ .../com/iemr/flw/dto/iemr/AttachmentDTO.java | 41 ++++++ .../iemr/flw/dto/iemr/SammelanRequestDTO.java | 17 +++ .../flw/dto/iemr/SammelanResponseDTO.java | 19 +++ .../iemr/SammelanAttachmentRepository.java | 14 ++ .../repo/iemr/SammelanRecordRepository.java | 18 +++ .../com/iemr/flw/service/SammelanService.java | 25 ++++ .../flw/service/impl/SammelanServiceImpl.java | 121 ++++++++++++++++++ 10 files changed, 378 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/SammelanController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AttachmentDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/SammelanAttachmentRepository.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java create mode 100644 src/main/java/com/iemr/flw/service/SammelanService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java new file mode 100644 index 00000000..3b822c7e --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -0,0 +1,43 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.service.SammelanService; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Limit; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +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.util.List; + +@RestController +@RequestMapping("sammelans") +public class SammelanController { + @Autowired + private SammelanService service; + + + + @RequestMapping(value = "saveAll",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity create( + @RequestPart("payload") @Valid SammelanRequestDTO payload, + @RequestPart(value = "files", required = false) MultipartFile[] files) { + + + SammelanResponseDTO resp = service.submitSammelan(payload); + return ResponseEntity.status(HttpStatus.CREATED).body(resp); + } + + + @RequestMapping(value = "getAll") + public List sammelanlist(@RequestParam Integer ashaId) { + return service.getSammelanHistory(ashaId); + } +} + diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java new file mode 100644 index 00000000..75db2258 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java @@ -0,0 +1,28 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "sammelan_attachment") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SammelanAttachment { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "sammelan_id", nullable = false) + private SammelanRecord sammelanRecord; + + + private String fileName; + private String fileType; + private Long fileSize; + private String storagePath; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java new file mode 100644 index 00000000..7d810544 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -0,0 +1,52 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.List; + +@Entity +@Table(name = "sammelan_record", + uniqueConstraints = @UniqueConstraint(name = "uk_asha_month", columnNames = {"asha_id", "meeting_date"})) +@Data +@NoArgsConstructor +@AllArgsConstructor +public class SammelanRecord { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + + @Column(name = "asha_id", nullable = false) + private Integer ashaId; + + + @Column(name = "meeting_date", nullable = false) + private Timestamp meetingDate; + + + @Column(nullable = false) + private String place; + + + @Column(nullable = false, name = "participants") + private int participants; + + + @Column(columnDefinition = "TEXT", name = "remarks") + private String remarks; + + @Column(name = "created_by") + private String createdBy; + + @Column(name = "created_date") + private Timestamp createdDate; + + @OneToMany(mappedBy = "sammelanRecord", cascade = CascadeType.ALL, orphanRemoval = true) + private List attachments = new ArrayList<>(); +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/AttachmentDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AttachmentDTO.java new file mode 100644 index 00000000..1ab382ca --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AttachmentDTO.java @@ -0,0 +1,41 @@ +package com.iemr.flw.dto.iemr; + +public class AttachmentDTO { + + private String fileName; // e.g. "meeting_photo1.jpg" + private String fileType; // e.g. "image/jpeg", "image/png", "application/pdf" + private Long fileSize; // size in bytes + + public AttachmentDTO() { + } + + public AttachmentDTO(String fileName, String fileType, Long fileSize) { + this.fileName = fileName; + this.fileType = fileType; + this.fileSize = fileSize; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } + + public String getFileType() { + return fileType; + } + + public void setFileType(String fileType) { + this.fileType = fileType; + } + + public Long getFileSize() { + return fileSize; + } + + public void setFileSize(Long fileSize) { + this.fileSize = fileSize; + } +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java new file mode 100644 index 00000000..4c10c936 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.List; +@Data +public class SammelanRequestDTO { + + private Integer ashaId; // ASHA worker ID + private Timestamp date; // Meeting date + private String place; // Dropdown: HWC / Anganwadi Centre / Community Center + private Integer participants; // Number of participants attended + private List attachments; // Min 2, Max 5 files + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java new file mode 100644 index 00000000..7760cdc7 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java @@ -0,0 +1,19 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Timestamp; +import java.time.LocalDate; +@Data +public class SammelanResponseDTO { + + private Long id; + private Integer ashaId; + private Timestamp date; + private String place; + private Integer participants; + private Double incentiveAmount; + private String incentiveStatus; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/SammelanAttachmentRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SammelanAttachmentRepository.java new file mode 100644 index 00000000..9563e986 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/SammelanAttachmentRepository.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.SammelanAttachment; +import com.iemr.flw.domain.iemr.SammelanRecord; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SammelanAttachmentRepository extends JpaRepository { + + List findBySammelanRecord(SammelanRecord record); +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java new file mode 100644 index 00000000..93e8c2c6 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java @@ -0,0 +1,18 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.SammelanRecord; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.time.LocalDate; +import java.util.List; + +@Repository +public interface SammelanRecordRepository extends JpaRepository { + + // Check if ASHA has already submitted record in same month + boolean existsByAshaIdAndMeetingDateBetween(Integer ashaId, LocalDate startDate, LocalDate endDate); + + // Fetch history + List findByAshaIdOrderByMeetingDateDesc(Integer ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/SammelanService.java b/src/main/java/com/iemr/flw/service/SammelanService.java new file mode 100644 index 00000000..419bd4d3 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/SammelanService.java @@ -0,0 +1,25 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.*; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +public interface SammelanService { + /** + * Submit a new Saas Bahu Sammelan record + * @param dto request data + * @return saved SammelanResponseDTO with incentive details + */ + SammelanResponseDTO submitSammelan(SammelanRequestDTO dto); + + /** + * Fetch Sammelan history for given ASHA worker + * @param ashaId ASHA worker ID + * @return list of past SammelanResponseDTO + */ + List getSammelanHistory(Integer ashaId); + +} diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java new file mode 100644 index 00000000..dd8febfd --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -0,0 +1,121 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.SammelanAttachment; +import com.iemr.flw.domain.iemr.SammelanRecord; +import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.repo.iemr.SammelanAttachmentRepository; +import com.iemr.flw.repo.iemr.SammelanRecordRepository; +import com.iemr.flw.service.SammelanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.time.ZoneId; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class SammelanServiceImpl implements SammelanService { + @Autowired + private SammelanRecordRepository recordRepo; + @Autowired + private SammelanAttachmentRepository attachmentRepo; + + private SammelanRecord record; + + + + @Override + public SammelanResponseDTO submitSammelan(SammelanRequestDTO dto) { + validateRequest(dto); + LocalDate localDate = dto.getDate().toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + + YearMonth ym = YearMonth.from(localDate); + + // Check for existing record in same month + boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( + dto.getAshaId(), + ym.atDay(1), + ym.atEndOfMonth() + ); + if (exists) { + throw new IllegalArgumentException("Sammelan already submitted for this month."); + } + + // Save Sammelan record + record = new SammelanRecord(); + record.setAshaId(dto.getAshaId()); + record.setMeetingDate(dto.getDate()); + record.setPlace(dto.getPlace()); + record.setParticipants(dto.getParticipants()); + record = recordRepo.save(record); + + // Save Attachments + if (dto.getAttachments() != null) { + List attachments = dto.getAttachments().stream().map(a -> { + SammelanAttachment att = new SammelanAttachment(); + att.setSammelanRecord(record); + att.setFileName(a.getFileName()); + att.setFileType(a.getFileType()); + att.setFileSize(a.getFileSize()); + return att; + }).collect(Collectors.toList()); + attachmentRepo.saveAll(attachments); + record.setAttachments(attachments); + } + + // Save incentive audit + + + // Prepare Response DTO + SammelanResponseDTO response = new SammelanResponseDTO(); + response.setId(record.getId()); + response.setAshaId(record.getAshaId()); + response.setDate(record.getMeetingDate()); + response.setPlace(record.getPlace()); + response.setParticipants(record.getParticipants()); + + return response; + } + + @Override + public List getSammelanHistory(Integer ashaId) { + List records = recordRepo.findByAshaIdOrderByMeetingDateDesc(ashaId); + return records.stream().map(record -> { + SammelanResponseDTO dto = new SammelanResponseDTO(); + dto.setId(record.getId()); + dto.setAshaId(record.getAshaId()); + dto.setDate(record.getMeetingDate()); + dto.setPlace(record.getPlace()); + dto.setParticipants(record.getParticipants()); + + return dto; + }).collect(Collectors.toList()); + } + + private void validateRequest(SammelanRequestDTO dto) { + LocalDate date = dto.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + + if (date == null) { + throw new IllegalArgumentException("Date is mandatory."); + } + if (date.isAfter(LocalDate.now())) { + throw new IllegalArgumentException("Date cannot be in future."); + } + if (date.isBefore(LocalDate.now().minusMonths(2))) { + throw new IllegalArgumentException("Backdate not allowed beyond 2 months."); + } + if (dto.getParticipants() < 0 || dto.getParticipants() > 999) { + throw new IllegalArgumentException("Participants must be between 0–999."); + } + if (dto.getAttachments() == null || dto.getAttachments().size() < 2) { + throw new IllegalArgumentException("Minimum 2 attachments required."); + } + if (dto.getAttachments().size() > 5) { + throw new IllegalArgumentException("Maximum 5 attachments allowed."); + } + } +} From 21eb654b51c16aa8a822de8510d9c8732a6bc6ed Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 3 Oct 2025 17:39:50 +0530 Subject: [PATCH 313/792] Backend api for Saas Bahu Sammelan Recording & Incentive Calculation --- .../java/com/iemr/flw/controller/SammelanController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 3b822c7e..0f23ef6e 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -17,14 +17,14 @@ import java.util.List; @RestController -@RequestMapping("sammelans") +@RequestMapping(value = "/sammelans") public class SammelanController { @Autowired private SammelanService service; - @RequestMapping(value = "saveAll",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @RequestMapping(value = "saveAll",consumes = MediaType.MULTIPART_FORM_DATA_VALUE,method = RequestMethod.POST) public ResponseEntity create( @RequestPart("payload") @Valid SammelanRequestDTO payload, @RequestPart(value = "files", required = false) MultipartFile[] files) { @@ -35,7 +35,7 @@ public ResponseEntity create( } - @RequestMapping(value = "getAll") + @RequestMapping(value = "getAll",method = RequestMethod.GET) public List sammelanlist(@RequestParam Integer ashaId) { return service.getSammelanHistory(ashaId); } From 4350330b0effbf801866ab79532be21497aa0902 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 6 Oct 2025 12:45:19 +0530 Subject: [PATCH 314/792] Update IncentiveServiceImpl.java --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 6c7c9f70..9ad9a4d8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -143,6 +143,9 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { String beneName = rmnchBeneficiaryDetails.getFirstName()+" "+rmnchBeneficiaryDetails.getLastName(); entry.setName(beneName); + }else{ + entry.setName(""); + } } From 24cf1050b119143a686c1686b95bff5d52bbb8d6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 6 Oct 2025 14:31:51 +0530 Subject: [PATCH 315/792] Update PaymentParam.java --- src/main/java/com/iemr/flw/utils/PaymentParam.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/iemr/flw/utils/PaymentParam.java b/src/main/java/com/iemr/flw/utils/PaymentParam.java index 01b73b33..914f764a 100644 --- a/src/main/java/com/iemr/flw/utils/PaymentParam.java +++ b/src/main/java/com/iemr/flw/utils/PaymentParam.java @@ -9,4 +9,7 @@ public enum PaymentParam { SECOND_DOSE_PER_ASHA, THIRD_DOSE_PER_ASHA, FOURTH_DOSE_PER_ASHA, + PER_NET, + PER_VISIT, + PER_YEAR, } From 5d510489a00713db8098d17ba2531c83c5e0e339 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 15:57:50 +0530 Subject: [PATCH 316/792] maa-meeting api --- .../flw/controller/MaaMeetingController.java | 63 +++++++++++++ .../com/iemr/flw/domain/iemr/MaaMeeting.java | 40 +++++++++ .../dto/iemr/MaaMeetingListResponseDTO.java | 12 +++ .../flw/dto/iemr/MaaMeetingRequestDTO.java | 15 ++++ .../flw/dto/iemr/MaaMeetingResponseDTO.java | 35 ++++++++ .../flw/repo/iemr/MaaMeetingRepository.java | 9 ++ .../iemr/flw/service/MaaMeetingService.java | 90 +++++++++++++++++++ 7 files changed, 264 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/MaaMeetingController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MaaMeetingListResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java create mode 100644 src/main/java/com/iemr/flw/service/MaaMeetingService.java diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java new file mode 100644 index 00000000..b4cdc6cc --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -0,0 +1,63 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.domain.iemr.MaaMeeting; +import com.iemr.flw.dto.iemr.MaaMeetingListResponseDTO; +import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; +import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; +import com.iemr.flw.service.MaaMeetingService; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("maa-meetings") +public class MaaMeetingController { + + + private final MaaMeetingService service; + + public MaaMeetingController(MaaMeetingService service) { + this.service = service; + } + + @PostMapping("/saveAll") + public ResponseEntity saveMeeting(@ModelAttribute List dto) { + try { + MaaMeeting saved = service.saveMeeting(dto); + return ResponseEntity.ok(saved); + } catch (Exception e) { + return ResponseEntity.badRequest().body(e.getMessage()); + } + } + + @GetMapping("/getAll") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = MaaMeetingListResponseDTO.class))), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + public ResponseEntity getMeetings() { + MaaMeetingListResponseDTO response = new MaaMeetingListResponseDTO(); + + try { + response.setData(service.getAllMeetings()); + response.setStatusCode(200); + response.setStatus("Success"); + return ResponseEntity.ok(response); + } catch (Exception e) { + response.setStatusCode(500); + response.setStatus("Something went wrong"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java new file mode 100644 index 00000000..fe5a477c --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -0,0 +1,40 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; + +@Entity +@Data +@Table(name = "maa_meeting", schema = "db_iemr") +public class MaaMeeting { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "meeting_date") + private LocalDate meetingDate; + + @Column(name = "place") + private String place; + + @Column(name = "participants") + private Integer participants; + + @Column(name = "quarter") + private Integer quarter; + + @Column(name = "year") + private Integer year; + + @Column(name = "asha_id") + private Long ashaId; + + // Store multiple images as JSON of base64 strings + @Lob + @Column(name = "meeting_images", columnDefinition = "LONGTEXT") + private String meetingImagesJson; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingListResponseDTO.java new file mode 100644 index 00000000..ad2a0f37 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingListResponseDTO.java @@ -0,0 +1,12 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; + +@Data +public class MaaMeetingListResponseDTO { + private List data; + private Integer statusCode; + private String status; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java new file mode 100644 index 00000000..0162b026 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.time.LocalDate; + +@Data +public class MaaMeetingRequestDTO { + private LocalDate meetingDate; + private String place; + private Integer participants; + private MultipartFile[] meetingImages; // up to 5 images + private Long ashaId; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java new file mode 100644 index 00000000..3dd21de9 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -0,0 +1,35 @@ +package com.iemr.flw.dto.iemr; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class MaaMeetingResponseDTO { + @Schema(description = "Unique ID of the meeting", example = "1") + private Long id; + + @Schema(description = "Date of the meeting", example = "2025-09-06") + private LocalDate meetingDate; + + @Schema(description = "Place of the meeting", example = "HWC") + private String place; + + @Schema(description = "Number of participants attended", example = "25") + private Integer participants; + + @Schema(description = "Quarter of the year", example = "3") + private Integer quarter; + + @Schema(description = "Year of the meeting", example = "2025") + private Integer year; + + @Schema(description = "ID of ASHA", example = "963") + private Long ashaId; + + @Schema(description = "Meeting images in base64 array", + example = "[\"iVBORw0KGgoAAAANSUhEUgAA...\", \"iVBORw0KGgoAAAANSUhEUgBB...\"]") + private List meetingImages; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java new file mode 100644 index 00000000..6e792226 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java @@ -0,0 +1,9 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.MaaMeeting; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MaaMeetingRepository extends JpaRepository { +} diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java new file mode 100644 index 00000000..4143a334 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -0,0 +1,90 @@ +package com.iemr.flw.service; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.MaaMeeting; +import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; +import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; +import com.iemr.flw.repo.iemr.MaaMeetingRepository; +import org.springframework.stereotype.Service; + +import java.util.Base64; +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class MaaMeetingService { + + private final MaaMeetingRepository repository; + private final ObjectMapper objectMapper; + + public MaaMeetingService(MaaMeetingRepository repository, ObjectMapper objectMapper) { + this.repository = repository; + this.objectMapper = objectMapper; + } + + public MaaMeeting saveMeeting(List dto) throws Exception { + MaaMeeting meeting = new MaaMeeting(); + dto.forEach(maaMeetingRequestDTO -> { + meeting.setMeetingDate(maaMeetingRequestDTO.getMeetingDate()); + meeting.setPlace(maaMeetingRequestDTO.getPlace()); + meeting.setParticipants(maaMeetingRequestDTO.getParticipants()); + meeting.setAshaId(maaMeetingRequestDTO.getAshaId()); + + // Convert images to Base64 + if (maaMeetingRequestDTO.getMeetingImages() != null && maaMeetingRequestDTO.getMeetingImages().length > 0) { + List base64Images = List.of(maaMeetingRequestDTO.getMeetingImages()) + .stream() + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = null; + try { + imagesJson = objectMapper.writeValueAsString(base64Images); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + meeting.setMeetingImagesJson(imagesJson); + } + } + ); + + + return repository.save(meeting); + } + + public List getAllMeetings() throws Exception { + List meetings = repository.findAll(); + return meetings.stream().map(meeting -> { + MaaMeetingResponseDTO dto = new MaaMeetingResponseDTO(); + dto.setId(meeting.getId()); + dto.setMeetingDate(meeting.getMeetingDate()); + dto.setPlace(meeting.getPlace()); + dto.setParticipants(meeting.getParticipants()); + dto.setAshaId(meeting.getAshaId()); + + try { + if (meeting.getMeetingImagesJson() != null) { + List images = objectMapper.readValue( + meeting.getMeetingImagesJson(), + new TypeReference>() { + } + ); + dto.setMeetingImages(images); + } + } catch (Exception e) { + dto.setMeetingImages(List.of()); + } + + return dto; + }).collect(Collectors.toList()); + } +} From 2090eeb7b68dc60c89732faf1387e531ec1d6ba1 Mon Sep 17 00:00:00 2001 From: Amoghavarsh <93114621+5Amogh@users.noreply.github.com> Date: Mon, 6 Oct 2025 16:00:21 +0530 Subject: [PATCH 317/792] Update common_docker.properties --- src/main/environment/common_docker.properties | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 3ab42ff2..cb3a613a 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -15,8 +15,8 @@ secondary.datasource.password=${DATABASE_IDENTITY_PASSWORD} secondary.datasource.url=${DATABASE_IDENTITY_URL} secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=false -springdoc.swagger-ui.enabled=false +springdoc.api-docs.enabled=true +springdoc.swagger-ui.enabled=true #ELK logging file name logging.path=logs/ @@ -32,4 +32,5 @@ send-sms=${SEND_SMS} source-address=${SMS_CONSENT_SOURCE_ADDRESS} sms-username=${SMS_USERNAME} sms-password=${SMS_PASSWORD} -send-message-url=${SMS_MESSAGE_URL} \ No newline at end of file + +send-message-url=${SMS_MESSAGE_URL} From 74bedd6853bfe12fbe333e33ba006163b54c89f2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 16:50:59 +0530 Subject: [PATCH 318/792] fix param issue --- .../flw/controller/SammelanController.java | 33 +++- .../flw/domain/iemr/SammelanAttachment.java | 4 +- .../iemr/flw/domain/iemr/SammelanRecord.java | 6 +- .../flw/dto/iemr/SammelanListResponseDTO.java | 12 ++ .../iemr/flw/dto/iemr/SammelanRequestDTO.java | 3 +- .../flw/dto/iemr/SammelanResponseDTO.java | 8 +- .../com/iemr/flw/service/SammelanService.java | 2 +- .../flw/service/impl/SammelanServiceImpl.java | 141 +++++++++++------- 8 files changed, 140 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SammelanListResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 0f23ef6e..541b75c7 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -2,6 +2,10 @@ import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.SammelanService; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; @@ -24,20 +28,35 @@ public class SammelanController { - @RequestMapping(value = "saveAll",consumes = MediaType.MULTIPART_FORM_DATA_VALUE,method = RequestMethod.POST) + @RequestMapping(value = "saveAll",method = RequestMethod.POST) public ResponseEntity create( - @RequestPart("payload") @Valid SammelanRequestDTO payload, - @RequestPart(value = "files", required = false) MultipartFile[] files) { - + @RequestBody @Valid List payload) { SammelanResponseDTO resp = service.submitSammelan(payload); return ResponseEntity.status(HttpStatus.CREATED).body(resp); } - @RequestMapping(value = "getAll",method = RequestMethod.GET) - public List sammelanlist(@RequestParam Integer ashaId) { - return service.getSammelanHistory(ashaId); + @GetMapping("/getAll") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = SammelanListResponseDTO.class))), + @ApiResponse(responseCode = "500", description = "Internal Server Error") + }) + public ResponseEntity getMeetings(@RequestParam Integer ashaId) { + SammelanListResponseDTO response = new SammelanListResponseDTO(); + + try { + response.setData(service.getSammelanHistory(ashaId)); + response.setStatusCode(200); + response.setStatus("Success"); + return ResponseEntity.ok(response); + } catch (Exception e) { + response.setStatusCode(500); + response.setStatus("Something went wrong"); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java index 75db2258..e94dd2bc 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanAttachment.java @@ -23,6 +23,6 @@ public class SammelanAttachment { private String fileName; private String fileType; - private Long fileSize; - private String storagePath; + @Lob + private byte[] fileData; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java index 7d810544..7895bb17 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -47,6 +47,8 @@ public class SammelanRecord { @Column(name = "created_date") private Timestamp createdDate; - @OneToMany(mappedBy = "sammelanRecord", cascade = CascadeType.ALL, orphanRemoval = true) - private List attachments = new ArrayList<>(); + + @Lob + @Column(columnDefinition = "LONGTEXT",name = "attachments") + private String attachments; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanListResponseDTO.java new file mode 100644 index 00000000..12efee50 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanListResponseDTO.java @@ -0,0 +1,12 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.List; +@Data +public class SammelanListResponseDTO { + private List data; + private Integer statusCode; + private String status; + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index 4c10c936..a172baeb 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -1,6 +1,7 @@ package com.iemr.flw.dto.iemr; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; import java.time.LocalDate; @@ -12,6 +13,6 @@ public class SammelanRequestDTO { private Timestamp date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center private Integer participants; // Number of participants attended - private List attachments; // Min 2, Max 5 files + private MultipartFile[] attachments; // up to 5 images } diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java index 7760cdc7..690f10ce 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java @@ -1,9 +1,13 @@ package com.iemr.flw.dto.iemr; +import com.iemr.flw.domain.iemr.SammelanAttachment; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; import java.time.LocalDate; +import java.util.List; + @Data public class SammelanResponseDTO { @@ -12,8 +16,8 @@ public class SammelanResponseDTO { private Timestamp date; private String place; private Integer participants; - private Double incentiveAmount; - private String incentiveStatus; + private List imagePaths; + } diff --git a/src/main/java/com/iemr/flw/service/SammelanService.java b/src/main/java/com/iemr/flw/service/SammelanService.java index 419bd4d3..4aef6689 100644 --- a/src/main/java/com/iemr/flw/service/SammelanService.java +++ b/src/main/java/com/iemr/flw/service/SammelanService.java @@ -13,7 +13,7 @@ public interface SammelanService { * @param dto request data * @return saved SammelanResponseDTO with incentive details */ - SammelanResponseDTO submitSammelan(SammelanRequestDTO dto); + SammelanResponseDTO submitSammelan(List dto); /** * Fetch Sammelan history for given ASHA worker diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index dd8febfd..7b094b3e 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -1,5 +1,8 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.SammelanAttachment; import com.iemr.flw.domain.iemr.SammelanRecord; import com.iemr.flw.dto.iemr.*; @@ -12,73 +15,93 @@ import java.time.LocalDate; import java.time.YearMonth; import java.time.ZoneId; +import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @Service public class SammelanServiceImpl implements SammelanService { @Autowired - private SammelanRecordRepository recordRepo; + private SammelanRecordRepository recordRepo; @Autowired - private SammelanAttachmentRepository attachmentRepo; + private SammelanAttachmentRepository attachmentRepo; private SammelanRecord record; + @Autowired + private ObjectMapper objectMapper; @Override - public SammelanResponseDTO submitSammelan(SammelanRequestDTO dto) { - validateRequest(dto); - LocalDate localDate = dto.getDate().toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - - YearMonth ym = YearMonth.from(localDate); - - // Check for existing record in same month - boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( - dto.getAshaId(), - ym.atDay(1), - ym.atEndOfMonth() - ); - if (exists) { - throw new IllegalArgumentException("Sammelan already submitted for this month."); - } - - // Save Sammelan record - record = new SammelanRecord(); - record.setAshaId(dto.getAshaId()); - record.setMeetingDate(dto.getDate()); - record.setPlace(dto.getPlace()); - record.setParticipants(dto.getParticipants()); - record = recordRepo.save(record); - - // Save Attachments - if (dto.getAttachments() != null) { - List attachments = dto.getAttachments().stream().map(a -> { - SammelanAttachment att = new SammelanAttachment(); - att.setSammelanRecord(record); - att.setFileName(a.getFileName()); - att.setFileType(a.getFileType()); - att.setFileSize(a.getFileSize()); - return att; - }).collect(Collectors.toList()); - attachmentRepo.saveAll(attachments); - record.setAttachments(attachments); - } + public SammelanResponseDTO submitSammelan(List dto) { + SammelanResponseDTO response = new SammelanResponseDTO(); - // Save incentive audit + try { + dto.forEach(sammelanRequestDTO -> { + validateRequest(sammelanRequestDTO); + LocalDate localDate = sammelanRequestDTO.getDate().toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + + YearMonth ym = YearMonth.from(localDate); + + // Check for existing record in same month + boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( + sammelanRequestDTO.getAshaId(), + ym.atDay(1), + ym.atEndOfMonth() + ); + if (exists) { + throw new IllegalArgumentException("Sammelan already submitted for this month."); + } + + // Save Sammelan record + record = new SammelanRecord(); + record.setAshaId(sammelanRequestDTO.getAshaId()); + record.setMeetingDate(sammelanRequestDTO.getDate()); + record.setPlace(sammelanRequestDTO.getPlace()); + record.setParticipants(sammelanRequestDTO.getParticipants()); + record = recordRepo.save(record); + + // Save Attachments + if (sammelanRequestDTO.getAttachments() != null && sammelanRequestDTO.getAttachments().length > 0) { + List base64Images = List.of(sammelanRequestDTO.getAttachments()) + .stream() + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = null; + try { + imagesJson = objectMapper.writeValueAsString(base64Images); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + record.setAttachments(imagesJson); + } + + + // Prepare Response DTO + response.setId(record.getId()); + response.setAshaId(record.getAshaId()); + response.setDate(record.getMeetingDate()); + response.setPlace(record.getPlace()); + response.setParticipants(record.getParticipants()); + }); + + + } catch (Exception e) { + } + return response; - // Prepare Response DTO - SammelanResponseDTO response = new SammelanResponseDTO(); - response.setId(record.getId()); - response.setAshaId(record.getAshaId()); - response.setDate(record.getMeetingDate()); - response.setPlace(record.getPlace()); - response.setParticipants(record.getParticipants()); - return response; } @Override @@ -91,6 +114,18 @@ public List getSammelanHistory(Integer ashaId) { dto.setDate(record.getMeetingDate()); dto.setPlace(record.getPlace()); dto.setParticipants(record.getParticipants()); + try { + if (record.getAttachments() != null) { + List images = objectMapper.readValue( + record.getAttachments(), + new TypeReference>() { + } + ); + dto.setImagePaths(images); + } + } catch (Exception e) { + dto.setImagePaths(List.of()); + } return dto; }).collect(Collectors.toList()); @@ -111,11 +146,9 @@ private void validateRequest(SammelanRequestDTO dto) { if (dto.getParticipants() < 0 || dto.getParticipants() > 999) { throw new IllegalArgumentException("Participants must be between 0–999."); } - if (dto.getAttachments() == null || dto.getAttachments().size() < 2) { + if (dto.getAttachments() == null) { throw new IllegalArgumentException("Minimum 2 attachments required."); } - if (dto.getAttachments().size() > 5) { - throw new IllegalArgumentException("Maximum 5 attachments allowed."); - } + } } From 51f1df20d453cc6d4c69f589eda5e8d7ddd1ad50 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 17:35:21 +0530 Subject: [PATCH 319/792] Pahal Kit Handover changes --- .../domain/iemr/EligibleCoupleRegister.java | 14 +++++++++++ .../iemr/flw/dto/iemr/EligibleCoupleDTO.java | 9 ++++++-- .../flw/service/impl/CoupleServiceImpl.java | 23 +++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index 58fd36bd..b30a6cb0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -3,7 +3,10 @@ import lombok.Data; import jakarta.persistence.*; +import org.springframework.web.multipart.MultipartFile; + import java.sql.Timestamp; +import java.util.List; @Entity @Table(name = "t_eligible_couple_register", schema = "db_iemr") @@ -161,5 +164,16 @@ public class EligibleCoupleRegister { @Column(name = "lmp_date") private String lmpDate; + + @Column(name = "is_kit_handed_over") + private Boolean isKitHandedOver; + + @Column(name = "is_kit_handed_over_date") + private Timestamp kitHandedOverDate; + + + @Lob + @Column(name = "kit_photo", columnDefinition = "LONGTEXT") + private String kitPhoto; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index 3a614f7a..d9f68f67 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -1,6 +1,7 @@ package com.iemr.flw.dto.iemr; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.io.Serializable; import java.sql.Timestamp; @@ -106,8 +107,12 @@ public class EligibleCoupleDTO implements Serializable { private String updatedBy; - - private String lmpDate; + private Boolean isKitHandedOver; + + private Timestamp kitHandedOverDate; + + private MultipartFile [] kitPhoto; + } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 40af4c7a..465b4ffd 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -1,5 +1,6 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -20,6 +21,7 @@ import java.math.BigInteger; import java.util.ArrayList; +import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @@ -70,6 +72,27 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) createIncentiveRecord(recordList, it, activity2); } Long id = existingECR.getId(); + if (it.getKitPhoto() != null && it.getKitPhoto().length > 0) { + List base64Images = List.of(it.getKitPhoto()) + .stream() + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = null; + try { + imagesJson = mapper.writeValueAsString(base64Images); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + existingECR.setKitPhoto(imagesJson); + } modelMapper.map(it, existingECR); existingECR.setId(id); } else { From 36c9e7c97d1aeaef3677ddc3f6b15287512ca042 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 18:17:15 +0530 Subject: [PATCH 320/792] Pahal Kit Handover incentive --- .../flw/service/impl/CoupleServiceImpl.java | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 465b4ffd..ad2c54fe 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -60,7 +60,27 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) EligibleCoupleRegister existingECR = // eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); + if (it.getKitPhoto() != null && it.getKitPhoto().length > 0) { + List base64Images = List.of(it.getKitPhoto()) + .stream() + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + String imagesJson = null; + try { + imagesJson = mapper.writeValueAsString(base64Images); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + existingECR.setKitPhoto(imagesJson); + } if (existingECR != null && null != existingECR.getNumLiveChildren()) { if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity1 = @@ -72,27 +92,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) createIncentiveRecord(recordList, it, activity2); } Long id = existingECR.getId(); - if (it.getKitPhoto() != null && it.getKitPhoto().length > 0) { - List base64Images = List.of(it.getKitPhoto()) - .stream() - .filter(file -> !file.isEmpty()) - .map(file -> { - try { - return Base64.getEncoder().encodeToString(file.getBytes()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); - String imagesJson = null; - try { - imagesJson = mapper.writeValueAsString(base64Images); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - existingECR.setKitPhoto(imagesJson); - } modelMapper.map(it, existingECR); existingECR.setId(id); } else { @@ -100,6 +100,11 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) modelMapper.map(it, existingECR); existingECR.setId(null); } + if(existingECR.getIsKitHandedOver() && !existingECR.getKitPhoto().isEmpty()){ + IncentiveActivity handoverKitActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", "FAMILY PLANNING"); + createIncentiveRecord(recordList, it, handoverKitActivity); + } ecrList.add(existingECR); }); eligibleCoupleRegisterRepo.saveAll(ecrList); From 8652d821fd36898d3c1fc17c8d5250e47140fd32 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 18:28:02 +0530 Subject: [PATCH 321/792] fix code --- src/main/java/com/iemr/flw/controller/MaaMeetingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index b4cdc6cc..e79bdcb4 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -30,7 +30,7 @@ public MaaMeetingController(MaaMeetingService service) { } @PostMapping("/saveAll") - public ResponseEntity saveMeeting(@ModelAttribute List dto) { + public ResponseEntity saveMeeting(@RequestBody List dto) { try { MaaMeeting saved = service.saveMeeting(dto); return ResponseEntity.ok(saved); From 70aea0aa7796ed6c9cf7acc2be9bcec3af8b0b4a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 18:37:38 +0530 Subject: [PATCH 322/792] fix code --- .../flw/controller/MaaMeetingController.java | 12 ++- .../iemr/flw/service/MaaMeetingService.java | 86 ++++++++++++------- 2 files changed, 63 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index e79bdcb4..dabd1b15 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -10,6 +10,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; 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; @@ -29,16 +30,19 @@ public MaaMeetingController(MaaMeetingService service) { this.service = service; } - @PostMapping("/saveAll") - public ResponseEntity saveMeeting(@RequestBody List dto) { + @PostMapping(value = "/saveAll", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity saveMeeting( + @RequestPart("data") List dto, + @RequestPart(value = "files", required = false) List files) { try { - MaaMeeting saved = service.saveMeeting(dto); - return ResponseEntity.ok(saved); + service.saveMeeting(dto, files); + return ResponseEntity.ok("Saved Successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); } } + @GetMapping("/getAll") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 4143a334..3557a624 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -6,16 +6,29 @@ import com.iemr.flw.domain.iemr.MaaMeeting; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.MaaMeetingRepository; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import java.util.ArrayList; import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @Service public class MaaMeetingService { + @Autowired + private IncentivesRepo incentivesRepo; + @Autowired + private UserServiceRoleRepo userRepo; + + @Autowired + private IncentiveRecordRepo recordRepo; private final MaaMeetingRepository repository; private final ObjectMapper objectMapper; @@ -24,43 +37,54 @@ public MaaMeetingService(MaaMeetingRepository repository, ObjectMapper objectMap this.objectMapper = objectMapper; } - public MaaMeeting saveMeeting(List dto) throws Exception { - MaaMeeting meeting = new MaaMeeting(); - dto.forEach(maaMeetingRequestDTO -> { - meeting.setMeetingDate(maaMeetingRequestDTO.getMeetingDate()); - meeting.setPlace(maaMeetingRequestDTO.getPlace()); - meeting.setParticipants(maaMeetingRequestDTO.getParticipants()); - meeting.setAshaId(maaMeetingRequestDTO.getAshaId()); - - // Convert images to Base64 - if (maaMeetingRequestDTO.getMeetingImages() != null && maaMeetingRequestDTO.getMeetingImages().length > 0) { - List base64Images = List.of(maaMeetingRequestDTO.getMeetingImages()) - .stream() - .filter(file -> !file.isEmpty()) - .map(file -> { - try { - return Base64.getEncoder().encodeToString(file.getBytes()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); - - String imagesJson = null; - try { - imagesJson = objectMapper.writeValueAsString(base64Images); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - meeting.setMeetingImagesJson(imagesJson); + public List saveMeeting(List dtoList, List files) throws Exception { + List meetings = new ArrayList<>(); + + for (MaaMeetingRequestDTO req : dtoList) { + MaaMeeting meeting = new MaaMeeting(); + meeting.setMeetingDate(req.getMeetingDate()); + meeting.setPlace(req.getPlace()); + meeting.setParticipants(req.getParticipants()); + meeting.setAshaId(req.getAshaId()); + + List base64Images = new ArrayList<>(); + + // 🟢 1️⃣ Convert any images inside DTO itself + if (req.getMeetingImages() != null && req.getMeetingImages().length > 0) { + for (MultipartFile file : req.getMeetingImages()) { + if (file != null && !file.isEmpty()) { + base64Images.add(Base64.getEncoder().encodeToString(file.getBytes())); } } - ); + } + // 🟢 2️⃣ Convert any separate uploaded files (from @RequestPart("files")) + if (files != null && !files.isEmpty()) { + for (MultipartFile file : files) { + if (file != null && !file.isEmpty()) { + base64Images.add(Base64.getEncoder().encodeToString(file.getBytes())); + } + } + } + + // 🟢 3️⃣ Convert all collected base64 images to JSON array string + if (!base64Images.isEmpty()) { + try { + String imagesJson = objectMapper.writeValueAsString(base64Images); + meeting.setMeetingImagesJson(imagesJson); + } catch (JsonProcessingException e) { + throw new RuntimeException("Error converting image list to JSON", e); + } + } + + meetings.add(meeting); + } - return repository.save(meeting); + // 🟢 4️⃣ Save all records together + return repository.saveAll(meetings); } + public List getAllMeetings() throws Exception { List meetings = repository.findAll(); return meetings.stream().map(meeting -> { From dcdfca1829e095660dea80c808948df0717bfb3b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 6 Oct 2025 18:45:15 +0530 Subject: [PATCH 323/792] fix code --- .../flw/controller/MaaMeetingController.java | 19 +++-- .../iemr/flw/service/MaaMeetingService.java | 69 +++++++------------ 2 files changed, 41 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index dabd1b15..2c0860fa 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.time.LocalDate; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -32,11 +33,21 @@ public MaaMeetingController(MaaMeetingService service) { @PostMapping(value = "/saveAll", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity saveMeeting( - @RequestPart("data") List dto, - @RequestPart(value = "files", required = false) List files) { + @RequestPart("meetingDate") String meetingDate, + @RequestPart("place") String place, + @RequestPart("participants") String participants, + @RequestPart("ashaId") String ashaId, + @RequestPart(value = "meetingImages", required = false) List meetingImages) { try { - service.saveMeeting(dto, files); - return ResponseEntity.ok("Saved Successfully"); + MaaMeetingRequestDTO dto = new MaaMeetingRequestDTO(); + dto.setMeetingDate(LocalDate.parse(meetingDate)); + dto.setPlace(place); + dto.setParticipants(Integer.parseInt(participants)); + dto.setAshaId(Long.parseLong(ashaId)); + dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); + + service.saveMeeting(dto); + return ResponseEntity.ok("Saved Successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); } diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 3557a624..88958079 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -14,7 +14,9 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @@ -37,54 +39,35 @@ public MaaMeetingService(MaaMeetingRepository repository, ObjectMapper objectMap this.objectMapper = objectMapper; } - public List saveMeeting(List dtoList, List files) throws Exception { - List meetings = new ArrayList<>(); - - for (MaaMeetingRequestDTO req : dtoList) { - MaaMeeting meeting = new MaaMeeting(); - meeting.setMeetingDate(req.getMeetingDate()); - meeting.setPlace(req.getPlace()); - meeting.setParticipants(req.getParticipants()); - meeting.setAshaId(req.getAshaId()); - - List base64Images = new ArrayList<>(); - - // 🟢 1️⃣ Convert any images inside DTO itself - if (req.getMeetingImages() != null && req.getMeetingImages().length > 0) { - for (MultipartFile file : req.getMeetingImages()) { - if (file != null && !file.isEmpty()) { - base64Images.add(Base64.getEncoder().encodeToString(file.getBytes())); - } - } - } - - // 🟢 2️⃣ Convert any separate uploaded files (from @RequestPart("files")) - if (files != null && !files.isEmpty()) { - for (MultipartFile file : files) { - if (file != null && !file.isEmpty()) { - base64Images.add(Base64.getEncoder().encodeToString(file.getBytes())); - } - } - } - - // 🟢 3️⃣ Convert all collected base64 images to JSON array string - if (!base64Images.isEmpty()) { - try { - String imagesJson = objectMapper.writeValueAsString(base64Images); - meeting.setMeetingImagesJson(imagesJson); - } catch (JsonProcessingException e) { - throw new RuntimeException("Error converting image list to JSON", e); - } - } - - meetings.add(meeting); + public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { + MaaMeeting meeting = new MaaMeeting(); + meeting.setMeetingDate(req.getMeetingDate()); + meeting.setPlace(req.getPlace()); + meeting.setParticipants(req.getParticipants()); + meeting.setAshaId(req.getAshaId()); + + // Convert meeting images to Base64 JSON + if (req.getMeetingImages() != null && req.getMeetingImages().length > 0) { + List base64Images = Arrays.stream(req.getMeetingImages()) + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (IOException e) { + throw new RuntimeException("Error converting image to Base64", e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = objectMapper.writeValueAsString(base64Images); + meeting.setMeetingImagesJson(imagesJson); } - // 🟢 4️⃣ Save all records together - return repository.saveAll(meetings); + return repository.save(meeting); } + public List getAllMeetings() throws Exception { List meetings = repository.findAll(); return meetings.stream().map(meeting -> { From 25fbff46852df46ac6e42b858e15efa09ab1db7b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 11:36:07 +0530 Subject: [PATCH 324/792] fix code --- .../flw/controller/MaaMeetingController.java | 7 ++++--- .../flw/dto/iemr/MaaMeetingResponseDTO.java | 2 +- .../flw/repo/iemr/MaaMeetingRepository.java | 3 +++ .../com/iemr/flw/service/MaaMeetingService.java | 17 +++++++++++------ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 2c0860fa..e1c48621 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -1,6 +1,7 @@ package com.iemr.flw.controller; import com.iemr.flw.domain.iemr.MaaMeeting; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.MaaMeetingListResponseDTO; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; @@ -54,18 +55,18 @@ public ResponseEntity saveMeeting( } - @GetMapping("/getAll") + @PostMapping("/getAll") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", content = @Content(mediaType = "application/json", schema = @Schema(implementation = MaaMeetingListResponseDTO.class))), @ApiResponse(responseCode = "500", description = "Internal Server Error") }) - public ResponseEntity getMeetings() { + public ResponseEntity getMeetings(@RequestBody GetBenRequestHandler getBenRequestHandler) { MaaMeetingListResponseDTO response = new MaaMeetingListResponseDTO(); try { - response.setData(service.getAllMeetings()); + response.setData(service.getAllMeetings(getBenRequestHandler)); response.setStatusCode(200); response.setStatus("Success"); return ResponseEntity.ok(response); diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 3dd21de9..5f415d35 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -31,5 +31,5 @@ public class MaaMeetingResponseDTO { @Schema(description = "Meeting images in base64 array", example = "[\"iVBORw0KGgoAAAANSUhEUgAA...\", \"iVBORw0KGgoAAAANSUhEUgBB...\"]") - private List meetingImages; + private List meetingImages; } diff --git a/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java index 6e792226..230aac54 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MaaMeetingRepository.java @@ -4,6 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface MaaMeetingRepository extends JpaRepository { + List findByAshaId(Integer ashaId); } diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 88958079..d738f0d3 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.MaaMeeting; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; @@ -68,8 +69,9 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { - public List getAllMeetings() throws Exception { - List meetings = repository.findAll(); + public List getAllMeetings(GetBenRequestHandler getBenRequestHandler) throws Exception { + List meetings = repository.findByAshaId(getBenRequestHandler.getAshaId()); + return meetings.stream().map(meeting -> { MaaMeetingResponseDTO dto = new MaaMeetingResponseDTO(); dto.setId(meeting.getId()); @@ -80,12 +82,14 @@ public List getAllMeetings() throws Exception { try { if (meeting.getMeetingImagesJson() != null) { - List images = objectMapper.readValue( + List base64Images = objectMapper.readValue( meeting.getMeetingImagesJson(), - new TypeReference>() { - } + new TypeReference>() {} ); - dto.setMeetingImages(images); + + dto.setMeetingImages(base64Images); + } else { + dto.setMeetingImages(List.of()); } } catch (Exception e) { dto.setMeetingImages(List.of()); @@ -94,4 +98,5 @@ public List getAllMeetings() throws Exception { return dto; }).collect(Collectors.toList()); } + } From 9733040ed64dacdffd8c3fab06efd81c02d493c0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 11:55:11 +0530 Subject: [PATCH 325/792] fix code --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 2 +- src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index b30a6cb0..de7799e1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -174,6 +174,6 @@ public class EligibleCoupleRegister { @Lob @Column(name = "kit_photo", columnDefinition = "LONGTEXT") - private String kitPhoto; + private List kitPhoto; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index d9f68f67..df1c1115 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -5,6 +5,7 @@ import java.io.Serializable; import java.sql.Timestamp; +import java.util.List; @Data public class EligibleCoupleDTO implements Serializable { @@ -113,6 +114,6 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp kitHandedOverDate; - private MultipartFile [] kitPhoto; + private List kitPhoto; } From 5d203fc4707d410246beda912af02485d5a6d70b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 12:04:56 +0530 Subject: [PATCH 326/792] fix code --- .../domain/iemr/EligibleCoupleRegister.java | 2 +- .../flw/service/impl/CoupleServiceImpl.java | 23 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index de7799e1..b30a6cb0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -174,6 +174,6 @@ public class EligibleCoupleRegister { @Lob @Column(name = "kit_photo", columnDefinition = "LONGTEXT") - private List kitPhoto; + private String kitPhoto; } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index ad2c54fe..2f1c0880 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -60,27 +60,16 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) EligibleCoupleRegister existingECR = // eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); - if (it.getKitPhoto() != null && it.getKitPhoto().length > 0) { - List base64Images = List.of(it.getKitPhoto()) - .stream() - .filter(file -> !file.isEmpty()) - .map(file -> { - try { - return Base64.getEncoder().encodeToString(file.getBytes()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); - - String imagesJson = null; + if (it.getKitPhoto() != null && !it.getKitPhoto().isEmpty()) { try { - imagesJson = mapper.writeValueAsString(base64Images); + // kitPhoto me sirf URI list hai → JSON bahut chhota hoga + String json = mapper.writeValueAsString(it.getKitPhoto()); + existingECR.setKitPhoto(json); } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new RuntimeException("Error converting kitPhoto list to JSON", e); } - existingECR.setKitPhoto(imagesJson); } + if (existingECR != null && null != existingECR.getNumLiveChildren()) { if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity1 = From dd873c43a3b46c41fbe866e8f108707caa655a8b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 12:34:25 +0530 Subject: [PATCH 327/792] fix code --- .../domain/iemr/EligibleCoupleRegister.java | 7 +++++-- .../iemr/flw/dto/iemr/EligibleCoupleDTO.java | 4 +++- .../flw/service/impl/CoupleServiceImpl.java | 18 +++++++++--------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index b30a6cb0..43f11459 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -173,7 +173,10 @@ public class EligibleCoupleRegister { @Lob - @Column(name = "kit_photo", columnDefinition = "LONGTEXT") - private String kitPhoto; + @Column(name = "kit_photo1", columnDefinition = "LONGTEXT") + private String kitPhoto1; + + @Column(name = "kit_photo2", columnDefinition = "LONGTEXT") + private String kitPhoto2; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index df1c1115..ea092f48 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -114,6 +114,8 @@ public class EligibleCoupleDTO implements Serializable { private Timestamp kitHandedOverDate; - private List kitPhoto; + private String kitPhoto1; + + private String kitPhoto2; } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 2f1c0880..7ba3a896 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -60,14 +60,14 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) EligibleCoupleRegister existingECR = // eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); - if (it.getKitPhoto() != null && !it.getKitPhoto().isEmpty()) { - try { - // kitPhoto me sirf URI list hai → JSON bahut chhota hoga - String json = mapper.writeValueAsString(it.getKitPhoto()); - existingECR.setKitPhoto(json); - } catch (JsonProcessingException e) { - throw new RuntimeException("Error converting kitPhoto list to JSON", e); - } + if (it.getKitPhoto1() != null && !it.getKitPhoto1().isEmpty()) { + existingECR.setKitPhoto1(it.getKitPhoto1()); + + } + + if (it.getKitPhoto2() != null && !it.getKitPhoto2().isEmpty()) { + existingECR.setKitPhoto2(it.getKitPhoto2()); + } if (existingECR != null && null != existingECR.getNumLiveChildren()) { @@ -89,7 +89,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) modelMapper.map(it, existingECR); existingECR.setId(null); } - if(existingECR.getIsKitHandedOver() && !existingECR.getKitPhoto().isEmpty()){ + if(existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())){ IncentiveActivity handoverKitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", "FAMILY PLANNING"); createIncentiveRecord(recordList, it, handoverKitActivity); From 1309fad614905df7834a256f09ec5b7f1127e8ca Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 12:58:10 +0530 Subject: [PATCH 328/792] fix code --- .../com/iemr/flw/domain/iemr/MaaMeeting.java | 8 +++-- .../flw/dto/iemr/MaaMeetingRequestDTO.java | 6 ++-- .../flw/dto/iemr/MaaMeetingResponseDTO.java | 11 +++++-- .../iemr/flw/service/MaaMeetingService.java | 29 +++++++++++++++++++ 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index fe5a477c..365356a0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -3,6 +3,7 @@ import jakarta.persistence.*; import lombok.Data; +import java.sql.Timestamp; import java.time.LocalDate; @Entity @@ -16,7 +17,7 @@ public class MaaMeeting { private Long id; @Column(name = "meeting_date") - private LocalDate meetingDate; + private Timestamp meetingDate; @Column(name = "place") private String place; @@ -31,10 +32,13 @@ public class MaaMeeting { private Integer year; @Column(name = "asha_id") - private Long ashaId; + private Integer ashaId; // Store multiple images as JSON of base64 strings @Lob @Column(name = "meeting_images", columnDefinition = "LONGTEXT") private String meetingImagesJson; + + @Column(name = "created_by") + private String createdBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index 0162b026..b2c871ad 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -3,13 +3,15 @@ import lombok.Data; import org.springframework.web.multipart.MultipartFile; +import java.sql.Timestamp; import java.time.LocalDate; @Data public class MaaMeetingRequestDTO { - private LocalDate meetingDate; + private Timestamp meetingDate; private String place; private Integer participants; private MultipartFile[] meetingImages; // up to 5 images - private Long ashaId; + private Integer ashaId; + private String createdBY; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 5f415d35..697a48a7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -1,8 +1,10 @@ package com.iemr.flw.dto.iemr; import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Column; import lombok.Data; +import java.sql.Timestamp; import java.time.LocalDate; import java.util.List; @@ -12,7 +14,7 @@ public class MaaMeetingResponseDTO { private Long id; @Schema(description = "Date of the meeting", example = "2025-09-06") - private LocalDate meetingDate; + private Timestamp meetingDate; @Schema(description = "Place of the meeting", example = "HWC") private String place; @@ -27,9 +29,14 @@ public class MaaMeetingResponseDTO { private Integer year; @Schema(description = "ID of ASHA", example = "963") - private Long ashaId; + private Integer ashaId; @Schema(description = "Meeting images in base64 array", example = "[\"iVBORw0KGgoAAAANSUhEUgAA...\", \"iVBORw0KGgoAAAANSUhEUgBB...\"]") private List meetingImages; + + @Column(name = "created_by") + private String createdBy; + + } diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index d738f0d3..cb2be8ee 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -3,7 +3,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.domain.iemr.MaaMeeting; +import com.iemr.flw.domain.iemr.UwinSession; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; @@ -46,6 +49,7 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setPlace(req.getPlace()); meeting.setParticipants(req.getParticipants()); meeting.setAshaId(req.getAshaId()); + meeting.setCreatedBy(req.getCreatedBY()); // Convert meeting images to Base64 JSON if (req.getMeetingImages() != null && req.getMeetingImages().length > 0) { @@ -63,6 +67,8 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { String imagesJson = objectMapper.writeValueAsString(base64Images); meeting.setMeetingImagesJson(imagesJson); } + checkAndAddIncentive(meeting); + return repository.save(meeting); } @@ -79,6 +85,7 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setPlace(meeting.getPlace()); dto.setParticipants(meeting.getParticipants()); dto.setAshaId(meeting.getAshaId()); + dto.setCreatedBy(meeting.getCreatedBy()); try { if (meeting.getMeetingImagesJson() != null) { @@ -98,5 +105,27 @@ public List getAllMeetings(GetBenRequestHandler getBenReq return dto; }).collect(Collectors.toList()); } + private void checkAndAddIncentive(MaaMeeting meeting) { + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", "CHILD HEALTH"); + + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), meeting.getMeetingDate(), 0L); + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(meeting.getMeetingDate()); + record.setCreatedBy(meeting.getCreatedBy()); + record.setStartDate(meeting.getMeetingDate()); + record.setEndDate(meeting.getMeetingDate()); + record.setUpdatedDate(meeting.getMeetingDate()); + record.setUpdatedBy(meeting.getCreatedBy()); + record.setBenId(0L); + record.setAshaId(meeting.getAshaId()); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + + } } From 95fb8da8d333e2bea78b0b643aa914546c1fe0a6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 13:09:53 +0530 Subject: [PATCH 329/792] api for u win session and incentive --- .../flw/controller/UwinSessionController.java | 38 +++++ .../com/iemr/flw/domain/iemr/UwinSession.java | 40 +++++ .../flw/dto/iemr/UwinSessionRequestDTO.java | 16 ++ .../flw/repo/iemr/UwinSessionRepository.java | 9 ++ .../iemr/flw/service/UwinSessionService.java | 11 ++ .../service/impl/UwinSessionServiceImpl.java | 137 ++++++++++++++++++ 6 files changed, 251 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/UwinSessionController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/UwinSession.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/UwinSessionRepository.java create mode 100644 src/main/java/com/iemr/flw/service/UwinSessionService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java new file mode 100644 index 00000000..9f438e5a --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -0,0 +1,38 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; +import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; +import com.iemr.flw.service.UwinSessionService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@RestController +@RequestMapping("uwin/session") +@RequiredArgsConstructor +public class UwinSessionController { + + private final UwinSessionService service; + + @PostMapping("/saveAll") + public ResponseEntity saveSession( + @RequestBody UwinSessionRequestDTO uwinSessionRequestDTO) throws Exception { + + UwinSessionRequestDTO dto = new UwinSessionRequestDTO(); + dto.setAshaId(uwinSessionRequestDTO.getAshaId()); + dto.setDate(uwinSessionRequestDTO.getDate()); + dto.setPlace(uwinSessionRequestDTO.getPlace()); + dto.setParticipants(uwinSessionRequestDTO.getParticipants()); + dto.setAttachments(uwinSessionRequestDTO.getAttachments()); + + return ResponseEntity.ok(service.saveSession(dto)); + } + + @GetMapping("/getAll") + public ResponseEntity> getSessions(@RequestParam Integer ashaId) throws Exception { + return ResponseEntity.ok(service.getSessionsByAsha(ashaId)); + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java b/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java new file mode 100644 index 00000000..f995a71d --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java @@ -0,0 +1,40 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.List; + +@Entity +@Data +@Table(name = "uwin_session_record",schema = "db_iemr") +public class UwinSession { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "asha_id", nullable = false) + private Integer ashaId; + + @Column(name = "date", nullable = false) + private Timestamp date; + + @Column(name = "place", nullable = false) + private String place; + + @Column(name = "participants", nullable = false) + private Integer participants; + + @Lob + @Column(name = "attachments_json", columnDefinition = "LONGTEXT") + private String attachmentsJson; + + @Column(name = "created_by") + private String createdBy; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java new file mode 100644 index 00000000..4fa40b61 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.sql.Timestamp; +import java.util.List; + +@Data +public class UwinSessionRequestDTO { + private Integer ashaId; + private Timestamp date; + private String place; + private Integer participants; + private List attachments; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/UwinSessionRepository.java b/src/main/java/com/iemr/flw/repo/iemr/UwinSessionRepository.java new file mode 100644 index 00000000..43a1d1c3 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/UwinSessionRepository.java @@ -0,0 +1,9 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.UwinSession; +import org.springframework.data.jpa.repository.JpaRepository; +import java.util.List; + +public interface UwinSessionRepository extends JpaRepository { + List findByAshaId(Integer ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/UwinSessionService.java b/src/main/java/com/iemr/flw/service/UwinSessionService.java new file mode 100644 index 00000000..3f6ddf0a --- /dev/null +++ b/src/main/java/com/iemr/flw/service/UwinSessionService.java @@ -0,0 +1,11 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; +import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; + +import java.util.List; + +public interface UwinSessionService { + UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exception; + List getSessionsByAsha(Integer ashaId) throws Exception; +} diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java new file mode 100644 index 00000000..5649d8f7 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -0,0 +1,137 @@ +package com.iemr.flw.service.impl; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; +import com.iemr.flw.domain.iemr.UwinSession; +import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; +import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; +import com.iemr.flw.repo.iemr.UwinSessionRepository; +import com.iemr.flw.service.UwinSessionService; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.sql.Timestamp; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +public class UwinSessionServiceImpl implements UwinSessionService { + @Autowired + private UwinSessionRepository repo; + private final ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + private IncentivesRepo incentivesRepo; + + @Autowired + private UserServiceRoleRepo userRepo; + + @Autowired + private IncentiveRecordRepo recordRepo; + + + @Override + public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exception { + + // 🧩 Validations + + Timestamp sessionDate = req.getDate(); // Timestamp from request + Timestamp now = Timestamp.from(Instant.now()); + +// 1️⃣ Future date check + if (sessionDate.after(now)) { + throw new RuntimeException("Date cannot be in future"); + } + +// 2️⃣ Backdate beyond 2 months + LocalDateTime twoMonthsAgo = LocalDateTime.now().minusMonths(2); + if (sessionDate.toLocalDateTime().isBefore(twoMonthsAgo)) { + throw new RuntimeException("Backdate not allowed beyond 2 months"); + } + +// 3️⃣ Participants check + if (req.getParticipants() == null || req.getParticipants() < 0 || req.getParticipants() > 999) { + throw new RuntimeException("Participants count must be between 0–999"); + } + + + String json = objectMapper.writeValueAsString(req.getAttachments()); + + // 🧩 Save record + UwinSession session = new UwinSession(); + session.setAshaId(req.getAshaId()); + session.setDate(req.getDate()); + session.setPlace(req.getPlace()); + session.setParticipants(req.getParticipants()); + session.setAttachmentsJson(json); + + + repo.save(session); + checkAndAddIncentive(session); + + // 🎯 Prepare response + UwinSessionResponseDTO dto = new UwinSessionResponseDTO(); + dto.setId(session.getId()); + dto.setAshaId(session.getAshaId()); + dto.setDate(session.getDate()); + dto.setPlace(session.getPlace()); + dto.setParticipants(session.getParticipants()); + dto.setAttachments(req.getAttachments()); + + return dto; + } + + @Override + public List getSessionsByAsha(Integer ashaId) throws Exception { + List sessions = repo.findByAshaId(ashaId); + return sessions.stream().map(s -> { + UwinSessionResponseDTO dto = new UwinSessionResponseDTO(); + dto.setId(s.getId()); + dto.setAshaId(s.getAshaId()); + dto.setDate(s.getDate()); + dto.setPlace(s.getPlace()); + dto.setParticipants(s.getParticipants()); + try { + List att = objectMapper.readValue(s.getAttachmentsJson(), new TypeReference>() { + }); + dto.setAttachments(att); + } catch (Exception e) { + dto.setAttachments(List.of()); + } + + return dto; + }).collect(Collectors.toList()); + } + + private void checkAndAddIncentive(UwinSession session) { + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", "IMMUNIZATION"); + + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), session.getDate(), 0L); + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(session.getDate()); + record.setCreatedBy(session.getCreatedBy()); + record.setStartDate(session.getDate()); + record.setEndDate(session.getDate()); + record.setUpdatedDate(session.getDate()); + record.setUpdatedBy(session.getCreatedBy()); + record.setBenId(0L); + record.setAshaId(session.getAshaId()); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + + } +} From 5aa9ef247873814b2571998361ec76105acc02eb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 13:10:20 +0530 Subject: [PATCH 330/792] api for u win session and incentive --- .../flw/dto/iemr/UwinSessionResponseDTO.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/UwinSessionResponseDTO.java diff --git a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionResponseDTO.java new file mode 100644 index 00000000..a740881b --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionResponseDTO.java @@ -0,0 +1,18 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import org.apache.poi.hssf.record.TabIdRecord; + +import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.List; + +@Data +public class UwinSessionResponseDTO { + private Long id; + private Integer ashaId; + private Timestamp date; + private String place; + private Integer participants; + private List attachments; +} From d479a11871f77bdad74a4afad893ddd7e8106aaa Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 14:39:17 +0530 Subject: [PATCH 331/792] api for u win session and incentive --- .../flw/controller/UwinSessionController.java | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java index 9f438e5a..104b4833 100644 --- a/src/main/java/com/iemr/flw/controller/UwinSessionController.java +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -1,23 +1,27 @@ package com.iemr.flw.controller; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; import com.iemr.flw.service.UwinSessionService; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; @RestController -@RequestMapping("uwin/session") +@RequestMapping(value = "/uwin/session", headers = "Authorization") @RequiredArgsConstructor public class UwinSessionController { private final UwinSessionService service; - @PostMapping("/saveAll") + @RequestMapping(value = "saveAll",method = RequestMethod.POST,headers = "Authorization") public ResponseEntity saveSession( @RequestBody UwinSessionRequestDTO uwinSessionRequestDTO) throws Exception { @@ -31,8 +35,23 @@ public ResponseEntity saveSession( return ResponseEntity.ok(service.saveSession(dto)); } - @GetMapping("/getAll") - public ResponseEntity> getSessions(@RequestParam Integer ashaId) throws Exception { - return ResponseEntity.ok(service.getSessionsByAsha(ashaId)); + @RequestMapping(value = "getAll",method = RequestMethod.POST,headers = "Authorization") + public ResponseEntity> getSessions(@RequestBody GetBenRequestHandler getBenRequestHandler) throws Exception { + Map response = new LinkedHashMap<>(); + + try { + Map data = new HashMap<>(); + data.put("userId", getBenRequestHandler.getUserId()); + data.put("entries", service.getSessionsByAsha(getBenRequestHandler.getAshaId())); + response.put("data", data); + response.put("statusCode", 200); + response.put("message", "Success"); + } catch (Exception e) { + response.put("statusCode", 500); + response.put("errorMessage", e.getMessage()); + + } + + return ResponseEntity.ok(response); } } From 270f3aea7129bdbda68568df50be760cb096b886 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 15:07:19 +0530 Subject: [PATCH 332/792] api for u win session and incentive --- .../iemr/flw/controller/MaaMeetingController.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index e1c48621..3becaa41 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.time.LocalDate; +import java.sql.Timestamp; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,24 +38,26 @@ public ResponseEntity saveMeeting( @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, + @RequestPart("createdBy") String createdBy, @RequestPart(value = "meetingImages", required = false) List meetingImages) { try { MaaMeetingRequestDTO dto = new MaaMeetingRequestDTO(); - dto.setMeetingDate(LocalDate.parse(meetingDate)); + dto.setMeetingDate(Timestamp.valueOf(meetingDate)); dto.setPlace(place); dto.setParticipants(Integer.parseInt(participants)); - dto.setAshaId(Long.parseLong(ashaId)); + dto.setAshaId(Integer.parseInt(ashaId)); + dto.setCreatedBY(createdBy); dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); - service.saveMeeting(dto); - return ResponseEntity.ok("Saved Successfully"); + MaaMeeting saved = service.saveMeeting(dto); + return ResponseEntity.ok("Saved Successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); } } - @PostMapping("/getAll") + @GetMapping("/getAll") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", content = @Content(mediaType = "application/json", From 67acec5054818ac04229b953cdf2b4f362acae7d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 15:29:20 +0530 Subject: [PATCH 333/792] fix date issue --- .../com/iemr/flw/controller/MaaMeetingController.java | 5 +++-- .../java/com/iemr/flw/domain/iemr/MaaMeeting.java | 2 +- .../com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java | 2 +- .../com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java | 2 +- .../java/com/iemr/flw/service/MaaMeetingService.java | 11 ++++++----- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 3becaa41..629698ea 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; +import java.time.LocalDate; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,14 +43,14 @@ public ResponseEntity saveMeeting( @RequestPart(value = "meetingImages", required = false) List meetingImages) { try { MaaMeetingRequestDTO dto = new MaaMeetingRequestDTO(); - dto.setMeetingDate(Timestamp.valueOf(meetingDate)); + dto.setMeetingDate(LocalDate.parse(meetingDate)); dto.setPlace(place); dto.setParticipants(Integer.parseInt(participants)); dto.setAshaId(Integer.parseInt(ashaId)); dto.setCreatedBY(createdBy); dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); - MaaMeeting saved = service.saveMeeting(dto); + service.saveMeeting(dto); return ResponseEntity.ok("Saved Successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index 365356a0..2bfb2970 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -17,7 +17,7 @@ public class MaaMeeting { private Long id; @Column(name = "meeting_date") - private Timestamp meetingDate; + private LocalDate meetingDate; @Column(name = "place") private String place; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index b2c871ad..c08c8d64 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -8,7 +8,7 @@ @Data public class MaaMeetingRequestDTO { - private Timestamp meetingDate; + private LocalDate meetingDate; private String place; private Integer participants; private MultipartFile[] meetingImages; // up to 5 images diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 697a48a7..9ba81ad8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -14,7 +14,7 @@ public class MaaMeetingResponseDTO { private Long id; @Schema(description = "Date of the meeting", example = "2025-09-06") - private Timestamp meetingDate; + private LocalDate meetingDate; @Schema(description = "Place of the meeting", example = "HWC") private String place; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index cb2be8ee..a6f33923 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -19,6 +19,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; @@ -109,16 +110,16 @@ private void checkAndAddIncentive(MaaMeeting meeting) { IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", "CHILD HEALTH"); IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), meeting.getMeetingDate(), 0L); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); - record.setCreatedDate(meeting.getMeetingDate()); + record.setCreatedDate(Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay())); record.setCreatedBy(meeting.getCreatedBy()); - record.setStartDate(meeting.getMeetingDate()); - record.setEndDate(meeting.getMeetingDate()); - record.setUpdatedDate(meeting.getMeetingDate()); + record.setStartDate(Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay())); + record.setEndDate(Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay())); + record.setUpdatedDate(Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay())); record.setUpdatedBy(meeting.getCreatedBy()); record.setBenId(0L); record.setAshaId(meeting.getAshaId()); From 3dfec681888718546d00455c57cc01c444d71380 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 15:52:48 +0530 Subject: [PATCH 334/792] fix date issue --- src/main/java/com/iemr/flw/controller/MaaMeetingController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 629698ea..d9bcdb1b 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -58,7 +58,7 @@ public ResponseEntity saveMeeting( } - @GetMapping("/getAll") + @PostMapping("/getAll") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", content = @Content(mediaType = "application/json", From 6e8028ffab39ef4de18311b2d0c6fd0ca6a54b59 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 7 Oct 2025 15:58:14 +0530 Subject: [PATCH 335/792] fix date issue --- .../flw/controller/UwinSessionController.java | 22 +++++++++++++------ .../flw/dto/iemr/UwinSessionRequestDTO.java | 2 +- .../service/impl/UwinSessionServiceImpl.java | 21 ++++++++++++++---- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java index 104b4833..d8bb931e 100644 --- a/src/main/java/com/iemr/flw/controller/UwinSessionController.java +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -6,9 +6,12 @@ import com.iemr.flw.service.UwinSessionService; import lombok.RequiredArgsConstructor; 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.HashMap; import java.util.LinkedHashMap; import java.util.List; @@ -21,16 +24,21 @@ public class UwinSessionController { private final UwinSessionService service; - @RequestMapping(value = "saveAll",method = RequestMethod.POST,headers = "Authorization") + @RequestMapping(value = "saveAll",method = RequestMethod.POST,headers = "Authorization",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity saveSession( - @RequestBody UwinSessionRequestDTO uwinSessionRequestDTO) throws Exception { + @RequestPart("meetingDate") String meetingDate, + @RequestPart("place") String place, + @RequestPart("participants") String participants, + @RequestPart("ashaId") String ashaId, + @RequestPart("createdBy") String createdBy, + @RequestPart(value = "meetingImages", required = false) List images) throws Exception { UwinSessionRequestDTO dto = new UwinSessionRequestDTO(); - dto.setAshaId(uwinSessionRequestDTO.getAshaId()); - dto.setDate(uwinSessionRequestDTO.getDate()); - dto.setPlace(uwinSessionRequestDTO.getPlace()); - dto.setParticipants(uwinSessionRequestDTO.getParticipants()); - dto.setAttachments(uwinSessionRequestDTO.getAttachments()); + dto.setAshaId(Integer.valueOf(ashaId)); + dto.setDate(Timestamp.valueOf(meetingDate)); + dto.setPlace(place); + dto.setParticipants(Integer.valueOf(participants)); + dto.setAttachments(images != null ? images.toArray(new MultipartFile[0]) : null); return ResponseEntity.ok(service.saveSession(dto)); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java index 4fa40b61..58bb5175 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java @@ -12,5 +12,5 @@ public class UwinSessionRequestDTO { private Timestamp date; private String place; private Integer participants; - private List attachments; + private MultipartFile[] attachments; } diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index 5649d8f7..c3f9a4dd 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.IOException; import java.sql.Timestamp; import java.time.Instant; import java.time.LocalDate; @@ -64,7 +65,6 @@ public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exce } - String json = objectMapper.writeValueAsString(req.getAttachments()); // 🧩 Save record UwinSession session = new UwinSession(); @@ -72,8 +72,21 @@ public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exce session.setDate(req.getDate()); session.setPlace(req.getPlace()); session.setParticipants(req.getParticipants()); - session.setAttachmentsJson(json); - + if (req.getAttachments() != null && req.getAttachments().length > 0) { + List base64Images = Arrays.stream(req.getAttachments()) + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (IOException e) { + throw new RuntimeException("Error converting image to Base64", e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = objectMapper.writeValueAsString(base64Images); + session.setAttachmentsJson(imagesJson); + } repo.save(session); checkAndAddIncentive(session); @@ -85,7 +98,7 @@ public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exce dto.setDate(session.getDate()); dto.setPlace(session.getPlace()); dto.setParticipants(session.getParticipants()); - dto.setAttachments(req.getAttachments()); + dto.setAttachments(Collections.singletonList(session.getAttachmentsJson())); return dto; } From 1261ef1e601ff286938c693af7f2a549fd0ce50c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 8 Oct 2025 11:58:37 +0530 Subject: [PATCH 336/792] fix date issue --- src/main/java/com/iemr/flw/controller/UwinSessionController.java | 1 + src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java | 1 + .../java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java index d8bb931e..c61534e0 100644 --- a/src/main/java/com/iemr/flw/controller/UwinSessionController.java +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -38,6 +38,7 @@ public ResponseEntity saveSession( dto.setDate(Timestamp.valueOf(meetingDate)); dto.setPlace(place); dto.setParticipants(Integer.valueOf(participants)); + dto.setCreatedBy(createdBy); dto.setAttachments(images != null ? images.toArray(new MultipartFile[0]) : null); return ResponseEntity.ok(service.saveSession(dto)); diff --git a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java index 58bb5175..f5456269 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/UwinSessionRequestDTO.java @@ -13,4 +13,5 @@ public class UwinSessionRequestDTO { private String place; private Integer participants; private MultipartFile[] attachments; + private String createdBy; } diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index c3f9a4dd..f923c6bb 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -72,6 +72,7 @@ public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exce session.setDate(req.getDate()); session.setPlace(req.getPlace()); session.setParticipants(req.getParticipants()); + session.setCreatedBy(req.getCreatedBy()); if (req.getAttachments() != null && req.getAttachments().length > 0) { List base64Images = Arrays.stream(req.getAttachments()) .filter(file -> !file.isEmpty()) From fc6126d3e40f45a59888c4677115c5c3efab3562 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 8 Oct 2025 14:16:09 +0530 Subject: [PATCH 337/792] fix date issue --- .../iemr/flw/controller/UwinSessionController.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java index c61534e0..0f077ad8 100644 --- a/src/main/java/com/iemr/flw/controller/UwinSessionController.java +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -25,13 +25,14 @@ public class UwinSessionController { private final UwinSessionService service; @RequestMapping(value = "saveAll",method = RequestMethod.POST,headers = "Authorization",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity saveSession( + public ResponseEntity saveSession( @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, @RequestPart("createdBy") String createdBy, @RequestPart(value = "meetingImages", required = false) List images) throws Exception { + Map response = new LinkedHashMap<>(); UwinSessionRequestDTO dto = new UwinSessionRequestDTO(); dto.setAshaId(Integer.valueOf(ashaId)); @@ -40,8 +41,16 @@ public ResponseEntity saveSession( dto.setParticipants(Integer.valueOf(participants)); dto.setCreatedBy(createdBy); dto.setAttachments(images != null ? images.toArray(new MultipartFile[0]) : null); + UwinSessionResponseDTO uwinSessionResponse = service.saveSession(dto); + if(uwinSessionResponse!=null){ + response.put("statusCode", 200); + response.put("message", "Data saved successfully"); + }else { + response.put("statusCode", 500); + response.put("message", "Something went wrong"); + } - return ResponseEntity.ok(service.saveSession(dto)); + return ResponseEntity.ok(response); } @RequestMapping(value = "getAll",method = RequestMethod.POST,headers = "Authorization") From 086737d09b75cfc66e43876794bc73bc7a680f89 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 12:29:50 +0530 Subject: [PATCH 338/792] fix date issue --- .../service/impl/ChildCareServiceImpl.java | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index ec433c7a..2a078163 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -347,42 +347,58 @@ private void checkAndAddHbyncIncentives(List hbycList) { } private void checkAndAddHbncIncentives(List hbncVisits) { - hbncVisits.forEach(hbncVisit -> { - boolean isVisitDone = List.of("1st Day", "3rd Day", "7th Day", "42nd Day") - .stream() - .allMatch(hbncVisits::contains); - - boolean isBabyDisChargeSNCUA = hbncVisits.stream() - .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu())); - Long benId = hbncVisit.getBeneficiaryId(); - if (isVisitDone) { - IncentiveActivity visitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", "CHILD HEALTH"); - createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); + // Group all visits by beneficiary + Map> visitsByBen = hbncVisits.stream() + .collect(Collectors.groupingBy(HbncVisit::getBeneficiaryId)); - } - if (isBabyDisChargeSNCUA) { - IncentiveActivity babyDisChargeSNCUAActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", "CHILD HEALTH"); + visitsByBen.forEach((benId, visits) -> { - createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); + // Extract all visit day names or day numbers + Set completedDays = visits.stream() + .map(HbncVisit::getVisit_day) // e.g. "1st Day" + .collect(Collectors.toSet()); - } - if(!hbncVisit.getIs_baby_alive()){ - IncentiveActivity isChildDeathActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); + boolean hasMandatoryVisits = completedDays.containsAll( + List.of("1st Day", "3rd Day", "7th Day", "42nd Day") + ); - createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity); - } + boolean allSevenVisitsDone = completedDays.containsAll( + List.of("1st Day", "3rd Day", "7th Day", "14th Day", "21st Day", "28th Day", "42nd Day") + ); + boolean isSncuOrLBW = visits.stream() + .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu()) + || Boolean.TRUE.equals(v.getBaby_weight())); + boolean isChildDeath = visits.stream() + .anyMatch(v -> Boolean.FALSE.equals(v.getIs_baby_alive())); - }); + // --- Incentive #1: HBNC 0–42 days (Rs. 250) + if (hasMandatoryVisits) { + IncentiveActivity visitActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", "CHILD HEALTH"); + createIncentiveRecordforHbncVisit(visits.get(0), benId, visitActivity); + } + // --- Incentive #2: SNCU/LBW Follow-up (Rs. 200) + if (isSncuOrLBW && allSevenVisitsDone) { + IncentiveActivity sncuActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", "CHILD HEALTH"); + createIncentiveRecordforHbncVisit(visits.get(0), benId, sncuActivity); + } + // --- Incentive #3: Child Death Reporting + if (isChildDeath) { + IncentiveActivity deathActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); + createIncentiveRecordforHbncVisit(visits.get(0), benId, deathActivity); + } + + }); } + private void checkAndAddIncentives(List vaccinationList) { vaccinationList.forEach(vaccination -> { From 990b82de07e42bbcc2d5900cfdc62bb22fe566e1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 13:25:37 +0530 Subject: [PATCH 339/792] fix date issue --- .../service/impl/ChildCareServiceImpl.java | 64 +++++++------------ 1 file changed, 24 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2a078163..1921feff 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -347,58 +347,42 @@ private void checkAndAddHbyncIncentives(List hbycList) { } private void checkAndAddHbncIncentives(List hbncVisits) { + hbncVisits.forEach(hbncVisit -> { + boolean isVisitDone = List.of("1st Day", "3rd Day", "7th Day", "42nd Day") + .stream() + .allMatch(hbncVisits::contains); + + boolean isBabyDisChargeSNCUA = hbncVisits.stream() + .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu())); + Long benId = hbncVisit.getBeneficiaryId(); + if (hbncVisit.getVisit_day().equals("42nd Day")) { + IncentiveActivity visitActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", "CHILD HEALTH"); - // Group all visits by beneficiary - Map> visitsByBen = hbncVisits.stream() - .collect(Collectors.groupingBy(HbncVisit::getBeneficiaryId)); - - visitsByBen.forEach((benId, visits) -> { - - // Extract all visit day names or day numbers - Set completedDays = visits.stream() - .map(HbncVisit::getVisit_day) // e.g. "1st Day" - .collect(Collectors.toSet()); - - boolean hasMandatoryVisits = completedDays.containsAll( - List.of("1st Day", "3rd Day", "7th Day", "42nd Day") - ); - - boolean allSevenVisitsDone = completedDays.containsAll( - List.of("1st Day", "3rd Day", "7th Day", "14th Day", "21st Day", "28th Day", "42nd Day") - ); + createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); - boolean isSncuOrLBW = visits.stream() - .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu()) - || Boolean.TRUE.equals(v.getBaby_weight())); + } + if (hbncVisit.getVisit_day().equals("42nd Day") && isBabyDisChargeSNCUA) { + IncentiveActivity babyDisChargeSNCUAActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", "CHILD HEALTH"); - boolean isChildDeath = visits.stream() - .anyMatch(v -> Boolean.FALSE.equals(v.getIs_baby_alive())); + createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); - // --- Incentive #1: HBNC 0–42 days (Rs. 250) - if (hasMandatoryVisits) { - IncentiveActivity visitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", "CHILD HEALTH"); - createIncentiveRecordforHbncVisit(visits.get(0), benId, visitActivity); } + if(!hbncVisit.getIs_baby_alive()){ + IncentiveActivity isChildDeathActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); - // --- Incentive #2: SNCU/LBW Follow-up (Rs. 200) - if (isSncuOrLBW && allSevenVisitsDone) { - IncentiveActivity sncuActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", "CHILD HEALTH"); - createIncentiveRecordforHbncVisit(visits.get(0), benId, sncuActivity); + createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity); } - // --- Incentive #3: Child Death Reporting - if (isChildDeath) { - IncentiveActivity deathActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); - createIncentiveRecordforHbncVisit(visits.get(0), benId, deathActivity); - } + }); - } + } + private void checkAndAddIncentives(List vaccinationList) { vaccinationList.forEach(vaccination -> { From 062edfba962d01269d471d6080c6c83c2ccf4911 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 15:52:03 +0530 Subject: [PATCH 340/792] fix date issue --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 3 +-- src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index 43f11459..c5dc11f4 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -169,8 +169,7 @@ public class EligibleCoupleRegister { private Boolean isKitHandedOver; @Column(name = "is_kit_handed_over_date") - private Timestamp kitHandedOverDate; - + private String kitHandedOverDate; @Lob @Column(name = "kit_photo1", columnDefinition = "LONGTEXT") diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index ea092f48..d583ba0c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -112,7 +112,7 @@ public class EligibleCoupleDTO implements Serializable { private Boolean isKitHandedOver; - private Timestamp kitHandedOverDate; + private String kitHandedOverDate; private String kitPhoto1; From 2e3dafbda508a9833df3b5781ceccc57730b9e63 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 16:33:14 +0530 Subject: [PATCH 341/792] hbync api --- .../flw/controller/ChildCareController.java | 2 +- .../iemr/flw/domain/iemr/HbycChildVisit.java | 126 ++++++++++++++++++ .../com/iemr/flw/dto/iemr/HbncRequestDTO.java | 3 +- .../java/com/iemr/flw/dto/iemr/HbycDTO.java | 117 +++++++++++----- .../com/iemr/flw/dto/iemr/HbycRequestDTO.java | 17 +++ .../com/iemr/flw/repo/iemr/HbncVisitRepo.java | 2 + .../java/com/iemr/flw/repo/iemr/HbycRepo.java | 5 +- .../iemr/flw/service/ChildCareService.java | 2 +- .../service/impl/ChildCareServiceImpl.java | 74 +++++----- src/main/resources/application.properties | 19 +++ 10 files changed, 296 insertions(+), 71 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/HbycRequestDTO.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 2354608e..8d3f9fa7 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -33,7 +33,7 @@ public class ChildCareController { @Operation(summary = "save HBYC details") @RequestMapping(value = {"/hbyc/saveAll"}, method = {RequestMethod.POST}) - public String saveHbycRecords(@RequestBody List hbycDTOs, + public String saveHbycRecords(@RequestBody List hbycDTOs, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java new file mode 100644 index 00000000..dce92723 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -0,0 +1,126 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +import lombok.Data; +import org.hibernate.annotations.Type; + +@Entity +@Data +@Table(name = "t_hbyc_child_visits",schema = "db_iemr") +public class HbycChildVisit { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "beneficiary_id") + private Long beneficiaryId; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "hbyc_visit") + private String hbycVisit; // 3 Months, 6 Months, etc. + + @Column(name = "hbyc_due_date") + private LocalDate hbycDueDate; + + @Column(name = "hbyc_visit_date") + private Timestamp hbycVisitDate; + + @Column(name = "is_baby_alive") + private Boolean isBabyAlive = true; + + @Column(name = "date_of_death") + private LocalDate dateOfDeath; + + @Column(name = "reason_for_death") + private String reasonForDeath; + + @Column(name = "place_of_death") + private String placeOfDeath; + + @Column(name = "other_place_of_death") + private String otherPlaceOfDeath; + + @Column(name = "baby_weight") + private BigDecimal babyWeight; // 0.5 - 7.0 + + @Column(name = "is_child_sick") + private Boolean isChildSick; + + @Column(name = "is_exclusive_breastfeeding") + private Boolean isExclusiveBreastfeeding; + + @Column(name = "is_mother_counseled_exbf") + private Boolean isMotherCounseledExbf; + + @Column(name = "has_child_started_complementary_feeding") + private Boolean hasChildStartedComplementaryFeeding; + + @Column(name = "is_mother_counseled_cf") + private Boolean isMotherCounseledCf; + + @Column(name = "is_weight_recorded_by_aww") + private Boolean isWeightRecordedByAww; + + @Column(name = "is_developmental_delay") + private Boolean isDevelopmentalDelay; + + @Column(name = "is_measles_vaccine_given") + private Boolean isMeaslesVaccineGiven; + + @Column(name = "is_vitamin_a_given") + private Boolean isVitaminAGiven; + + @Column(name = "is_ors_available") + private Boolean isOrsAvailable; + + @Column(name = "is_ifa_syrup_available") + private Boolean isIfaSyrupAvailable; + + @Column(name = "is_ors_given") + private Boolean isOrsGiven; + + @Column(name = "is_ifa_syrup_given") + private Boolean isIfaSyrupGiven; + + @Column(name = "is_handwashing_counseling_given") + private Boolean isHandwashingCounselingGiven; + + @Column(name = "is_parenting_counseling_given") + private Boolean isParentingCounselingGiven; + + @Column(name = "is_family_planning_counseling_given") + private Boolean isFamilyPlanningCounselingGiven; + + @Column(name = "diarrhoea_episode") + private Boolean diarrhoeaEpisode; + + @Column(name = "pneumonia_symptoms") + private Boolean pneumoniaSymptoms; + + @Column(name = "temperature") + private BigDecimal temperature; + + @Column(name = "mcp_card_images", columnDefinition = "json") + private List mcpCardImages; + + @Column(name = "created_at") + private LocalDateTime createdAt; + + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + @Column(name = "created_by") + private String createdBy; + + // Getters and Setters +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbncRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbncRequestDTO.java index 174f1d20..742144b8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbncRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbncRequestDTO.java @@ -10,7 +10,8 @@ public class HbncRequestDTO { private Long beneficiaryId; private Long houseHoldId; private String visitDate; - private Integer ashaId; private String userName; private HbncVisitDTO fields; } + + diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index 0011bc93..0d69d020 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -1,71 +1,126 @@ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; import lombok.Data; +import java.math.BigDecimal; import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; @Data public class HbycDTO { - private Long id; - private Long benId; + @SerializedName("beneficiary_id") + private Long beneficiaryId; + + @SerializedName("hbyc_visit") + private String hbycVisit; // 3 Months, 6 Months, etc. + + @SerializedName("hbyc_due_date") + private LocalDate hbycDueDate; + + @SerializedName("hbyc_visit_date") + private Timestamp hbycVisitDate; + + @SerializedName("is_baby_alive") + private Boolean isBabyAlive; + + @SerializedName("date_of_death") + private LocalDate dateOfDeath; - private String subcenterName; + @SerializedName("reason_for_death") + private String reasonForDeath; - private String primaryHealthCenterName; + @SerializedName("place_of_death") + private String placeOfDeath; - private Integer villagePopulation; + @SerializedName("other_place_of_death") + private String otherPlaceOfDeath; - private Integer infantPopulation; + @SerializedName("baby_weight") + private BigDecimal babyWeight; // 0.5 - 7.0 - private Timestamp visitDate; + @SerializedName("is_child_sick") + private Boolean isChildSick; - private String hbycAgeCategory; + @SerializedName("is_exclusive_breastfeeding") + private Boolean isExclusiveBreastfeeding; - private Boolean orsPacketDelivered; + @SerializedName("is_mother_counseled_exbf") + private Boolean isMotherCounseledExbf; - private Boolean ironFolicAcidGiven; + @SerializedName("has_child_started_complementary_feeding") + private Boolean hasChildStartedComplementaryFeeding; - private Boolean isVaccinatedByAge; + @SerializedName("is_mother_counseled_cf") + private Boolean isMotherCounseledCf; - private Boolean wasIll; + @SerializedName("is_weight_recorded_by_aww") + private Boolean isWeightRecordedByAww; - private Boolean referred; + @SerializedName("is_developmental_delay") + private Boolean isDevelopmentalDelay; - private Boolean supplementsGiven; + @SerializedName("is_measles_vaccine_given") + private Boolean isMeaslesVaccineGiven; - private Boolean byHeightLength; + @SerializedName("is_vitamin_a_given") + private Boolean isVitaminAGiven; - private Boolean childrenWeighingLessReferred; + @SerializedName("is_ors_available") + private Boolean isOrsAvailable; - private Boolean weightAccordingToAge; + @SerializedName("is_ifa_syrup_available") + private Boolean isIfaSyrupAvailable; - private Boolean delayInDevelopment; + @SerializedName("is_ors_given") + private Boolean isOrsGiven; - private Boolean referredToHealthInstitite; + @SerializedName("is_ifa_syrup_given") + private Boolean isIfaSyrupGiven; - private Boolean vitaminASupplementsGiven; + @SerializedName("is_handwashing_counseling_given") + private Boolean isHandwashingCounselingGiven; - private String deathAge; + @SerializedName("is_parenting_counseling_given") + private Boolean isParentingCounselingGiven; - private String deathCause; + @SerializedName("is_family_planning_counseling_given") + private Boolean isFamilyPlanningCounselingGiven; - private Boolean qmOrAnmInformed; + @SerializedName("diarrhoea_episode") + private Boolean diarrhoeaEpisode; - private String deathPlace; + @SerializedName("pneumonia_symptoms") + private Boolean pneumoniaSymptoms; - private Boolean superVisorOn; + @SerializedName("temperature") + private BigDecimal temperature; - private Boolean orsShortage; + @SerializedName("mcp_card_images") + private List mcpCardImages; - private Boolean ifaDecreased; + @SerializedName("created_at") + private LocalDateTime createdAt; - private String createdBy; + @SerializedName("updated_at") + private LocalDateTime updatedAt; - private Timestamp createdDate; + // Getters and Setters - private Timestamp updatedDate; - private String updatedBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycRequestDTO.java new file mode 100644 index 00000000..82aa28d9 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycRequestDTO.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.HBYC; +import lombok.Data; + +import java.util.List; + +@Data +public class HbycRequestDTO { + + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private String userName; + private HbycDTO fields; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbncVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbncVisitRepo.java index df6e1a4e..655c0547 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbncVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbncVisitRepo.java @@ -20,4 +20,6 @@ public interface HbncVisitRepo extends JpaRepository { HbncVisit findByBeneficiaryIdAndVisit_day(@Param("beneficiaryId") Long beneficiaryId, @Param("visitDay") String visitDay); + List findByAshaId(Integer ashaId); + } diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 18d37b3d..9144c98b 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -1,6 +1,7 @@ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.HBYC; +import com.iemr.flw.domain.iemr.HbycChildVisit; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; @@ -10,9 +11,9 @@ import java.util.List; @Repository -public interface HbycRepo extends JpaRepository { +public interface HbycRepo extends JpaRepository { - HBYC findHBYCByBenIdAndCreatedDate(Long benId, Timestamp createdDate); + HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDate(Long benId, Timestamp createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index adf1483a..6bac9717 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -8,7 +8,7 @@ public interface ChildCareService { - String registerHBYC(List hbycDTOs); + String registerHBYC(List hbycDTOs); List getHbycRecords(GetBenRequestHandler dto); diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 1921feff..7259ee88 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -59,21 +59,24 @@ public class ChildCareServiceImpl implements ChildCareService { ModelMapper modelMapper = new ModelMapper(); @Override - public String registerHBYC(List hbycDTOs) { + public String registerHBYC(List hbycDTOs) { try { - List hbycList = new ArrayList<>(); + List hbycList = new ArrayList<>(); hbycDTOs.forEach(it -> { - HBYC hbyc = - hbycRepo.findHBYCByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); + HbycChildVisit hbyc = + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDate(it.getBeneficiaryId(), it.getFields().getHbycVisitDate()); if (hbyc != null) { Long id = hbyc.getId(); modelMapper.map(it, hbyc); hbyc.setId(id); + hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); + hbyc.setCreatedBy(it.getUserName()); } else { - hbyc = new HBYC(); + hbyc = new HbycChildVisit(); modelMapper.map(it, hbyc); hbyc.setId(null); + } hbycList.add(hbyc); }); @@ -106,7 +109,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { public List getHBNCDetails(GetBenRequestHandler dto) { List result = new ArrayList<>(); try { - List hbncVisits = hbncVisitRepo.findAll(); + List hbncVisits = hbncVisitRepo.findByAshaId(dto.getAshaId()); for (HbncVisit visit : hbncVisits) { HbncVisitResponseDTO responseDTO = new HbncVisitResponseDTO(); @@ -151,6 +154,7 @@ public List getHBNCDetails(GetBenRequestHandler dto) { } return result; } + private void addIfValid(Map map, String key, Object value) { if (value == null) return; @@ -158,10 +162,12 @@ private void addIfValid(Map map, String key, Object value) { map.put(key, value); } + private String convert(Boolean value) { if (value == null) return null; return value ? "Yes" : "No"; } + private String convert(Object value) { if (value == null) return null; if (value instanceof Boolean) return (Boolean) value ? "Yes" : "No"; @@ -169,7 +175,6 @@ private String convert(Object value) { } - private String convert(String value) { return "true".equalsIgnoreCase(value) ? "Yes" : "No"; } @@ -195,7 +200,7 @@ public String saveHBNCDetails(List hbncRequestDTOs) { hbncVisit = new HbncVisit(); modelMapper.map(hbncVisitDTO, hbncVisit); hbncVisit.setBeneficiaryId(it.getBeneficiaryId()); - hbncVisit.setAshaId(it.getAshaId()); + hbncVisit.setAshaId(userRepo.getUserIdByName(it.getUserName())); hbncVisit.setCreatedBy(it.getUserName()); hbncVisit.setHouseHoldId(it.getHouseHoldId()); hbncVisit.setId(null); @@ -319,23 +324,23 @@ public List getAllChildVaccines(String category) { return null; } - private void checkAndAddHbyncIncentives(List hbycList) { + private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", "CHILD HEALTH"); IncentiveActivity hbyncOrsPacketActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", "CHILD HEALTH"); - if(hbyncVisitActivity!=null){ - if(hbyc.getVisitDate()!=null){ - createIncentiveRecordforHbyncVisit(hbyc,hbyc.getBenId(),hbyncVisitActivity); + if (hbyncVisitActivity != null) { + if (hbyc.getHbycVisitDate() != null) { + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreatedBy()); } } - if(hbyncOrsPacketActivity!=null){ - if(hbyc.getOrsPacketDelivered()){ - createIncentiveRecordforHbyncOrsDistribution(hbyc,hbyc.getBenId(),hbyncOrsPacketActivity); + if (hbyncOrsPacketActivity != null) { + if (hbyc.getIsOrsGiven()) { + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivity, hbyc.getCreatedBy()); } @@ -369,7 +374,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); } - if(!hbncVisit.getIs_baby_alive()){ + if (!hbncVisit.getIs_baby_alive()) { IncentiveActivity isChildDeathActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); @@ -377,7 +382,6 @@ private void checkAndAddHbncIncentives(List hbncVisits) { } - }); @@ -460,46 +464,46 @@ record = new IncentiveActivityRecord(); } } - private void createIncentiveRecordforHbyncVisit(HBYC data, Long benId, IncentiveActivity immunizationActivity) { + private void createIncentiveRecordforHbyncVisit(HbycChildVisit data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getCreatedDate(), benId); + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getHbycVisitDate(), benId); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(data.getVisitDate()); - record.setCreatedBy(data.getCreatedBy()); - record.setStartDate(data.getVisitDate()); - record.setEndDate(data.getVisitDate()); - record.setUpdatedDate(data.getVisitDate()); - record.setUpdatedBy(data.getUpdatedBy()); + record.setCreatedDate(data.getHbycVisitDate()); + record.setCreatedBy(createdBy); + record.setStartDate(data.getHbycVisitDate()); + record.setEndDate(data.getHbycVisitDate()); + record.setUpdatedDate(data.getHbycVisitDate()); + record.setUpdatedBy(createdBy); record.setBenId(benId); - record.setAshaId(beneficiaryRepo.getUserIDByUserName(data.getCreatedBy())); + record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); record.setAmount(Long.valueOf(immunizationActivity.getRate())); recordRepo.save(record); } } - private void createIncentiveRecordforHbyncOrsDistribution(HBYC data, Long benId, IncentiveActivity immunizationActivity) { + private void createIncentiveRecordforHbyncOrsDistribution(HbycChildVisit data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getCreatedDate(), benId); + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getHbycVisitDate(), benId); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(data.getVisitDate()); - record.setCreatedBy(data.getCreatedBy()); - record.setStartDate(data.getVisitDate()); - record.setEndDate(data.getVisitDate()); - record.setUpdatedDate(data.getVisitDate()); - record.setUpdatedBy(data.getUpdatedBy()); + record.setCreatedDate(data.getHbycVisitDate()); + record.setCreatedBy(createdBy); + record.setStartDate(data.getHbycVisitDate()); + record.setEndDate(data.getHbycVisitDate()); + record.setUpdatedDate(data.getHbycVisitDate()); + record.setUpdatedBy(createdBy); record.setBenId(benId); - record.setAshaId(beneficiaryRepo.getUserIDByUserName(data.getCreatedBy())); + record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); record.setAmount(Long.valueOf(immunizationActivity.getRate())); recordRepo.save(record); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index a74a980a..41b05d58 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -73,6 +73,25 @@ spring.redis.port=6379 notificationurl =https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification +secondary.datasource.username=app_user +secondary.datasource.password=NewSecureP@ss123! +secondary.datasource.url=jdbc:mysql://192.168.45.40:3306/db_identity +secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver +server.port=9876 + +cors.allowed-origins = +jwt.secret + + +spring.datasource.url=jdbc:mysql://192.168.45.40:3306/db_iemr +spring.datasource.username=app_user +spring.datasource.password=NewSecureP@ss123! + +source-address= +sms-username= +sms-password= +send-message-url= + From 095237edb35c96ceeb318a3d00b3fe1b9e98d590 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 16:46:23 +0530 Subject: [PATCH 342/792] hbync api --- .../java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java index c5dc11f4..4a6226b4 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleRegister.java @@ -1,5 +1,6 @@ package com.iemr.flw.domain.iemr; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; import jakarta.persistence.*; @@ -11,6 +12,7 @@ @Entity @Table(name = "t_eligible_couple_register", schema = "db_iemr") @Data +@JsonInclude(JsonInclude.Include.ALWAYS) // Null values included public class EligibleCoupleRegister { @Id From 0c45962fca48ea451d59f3bb58fd35dfc9cea70e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 16:56:38 +0530 Subject: [PATCH 343/792] hbync api --- src/main/java/com/iemr/flw/controller/ChildCareController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 8d3f9fa7..28963620 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -32,7 +32,7 @@ public class ChildCareController { private ChildCareService childCareService; @Operation(summary = "save HBYC details") - @RequestMapping(value = {"/hbyc/saveAll"}, method = {RequestMethod.POST}) + @RequestMapping(value = {"/hbycVisit/saveAll"}, method = {RequestMethod.POST}) public String saveHbycRecords(@RequestBody List hbycDTOs, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); From 00a3d6f5bf997cc3a83aebc13abc78f44977a43c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 17:14:42 +0530 Subject: [PATCH 344/792] hbync api --- .../iemr/flw/domain/iemr/HbycChildVisit.java | 8 ++-- .../java/com/iemr/flw/dto/iemr/HbycDTO.java | 9 ++-- .../service/impl/ChildCareServiceImpl.java | 44 ++++++++++++++----- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index dce92723..9ea9d01c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -2,8 +2,6 @@ import jakarta.persistence.*; import java.math.BigDecimal; -import java.sql.Timestamp; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; @@ -30,16 +28,16 @@ public class HbycChildVisit { private String hbycVisit; // 3 Months, 6 Months, etc. @Column(name = "hbyc_due_date") - private LocalDate hbycDueDate; + private String hbycDueDate; @Column(name = "hbyc_visit_date") - private Timestamp hbycVisitDate; + private String hbycVisitDate; @Column(name = "is_baby_alive") private Boolean isBabyAlive = true; @Column(name = "date_of_death") - private LocalDate dateOfDeath; + private String dateOfDeath; @Column(name = "reason_for_death") private String reasonForDeath; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index 0d69d020..abcd17be 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -16,8 +16,7 @@ import java.math.BigDecimal; import java.sql.Timestamp; -import java.time.LocalDate; -import java.time.LocalDateTime; + import java.util.List; @Data @@ -31,16 +30,16 @@ public class HbycDTO { private String hbycVisit; // 3 Months, 6 Months, etc. @SerializedName("hbyc_due_date") - private LocalDate hbycDueDate; + private String hbycDueDate; @SerializedName("hbyc_visit_date") - private Timestamp hbycVisitDate; + private String hbycVisitDate; @SerializedName("is_baby_alive") private Boolean isBabyAlive; @SerializedName("date_of_death") - private LocalDate dateOfDeath; + private String dateOfDeath; @SerializedName("reason_for_death") private String reasonForDeath; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 7259ee88..a314036f 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -61,10 +61,18 @@ public class ChildCareServiceImpl implements ChildCareService { @Override public String registerHBYC(List hbycDTOs) { try { + List hbycList = new ArrayList<>(); hbycDTOs.forEach(it -> { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Convert to LocalDate + LocalDate localDate = LocalDate.parse(it.getVisitDate(), formatter); + + // Convert LocalDate to Timestamp (00:00:00 by default) + Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDate(it.getBeneficiaryId(), it.getFields().getHbycVisitDate()); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDate(it.getBeneficiaryId(), visitDate); if (hbyc != null) { Long id = hbyc.getId(); @@ -465,19 +473,26 @@ record = new IncentiveActivityRecord(); } private void createIncentiveRecordforHbyncVisit(HbycChildVisit data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Convert to LocalDate + LocalDate localDate = LocalDate.parse(data.getHbycVisitDate(), formatter); + + // Convert LocalDate to Timestamp (00:00:00 by default) + Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getHbycVisitDate(), benId); + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), visitDate, benId); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(data.getHbycVisitDate()); + record.setCreatedDate(visitDate); record.setCreatedBy(createdBy); - record.setStartDate(data.getHbycVisitDate()); - record.setEndDate(data.getHbycVisitDate()); - record.setUpdatedDate(data.getHbycVisitDate()); + record.setStartDate(visitDate); + record.setEndDate(visitDate); + record.setUpdatedDate(visitDate); record.setUpdatedBy(createdBy); record.setBenId(benId); record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); @@ -488,19 +503,26 @@ record = new IncentiveActivityRecord(); private void createIncentiveRecordforHbyncOrsDistribution(HbycChildVisit data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + // Convert to LocalDate + LocalDate localDate = LocalDate.parse(data.getHbycVisitDate(), formatter); + + // Convert LocalDate to Timestamp (00:00:00 by default) + Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), data.getHbycVisitDate(), benId); + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), visitDate, benId); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(data.getHbycVisitDate()); + record.setCreatedDate(visitDate); record.setCreatedBy(createdBy); - record.setStartDate(data.getHbycVisitDate()); - record.setEndDate(data.getHbycVisitDate()); - record.setUpdatedDate(data.getHbycVisitDate()); + record.setStartDate(visitDate); + record.setEndDate(visitDate); + record.setUpdatedDate(visitDate); record.setUpdatedBy(createdBy); record.setBenId(benId); record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); From 3f8932278dbcdf150b6bd30ddaf58d1d97b6e708 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 17:24:21 +0530 Subject: [PATCH 345/792] hbync api --- src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java | 4 ++-- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 8 +------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index abcd17be..e66644e9 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -26,10 +26,10 @@ public class HbycDTO { @SerializedName("beneficiary_id") private Long beneficiaryId; - @SerializedName("hbyc_visit") + @SerializedName("visit_day") private String hbycVisit; // 3 Months, 6 Months, etc. - @SerializedName("hbyc_due_date") + @SerializedName("due_date") private String hbycDueDate; @SerializedName("hbyc_visit_date") diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 9144c98b..4fc7f22b 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -13,7 +13,7 @@ @Repository public interface HbycRepo extends JpaRepository { - HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDate(Long benId, Timestamp createdDate); + HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisit(Long benId, String createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index a314036f..434cf3dc 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -64,15 +64,9 @@ public String registerHBYC(List hbycDTOs) { List hbycList = new ArrayList<>(); hbycDTOs.forEach(it -> { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - // Convert to LocalDate - LocalDate localDate = LocalDate.parse(it.getVisitDate(), formatter); - - // Convert LocalDate to Timestamp (00:00:00 by default) - Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDate(it.getBeneficiaryId(), visitDate); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisit(it.getBeneficiaryId(), it.getFields().getHbycVisit()); if (hbyc != null) { Long id = hbyc.getId(); From 1712335193d1f23156d45ea9ca35e640a4760fe2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 17:31:33 +0530 Subject: [PATCH 346/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 434cf3dc..1cdbaf5c 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -78,6 +78,8 @@ public String registerHBYC(List hbycDTOs) { hbyc = new HbycChildVisit(); modelMapper.map(it, hbyc); hbyc.setId(null); + hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); + hbyc.setCreatedBy(it.getUserName()); } hbycList.add(hbyc); From 8db663f4574d6f2b2d676fe6070dc8fb1ab8b100 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 9 Oct 2025 18:38:16 +0530 Subject: [PATCH 347/792] hbync api --- .../flw/controller/ChildCareController.java | 4 +- .../iemr/flw/domain/iemr/HbycChildVisit.java | 3 + .../flw/dto/iemr/HbncVisitResponseDTO.java | 1 + .../java/com/iemr/flw/dto/iemr/HbycDTO.java | 81 ++++++++++--------- .../flw/dto/iemr/HbycVisitResponseDTO.java | 14 ++++ .../java/com/iemr/flw/repo/iemr/HbycRepo.java | 3 + .../iemr/flw/service/ChildCareService.java | 2 +- .../service/impl/ChildCareServiceImpl.java | 62 +++++++++++--- 8 files changed, 119 insertions(+), 51 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/HbycVisitResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 28963620..57f65216 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -54,14 +54,14 @@ public String saveHbycRecords(@RequestBody List hbycDTOs, } @Operation(summary = "get List of HBYC details") - @RequestMapping(value = {"/hbyc/getAll"}, method = {RequestMethod.POST}) + @RequestMapping(value = {"/hbycVisit/getAll"}, method = {RequestMethod.POST}) public String getHbycRecords(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { logger.info("fetching All HBYC Details for user: " + requestDTO.getAshaId()); if (requestDTO != null) { - List result = childCareService.getHbycRecords(requestDTO); + List result = childCareService.getHbycRecords(requestDTO); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); String s = gson.toJson(result); if (s != null) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 9ea9d01c..733697a9 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -21,6 +21,9 @@ public class HbycChildVisit { @Column(name = "beneficiary_id") private Long beneficiaryId; + @Column(name = "household_id") + private Long houseHoldId; + @Column(name = "user_id") private Integer userId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbncVisitResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbncVisitResponseDTO.java index 5ca840f6..48f66e4b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbncVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbncVisitResponseDTO.java @@ -12,3 +12,4 @@ public class HbncVisitResponseDTO { private String visitDate; private Map fields; // for dynamic form fields } + diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index e66644e9..c0ef7dc7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -29,14 +29,17 @@ public class HbycDTO { @SerializedName("visit_day") private String hbycVisit; // 3 Months, 6 Months, etc. + @SerializedName("household_id") + private Long houseHoldId; + @SerializedName("due_date") private String hbycDueDate; - @SerializedName("hbyc_visit_date") + @SerializedName("visit_date") private String hbycVisitDate; @SerializedName("is_baby_alive") - private Boolean isBabyAlive; + private String isBabyAlive; // Yes/No @SerializedName("date_of_death") private String dateOfDeath; @@ -51,63 +54,63 @@ public class HbycDTO { private String otherPlaceOfDeath; @SerializedName("baby_weight") - private BigDecimal babyWeight; // 0.5 - 7.0 + private BigDecimal babyWeight; @SerializedName("is_child_sick") - private Boolean isChildSick; + private String isChildSick; - @SerializedName("is_exclusive_breastfeeding") - private Boolean isExclusiveBreastfeeding; + @SerializedName("exclusive_breastfeeding") + private String isExclusiveBreastfeeding; - @SerializedName("is_mother_counseled_exbf") - private Boolean isMotherCounseledExbf; + @SerializedName("mother_counseled_ebf") + private String isMotherCounseledExbf; - @SerializedName("has_child_started_complementary_feeding") - private Boolean hasChildStartedComplementaryFeeding; + @SerializedName("complementary_feeding") + private String hasChildStartedComplementaryFeeding; - @SerializedName("is_mother_counseled_cf") - private Boolean isMotherCounseledCf; + @SerializedName("mother_counseled_cf") + private String isMotherCounseledCf; - @SerializedName("is_weight_recorded_by_aww") - private Boolean isWeightRecordedByAww; + @SerializedName("weight_recorded") + private String isWeightRecordedByAww; - @SerializedName("is_developmental_delay") - private Boolean isDevelopmentalDelay; + @SerializedName("developmental_delay") + private String isDevelopmentalDelay; - @SerializedName("is_measles_vaccine_given") - private Boolean isMeaslesVaccineGiven; + @SerializedName("measles_vaccine") + private String isMeaslesVaccineGiven; - @SerializedName("is_vitamin_a_given") - private Boolean isVitaminAGiven; + @SerializedName("vitamin_a") + private String isVitaminAGiven; - @SerializedName("is_ors_available") - private Boolean isOrsAvailable; + @SerializedName("ors_available") + private String isOrsAvailable; - @SerializedName("is_ifa_syrup_available") - private Boolean isIfaSyrupAvailable; + @SerializedName("ifa_available") + private String isIfaSyrupAvailable; - @SerializedName("is_ors_given") - private Boolean isOrsGiven; + @SerializedName("ors_given") + private String isOrsGiven; - @SerializedName("is_ifa_syrup_given") - private Boolean isIfaSyrupGiven; + @SerializedName("ifa_given") + private String isIfaSyrupGiven; - @SerializedName("is_handwashing_counseling_given") - private Boolean isHandwashingCounselingGiven; + @SerializedName("handwash_counseling") + private String isHandwashingCounselingGiven; - @SerializedName("is_parenting_counseling_given") - private Boolean isParentingCounselingGiven; + @SerializedName("parenting_counseling") + private String isParentingCounselingGiven; - @SerializedName("is_family_planning_counseling_given") - private Boolean isFamilyPlanningCounselingGiven; + @SerializedName("family_planning_counseling") + private String isFamilyPlanningCounselingGiven; @SerializedName("diarrhoea_episode") - private Boolean diarrhoeaEpisode; + private String diarrhoeaEpisode; - @SerializedName("pneumonia_symptoms") - private Boolean pneumoniaSymptoms; + @SerializedName("breathing_difficulty") + private String pneumoniaSymptoms; - @SerializedName("temperature") + @SerializedName("temperature_check") private BigDecimal temperature; @SerializedName("mcp_card_images") @@ -119,7 +122,7 @@ public class HbycDTO { @SerializedName("updated_at") private LocalDateTime updatedAt; - // Getters and Setters + } diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycVisitResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycVisitResponseDTO.java new file mode 100644 index 00000000..e569e223 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycVisitResponseDTO.java @@ -0,0 +1,14 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Map; + +@Data +public class HbycVisitResponseDTO { + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private Map fields; // for dynamic form fields +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 4fc7f22b..8e1cb633 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -18,4 +18,7 @@ public interface HbycRepo extends JpaRepository { @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); + + + List findByUserId(Integer ashaId); } diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index 6bac9717..0ae7a0a7 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -10,7 +10,7 @@ public interface ChildCareService { String registerHBYC(List hbycDTOs); - List getHbycRecords(GetBenRequestHandler dto); + List getHbycRecords(GetBenRequestHandler dto); List getHBNCDetails(GetBenRequestHandler dto); diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 1cdbaf5c..47a49078 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -95,18 +95,62 @@ public String registerHBYC(List hbycDTOs) { } @Override - public List getHbycRecords(GetBenRequestHandler dto) { + public List getHbycRecords(GetBenRequestHandler dto) { + List result = new ArrayList<>(); + try { - String user = beneficiaryRepo.getUserName(dto.getAshaId()); - List hbycList = - hbycRepo.getAllHbycByBenId(user, dto.getFromDate(), dto.getToDate()); - return hbycList.stream() - .map(hbyc -> mapper.convertValue(hbyc, HbycDTO.class)) - .collect(Collectors.toList()); + List hbycChildVisits = hbycRepo.findByUserId(dto.getAshaId()); + + for (HbycChildVisit hbycChildVisit : hbycChildVisits) { + HbycVisitResponseDTO hbycRequestDTO = new HbycVisitResponseDTO(); + hbycRequestDTO.setId(hbycChildVisit.getId()); + hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiaryId()); + hbycRequestDTO.setHouseHoldId(hbycChildVisit.getHouseHoldId()); + hbycRequestDTO.setVisitDate(hbycChildVisit.getHbycVisitDate()); + + // Prepare dynamic fields map + Map fields = new HashMap<>(); + addIfValid(fields, "visit_day", hbycChildVisit.getHbycVisit()); + addIfValid(fields, "due_date", hbycChildVisit.getHbycDueDate()); + addIfValid(fields, "visit_date", hbycChildVisit.getHbycVisitDate()); + addIfValid(fields, "is_baby_alive", convert(hbycChildVisit.getIsBabyAlive())); + addIfValid(fields, "date_of_death", hbycChildVisit.getDateOfDeath()); + addIfValid(fields, "reason_for_death", hbycChildVisit.getReasonForDeath()); + addIfValid(fields, "place_of_death", hbycChildVisit.getPlaceOfDeath()); + addIfValid(fields, "other_place_of_death", hbycChildVisit.getOtherPlaceOfDeath()); + addIfValid(fields, "baby_weight", hbycChildVisit.getBabyWeight()); + addIfValid(fields, "is_child_sick", convert(hbycChildVisit.getIsChildSick())); + addIfValid(fields, "exclusive_breastfeeding", convert(hbycChildVisit.getIsExclusiveBreastfeeding())); + addIfValid(fields, "mother_counseled_ebf", convert(hbycChildVisit.getIsMotherCounseledExbf())); + addIfValid(fields, "complementary_feeding", convert(hbycChildVisit.getHasChildStartedComplementaryFeeding())); + addIfValid(fields, "mother_counseled_cf", convert(hbycChildVisit.getIsMotherCounseledCf())); + addIfValid(fields, "weight_recorded", convert(hbycChildVisit.getIsWeightRecordedByAww())); + addIfValid(fields, "developmental_delay", convert(hbycChildVisit.getIsDevelopmentalDelay())); + addIfValid(fields, "measles_vaccine", convert(hbycChildVisit.getIsMeaslesVaccineGiven())); + addIfValid(fields, "vitamin_a", convert(hbycChildVisit.getIsVitaminAGiven())); + addIfValid(fields, "ors_available", convert(hbycChildVisit.getIsOrsAvailable())); + addIfValid(fields, "ifa_available", convert(hbycChildVisit.getIsIfaSyrupAvailable())); + addIfValid(fields, "ors_given", convert(hbycChildVisit.getIsOrsGiven())); + addIfValid(fields, "ifa_given", convert(hbycChildVisit.getIsIfaSyrupGiven())); + addIfValid(fields, "handwash_counseling", convert(hbycChildVisit.getIsHandwashingCounselingGiven())); + addIfValid(fields, "parenting_counseling", convert(hbycChildVisit.getIsParentingCounselingGiven())); + addIfValid(fields, "family_planning_counseling", convert(hbycChildVisit.getIsFamilyPlanningCounselingGiven())); + addIfValid(fields, "diarrhoea_episode", convert(hbycChildVisit.getDiarrhoeaEpisode())); + addIfValid(fields, "breathing_difficulty", convert(hbycChildVisit.getPneumoniaSymptoms())); + addIfValid(fields, "temperature_check", hbycChildVisit.getTemperature()); + addIfValid(fields, "mcp_card_images", hbycChildVisit.getMcpCardImages()); + + // Set fields map in DTO + hbycRequestDTO.setFields(fields); + result.add(hbycRequestDTO); + } + } catch (Exception e) { - logger.info("error while fetching hbyc details: " + e.getMessage()); + logger.error("Error while fetching HBYC details: ", e); } - return null; + + return result; + } @Override From 32bc79e397a247b41bad694fe4ae57e3d1a668d2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 10:22:13 +0530 Subject: [PATCH 348/792] hbync api --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 7ba3a896..0e6cbcdf 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -259,7 +259,9 @@ public String getEligibleCoupleRegRecords(GetBenRequestHandler dto) { List list = eligibleCoupleRegisterList.stream() .map(eligibleCoupleRegister -> mapper.convertValue(eligibleCoupleRegister, EligibleCoupleDTO.class)) .collect(Collectors.toList()); - Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); + Gson gson = new GsonBuilder() + .serializeNulls() + .setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(list); } catch (Exception e) { logger.error(e.getMessage()); From 6c573d1eb64b5bc0aef48185711be0199c9a4e56 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 10:55:25 +0530 Subject: [PATCH 349/792] hbync api --- .../iemr/flw/controller/BeneficiaryController.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index dbcbc7cd..e76c0c45 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -2,9 +2,11 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.service.BeneficiaryService; +import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -20,12 +22,19 @@ public class BeneficiaryController { @Autowired BeneficiaryService beneficiaryService; + @Autowired + private JwtUtil jwtUtil; + @RequestMapping(value = "/getBeneficiaryData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String authorization) { + @RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { OutputResponse response = new OutputResponse(); + + String userName = jwtUtil.extractUsername(authorization); + logger.info("Ben_UserName:"+userName); try { + if (requestDTO != null) { logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + requestDTO); From 57704943a90cf024aa7a66230605f6f58c5e33d3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 11:01:50 +0530 Subject: [PATCH 350/792] hbync api --- .../java/com/iemr/flw/controller/IncentiveController.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index 9d94b3bb..a84092e5 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -4,10 +4,12 @@ import com.iemr.flw.dto.iemr.IncentiveActivityDTO; import com.iemr.flw.dto.iemr.IncentiveRequestDTO; import com.iemr.flw.service.IncentiveService; +import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,12 +24,16 @@ public class IncentiveController { private final Logger logger = LoggerFactory.getLogger(IncentiveController.class); + @Autowired + private JwtUtil jwtUtil; @Autowired IncentiveService incentiveService; @Operation(summary = "save incentive master") @RequestMapping(value = { "/masterData/saveAll" }, method = { RequestMethod.POST }) - public String saveIncentiveMasterData(@RequestBody List activityDTOS) { + public String saveIncentiveMasterData(@RequestBody List activityDTOS,@RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { + String userName = jwtUtil.extractUsername(authorization); + logger.info("Ben_UserName:"+userName); OutputResponse response = new OutputResponse(); try { logger.info("Saving All incentives"); From 43b292a6d9866d9adaec29dec5df8c8a3759a5d2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 11:10:28 +0530 Subject: [PATCH 351/792] hbync api --- .../java/com/iemr/flw/controller/IncentiveController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index a84092e5..31e13c92 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -32,8 +32,6 @@ public class IncentiveController { @Operation(summary = "save incentive master") @RequestMapping(value = { "/masterData/saveAll" }, method = { RequestMethod.POST }) public String saveIncentiveMasterData(@RequestBody List activityDTOS,@RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { - String userName = jwtUtil.extractUsername(authorization); - logger.info("Ben_UserName:"+userName); OutputResponse response = new OutputResponse(); try { logger.info("Saving All incentives"); @@ -58,6 +56,9 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { + logger.info("Authorization:"+Authorization); + String userName = jwtUtil.extractUsername(Authorization); + logger.info("Ben_UserName:"+userName); logger.info("get All incentives"); // add logic for different state or district From 872f9141302478e8c80fd78e801a98ecfe566ecd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 11:41:50 +0530 Subject: [PATCH 352/792] hbync api --- .../com/iemr/flw/controller/BeneficiaryController.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index e76c0c45..11e0a202 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -22,17 +22,14 @@ public class BeneficiaryController { @Autowired BeneficiaryService beneficiaryService; - @Autowired - private JwtUtil jwtUtil; + @RequestMapping(value = "/getBeneficiaryData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { + @RequestHeader(value = "Authorization") String authorization) { OutputResponse response = new OutputResponse(); - String userName = jwtUtil.extractUsername(authorization); - logger.info("Ben_UserName:"+userName); try { if (requestDTO != null) { From 383ae4cc133c3c10804913e208ae4c3305d5be27 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:30:45 +0530 Subject: [PATCH 353/792] hbync api --- .../iemr/flw/controller/CoupleController.java | 19 +++++++------ .../iemr/flw/dto/iemr/EligibleCoupleDTO.java | 2 -- .../flw/service/impl/CoupleServiceImpl.java | 27 +++++++++++++++---- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CoupleController.java b/src/main/java/com/iemr/flw/controller/CoupleController.java index 5036e1d5..42c75fbf 100644 --- a/src/main/java/com/iemr/flw/controller/CoupleController.java +++ b/src/main/java/com/iemr/flw/controller/CoupleController.java @@ -6,11 +6,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -21,6 +17,7 @@ import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.web.multipart.MultipartFile; @RestController @RequestMapping(value = "/couple", headers = "Authorization") @@ -31,15 +28,21 @@ public class CoupleController { @Autowired private CoupleService coupleService; + private String kitPhoto1; + + private String kitPhoto2; + @Operation(summary = "save eligible couple registration details") @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST }) - public String saveEligibleCouple(@RequestBody List eligibleCoupleDTOs, - @RequestHeader(value = "Authorization") String Authorization) { + public String saveEligibleCouple(@RequestPart("data") List eligibleCoupleDTOs, + @RequestPart(value = "kitPhoto1", required = false) MultipartFile kitPhoto1, + @RequestPart(value = "kitPhoto2", required = false) MultipartFile kitPhoto2, + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { logger.info("Saving All Eligible Couple Details"); if (eligibleCoupleDTOs != null) { - String s = coupleService.registerEligibleCouple(eligibleCoupleDTOs); + String s = coupleService.registerEligibleCouple(eligibleCoupleDTOs,kitPhoto1,kitPhoto2); if (s != null) response.setResponse(s); else diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index d583ba0c..ad2d9564 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -114,8 +114,6 @@ public class EligibleCoupleDTO implements Serializable { private String kitHandedOverDate; - private String kitPhoto1; - private String kitPhoto2; } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 0e6cbcdf..3d762635 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -18,7 +18,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; import java.util.Base64; @@ -52,7 +54,7 @@ public class CoupleServiceImpl implements CoupleService { private final Logger logger = LoggerFactory.getLogger(CoupleServiceImpl.class); @Override - public String registerEligibleCouple(List eligibleCoupleDTOs) { + public String registerEligibleCouple(List eligibleCoupleDTOs, MultipartFile kitPhoto1, MultipartFile kitPhoto2) { try { List ecrList = new ArrayList<>(); List recordList = new ArrayList<>(); @@ -60,13 +62,26 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) EligibleCoupleRegister existingECR = // eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); - if (it.getKitPhoto1() != null && !it.getKitPhoto1().isEmpty()) { - existingECR.setKitPhoto1(it.getKitPhoto1()); + if (kitPhoto1 != null && !kitPhoto1.isEmpty()) { + String kitPhoto1base64Image = null; + try { + kitPhoto1base64Image = Base64.getEncoder().encodeToString(kitPhoto1.getBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + existingECR.setKitPhoto1(String.valueOf(kitPhoto1base64Image)); } - if (it.getKitPhoto2() != null && !it.getKitPhoto2().isEmpty()) { - existingECR.setKitPhoto2(it.getKitPhoto2()); + + if (kitPhoto2 != null && !kitPhoto2.isEmpty()) { + String kitPhoto2base64Image = null; + try { + kitPhoto2base64Image = Base64.getEncoder().encodeToString(kitPhoto2.getBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + existingECR.setKitPhoto2(String.valueOf(kitPhoto2base64Image)); } @@ -285,4 +300,6 @@ public List getEligibleCoupleTracking(GetBenRequestHa } return null; } + + } From 75ee6498c1edfcf0f2a8fa8d4bd5cb3cc95d726d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:38:37 +0530 Subject: [PATCH 354/792] hbync api --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 3d762635..f5b5ec13 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -62,7 +62,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, EligibleCoupleRegister existingECR = // eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); - if (kitPhoto1 != null && !kitPhoto1.isEmpty()) { + if (kitPhoto1 != null) { String kitPhoto1base64Image = null; try { kitPhoto1base64Image = Base64.getEncoder().encodeToString(kitPhoto1.getBytes()); @@ -74,7 +74,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, } - if (kitPhoto2 != null && !kitPhoto2.isEmpty()) { + if (kitPhoto2 != null) { String kitPhoto2base64Image = null; try { kitPhoto2base64Image = Base64.getEncoder().encodeToString(kitPhoto2.getBytes()); From 03560069b2c011d3b9aae84187d80c2b4dd6f40d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:40:52 +0530 Subject: [PATCH 355/792] hbync api --- src/main/java/com/iemr/flw/controller/CoupleController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/CoupleController.java b/src/main/java/com/iemr/flw/controller/CoupleController.java index 42c75fbf..d0cc807b 100644 --- a/src/main/java/com/iemr/flw/controller/CoupleController.java +++ b/src/main/java/com/iemr/flw/controller/CoupleController.java @@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.*; import com.google.gson.Gson; @@ -33,7 +34,7 @@ public class CoupleController { private String kitPhoto2; @Operation(summary = "save eligible couple registration details") - @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST }) + @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST },consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public String saveEligibleCouple(@RequestPart("data") List eligibleCoupleDTOs, @RequestPart(value = "kitPhoto1", required = false) MultipartFile kitPhoto1, @RequestPart(value = "kitPhoto2", required = false) MultipartFile kitPhoto2, From bab3e03404b2e081f8ab38bc75a9e479a1c64b61 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:43:15 +0530 Subject: [PATCH 356/792] hbync api --- src/main/java/com/iemr/flw/controller/CoupleController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CoupleController.java b/src/main/java/com/iemr/flw/controller/CoupleController.java index d0cc807b..14561e02 100644 --- a/src/main/java/com/iemr/flw/controller/CoupleController.java +++ b/src/main/java/com/iemr/flw/controller/CoupleController.java @@ -34,8 +34,8 @@ public class CoupleController { private String kitPhoto2; @Operation(summary = "save eligible couple registration details") - @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST },consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String saveEligibleCouple(@RequestPart("data") List eligibleCoupleDTOs, + @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST }) + public String saveEligibleCouple(@RequestBody List eligibleCoupleDTOs, @RequestPart(value = "kitPhoto1", required = false) MultipartFile kitPhoto1, @RequestPart(value = "kitPhoto2", required = false) MultipartFile kitPhoto2, @RequestHeader(value = "Authorization") String Authorization) { From 441ea3490be9121f00e1bbbf59f7a8907b7cae39 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:47:23 +0530 Subject: [PATCH 357/792] hbync api --- src/main/java/com/iemr/flw/service/CoupleService.java | 3 ++- src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/CoupleService.java b/src/main/java/com/iemr/flw/service/CoupleService.java index b6f60177..ab690396 100644 --- a/src/main/java/com/iemr/flw/service/CoupleService.java +++ b/src/main/java/com/iemr/flw/service/CoupleService.java @@ -3,12 +3,12 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.EligibleCoupleDTO; import com.iemr.flw.dto.iemr.EligibleCoupleTrackingDTO; +import org.springframework.web.multipart.MultipartFile; import java.util.List; public interface CoupleService { - String registerEligibleCouple(List eligibleCoupleDTOs); String registerEligibleCoupleTracking(List eligibleCoupleTrackingDTOs); @@ -16,4 +16,5 @@ public interface CoupleService { List getEligibleCoupleTracking(GetBenRequestHandler requestDto); + String registerEligibleCouple(List eligibleCoupleDTOs, MultipartFile kitPhoto1, MultipartFile kitPhoto2); } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index f5b5ec13..a4a81c91 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -53,6 +53,7 @@ public class CoupleServiceImpl implements CoupleService { private final Logger logger = LoggerFactory.getLogger(CoupleServiceImpl.class); + @Override public String registerEligibleCouple(List eligibleCoupleDTOs, MultipartFile kitPhoto1, MultipartFile kitPhoto2) { try { From 79715bd0b0a1dc8a5ea30a1eb0687840e0332dde Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 12:59:41 +0530 Subject: [PATCH 358/792] hbync api --- .../flw/controller/SammelanController.java | 15 ++- .../iemr/flw/dto/iemr/SammelanRequestDTO.java | 1 - .../com/iemr/flw/service/SammelanService.java | 2 +- .../flw/service/impl/SammelanServiceImpl.java | 111 +++++++++--------- 4 files changed, 68 insertions(+), 61 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 541b75c7..2fe77519 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import java.sql.Timestamp; import java.util.List; @RestController @@ -30,9 +31,19 @@ public class SammelanController { @RequestMapping(value = "saveAll",method = RequestMethod.POST) public ResponseEntity create( - @RequestBody @Valid List payload) { - SammelanResponseDTO resp = service.submitSammelan(payload); + @RequestPart("date") String date, + @RequestPart("place") String place, + @RequestPart("participants") String participants, + @RequestPart("ashaId") String ashaId, + @RequestPart(value = "meetingImages", required = false) MultipartFile[] images) { + SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); + sammelanRequestDTO.setPlace(place); + sammelanRequestDTO.setDate(Timestamp.valueOf(date)); + sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); + + + SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO,images); return ResponseEntity.status(HttpStatus.CREATED).body(resp); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index a172baeb..a731d05e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -13,6 +13,5 @@ public class SammelanRequestDTO { private Timestamp date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center private Integer participants; // Number of participants attended - private MultipartFile[] attachments; // up to 5 images } diff --git a/src/main/java/com/iemr/flw/service/SammelanService.java b/src/main/java/com/iemr/flw/service/SammelanService.java index 4aef6689..fbe4ae37 100644 --- a/src/main/java/com/iemr/flw/service/SammelanService.java +++ b/src/main/java/com/iemr/flw/service/SammelanService.java @@ -13,7 +13,7 @@ public interface SammelanService { * @param dto request data * @return saved SammelanResponseDTO with incentive details */ - SammelanResponseDTO submitSammelan(List dto); + public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, MultipartFile[] images); /** * Fetch Sammelan history for given ASHA worker diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 7b094b3e..77a2d35b 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -11,6 +11,7 @@ import com.iemr.flw.service.SammelanService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.time.LocalDate; import java.time.YearMonth; @@ -33,67 +34,65 @@ public class SammelanServiceImpl implements SammelanService { @Override - public SammelanResponseDTO submitSammelan(List dto) { + public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, MultipartFile[] images) { SammelanResponseDTO response = new SammelanResponseDTO(); try { - dto.forEach(sammelanRequestDTO -> { - validateRequest(sammelanRequestDTO); - LocalDate localDate = sammelanRequestDTO.getDate().toInstant() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - - YearMonth ym = YearMonth.from(localDate); - - // Check for existing record in same month - boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( - sammelanRequestDTO.getAshaId(), - ym.atDay(1), - ym.atEndOfMonth() - ); - if (exists) { - throw new IllegalArgumentException("Sammelan already submitted for this month."); - } + validateRequest(sammelanRequestDTO); + LocalDate localDate = sammelanRequestDTO.getDate().toInstant() + .atZone(ZoneId.systemDefault()) + .toLocalDate(); + + YearMonth ym = YearMonth.from(localDate); + + // Check for existing record in same month + boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( + sammelanRequestDTO.getAshaId(), + ym.atDay(1), + ym.atEndOfMonth() + ); + if (exists) { + throw new IllegalArgumentException("Sammelan already submitted for this month."); + } - // Save Sammelan record - record = new SammelanRecord(); - record.setAshaId(sammelanRequestDTO.getAshaId()); - record.setMeetingDate(sammelanRequestDTO.getDate()); - record.setPlace(sammelanRequestDTO.getPlace()); - record.setParticipants(sammelanRequestDTO.getParticipants()); - record = recordRepo.save(record); - - // Save Attachments - if (sammelanRequestDTO.getAttachments() != null && sammelanRequestDTO.getAttachments().length > 0) { - List base64Images = List.of(sammelanRequestDTO.getAttachments()) - .stream() - .filter(file -> !file.isEmpty()) - .map(file -> { - try { - return Base64.getEncoder().encodeToString(file.getBytes()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); - - String imagesJson = null; - try { - imagesJson = objectMapper.writeValueAsString(base64Images); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - record.setAttachments(imagesJson); + // Save Sammelan record + record = new SammelanRecord(); + record.setAshaId(sammelanRequestDTO.getAshaId()); + record.setMeetingDate(sammelanRequestDTO.getDate()); + record.setPlace(sammelanRequestDTO.getPlace()); + record.setParticipants(sammelanRequestDTO.getParticipants()); + record = recordRepo.save(record); + + // Save Attachments + if (images != null && images.length > 0) { + List base64Images = List.of(images) + .stream() + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (Exception e) { + throw new RuntimeException(e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = null; + try { + imagesJson = objectMapper.writeValueAsString(base64Images); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); } + record.setAttachments(imagesJson); + } - // Prepare Response DTO - response.setId(record.getId()); - response.setAshaId(record.getAshaId()); - response.setDate(record.getMeetingDate()); - response.setPlace(record.getPlace()); - response.setParticipants(record.getParticipants()); - }); + // Prepare Response DTO + response.setId(record.getId()); + response.setAshaId(record.getAshaId()); + response.setDate(record.getMeetingDate()); + response.setPlace(record.getPlace()); + response.setParticipants(record.getParticipants()); } catch (Exception e) { @@ -146,9 +145,7 @@ private void validateRequest(SammelanRequestDTO dto) { if (dto.getParticipants() < 0 || dto.getParticipants() > 999) { throw new IllegalArgumentException("Participants must be between 0–999."); } - if (dto.getAttachments() == null) { - throw new IllegalArgumentException("Minimum 2 attachments required."); - } + } } From ffdff2d0bd535b609a3b135473b06b153c15d911 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 13:01:38 +0530 Subject: [PATCH 359/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 2fe77519..fce56dce 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -39,6 +39,7 @@ public ResponseEntity create( @RequestPart(value = "meetingImages", required = false) MultipartFile[] images) { SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); + sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); sammelanRequestDTO.setDate(Timestamp.valueOf(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); From 697dde910ae5f66570d881f1d2cdee0fcd940bd7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 13:04:35 +0530 Subject: [PATCH 360/792] hbync api --- src/main/java/com/iemr/flw/controller/CoupleController.java | 4 ++-- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CoupleController.java b/src/main/java/com/iemr/flw/controller/CoupleController.java index 14561e02..d0cc807b 100644 --- a/src/main/java/com/iemr/flw/controller/CoupleController.java +++ b/src/main/java/com/iemr/flw/controller/CoupleController.java @@ -34,8 +34,8 @@ public class CoupleController { private String kitPhoto2; @Operation(summary = "save eligible couple registration details") - @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST }) - public String saveEligibleCouple(@RequestBody List eligibleCoupleDTOs, + @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST },consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String saveEligibleCouple(@RequestPart("data") List eligibleCoupleDTOs, @RequestPart(value = "kitPhoto1", required = false) MultipartFile kitPhoto1, @RequestPart(value = "kitPhoto2", required = false) MultipartFile kitPhoto2, @RequestHeader(value = "Authorization") String Authorization) { diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index fce56dce..d72a6ff5 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -36,7 +36,7 @@ public ResponseEntity create( @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, - @RequestPart(value = "meetingImages", required = false) MultipartFile[] images) { + @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) { SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); From 49c32332feeccb4ae9da983c70ce5162fd3022f8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 13:24:47 +0530 Subject: [PATCH 361/792] hbync api --- .../java/com/iemr/flw/FlwApplication.java | 11 +++- .../flw/controller/UwinSessionController.java | 57 +++++++++++++------ .../com/iemr/flw/masterEnum/GroupName.java | 35 ++++++++++++ .../service/impl/ChildCareServiceImpl.java | 22 +++---- .../impl/DeliveryOutcomeServiceImpl.java | 3 +- .../impl/MaternalHealthServiceImpl.java | 19 ++++--- .../service/impl/UwinSessionServiceImpl.java | 3 +- .../utils/sessionobject/SessionObject.java | 5 ++ 8 files changed, 112 insertions(+), 43 deletions(-) create mode 100644 src/main/java/com/iemr/flw/masterEnum/GroupName.java diff --git a/src/main/java/com/iemr/flw/FlwApplication.java b/src/main/java/com/iemr/flw/FlwApplication.java index 322edb48..e29d3468 100644 --- a/src/main/java/com/iemr/flw/FlwApplication.java +++ b/src/main/java/com/iemr/flw/FlwApplication.java @@ -1,8 +1,10 @@ package com.iemr.flw; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.utils.FLWApplBeans; +import jakarta.annotation.PostConstruct; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -16,8 +18,11 @@ @EntityScan(basePackages = {"com.iemr.flw.domain.identity", "com.iemr.flw.domain.iemr"}) @EnableScheduling public class FlwApplication extends SpringBootServletInitializer { + private Boolean IS_CH =true; public static void main(String[] args) { + + SpringApplication.run(applicationClass, args); } @@ -33,4 +38,8 @@ public FLWApplBeans instantiateBeans(){ return new FLWApplBeans(); } + @PostConstruct + public void init() { + GroupName.setIsCh(IS_CH); + } } diff --git a/src/main/java/com/iemr/flw/controller/UwinSessionController.java b/src/main/java/com/iemr/flw/controller/UwinSessionController.java index 0f077ad8..6fd31b16 100644 --- a/src/main/java/com/iemr/flw/controller/UwinSessionController.java +++ b/src/main/java/com/iemr/flw/controller/UwinSessionController.java @@ -4,7 +4,10 @@ import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; import com.iemr.flw.service.UwinSessionService; +import com.iemr.flw.utils.JwtUtil; +import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -18,13 +21,17 @@ import java.util.Map; @RestController -@RequestMapping(value = "/uwin/session", headers = "Authorization") -@RequiredArgsConstructor +@RequestMapping(value = "/uwin/session") public class UwinSessionController { - private final UwinSessionService service; - @RequestMapping(value = "saveAll",method = RequestMethod.POST,headers = "Authorization",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Autowired + private UwinSessionService service; + + @Autowired + private JwtUtil jwtUtil; + + @RequestMapping(value = "saveAll", method = RequestMethod.POST, headers = "Authorization", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity saveSession( @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @@ -42,30 +49,44 @@ public ResponseEntity saveSession( dto.setCreatedBy(createdBy); dto.setAttachments(images != null ? images.toArray(new MultipartFile[0]) : null); UwinSessionResponseDTO uwinSessionResponse = service.saveSession(dto); - if(uwinSessionResponse!=null){ - response.put("statusCode", 200); - response.put("message", "Data saved successfully"); - }else { - response.put("statusCode", 500); - response.put("message", "Something went wrong"); + try { + if (uwinSessionResponse != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Data saved successfully"); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + + } catch (Exception e) { + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); } return ResponseEntity.ok(response); } - @RequestMapping(value = "getAll",method = RequestMethod.POST,headers = "Authorization") - public ResponseEntity> getSessions(@RequestBody GetBenRequestHandler getBenRequestHandler) throws Exception { + @RequestMapping(value = "getAll", method = RequestMethod.POST,headers = "Authorization") + public ResponseEntity> getSessions(@RequestBody GetBenRequestHandler getBenRequestHandler, HttpServletRequest request) throws Exception { Map response = new LinkedHashMap<>(); try { Map data = new HashMap<>(); - data.put("userId", getBenRequestHandler.getUserId()); - data.put("entries", service.getSessionsByAsha(getBenRequestHandler.getAshaId())); - response.put("data", data); - response.put("statusCode", 200); - response.put("message", "Success"); + + List uwinSessionResponse = service.getSessionsByAsha(getBenRequestHandler.getAshaId()); + if (uwinSessionResponse!= null) { + data.put("userId", getBenRequestHandler.getUserId()); + data.put("entries", service.getSessionsByAsha(getBenRequestHandler.getAshaId())); + response.put("data", data); + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Success"); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "Data not found for this user"); + } + } catch (Exception e) { - response.put("statusCode", 500); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); } diff --git a/src/main/java/com/iemr/flw/masterEnum/GroupName.java b/src/main/java/com/iemr/flw/masterEnum/GroupName.java new file mode 100644 index 00000000..8d6736eb --- /dev/null +++ b/src/main/java/com/iemr/flw/masterEnum/GroupName.java @@ -0,0 +1,35 @@ +package com.iemr.flw.masterEnum; + +public enum GroupName { + CHILD_HEALTH("CHILD HEALTH"), + IMMUNIZATION("IMMUNIZATION"), + MATERNAL_HEALTH("MATERNAL HEALTH"), + JSY("JSY"), + FAMILY_PLANNING("FAMILY PLANNING"), + ADOLESCENT_HEALTH("ADOLESCENT HEALTH"), + ASHA_MONTHLY_ROUTINE("ASHA MONTHLY ROUTINE"), + UMBRELLA_PROGRAMMES("UMBRELLA PROGRAMMES"), + NCD("NCD"), + ADDITIONAL_INCENTIVE("ADDITIONAL INCENTIVE"), + OTHER_INCENTIVES("OTHER INCENTIVES"), + ACTIVITY("ACTIVITY"); + + private final String originalDisplayName; + private static boolean isCh = false; + + GroupName(String displayName) { + this.originalDisplayName = displayName; + } + + // Set the master flag + public static void setIsCh(boolean flag) { + isCh = flag; + } + + // Get display name based on isCh + public String getDisplayName() { + return isCh ? "ACTIVITY" : originalDisplayName; + } +} + + diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 47a49078..d9ad5065 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -1,12 +1,10 @@ package com.iemr.flw.service.impl; -import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.iemr.flw.domain.identity.RMNCHBeneficiaryDetailsRmnch; -import com.iemr.flw.domain.identity.RMNCHMBeneficiarydetail; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.ChildCareService; @@ -19,10 +17,8 @@ import java.math.BigInteger; import java.sql.Timestamp; import java.time.LocalDate; -import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; -import java.util.stream.Collectors; @Service public class ChildCareServiceImpl implements ChildCareService { @@ -375,10 +371,10 @@ public List getAllChildVaccines(String category) { private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity hbyncOrsPacketActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName()); if (hbyncVisitActivity != null) { if (hbyc.getHbycVisitDate() != null) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreatedBy()); @@ -410,21 +406,21 @@ private void checkAndAddHbncIncentives(List hbncVisits) { Long benId = hbncVisit.getBeneficiaryId(); if (hbncVisit.getVisit_day().equals("42nd Day")) { IncentiveActivity visitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); } if (hbncVisit.getVisit_day().equals("42nd Day") && isBabyDisChargeSNCUA) { IncentiveActivity babyDisChargeSNCUAActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); } if (!hbncVisit.getIs_baby_alive()) { IncentiveActivity isChildDeathActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity); } @@ -443,21 +439,21 @@ private void checkAndAddIncentives(List vaccinationList) { Integer immunizationServiceId = getImmunizationServiceIdForVaccine(vaccination.getVaccineId().shortValue()); if (immunizationServiceId < 6) { IncentiveActivity immunizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", "IMMUNIZATION"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.IMMUNIZATION.getDisplayName()); if (immunizationActivity != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) .equals(childVaccinationRepo.getFirstYearVaccineCount())) { createIncentiveRecord(vaccination, benId, userId, immunizationActivity); } } else if (immunizationServiceId == 7) { IncentiveActivity immunizationActivity2 = - incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", "IMMUNIZATION"); + incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", GroupName.IMMUNIZATION.getDisplayName()); if (immunizationActivity2 != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) .equals(childVaccinationRepo.getSecondYearVaccineCount())) { createIncentiveRecord(vaccination, benId, userId, immunizationActivity2); } } else if (immunizationServiceId == 8) { IncentiveActivity immunizationActivity5 = - incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", "IMMUNIZATION"); + incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.IMMUNIZATION.getDisplayName()); if (immunizationActivity5 != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { createIncentiveRecord(vaccination, benId, userId, immunizationActivity5); } diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 107a7914..927e38bc 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -10,6 +10,7 @@ import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.DeliveryOutcomeDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.identity.HouseHoldRepo; import com.iemr.flw.repo.iemr.DeliveryOutcomeRepo; @@ -170,7 +171,7 @@ public void checkAndAddJsyIncentive(List delOutList){ // For each activity, create record for(String activityName : activityNames){ - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName,"JSY"); + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName, GroupName.JSY.getDisplayName()); if(incentiveActivity != null){ createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivity); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 99d96c96..7031a0de 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -6,6 +6,7 @@ import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.MaternalHealthService; @@ -323,35 +324,35 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")){ IncentiveActivity maleSterilizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); if (maleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); } }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("FEMALE STERILIZATION")){ IncentiveActivity femaleSterilizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); if (femaleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); } }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MiniLap")){ IncentiveActivity miniLapActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MINILAP", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MINILAP", GroupName.FAMILY_PLANNING.getDisplayName()); if (miniLapActivity != null) { addIncenticeRecord(recordList, ect, userId, miniLapActivity); } }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Condom")){ IncentiveActivity comdomActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", GroupName.FAMILY_PLANNING.getDisplayName()); if (comdomActivity != null) { addIncenticeRecord(recordList, ect, userId, comdomActivity); } }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Copper T (IUCD)")){ IncentiveActivity copperTActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", GroupName.FAMILY_PLANNING.getDisplayName()); if (copperTActivity != null) { addIncenticeRecord(recordList, ect, userId, copperTActivity); } @@ -383,14 +384,14 @@ record = new IncentiveActivityRecord(); private void checkAndAddIncentives(List ancList) { IncentiveActivity anc1Activity = - incentivesRepo.findIncentiveMasterByNameAndGroup("ANC_REGISTRATION_1ST_TRIM", "MATERNAL HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("ANC_REGISTRATION_1ST_TRIM", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity ancFullActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", "MATERNAL HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity abortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", "MATERNAL HEALTH"); + IncentiveActivity abortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity identifiedHrpActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", "MATERNAL HEALTH"); + IncentiveActivity identifiedHrpActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); if (anc1Activity != null) { diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index f923c6bb..b2abd3ca 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -7,6 +7,7 @@ import com.iemr.flw.domain.iemr.UwinSession; import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.UserServiceRoleRepo; @@ -127,7 +128,7 @@ public List getSessionsByAsha(Integer ashaId) throws Exc } private void checkAndAddIncentive(UwinSession session) { - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", "IMMUNIZATION"); + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.IMMUNIZATION.getDisplayName()); IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), session.getDate(), 0L); diff --git a/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java b/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java index 9c8e4a03..c516a5c5 100644 --- a/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java +++ b/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java @@ -27,6 +27,8 @@ import com.iemr.flw.utils.config.ConfigProperties; import com.iemr.flw.utils.redis.RedisSessionException; import com.iemr.flw.utils.redis.RedisStorage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -47,6 +49,8 @@ public SessionObject() { private boolean extendExpirationTime; private int sessionExpiryTime; + Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + public String getSessionObject(String key) throws RedisSessionException { Boolean extendExpirationTime = ConfigProperties.getExtendExpiryTime(); Integer sessionExpiryTime = ConfigProperties.getSessionExpiryTime(); @@ -74,6 +78,7 @@ private void updateConcurrentSessionObject(String key, String value, Boolean ext JsonElement jsnElmnt = jsnParser.parse(value); jsnOBJ = jsnElmnt.getAsJsonObject(); if (jsnOBJ.has("userName") && jsnOBJ.get("userName") != null) { + logger.info("Saurav:"+jsnOBJ.get("userName")); objectStore.updateObject(jsnOBJ.get("userName").getAsString().trim().toLowerCase(), key, extendExpirationTime, sessionExpiryTime); } From f08152b91d0d1a9581c4705aec54ac6d3718dabc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 13:44:21 +0530 Subject: [PATCH 362/792] hbync api --- .../iemr/flw/controller/IncentiveController.java | 3 +-- src/main/java/com/iemr/flw/utils/JwtUtil.java | 16 ++++++++++++++-- .../flw/utils/sessionobject/SessionObject.java | 5 ++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index 31e13c92..7c27e884 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -56,8 +56,7 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { - logger.info("Authorization:"+Authorization); - String userName = jwtUtil.extractUsername(Authorization); + String userName = jwtUtil.getUserNameFromStorage(); logger.info("Ben_UserName:"+userName); logger.info("get All incentives"); diff --git a/src/main/java/com/iemr/flw/utils/JwtUtil.java b/src/main/java/com/iemr/flw/utils/JwtUtil.java index 4ccd85b7..7107d738 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUtil.java +++ b/src/main/java/com/iemr/flw/utils/JwtUtil.java @@ -4,6 +4,7 @@ import java.util.function.Function; import javax.crypto.SecretKey; +import com.google.gson.JsonElement; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -19,10 +20,10 @@ public class JwtUtil { @Value("${jwt.secret}") private String SECRET_KEY; + private String userName; @Autowired private TokenDenylist tokenDenylist; - // Generate a key using the secret private SecretKey getSigningKey() { if (SECRET_KEY == null || SECRET_KEY.isEmpty()) { @@ -86,5 +87,16 @@ private Claims extractAllClaims(String token) { .verifyWith(getSigningKey()) .build() .parseSignedClaims(token) - .getPayload(); } + .getPayload(); + } + + public String getUserNameFromStorage() { + return userName; + + } + + public void setUserNameFromStorage(String loginUserName) { + this.userName = loginUserName; + + } } diff --git a/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java b/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java index c516a5c5..d84a1684 100644 --- a/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java +++ b/src/main/java/com/iemr/flw/utils/sessionobject/SessionObject.java @@ -24,6 +24,7 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.config.ConfigProperties; import com.iemr.flw.utils.redis.RedisSessionException; import com.iemr.flw.utils.redis.RedisStorage; @@ -36,6 +37,8 @@ public class SessionObject { private RedisStorage objectStore; + @Autowired + private JwtUtil jwtUtil; @Autowired public void setObjectStore(RedisStorage objectStore) { this.objectStore = objectStore; @@ -78,7 +81,7 @@ private void updateConcurrentSessionObject(String key, String value, Boolean ext JsonElement jsnElmnt = jsnParser.parse(value); jsnOBJ = jsnElmnt.getAsJsonObject(); if (jsnOBJ.has("userName") && jsnOBJ.get("userName") != null) { - logger.info("Saurav:"+jsnOBJ.get("userName")); + jwtUtil.setUserNameFromStorage(jsnOBJ.get("userName").getAsString()); objectStore.updateObject(jsnOBJ.get("userName").getAsString().trim().toLowerCase(), key, extendExpirationTime, sessionExpiryTime); } From 9f3767dfcebe19c572a508eac2229a9a70cfb7b0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 14:01:33 +0530 Subject: [PATCH 363/792] hbync api --- .../flw/controller/IncentiveController.java | 6 +-- .../service/impl/IncentiveServiceImpl.java | 52 ++++++++++++++++++- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index 7c27e884..6f907b5c 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -24,8 +24,7 @@ public class IncentiveController { private final Logger logger = LoggerFactory.getLogger(IncentiveController.class); - @Autowired - private JwtUtil jwtUtil; + @Autowired IncentiveService incentiveService; @@ -56,8 +55,7 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { - String userName = jwtUtil.getUserNameFromStorage(); - logger.info("Ben_UserName:"+userName); + logger.info("get All incentives"); // add logic for different state or district diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 9ad9a4d8..8df3ac17 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -9,11 +9,14 @@ import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.IncentiveActivityLangMappingRepo; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.IncentiveService; +import com.iemr.flw.utils.JwtUtil; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +24,8 @@ import org.springframework.stereotype.Service; import java.math.BigInteger; +import java.sql.Timestamp; +import java.time.Instant; import java.util.*; import java.util.stream.Collectors; @@ -41,7 +46,11 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired IncentiveRecordRepo recordRepo; + @Autowired + private JwtUtil jwtUtil; + @Autowired + private UserServiceRoleRepo userRepo; @Override public String saveIncentivesMaster(List activityDTOS) { try { @@ -118,10 +127,11 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { return dto; }).collect(Collectors.toList()); + checkMonthlyAshaIncentive(); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); - return gson.toJson(dtos); + return gson.toJson(dtos); } catch (Exception e) { e.printStackTrace(); } @@ -156,4 +166,44 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } + private void checkMonthlyAshaIncentive(){ + IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); + IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); + IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); + if(MOBILEBILLREIMB_ACTIVITY!=null){ + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY); + } + if(ADDITIONAL_ASHA_INCENTIVE!=null){ + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE); + + } + + if(ASHA_MONTHLY_ROUTINE!=null){ + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE); + + } + } + + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ + + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.from(Instant.now()), 0L); + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(Timestamp.from(Instant.now())); + record.setCreatedBy(jwtUtil.getUserNameFromStorage()); + record.setStartDate(Timestamp.from(Instant.now())); + record.setEndDate(Timestamp.from(Instant.now())); + record.setUpdatedDate(Timestamp.from(Instant.now())); + record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); + record.setBenId(0L); + record.setAshaId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + } + + } From 38ba717758a81ca323be33a9be8dbc0b2157c3f2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 14:06:43 +0530 Subject: [PATCH 364/792] hbync api --- src/main/java/com/iemr/flw/FlwApplication.java | 6 +----- .../com/iemr/flw/service/impl/IncentiveServiceImpl.java | 4 ++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/FlwApplication.java b/src/main/java/com/iemr/flw/FlwApplication.java index e29d3468..23fc5352 100644 --- a/src/main/java/com/iemr/flw/FlwApplication.java +++ b/src/main/java/com/iemr/flw/FlwApplication.java @@ -18,7 +18,6 @@ @EntityScan(basePackages = {"com.iemr.flw.domain.identity", "com.iemr.flw.domain.iemr"}) @EnableScheduling public class FlwApplication extends SpringBootServletInitializer { - private Boolean IS_CH =true; public static void main(String[] args) { @@ -38,8 +37,5 @@ public FLWApplBeans instantiateBeans(){ return new FLWApplBeans(); } - @PostConstruct - public void init() { - GroupName.setIsCh(IS_CH); - } + } diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 8df3ac17..febedffe 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -99,8 +99,12 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { dto.setGroupName(mapping.getGroup()); if(Objects.equals(incentiveRequestDTO.getLangCode(), "en")){ dto.setDescription(mapping.getDescription()); + GroupName.setIsCh(true); + }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "as")){ + GroupName.setIsCh(false); + if(mapping.getAssameActivityDescription()!=null){ dto.setDescription(mapping.getAssameActivityDescription()); From 327a5675a724e49f61079c4352973563731ef02e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 14:58:59 +0530 Subject: [PATCH 365/792] hbync api --- .../iemr/flw/service/impl/IncentiveServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index febedffe..12a22c0c 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -81,6 +81,14 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { + Integer stateId= userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId(); + if(stateId==5){ + GroupName.setIsCh(false); + + }else if(stateId==9){ + GroupName.setIsCh(true); + + } List incs = incentivesRepo.findAll(); @@ -99,7 +107,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { dto.setGroupName(mapping.getGroup()); if(Objects.equals(incentiveRequestDTO.getLangCode(), "en")){ dto.setDescription(mapping.getDescription()); - GroupName.setIsCh(true); + }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "as")){ From 53c1ed2dfbc6ffb4ac423146d852946f7307511d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 15:15:32 +0530 Subject: [PATCH 366/792] hbync api --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 12a22c0c..d0bdf960 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -26,6 +26,7 @@ import java.math.BigInteger; import java.sql.Timestamp; import java.time.Instant; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; @@ -199,7 +200,7 @@ private void checkMonthlyAshaIncentive(){ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.from(Instant.now()), 0L); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(LocalDate.now().atStartOfDay()), 0L); if (record == null) { record = new IncentiveActivityRecord(); From 2ea1ffeb6b31097f6d58e3999477ea88f70ecd7a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 15:23:01 +0530 Subject: [PATCH 367/792] hbync api --- .../iemr/flw/service/impl/IncentiveServiceImpl.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index d0bdf960..1af9c5b4 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -198,18 +198,18 @@ private void checkMonthlyAshaIncentive(){ } private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ - + Timestamp timestamp = Timestamp.valueOf(LocalDate.now().atStartOfDay()); IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(LocalDate.now().atStartOfDay()), 0L); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), timestamp, 0L); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); - record.setCreatedDate(Timestamp.from(Instant.now())); + record.setCreatedDate(timestamp); record.setCreatedBy(jwtUtil.getUserNameFromStorage()); - record.setStartDate(Timestamp.from(Instant.now())); - record.setEndDate(Timestamp.from(Instant.now())); - record.setUpdatedDate(Timestamp.from(Instant.now())); + record.setStartDate(timestamp); + record.setEndDate(timestamp); + record.setUpdatedDate(timestamp); record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); record.setBenId(0L); record.setAshaId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); From 0b9bea61d92c3404a662c276677c4722f28c3fb4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 15:55:33 +0530 Subject: [PATCH 368/792] hbync api --- .../service/impl/DeathReportsServiceImpl.java | 6 +- .../impl/DeliveryOutcomeServiceImpl.java | 63 +++++++++++++++---- 2 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index 546694cd..01e6b2f6 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -6,6 +6,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.CdrDTO; import com.iemr.flw.dto.iemr.MdsrDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DeathReportsService; @@ -138,7 +139,7 @@ private void checkAndAddIncentives(List cdrList) { Long benId = beneficiaryRepo.getBenIdFromRegID(cdr.getBenId()).longValue(); Integer userId = userRepo.getUserIdByName(cdr.getCreatedBy()); IncentiveActivity immunizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", "CHILD HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); createIncentiveRecord(cdr,benId,userId,immunizationActivity); }); } @@ -150,7 +151,8 @@ private void checkAndAddIncentivesMdsr(List mdsrList) { Long benId = beneficiaryRepo.getBenIdFromRegID(mdsr.getBenId()).longValue(); Integer userId = userRepo.getUserIdByName(mdsr.getCreatedBy()); IncentiveActivity immunizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("MATERNAL_DEATH_REPORT", "MATERNAL HEALTH"); + incentivesRepo.findIncentiveMasterByNameAndGroup("MATERNAL_DEATH_REPORT", GroupName.MATERNAL_HEALTH.getDisplayName()); + createIncentiveRecord(mdsr,benId,userId,immunizationActivity); }); } diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 927e38bc..75608766 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -127,6 +127,7 @@ public void checkAndAddJsyIncentive(List delOutList){ // Determine delivery number int deliveryNumber = deliveryOutcome.getDeliveryOutcome(); // 1,2,3,4 if(deliveryOutcome.getIsJSYBenificiary()!=null){ + isJsyBeneficiary = deliveryOutcome.getIsJSYBenificiary(); } @@ -143,32 +144,72 @@ public void checkAndAddJsyIncentive(List delOutList){ String location = "Rural"; // JSY incentive name construction - List activityNames = new ArrayList<>(); + + if(location.equalsIgnoreCase("Rural")) { switch(deliveryNumber) { case 1: - if(isJsyBeneficiary) activityNames.add("JSY_1ST_DEL_ANC_RURAL"); - if(institutionalDelivery) activityNames.add("JSY_1ST_DEL_INST_RURAL"); + if(isJsyBeneficiary){ + if(deliveryOutcome.getLiveBirth()==0){ + activityNames.add("JSY_1ST_DEL_ANC_RURAL"); + } + } + if(institutionalDelivery) { + if(deliveryOutcome.getLiveBirth()==0) + activityNames.add("JSY_1ST_DEL_INST_RURAL"); + } break; + case 2: - if(isJsyBeneficiary) activityNames.add("JSY_2ND_DEL_ANC_RURAL"); - if(institutionalDelivery) activityNames.add("JSY_2ND_DEL_INST_RURAL"); + if(isJsyBeneficiary){ + if(deliveryOutcome.getLiveBirth()==1){ + activityNames.add("JSY_2ND_DEL_ANC_RURAL"); + } + } + if(institutionalDelivery) { + if(deliveryOutcome.getLiveBirth()==1) + activityNames.add("JSY_2ND_DEL_INST_RURAL"); + } break; + case 3: - if(isJsyBeneficiary) activityNames.add("JSY_3RD_DEL_ANC_RURAL"); - if(institutionalDelivery) activityNames.add("JSY_3RD_DEL_INST_RURAL"); + if(isJsyBeneficiary){ + if(deliveryOutcome.getLiveBirth()==2){ + activityNames.add("JSY_3RD_DEL_ANC_RURAL"); + } + } + if(institutionalDelivery) { + if(deliveryOutcome.getLiveBirth()==2) + activityNames.add("JSY_3RD_DEL_INST_RURAL"); + } break; + case 4: - if(isJsyBeneficiary) activityNames.add("JSY_4TH_DEL_ANC_RURAL"); - if(institutionalDelivery) activityNames.add("JSY_4TH_DEL_INST_RURAL"); + if(isJsyBeneficiary){ + if(deliveryOutcome.getLiveBirth()==3){ + activityNames.add("JSY_4TH_DEL_ANC_RURAL"); + } + } + if(institutionalDelivery) { + if(deliveryOutcome.getLiveBirth()==3) + activityNames.add("JSY_4TH_DEL_INST_RURAL"); + } break; } } else if(location.equalsIgnoreCase("Urban")) { - if(isJsyBeneficiary) activityNames.add("JSY_ANC_URBAN"); - if(institutionalDelivery) activityNames.add("JSY_INST_URBAN"); + if(isJsyBeneficiary){ + if(deliveryOutcome.getLiveBirth()==0){ + activityNames.add("JSY_ANC_URBAN"); + } + } + if(institutionalDelivery){ + if(deliveryOutcome.getLiveBirth()==0) + activityNames.add("JSY_INST_URBAN"); + } } + // For each activity, create record for(String activityName : activityNames){ IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName, GroupName.JSY.getDisplayName()); From f64ac16b03306025e2c331cc98d67914f0b2b93d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:07:18 +0530 Subject: [PATCH 369/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index d9ad5065..f70a38a1 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -404,7 +404,8 @@ private void checkAndAddHbncIncentives(List hbncVisits) { boolean isBabyDisChargeSNCUA = hbncVisits.stream() .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu())); Long benId = hbncVisit.getBeneficiaryId(); - if (hbncVisit.getVisit_day().equals("42nd Day")) { + GroupName.setIsCh(true); + if (hbncVisit.getVisit_day().equals("1st Day")) { IncentiveActivity visitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); From 586befd69332fddb696751f2f74be276d3d088ef Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:21:46 +0530 Subject: [PATCH 370/792] hbync api --- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 6 ++---- .../com/iemr/flw/service/impl/IncentiveServiceImpl.java | 9 --------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f70a38a1..5ee44f48 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -401,10 +401,8 @@ private void checkAndAddHbncIncentives(List hbncVisits) { .stream() .allMatch(hbncVisits::contains); - boolean isBabyDisChargeSNCUA = hbncVisits.stream() - .anyMatch(v -> Boolean.TRUE.equals(v.getDischarged_from_sncu())); + Long benId = hbncVisit.getBeneficiaryId(); - GroupName.setIsCh(true); if (hbncVisit.getVisit_day().equals("1st Day")) { IncentiveActivity visitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); @@ -412,7 +410,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); } - if (hbncVisit.getVisit_day().equals("42nd Day") && isBabyDisChargeSNCUA) { + if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 1af9c5b4..fdc43308 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -82,14 +82,6 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { - Integer stateId= userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId(); - if(stateId==5){ - GroupName.setIsCh(false); - - }else if(stateId==9){ - GroupName.setIsCh(true); - - } List incs = incentivesRepo.findAll(); @@ -112,7 +104,6 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "as")){ - GroupName.setIsCh(false); if(mapping.getAssameActivityDescription()!=null){ dto.setDescription(mapping.getAssameActivityDescription()); From 320db9b85c7f410e264b66f2b61274c50c1a8df7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:40:50 +0530 Subject: [PATCH 371/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbncVisit.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/HbncVisitDTO.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbncVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbncVisit.java index 3e82e893..1513c088 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbncVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbncVisit.java @@ -104,4 +104,7 @@ public class HbncVisit { @Column(name = "created_date") private Timestamp createdDate; + @Column(name = "baby_eyes_swollen") + private Boolean babyEyesSwollen; + }; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbncVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbncVisitDTO.java index 3d2be6cf..239e21c8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbncVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbncVisitDTO.java @@ -90,6 +90,9 @@ public class HbncVisitDTO { @Column(name = "updated_by") private String updatedBy; + @Column(name = "baby_eyes_swollen") + private Boolean babyEyesSwollen; + } From 32e401127fba78ee8ad61ea73ae8fd424688d3b9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:49:03 +0530 Subject: [PATCH 372/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 5ee44f48..b2858792 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -401,7 +401,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { .stream() .allMatch(hbncVisits::contains); - + GroupName.setIsCh(true); Long benId = hbncVisit.getBeneficiaryId(); if (hbncVisit.getVisit_day().equals("1st Day")) { IncentiveActivity visitActivity = @@ -417,6 +417,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); } + logger.info("getIs_baby_alive"+hbncVisit.getIs_baby_alive()); if (!hbncVisit.getIs_baby_alive()) { IncentiveActivity isChildDeathActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); @@ -481,6 +482,7 @@ record = new IncentiveActivityRecord(); } private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity) { + IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), hbncVisit.getCreatedDate(), benId); From 9483687ff8f9bfb2d7374d9c8f4ea6c8eed743ae Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:51:53 +0530 Subject: [PATCH 373/792] hbync api --- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index b2858792..0680fcb0 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -410,7 +410,9 @@ private void checkAndAddHbncIncentives(List hbncVisits) { createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); } - if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { + logger.info("getDischarged_from_sncu"+hbncVisit.getDischarged_from_sncu()); + + if (hbncVisit.getVisit_day().equals("1st Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); @@ -433,6 +435,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { private void checkAndAddIncentives(List vaccinationList) { + vaccinationList.forEach(vaccination -> { Long benId = beneficiaryRepo.getBenIdFromRegID(vaccination.getBeneficiaryRegId()).longValue(); Integer userId = userRepo.getUserIdByName(vaccination.getCreatedBy()); @@ -482,6 +485,8 @@ record = new IncentiveActivityRecord(); } private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity) { + logger.info("immunizationActivity "+immunizationActivity.getName()); + IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), hbncVisit.getCreatedDate(), benId); From 538f839e003f7c76ca64d91a9a4ed48774249fc9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 16:58:28 +0530 Subject: [PATCH 374/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 0680fcb0..e081e00a 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -401,7 +401,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { .stream() .allMatch(hbncVisits::contains); - GroupName.setIsCh(true); + GroupName.setIsCh(false); Long benId = hbncVisit.getBeneficiaryId(); if (hbncVisit.getVisit_day().equals("1st Day")) { IncentiveActivity visitActivity = From c2d6994f9d2fec0c030fd6453775061daee5eba3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 17:10:26 +0530 Subject: [PATCH 375/792] hbync api --- .../iemr/flw/service/MaaMeetingService.java | 14 ++++++++++++- .../service/impl/ChildCareServiceImpl.java | 20 +++++++++---------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index a6f33923..e9740a92 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -10,6 +10,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.MaaMeetingRepository; @@ -107,8 +108,19 @@ public List getAllMeetings(GetBenRequestHandler getBenReq }).collect(Collectors.toList()); } private void checkAndAddIncentive(MaaMeeting meeting) { - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", "CHILD HEALTH"); + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.ACTIVITY.getDisplayName()); + if(incentiveActivityAM!=null){ + addIncentive(incentiveActivityAM,meeting); + } + if(incentiveActivityCH!=null){ + addIncentive(incentiveActivityCH,meeting); + } + + } + + private void addIncentive(IncentiveActivity incentiveActivity,MaaMeeting meeting){ IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L); diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index e081e00a..d15cf1f4 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -403,20 +403,21 @@ private void checkAndAddHbncIncentives(List hbncVisits) { GroupName.setIsCh(false); Long benId = hbncVisit.getBeneficiaryId(); - if (hbncVisit.getVisit_day().equals("1st Day")) { - IncentiveActivity visitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); + if (hbncVisit.getVisit_day().equals("42nd Day")) { + IncentiveActivity visitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity visitActivityCH= incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.ACTIVITY.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivity); + createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityAM,"HBNC_0_42_DAYS"); + createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityCH,"HBNC_0_42_DAYS_CH"); } logger.info("getDischarged_from_sncu"+hbncVisit.getDischarged_from_sncu()); - if (hbncVisit.getVisit_day().equals("1st Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { + if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity); + createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity,"SNCU_LBW_FOLLOWUP"); } logger.info("getIs_baby_alive"+hbncVisit.getIs_baby_alive()); @@ -424,7 +425,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { IncentiveActivity isChildDeathActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity); + createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity,"CHILD_DEATH_REPORTING"); } @@ -484,9 +485,8 @@ record = new IncentiveActivityRecord(); } } - private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity) { - logger.info("immunizationActivity "+immunizationActivity.getName()); - + private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity,String activityName) { + logger.info("RecordIncentive"+activityName); IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), hbncVisit.getCreatedDate(), benId); From 558d8d150377bca61a613b54a6ee22f235850a99 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 17:38:13 +0530 Subject: [PATCH 376/792] hbync api --- .../service/impl/ChildCareServiceImpl.java | 54 +++++-- .../impl/DeliveryOutcomeServiceImpl.java | 21 +++ .../impl/MaternalHealthServiceImpl.java | 144 ++++++++++++------ .../service/impl/UwinSessionServiceImpl.java | 59 ++++--- .../impl/VillageLevelFormServiceImpl.java | 35 ++++- 5 files changed, 233 insertions(+), 80 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index d15cf1f4..7e72c259 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -373,8 +373,11 @@ private void checkAndAddHbyncIncentives(List hbycList) { IncentiveActivity hbyncVisitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.CHILD_HEALTH.getDisplayName()); - IncentiveActivity hbyncOrsPacketActivity = + IncentiveActivity hbyncOrsPacketActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName()); + + IncentiveActivity hbyncOrsPacketActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if (hbyncVisitActivity != null) { if (hbyc.getHbycVisitDate() != null) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreatedBy()); @@ -382,9 +385,17 @@ private void checkAndAddHbyncIncentives(List hbycList) { } } - if (hbyncOrsPacketActivity != null) { + if (hbyncOrsPacketActivityAM != null) { + if (hbyc.getIsOrsGiven()) { + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityAM, hbyc.getCreatedBy()); + + } + + } + + if (hbyncOrsPacketActivityCH != null) { if (hbyc.getIsOrsGiven()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivity, hbyc.getCreatedBy()); + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreatedBy()); } @@ -442,24 +453,43 @@ private void checkAndAddIncentives(List vaccinationList) { Integer userId = userRepo.getUserIdByName(vaccination.getCreatedBy()); Integer immunizationServiceId = getImmunizationServiceIdForVaccine(vaccination.getVaccineId().shortValue()); if (immunizationServiceId < 6) { - IncentiveActivity immunizationActivity = + IncentiveActivity immunizationActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.IMMUNIZATION.getDisplayName()); - if (immunizationActivity != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) + IncentiveActivity immunizationActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.ACTIVITY.getDisplayName()); + if (immunizationActivityAM != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) .equals(childVaccinationRepo.getFirstYearVaccineCount())) { - createIncentiveRecord(vaccination, benId, userId, immunizationActivity); + createIncentiveRecord(vaccination, benId, userId, immunizationActivityAM); + } + + if (immunizationActivityCH != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) + .equals(childVaccinationRepo.getFirstYearVaccineCount())) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivityCH); } } else if (immunizationServiceId == 7) { - IncentiveActivity immunizationActivity2 = + IncentiveActivity immunizationActivity2AM = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", GroupName.IMMUNIZATION.getDisplayName()); - if (immunizationActivity2 != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) + IncentiveActivity immunizationActivity2CH = + incentivesRepo.findIncentiveMasterByNameAndGroup("COMPLETE_IMMUNIZATION_1_2", GroupName.ACTIVITY.getDisplayName()); + if (immunizationActivity2AM != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) .equals(childVaccinationRepo.getSecondYearVaccineCount())) { - createIncentiveRecord(vaccination, benId, userId, immunizationActivity2); + createIncentiveRecord(vaccination, benId, userId, immunizationActivity2AM); + } + if (immunizationActivity2CH != null && childVaccinationRepo.getSecondYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) + .equals(childVaccinationRepo.getSecondYearVaccineCount())) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivity2CH); } } else if (immunizationServiceId == 8) { - IncentiveActivity immunizationActivity5 = + IncentiveActivity immunizationActivity5AM = incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.IMMUNIZATION.getDisplayName()); - if (immunizationActivity5 != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { - createIncentiveRecord(vaccination, benId, userId, immunizationActivity5); + if (immunizationActivity5AM != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivity5AM); + } + + IncentiveActivity immunizationActivity5CH = + incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.ACTIVITY.getDisplayName()); + if (immunizationActivity5CH != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivity5CH); } } }); diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 75608766..50ec512f 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -141,6 +141,7 @@ public void checkAndAddJsyIncentive(List delOutList){ if(rmnchBeneficiaryDetailsRmnch.isPresent()){ logger.info("rmnchBeneficiaryDetailsRmnch"+rmnchBeneficiaryDetailsRmnch.get()); } + String location = "Rural"; // JSY incentive name construction @@ -217,8 +218,28 @@ public void checkAndAddJsyIncentive(List delOutList){ createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivity); } } + IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); + String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); + + if (placeOfDelivery != null && + !placeOfDelivery.equalsIgnoreCase("home") && + !placeOfDelivery.equalsIgnoreCase("in transit") && + !placeOfDelivery.equalsIgnoreCase("other private hospital")) { + + // Institutional delivery (eligible case) + if (institutionalDeliveryActivityAM != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityAM); + } + + if (institutionalDeliveryActivityCH != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityCH); + } + } }); + + } private void createIncentiveRecordforJsy(DeliveryOutcome delOutList, Long benId, IncentiveActivity immunizationActivity) { logger.info("benId"+benId); diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 7031a0de..7c4bde4d 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -66,10 +66,9 @@ public class MaternalHealthServiceImpl implements MaternalHealthService { ModelMapper modelMapper = new ModelMapper(); - - @Autowired - private SMSServiceImpl smsServiceImpl; + @Autowired + private SMSServiceImpl smsServiceImpl; public static final List PNC_PERIODS = @@ -107,7 +106,7 @@ public String registerPregnantWoman(List pregnantWomanDTOs) { @Override public List getPregnantWoman(GetBenRequestHandler dto) { - try{ + try { String user = beneficiaryRepo.getUserName(dto.getAshaId()); List pregnantWomanRegisterList = pregnantWomanRegisterRepo.getPWRWithBen(user, dto.getFromDate(), dto.getToDate()); @@ -174,7 +173,7 @@ public String saveANCVisit(List ancVisitDTOs) { modelMapper.map(it, ancCare); ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); ancCare.setBeneficiaryRegId(benRegId); - if(pwr != null) { + if (pwr != null) { ancCare.setLastMenstrualPeriodLmp(pwr.getLmpDate()); Calendar cal = Calendar.getInstance(); cal.setTime(pwr.getLmpDate()); @@ -304,7 +303,7 @@ public String savePNCVisit(List pncVisitDTOs) { pncCare.setLastModDate(it.getUpdatedDate()); pncCare.setProcessed("N"); pncCareList.add(pncCare); - checkAndAddAntaraIncentive(pncList,pncVisit); + checkAndAddAntaraIncentive(pncList, pncVisit); } pncList.add(pncVisit); }); @@ -320,36 +319,36 @@ public String savePNCVisit(List pncVisitDTOs) { private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) { Integer userId = userRepo.getUserIdByName(ect.getCreatedBy()); - logger.info("ContraceptionMethod:"+ect.getContraceptionMethod()); - if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")){ + logger.info("ContraceptionMethod:" + ect.getContraceptionMethod()); + if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")) { IncentiveActivity maleSterilizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); if (maleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); } - }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("FEMALE STERILIZATION")){ + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("FEMALE STERILIZATION")) { IncentiveActivity femaleSterilizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); if (femaleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); } - }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MiniLap")){ + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MiniLap")) { IncentiveActivity miniLapActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MINILAP", GroupName.FAMILY_PLANNING.getDisplayName()); if (miniLapActivity != null) { addIncenticeRecord(recordList, ect, userId, miniLapActivity); } - }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Condom")){ + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Condom")) { IncentiveActivity comdomActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", GroupName.FAMILY_PLANNING.getDisplayName()); if (comdomActivity != null) { addIncenticeRecord(recordList, ect, userId, comdomActivity); } - }else if(ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Copper T (IUCD)")){ + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Copper T (IUCD)")) { IncentiveActivity copperTActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", GroupName.FAMILY_PLANNING.getDisplayName()); @@ -386,16 +385,22 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity anc1Activity = incentivesRepo.findIncentiveMasterByNameAndGroup("ANC_REGISTRATION_1ST_TRIM", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity ancFullActivity = + IncentiveActivity ancFullActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); + + IncentiveActivity ancFullActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity abortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity identifiedHrpActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + + if (anc1Activity != null) { - ancList.forEach( ancVisit -> { + ancList.forEach(ancVisit -> { Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); if (ancVisit.getAncVisit() == 1) { @@ -419,8 +424,13 @@ record = new IncentiveActivityRecord(); } if (ancVisit.getAncVisit() == 4) { - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + + IncentiveActivityRecord recordAM = recordRepo + .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + + IncentiveActivityRecord recordCH = recordRepo + .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + ANCVisit visit1 = ancVisitRepo .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 1, true); ANCVisit visit2 = ancVisitRepo @@ -430,33 +440,49 @@ record = new IncentiveActivityRecord(); ANCVisit visit4 = ancVisitRepo .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 4, true); - if (record == null && (visit1 != null) && (visit2 != null) && (visit3 != null) && (visit4 != null)) { + if (recordAM == null && (visit1 != null) && (visit2 != null) && (visit3 != null) && (visit4 != null)) { + + recordAM = new IncentiveActivityRecord(); + recordAM.setActivityId(ancFullActivityAM.getId()); + recordAM.setCreatedDate(ancVisit.getAncDate()); + recordAM.setCreatedBy(ancVisit.getCreatedBy()); + recordAM.setUpdatedDate(ancVisit.getAncDate()); + recordAM.setUpdatedBy(ancVisit.getCreatedBy()); + recordAM.setStartDate(visit1.getAncDate()); + recordAM.setEndDate(visit4.getAncDate()); + recordAM.setBenId(ancVisit.getBenId()); + recordAM.setAshaId(userId); + recordAM.setAmount(Long.valueOf(ancFullActivityAM.getRate())); + recordRepo.save(recordAM); + } - record = new IncentiveActivityRecord(); - record.setActivityId(ancFullActivity.getId()); - record.setCreatedDate(ancVisit.getAncDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getAncDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(visit1.getAncDate()); - record.setEndDate(visit4.getAncDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(ancFullActivity.getRate())); - recordRepo.save(record); + if (recordCH == null && (visit1 != null) && (visit2 != null) && (visit3 != null) && (visit4 != null)) { + + recordCH = new IncentiveActivityRecord(); + recordCH.setActivityId(ancFullActivityCH.getId()); + recordCH.setCreatedDate(ancVisit.getAncDate()); + recordCH.setCreatedBy(ancVisit.getCreatedBy()); + recordCH.setUpdatedDate(ancVisit.getAncDate()); + recordCH.setUpdatedBy(ancVisit.getCreatedBy()); + recordCH.setStartDate(visit1.getAncDate()); + recordCH.setEndDate(visit4.getAncDate()); + recordCH.setBenId(ancVisit.getBenId()); + recordCH.setAshaId(userId); + recordCH.setAmount(Long.valueOf(ancFullActivityCH.getRate())); + recordRepo.save(recordCH); } } }); } - if(abortionActivity!=null){ + if (abortionActivity != null) { ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(abortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - if(Objects.equals(ancVisit.getIsAborted(), "true")){ - if(record==null){ + if (Objects.equals(ancVisit.getIsAborted(), "true")) { + if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(abortionActivity.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); @@ -475,17 +501,17 @@ record = new IncentiveActivityRecord(); })); } - if(identifiedHrpActivity!=null){ + if (identifiedHrpActivityAM != null) { ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(ancVisit.getBenId())); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName()+" "+rmnchBeneficiaryDetailsRmnch.getLastName(); - if(ancVisit.getIsHrpConfirmed()!=null){ - if(ancVisit.getIsHrpConfirmed()){ - if(record==null){ + String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName() + " " + rmnchBeneficiaryDetailsRmnch.getLastName(); + if (ancVisit.getIsHrpConfirmed() != null) { + if (ancVisit.getIsHrpConfirmed()) { + if (record == null) { record = new IncentiveActivityRecord(); - record.setActivityId(identifiedHrpActivity.getId()); + record.setActivityId(identifiedHrpActivityAM.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); @@ -495,7 +521,38 @@ record = new IncentiveActivityRecord(); record.setEndDate(ancVisit.getCreatedDate()); record.setBenId(ancVisit.getBenId()); record.setAshaId(userId); - record.setAmount(Long.valueOf(identifiedHrpActivity.getRate())); + record.setAmount(Long.valueOf(identifiedHrpActivityAM.getRate())); + recordRepo.save(record); + } + } + + + } + })); + } + + + if (identifiedHrpActivityCH != null) { + ancList.forEach((ancVisit -> { + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(ancVisit.getBenId())); + String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName() + " " + rmnchBeneficiaryDetailsRmnch.getLastName(); + if (ancVisit.getIsHrpConfirmed() != null) { + if (ancVisit.getIsHrpConfirmed()) { + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(identifiedHrpActivityCH.getId()); + record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedBy(ancVisit.getCreatedBy()); + record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setName(beneName); + record.setUpdatedBy(ancVisit.getCreatedBy()); + record.setStartDate(ancVisit.getCreatedDate()); + record.setEndDate(ancVisit.getCreatedDate()); + record.setBenId(ancVisit.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(identifiedHrpActivityCH.getRate())); recordRepo.save(record); } } @@ -506,7 +563,9 @@ record = new IncentiveActivityRecord(); } } - public void sendAncDueTomorrowNotifications(String ashaId) { + + + public void sendAncDueTomorrowNotifications(String ashaId) { try { GetBenRequestHandler request = new GetBenRequestHandler(); request.setAshaId(Integer.valueOf(ashaId)); @@ -526,7 +585,6 @@ public void sendAncDueTomorrowNotifications(String ashaId) { String topic = "All"; // or some user/topic identifier String title = "ANC Reminder"; - } } diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index b2abd3ca..1add9c38 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -128,25 +128,48 @@ public List getSessionsByAsha(Integer ashaId) throws Exc } private void checkAndAddIncentive(UwinSession session) { - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.IMMUNIZATION.getDisplayName()); - - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), session.getDate(), 0L); - - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(incentiveActivity.getId()); - record.setCreatedDate(session.getDate()); - record.setCreatedBy(session.getCreatedBy()); - record.setStartDate(session.getDate()); - record.setEndDate(session.getDate()); - record.setUpdatedDate(session.getDate()); - record.setUpdatedBy(session.getCreatedBy()); - record.setBenId(0L); - record.setAshaId(session.getAshaId()); - record.setAmount(Long.valueOf(incentiveActivity.getRate())); - recordRepo.save(record); + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.IMMUNIZATION.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.ACTIVITY.getDisplayName()); + + + if(incentiveActivityAM!=null){ + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivityAM.getId(), session.getDate(), 0L); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivityAM.getId()); + record.setCreatedDate(session.getDate()); + record.setCreatedBy(session.getCreatedBy()); + record.setStartDate(session.getDate()); + record.setEndDate(session.getDate()); + record.setUpdatedDate(session.getDate()); + record.setUpdatedBy(session.getCreatedBy()); + record.setBenId(0L); + record.setAshaId(session.getAshaId()); + record.setAmount(Long.valueOf(incentiveActivityAM.getRate())); + recordRepo.save(record); + } + } + + if(incentiveActivityCH!=null){ + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivityCH.getId(), session.getDate(), 0L); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivityCH.getId()); + record.setCreatedDate(session.getDate()); + record.setCreatedBy(session.getCreatedBy()); + record.setStartDate(session.getDate()); + record.setEndDate(session.getDate()); + record.setUpdatedDate(session.getDate()); + record.setUpdatedBy(session.getCreatedBy()); + record.setBenId(0L); + record.setAshaId(session.getAshaId()); + record.setAmount(Long.valueOf(incentiveActivityCH.getRate())); + recordRepo.save(record); + } } + } } diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 8ce3d65e..e0c2db96 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -27,6 +27,7 @@ import com.iemr.flw.controller.CoupleController; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.VillageLevelFormService; import org.slf4j.Logger; @@ -252,15 +253,17 @@ private void checkAndAddIncentives(String date, Integer userID, String formType, Timestamp timestamp = Timestamp.valueOf(localDate.atStartOfDay()); logger.info("timestamp" + timestamp); - IncentiveActivity villageFormEntryActivity; - villageFormEntryActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(formType, "CHILD HEALTH"); + IncentiveActivity villageFormEntryActivityAM; + IncentiveActivity villageFormEntryActivityCH; + villageFormEntryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup(formType, GroupName.CHILD_HEALTH.getDisplayName()); + villageFormEntryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup(formType, GroupName.ACTIVITY.getDisplayName()); - if (villageFormEntryActivity != null) { + if (villageFormEntryActivityAM != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivity.getId(), timestamp, null); + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityAM.getId(), timestamp, null); if (record == null) { record = new IncentiveActivityRecord(); - record.setActivityId(villageFormEntryActivity.getId()); + record.setActivityId(villageFormEntryActivityAM.getId()); record.setCreatedDate(timestamp); record.setCreatedBy(createdBY); record.setStartDate(timestamp); @@ -268,8 +271,26 @@ record = new IncentiveActivityRecord(); record.setUpdatedDate(timestamp); record.setUpdatedBy(createdBY); record.setAshaId(userID); - record.setName(villageFormEntryActivity.getName()); - record.setAmount(Long.valueOf(villageFormEntryActivity.getRate())); + record.setAmount(Long.valueOf(villageFormEntryActivityAM.getRate())); + recordRepo.save(record); + + } + } + + if (villageFormEntryActivityCH != null) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityCH.getId(), timestamp, null); + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(villageFormEntryActivityCH.getId()); + record.setCreatedDate(timestamp); + record.setCreatedBy(createdBY); + record.setStartDate(timestamp); + record.setEndDate(timestamp); + record.setUpdatedDate(timestamp); + record.setUpdatedBy(createdBY); + record.setAshaId(userID); + record.setAmount(Long.valueOf(villageFormEntryActivityCH.getRate())); recordRepo.save(record); } From 524fef51a433dec34b5a418219c2d5f20c135cd8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 17:38:39 +0530 Subject: [PATCH 377/792] hbync api --- .../com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 50ec512f..a5be4350 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -219,7 +219,7 @@ public void checkAndAddJsyIncentive(List delOutList){ } } IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.ACTIVITY.getDisplayName()); String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); if (placeOfDelivery != null && From 3b19829230c4a41d7c0aa0bfc982e9495a86b267 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 10 Oct 2025 17:48:37 +0530 Subject: [PATCH 378/792] hbync api --- .../iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index a5be4350..7b7f8053 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -223,9 +223,9 @@ public void checkAndAddJsyIncentive(List delOutList){ String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); if (placeOfDelivery != null && - !placeOfDelivery.equalsIgnoreCase("home") && - !placeOfDelivery.equalsIgnoreCase("in transit") && - !placeOfDelivery.equalsIgnoreCase("other private hospital")) { + (!placeOfDelivery.equalsIgnoreCase("home") || + !placeOfDelivery.equalsIgnoreCase("in transit") || + !placeOfDelivery.equalsIgnoreCase("other private hospital"))) { // Institutional delivery (eligible case) if (institutionalDeliveryActivityAM != null) { From fc666d9a85c709d00fbc1148a657369ed55feee6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 12:29:27 +0530 Subject: [PATCH 379/792] hbync api --- .../java/com/iemr/flw/controller/ChildCareController.java | 3 +-- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 7 ++++--- src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java | 2 +- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 57f65216..b7a61bd0 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -55,8 +55,7 @@ public String saveHbycRecords(@RequestBody List hbycDTOs, @Operation(summary = "get List of HBYC details") @RequestMapping(value = {"/hbycVisit/getAll"}, method = {RequestMethod.POST}) - public String getHbycRecords(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + public String getHbycRecords(@RequestBody GetBenRequestHandler requestDTO) { OutputResponse response = new OutputResponse(); try { logger.info("fetching All HBYC Details for user: " + requestDTO.getAshaId()); diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 733697a9..212b65b6 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -1,5 +1,6 @@ package com.iemr.flw.domain.iemr; +import com.google.gson.annotations.SerializedName; import jakarta.persistence.*; import java.math.BigDecimal; import java.time.LocalDateTime; @@ -24,12 +25,12 @@ public class HbycChildVisit { @Column(name = "household_id") private Long houseHoldId; + @Column(name = "visit_day") + private String hbycVisitDay; // 3 Months, 6 Months, etc. + @Column(name = "user_id") private Integer userId; - @Column(name = "hbyc_visit") - private String hbycVisit; // 3 Months, 6 Months, etc. - @Column(name = "hbyc_due_date") private String hbycDueDate; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index c0ef7dc7..d085630f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -27,7 +27,7 @@ public class HbycDTO { private Long beneficiaryId; @SerializedName("visit_day") - private String hbycVisit; // 3 Months, 6 Months, etc. + private String hbycVisitDay; // 3 Months, 6 Months, etc. @SerializedName("household_id") private Long houseHoldId; diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 8e1cb633..2f02c7ee 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -13,7 +13,7 @@ @Repository public interface HbycRepo extends JpaRepository { - HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisit(Long benId, String createdDate); + HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDay(Long benId, String createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 7e72c259..bf0129c6 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisit(it.getBeneficiaryId(), it.getFields().getHbycVisit()); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getHbycVisitDay()); if (hbyc != null) { Long id = hbyc.getId(); @@ -106,7 +106,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { // Prepare dynamic fields map Map fields = new HashMap<>(); - addIfValid(fields, "visit_day", hbycChildVisit.getHbycVisit()); + addIfValid(fields, "visit_day", hbycChildVisit.getHbycVisitDay()); addIfValid(fields, "due_date", hbycChildVisit.getHbycDueDate()); addIfValid(fields, "visit_date", hbycChildVisit.getHbycVisitDate()); addIfValid(fields, "is_baby_alive", convert(hbycChildVisit.getIsBabyAlive())); From 3ad2f4f8a8528e68e0e0a426f1dd2292cd7f1fe8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 17:47:56 +0530 Subject: [PATCH 380/792] hbync api --- .../flw/controller/ChildCareController.java | 3 + .../iemr/flw/domain/iemr/HbycChildVisit.java | 68 +++++++------- .../java/com/iemr/flw/dto/iemr/HbycDTO.java | 64 ++++++------- .../service/impl/ChildCareServiceImpl.java | 89 ++++++++++--------- 4 files changed, 114 insertions(+), 110 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index b7a61bd0..cc7c3a08 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -35,7 +35,10 @@ public class ChildCareController { @RequestMapping(value = {"/hbycVisit/saveAll"}, method = {RequestMethod.POST}) public String saveHbycRecords(@RequestBody List hbycDTOs, @RequestHeader(value = "Authorization") String Authorization) { + logger.info("Request: "+hbycDTOs.toString()); + logger.info("Request: "+hbycDTOs); OutputResponse response = new OutputResponse(); + try { logger.info("Saving All HBYC Details"); if (hbycDTOs != null) { diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 212b65b6..deaf4f17 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -20,109 +20,109 @@ public class HbycChildVisit { private Long id; @Column(name = "beneficiary_id") - private Long beneficiaryId; + private Long beneficiary_id; @Column(name = "household_id") - private Long houseHoldId; + private Long household_id; @Column(name = "visit_day") - private String hbycVisitDay; // 3 Months, 6 Months, etc. + private String visit_day; // 3 Months, 6 Months, etc. @Column(name = "user_id") - private Integer userId; + private Integer user_id; @Column(name = "hbyc_due_date") - private String hbycDueDate; + private String hbyc_due_date; @Column(name = "hbyc_visit_date") - private String hbycVisitDate; + private String hbyc_visit_date; @Column(name = "is_baby_alive") - private Boolean isBabyAlive = true; + private Boolean is_baby_alive = true; @Column(name = "date_of_death") - private String dateOfDeath; + private String date_of_death; @Column(name = "reason_for_death") - private String reasonForDeath; + private String reason_for_death; @Column(name = "place_of_death") - private String placeOfDeath; + private String place_of_death; @Column(name = "other_place_of_death") - private String otherPlaceOfDeath; + private String other_place_of_death; @Column(name = "baby_weight") - private BigDecimal babyWeight; // 0.5 - 7.0 + private BigDecimal baby_weight; // 0.5 - 7.0 @Column(name = "is_child_sick") - private Boolean isChildSick; + private Boolean is_child_sick; @Column(name = "is_exclusive_breastfeeding") - private Boolean isExclusiveBreastfeeding; + private Boolean is_exclusive_breastfeeding; @Column(name = "is_mother_counseled_exbf") - private Boolean isMotherCounseledExbf; + private Boolean is_mother_counseled_exbf; @Column(name = "has_child_started_complementary_feeding") - private Boolean hasChildStartedComplementaryFeeding; + private Boolean has_child_started_complementary_feeding; @Column(name = "is_mother_counseled_cf") - private Boolean isMotherCounseledCf; + private Boolean is_mother_counseled_cf; @Column(name = "is_weight_recorded_by_aww") - private Boolean isWeightRecordedByAww; + private Boolean is_weight_recorded_by_aww; @Column(name = "is_developmental_delay") - private Boolean isDevelopmentalDelay; + private Boolean is_developmental_delay; @Column(name = "is_measles_vaccine_given") - private Boolean isMeaslesVaccineGiven; + private Boolean is_measles_vaccine_given; @Column(name = "is_vitamin_a_given") - private Boolean isVitaminAGiven; + private Boolean is_vitamin_a_given; @Column(name = "is_ors_available") - private Boolean isOrsAvailable; + private Boolean is_ors_available; @Column(name = "is_ifa_syrup_available") - private Boolean isIfaSyrupAvailable; + private Boolean is_ifa_syrup_available; @Column(name = "is_ors_given") - private Boolean isOrsGiven; + private Boolean is_ors_given; @Column(name = "is_ifa_syrup_given") - private Boolean isIfaSyrupGiven; + private Boolean is_ifa_syrup_given; @Column(name = "is_handwashing_counseling_given") - private Boolean isHandwashingCounselingGiven; + private Boolean is_handwashing_counseling_given; @Column(name = "is_parenting_counseling_given") - private Boolean isParentingCounselingGiven; + private Boolean is_parenting_counseling_given; @Column(name = "is_family_planning_counseling_given") - private Boolean isFamilyPlanningCounselingGiven; + private Boolean is_family_planning_counseling_given; @Column(name = "diarrhoea_episode") - private Boolean diarrhoeaEpisode; + private Boolean diarrhoea_episode; @Column(name = "pneumonia_symptoms") - private Boolean pneumoniaSymptoms; + private Boolean pneumonia_symptoms; @Column(name = "temperature") private BigDecimal temperature; @Column(name = "mcp_card_images", columnDefinition = "json") - private List mcpCardImages; + private List mcp_card_images; @Column(name = "created_at") - private LocalDateTime createdAt; + private LocalDateTime created_at; @Column(name = "updated_at") - private LocalDateTime updatedAt; + private LocalDateTime updated_at; @Column(name = "created_by") - private String createdBy; + private String created_by; // Getters and Setters } diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index d085630f..105eed57 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -24,103 +24,103 @@ public class HbycDTO { @SerializedName("beneficiary_id") - private Long beneficiaryId; + private Long beneficiary_id; @SerializedName("visit_day") - private String hbycVisitDay; // 3 Months, 6 Months, etc. + private String visit_day; // 3 Months, 6 Months, etc. @SerializedName("household_id") private Long houseHoldId; @SerializedName("due_date") - private String hbycDueDate; + private String due_date; @SerializedName("visit_date") - private String hbycVisitDate; + private String visit_date; @SerializedName("is_baby_alive") - private String isBabyAlive; // Yes/No + private String is_baby_alive; // Yes/No @SerializedName("date_of_death") - private String dateOfDeath; + private String date_of_death; @SerializedName("reason_for_death") - private String reasonForDeath; + private String reason_for_death; @SerializedName("place_of_death") - private String placeOfDeath; + private String place_of_death; @SerializedName("other_place_of_death") - private String otherPlaceOfDeath; + private String other_place_of_death; @SerializedName("baby_weight") - private BigDecimal babyWeight; + private BigDecimal baby_weight; @SerializedName("is_child_sick") - private String isChildSick; + private String is_child_sick; @SerializedName("exclusive_breastfeeding") - private String isExclusiveBreastfeeding; + private String exclusive_breastfeeding; @SerializedName("mother_counseled_ebf") - private String isMotherCounseledExbf; + private String mother_counseled_ebf; @SerializedName("complementary_feeding") - private String hasChildStartedComplementaryFeeding; + private String complementary_feeding; @SerializedName("mother_counseled_cf") - private String isMotherCounseledCf; + private String mother_counseled_cf; @SerializedName("weight_recorded") - private String isWeightRecordedByAww; + private String weight_recorded; @SerializedName("developmental_delay") - private String isDevelopmentalDelay; + private String developmental_delay; @SerializedName("measles_vaccine") - private String isMeaslesVaccineGiven; + private String measles_vaccine; @SerializedName("vitamin_a") - private String isVitaminAGiven; + private String vitamin_a; @SerializedName("ors_available") - private String isOrsAvailable; + private String ors_available; @SerializedName("ifa_available") - private String isIfaSyrupAvailable; + private String ifa_available; @SerializedName("ors_given") - private String isOrsGiven; + private String ors_given; @SerializedName("ifa_given") - private String isIfaSyrupGiven; + private String ifa_given; @SerializedName("handwash_counseling") - private String isHandwashingCounselingGiven; + private String handwash_counseling; @SerializedName("parenting_counseling") - private String isParentingCounselingGiven; + private String parenting_counseling; @SerializedName("family_planning_counseling") - private String isFamilyPlanningCounselingGiven; + private String family_planning_counseling; @SerializedName("diarrhoea_episode") - private String diarrhoeaEpisode; + private String diarrhoea_episode; @SerializedName("breathing_difficulty") - private String pneumoniaSymptoms; + private String breathing_difficulty; @SerializedName("temperature_check") - private BigDecimal temperature; + private BigDecimal tempertemperature_checkature; @SerializedName("mcp_card_images") - private List mcpCardImages; + private List mcp_card_images; @SerializedName("created_at") - private LocalDateTime createdAt; + private LocalDateTime created_at; @SerializedName("updated_at") - private LocalDateTime updatedAt; + private LocalDateTime updated_at; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index bf0129c6..2ba76976 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,20 +62,20 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getHbycVisitDay()); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); modelMapper.map(it, hbyc); hbyc.setId(id); - hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); - hbyc.setCreatedBy(it.getUserName()); + hbyc.setUser_id(userRepo.getUserIdByName(it.getUserName())); + hbyc.setCreated_by(it.getUserName()); } else { hbyc = new HbycChildVisit(); modelMapper.map(it, hbyc); hbyc.setId(null); - hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); - hbyc.setCreatedBy(it.getUserName()); + hbyc.setUser_id(userRepo.getUserIdByName(it.getUserName())); + hbyc.setCreated_by(it.getUserName()); } hbycList.add(hbyc); @@ -100,41 +100,42 @@ public List getHbycRecords(GetBenRequestHandler dto) { for (HbycChildVisit hbycChildVisit : hbycChildVisits) { HbycVisitResponseDTO hbycRequestDTO = new HbycVisitResponseDTO(); hbycRequestDTO.setId(hbycChildVisit.getId()); - hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiaryId()); - hbycRequestDTO.setHouseHoldId(hbycChildVisit.getHouseHoldId()); - hbycRequestDTO.setVisitDate(hbycChildVisit.getHbycVisitDate()); + hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiary_id()); + hbycRequestDTO.setHouseHoldId(hbycChildVisit.getHousehold_id()); + hbycRequestDTO.setVisitDate(hbycChildVisit.getHbyc_visit_date()); // Prepare dynamic fields map Map fields = new HashMap<>(); - addIfValid(fields, "visit_day", hbycChildVisit.getHbycVisitDay()); - addIfValid(fields, "due_date", hbycChildVisit.getHbycDueDate()); - addIfValid(fields, "visit_date", hbycChildVisit.getHbycVisitDate()); - addIfValid(fields, "is_baby_alive", convert(hbycChildVisit.getIsBabyAlive())); - addIfValid(fields, "date_of_death", hbycChildVisit.getDateOfDeath()); - addIfValid(fields, "reason_for_death", hbycChildVisit.getReasonForDeath()); - addIfValid(fields, "place_of_death", hbycChildVisit.getPlaceOfDeath()); - addIfValid(fields, "other_place_of_death", hbycChildVisit.getOtherPlaceOfDeath()); - addIfValid(fields, "baby_weight", hbycChildVisit.getBabyWeight()); - addIfValid(fields, "is_child_sick", convert(hbycChildVisit.getIsChildSick())); - addIfValid(fields, "exclusive_breastfeeding", convert(hbycChildVisit.getIsExclusiveBreastfeeding())); - addIfValid(fields, "mother_counseled_ebf", convert(hbycChildVisit.getIsMotherCounseledExbf())); - addIfValid(fields, "complementary_feeding", convert(hbycChildVisit.getHasChildStartedComplementaryFeeding())); - addIfValid(fields, "mother_counseled_cf", convert(hbycChildVisit.getIsMotherCounseledCf())); - addIfValid(fields, "weight_recorded", convert(hbycChildVisit.getIsWeightRecordedByAww())); - addIfValid(fields, "developmental_delay", convert(hbycChildVisit.getIsDevelopmentalDelay())); - addIfValid(fields, "measles_vaccine", convert(hbycChildVisit.getIsMeaslesVaccineGiven())); - addIfValid(fields, "vitamin_a", convert(hbycChildVisit.getIsVitaminAGiven())); - addIfValid(fields, "ors_available", convert(hbycChildVisit.getIsOrsAvailable())); - addIfValid(fields, "ifa_available", convert(hbycChildVisit.getIsIfaSyrupAvailable())); - addIfValid(fields, "ors_given", convert(hbycChildVisit.getIsOrsGiven())); - addIfValid(fields, "ifa_given", convert(hbycChildVisit.getIsIfaSyrupGiven())); - addIfValid(fields, "handwash_counseling", convert(hbycChildVisit.getIsHandwashingCounselingGiven())); - addIfValid(fields, "parenting_counseling", convert(hbycChildVisit.getIsParentingCounselingGiven())); - addIfValid(fields, "family_planning_counseling", convert(hbycChildVisit.getIsFamilyPlanningCounselingGiven())); - addIfValid(fields, "diarrhoea_episode", convert(hbycChildVisit.getDiarrhoeaEpisode())); - addIfValid(fields, "breathing_difficulty", convert(hbycChildVisit.getPneumoniaSymptoms())); + addIfValid(fields, "visit_day", hbycChildVisit.getVisit_day()); + addIfValid(fields, "due_date", hbycChildVisit.getHbyc_due_date()); + addIfValid(fields, "visit_date", hbycChildVisit.getHbyc_visit_date()); + addIfValid(fields, "is_baby_alive", convert(hbycChildVisit.getIs_baby_alive())); + addIfValid(fields, "date_of_death", hbycChildVisit.getDate_of_death()); + addIfValid(fields, "reason_for_death", hbycChildVisit.getReason_for_death()); + addIfValid(fields, "place_of_death", hbycChildVisit.getPlace_of_death()); + addIfValid(fields, "other_place_of_death", hbycChildVisit.getOther_place_of_death()); + addIfValid(fields, "baby_weight", hbycChildVisit.getBaby_weight()); + addIfValid(fields, "is_child_sick", convert(hbycChildVisit.getIs_child_sick())); + addIfValid(fields, "exclusive_breastfeeding", convert(hbycChildVisit.getIs_exclusive_breastfeeding())); + addIfValid(fields, "mother_counseled_ebf", convert(hbycChildVisit.getIs_mother_counseled_exbf())); + addIfValid(fields, "complementary_feeding", convert(hbycChildVisit.getHas_child_started_complementary_feeding())); + addIfValid(fields, "mother_counseled_cf", convert(hbycChildVisit.getIs_mother_counseled_cf())); + addIfValid(fields, "weight_recorded", convert(hbycChildVisit.getIs_weight_recorded_by_aww())); + addIfValid(fields, "developmental_delay", convert(hbycChildVisit.getIs_developmental_delay())); + addIfValid(fields, "measles_vaccine", convert(hbycChildVisit.getIs_measles_vaccine_given())); + addIfValid(fields, "vitamin_a", convert(hbycChildVisit.getIs_vitamin_a_given())); + addIfValid(fields, "ors_available", convert(hbycChildVisit.getIs_ors_available())); + addIfValid(fields, "ifa_available", convert(hbycChildVisit.getIs_ifa_syrup_available())); + addIfValid(fields, "ors_given", convert(hbycChildVisit.getIs_ors_given())); + addIfValid(fields, "ifa_given", convert(hbycChildVisit.getIs_ifa_syrup_given())); + addIfValid(fields, "handwash_counseling", convert(hbycChildVisit.getIs_handwashing_counseling_given())); + addIfValid(fields, "parenting_counseling", convert(hbycChildVisit.getIs_parenting_counseling_given())); + addIfValid(fields, "family_planning_counseling", convert(hbycChildVisit.getIs_family_planning_counseling_given())); + addIfValid(fields, "diarrhoea_episode", convert(hbycChildVisit.getDiarrhoea_episode())); + addIfValid(fields, "breathing_difficulty", convert(hbycChildVisit.getPneumonia_symptoms())); addIfValid(fields, "temperature_check", hbycChildVisit.getTemperature()); - addIfValid(fields, "mcp_card_images", hbycChildVisit.getMcpCardImages()); + addIfValid(fields, "mcp_card_images", hbycChildVisit.getMcp_card_images()); + // Set fields map in DTO hbycRequestDTO.setFields(fields); @@ -379,23 +380,23 @@ private void checkAndAddHbyncIncentives(List hbycList) { IncentiveActivity hbyncOrsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if (hbyncVisitActivity != null) { - if (hbyc.getHbycVisitDate() != null) { - createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreatedBy()); + if (hbyc.getHbyc_visit_date() != null) { + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiary_id(), hbyncVisitActivity, hbyc.getCreated_by()); } } if (hbyncOrsPacketActivityAM != null) { - if (hbyc.getIsOrsGiven()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityAM, hbyc.getCreatedBy()); + if (hbyc.getIs_ors_given()) { + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiary_id(), hbyncOrsPacketActivityAM, hbyc.getCreated_by()); } } if (hbyncOrsPacketActivityCH != null) { - if (hbyc.getIsOrsGiven()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreatedBy()); + if (hbyc.getIs_ors_given()) { + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiary_id(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); } @@ -548,7 +549,7 @@ private void createIncentiveRecordforHbyncVisit(HbycChildVisit data, Long benId, DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Convert to LocalDate - LocalDate localDate = LocalDate.parse(data.getHbycVisitDate(), formatter); + LocalDate localDate = LocalDate.parse(data.getHbyc_visit_date(), formatter); // Convert LocalDate to Timestamp (00:00:00 by default) Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); @@ -578,7 +579,7 @@ private void createIncentiveRecordforHbyncOrsDistribution(HbycChildVisit data, L DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Convert to LocalDate - LocalDate localDate = LocalDate.parse(data.getHbycVisitDate(), formatter); + LocalDate localDate = LocalDate.parse(data.getHbyc_visit_date(), formatter); // Convert LocalDate to Timestamp (00:00:00 by default) Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); From 1ca2c4324a41e2322bd06c7006b768e1e96a7432 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 17:57:39 +0530 Subject: [PATCH 381/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 2f02c7ee..e07bc2a7 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -13,7 +13,7 @@ @Repository public interface HbycRepo extends JpaRepository { - HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDay(Long benId, String createdDate); + HbycChildVisit findHBYCByBeneficiary_IdAndHbycVisitDay(Long benId, String createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2ba76976..5832a4a9 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findHBYCByBeneficiary_IdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); From faf16c07fb01896ce82969eab1c0bb1f0be1e68a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:02:53 +0530 Subject: [PATCH 382/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 2 +- src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java | 2 +- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index deaf4f17..8763f557 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -20,7 +20,7 @@ public class HbycChildVisit { private Long id; @Column(name = "beneficiary_id") - private Long beneficiary_id; + private Long beneficiaryId; @Column(name = "household_id") private Long household_id; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index 105eed57..fb96b3c0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -24,7 +24,7 @@ public class HbycDTO { @SerializedName("beneficiary_id") - private Long beneficiary_id; + private Long beneficiaryId; @SerializedName("visit_day") private String visit_day; // 3 Months, 6 Months, etc. diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index e07bc2a7..2f02c7ee 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -13,7 +13,7 @@ @Repository public interface HbycRepo extends JpaRepository { - HbycChildVisit findHBYCByBeneficiary_IdAndHbycVisitDay(Long benId, String createdDate); + HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDay(Long benId, String createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 5832a4a9..2ba76976 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiary_IdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); From 6b5724f115163b51091d556efc7e74ece086a31d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:14:31 +0530 Subject: [PATCH 383/792] hbync api --- .../com/iemr/flw/controller/ChildCareController.java | 12 ++++++++++-- .../iemr/flw/service/impl/ChildCareServiceImpl.java | 8 ++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index cc7c3a08..fcc21890 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -1,5 +1,7 @@ package com.iemr.flw.controller; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iemr.flw.domain.iemr.HbncVisit; @@ -35,11 +37,16 @@ public class ChildCareController { @RequestMapping(value = {"/hbycVisit/saveAll"}, method = {RequestMethod.POST}) public String saveHbycRecords(@RequestBody List hbycDTOs, @RequestHeader(value = "Authorization") String Authorization) { - logger.info("Request: "+hbycDTOs.toString()); - logger.info("Request: "+hbycDTOs); + ObjectMapper mapper = new ObjectMapper(); + mapper.enable(SerializationFeature.INDENT_OUTPUT); // Pretty print + + // Request log + OutputResponse response = new OutputResponse(); try { + String json = mapper.writeValueAsString(hbycDTOs); + logger.info("📥 Incoming HBYC Request: \n" + json); logger.info("Saving All HBYC Details"); if (hbycDTOs != null) { String s = childCareService.registerHBYC(hbycDTOs); @@ -84,6 +91,7 @@ public String getHbycRecords(@RequestBody GetBenRequestHandler requestDTO) { public String saveHBNCVisit(@RequestBody List hbncRequestDTOs, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); + try { if (!hbncRequestDTOs.isEmpty()) { logger.info("Saving HBNC details at: " + new Timestamp(System.currentTimeMillis())); diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2ba76976..0c060c34 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -100,7 +100,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { for (HbycChildVisit hbycChildVisit : hbycChildVisits) { HbycVisitResponseDTO hbycRequestDTO = new HbycVisitResponseDTO(); hbycRequestDTO.setId(hbycChildVisit.getId()); - hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiary_id()); + hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiaryId()); hbycRequestDTO.setHouseHoldId(hbycChildVisit.getHousehold_id()); hbycRequestDTO.setVisitDate(hbycChildVisit.getHbyc_visit_date()); @@ -381,14 +381,14 @@ private void checkAndAddHbyncIncentives(List hbycList) { incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if (hbyncVisitActivity != null) { if (hbyc.getHbyc_visit_date() != null) { - createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiary_id(), hbyncVisitActivity, hbyc.getCreated_by()); + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } } if (hbyncOrsPacketActivityAM != null) { if (hbyc.getIs_ors_given()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiary_id(), hbyncOrsPacketActivityAM, hbyc.getCreated_by()); + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityAM, hbyc.getCreated_by()); } @@ -396,7 +396,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { if (hbyncOrsPacketActivityCH != null) { if (hbyc.getIs_ors_given()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiary_id(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); + createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); } From 617ca6e04eb866a3a7585bed191ace0cd1d68013 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:35:21 +0530 Subject: [PATCH 384/792] hbync api --- src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index fb96b3c0..acc54ca8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -22,16 +22,9 @@ @Data public class HbycDTO { - - @SerializedName("beneficiary_id") - private Long beneficiaryId; - @SerializedName("visit_day") private String visit_day; // 3 Months, 6 Months, etc. - @SerializedName("household_id") - private Long houseHoldId; - @SerializedName("due_date") private String due_date; @@ -111,7 +104,7 @@ public class HbycDTO { private String breathing_difficulty; @SerializedName("temperature_check") - private BigDecimal tempertemperature_checkature; + private BigDecimal temperature_check; @SerializedName("mcp_card_images") private List mcp_card_images; @@ -125,4 +118,5 @@ public class HbycDTO { + } From 856faf02359389f4cae528cd1270879446d6cd90 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:40:26 +0530 Subject: [PATCH 385/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 3 ++- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 2f02c7ee..1b79d041 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -13,7 +13,6 @@ @Repository public interface HbycRepo extends JpaRepository { - HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisitDay(Long benId, String createdDate); @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") List getAllHbycByBenId(@Param("userId") String userId, @@ -21,4 +20,6 @@ List getAllHbycByBenId(@Param("userId") String userId, List findByUserId(Integer ashaId); + + HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisit_day(Long beneficiaryId, String visit_day); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 0c060c34..c57bdfb5 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisitDay(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findHBYCByBeneficiaryIdAndHbycVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); From 4520aa077791f0964cc83b56c4e274fb3da3069f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:45:14 +0530 Subject: [PATCH 386/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 1b79d041..61f92177 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -21,5 +21,5 @@ List getAllHbycByBenId(@Param("userId") String userId, List findByUserId(Integer ashaId); - HbycChildVisit findHBYCByBeneficiaryIdAndHbycVisit_day(Long beneficiaryId, String visit_day); + HbycChildVisit findHBYCByBeneficiaryIdAndVisit_day(Long beneficiaryId, String visit_day); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index c57bdfb5..f20b95dd 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndHbycVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findHBYCByBeneficiaryIdAndVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); From c2f1b8e6ff121ba55dec43af36509d3948add060 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:49:34 +0530 Subject: [PATCH 387/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 6 +++++- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 61f92177..3a91b426 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -1,6 +1,7 @@ package com.iemr.flw.repo.iemr; import com.iemr.flw.domain.iemr.HBYC; +import com.iemr.flw.domain.iemr.HbncVisit; import com.iemr.flw.domain.iemr.HbycChildVisit; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -21,5 +22,8 @@ List getAllHbycByBenId(@Param("userId") String userId, List findByUserId(Integer ashaId); - HbycChildVisit findHBYCByBeneficiaryIdAndVisit_day(Long beneficiaryId, String visit_day); + @Query("SELECT v FROM HbycChildVisit v WHERE v.beneficiaryId = :beneficiaryId AND v.visit_day = :visitDay") + HbycChildVisit findByBeneficiaryIdAndVisit_day(@Param("beneficiaryId") Long beneficiaryId, + @Param("visitDay") String visitDay); + } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f20b95dd..021811fd 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -62,7 +62,7 @@ public String registerHBYC(List hbycDTOs) { hbycDTOs.forEach(it -> { HbycChildVisit hbyc = - hbycRepo.findHBYCByBeneficiaryIdAndVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findByBeneficiaryIdAndVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); From 651a198227f30d493d64b2e5212a73821e38566b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:52:36 +0530 Subject: [PATCH 388/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 7 +------ .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 3a91b426..5df90838 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -15,12 +15,7 @@ public interface HbycRepo extends JpaRepository { - @Query(" SELECT hbyc FROM HBYC hbyc WHERE hbyc.createdBy = :userId and hbyc.createdDate >= :fromDate and hbyc.createdDate <= :toDate") - List getAllHbycByBenId(@Param("userId") String userId, - @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); - - - List findByUserId(Integer ashaId); + List findByUser_id(Integer ashaId); @Query("SELECT v FROM HbycChildVisit v WHERE v.beneficiaryId = :beneficiaryId AND v.visit_day = :visitDay") HbycChildVisit findByBeneficiaryIdAndVisit_day(@Param("beneficiaryId") Long beneficiaryId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 021811fd..1a1db8c0 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -95,7 +95,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { List result = new ArrayList<>(); try { - List hbycChildVisits = hbycRepo.findByUserId(dto.getAshaId()); + List hbycChildVisits = hbycRepo.findByUser_id(dto.getAshaId()); for (HbycChildVisit hbycChildVisit : hbycChildVisits) { HbycVisitResponseDTO hbycRequestDTO = new HbycVisitResponseDTO(); From 4d169c22b3a501930d8312019d0ff35ce1c85d01 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:53:16 +0530 Subject: [PATCH 389/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 2 +- src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java | 2 +- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 8763f557..73780a13 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -29,7 +29,7 @@ public class HbycChildVisit { private String visit_day; // 3 Months, 6 Months, etc. @Column(name = "user_id") - private Integer user_id; + private Integer userId; @Column(name = "hbyc_due_date") private String hbyc_due_date; diff --git a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java index 5df90838..15f35e23 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/HbycRepo.java @@ -15,7 +15,7 @@ public interface HbycRepo extends JpaRepository { - List findByUser_id(Integer ashaId); + List findByUserId(Integer ashaId); @Query("SELECT v FROM HbycChildVisit v WHERE v.beneficiaryId = :beneficiaryId AND v.visit_day = :visitDay") HbycChildVisit findByBeneficiaryIdAndVisit_day(@Param("beneficiaryId") Long beneficiaryId, diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 1a1db8c0..df05cf93 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -68,13 +68,13 @@ public String registerHBYC(List hbycDTOs) { Long id = hbyc.getId(); modelMapper.map(it, hbyc); hbyc.setId(id); - hbyc.setUser_id(userRepo.getUserIdByName(it.getUserName())); + hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); } else { hbyc = new HbycChildVisit(); modelMapper.map(it, hbyc); hbyc.setId(null); - hbyc.setUser_id(userRepo.getUserIdByName(it.getUserName())); + hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); } @@ -95,7 +95,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { List result = new ArrayList<>(); try { - List hbycChildVisits = hbycRepo.findByUser_id(dto.getAshaId()); + List hbycChildVisits = hbycRepo.findByUserId(dto.getAshaId()); for (HbycChildVisit hbycChildVisit : hbycChildVisits) { HbycVisitResponseDTO hbycRequestDTO = new HbycVisitResponseDTO(); From 94e1d5a6134f119dec86ad44c0a8147e62e8e843 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:56:44 +0530 Subject: [PATCH 390/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 73780a13..a3d0d1ef 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -35,7 +35,7 @@ public class HbycChildVisit { private String hbyc_due_date; @Column(name = "hbyc_visit_date") - private String hbyc_visit_date; + private String visit_date; @Column(name = "is_baby_alive") private Boolean is_baby_alive = true; From 05e520ab83547472f1ff3dd8d24d9f28429ff4ee Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 18:58:43 +0530 Subject: [PATCH 391/792] hbync api --- .../iemr/flw/service/impl/ChildCareServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index df05cf93..e6ee109c 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -102,13 +102,13 @@ public List getHbycRecords(GetBenRequestHandler dto) { hbycRequestDTO.setId(hbycChildVisit.getId()); hbycRequestDTO.setBeneficiaryId(hbycChildVisit.getBeneficiaryId()); hbycRequestDTO.setHouseHoldId(hbycChildVisit.getHousehold_id()); - hbycRequestDTO.setVisitDate(hbycChildVisit.getHbyc_visit_date()); + hbycRequestDTO.setVisitDate(hbycChildVisit.getVisit_date()); // Prepare dynamic fields map Map fields = new HashMap<>(); addIfValid(fields, "visit_day", hbycChildVisit.getVisit_day()); addIfValid(fields, "due_date", hbycChildVisit.getHbyc_due_date()); - addIfValid(fields, "visit_date", hbycChildVisit.getHbyc_visit_date()); + addIfValid(fields, "visit_date", hbycChildVisit.getVisit_date()); addIfValid(fields, "is_baby_alive", convert(hbycChildVisit.getIs_baby_alive())); addIfValid(fields, "date_of_death", hbycChildVisit.getDate_of_death()); addIfValid(fields, "reason_for_death", hbycChildVisit.getReason_for_death()); @@ -380,7 +380,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { IncentiveActivity hbyncOrsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if (hbyncVisitActivity != null) { - if (hbyc.getHbyc_visit_date() != null) { + if (hbyc.getVisit_date() != null) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } @@ -549,7 +549,7 @@ private void createIncentiveRecordforHbyncVisit(HbycChildVisit data, Long benId, DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Convert to LocalDate - LocalDate localDate = LocalDate.parse(data.getHbyc_visit_date(), formatter); + LocalDate localDate = LocalDate.parse(data.getVisit_date(), formatter); // Convert LocalDate to Timestamp (00:00:00 by default) Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); @@ -579,7 +579,7 @@ private void createIncentiveRecordforHbyncOrsDistribution(HbycChildVisit data, L DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); // Convert to LocalDate - LocalDate localDate = LocalDate.parse(data.getHbyc_visit_date(), formatter); + LocalDate localDate = LocalDate.parse(data.getVisit_date(), formatter); // Convert LocalDate to Timestamp (00:00:00 by default) Timestamp visitDate = Timestamp.valueOf(localDate.atStartOfDay()); From fc928ff8a7a9534f0433acb16b9afdc5ba3b6afa Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 13 Oct 2025 19:08:29 +0530 Subject: [PATCH 392/792] hbync api --- .../iemr/flw/service/impl/BeneficiaryServiceImpl.java | 10 ++++++++++ .../iemr/flw/service/impl/ChildCareServiceImpl.java | 9 +++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index a99f2bdc..d540aa91 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -11,7 +11,11 @@ import java.util.Map; import java.util.stream.Collectors; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.GeneralOpdRepo; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -63,7 +67,11 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { @Autowired private GeneralOpdRepo generalOpdRepo; + @Autowired + IncentivesRepo incentivesRepo; + @Autowired + IncentiveRecordRepo recordRepo; @Override public String getBenData(GetBenRequestHandler request, String authorisation) throws Exception { String outputResponse = null; @@ -372,6 +380,7 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("otherPlaceOfDeath", benDetailsRMNCH_OBJ.getOtherPlaceOfDeath()); + resultMap.put("BenRegId", m.getBenRegId()); // adding asha id / created by - user id @@ -403,6 +412,7 @@ private String getMappingsForAddressIDs(List addressLi return gson.toJson(response); } + private Map getBenHealthDetails(BigInteger benRegId) { Map healthDetails = new HashMap<>(); if (null != benRegId) { diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index e6ee109c..0157b889 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -60,19 +60,20 @@ public String registerHBYC(List hbycDTOs) { List hbycList = new ArrayList<>(); hbycDTOs.forEach(it -> { - + HbycDTO hbycDTO = it.getFields(); + hbycDTO.setVisit_date(it.getVisitDate()); HbycChildVisit hbyc = - hbycRepo.findByBeneficiaryIdAndVisit_day(it.getBeneficiaryId(), it.getFields().getVisit_day()); + hbycRepo.findByBeneficiaryIdAndVisit_day(it.getBeneficiaryId(), hbycDTO.getVisit_day()); if (hbyc != null) { Long id = hbyc.getId(); - modelMapper.map(it, hbyc); + modelMapper.map(it, hbycDTO); hbyc.setId(id); hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); } else { hbyc = new HbycChildVisit(); - modelMapper.map(it, hbyc); + modelMapper.map(it, hbycDTO); hbyc.setId(null); hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); From a9f105b011801bf9ab6485092bee69e4f77c0c6e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 10:52:47 +0530 Subject: [PATCH 393/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 0157b889..76234744 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -77,6 +77,7 @@ public String registerHBYC(List hbycDTOs) { hbyc.setId(null); hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); + hbyc.setBeneficiaryId(it.getBeneficiaryId()); } hbycList.add(hbyc); From 9b437e7477f3405cd732086a23d543f867656871 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 11:26:34 +0530 Subject: [PATCH 394/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 76234744..d718fbaa 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -78,6 +78,7 @@ public String registerHBYC(List hbycDTOs) { hbyc.setUserId(userRepo.getUserIdByName(it.getUserName())); hbyc.setCreated_by(it.getUserName()); hbyc.setBeneficiaryId(it.getBeneficiaryId()); + hbyc.setVisit_date(it.getVisitDate()); } hbycList.add(hbyc); From ad2ab64d987e48a0766b47ff1e380cecf939fe2c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 11:27:41 +0530 Subject: [PATCH 395/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 4 ++-- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index a3d0d1ef..2b22f054 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -116,10 +116,10 @@ public class HbycChildVisit { private List mcp_card_images; @Column(name = "created_at") - private LocalDateTime created_at; + private LocalDateTime created_at = LocalDateTime.now(); @Column(name = "updated_at") - private LocalDateTime updated_at; + private LocalDateTime updated_at = LocalDateTime.now(); @Column(name = "created_by") private String created_by; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index d718fbaa..d989e25f 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -79,6 +79,7 @@ public String registerHBYC(List hbycDTOs) { hbyc.setCreated_by(it.getUserName()); hbyc.setBeneficiaryId(it.getBeneficiaryId()); hbyc.setVisit_date(it.getVisitDate()); + hbyc.setHousehold_id(it.getHouseHoldId()); } hbycList.add(hbyc); From cefa498fa3726d2f73ed0d4ed79ac1367b96ce07 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 11:50:02 +0530 Subject: [PATCH 396/792] hbync api --- .../iemr/flw/domain/iemr/HbycChildVisit.java | 28 +++---- .../service/impl/ChildCareServiceImpl.java | 77 ++++++++++++++----- 2 files changed, 73 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index 2b22f054..a2346407 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -59,49 +59,49 @@ public class HbycChildVisit { private Boolean is_child_sick; @Column(name = "is_exclusive_breastfeeding") - private Boolean is_exclusive_breastfeeding; + private Boolean exclusive_breastfeeding; @Column(name = "is_mother_counseled_exbf") - private Boolean is_mother_counseled_exbf; + private Boolean mother_counseled_ebf; @Column(name = "has_child_started_complementary_feeding") private Boolean has_child_started_complementary_feeding; @Column(name = "is_mother_counseled_cf") - private Boolean is_mother_counseled_cf; + private Boolean mother_counseled_cf; @Column(name = "is_weight_recorded_by_aww") - private Boolean is_weight_recorded_by_aww; + private Boolean weight_recorded; @Column(name = "is_developmental_delay") - private Boolean is_developmental_delay; + private Boolean developmental_delay; @Column(name = "is_measles_vaccine_given") - private Boolean is_measles_vaccine_given; + private Boolean measles_vaccine; @Column(name = "is_vitamin_a_given") - private Boolean is_vitamin_a_given; + private Boolean vitamin_a; @Column(name = "is_ors_available") - private Boolean is_ors_available; + private Boolean ors_available; @Column(name = "is_ifa_syrup_available") - private Boolean is_ifa_syrup_available; + private Boolean Ifa_available; @Column(name = "is_ors_given") - private Boolean is_ors_given; + private Boolean ors_given; @Column(name = "is_ifa_syrup_given") - private Boolean is_ifa_syrup_given; + private Boolean ifa_given; @Column(name = "is_handwashing_counseling_given") - private Boolean is_handwashing_counseling_given; + private Boolean handwash_counseling; @Column(name = "is_parenting_counseling_given") - private Boolean is_parenting_counseling_given; + private Boolean parenting_counseling; @Column(name = "is_family_planning_counseling_given") - private Boolean is_family_planning_counseling_given; + private Boolean family_planning_counseling; @Column(name = "diarrhoea_episode") private Boolean diarrhoea_episode; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index d989e25f..a4fc949f 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -80,6 +80,37 @@ public String registerHBYC(List hbycDTOs) { hbyc.setBeneficiaryId(it.getBeneficiaryId()); hbyc.setVisit_date(it.getVisitDate()); hbyc.setHousehold_id(it.getHouseHoldId()); + hbyc.setVisit_day(hbycDTO.getVisit_day()); + hbyc.setHbyc_due_date(hbycDTO.getDue_date()); + hbyc.setBaby_weight(hbycDTO.getBaby_weight()); + hbyc.setPlace_of_death(hbycDTO.getPlace_of_death()); + hbyc.setReason_for_death(hbycDTO.getReason_for_death()); + hbyc.setOther_place_of_death(hbycDTO.getOther_place_of_death()); + hbyc.setIs_child_sick(convertBollen(hbycDTO.getIs_child_sick())); + + hbyc.setIs_baby_alive(convertBollen(hbycDTO.getIs_baby_alive())); + hbyc.setDate_of_death(hbycDTO.getDate_of_death()); + hbyc.setExclusive_breastfeeding(convertBollen(hbycDTO.getExclusive_breastfeeding())); + hbyc.setMother_counseled_ebf(convertBollen(hbycDTO.getMother_counseled_ebf())); +// hbyc.setComplementary_feeding(hbycDTO.getComplementary_feeding()); + hbyc.setMother_counseled_cf(convertBollen((hbycDTO.getMother_counseled_cf()))); + hbyc.setWeight_recorded(convertBollen(hbycDTO.getWeight_recorded())); + hbyc.setDevelopmental_delay(convertBollen(hbycDTO.getDevelopmental_delay())); + hbyc.setMeasles_vaccine(convertBollen(hbycDTO.getMeasles_vaccine())); + hbyc.setVitamin_a(convertBollen(hbycDTO.getVitamin_a())); + hbyc.setOrs_available(convertBollen(hbycDTO.getOrs_available())); + hbyc.setIfa_available(convertBollen(hbycDTO.getIfa_available())); + hbyc.setOrs_given(convertBollen(hbycDTO.getOrs_given())); + hbyc.setIfa_given(convertBollen(hbycDTO.getIfa_given())); + hbyc.setHandwash_counseling(convertBollen(hbycDTO.getHandwash_counseling())); + hbyc.setParenting_counseling(convertBollen(hbycDTO.getParenting_counseling())); + hbyc.setFamily_planning_counseling(convertBollen(hbycDTO.getFamily_planning_counseling())); + hbyc.setDiarrhoea_episode(convertBollen(hbycDTO.getDiarrhoea_episode())); +// hbyc.setBreathing_difficulty(hbycDTO.getBreathing_difficulty()); + hbyc.setTemperature(hbycDTO.getTemperature_check()); + hbyc.setMcp_card_images(hbycDTO.getMcp_card_images()); + hbyc.setCreated_at(hbycDTO.getCreated_at()); + hbyc.setUpdated_at(hbycDTO.getUpdated_at()); } hbycList.add(hbyc); @@ -110,6 +141,7 @@ public List getHbycRecords(GetBenRequestHandler dto) { // Prepare dynamic fields map Map fields = new HashMap<>(); + addIfValid(fields, "visit_day", hbycChildVisit.getVisit_day()); addIfValid(fields, "due_date", hbycChildVisit.getHbyc_due_date()); addIfValid(fields, "visit_date", hbycChildVisit.getVisit_date()); @@ -120,27 +152,28 @@ public List getHbycRecords(GetBenRequestHandler dto) { addIfValid(fields, "other_place_of_death", hbycChildVisit.getOther_place_of_death()); addIfValid(fields, "baby_weight", hbycChildVisit.getBaby_weight()); addIfValid(fields, "is_child_sick", convert(hbycChildVisit.getIs_child_sick())); - addIfValid(fields, "exclusive_breastfeeding", convert(hbycChildVisit.getIs_exclusive_breastfeeding())); - addIfValid(fields, "mother_counseled_ebf", convert(hbycChildVisit.getIs_mother_counseled_exbf())); - addIfValid(fields, "complementary_feeding", convert(hbycChildVisit.getHas_child_started_complementary_feeding())); - addIfValid(fields, "mother_counseled_cf", convert(hbycChildVisit.getIs_mother_counseled_cf())); - addIfValid(fields, "weight_recorded", convert(hbycChildVisit.getIs_weight_recorded_by_aww())); - addIfValid(fields, "developmental_delay", convert(hbycChildVisit.getIs_developmental_delay())); - addIfValid(fields, "measles_vaccine", convert(hbycChildVisit.getIs_measles_vaccine_given())); - addIfValid(fields, "vitamin_a", convert(hbycChildVisit.getIs_vitamin_a_given())); - addIfValid(fields, "ors_available", convert(hbycChildVisit.getIs_ors_available())); - addIfValid(fields, "ifa_available", convert(hbycChildVisit.getIs_ifa_syrup_available())); - addIfValid(fields, "ors_given", convert(hbycChildVisit.getIs_ors_given())); - addIfValid(fields, "ifa_given", convert(hbycChildVisit.getIs_ifa_syrup_given())); - addIfValid(fields, "handwash_counseling", convert(hbycChildVisit.getIs_handwashing_counseling_given())); - addIfValid(fields, "parenting_counseling", convert(hbycChildVisit.getIs_parenting_counseling_given())); - addIfValid(fields, "family_planning_counseling", convert(hbycChildVisit.getIs_family_planning_counseling_given())); + addIfValid(fields, "exclusive_breastfeeding", convert(hbycChildVisit.getExclusive_breastfeeding())); + addIfValid(fields, "mother_counseled_ebf", convert(hbycChildVisit.getMother_counseled_ebf())); +// addIfValid(fields, "complementary_feeding", convert(hbycChildVisit.getComplementary_feeding())); + addIfValid(fields, "mother_counseled_cf", convert(hbycChildVisit.getMother_counseled_cf())); + addIfValid(fields, "weight_recorded", convert(hbycChildVisit.getWeight_recorded())); + addIfValid(fields, "developmental_delay", convert(hbycChildVisit.getDevelopmental_delay())); + addIfValid(fields, "measles_vaccine", convert(hbycChildVisit.getMeasles_vaccine())); + addIfValid(fields, "vitamin_a", convert(hbycChildVisit.getVitamin_a())); + addIfValid(fields, "ors_available", convert(hbycChildVisit.getOrs_available())); + addIfValid(fields, "ifa_available", convert(hbycChildVisit.getIfa_available())); + addIfValid(fields, "ors_given", convert(hbycChildVisit.getOrs_given())); + addIfValid(fields, "ifa_given", convert(hbycChildVisit.getIfa_given())); + addIfValid(fields, "handwash_counseling", convert(hbycChildVisit.getHandwash_counseling())); + addIfValid(fields, "parenting_counseling", convert(hbycChildVisit.getParenting_counseling())); + addIfValid(fields, "family_planning_counseling", convert(hbycChildVisit.getFamily_planning_counseling())); addIfValid(fields, "diarrhoea_episode", convert(hbycChildVisit.getDiarrhoea_episode())); - addIfValid(fields, "breathing_difficulty", convert(hbycChildVisit.getPneumonia_symptoms())); +// addIfValid(fields, "breathing_difficulty", convert(hbycChildVisit.getBreathing_difficulty())); addIfValid(fields, "temperature_check", hbycChildVisit.getTemperature()); addIfValid(fields, "mcp_card_images", hbycChildVisit.getMcp_card_images()); + // Set fields map in DTO hbycRequestDTO.setFields(fields); result.add(hbycRequestDTO); @@ -217,6 +250,14 @@ private String convert(Boolean value) { return value ? "Yes" : "No"; } + private Boolean convertBollen(String value) { + if(value.equals("Yes")){ + return true; + }else { + return false; + } + } + private String convert(Object value) { if (value == null) return null; if (value instanceof Boolean) return (Boolean) value ? "Yes" : "No"; @@ -391,7 +432,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { } if (hbyncOrsPacketActivityAM != null) { - if (hbyc.getIs_ors_given()) { + if (hbyc.getOrs_given()) { createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityAM, hbyc.getCreated_by()); } @@ -399,7 +440,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { } if (hbyncOrsPacketActivityCH != null) { - if (hbyc.getIs_ors_given()) { + if (hbyc.getOrs_given()) { createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); } From b1cc88c5d8c5f47851e1d0597ce3f466da400e12 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 11:58:13 +0530 Subject: [PATCH 397/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java | 6 ++++++ .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index a2346407..bcaeabc4 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -124,5 +124,11 @@ public class HbycChildVisit { @Column(name = "created_by") private String created_by; + @Column(name = "is_breathing_difficulty") + private Boolean breathing_difficulty; + + @Column(name = "is_complementary_feeding") + private Boolean complementary_feeding; + // Getters and Setters } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index a4fc949f..9ca3e461 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -92,7 +92,7 @@ public String registerHBYC(List hbycDTOs) { hbyc.setDate_of_death(hbycDTO.getDate_of_death()); hbyc.setExclusive_breastfeeding(convertBollen(hbycDTO.getExclusive_breastfeeding())); hbyc.setMother_counseled_ebf(convertBollen(hbycDTO.getMother_counseled_ebf())); -// hbyc.setComplementary_feeding(hbycDTO.getComplementary_feeding()); + hbyc.setComplementary_feeding(convertBollen(hbycDTO.getComplementary_feeding())); hbyc.setMother_counseled_cf(convertBollen((hbycDTO.getMother_counseled_cf()))); hbyc.setWeight_recorded(convertBollen(hbycDTO.getWeight_recorded())); hbyc.setDevelopmental_delay(convertBollen(hbycDTO.getDevelopmental_delay())); @@ -106,7 +106,7 @@ public String registerHBYC(List hbycDTOs) { hbyc.setParenting_counseling(convertBollen(hbycDTO.getParenting_counseling())); hbyc.setFamily_planning_counseling(convertBollen(hbycDTO.getFamily_planning_counseling())); hbyc.setDiarrhoea_episode(convertBollen(hbycDTO.getDiarrhoea_episode())); -// hbyc.setBreathing_difficulty(hbycDTO.getBreathing_difficulty()); + hbyc.setBreathing_difficulty(convertBollen(hbycDTO.getBreathing_difficulty())); hbyc.setTemperature(hbycDTO.getTemperature_check()); hbyc.setMcp_card_images(hbycDTO.getMcp_card_images()); hbyc.setCreated_at(hbycDTO.getCreated_at()); From 560d4606cf5f96e508a0f048c189ccb8cbdb7155 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 11:58:56 +0530 Subject: [PATCH 398/792] hbync api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 9ca3e461..f951d1ef 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -109,8 +109,6 @@ public String registerHBYC(List hbycDTOs) { hbyc.setBreathing_difficulty(convertBollen(hbycDTO.getBreathing_difficulty())); hbyc.setTemperature(hbycDTO.getTemperature_check()); hbyc.setMcp_card_images(hbycDTO.getMcp_card_images()); - hbyc.setCreated_at(hbycDTO.getCreated_at()); - hbyc.setUpdated_at(hbycDTO.getUpdated_at()); } hbycList.add(hbyc); From 65260681f621c8d7e43ba2631f51d6318c33a4d7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:19:07 +0530 Subject: [PATCH 399/792] hbync api --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 77a2d35b..d34da62f 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -9,6 +9,8 @@ import com.iemr.flw.repo.iemr.SammelanAttachmentRepository; import com.iemr.flw.repo.iemr.SammelanRecordRepository; import com.iemr.flw.service.SammelanService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -22,6 +24,8 @@ @Service public class SammelanServiceImpl implements SammelanService { + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + @Autowired private SammelanRecordRepository recordRepo; @Autowired @@ -97,6 +101,7 @@ record = recordRepo.save(record); } catch (Exception e) { + logger.info("Exception: "+e.getMessage()); } return response; From 5dd8dc281014fbaa03652830cddae2a700cc81bc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:27:08 +0530 Subject: [PATCH 400/792] hbync api --- .../flw/controller/AshaProfileController.java | 2 +- .../java/com/iemr/flw/utils/DateUtil.java | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/iemr/flw/utils/DateUtil.java diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index 8f704884..1c8d2930 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -47,7 +47,7 @@ public class AshaProfileController { private EmployeeMasterInter employeeMasterInter; @RequestMapping(value = "editProfile", method = {RequestMethod.POST}, produces = { - "application/json"}, consumes = "application/json") + "application/json"}, consumes = "application/json", headers = "Authorization") public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee,@RequestHeader(value = "Authorization") String authorization) { diff --git a/src/main/java/com/iemr/flw/utils/DateUtil.java b/src/main/java/com/iemr/flw/utils/DateUtil.java new file mode 100644 index 00000000..3a1143a3 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/DateUtil.java @@ -0,0 +1,20 @@ +package com.iemr.flw.utils; + +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class DateUtil { + + private static final DateTimeFormatter OUTPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + public static String formatToTimestamp(LocalDateTime dateTime) { + try { + if (dateTime != null) { + return dateTime.format(OUTPUT_FORMATTER); + } + } catch (Exception e) { + System.err.println("Error formatting date: " + e.getMessage()); + } + return null; + } +} From eb5308cf52f8972fc26695b47e6f705fba412480 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:33:25 +0530 Subject: [PATCH 401/792] hbync api --- .../flw/controller/SammelanController.java | 6 ++++- .../java/com/iemr/flw/utils/DateUtil.java | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index d72a6ff5..9654d1ea 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -2,6 +2,7 @@ import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.SammelanService; +import com.iemr.flw.utils.DateUtil; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -19,7 +20,10 @@ import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; +import java.util.Objects; @RestController @RequestMapping(value = "/sammelans") @@ -40,7 +44,7 @@ public ResponseEntity create( SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(Timestamp.valueOf(date)); + sammelanRequestDTO.setDate(DateUtil.convertToTimestamp(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); diff --git a/src/main/java/com/iemr/flw/utils/DateUtil.java b/src/main/java/com/iemr/flw/utils/DateUtil.java index 3a1143a3..ff095511 100644 --- a/src/main/java/com/iemr/flw/utils/DateUtil.java +++ b/src/main/java/com/iemr/flw/utils/DateUtil.java @@ -1,20 +1,31 @@ package com.iemr.flw.utils; +import java.sql.Timestamp; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class DateUtil { + private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - private static final DateTimeFormatter OUTPUT_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static final DateTimeFormatter OUTPUT_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - public static String formatToTimestamp(LocalDateTime dateTime) { + public static Timestamp convertToTimestamp(String inputDate) { try { - if (dateTime != null) { - return dateTime.format(OUTPUT_FORMATTER); - } + if (inputDate == null || inputDate.isEmpty()) return null; + + // Parse "14-10-2025" → LocalDate + LocalDate localDate = LocalDate.parse(inputDate, INPUT_FORMAT); + + // Convert to LocalDateTime (midnight) + LocalDateTime localDateTime = localDate.atStartOfDay(); + + // Convert to SQL Timestamp + return Timestamp.valueOf(localDateTime); } catch (Exception e) { - System.err.println("Error formatting date: " + e.getMessage()); + System.err.println("❌ Date parsing failed for: " + inputDate + " | " + e.getMessage()); + return null; } - return null; } } + From b99c45b90add3e9059757934cc3f8409823f507d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:41:17 +0530 Subject: [PATCH 402/792] hbync api --- .../com/iemr/flw/controller/SammelanController.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 9654d1ea..d336afed 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -1,5 +1,7 @@ package com.iemr.flw.controller; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.SammelanService; import com.iemr.flw.utils.DateUtil; @@ -9,6 +11,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Limit; import org.springframework.data.domain.Page; @@ -28,6 +32,8 @@ @RestController @RequestMapping(value = "/sammelans") public class SammelanController { + private final Logger logger = LoggerFactory.getLogger(DeathReportsController.class); + @Autowired private SammelanService service; @@ -40,14 +46,16 @@ public ResponseEntity create( @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, - @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) { + @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); sammelanRequestDTO.setDate(DateUtil.convertToTimestamp(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); + ObjectMapper mapper = new ObjectMapper(); - + String json = mapper.writeValueAsString(sammelanRequestDTO); + logger.info("📥 Incoming HBYC Request: \n" + json); SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO,images); return ResponseEntity.status(HttpStatus.CREATED).body(resp); } From 601ca4f7a2cc4cc0bb88263730acf4da34f2f3c2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:45:25 +0530 Subject: [PATCH 403/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index d336afed..d80af2e3 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -55,7 +55,7 @@ public ResponseEntity create( ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(sammelanRequestDTO); - logger.info("📥 Incoming HBYC Request: \n" + json); + logger.info("📥 Incoming HBYC Request: \n" + json+"date"+date); SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO,images); return ResponseEntity.status(HttpStatus.CREATED).body(resp); } From a1605a3099c21d69d4ebe3a45915004d388bfb7d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:50:26 +0530 Subject: [PATCH 404/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index d80af2e3..6c2098cd 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -50,7 +50,7 @@ public ResponseEntity create( SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(DateUtil.convertToTimestamp(date)); + sammelanRequestDTO.setDate(Timestamp.valueOf(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); ObjectMapper mapper = new ObjectMapper(); From e88302e266e2afeb019adb8271da3e9e2e1f3489 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:51:24 +0530 Subject: [PATCH 405/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 6c2098cd..f251dbbe 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -47,10 +47,12 @@ public ResponseEntity create( @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { + Timestamp ts = new Timestamp(Long.parseLong(date)); + SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(Timestamp.valueOf(date)); + sammelanRequestDTO.setDate(ts); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); ObjectMapper mapper = new ObjectMapper(); From 6c8c65b8fb7ac945bc401381bbf39db865cb53c3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 12:59:48 +0530 Subject: [PATCH 406/792] hbync api --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index d34da62f..4787d342 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.sql.Timestamp; import java.time.LocalDate; import java.time.YearMonth; import java.time.ZoneId; @@ -62,6 +63,7 @@ public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, // Save Sammelan record record = new SammelanRecord(); record.setAshaId(sammelanRequestDTO.getAshaId()); + logger.info("Meeting Date:"+sammelanRequestDTO.getDate()); record.setMeetingDate(sammelanRequestDTO.getDate()); record.setPlace(sammelanRequestDTO.getPlace()); record.setParticipants(sammelanRequestDTO.getParticipants()); @@ -90,7 +92,6 @@ record = recordRepo.save(record); record.setAttachments(imagesJson); } - // Prepare Response DTO response.setId(record.getId()); response.setAshaId(record.getAshaId()); From 41eef36916863f4bbafa44d20793d4a4a193ae90 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 13:06:29 +0530 Subject: [PATCH 407/792] hbync api --- .../java/com/iemr/flw/controller/ChildCareController.java | 3 +-- src/main/java/com/iemr/flw/controller/SammelanController.java | 3 ++- src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java | 2 +- src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java | 2 +- src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java | 2 +- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index fcc21890..81fa422b 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -45,8 +45,7 @@ public String saveHbycRecords(@RequestBody List hbycDTOs, OutputResponse response = new OutputResponse(); try { - String json = mapper.writeValueAsString(hbycDTOs); - logger.info("📥 Incoming HBYC Request: \n" + json); + logger.info("Saving All HBYC Details"); if (hbycDTOs != null) { String s = childCareService.registerHBYC(hbycDTOs); diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index f251dbbe..55fb3c34 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -24,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.List; @@ -52,7 +53,7 @@ public ResponseEntity create( SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(ts); + sammelanRequestDTO.setDate(LocalDate.parse(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java index 7895bb17..24681d19 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -27,7 +27,7 @@ public class SammelanRecord { @Column(name = "meeting_date", nullable = false) - private Timestamp meetingDate; + private LocalDate meetingDate; @Column(nullable = false) diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index a731d05e..7642afc9 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -10,7 +10,7 @@ public class SammelanRequestDTO { private Integer ashaId; // ASHA worker ID - private Timestamp date; // Meeting date + private LocalDate date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center private Integer participants; // Number of participants attended diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java index 690f10ce..0b8fbd50 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java @@ -13,7 +13,7 @@ public class SammelanResponseDTO { private Long id; private Integer ashaId; - private Timestamp date; + private LocalDate date; private String place; private Integer participants; private List imagePaths; diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 4787d342..f8dee319 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -44,7 +44,7 @@ public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, try { validateRequest(sammelanRequestDTO); - LocalDate localDate = sammelanRequestDTO.getDate().toInstant() + LocalDate localDate = sammelanRequestDTO.getDate().atStartOfDay() .atZone(ZoneId.systemDefault()) .toLocalDate(); @@ -137,7 +137,7 @@ public List getSammelanHistory(Integer ashaId) { } private void validateRequest(SammelanRequestDTO dto) { - LocalDate date = dto.getDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate date = dto.getDate().atStartOfDay().atZone(ZoneId.systemDefault()).toLocalDate(); if (date == null) { throw new IllegalArgumentException("Date is mandatory."); From caac6a9bbf1f7bfa2e931f70d8f62955638a1afb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 13:10:33 +0530 Subject: [PATCH 408/792] hbync api --- .../com/iemr/flw/controller/SammelanController.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 55fb3c34..6f18bcd2 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -24,8 +24,10 @@ import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; +import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Objects; @@ -48,12 +50,14 @@ public ResponseEntity create( @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { - Timestamp ts = new Timestamp(Long.parseLong(date)); - + long epochMilli = Long.parseLong(date); // "1760380200000" from request + LocalDate localDate = Instant.ofEpochMilli(epochMilli) + .atZone(ZoneId.systemDefault()) + .toLocalDate(); SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(LocalDate.parse(date)); + sammelanRequestDTO.setDate(localDate); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); ObjectMapper mapper = new ObjectMapper(); From 5df817e956578d8b4bc8319717f1b2bd8ef9fa7b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 13:16:40 +0530 Subject: [PATCH 409/792] hbync api --- .../flw/controller/SammelanController.java | 7 ++-- .../iemr/flw/domain/iemr/SammelanRecord.java | 2 +- .../iemr/flw/dto/iemr/SammelanRequestDTO.java | 2 +- .../flw/dto/iemr/SammelanResponseDTO.java | 2 +- .../flw/service/impl/SammelanServiceImpl.java | 35 +------------------ 5 files changed, 6 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 6f18bcd2..b4fdbdc8 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -50,14 +50,11 @@ public ResponseEntity create( @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { - long epochMilli = Long.parseLong(date); // "1760380200000" from request - LocalDate localDate = Instant.ofEpochMilli(epochMilli) - .atZone(ZoneId.systemDefault()) - .toLocalDate(); + SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); - sammelanRequestDTO.setDate(localDate); + sammelanRequestDTO.setDate(Long.parseLong(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java index 24681d19..0516aa15 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -27,7 +27,7 @@ public class SammelanRecord { @Column(name = "meeting_date", nullable = false) - private LocalDate meetingDate; + private Long meetingDate; @Column(nullable = false) diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index 7642afc9..74970df4 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -10,7 +10,7 @@ public class SammelanRequestDTO { private Integer ashaId; // ASHA worker ID - private LocalDate date; // Meeting date + private Long date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center private Integer participants; // Number of participants attended diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java index 0b8fbd50..ee2a0b79 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanResponseDTO.java @@ -13,7 +13,7 @@ public class SammelanResponseDTO { private Long id; private Integer ashaId; - private LocalDate date; + private Long date; private String place; private Integer participants; private List imagePaths; diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index f8dee319..972f0ef5 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -43,22 +43,7 @@ public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, SammelanResponseDTO response = new SammelanResponseDTO(); try { - validateRequest(sammelanRequestDTO); - LocalDate localDate = sammelanRequestDTO.getDate().atStartOfDay() - .atZone(ZoneId.systemDefault()) - .toLocalDate(); - - YearMonth ym = YearMonth.from(localDate); - - // Check for existing record in same month - boolean exists = recordRepo.existsByAshaIdAndMeetingDateBetween( - sammelanRequestDTO.getAshaId(), - ym.atDay(1), - ym.atEndOfMonth() - ); - if (exists) { - throw new IllegalArgumentException("Sammelan already submitted for this month."); - } + // Save Sammelan record record = new SammelanRecord(); @@ -136,22 +121,4 @@ public List getSammelanHistory(Integer ashaId) { }).collect(Collectors.toList()); } - private void validateRequest(SammelanRequestDTO dto) { - LocalDate date = dto.getDate().atStartOfDay().atZone(ZoneId.systemDefault()).toLocalDate(); - - if (date == null) { - throw new IllegalArgumentException("Date is mandatory."); - } - if (date.isAfter(LocalDate.now())) { - throw new IllegalArgumentException("Date cannot be in future."); - } - if (date.isBefore(LocalDate.now().minusMonths(2))) { - throw new IllegalArgumentException("Backdate not allowed beyond 2 months."); - } - if (dto.getParticipants() < 0 || dto.getParticipants() > 999) { - throw new IllegalArgumentException("Participants must be between 0–999."); - } - - - } } From 4855b87beaa989cb09b938a7fd54b6a2a7b9b814 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 13:21:24 +0530 Subject: [PATCH 410/792] hbync api --- .../java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java index 93e8c2c6..ce45de94 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java @@ -10,8 +10,6 @@ @Repository public interface SammelanRecordRepository extends JpaRepository { - // Check if ASHA has already submitted record in same month - boolean existsByAshaIdAndMeetingDateBetween(Integer ashaId, LocalDate startDate, LocalDate endDate); // Fetch history List findByAshaIdOrderByMeetingDateDesc(Integer ashaId); From 3e0fb19873bf0dbe4e11ef5357cf4645778b54ac Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 14:30:43 +0530 Subject: [PATCH 411/792] hbync api --- .../com/iemr/flw/domain/iemr/EligibleCoupleTracking.java | 6 ++++++ .../com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java index e9f1ca1a..99b8b511 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EligibleCoupleTracking.java @@ -66,4 +66,10 @@ public class EligibleCoupleTracking { @Column(name = "antra_dose") private String antraDose; + + @Column(name = "discharge_summary1") + private String dischargeSummary1; + + @Column(name = "discharge_summary2") + private String dischargeSummary2; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java index 968e3dcc..415fd1b1 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleTrackingDTO.java @@ -44,4 +44,7 @@ public class EligibleCoupleTrackingDTO implements Serializable { private String antraDose; + private String dischargeSummary1; + private String dischargeSummary2; + } From d1e9bb4bd71bb96126fa5aa128e48889d874898e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 15:47:10 +0530 Subject: [PATCH 412/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index b4fdbdc8..964535dc 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -42,7 +42,7 @@ public class SammelanController { - @RequestMapping(value = "saveAll",method = RequestMethod.POST) + @RequestMapping(value = "saveAll",method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity create( @RequestPart("date") String date, diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java index 0516aa15..84f0af48 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -7,6 +7,7 @@ import java.sql.Timestamp; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -45,8 +46,7 @@ public class SammelanRecord { private String createdBy; @Column(name = "created_date") - private Timestamp createdDate; - + private Timestamp createdDate = new Timestamp(System.currentTimeMillis()); @Lob @Column(columnDefinition = "LONGTEXT",name = "attachments") From f3ca2850fabe5799786dc80cf6202a42e3882c3d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 15:50:52 +0530 Subject: [PATCH 413/792] hbync api --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 972f0ef5..5c1eb883 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -96,7 +96,7 @@ record = recordRepo.save(record); @Override public List getSammelanHistory(Integer ashaId) { - List records = recordRepo.findByAshaIdOrderByMeetingDateDesc(ashaId); + List records = recordRepo.findByAshaId(ashaId); return records.stream().map(record -> { SammelanResponseDTO dto = new SammelanResponseDTO(); dto.setId(record.getId()); From 8fdd0c493cb127e22b4b6b63cb5edcc5454b5998 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 15:56:24 +0530 Subject: [PATCH 414/792] hbync api --- .../java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java index ce45de94..1ea31437 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/SammelanRecordRepository.java @@ -12,5 +12,5 @@ public interface SammelanRecordRepository extends JpaRepository findByAshaIdOrderByMeetingDateDesc(Integer ashaId); + List findByAshaId(Integer ashaId); } From 5c39dbf6e0c49317284f58fe5e5dbbc4986f2a1c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 16:06:25 +0530 Subject: [PATCH 415/792] hbync api --- .../flw/controller/SammelanController.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 964535dc..8e85be86 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -29,7 +29,9 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Objects; @RestController @@ -43,13 +45,14 @@ public class SammelanController { @RequestMapping(value = "saveAll",method = RequestMethod.POST,consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity create( + public ResponseEntity create( @RequestPart("date") String date, @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { + Map response = new LinkedHashMap<>(); SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); sammelanRequestDTO.setPlace(place); @@ -61,7 +64,23 @@ public ResponseEntity create( String json = mapper.writeValueAsString(sammelanRequestDTO); logger.info("📥 Incoming HBYC Request: \n" + json+"date"+date); SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO,images); - return ResponseEntity.status(HttpStatus.CREATED).body(resp); + + try { + if (resp != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Data saved successfully"); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + + } catch (Exception e) { + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + } + return ResponseEntity.ok(response); + + } From f75c4b82c2b4acf3391b6412b45ad89ac45811a7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 16:47:03 +0530 Subject: [PATCH 416/792] hbync api --- .../java/com/iemr/flw/controller/SammelanController.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 8e85be86..91955955 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.SammelanService; import com.iemr.flw.utils.DateUtil; @@ -84,18 +85,18 @@ public ResponseEntity create( } - @GetMapping("/getAll") + @PostMapping("/getAll") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully fetched meetings", content = @Content(mediaType = "application/json", schema = @Schema(implementation = SammelanListResponseDTO.class))), @ApiResponse(responseCode = "500", description = "Internal Server Error") }) - public ResponseEntity getMeetings(@RequestParam Integer ashaId) { + public ResponseEntity getMeetings(@RequestBody GetBenRequestHandler getBenRequestHandler) { SammelanListResponseDTO response = new SammelanListResponseDTO(); try { - response.setData(service.getSammelanHistory(ashaId)); + response.setData(service.getSammelanHistory(getBenRequestHandler.getAshaId())); response.setStatusCode(200); response.setStatus("Success"); return ResponseEntity.ok(response); From 8abc91c3a3801453f7c36d15048953b2b461c2e0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 17:44:18 +0530 Subject: [PATCH 417/792] hbync api --- .../flw/controller/SammelanController.java | 5 ++- .../iemr/flw/dto/iemr/SammelanRequestDTO.java | 4 +- .../com/iemr/flw/service/SammelanService.java | 2 +- .../flw/service/impl/SammelanServiceImpl.java | 44 +++++++++---------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 91955955..b6b8ba62 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -52,7 +52,7 @@ public ResponseEntity create( @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, - @RequestPart(value = "SammelanImages", required = false) MultipartFile[] images) throws JsonProcessingException { + @RequestPart(value = "SammelanImages", required = false) List sammelanImages) throws JsonProcessingException { Map response = new LinkedHashMap<>(); SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); @@ -60,11 +60,12 @@ public ResponseEntity create( sammelanRequestDTO.setParticipants(Integer.valueOf(participants)); sammelanRequestDTO.setDate(Long.parseLong(date)); sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); + sammelanRequestDTO.setSammelanImages(sammelanImages != null ? sammelanImages.toArray(new MultipartFile[0]) : null); ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(sammelanRequestDTO); logger.info("📥 Incoming HBYC Request: \n" + json+"date"+date); - SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO,images); + SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO); try { if (resp != null) { diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index 74970df4..dc0869ea 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -12,6 +12,8 @@ public class SammelanRequestDTO { private Integer ashaId; // ASHA worker ID private Long date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center - private Integer participants; // Number of participants attended + private Integer participants; + private MultipartFile[] sammelanImages; // up to 5 images +// Number of participants attended } diff --git a/src/main/java/com/iemr/flw/service/SammelanService.java b/src/main/java/com/iemr/flw/service/SammelanService.java index fbe4ae37..ed2e9cb7 100644 --- a/src/main/java/com/iemr/flw/service/SammelanService.java +++ b/src/main/java/com/iemr/flw/service/SammelanService.java @@ -13,7 +13,7 @@ public interface SammelanService { * @param dto request data * @return saved SammelanResponseDTO with incentive details */ - public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, MultipartFile[] images); + public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO); /** * Fetch Sammelan history for given ASHA worker diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 5c1eb883..e13d4043 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -15,10 +15,12 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.sql.Timestamp; import java.time.LocalDate; import java.time.YearMonth; import java.time.ZoneId; +import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @@ -39,12 +41,11 @@ public class SammelanServiceImpl implements SammelanService { @Override - public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO, MultipartFile[] images) { + public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO) { SammelanResponseDTO response = new SammelanResponseDTO(); try { - // Save Sammelan record record = new SammelanRecord(); record.setAshaId(sammelanRequestDTO.getAshaId()); @@ -54,30 +55,25 @@ record = new SammelanRecord(); record.setParticipants(sammelanRequestDTO.getParticipants()); record = recordRepo.save(record); - // Save Attachments - if (images != null && images.length > 0) { - List base64Images = List.of(images) - .stream() - .filter(file -> !file.isEmpty()) - .map(file -> { - try { - return Base64.getEncoder().encodeToString(file.getBytes()); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .collect(Collectors.toList()); - - String imagesJson = null; - try { - imagesJson = objectMapper.writeValueAsString(base64Images); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); + + if (sammelanRequestDTO.getSammelanImages() != null && sammelanRequestDTO.getSammelanImages().length > 0) { + List base64Images = Arrays.stream(sammelanRequestDTO.getSammelanImages()) + .filter(file -> !file.isEmpty()) + .map(file -> { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (IOException e) { + throw new RuntimeException("Error converting image to Base64", e); + } + }) + .collect(Collectors.toList()); + + String imagesJson = objectMapper.writeValueAsString(base64Images); + record .setAttachments(imagesJson); } - record.setAttachments(imagesJson); - } - // Prepare Response DTO + + // Prepare Response DTO response.setId(record.getId()); response.setAshaId(record.getAshaId()); response.setDate(record.getMeetingDate()); From 5877777c7453088fb5075dbedfad49a105c2a831 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 17:49:17 +0530 Subject: [PATCH 418/792] hbync api --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index e13d4043..e834e2b8 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -53,7 +53,6 @@ record = new SammelanRecord(); record.setMeetingDate(sammelanRequestDTO.getDate()); record.setPlace(sammelanRequestDTO.getPlace()); record.setParticipants(sammelanRequestDTO.getParticipants()); - record = recordRepo.save(record); if (sammelanRequestDTO.getSammelanImages() != null && sammelanRequestDTO.getSammelanImages().length > 0) { @@ -72,7 +71,10 @@ record = recordRepo.save(record); record .setAttachments(imagesJson); } + if(record!=null){ + record = recordRepo.save(record); + } // Prepare Response DTO response.setId(record.getId()); response.setAshaId(record.getAshaId()); From 53bde7f8468dfcc3200566ddd03345659279c9a8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 17:54:11 +0530 Subject: [PATCH 419/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index b6b8ba62..025e0368 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -62,7 +62,7 @@ public ResponseEntity create( sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); sammelanRequestDTO.setSammelanImages(sammelanImages != null ? sammelanImages.toArray(new MultipartFile[0]) : null); ObjectMapper mapper = new ObjectMapper(); - + logger.info("Image: "+sammelanImages.size()); String json = mapper.writeValueAsString(sammelanRequestDTO); logger.info("📥 Incoming HBYC Request: \n" + json+"date"+date); SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO); From f5bd3f1ff5f950b7fd8efbe1f75289dab4ffd672 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 17:58:39 +0530 Subject: [PATCH 420/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 025e0368..ba178667 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -52,7 +52,7 @@ public ResponseEntity create( @RequestPart("place") String place, @RequestPart("participants") String participants, @RequestPart("ashaId") String ashaId, - @RequestPart(value = "SammelanImages", required = false) List sammelanImages) throws JsonProcessingException { + @RequestPart(value = "sammelanImages", required = false) List sammelanImages) throws JsonProcessingException { Map response = new LinkedHashMap<>(); SammelanRequestDTO sammelanRequestDTO = new SammelanRequestDTO(); From 8141b024cde2b0add75a75a49888c0ddc13fca39 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 14 Oct 2025 18:07:45 +0530 Subject: [PATCH 421/792] hbync api --- src/main/java/com/iemr/flw/controller/SammelanController.java | 1 - src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index ba178667..881d150b 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -62,7 +62,6 @@ public ResponseEntity create( sammelanRequestDTO.setAshaId(Integer.valueOf(ashaId)); sammelanRequestDTO.setSammelanImages(sammelanImages != null ? sammelanImages.toArray(new MultipartFile[0]) : null); ObjectMapper mapper = new ObjectMapper(); - logger.info("Image: "+sammelanImages.size()); String json = mapper.writeValueAsString(sammelanRequestDTO); logger.info("📥 Incoming HBYC Request: \n" + json+"date"+date); SammelanResponseDTO resp = service.submitSammelan(sammelanRequestDTO); diff --git a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java index dc0869ea..a39b84d7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SammelanRequestDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import org.springframework.web.multipart.MultipartFile; @@ -13,6 +14,8 @@ public class SammelanRequestDTO { private Long date; // Meeting date private String place; // Dropdown: HWC / Anganwadi Centre / Community Center private Integer participants; + + @JsonIgnore private MultipartFile[] sammelanImages; // up to 5 images // Number of participants attended From 36b62cf9d1c2bad544416ce8aed6d6c9f97ccfc4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 15 Oct 2025 11:02:04 +0530 Subject: [PATCH 422/792] hbync api --- .../iemr/flw/controller/CoupleController.java | 24 ++++++++++++ .../com/iemr/flw/service/CoupleService.java | 3 ++ .../flw/service/impl/CoupleServiceImpl.java | 38 +++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/CoupleController.java b/src/main/java/com/iemr/flw/controller/CoupleController.java index d0cc807b..4a14da4e 100644 --- a/src/main/java/com/iemr/flw/controller/CoupleController.java +++ b/src/main/java/com/iemr/flw/controller/CoupleController.java @@ -57,6 +57,30 @@ public String saveEligibleCouple(@RequestPart("data") List el return response.toString(); } + + + @Operation(summary = "save eligible couple registration details") + @RequestMapping(value = { "/register/saveAll" }, method = { RequestMethod.POST }) + public String saveEligibleCouple(@RequestBody List eligibleCoupleDTOs, + @RequestHeader(value = "Authorization") String Authorization) { + OutputResponse response = new OutputResponse(); + try { + logger.info("Saving All Eligible Couple Details"); + if (eligibleCoupleDTOs != null) { + String s = coupleService.registerEligibleCouple(eligibleCoupleDTOs); + if (s != null) + response.setResponse(s); + else + response.setError(5000, "No record found"); + } else + response.setError(5000, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in saving eligible couple registration details, " + e); + response.setError(5000, "Error in saving eligible couple registration details" + e); + } + return response.toString(); + } + @Operation(summary = "save eligible couple tracking details") @RequestMapping(value = { "/tracking/saveAll" }, method = { RequestMethod.POST }) public String saveEligibleCoupleTracking(@RequestBody List eligibleCoupleTrackingDTOs, diff --git a/src/main/java/com/iemr/flw/service/CoupleService.java b/src/main/java/com/iemr/flw/service/CoupleService.java index ab690396..0dd27341 100644 --- a/src/main/java/com/iemr/flw/service/CoupleService.java +++ b/src/main/java/com/iemr/flw/service/CoupleService.java @@ -17,4 +17,7 @@ public interface CoupleService { List getEligibleCoupleTracking(GetBenRequestHandler requestDto); String registerEligibleCouple(List eligibleCoupleDTOs, MultipartFile kitPhoto1, MultipartFile kitPhoto2); + + String registerEligibleCouple(List eligibleCoupleDTOs); + } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index a4a81c91..004b532b 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -119,6 +119,44 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, return "error while saving ecr details: " + e.getMessage(); } } + @Override + public String registerEligibleCouple(List eligibleCoupleDTOs) { + try { + List ecrList = new ArrayList<>(); + List recordList = new ArrayList<>(); + eligibleCoupleDTOs.forEach(it -> { + EligibleCoupleRegister existingECR = +// eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenIdAndCreatedDate(it.getBenId(), it.getCreatedDate()); + eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); + + if (existingECR != null && null != existingECR.getNumLiveChildren()) { + if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { + IncentiveActivity activity1 = + incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", "FAMILY PLANNING"); + createIncentiveRecord(recordList, it, activity1); + } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 2) { + IncentiveActivity activity2 = + incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", "FAMILY PLANNING"); + createIncentiveRecord(recordList, it, activity2); + } + Long id = existingECR.getId(); + modelMapper.map(it, existingECR); + existingECR.setId(id); + } else { + existingECR = new EligibleCoupleRegister(); + modelMapper.map(it, existingECR); + existingECR.setId(null); + } + ecrList.add(existingECR); + }); + eligibleCoupleRegisterRepo.saveAll(ecrList); + recordRepo.saveAll(recordList); + return "no of ecr details saved: " + ecrList.size(); + } catch (Exception e) { + return "error while saving ecr details: " + e.getMessage(); + } + } + private void createIncentiveRecord(List recordList, EligibleCoupleDTO eligibleCoupleDTO, IncentiveActivity activity) { if (activity != null) { From cc2ba56e9061b47a5068e7b688e3c02308316097 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 15 Oct 2025 14:03:38 +0530 Subject: [PATCH 423/792] hbync api --- src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java index ad2d9564..0ec1c876 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EligibleCoupleDTO.java @@ -1,5 +1,7 @@ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; +import jakarta.persistence.Lob; import lombok.Data; import org.springframework.web.multipart.MultipartFile; @@ -114,6 +116,10 @@ public class EligibleCoupleDTO implements Serializable { private String kitHandedOverDate; + private String kitPhoto1; + + private String kitPhoto2; + } From a83ed4c1832189d276750228d4300a1f496f2949 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 11:33:14 +0530 Subject: [PATCH 424/792] hbync api --- .../flw/repo/iemr/IncentiveRecordRepo.java | 13 ++++++++++--- .../flw/service/impl/IncentiveServiceImpl.java | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 989e6e24..4c5eaf84 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -13,9 +13,16 @@ @Repository public interface IncentiveRecordRepo extends JpaRepository { - @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") - IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); - + @Query("SELECT record FROM IncentiveActivityRecord record " + + "WHERE record.activityId = :id " + + "AND record.createdDate BETWEEN :startDate AND :endDate " + + "AND record.benId = :benId") + IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( + @Param("id") Long id, + @Param("startDate") Timestamp startDate, + @Param("endDate") Timestamp endDate, + @Param("benId") Long benId + ); @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index fdc43308..dcdfd440 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -27,6 +27,7 @@ import java.sql.Timestamp; import java.time.Instant; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -189,9 +190,22 @@ private void checkMonthlyAshaIncentive(){ } private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ - Timestamp timestamp = Timestamp.valueOf(LocalDate.now().atStartOfDay()); + Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); + + LocalDate now = LocalDate.now(); + LocalDate firstDay = now.withDayOfMonth(1); + LocalDate lastDay = now.withDayOfMonth(now.lengthOfMonth()); + + Timestamp startOfMonth = Timestamp.valueOf(firstDay.atStartOfDay()); + Timestamp endOfMonth = Timestamp.valueOf(lastDay.atTime(23, 59, 59)); + IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), timestamp, 0L); + .findRecordByActivityIdCreatedDateBenId( + incentiveActivity.getId(), + startOfMonth, + endOfMonth, + 0L + ); if (record == null) { record = new IncentiveActivityRecord(); From 97e3f7c55d2e263c9a507cf4946d3f30410649c1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 11:36:43 +0530 Subject: [PATCH 425/792] hbync api --- .../flw/repo/iemr/IncentiveRecordRepo.java | 1 + .../service/impl/IncentiveServiceImpl.java | 24 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 4c5eaf84..e36d5397 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -23,6 +23,7 @@ IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( @Param("endDate") Timestamp endDate, @Param("benId") Long benId ); + @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index dcdfd440..9500929f 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -192,20 +192,16 @@ private void checkMonthlyAshaIncentive(){ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); - LocalDate now = LocalDate.now(); - LocalDate firstDay = now.withDayOfMonth(1); - LocalDate lastDay = now.withDayOfMonth(now.lengthOfMonth()); - - Timestamp startOfMonth = Timestamp.valueOf(firstDay.atStartOfDay()); - Timestamp endOfMonth = Timestamp.valueOf(lastDay.atTime(23, 59, 59)); - - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId( - incentiveActivity.getId(), - startOfMonth, - endOfMonth, - 0L - ); + Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); + Timestamp endOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()).atTime(23, 59, 59)); + + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId( + incentiveActivity.getId(), + startOfMonth, + endOfMonth, + 0L + ); + if (record == null) { record = new IncentiveActivityRecord(); From 175225d02f65bd9d448993944674fb6c0f8313c1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 11:39:57 +0530 Subject: [PATCH 426/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index e36d5397..62b756fe 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -13,6 +13,9 @@ @Repository public interface IncentiveRecordRepo extends JpaRepository { + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") + IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); + @Query("SELECT record FROM IncentiveActivityRecord record " + "WHERE record.activityId = :id " + "AND record.createdDate BETWEEN :startDate AND :endDate " + @@ -23,7 +26,6 @@ IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( @Param("endDate") Timestamp endDate, @Param("benId") Long benId ); - @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); From 41bbb3075ca3e616e5594bcc5c1e2e39cb097d18 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 12:32:57 +0530 Subject: [PATCH 427/792] hbync api --- .../flw/service/impl/MaternalHealthServiceImpl.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 7c4bde4d..eb06217a 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -391,7 +391,7 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity ancFullActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity abortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); @@ -475,16 +475,17 @@ record = new IncentiveActivityRecord(); }); } - if (abortionActivity != null) { + if (comprehensiveAbortionActivity != null) { ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(abortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - + logger.info("record:"+record.getName()); + logger.info("condition:"+ancVisit.getIsAborted()); if (Objects.equals(ancVisit.getIsAborted(), "true")) { if (record == null) { record = new IncentiveActivityRecord(); - record.setActivityId(abortionActivity.getId()); + record.setActivityId(comprehensiveAbortionActivity.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); @@ -493,7 +494,7 @@ record = new IncentiveActivityRecord(); record.setEndDate(ancVisit.getCreatedDate()); record.setBenId(ancVisit.getBenId()); record.setAshaId(userId); - record.setAmount(Long.valueOf(abortionActivity.getRate())); + record.setAmount(Long.valueOf(comprehensiveAbortionActivity.getRate())); recordRepo.save(record); } From 2551c0f611b2f4012a3cc1af1466dbb1c4cddddf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 12:49:43 +0530 Subject: [PATCH 428/792] hbync api --- .../com/iemr/flw/service/impl/DeathReportsServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index 01e6b2f6..3af4a68c 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -136,17 +136,17 @@ public List getMdsrRecords(GetBenRequestHandler dto) { private void checkAndAddIncentives(List cdrList) { cdrList.forEach( cdr -> { - Long benId = beneficiaryRepo.getBenIdFromRegID(cdr.getBenId()).longValue(); Integer userId = userRepo.getUserIdByName(cdr.getCreatedBy()); IncentiveActivity immunizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecord(cdr,benId,userId,immunizationActivity); + createIncentiveRecord(cdr,cdr.getBenId(),userId,immunizationActivity); }); } private void checkAndAddIncentivesMdsr(List mdsrList) { + mdsrList.forEach( mdsr -> { Long benId = beneficiaryRepo.getBenIdFromRegID(mdsr.getBenId()).longValue(); Integer userId = userRepo.getUserIdByName(mdsr.getCreatedBy()); From 2a78cb5b4dff76c55bc0d73608d8827ad0f312ab Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 22 Oct 2025 17:55:47 +0530 Subject: [PATCH 429/792] hbync api --- .../com/iemr/flw/domain/iemr/InfantRegister.java | 15 +++++++++++++++ .../com/iemr/flw/dto/iemr/InfantRegisterDTO.java | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/InfantRegister.java b/src/main/java/com/iemr/flw/domain/iemr/InfantRegister.java index 7d6ae835..7a22516f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/InfantRegister.java +++ b/src/main/java/com/iemr/flw/domain/iemr/InfantRegister.java @@ -85,4 +85,19 @@ public class InfantRegister { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "delivery_discharge_summary1") + private String deliveryDischargeSummary1; + + @Column(name = "delivery_discharge_summary2") + private String deliveryDischargeSummary2; + + @Column(name = "delivery_discharge_summary3") + private String deliveryDischargeSummary3; + + @Column(name = "delivery_discharge_summary4") + private String deliveryDischargeSummary4; + + @Column(name = "is_sncu") + private String isSNCU; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/InfantRegisterDTO.java b/src/main/java/com/iemr/flw/dto/iemr/InfantRegisterDTO.java index 1e59b95d..0be067ff 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/InfantRegisterDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/InfantRegisterDTO.java @@ -32,4 +32,9 @@ public class InfantRegisterDTO { private String createdBy; private Timestamp updatedDate; private String updatedBy; + private String deliveryDischargeSummary1; + private String deliveryDischargeSummary2; + private String deliveryDischargeSummary3; + private String deliveryDischargeSummary4; + private String isSNCU; } From a66f75482da2ab579d520b0a00c76894c7df8814 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 13:30:24 +0530 Subject: [PATCH 430/792] hbync api --- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index eb06217a..27e3a3b4 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -480,10 +480,12 @@ record = new IncentiveActivityRecord(); ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - logger.info("record:"+record.getName()); - logger.info("condition:"+ancVisit.getIsAborted()); + if (Objects.equals(ancVisit.getIsAborted(), "true")) { + if (record == null) { + logger.info("record:"+record.getName()); + logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); record.setActivityId(comprehensiveAbortionActivity.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); From 0ec4c9795eddfd415ba8487b2d290db2beaf7702 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 14:24:17 +0530 Subject: [PATCH 431/792] hbync api --- .../flw/controller/SammelanController.java | 6 +- .../com/iemr/flw/domain/iemr/SamVisit.java | 57 +++++++++++++++++++ .../flw/domain/iemr/SamVisitResponseDTO.java | 53 +++++++++++++++++ .../java/com/iemr/flw/dto/iemr/SamDTO.java | 52 +++++++++++++++++ .../flw/repo/iemr/SamVisitRepository.java | 20 +++++++ 5 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/SamVisit.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SamDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java diff --git a/src/main/java/com/iemr/flw/controller/SammelanController.java b/src/main/java/com/iemr/flw/controller/SammelanController.java index 881d150b..e5c85227 100644 --- a/src/main/java/com/iemr/flw/controller/SammelanController.java +++ b/src/main/java/com/iemr/flw/controller/SammelanController.java @@ -97,12 +97,12 @@ public ResponseEntity getMeetings(@RequestBody GetBenRequestHandler getBenReq try { response.setData(service.getSammelanHistory(getBenRequestHandler.getAshaId())); - response.setStatusCode(200); + response.setStatusCode(HttpStatus.OK.value()); response.setStatus("Success"); return ResponseEntity.ok(response); } catch (Exception e) { - response.setStatusCode(500); - response.setStatus("Something went wrong"); + response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()+"\n"+e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java new file mode 100644 index 00000000..b347d2be --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java @@ -0,0 +1,57 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import java.time.LocalDate; + +@Entity +@Data +@Table(name = "t_sam_visit", schema = "db_iemr") +public class SamVisit { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "beneficiary_id") + private Long beneficiaryId; + + @Column(name = "visit_date") + private LocalDate visitDate; + + @Column(name = "visit_label") + private String visitLabel; + + @Column(name = "muac") + private Double muac; + + @Column(name = "weight_for_height_status") + private String weightForHeightStatus; + + @Column(name = "is_child_referred_nrc") + private String isChildReferredNrc; + + @Column(name = "is_child_admitted_nrc") + private String isChildAdmittedNrc; + + @Column(name = "nrc_admission_date") + private LocalDate nrcAdmissionDate; + + @Column(name = "is_child_discharged_nrc") + private String isChildDischargedNrc; + + @Column(name = "nrc_discharge_date") + private LocalDate nrcDischargeDate; + + @Column(name = "follow_up_visit_date") + private LocalDate followUpVisitDate; + + @Column(name = "sam_status") + private String samStatus; + + @Column(name = "discharge_summary") + private String dischargeSummary; + + @Column(name = "view_discharge_docs") + private String viewDischargeDocs; +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java new file mode 100644 index 00000000..533c37b9 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -0,0 +1,53 @@ +package com.iemr.flw.domain.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class SamVisitResponseDTO { + + @SerializedName("beneficiary_id") + private Long beneficiaryId; + + @SerializedName("visit_date") + private LocalDate visitDate; + + @SerializedName("visit_label") + private String visitLabel; + + @SerializedName("muac") + private Double muac; + + @SerializedName("weight_for_height_status") + private String weightForHeightStatus; + + @SerializedName("is_child_referred_nrc") + private String isChildReferredNrc; + + @SerializedName("is_child_admitted_nrc") + private String isChildAdmittedNrc; + + @SerializedName("nrc_admission_date") + private LocalDate nrcAdmissionDate; + + @SerializedName("is_child_discharged_nrc") + private String isChildDischargedNrc; + + @SerializedName("nrc_discharge_date") + private LocalDate nrcDischargeDate; + + @SerializedName("follow_up_visit_date") + private LocalDate followUpVisitDate; + + @SerializedName("sam_status") + private String samStatus; + + @SerializedName("discharge_summary") + private String dischargeSummary; + + @SerializedName("view_discharge_docs") + private List viewDischargeDocs; // Base64 array or JSON array +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java new file mode 100644 index 00000000..a0e84ed0 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java @@ -0,0 +1,52 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import jakarta.mail.Multipart; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.time.LocalDate; +@Data +public class SamDTO { + @SerializedName("beneficiary_id") + private Long beneficiaryId; + + @SerializedName("visit_date") + private LocalDate visitDate; + + @SerializedName("visit_label") + private String visitLabel; + + @SerializedName("muac") + private Double muac; + + @SerializedName("weight_for_height_status") + private String weightForHeightStatus; + + @SerializedName("is_child_referred_nrc") + private String isChildReferredNrc; + + @SerializedName("is_child_admitted_nrc") + private String isChildAdmittedNrc; + + @SerializedName("nrc_admission_date") + private LocalDate nrcAdmissionDate; + + @SerializedName("is_child_discharged_nrc") + private String isChildDischargedNrc; + + @SerializedName("nrc_discharge_date") + private LocalDate nrcDischargeDate; + + @SerializedName("follow_up_visit_date") + private LocalDate followUpVisitDate; + + @SerializedName("sam_status") + private String samStatus; + + @SerializedName("discharge_summary") + private String dischargeSummary; + + @SerializedName("view_discharge_docs") + private MultipartFile viewDischargeDocs; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java new file mode 100644 index 00000000..cab43359 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java @@ -0,0 +1,20 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.SamVisit; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface SamVisitRepository extends JpaRepository { + + // Find all visits for a particular beneficiary + List findByBeneficiaryId(Long beneficiaryId); + + // Optional: Get latest visit record for a beneficiary + SamVisit findTopByBeneficiaryIdOrderByVisitDateDesc(Long beneficiaryId); + + // Optional: Check if a visit exists for a given date + boolean existsByBeneficiaryIdAndVisitDate(Long beneficiaryId, java.time.LocalDate visitDate); +} From 96d4f2a757713739e2016d326cf314a8dc131bea Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 15:39:47 +0530 Subject: [PATCH 432/792] hbync api --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 9500929f..c3f6da84 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -85,7 +85,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { - List incs = incentivesRepo.findAll(); + List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); List dtos = incs.stream().map(inc -> { IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); From 1730db4091a6e4ca679cce255d9be0dd58db545f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 16:09:08 +0530 Subject: [PATCH 433/792] hbync api --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index c3f6da84..8f45c7e5 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -148,6 +148,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { public String getAllIncentivesByUserId(GetBenRequestHandler request) { List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); + entities = entities.stream().filter(entitie-> incentivesRepo.isExist(entitie.getActivityId())).collect(Collectors.toList()); entities.forEach(entry -> { if(entry.getName()==null){ if(entry.getBenId()!=0){ From 2d87e8634311b3c1b998a6d7dc9bb395e57dc7b4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 16:12:34 +0530 Subject: [PATCH 434/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 3 +++ .../com/iemr/flw/service/impl/DeathReportsServiceImpl.java | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index a335f320..8f91d9b7 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -17,6 +17,9 @@ public interface IncentivesRepo extends JpaRepository { @Query("select inc from IncentiveActivity inc where inc.name = :name and inc.group = :group and inc.isDeleted = false") IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); + @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END FROM IncentiveActivity a WHERE a.id = :activityId") + Boolean isExist(@Param("activityId") Long activityId); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); } diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index 3af4a68c..6e3dde2e 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -184,14 +184,11 @@ record = new IncentiveActivityRecord(); private void createIncentiveRecord(MDSR mdsr, Long benId, Integer userId, IncentiveActivity immunizationActivity) { IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), mdsr.getCreatedDate(), benId); - RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(benId)); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName()+" "+rmnchBeneficiaryDetailsRmnch.getLastName(); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); record.setCreatedDate(mdsr.getCreatedDate()); record.setCreatedBy(mdsr.getCreatedBy()); - record.setName(beneName); record.setStartDate(mdsr.getCreatedDate()); record.setEndDate(mdsr.getCreatedDate()); record.setUpdatedDate(mdsr.getCreatedDate()); From d92f62bd24f2096049dd3cb327c7d043b1f1d9e3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 16:19:51 +0530 Subject: [PATCH 435/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index 8f91d9b7..742115c9 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -17,7 +17,10 @@ public interface IncentivesRepo extends JpaRepository { @Query("select inc from IncentiveActivity inc where inc.name = :name and inc.group = :group and inc.isDeleted = false") IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); - @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END FROM IncentiveActivity a WHERE a.id = :activityId") + @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END " + + "FROM IncentiveActivity a " + + "WHERE a.id = :activityId AND a.group <> 'ACTIVITY'") + Boolean isExist(@Param("activityId") Integer activityId); Boolean isExist(@Param("activityId") Long activityId); @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") From 6ee38c4e0d7b918f69b916d78e5e24165ab05328 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 16:24:50 +0530 Subject: [PATCH 436/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index 742115c9..b54413ea 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -20,7 +20,6 @@ public interface IncentivesRepo extends JpaRepository { @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END " + "FROM IncentiveActivity a " + "WHERE a.id = :activityId AND a.group <> 'ACTIVITY'") - Boolean isExist(@Param("activityId") Integer activityId); Boolean isExist(@Param("activityId") Long activityId); @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") From aa7fd981e941ef64c707b0cb6c989f2fe8b5e568 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 23 Oct 2025 16:32:55 +0530 Subject: [PATCH 437/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 2 +- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index b54413ea..5f574835 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -20,7 +20,7 @@ public interface IncentivesRepo extends JpaRepository { @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END " + "FROM IncentiveActivity a " + "WHERE a.id = :activityId AND a.group <> 'ACTIVITY'") - Boolean isExist(@Param("activityId") Long activityId); + IncentiveActivity findIncentiveMasterById(@Param("id") Long activityId); @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 8f45c7e5..295e6a2e 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -148,7 +148,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { public String getAllIncentivesByUserId(GetBenRequestHandler request) { List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); - entities = entities.stream().filter(entitie-> incentivesRepo.isExist(entitie.getActivityId())).collect(Collectors.toList()); + entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId())!=null).collect(Collectors.toList()); entities.forEach(entry -> { if(entry.getName()==null){ if(entry.getBenId()!=0){ From 6bf2195585be17e708520f7c561ec88f60528967 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 10:25:34 +0530 Subject: [PATCH 438/792] hbync api --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index 5f574835..2ac337d3 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -17,10 +17,9 @@ public interface IncentivesRepo extends JpaRepository { @Query("select inc from IncentiveActivity inc where inc.name = :name and inc.group = :group and inc.isDeleted = false") IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); - @Query("SELECT CASE WHEN COUNT(a) > 0 THEN true ELSE false END " + - "FROM IncentiveActivity a " + + @Query("SELECT a FROM IncentiveActivity a " + "WHERE a.id = :activityId AND a.group <> 'ACTIVITY'") - IncentiveActivity findIncentiveMasterById(@Param("id") Long activityId); + IncentiveActivity findIncentiveMasterById(@Param("activityId") Long activityId); @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); From 84977ae03984b769a8e3b6a8d1c5f2cd3228c216 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 10:50:07 +0530 Subject: [PATCH 439/792] hbync api --- .../flw/controller/ChildCareController.java | 52 +++++++ .../iemr/flw/service/ChildCareService.java | 6 +- .../service/impl/ChildCareServiceImpl.java | 132 +++++++++++++++--- .../service/impl/DeathReportsServiceImpl.java | 3 - 4 files changed, 172 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 81fa422b..c27dccf5 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -5,6 +5,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iemr.flw.domain.iemr.HbncVisit; +import com.iemr.flw.domain.iemr.SamVisitResponseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.ChildCareService; @@ -12,6 +13,7 @@ import io.swagger.v3.oas.annotations.Operation; +import jakarta.mail.Multipart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +23,7 @@ import java.sql.Timestamp; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -223,4 +226,53 @@ public String getChildVaccinationDetails(@RequestParam(value = "category") Strin } return response.toString(); } + @RequestMapping(value = {"/sam/saveAll"},method = RequestMethod.POST) + public ResponseEntity saveSevereAcuteMalnutrition(@RequestPart("data") List samRequest){ + Map response = new LinkedHashMap<>(); + + try { + if(samRequest!=null){ + String responseObject = childCareService.saveSamDetails(samRequest); + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Data saved successfully"); + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); + } + + + @RequestMapping(value = {"/sam/getAll"},method = RequestMethod.GET) + public ResponseEntity getAllSevereAcuteMalnutrition(){ + Map response = new LinkedHashMap<>(); + + try { + List responseObject = childCareService.getSamVisitsByBeneficiary(); + + if(responseObject!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("data",responseObject); + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index 0ae7a0a7..b8ef7048 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -1,6 +1,6 @@ package com.iemr.flw.service; -import com.iemr.flw.domain.iemr.HbncVisit; +import com.iemr.flw.domain.iemr.SamVisitResponseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; @@ -21,4 +21,8 @@ public interface ChildCareService { String saveChildVaccinationDetails(List childVaccinationDTOs); List getAllChildVaccines(String category); + + String saveSamDetails(List samRequest); + + List getSamVisitsByBeneficiary(); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f951d1ef..2402dee5 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -1,5 +1,6 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; @@ -13,12 +14,16 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import java.io.File; +import java.io.IOException; import java.math.BigInteger; import java.sql.Timestamp; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.stream.Collectors; @Service public class ChildCareServiceImpl implements ChildCareService { @@ -47,6 +52,9 @@ public class ChildCareServiceImpl implements ChildCareService { @Autowired private ChildVaccinationRepo childVaccinationRepo; + @Autowired + private SamVisitRepository samVisitRepository; + @Autowired private VaccineRepo vaccineRepo; @@ -54,6 +62,8 @@ public class ChildCareServiceImpl implements ChildCareService { ModelMapper modelMapper = new ModelMapper(); + + @Override public String registerHBYC(List hbycDTOs) { try { @@ -171,7 +181,6 @@ public List getHbycRecords(GetBenRequestHandler dto) { addIfValid(fields, "mcp_card_images", hbycChildVisit.getMcp_card_images()); - // Set fields map in DTO hbycRequestDTO.setFields(fields); result.add(hbycRequestDTO); @@ -249,11 +258,11 @@ private String convert(Boolean value) { } private Boolean convertBollen(String value) { - if(value.equals("Yes")){ - return true; - }else { - return false; - } + if (value.equals("Yes")) { + return true; + } else { + return false; + } } private String convert(Object value) { @@ -412,6 +421,94 @@ public List getAllChildVaccines(String category) { return null; } + @Override + public String saveSamDetails(List samRequest) { + for (SamDTO dto : samRequest) { + SamVisit entity = new SamVisit(); + + entity.setBeneficiaryId(dto.getBeneficiaryId()); + entity.setVisitDate(dto.getVisitDate()); + entity.setVisitLabel(dto.getVisitLabel()); + entity.setMuac(dto.getMuac()); + entity.setWeightForHeightStatus(dto.getWeightForHeightStatus()); + entity.setIsChildReferredNrc(dto.getIsChildReferredNrc()); + entity.setIsChildAdmittedNrc(dto.getIsChildAdmittedNrc()); + entity.setNrcAdmissionDate(dto.getNrcAdmissionDate()); + entity.setIsChildDischargedNrc(dto.getIsChildDischargedNrc()); + entity.setNrcDischargeDate(dto.getNrcDischargeDate()); + entity.setFollowUpVisitDate(dto.getFollowUpVisitDate()); + entity.setSamStatus(dto.getSamStatus()); + entity.setDischargeSummary(dto.getDischargeSummary()); + + // Handle MultipartFile → Base64 JSON + MultipartFile file = dto.getViewDischargeDocs(); + if (file != null && !file.isEmpty()) { + try { + List base64List = Arrays.asList(file).stream() + .filter(f -> !f.isEmpty()) + .map(f -> { + try { + return Base64.getEncoder().encodeToString(f.getBytes()); + } catch (IOException e) { + throw new RuntimeException("Error converting file to Base64", e); + } + }) + .collect(Collectors.toList()); + + String jsonBase64 = mapper.writeValueAsString(base64List); + entity.setViewDischargeDocs(jsonBase64); + + } catch (Exception e) { + e.printStackTrace(); + return "Failed to process file: " + file.getOriginalFilename(); + } + } + + samVisitRepository.save(entity); + } + + return "Saved " + samRequest.size() + " SAM visit records successfully"; + + + } + + @Override + public List getSamVisitsByBeneficiary() { + + List entities = samVisitRepository.findAll(); + + return entities.stream().map(entity -> { + SamVisitResponseDTO dto = new SamVisitResponseDTO(); + dto.setBeneficiaryId(entity.getBeneficiaryId()); + dto.setVisitDate(entity.getVisitDate()); + dto.setVisitLabel(entity.getVisitLabel()); + dto.setMuac(entity.getMuac()); + dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); + dto.setIsChildReferredNrc(entity.getIsChildReferredNrc()); + dto.setIsChildAdmittedNrc(entity.getIsChildAdmittedNrc()); + dto.setNrcAdmissionDate(entity.getNrcAdmissionDate()); + dto.setIsChildDischargedNrc(entity.getIsChildDischargedNrc()); + dto.setNrcDischargeDate(entity.getNrcDischargeDate()); + dto.setFollowUpVisitDate(entity.getFollowUpVisitDate()); + dto.setSamStatus(entity.getSamStatus()); + dto.setDischargeSummary(entity.getDischargeSummary()); + + // Convert Base64 JSON string to List + try { + if (entity.getViewDischargeDocs() != null) { + List base64List = mapper.readValue( + entity.getViewDischargeDocs(), new TypeReference>() {}); + dto.setViewDischargeDocs(base64List); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return dto; + }).collect(Collectors.toList()); + } + + private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = @@ -456,31 +553,31 @@ private void checkAndAddHbncIncentives(List hbncVisits) { .stream() .allMatch(hbncVisits::contains); - GroupName.setIsCh(false); + GroupName.setIsCh(false); Long benId = hbncVisit.getBeneficiaryId(); if (hbncVisit.getVisit_day().equals("42nd Day")) { IncentiveActivity visitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); - IncentiveActivity visitActivityCH= incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.ACTIVITY.getDisplayName()); + IncentiveActivity visitActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.ACTIVITY.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityAM,"HBNC_0_42_DAYS"); - createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityCH,"HBNC_0_42_DAYS_CH"); + createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityAM, "HBNC_0_42_DAYS"); + createIncentiveRecordforHbncVisit(hbncVisit, benId, visitActivityCH, "HBNC_0_42_DAYS_CH"); } - logger.info("getDischarged_from_sncu"+hbncVisit.getDischarged_from_sncu()); + logger.info("getDischarged_from_sncu" + hbncVisit.getDischarged_from_sncu()); - if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight()<2.5) { + if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight() < 2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity,"SNCU_LBW_FOLLOWUP"); + createIncentiveRecordforHbncVisit(hbncVisit, benId, babyDisChargeSNCUAActivity, "SNCU_LBW_FOLLOWUP"); } - logger.info("getIs_baby_alive"+hbncVisit.getIs_baby_alive()); + logger.info("getIs_baby_alive" + hbncVisit.getIs_baby_alive()); if (!hbncVisit.getIs_baby_alive()) { IncentiveActivity isChildDeathActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity,"CHILD_DEATH_REPORTING"); + createIncentiveRecordforHbncVisit(hbncVisit, benId, isChildDeathActivity, "CHILD_DEATH_REPORTING"); } @@ -559,8 +656,8 @@ record = new IncentiveActivityRecord(); } } - private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity,String activityName) { - logger.info("RecordIncentive"+activityName); + private void createIncentiveRecordforHbncVisit(HbncVisit hbncVisit, Long benId, IncentiveActivity immunizationActivity, String activityName) { + logger.info("RecordIncentive" + activityName); IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), hbncVisit.getCreatedDate(), benId); @@ -654,4 +751,5 @@ private Integer getImmunizationServiceIdForVaccine(Short vaccineId) { public void getTomorrowImmunizationReminders(Integer userID) { } + } diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index 6e3dde2e..dab80e26 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -162,14 +162,11 @@ private void checkAndAddIncentivesMdsr(List mdsrList) { private void createIncentiveRecord(CDR cdr, Long benId, Integer userId, IncentiveActivity immunizationActivity) { IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), cdr.getCreatedDate(), benId); - RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(benId)); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName()+" "+rmnchBeneficiaryDetailsRmnch.getLastName(); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); record.setCreatedDate(cdr.getCreatedDate()); record.setCreatedBy(cdr.getCreatedBy()); - record.setName(beneName); record.setStartDate(cdr.getCreatedDate()); record.setEndDate(cdr.getCreatedDate()); record.setUpdatedDate(cdr.getCreatedDate()); From fcf73e7cace1b7c293e2c12ac5fd2eab1eadb0eb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 11:44:32 +0530 Subject: [PATCH 440/792] hbync api --- .../flw/controller/ChildCareController.java | 2 +- .../java/com/iemr/flw/dto/iemr/SamDTO.java | 2 +- .../service/impl/ChildCareServiceImpl.java | 50 ++++++++++--------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index c27dccf5..de0cc7d4 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -227,7 +227,7 @@ public String getChildVaccinationDetails(@RequestParam(value = "category") Strin return response.toString(); } @RequestMapping(value = {"/sam/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveSevereAcuteMalnutrition(@RequestPart("data") List samRequest){ + public ResponseEntity saveSevereAcuteMalnutrition( List samRequest){ Map response = new LinkedHashMap<>(); try { diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java index a0e84ed0..5c95c92c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java @@ -48,5 +48,5 @@ public class SamDTO { private String dischargeSummary; @SerializedName("view_discharge_docs") - private MultipartFile viewDischargeDocs; + private String viewDischargeDocs; } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2402dee5..f13c8e16 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -439,30 +439,32 @@ public String saveSamDetails(List samRequest) { entity.setFollowUpVisitDate(dto.getFollowUpVisitDate()); entity.setSamStatus(dto.getSamStatus()); entity.setDischargeSummary(dto.getDischargeSummary()); - - // Handle MultipartFile → Base64 JSON - MultipartFile file = dto.getViewDischargeDocs(); - if (file != null && !file.isEmpty()) { - try { - List base64List = Arrays.asList(file).stream() - .filter(f -> !f.isEmpty()) - .map(f -> { - try { - return Base64.getEncoder().encodeToString(f.getBytes()); - } catch (IOException e) { - throw new RuntimeException("Error converting file to Base64", e); - } - }) - .collect(Collectors.toList()); - - String jsonBase64 = mapper.writeValueAsString(base64List); - entity.setViewDischargeDocs(jsonBase64); - - } catch (Exception e) { - e.printStackTrace(); - return "Failed to process file: " + file.getOriginalFilename(); - } - } + entity.setViewDischargeDocs(dto.getViewDischargeDocs()); + + +// // Handle MultipartFile → Base64 JSON +// MultipartFile file = dto.getViewDischargeDocs(); +// if (file != null && !file.isEmpty()) { +// try { +// List base64List = Arrays.asList(file).stream() +// .filter(f -> !f.isEmpty()) +// .map(f -> { +// try { +// return Base64.getEncoder().encodeToString(f.getBytes()); +// } catch (IOException e) { +// throw new RuntimeException("Error converting file to Base64", e); +// } +// }) +// .collect(Collectors.toList()); +// +// String jsonBase64 = mapper.writeValueAsString(base64List); +// entity.setViewDischargeDocs(jsonBase64); +// +// } catch (Exception e) { +// e.printStackTrace(); +// return "Failed to process file: " + file.getOriginalFilename(); +// } +// } samVisitRepository.save(entity); } From 920658be834171e6d77848319db9bf5a9c34457c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 11:58:41 +0530 Subject: [PATCH 441/792] hbync api --- src/main/java/com/iemr/flw/controller/ChildCareController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index de0cc7d4..e7e4ef2c 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -227,7 +227,7 @@ public String getChildVaccinationDetails(@RequestParam(value = "category") Strin return response.toString(); } @RequestMapping(value = {"/sam/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveSevereAcuteMalnutrition( List samRequest){ + public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List samRequest){ Map response = new LinkedHashMap<>(); try { From 07b75542f9be732cc217bef8671a42550b4feda7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 12:21:31 +0530 Subject: [PATCH 442/792] hbync api --- .../flw/controller/ChildCareController.java | 6 +-- .../com/iemr/flw/domain/iemr/SamVisit.java | 15 ++++++ .../java/com/iemr/flw/dto/iemr/SamDTO.java | 45 ++--------------- .../com/iemr/flw/dto/iemr/SamListDTO.java | 47 ++++++++++++++++++ .../flw/repo/iemr/SamVisitRepository.java | 2 + .../iemr/flw/service/ChildCareService.java | 2 +- .../service/impl/ChildCareServiceImpl.java | 48 +++++++++---------- 7 files changed, 95 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index e7e4ef2c..928cd229 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -251,12 +251,12 @@ public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List } - @RequestMapping(value = {"/sam/getAll"},method = RequestMethod.GET) - public ResponseEntity getAllSevereAcuteMalnutrition(){ + @RequestMapping(value = {"/sam/getAll"},method = RequestMethod.POST) + public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenRequestHandler request){ Map response = new LinkedHashMap<>(); try { - List responseObject = childCareService.getSamVisitsByBeneficiary(); + List responseObject = childCareService.getSamVisitsByBeneficiary(request); if(responseObject!=null){ if(responseObject!=null){ diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java index b347d2be..b11a58e6 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java @@ -13,9 +13,15 @@ public class SamVisit { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "user_id") + private Integer userId; + @Column(name = "beneficiary_id") private Long beneficiaryId; + @Column(name = "household_id") + private Long householdId; + @Column(name = "visit_date") private LocalDate visitDate; @@ -54,4 +60,13 @@ public class SamVisit { @Column(name = "view_discharge_docs") private String viewDischargeDocs; + + @Column(name = "created_by") + private String createdBy; + + @Column(name = "created_date") + private LocalDate createdDate = LocalDate.now(); + + @Column(name = "update_date") + private LocalDate updateDate = LocalDate.now(); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java index 5c95c92c..028cc74f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java @@ -8,45 +8,10 @@ import java.time.LocalDate; @Data public class SamDTO { - @SerializedName("beneficiary_id") + private Long id; private Long beneficiaryId; - - @SerializedName("visit_date") - private LocalDate visitDate; - - @SerializedName("visit_label") - private String visitLabel; - - @SerializedName("muac") - private Double muac; - - @SerializedName("weight_for_height_status") - private String weightForHeightStatus; - - @SerializedName("is_child_referred_nrc") - private String isChildReferredNrc; - - @SerializedName("is_child_admitted_nrc") - private String isChildAdmittedNrc; - - @SerializedName("nrc_admission_date") - private LocalDate nrcAdmissionDate; - - @SerializedName("is_child_discharged_nrc") - private String isChildDischargedNrc; - - @SerializedName("nrc_discharge_date") - private LocalDate nrcDischargeDate; - - @SerializedName("follow_up_visit_date") - private LocalDate followUpVisitDate; - - @SerializedName("sam_status") - private String samStatus; - - @SerializedName("discharge_summary") - private String dischargeSummary; - - @SerializedName("view_discharge_docs") - private String viewDischargeDocs; + private Long houseHoldId; + private String visitDate; + private String userName; + private SamListDTO samListDTO; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java new file mode 100644 index 00000000..1f41d8c4 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java @@ -0,0 +1,47 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class SamListDTO { + + + @SerializedName("visit_label") + private String visitLabel; + + @SerializedName("muac") + private Double muac; + + @SerializedName("weight_for_height_status") + private String weightForHeightStatus; + + @SerializedName("is_child_referred_nrc") + private String isChildReferredNrc; + + @SerializedName("is_child_admitted_nrc") + private String isChildAdmittedNrc; + + @SerializedName("nrc_admission_date") + private LocalDate nrcAdmissionDate; + + @SerializedName("is_child_discharged_nrc") + private String isChildDischargedNrc; + + @SerializedName("nrc_discharge_date") + private LocalDate nrcDischargeDate; + + @SerializedName("follow_up_visit_date") + private LocalDate followUpVisitDate; + + @SerializedName("sam_status") + private String samStatus; + + @SerializedName("discharge_summary") + private String dischargeSummary; + + @SerializedName("view_discharge_docs") + private String viewDischargeDocs; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java index cab43359..a6a654fd 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java @@ -17,4 +17,6 @@ public interface SamVisitRepository extends JpaRepository { // Optional: Check if a visit exists for a given date boolean existsByBeneficiaryIdAndVisitDate(Long beneficiaryId, java.time.LocalDate visitDate); + + List findByUserId(Integer ashaId); } diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index b8ef7048..0b1e7fba 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -24,5 +24,5 @@ public interface ChildCareService { String saveSamDetails(List samRequest); - List getSamVisitsByBeneficiary(); + List getSamVisitsByBeneficiary(GetBenRequestHandler dto); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f13c8e16..a8587246 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -423,26 +423,26 @@ public List getAllChildVaccines(String category) { @Override public String saveSamDetails(List samRequest) { - for (SamDTO dto : samRequest) { - SamVisit entity = new SamVisit(); - - entity.setBeneficiaryId(dto.getBeneficiaryId()); - entity.setVisitDate(dto.getVisitDate()); - entity.setVisitLabel(dto.getVisitLabel()); - entity.setMuac(dto.getMuac()); - entity.setWeightForHeightStatus(dto.getWeightForHeightStatus()); - entity.setIsChildReferredNrc(dto.getIsChildReferredNrc()); - entity.setIsChildAdmittedNrc(dto.getIsChildAdmittedNrc()); - entity.setNrcAdmissionDate(dto.getNrcAdmissionDate()); - entity.setIsChildDischargedNrc(dto.getIsChildDischargedNrc()); - entity.setNrcDischargeDate(dto.getNrcDischargeDate()); - entity.setFollowUpVisitDate(dto.getFollowUpVisitDate()); - entity.setSamStatus(dto.getSamStatus()); - entity.setDischargeSummary(dto.getDischargeSummary()); - entity.setViewDischargeDocs(dto.getViewDischargeDocs()); - - -// // Handle MultipartFile → Base64 JSON + List vaccinationList = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + samRequest.forEach(samDTO -> { + SamVisit samVisits = new SamVisit(); + modelMapper.map(samVisits,samDTO); + samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); + samVisits.setHouseholdId(samDTO.getHouseHoldId()); + samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); + samVisits.setUserId(userRepo.getUserIdByName(samDTO.getUserName())); + samVisits.setCreatedBy(samDTO.getUserName()); + vaccinationList.add(samVisits); + }); + + samVisitRepository.saveAll(vaccinationList); + + + return "Saved " + samRequest.size() + " SAM visit records successfully"; + + // Handle MultipartFile → Base64 JSON // MultipartFile file = dto.getViewDischargeDocs(); // if (file != null && !file.isEmpty()) { // try { @@ -466,18 +466,14 @@ public String saveSamDetails(List samRequest) { // } // } - samVisitRepository.save(entity); - } - - return "Saved " + samRequest.size() + " SAM visit records successfully"; } @Override - public List getSamVisitsByBeneficiary() { + public List getSamVisitsByBeneficiary(GetBenRequestHandler request) { - List entities = samVisitRepository.findAll(); + List entities = samVisitRepository.findByUserId(request.getAshaId()); return entities.stream().map(entity -> { SamVisitResponseDTO dto = new SamVisitResponseDTO(); From 005f998c155dd90c1af8bc27b9eb304ed6d0c188 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 12:25:14 +0530 Subject: [PATCH 443/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/SamVisit.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java index b11a58e6..23e33f16 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java @@ -3,6 +3,7 @@ import jakarta.persistence.*; import lombok.Data; import java.time.LocalDate; +import java.time.LocalDateTime; @Entity @Data @@ -65,8 +66,8 @@ public class SamVisit { private String createdBy; @Column(name = "created_date") - private LocalDate createdDate = LocalDate.now(); + private LocalDateTime createdDate = LocalDateTime.now(); @Column(name = "update_date") - private LocalDate updateDate = LocalDate.now(); + private LocalDateTime updateDate = LocalDateTime.now(); } From c52c19c9106424c9ec6151f0a014686079c7106a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 12:46:24 +0530 Subject: [PATCH 444/792] hbync api --- .../flw/controller/ChildCareController.java | 9 ++++- .../service/impl/ChildCareServiceImpl.java | 34 +++++++++++-------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 928cd229..1e7b7ccd 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -236,18 +236,25 @@ public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List if(responseObject!=null){ response.put("statusCode", HttpStatus.OK.value()); response.put("message", "Data saved successfully"); + return ResponseEntity.ok().body(response); + } }else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); + } }catch (Exception e){ response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); + } - return ResponseEntity.ok(response); + return null; + } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index a8587246..318f87fe 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -423,24 +423,30 @@ public List getAllChildVaccines(String category) { @Override public String saveSamDetails(List samRequest) { - List vaccinationList = new ArrayList<>(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + try { + List vaccinationList = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - samRequest.forEach(samDTO -> { - SamVisit samVisits = new SamVisit(); - modelMapper.map(samVisits,samDTO); - samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); - samVisits.setHouseholdId(samDTO.getHouseHoldId()); - samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); - samVisits.setUserId(userRepo.getUserIdByName(samDTO.getUserName())); - samVisits.setCreatedBy(samDTO.getUserName()); - vaccinationList.add(samVisits); - }); + samRequest.forEach(samDTO -> { + SamVisit samVisits = new SamVisit(); + modelMapper.map(samVisits,samDTO); + samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); + samVisits.setHouseholdId(samDTO.getHouseHoldId()); + samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); + samVisits.setUserId(userRepo.getUserIdByName(samDTO.getUserName())); + samVisits.setCreatedBy(samDTO.getUserName()); + vaccinationList.add(samVisits); + }); + + samVisitRepository.saveAll(vaccinationList); - samVisitRepository.saveAll(vaccinationList); + return "Saved " + samRequest.size() + " SAM visit records successfully"; + }catch (Exception e){ + logger.error(e.getMessage()); + } - return "Saved " + samRequest.size() + " SAM visit records successfully"; + return "Fail"; // Handle MultipartFile → Base64 JSON // MultipartFile file = dto.getViewDischargeDocs(); From 26e4381f68e4f9407b00056cc6e88e251837dbdf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 12:51:27 +0530 Subject: [PATCH 445/792] hbync api --- src/main/java/com/iemr/flw/domain/iemr/SamVisit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java index 23e33f16..2dd7a55e 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java @@ -68,6 +68,6 @@ public class SamVisit { @Column(name = "created_date") private LocalDateTime createdDate = LocalDateTime.now(); - @Column(name = "update_date") - private LocalDateTime updateDate = LocalDateTime.now(); + @Column(name = "updated_date") + private LocalDateTime updatedDate = LocalDateTime.now(); } From 7c7128115df6141f670b5da1d0fb8fd32d3a1522 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 13:51:36 +0530 Subject: [PATCH 446/792] hbync api --- .../java/com/iemr/flw/controller/ChildCareController.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 1e7b7ccd..73cf6c3c 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -230,19 +230,21 @@ public String getChildVaccinationDetails(@RequestParam(value = "category") Strin public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List samRequest){ Map response = new LinkedHashMap<>(); + logger.info("sam request :"+samRequest); try { + String responseObject = childCareService.saveSamDetails(samRequest); + if(samRequest!=null){ - String responseObject = childCareService.saveSamDetails(samRequest); if(responseObject!=null){ response.put("statusCode", HttpStatus.OK.value()); - response.put("message", "Data saved successfully"); + response.put("message", responseObject); return ResponseEntity.ok().body(response); } }else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + response.put("message", responseObject); return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); } From c3eadf0153e74344070599baee8d30ca1800ec11 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 14:58:14 +0530 Subject: [PATCH 447/792] hbync api --- .../service/impl/ChildCareServiceImpl.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 318f87fe..c669c283 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -624,18 +624,17 @@ private void checkAndAddIncentives(List vaccinationList) { .equals(childVaccinationRepo.getSecondYearVaccineCount())) { createIncentiveRecord(vaccination, benId, userId, immunizationActivity2CH); } - } else if (immunizationServiceId == 8) { - IncentiveActivity immunizationActivity5AM = - incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.IMMUNIZATION.getDisplayName()); - if (immunizationActivity5AM != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { - createIncentiveRecord(vaccination, benId, userId, immunizationActivity5AM); - } + } + IncentiveActivity immunizationActivity5AM = + incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.IMMUNIZATION.getDisplayName()); + if (immunizationActivity5AM != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivity5AM); + } - IncentiveActivity immunizationActivity5CH = - incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.ACTIVITY.getDisplayName()); - if (immunizationActivity5CH != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { - createIncentiveRecord(vaccination, benId, userId, immunizationActivity5CH); - } + IncentiveActivity immunizationActivity5CH = + incentivesRepo.findIncentiveMasterByNameAndGroup("DPT_IMMUNIZATION_5_YEARS", GroupName.ACTIVITY.getDisplayName()); + if (immunizationActivity5CH != null && childVaccinationRepo.checkDptVaccinatedUser(vaccination.getBeneficiaryRegId()) == 1) { + createIncentiveRecord(vaccination, benId, userId, immunizationActivity5CH); } }); } From e83d73ab9b1bb39ea2c5f0c4ba6d8b238a89c2f5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 16:59:45 +0530 Subject: [PATCH 448/792] hbync api --- src/main/java/com/iemr/flw/dto/iemr/SamDTO.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java index 028cc74f..fd2305a7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SamDTO.java @@ -13,5 +13,5 @@ public class SamDTO { private Long houseHoldId; private String visitDate; private String userName; - private SamListDTO samListDTO; + private SamListDTO fields; } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index c669c283..53114e58 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -429,7 +429,7 @@ public String saveSamDetails(List samRequest) { samRequest.forEach(samDTO -> { SamVisit samVisits = new SamVisit(); - modelMapper.map(samVisits,samDTO); + modelMapper.map(samVisits,samDTO.getFields()); samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisits.setHouseholdId(samDTO.getHouseHoldId()); samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); From 964be5a325d84d75d2adda74450fd4efbe32a698 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 17:06:43 +0530 Subject: [PATCH 449/792] hbync api --- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 53114e58..36d7d127 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -9,6 +9,7 @@ import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.ChildCareService; +import com.iemr.flw.utils.JwtUtil; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -62,6 +63,9 @@ public class ChildCareServiceImpl implements ChildCareService { ModelMapper modelMapper = new ModelMapper(); + @Autowired + private JwtUtil jwtUtil; + @Override @@ -433,8 +437,8 @@ public String saveSamDetails(List samRequest) { samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisits.setHouseholdId(samDTO.getHouseHoldId()); samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); - samVisits.setUserId(userRepo.getUserIdByName(samDTO.getUserName())); - samVisits.setCreatedBy(samDTO.getUserName()); + samVisits.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + samVisits.setCreatedBy(jwtUtil.getUserNameFromStorage()); vaccinationList.add(samVisits); }); From 2bfc7b2832715f0fb8cb9113b89deccb682fd5f5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 18:20:58 +0530 Subject: [PATCH 450/792] hbync api --- .../flw/controller/ChildCareController.java | 2 +- .../com/iemr/flw/domain/iemr/SamVisit.java | 8 ++-- .../flw/domain/iemr/SamVisitResponseDTO.java | 38 ++++++++-------- .../com/iemr/flw/dto/iemr/SAMResponseDTO.java | 16 +++++++ .../com/iemr/flw/dto/iemr/SamListDTO.java | 24 +++++----- .../iemr/flw/service/ChildCareService.java | 2 +- .../service/impl/ChildCareServiceImpl.java | 44 ++++++++++++------- 7 files changed, 82 insertions(+), 52 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/SAMResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 73cf6c3c..0ea4c309 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -265,7 +265,7 @@ public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenReque Map response = new LinkedHashMap<>(); try { - List responseObject = childCareService.getSamVisitsByBeneficiary(request); + List responseObject = childCareService.getSamVisitsByBeneficiary(request); if(responseObject!=null){ if(responseObject!=null){ diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java index 2dd7a55e..56822609 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisit.java @@ -30,7 +30,7 @@ public class SamVisit { private String visitLabel; @Column(name = "muac") - private Double muac; + private String muac; @Column(name = "weight_for_height_status") private String weightForHeightStatus; @@ -42,16 +42,16 @@ public class SamVisit { private String isChildAdmittedNrc; @Column(name = "nrc_admission_date") - private LocalDate nrcAdmissionDate; + private String nrcAdmissionDate; @Column(name = "is_child_discharged_nrc") private String isChildDischargedNrc; @Column(name = "nrc_discharge_date") - private LocalDate nrcDischargeDate; + private String nrcDischargeDate; @Column(name = "follow_up_visit_date") - private LocalDate followUpVisitDate; + private String followUpVisitDate; @Column(name = "sam_status") private String samStatus; diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java index 533c37b9..3055bc35 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -1,6 +1,6 @@ package com.iemr.flw.domain.iemr; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import java.time.LocalDate; @@ -9,45 +9,45 @@ @Data public class SamVisitResponseDTO { - @SerializedName("beneficiary_id") + @JsonProperty("beneficiary_id") private Long beneficiaryId; - @SerializedName("visit_date") + @JsonProperty("visit_date") private LocalDate visitDate; - @SerializedName("visit_label") + @JsonProperty("visit_label") private String visitLabel; - @SerializedName("muac") - private Double muac; + @JsonProperty("muac") + private String muac; - @SerializedName("weight_for_height_status") + @JsonProperty("weight_for_height_status") private String weightForHeightStatus; - @SerializedName("is_child_referred_nrc") + @JsonProperty("is_child_referred_nrc") private String isChildReferredNrc; - @SerializedName("is_child_admitted_nrc") + @JsonProperty("is_child_admitted_nrc") private String isChildAdmittedNrc; - @SerializedName("nrc_admission_date") - private LocalDate nrcAdmissionDate; + @JsonProperty("nrc_admission_date") + private String nrcAdmissionDate; - @SerializedName("is_child_discharged_nrc") + @JsonProperty("is_child_discharged_nrc") private String isChildDischargedNrc; - @SerializedName("nrc_discharge_date") - private LocalDate nrcDischargeDate; + @JsonProperty("nrc_discharge_date") + private String nrcDischargeDate; - @SerializedName("follow_up_visit_date") - private LocalDate followUpVisitDate; + @JsonProperty("follow_up_visit_date") + private String followUpVisitDate; - @SerializedName("sam_status") + @JsonProperty("sam_status") private String samStatus; - @SerializedName("discharge_summary") + @JsonProperty("discharge_summary") private String dischargeSummary; - @SerializedName("view_discharge_docs") + @JsonProperty("view_discharge_docs") private List viewDischargeDocs; // Base64 array or JSON array } diff --git a/src/main/java/com/iemr/flw/dto/iemr/SAMResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SAMResponseDTO.java new file mode 100644 index 00000000..99e0d68a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/SAMResponseDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.SamVisitResponseDTO; +import lombok.Data; + +import java.util.Map; + +@Data +public class SAMResponseDTO { + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private SamVisitResponseDTO fields; // for dynamic form fields +} + diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java index 1f41d8c4..17e3ec56 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java @@ -10,38 +10,38 @@ public class SamListDTO { @SerializedName("visit_label") - private String visitLabel; + private String visit_label; @SerializedName("muac") - private Double muac; + private String muac; @SerializedName("weight_for_height_status") - private String weightForHeightStatus; + private String weight_for_height_status; @SerializedName("is_child_referred_nrc") - private String isChildReferredNrc; + private String is_child_referred_nrc; @SerializedName("is_child_admitted_nrc") - private String isChildAdmittedNrc; + private String is_child_admitted_nrc; @SerializedName("nrc_admission_date") - private LocalDate nrcAdmissionDate; + private String nrc_admission_date; @SerializedName("is_child_discharged_nrc") - private String isChildDischargedNrc; + private String is_child_discharged_nrc; @SerializedName("nrc_discharge_date") - private LocalDate nrcDischargeDate; + private String nrc_discharge_date; @SerializedName("follow_up_visit_date") - private LocalDate followUpVisitDate; + private String follow_up_visit_date; @SerializedName("sam_status") - private String samStatus; + private String sam_status; @SerializedName("discharge_summary") - private String dischargeSummary; + private String discharge_summary; @SerializedName("view_discharge_docs") - private String viewDischargeDocs; + private String view_discharge_docs; } diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index 0b1e7fba..966250fa 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -24,5 +24,5 @@ public interface ChildCareService { String saveSamDetails(List samRequest); - List getSamVisitsByBeneficiary(GetBenRequestHandler dto); + List getSamVisitsByBeneficiary(GetBenRequestHandler dto); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 36d7d127..18dab063 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -432,13 +432,24 @@ public String saveSamDetails(List samRequest) { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); samRequest.forEach(samDTO -> { + logger.info(samDTO.getFields().getMuac()); SamVisit samVisits = new SamVisit(); - modelMapper.map(samVisits,samDTO.getFields()); samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisits.setHouseholdId(samDTO.getHouseHoldId()); samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); samVisits.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); samVisits.setCreatedBy(jwtUtil.getUserNameFromStorage()); + samVisits.setMuac(samDTO.getFields().getMuac()); + samVisits.setSamStatus(samDTO.getFields().getSam_status()); + samVisits.setVisitLabel(samDTO.getFields().getVisit_label()); + samVisits.setWeightForHeightStatus(samDTO.getFields().getWeight_for_height_status()); + samVisits.setIsChildReferredNrc(samDTO.getFields().getIs_child_referred_nrc()); + samVisits.setNrcAdmissionDate(samDTO.getFields().getNrc_admission_date()); + samVisits.setIsChildDischargedNrc(samDTO.getFields().getIs_child_discharged_nrc()); + samVisits.setNrcDischargeDate(samDTO.getFields().getNrc_discharge_date()); + samVisits.setFollowUpVisitDate(samDTO.getFields().getFollow_up_visit_date()); + samVisits.setDischargeSummary(samDTO.getFields().getDischarge_summary()); + samVisits.setViewDischargeDocs(samDTO.getFields().getView_discharge_docs()); vaccinationList.add(samVisits); }); @@ -481,11 +492,19 @@ public String saveSamDetails(List samRequest) { } @Override - public List getSamVisitsByBeneficiary(GetBenRequestHandler request) { + public List getSamVisitsByBeneficiary(GetBenRequestHandler request) { List entities = samVisitRepository.findByUserId(request.getAshaId()); + List samResponseListDTO = new ArrayList<>(); + + for (SamVisit entity : entities) { + SAMResponseDTO samResponseDTO = new SAMResponseDTO(); + + samResponseDTO.setBeneficiaryId(entity.getBeneficiaryId()); + samResponseDTO.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); + samResponseDTO.setHouseHoldId(entity.getHouseholdId()); + samResponseDTO.setId(entity.getId()); - return entities.stream().map(entity -> { SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); dto.setVisitDate(entity.getVisitDate()); @@ -501,22 +520,17 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler dto.setSamStatus(entity.getSamStatus()); dto.setDischargeSummary(entity.getDischargeSummary()); - // Convert Base64 JSON string to List - try { - if (entity.getViewDischargeDocs() != null) { - List base64List = mapper.readValue( - entity.getViewDischargeDocs(), new TypeReference>() {}); - dto.setViewDischargeDocs(base64List); - } - } catch (Exception e) { - e.printStackTrace(); - } + samResponseDTO.setFields(dto); - return dto; - }).collect(Collectors.toList()); + samResponseListDTO.add(samResponseDTO); + } + + return samResponseListDTO; } + + private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = From 444262e0327b00982ce4c1014c54ec2e13d964ed Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 19:00:42 +0530 Subject: [PATCH 451/792] hbync api --- .../com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index d540aa91..8447e631 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -72,6 +72,9 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { @Autowired IncentiveRecordRepo recordRepo; + + @Value("${fhir-url}") + private String fhirUrl; @Override public String getBenData(GetBenRequestHandler request, String authorisation) throws Exception { String outputResponse = null; @@ -467,7 +470,7 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map header = new HashMap(); header.put("Authorization", authorization); - String responseStr = utils.post(ConfigProperties.getPropertyByName("fhir-url") + "/" + String responseStr = utils.post(fhirUrl + "/" + ConfigProperties.getPropertyByName("getHealthID"), new Gson().toJson(requestMap), header); JsonElement jsnElmnt = jsnParser.parse(responseStr); JsonObject jsnOBJ = new JsonObject(); From 0de140c2a8027badc514d6b9dacf4ff03813cc5d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 24 Oct 2025 19:04:27 +0530 Subject: [PATCH 452/792] hbync api --- .../com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 8447e631..2ed01f42 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -73,8 +73,7 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { @Autowired IncentiveRecordRepo recordRepo; - @Value("${fhir-url}") - private String fhirUrl; + @Override public String getBenData(GetBenRequestHandler request, String authorisation) throws Exception { String outputResponse = null; @@ -470,7 +469,7 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map header = new HashMap(); header.put("Authorization", authorization); - String responseStr = utils.post(fhirUrl + "/" + String responseStr = utils.post(ConfigProperties.getPropertyByName("fhir-url") + "/" + ConfigProperties.getPropertyByName("getHealthID"), new Gson().toJson(requestMap), header); JsonElement jsnElmnt = jsnParser.parse(responseStr); JsonObject jsnOBJ = new JsonObject(); From 331c1b7195f8043d7cd0adf2441da65996fa84c1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 27 Oct 2025 15:18:45 +0530 Subject: [PATCH 453/792] ors distribution api --- .../flw/controller/ChildCareController.java | 59 +++++++++++++++++++ .../iemr/flw/domain/iemr/OrsDistribution.java | 47 +++++++++++++++ .../iemr/flw/dto/iemr/OrsDistributionDTO.java | 13 ++++ .../flw/dto/iemr/OrsDistributionListDTO.java | 23 ++++++++ .../dto/iemr/OrsDistributionResponseDTO.java | 13 ++++ .../iemr/OrsDistributionResponseListDTO.java | 24 ++++++++ .../flw/repo/iemr/OrsDistributionRepo.java | 14 +++++ .../iemr/flw/service/ChildCareService.java | 4 ++ .../service/impl/ChildCareServiceImpl.java | 57 ++++++++++++++++++ 9 files changed, 254 insertions(+) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsDistributionDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/OrsDistributionRepo.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 0ea4c309..44280789 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -284,4 +284,63 @@ public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenReque } return ResponseEntity.ok(response); } + + @RequestMapping(value = {"/ors/distribution/saveAll"},method = RequestMethod.POST) + public ResponseEntity saveOrsDistribution(@RequestBody List orsDistributionDTOS){ + Map response = new LinkedHashMap<>(); + + logger.info("sam request :"+orsDistributionDTOS); + try { + String responseObject = childCareService.saveOrsDistributionDetails(orsDistributionDTOS); + + if(orsDistributionDTOS!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", responseObject); + return ResponseEntity.ok().body(response); + + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", responseObject); + return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); + + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); + + + } + return null; + + } + + + @RequestMapping(value = {"/or/distribution/getAll"},method = RequestMethod.POST) + public ResponseEntity getAllOrDistribution(@RequestBody GetBenRequestHandler request){ + Map response = new LinkedHashMap<>(); + + try { + List responseObject = childCareService.getOrdDistrubtion(request); + + if(responseObject!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("data",responseObject); + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java new file mode 100644 index 00000000..bb622e1d --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java @@ -0,0 +1,47 @@ +package com.iemr.flw.domain.iemr; + +import io.swagger.v3.oas.annotations.tags.Tags; +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; + +@Table(name = "t_ors_distribution",schema = "db_iemr") +@Data +public class OrsDistribution { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "household_id") + private Long householdId; + + @Column(name = "beneficiary_id") + private Long beneficiaryId; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "visit_date") + private LocalDate visitDate; + + @Column(name = "child_count") + private Integer childCount; + + @Column(name = "num_ors_packets") + private Integer numOrsPackets; + + @Column(name = "ifa_provision_date") + private LocalDate ifaProvisionDate; + + // Image stored as path or file name + @Column(name = "mcp_card_upload") + private String mcpCardUpload; + + @Column(name = "created_at", updatable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") + private java.sql.Timestamp createdAt; + + @Column(name = "updated_at", insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP") + private java.sql.Timestamp updatedAt; + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionDTO.java new file mode 100644 index 00000000..7bdfd4fd --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OrsDistributionDTO { + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private String userName; + private OrsDistributionListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java new file mode 100644 index 00000000..9889708e --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java @@ -0,0 +1,23 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class OrsDistributionListDTO { + + + @SerializedName("num_under5_children") + private String num_under5_children; + + @SerializedName("num_ors_packets") + private String num_ors_packets; + + @SerializedName("ifa_provision_date") + private String ifa_provision_date; + + @SerializedName("mcp_card_upload") + private String mcp_card_upload; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseDTO.java new file mode 100644 index 00000000..051db762 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OrsDistributionResponseDTO { + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private String userName; + private OrsDistributionResponseListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java new file mode 100644 index 00000000..393106f9 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java @@ -0,0 +1,24 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class OrsDistributionResponseListDTO { + + + @JsonProperty("num_under5_children") + private String num_under5_children; + + @JsonProperty("num_ors_packets") + private String num_ors_packets; + + @JsonProperty("ifa_provision_date") + private String ifa_provision_date; + + @JsonProperty("mcp_card_upload") + private String mcp_card_upload; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/OrsDistributionRepo.java b/src/main/java/com/iemr/flw/repo/iemr/OrsDistributionRepo.java new file mode 100644 index 00000000..3d291e7d --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/OrsDistributionRepo.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.OrsDistribution; +import com.iemr.flw.domain.iemr.SamVisit; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface OrsDistributionRepo extends JpaRepository { + + List findByUserId(Integer ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index 966250fa..72530fee 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -25,4 +25,8 @@ public interface ChildCareService { String saveSamDetails(List samRequest); List getSamVisitsByBeneficiary(GetBenRequestHandler dto); + + String saveOrsDistributionDetails(List orsDistributionDTOS); + + List getOrdDistrubtion(GetBenRequestHandler request); } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 18dab063..ab51dfb8 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -66,6 +66,9 @@ public class ChildCareServiceImpl implements ChildCareService { @Autowired private JwtUtil jwtUtil; + @Autowired + private OrsDistributionRepo orsDistributionRepo; + @Override @@ -528,8 +531,62 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque return samResponseListDTO; } + @Override + public String saveOrsDistributionDetails(List orsDistributionDTOS) { + try { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + List orsDistributionList = new ArrayList<>(); + orsDistributionDTOS.forEach(orsDistributionDTO -> { + OrsDistribution orsDistribution = new OrsDistribution(); + orsDistribution.setBeneficiaryId(orsDistributionDTO.getBeneficiaryId()); + orsDistribution.setNumOrsPackets(Integer.parseInt(orsDistributionDTO.getFields().getNum_ors_packets())); + orsDistribution.setChildCount(Integer.parseInt(orsDistributionDTO.getFields().getNum_under5_children())); + orsDistribution.setMcpCardUpload(orsDistributionDTO.getFields().getMcp_card_upload()); + orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); + orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + orsDistribution.setVisitDate(LocalDate.parse(orsDistributionDTO.getVisitDate(),formatter)); + orsDistribution.setIfaProvisionDate(LocalDate.parse(orsDistributionDTO.getFields().getIfa_provision_date(),formatter)); + orsDistributionList.add(orsDistribution); + + }); + if(!orsDistributionList.isEmpty()){ + orsDistributionRepo.saveAll(orsDistributionList); + return "Saved " + orsDistributionList.size() + " ORS visit records successfully"; + + } + }catch (Exception e){ + logger.error(e.getMessage()); + + } + + return "Fail"; + } + + @Override + public List getOrdDistrubtion(GetBenRequestHandler request) { + List entities = orsDistributionRepo.findByUserId(request.getAshaId()); + List orsDistributionResponseDTOSList = new ArrayList<>(); + + for(OrsDistribution orsDistribution: entities){ + OrsDistributionResponseDTO orsDistributionResponseDTO = new OrsDistributionResponseDTO(); + orsDistributionResponseDTO.setId(orsDistribution.getId()); + orsDistributionResponseDTO.setBeneficiaryId(orsDistribution.getBeneficiaryId()); + orsDistributionResponseDTO.setHouseHoldId(orsDistribution.getHouseholdId()); + OrsDistributionResponseListDTO orsDistributionResponseListDTO = new OrsDistributionResponseListDTO(); + orsDistributionResponseListDTO.setNum_ors_packets(orsDistribution.getNumOrsPackets().toString()); + orsDistributionResponseListDTO.setMcp_card_upload(orsDistribution.getMcpCardUpload()); + orsDistributionResponseListDTO.setIfa_provision_date(orsDistribution.getIfaProvisionDate().toString()); + orsDistributionResponseListDTO.setNum_under5_children(orsDistribution.getChildCount().toString()); + orsDistributionResponseDTO.setFields(orsDistributionResponseListDTO); + + orsDistributionResponseDTOSList.add(orsDistributionResponseDTO); + + } + return orsDistributionResponseDTOSList; + + } private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { From ddc995fd9422278300046873ad389db01d44fe37 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 27 Oct 2025 16:06:40 +0530 Subject: [PATCH 454/792] ors distribution api --- src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java index bb622e1d..bf91e1bd 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java +++ b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java @@ -7,6 +7,7 @@ import java.time.LocalDate; @Table(name = "t_ors_distribution",schema = "db_iemr") +@Entity @Data public class OrsDistribution { @Id From 2728a2ac32f159345bd5d351374d57e57a14ad57 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 27 Oct 2025 16:26:42 +0530 Subject: [PATCH 455/792] ors distribution api --- .../java/com/iemr/flw/controller/ChildCareController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 44280789..fa5e2dc3 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -285,7 +285,7 @@ public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenReque return ResponseEntity.ok(response); } - @RequestMapping(value = {"/ors/distribution/saveAll"},method = RequestMethod.POST) + @RequestMapping(value = {"/ors/saveAll"},method = RequestMethod.POST) public ResponseEntity saveOrsDistribution(@RequestBody List orsDistributionDTOS){ Map response = new LinkedHashMap<>(); @@ -319,7 +319,7 @@ public ResponseEntity saveOrsDistribution(@RequestBody List getAllOrDistribution(@RequestBody GetBenRequestHandler request){ Map response = new LinkedHashMap<>(); From 1b5c366727140c3673fd6cf74842752dede6467b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 27 Oct 2025 17:15:11 +0530 Subject: [PATCH 456/792] ors distribution api --- src/main/java/com/iemr/flw/controller/ChildCareController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index fa5e2dc3..91f3b1fb 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -319,7 +319,7 @@ public ResponseEntity saveOrsDistribution(@RequestBody List getAllOrDistribution(@RequestBody GetBenRequestHandler request){ Map response = new LinkedHashMap<>(); From 6230358131384ab6bbdac208220959fd8e614ac5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 11:32:44 +0530 Subject: [PATCH 457/792] ors distribution api --- src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java | 4 ++-- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java index bf91e1bd..0461775a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java +++ b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java @@ -27,10 +27,10 @@ public class OrsDistribution { private LocalDate visitDate; @Column(name = "child_count") - private Integer childCount; + private String childCount; @Column(name = "num_ors_packets") - private Integer numOrsPackets; + private String numOrsPackets; @Column(name = "ifa_provision_date") private LocalDate ifaProvisionDate; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index ab51dfb8..a1d77c5a 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -539,8 +539,8 @@ public String saveOrsDistributionDetails(List orsDistributio orsDistributionDTOS.forEach(orsDistributionDTO -> { OrsDistribution orsDistribution = new OrsDistribution(); orsDistribution.setBeneficiaryId(orsDistributionDTO.getBeneficiaryId()); - orsDistribution.setNumOrsPackets(Integer.parseInt(orsDistributionDTO.getFields().getNum_ors_packets())); - orsDistribution.setChildCount(Integer.parseInt(orsDistributionDTO.getFields().getNum_under5_children())); + orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets()); + orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children()); orsDistribution.setMcpCardUpload(orsDistributionDTO.getFields().getMcp_card_upload()); orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); From 44b2ebd0ad9702c174f85317fb2ff5a13bbda520 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 11:54:36 +0530 Subject: [PATCH 458/792] ors distribution api --- .../java/com/iemr/flw/controller/ChildCareController.java | 1 + .../java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java | 4 ++-- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 91f3b1fb..e9564c26 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -308,6 +308,7 @@ public ResponseEntity saveOrsDistribution(@RequestBody List orsDistributio orsDistributionDTOS.forEach(orsDistributionDTO -> { OrsDistribution orsDistribution = new OrsDistribution(); orsDistribution.setBeneficiaryId(orsDistributionDTO.getBeneficiaryId()); - orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets()); - orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children()); + orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets().toString()); + orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children().toString()); orsDistribution.setMcpCardUpload(orsDistributionDTO.getFields().getMcp_card_upload()); orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); From 187bcf165f9426d7e5e51530575ba5eff2486106 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 12:03:26 +0530 Subject: [PATCH 459/792] ors distribution api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 514e5fb0..2383eb98 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -549,13 +549,14 @@ public String saveOrsDistributionDetails(List orsDistributio orsDistributionList.add(orsDistribution); }); + logger.info("orsList"+orsDistributionList.size()); if(!orsDistributionList.isEmpty()){ orsDistributionRepo.saveAll(orsDistributionList); return "Saved " + orsDistributionList.size() + " ORS visit records successfully"; } }catch (Exception e){ - logger.error(e.getMessage()); + logger.error("ORS Error"+e.getMessage()); } From a264723defee767e89cbf3b1d5245437674d0d3a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 12:12:55 +0530 Subject: [PATCH 460/792] ors distribution api --- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2383eb98..03544923 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -541,11 +541,9 @@ public String saveOrsDistributionDetails(List orsDistributio orsDistribution.setBeneficiaryId(orsDistributionDTO.getBeneficiaryId()); orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets().toString()); orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children().toString()); - orsDistribution.setMcpCardUpload(orsDistributionDTO.getFields().getMcp_card_upload()); orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); orsDistribution.setVisitDate(LocalDate.parse(orsDistributionDTO.getVisitDate(),formatter)); - orsDistribution.setIfaProvisionDate(LocalDate.parse(orsDistributionDTO.getFields().getIfa_provision_date(),formatter)); orsDistributionList.add(orsDistribution); }); @@ -570,13 +568,11 @@ public List getOrdDistrubtion(GetBenRequestHandler r for(OrsDistribution orsDistribution: entities){ OrsDistributionResponseDTO orsDistributionResponseDTO = new OrsDistributionResponseDTO(); + OrsDistributionResponseListDTO orsDistributionResponseListDTO = new OrsDistributionResponseListDTO(); orsDistributionResponseDTO.setId(orsDistribution.getId()); orsDistributionResponseDTO.setBeneficiaryId(orsDistribution.getBeneficiaryId()); orsDistributionResponseDTO.setHouseHoldId(orsDistribution.getHouseholdId()); - OrsDistributionResponseListDTO orsDistributionResponseListDTO = new OrsDistributionResponseListDTO(); orsDistributionResponseListDTO.setNum_ors_packets(orsDistribution.getNumOrsPackets().toString()); - orsDistributionResponseListDTO.setMcp_card_upload(orsDistribution.getMcpCardUpload()); - orsDistributionResponseListDTO.setIfa_provision_date(orsDistribution.getIfaProvisionDate().toString()); orsDistributionResponseListDTO.setNum_under5_children(orsDistribution.getChildCount().toString()); orsDistributionResponseDTO.setFields(orsDistributionResponseListDTO); From 8606012a8c81d11942a3d072e5098a16b88dde26 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 12:13:13 +0530 Subject: [PATCH 461/792] ors distribution api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 03544923..2c53d8b1 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -554,7 +554,7 @@ public String saveOrsDistributionDetails(List orsDistributio } }catch (Exception e){ - logger.error("ORS Error"+e.getMessage()); + logger.error("ORS Error"+e.getCause()); } From 501bee34a06bb0cf592e065c81782cebbeef180d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 12:16:36 +0530 Subject: [PATCH 462/792] ors distribution api --- .../java/com/iemr/flw/domain/iemr/OrsDistribution.java | 6 ------ .../iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java | 7 ------- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 1 + 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java index 0461775a..e5603dee 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java +++ b/src/main/java/com/iemr/flw/domain/iemr/OrsDistribution.java @@ -32,12 +32,6 @@ public class OrsDistribution { @Column(name = "num_ors_packets") private String numOrsPackets; - @Column(name = "ifa_provision_date") - private LocalDate ifaProvisionDate; - - // Image stored as path or file name - @Column(name = "mcp_card_upload") - private String mcpCardUpload; @Column(name = "created_at", updatable = false, insertable = false, columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") private java.sql.Timestamp createdAt; diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java index 393106f9..3ce0db51 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionResponseListDTO.java @@ -14,11 +14,4 @@ public class OrsDistributionResponseListDTO { @JsonProperty("num_ors_packets") private String num_ors_packets; - @JsonProperty("ifa_provision_date") - private String ifa_provision_date; - - @JsonProperty("mcp_card_upload") - private String mcp_card_upload; - - } diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 004b532b..103140b8 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -331,6 +331,7 @@ public List getEligibleCoupleTracking(GetBenRequestHa List eligibleCoupleTrackingList = eligibleCoupleTrackingRepo.getECTrackRecords(user, dto.getFromDate(), dto.getToDate()); + return eligibleCoupleTrackingList.stream() .map(ect -> mapper.convertValue(ect, EligibleCoupleTrackingDTO.class)) .collect(Collectors.toList()); From 3ae3869e85f82bedebf23276629c16fc5681152f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 12:37:07 +0530 Subject: [PATCH 463/792] ors distribution api --- .../flw/controller/ChildCareController.java | 61 +++++++++++++++++ .../iemr/flw/domain/iemr/IfaDistribution.java | 38 +++++++++++ .../iemr/flw/dto/iemr/IfaDistributionDTO.java | 32 +++++++++ .../repo/iemr/IfaDistributionRepository.java | 10 +++ .../iemr/flw/service/ChildCareService.java | 7 ++ .../service/impl/ChildCareServiceImpl.java | 68 +++++++++++++++++++ 6 files changed, 216 insertions(+) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/IfaDistributionRepository.java diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index e9564c26..71d177f2 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -5,6 +5,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iemr.flw.domain.iemr.HbncVisit; +import com.iemr.flw.domain.iemr.IfaDistribution; import com.iemr.flw.domain.iemr.SamVisitResponseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; @@ -344,4 +345,64 @@ public ResponseEntity getAllOrDistribution(@RequestBody GetBenRequestHandler } return ResponseEntity.ok(response); } + + @RequestMapping(value = {"/ifa/saveAll"},method = RequestMethod.POST) + public ResponseEntity saveIfDistribution(@RequestBody List ifaDistributionDTOS){ + Map response = new LinkedHashMap<>(); + + logger.info("sam request :"+ifaDistributionDTOS); + try { + List responseObject = childCareService.saveAllIfa(ifaDistributionDTOS); + + if(ifaDistributionDTOS!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Ifa Save successfully "); + return ResponseEntity.ok().body(response); + + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", responseObject); + return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); + + } + }catch (Exception e){ + logger.error("Error:"+e.getMessage()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); + + + } + return null; + + } + + @RequestMapping(value = {"/ifa/getAll"},method = RequestMethod.POST) + public ResponseEntity getIfaDistribution(@RequestBody GetBenRequestHandler request){ + Map response = new LinkedHashMap<>(); + + try { + List responseObject = childCareService.getByBeneficiaryId(request); + + if(responseObject!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("data",responseObject); + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); + } + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java new file mode 100644 index 00000000..379990eb --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java @@ -0,0 +1,38 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import org.checkerframework.checker.units.qual.C; + +import java.time.LocalDate; + +@Entity +@Table(name = "t_ifa_distribution") +@Data +public class IfaDistribution { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "beneficiary_id") + private Long beneficiaryId; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "house_hold_id") + private Long houseHoldId; + + @Column(name = "form_id") + private String formId; + + @Column(name = "visit_date") + private String visitDate; // kept as String because "N/A" possible + + @Column(name = "ifa_provision_date") + private LocalDate ifaProvisionDate; + + @Column(name = "mcp_card_upload", columnDefinition = "TEXT") + private String mcpCardUpload; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java new file mode 100644 index 00000000..7c9b4092 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java @@ -0,0 +1,32 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class IfaDistributionDTO { + + @SerializedName("beneficiaryId") + private Long beneficiaryId; + + @SerializedName("houseHoldId") + private Long houseHoldId; + + @SerializedName("formId") + private String formId; + + @SerializedName("visitDate") + private String visitDate; // can be "N/A" or date string + + @SerializedName("fields") + private FieldsDTO fields; + + @Data + public static class FieldsDTO { + @SerializedName("ifa_provision_date") + private String ifaProvisionDate; + + @SerializedName("mcp_card_upload") + private String mcpCardUpload; + } +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/IfaDistributionRepository.java b/src/main/java/com/iemr/flw/repo/iemr/IfaDistributionRepository.java new file mode 100644 index 00000000..a1a3ae8d --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/IfaDistributionRepository.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.IfaDistribution; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface IfaDistributionRepository extends JpaRepository { + List findByUserId(Integer ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/ChildCareService.java b/src/main/java/com/iemr/flw/service/ChildCareService.java index 72530fee..bbd5c96f 100644 --- a/src/main/java/com/iemr/flw/service/ChildCareService.java +++ b/src/main/java/com/iemr/flw/service/ChildCareService.java @@ -1,5 +1,6 @@ package com.iemr.flw.service; +import com.iemr.flw.domain.iemr.IfaDistribution; import com.iemr.flw.domain.iemr.SamVisitResponseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; @@ -29,4 +30,10 @@ public interface ChildCareService { String saveOrsDistributionDetails(List orsDistributionDTOS); List getOrdDistrubtion(GetBenRequestHandler request); + + List saveAllIfa(List dtoList); + + List getByBeneficiaryId(GetBenRequestHandler request); + + } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2c53d8b1..90e339ee 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -56,6 +56,9 @@ public class ChildCareServiceImpl implements ChildCareService { @Autowired private SamVisitRepository samVisitRepository; + @Autowired + private IfaDistributionRepository ifaDistributionRepository; + @Autowired private VaccineRepo vaccineRepo; @@ -585,6 +588,71 @@ public List getOrdDistrubtion(GetBenRequestHandler r } + @Override + public List saveAllIfa(List dtoList) { + return dtoList.stream() + .map(this::mapToEntity) + .map(ifaDistributionRepository::save) + .toList(); + } + + + + @Override + public List getByBeneficiaryId(GetBenRequestHandler requestHandler) { + return ifaDistributionRepository.findByUserId(requestHandler.getAshaId()).stream() + .map(this::mapToDTO) + .toList(); + } + // 🔁 Entity → DTO (date formatted as dd-MM-yyyy) + private IfaDistributionDTO mapToDTO(IfaDistribution entity) { + final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + IfaDistributionDTO dto = new IfaDistributionDTO(); + + dto.setBeneficiaryId(entity.getBeneficiaryId()); + dto.setHouseHoldId(entity.getHouseHoldId()); + dto.setFormId(entity.getFormId()); + dto.setVisitDate(entity.getVisitDate()); + + IfaDistributionDTO.FieldsDTO fields = new IfaDistributionDTO.FieldsDTO(); + + if (entity.getIfaProvisionDate() != null) { + fields.setIfaProvisionDate(entity.getIfaProvisionDate().format(FORMATTER)); + } + fields.setMcpCardUpload(entity.getMcpCardUpload()); + + dto.setFields(fields); + return dto; + } + + // 🔄 Helper method to convert DTO → Entity + private IfaDistribution mapToEntity(IfaDistributionDTO dto) { + IfaDistribution entity = new IfaDistribution(); + + entity.setBeneficiaryId(dto.getBeneficiaryId()); + entity.setHouseHoldId(dto.getHouseHoldId()); + entity.setFormId(dto.getFormId()); + entity.setVisitDate(dto.getVisitDate()); + entity.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + + if (dto.getFields() != null) { + if (dto.getFields().getIfaProvisionDate() != null) { + try { + entity.setIfaProvisionDate(LocalDate.parse( + dto.getFields().getIfaProvisionDate(), + DateTimeFormatter.ofPattern("dd-MM-yyyy") + )); + } catch (Exception e) { + entity.setIfaProvisionDate(null); + } + } + entity.setMcpCardUpload(dto.getFields().getMcpCardUpload()); + } + + return entity; + } + private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = From 7b66e8f76a676d3de8f61767a956863493299a90 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 13:52:56 +0530 Subject: [PATCH 464/792] ors distribution api --- .../java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java | 4 ++-- .../iemr/flw/service/impl/ChildCareServiceImpl.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java index 7c9b4092..a0e77778 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java @@ -24,9 +24,9 @@ public class IfaDistributionDTO { @Data public static class FieldsDTO { @SerializedName("ifa_provision_date") - private String ifaProvisionDate; + private String ifa_provision_date; @SerializedName("mcp_card_upload") - private String mcpCardUpload; + private String mcp_card_upload; } } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 90e339ee..fdc09a42 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -618,9 +618,9 @@ private IfaDistributionDTO mapToDTO(IfaDistribution entity) { IfaDistributionDTO.FieldsDTO fields = new IfaDistributionDTO.FieldsDTO(); if (entity.getIfaProvisionDate() != null) { - fields.setIfaProvisionDate(entity.getIfaProvisionDate().format(FORMATTER)); + fields.setIfa_provision_date(entity.getIfaProvisionDate().format(FORMATTER)); } - fields.setMcpCardUpload(entity.getMcpCardUpload()); + fields.setIfa_provision_date(entity.getMcpCardUpload()); dto.setFields(fields); return dto; @@ -637,17 +637,17 @@ private IfaDistribution mapToEntity(IfaDistributionDTO dto) { entity.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); if (dto.getFields() != null) { - if (dto.getFields().getIfaProvisionDate() != null) { + if (dto.getFields().getIfa_provision_date() != null) { try { entity.setIfaProvisionDate(LocalDate.parse( - dto.getFields().getIfaProvisionDate(), + dto.getFields().getIfa_provision_date(), DateTimeFormatter.ofPattern("dd-MM-yyyy") )); } catch (Exception e) { entity.setIfaProvisionDate(null); } } - entity.setMcpCardUpload(dto.getFields().getMcpCardUpload()); + entity.setMcpCardUpload(dto.getFields().getMcp_card_upload()); } return entity; From 513bcf8fd472847a7a41912e5ddfa35d31cbe44a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 28 Oct 2025 16:40:53 +0530 Subject: [PATCH 465/792] ors distribution api --- src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java | 4 ++++ src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java | 3 +++ .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java b/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java index 379990eb..c6b61354 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IfaDistribution.java @@ -1,5 +1,6 @@ package com.iemr.flw.domain.iemr; +import com.google.gson.annotations.SerializedName; import jakarta.persistence.*; import lombok.Data; import org.checkerframework.checker.units.qual.C; @@ -35,4 +36,7 @@ public class IfaDistribution { @Column(name = "mcp_card_upload", columnDefinition = "TEXT") private String mcpCardUpload; + + @Column(name = "ifa_bottle_count") + private String ifaBottleCount; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java index a0e77778..32143753 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IfaDistributionDTO.java @@ -28,5 +28,8 @@ public static class FieldsDTO { @SerializedName("mcp_card_upload") private String mcp_card_upload; + + @SerializedName("ifa_bottle_count") + private Double ifa_bottle_count; } } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index fdc09a42..5e778d5a 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -621,6 +621,7 @@ private IfaDistributionDTO mapToDTO(IfaDistribution entity) { fields.setIfa_provision_date(entity.getIfaProvisionDate().format(FORMATTER)); } fields.setIfa_provision_date(entity.getMcpCardUpload()); + fields.setIfa_bottle_count(Double.valueOf(entity.getIfaBottleCount())); dto.setFields(fields); return dto; @@ -628,6 +629,8 @@ private IfaDistributionDTO mapToDTO(IfaDistribution entity) { // 🔄 Helper method to convert DTO → Entity private IfaDistribution mapToEntity(IfaDistributionDTO dto) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + IfaDistribution entity = new IfaDistribution(); entity.setBeneficiaryId(dto.getBeneficiaryId()); @@ -647,6 +650,7 @@ private IfaDistribution mapToEntity(IfaDistributionDTO dto) { entity.setIfaProvisionDate(null); } } + entity.setIfaBottleCount(dto.getFields().getIfa_bottle_count().toString()); entity.setMcpCardUpload(dto.getFields().getMcp_card_upload()); } From bbe70eae9a8fce4c50f4e7d8e15ef0c9693229a2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 10:26:18 +0530 Subject: [PATCH 466/792] ors distribution api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 5e778d5a..84449de1 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -578,7 +578,7 @@ public List getOrdDistrubtion(GetBenRequestHandler r orsDistributionResponseListDTO.setNum_ors_packets(orsDistribution.getNumOrsPackets().toString()); orsDistributionResponseListDTO.setNum_under5_children(orsDistribution.getChildCount().toString()); orsDistributionResponseDTO.setFields(orsDistributionResponseListDTO); - + orsDistributionResponseDTO.setVisitDate(orsDistribution.getVisitDate().toString()); orsDistributionResponseDTOSList.add(orsDistributionResponseDTO); From f84745d6a827697ebdb8637ae5ef543b26ffeab7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 11:28:51 +0530 Subject: [PATCH 467/792] ors distribution api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 84449de1..22911dc5 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -620,7 +620,7 @@ private IfaDistributionDTO mapToDTO(IfaDistribution entity) { if (entity.getIfaProvisionDate() != null) { fields.setIfa_provision_date(entity.getIfaProvisionDate().format(FORMATTER)); } - fields.setIfa_provision_date(entity.getMcpCardUpload()); + fields.setMcp_card_upload(entity.getMcpCardUpload()); fields.setIfa_bottle_count(Double.valueOf(entity.getIfaBottleCount())); dto.setFields(fields); From e9187028b147f5debebbc217b8656e4f08d526d4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 12:43:44 +0530 Subject: [PATCH 468/792] ors distribution api --- .../iemr/flw/service/impl/ChildCareServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 22911dc5..f62de1eb 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -502,7 +502,7 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque List entities = samVisitRepository.findByUserId(request.getAshaId()); List samResponseListDTO = new ArrayList<>(); - + DateTimeFormatter outFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); for (SamVisit entity : entities) { SAMResponseDTO samResponseDTO = new SAMResponseDTO(); @@ -510,10 +510,11 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque samResponseDTO.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); samResponseDTO.setHouseHoldId(entity.getHouseholdId()); samResponseDTO.setId(entity.getId()); + String formatted = entity.getVisitDate().format(outFormatter); SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); - dto.setVisitDate(entity.getVisitDate()); + dto.setVisitDate(LocalDate.parse(formatted)); dto.setVisitLabel(entity.getVisitLabel()); dto.setMuac(entity.getMuac()); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); @@ -568,8 +569,11 @@ public String saveOrsDistributionDetails(List orsDistributio public List getOrdDistrubtion(GetBenRequestHandler request) { List entities = orsDistributionRepo.findByUserId(request.getAshaId()); List orsDistributionResponseDTOSList = new ArrayList<>(); + DateTimeFormatter outFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); for(OrsDistribution orsDistribution: entities){ + String formatted = orsDistribution.getVisitDate().format(outFormatter); + OrsDistributionResponseDTO orsDistributionResponseDTO = new OrsDistributionResponseDTO(); OrsDistributionResponseListDTO orsDistributionResponseListDTO = new OrsDistributionResponseListDTO(); orsDistributionResponseDTO.setId(orsDistribution.getId()); @@ -578,7 +582,7 @@ public List getOrdDistrubtion(GetBenRequestHandler r orsDistributionResponseListDTO.setNum_ors_packets(orsDistribution.getNumOrsPackets().toString()); orsDistributionResponseListDTO.setNum_under5_children(orsDistribution.getChildCount().toString()); orsDistributionResponseDTO.setFields(orsDistributionResponseListDTO); - orsDistributionResponseDTO.setVisitDate(orsDistribution.getVisitDate().toString()); + orsDistributionResponseDTO.setVisitDate(formatted.toString()); orsDistributionResponseDTOSList.add(orsDistributionResponseDTO); From d475782a1b06f7e72e377231b714d0373d61c936 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 14:11:52 +0530 Subject: [PATCH 469/792] eye check up vist api --- .../flw/controller/BeneficiaryController.java | 71 +++++++++++++++++ .../iemr/flw/domain/iemr/EyeCheckupVisit.java | 51 ++++++++++++ .../iemr/flw/dto/iemr/EyeCheckupListDTO.java | 26 ++++++ .../flw/dto/iemr/EyeCheckupRequestDTO.java | 14 ++++ .../flw/repo/iemr/EyeCheckUpVisitRepo.java | 13 +++ .../iemr/flw/service/BeneficiaryService.java | 7 ++ .../service/impl/BeneficiaryServiceImpl.java | 79 ++++++++++++++++++- 7 files changed, 258 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/EyeCheckupRequestDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index 11e0a202..6681822e 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -1,6 +1,9 @@ package com.iemr.flw.controller; import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.EyeCheckupRequestDTO; +import com.iemr.flw.dto.iemr.SAMResponseDTO; +import com.iemr.flw.dto.iemr.SamDTO; import com.iemr.flw.service.BeneficiaryService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; @@ -9,9 +12,14 @@ import jakarta.servlet.http.HttpServletRequest; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.sql.Timestamp; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; @RestController @RequestMapping(value = "/beneficiary", headers = "Authorization", consumes = "application/json", produces = "application/json") @@ -24,6 +32,8 @@ public class BeneficiaryController { + + @RequestMapping(value = "/getBeneficiaryData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, @@ -49,4 +59,65 @@ public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler request return response.toString(); } + @RequestMapping(value = {"/eye_surgery/saveAll"},method = RequestMethod.POST) + public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List eyeCheckupRequestDTOS){ + Map response = new LinkedHashMap<>(); + + logger.info("sam request :"+eyeCheckupRequestDTOS); + try { + String responseObject = beneficiaryService.saveEyeCheckupVsit(eyeCheckupRequestDTOS); + + if(eyeCheckupRequestDTOS!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", responseObject); + return ResponseEntity.ok().body(response); + + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", responseObject); + return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); + + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); + + + } + return null; + + } + + + @RequestMapping(value = {"/eye_surgery/getAll"},method = RequestMethod.POST) + public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenRequestHandler request){ + Map response = new LinkedHashMap<>(); + + try { + List responseObject = beneficiaryService.getEyeCheckUpVisit(request); + + if(responseObject!=null){ + if(responseObject!=null){ + response.put("statusCode", HttpStatus.OK.value()); + response.put("data",responseObject); + } + + }else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + } + }catch (Exception e){ + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + + } + return ResponseEntity.ok(response); + } + + + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java new file mode 100644 index 00000000..b888d8b6 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java @@ -0,0 +1,51 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; +@Data +@Entity +@Table(name = "t_eye_check_up",schema = "db_iemr") +public class EyeCheckupVisit { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "beneficiary_id") + private Long beneficiaryId; + + @Column(name = "household_id") + private Long householdId; + + @Column(name = "visit_date") + private LocalDate visitDate; + + @Column(name = "symptoms_observed") + private String symptomsObserved; + + @Column(name = "eye_affected") + private String eyeAffected; + + @Column(name = "referred_to") + private String referredTo; + + @Column(name = "follow_up_status") + private String followUpStatus; + + @Column(name = "date_of_surgery") + private String dateOfSurgery; + + @Column(name = "created_by") + private String createdBy; + + @Column(name = "created_date") + private LocalDateTime createdDate = LocalDateTime.now(); + + @Column(name = "updated_date") + private LocalDateTime updatedDate = LocalDateTime.now(); +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java new file mode 100644 index 00000000..d2236b9a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java @@ -0,0 +1,26 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class EyeCheckupListDTO { + @SerializedName("visit_date") + private String visitDate; + + @SerializedName("symptoms_observed") + private String symptomsObserved; + + @SerializedName("eye_affected") + private String eyeAffected; + + @SerializedName("referred_to") + private String referredTo; + + @SerializedName("follow_up_status") + private String followUpStatus; + + @SerializedName("date_of_surgery") + private String dateOfSurgery; + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupRequestDTO.java new file mode 100644 index 00000000..f0c6d8bb --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupRequestDTO.java @@ -0,0 +1,14 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class EyeCheckupRequestDTO { + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private String userName; + private EyeCheckupListDTO fields; + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java new file mode 100644 index 00000000..c0e3df73 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.EyeCheckupVisit; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public +interface EyeCheckUpVisitRepo extends JpaRepository { + List findByUserId(Integer userId); +} diff --git a/src/main/java/com/iemr/flw/service/BeneficiaryService.java b/src/main/java/com/iemr/flw/service/BeneficiaryService.java index 2be7260b..1db3026b 100644 --- a/src/main/java/com/iemr/flw/service/BeneficiaryService.java +++ b/src/main/java/com/iemr/flw/service/BeneficiaryService.java @@ -1,9 +1,16 @@ package com.iemr.flw.service; import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.EyeCheckupRequestDTO; +import com.iemr.flw.dto.iemr.SAMResponseDTO; + +import java.util.List; public interface BeneficiaryService { String getBenData(GetBenRequestHandler requestDTO, String authorisation) throws Exception; + String saveEyeCheckupVsit(List eyeCheckupRequestDTOS); + + List getEyeCheckUpVisit(GetBenRequestHandler request); } diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 2ed01f42..787bde4a 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -3,7 +3,9 @@ import java.math.BigInteger; import java.sql.Date; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.time.Period; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -11,11 +13,13 @@ import java.util.Map; import java.util.stream.Collectors; +import com.iemr.flw.domain.iemr.EyeCheckupVisit; import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.dto.iemr.EyeCheckupListDTO; +import com.iemr.flw.dto.iemr.EyeCheckupRequestDTO; import com.iemr.flw.masterEnum.GroupName; -import com.iemr.flw.repo.iemr.GeneralOpdRepo; -import com.iemr.flw.repo.iemr.IncentiveRecordRepo; -import com.iemr.flw.repo.iemr.IncentivesRepo; +import com.iemr.flw.repo.iemr.*; +import com.iemr.flw.utils.JwtUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -73,6 +77,18 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { @Autowired IncentiveRecordRepo recordRepo; + @Autowired + private EyeCheckUpVisitRepo eyeCheckUpVisitRepo; + + @Autowired + private JwtUtil jwtUtil; + + @Autowired + private UserServiceRoleRepo userRepo; + + private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + @Override public String getBenData(GetBenRequestHandler request, String authorisation) throws Exception { @@ -497,4 +513,61 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map eyeCheckupRequestDTOS) { + + try { + for (EyeCheckupRequestDTO dto : eyeCheckupRequestDTOS) { + EyeCheckupVisit visit = new EyeCheckupVisit(); + + visit.setBeneficiaryId(dto.getBeneficiaryId()); + visit.setHouseholdId(dto.getHouseHoldId()); + visit.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); // cache se lena hai + visit.setCreatedBy(dto.getUserName()); + + // fields mapping + EyeCheckupListDTO f = dto.getFields(); + visit.setVisitDate(LocalDate.parse(f.getVisitDate(), FORMATTER)); + visit.setSymptomsObserved(f.getSymptomsObserved()); + visit.setEyeAffected(f.getEyeAffected()); + visit.setReferredTo(f.getReferredTo()); + visit.setFollowUpStatus(f.getFollowUpStatus()); + visit.setDateOfSurgery(f.getDateOfSurgery()); + + // save/update + eyeCheckUpVisitRepo.save(visit); + } + return "Eye checkup data saved successfully."; + } catch (Exception e) { + e.printStackTrace(); + return "Error while saving Eye Checkup data: " + e.getMessage(); + } + } + + @Override + public List getEyeCheckUpVisit(GetBenRequestHandler request) { + List visits = eyeCheckUpVisitRepo.findByUserId(request.getUserId()); + + return visits.stream().map(v -> { + EyeCheckupRequestDTO dto = new EyeCheckupRequestDTO(); + dto.setId(v.getId()); + dto.setBeneficiaryId(v.getBeneficiaryId()); + dto.setHouseHoldId(v.getHouseholdId()); + dto.setUserName(v.getCreatedBy()); + dto.setVisitDate(v.getVisitDate().format(FORMATTER)); + + EyeCheckupListDTO fields = new EyeCheckupListDTO(); + fields.setVisitDate(v.getVisitDate().format(FORMATTER)); + fields.setSymptomsObserved(v.getSymptomsObserved()); + fields.setEyeAffected(v.getEyeAffected()); + fields.setReferredTo(v.getReferredTo()); + fields.setFollowUpStatus(v.getFollowUpStatus()); + fields.setDateOfSurgery(v.getDateOfSurgery()); + + dto.setFields(fields); + return dto; + }).collect(Collectors.toList()); + } + + } From 575628f540d2faced0776050640c687006a35fc4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 15:11:35 +0530 Subject: [PATCH 470/792] eye check up vist api --- .../iemr/flw/domain/iemr/EyeCheckupVisit.java | 2 +- .../iemr/flw/dto/iemr/EyeCheckupListDTO.java | 12 +++++----- .../service/impl/BeneficiaryServiceImpl.java | 24 +++++++++---------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java index b888d8b6..0c0deeec 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java @@ -7,7 +7,7 @@ import java.time.LocalDateTime; @Data @Entity -@Table(name = "t_eye_check_up",schema = "db_iemr") +@Table(name = "t_eye_checkup",schema = "db_iemr") public class EyeCheckupVisit { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java index d2236b9a..9af61c9d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java @@ -6,21 +6,21 @@ @Data public class EyeCheckupListDTO { @SerializedName("visit_date") - private String visitDate; + private String visit_date; @SerializedName("symptoms_observed") - private String symptomsObserved; + private String symptoms_observed; @SerializedName("eye_affected") - private String eyeAffected; + private String eye_affected; @SerializedName("referred_to") - private String referredTo; + private String referred_to; @SerializedName("follow_up_status") - private String followUpStatus; + private String follow_up_status; @SerializedName("date_of_surgery") - private String dateOfSurgery; + private String date_of_surgery; } diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 787bde4a..019c2863 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -527,12 +527,12 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO // fields mapping EyeCheckupListDTO f = dto.getFields(); - visit.setVisitDate(LocalDate.parse(f.getVisitDate(), FORMATTER)); - visit.setSymptomsObserved(f.getSymptomsObserved()); - visit.setEyeAffected(f.getEyeAffected()); - visit.setReferredTo(f.getReferredTo()); - visit.setFollowUpStatus(f.getFollowUpStatus()); - visit.setDateOfSurgery(f.getDateOfSurgery()); + visit.setVisitDate(LocalDate.parse(f.getVisit_date(), FORMATTER)); + visit.setSymptomsObserved(f.getSymptoms_observed()); + visit.setEyeAffected(f.getEye_affected()); + visit.setReferredTo(f.getReferred_to()); + visit.setFollowUpStatus(f.getFollow_up_status()); + visit.setDateOfSurgery(f.getDate_of_surgery()); // save/update eyeCheckUpVisitRepo.save(visit); @@ -557,12 +557,12 @@ public List getEyeCheckUpVisit(GetBenRequestHandler reques dto.setVisitDate(v.getVisitDate().format(FORMATTER)); EyeCheckupListDTO fields = new EyeCheckupListDTO(); - fields.setVisitDate(v.getVisitDate().format(FORMATTER)); - fields.setSymptomsObserved(v.getSymptomsObserved()); - fields.setEyeAffected(v.getEyeAffected()); - fields.setReferredTo(v.getReferredTo()); - fields.setFollowUpStatus(v.getFollowUpStatus()); - fields.setDateOfSurgery(v.getDateOfSurgery()); + fields.setVisit_date(v.getVisitDate().format(FORMATTER)); + fields.setSymptoms_observed(v.getSymptomsObserved()); + fields.setEye_affected(v.getEyeAffected()); + fields.setReferred_to(v.getReferredTo()); + fields.setFollow_up_status(v.getFollowUpStatus()); + fields.setDate_of_surgery(v.getDateOfSurgery()); dto.setFields(fields); return dto; From e3d283e98a5db0f9925111ecd0fb006b91b86774 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 15:18:30 +0530 Subject: [PATCH 471/792] eye check up vist api --- .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 019c2863..d2a55ab8 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -546,7 +546,7 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO @Override public List getEyeCheckUpVisit(GetBenRequestHandler request) { - List visits = eyeCheckUpVisitRepo.findByUserId(request.getUserId()); + List visits = eyeCheckUpVisitRepo.findByUserId(request.getAshaId()); return visits.stream().map(v -> { EyeCheckupRequestDTO dto = new EyeCheckupRequestDTO(); From d5d61d8ae5cac7bce7521eefbdff291b569eaba0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 16:11:22 +0530 Subject: [PATCH 472/792] eye check up vist api --- .../flw/controller/BeneficiaryController.java | 80 +++--- .../flw/controller/ChildCareController.java | 231 +++++++++--------- 2 files changed, 154 insertions(+), 157 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index 6681822e..fb06aa22 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -59,65 +59,65 @@ public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler request return response.toString(); } - @RequestMapping(value = {"/eye_surgery/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List eyeCheckupRequestDTOS){ - Map response = new LinkedHashMap<>(); + @RequestMapping(value = {"/eye_surgery/saveAll"}, method = RequestMethod.POST) + public ResponseEntity saveEyeSurgery(@RequestBody List eyeCheckupRequestDTOS) { + Map response = new LinkedHashMap<>(); + logger.info("Eye Checkup Save Request: {}", eyeCheckupRequestDTOS); - logger.info("sam request :"+eyeCheckupRequestDTOS); try { - String responseObject = beneficiaryService.saveEyeCheckupVsit(eyeCheckupRequestDTOS); - - if(eyeCheckupRequestDTOS!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("message", responseObject); - return ResponseEntity.ok().body(response); + if (eyeCheckupRequestDTOS == null || eyeCheckupRequestDTOS.isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Request body cannot be empty"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } - } + String responseObject = beneficiaryService.saveEyeCheckupVsit(eyeCheckupRequestDTOS); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + if (responseObject != null) { + response.put("statusCode", HttpStatus.OK.value()); response.put("message", responseObject); - return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); - + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save records"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error saving eye checkup visit:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); - - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return null; - } - @RequestMapping(value = {"/eye_surgery/getAll"},method = RequestMethod.POST) - public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenRequestHandler request){ - Map response = new LinkedHashMap<>(); - - try { - List responseObject = beneficiaryService.getEyeCheckUpVisit(request); - if(responseObject!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("data",responseObject); - } + @RequestMapping(value = {"/eye_surgery/getAll"}, method = RequestMethod.POST) + public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler request) { + Map response = new LinkedHashMap<>(); + logger.info("Eye Checkup Get Request: {}", request); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + try { + List responseObject = beneficiaryService.getEyeCheckUpVisit(request); + + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error fetching eye checkup visit:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return ResponseEntity.ok(response); } - } diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 71d177f2..9e069fed 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -227,182 +227,179 @@ public String getChildVaccinationDetails(@RequestParam(value = "category") Strin } return response.toString(); } - @RequestMapping(value = {"/sam/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List samRequest){ - Map response = new LinkedHashMap<>(); + @RequestMapping(value = {"/sam/saveAll"}, method = RequestMethod.POST) + public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List samRequest) { + Map response = new LinkedHashMap<>(); + logger.info("SAM Request: {}", samRequest); - logger.info("sam request :"+samRequest); try { - String responseObject = childCareService.saveSamDetails(samRequest); - - if(samRequest!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("message", responseObject); - return ResponseEntity.ok().body(response); + if (samRequest == null || samRequest.isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Request body cannot be empty"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } - } + String responseObject = childCareService.saveSamDetails(samRequest); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + if (responseObject != null) { + response.put("statusCode", HttpStatus.OK.value()); response.put("message", responseObject); - return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); - + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save SAM details"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error saving SAM details:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); - - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return null; - } - @RequestMapping(value = {"/sam/getAll"},method = RequestMethod.POST) - public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenRequestHandler request){ - Map response = new LinkedHashMap<>(); - + @RequestMapping(value = {"/sam/getAll"}, method = RequestMethod.POST) + public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenRequestHandler request) { + Map response = new LinkedHashMap<>(); try { - List responseObject = childCareService.getSamVisitsByBeneficiary(request); - - if(responseObject!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("data",responseObject); - } + List responseObject = childCareService.getSamVisitsByBeneficiary(request); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No SAM records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error fetching SAM records:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return ResponseEntity.ok(response); } - @RequestMapping(value = {"/ors/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveOrsDistribution(@RequestBody List orsDistributionDTOS){ - Map response = new LinkedHashMap<>(); - logger.info("sam request :"+orsDistributionDTOS); - try { - String responseObject = childCareService.saveOrsDistributionDetails(orsDistributionDTOS); + @RequestMapping(value = {"/ors/saveAll"}, method = RequestMethod.POST) + public ResponseEntity saveOrsDistribution(@RequestBody List orsDistributionDTOS) { + Map response = new LinkedHashMap<>(); + logger.info("ORS Request: {}", orsDistributionDTOS); - if(orsDistributionDTOS!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("message", responseObject); - return ResponseEntity.ok().body(response); + try { + if (orsDistributionDTOS == null || orsDistributionDTOS.isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Request body cannot be empty"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } - } + String responseObject = childCareService.saveOrsDistributionDetails(orsDistributionDTOS); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + if (responseObject != null) { + response.put("statusCode", HttpStatus.OK.value()); response.put("message", responseObject); - return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); - + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save ORS details"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } - }catch (Exception e){ - logger.error("Error:"+e.getMessage()); + + } catch (Exception e) { + logger.error("Error saving ORS:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); - - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return null; - } - @RequestMapping(value = {"/ors/getAll"},method = RequestMethod.POST) - public ResponseEntity getAllOrDistribution(@RequestBody GetBenRequestHandler request){ - Map response = new LinkedHashMap<>(); + @RequestMapping(value = {"/ors/getAll"}, method = RequestMethod.POST) + public ResponseEntity getAllOrDistribution(@RequestBody GetBenRequestHandler request) { + Map response = new LinkedHashMap<>(); try { - List responseObject = childCareService.getOrdDistrubtion(request); + List responseObject = childCareService.getOrdDistrubtion(request); - if(responseObject!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("data",responseObject); - } - - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No ORS records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error fetching ORS records:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return ResponseEntity.ok(response); } - @RequestMapping(value = {"/ifa/saveAll"},method = RequestMethod.POST) - public ResponseEntity saveIfDistribution(@RequestBody List ifaDistributionDTOS){ - Map response = new LinkedHashMap<>(); - logger.info("sam request :"+ifaDistributionDTOS); - try { - List responseObject = childCareService.saveAllIfa(ifaDistributionDTOS); + @RequestMapping(value = {"/ifa/saveAll"}, method = RequestMethod.POST) + public ResponseEntity saveIfDistribution(@RequestBody List ifaDistributionDTOS) { + Map response = new LinkedHashMap<>(); + logger.info("IFA Request: {}", ifaDistributionDTOS); - if(ifaDistributionDTOS!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("message", "Ifa Save successfully "); - return ResponseEntity.ok().body(response); + try { + if (ifaDistributionDTOS == null || ifaDistributionDTOS.isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Request body cannot be empty"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } - } + List responseObject = childCareService.saveAllIfa(ifaDistributionDTOS); - }else { + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "IFA saved successfully"); + return ResponseEntity.ok(response); + } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", responseObject); - return ResponseEntity.status(HttpStatus.BAD_REQUEST.value()).body(response); - + response.put("message", "Failed to save IFA details"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } - }catch (Exception e){ - logger.error("Error:"+e.getMessage()); + + } catch (Exception e) { + logger.error("Error saving IFA:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR.value()).body(response); - - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return null; - } - @RequestMapping(value = {"/ifa/getAll"},method = RequestMethod.POST) - public ResponseEntity getIfaDistribution(@RequestBody GetBenRequestHandler request){ - Map response = new LinkedHashMap<>(); - try { - List responseObject = childCareService.getByBeneficiaryId(request); + @RequestMapping(value = {"/ifa/getAll"}, method = RequestMethod.POST) + public ResponseEntity getIfaDistribution(@RequestBody GetBenRequestHandler request) { + Map response = new LinkedHashMap<>(); - if(responseObject!=null){ - if(responseObject!=null){ - response.put("statusCode", HttpStatus.OK.value()); - response.put("data",responseObject); - } + try { + List responseObject = childCareService.getByBeneficiaryId(request); - }else { - response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", HttpStatus.BAD_REQUEST.getReasonPhrase()); + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No IFA records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); } - }catch (Exception e){ + + } catch (Exception e) { + logger.error("Error fetching IFA records:", e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); - + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return ResponseEntity.ok(response); } } From b07d48607a94531d1265eea9fcddc13063f4bc07 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 16:24:45 +0530 Subject: [PATCH 473/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f62de1eb..b295a311 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -10,6 +10,7 @@ import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.ChildCareService; import com.iemr.flw.utils.JwtUtil; +import org.aspectj.weaver.ast.Or; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -436,10 +437,11 @@ public String saveSamDetails(List samRequest) { try { List vaccinationList = new ArrayList<>(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - samRequest.forEach(samDTO -> { + logger.info(samDTO.getFields().getMuac()); SamVisit samVisits = new SamVisit(); + samVisits.setId(samDTO.getId()); samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisits.setHouseholdId(samDTO.getHouseHoldId()); samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); @@ -542,6 +544,7 @@ public String saveOrsDistributionDetails(List orsDistributio List orsDistributionList = new ArrayList<>(); orsDistributionDTOS.forEach(orsDistributionDTO -> { OrsDistribution orsDistribution = new OrsDistribution(); + orsDistribution.setId(orsDistributionDTO.getId()); orsDistribution.setBeneficiaryId(orsDistributionDTO.getBeneficiaryId()); orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets().toString()); orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children().toString()); @@ -554,6 +557,8 @@ public String saveOrsDistributionDetails(List orsDistributio logger.info("orsList"+orsDistributionList.size()); if(!orsDistributionList.isEmpty()){ orsDistributionRepo.saveAll(orsDistributionList); + checkAndAddOrdDistributionIncentive(orsDistributionList); + return "Saved " + orsDistributionList.size() + " ORS visit records successfully"; } @@ -660,14 +665,23 @@ private IfaDistribution mapToEntity(IfaDistributionDTO dto) { return entity; } + private void checkAndAddOrdDistributionIncentive(List orsDistributionList){ + orsDistributionList.forEach(orsDistribution -> { + IncentiveActivity OrsPacketActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName()); + if(orsDistribution.getNumOrsPackets()!=null){ + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),OrsPacketActivityAM,jwtUtil.getUserNameFromStorage()); + } + + }); + + } private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { IncentiveActivity hbyncVisitActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.CHILD_HEALTH.getDisplayName()); - IncentiveActivity hbyncOrsPacketActivityAM = - incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity hbyncOrsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); @@ -678,13 +692,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { } } - if (hbyncOrsPacketActivityAM != null) { - if (hbyc.getOrs_given()) { - createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityAM, hbyc.getCreated_by()); - } - - } if (hbyncOrsPacketActivityCH != null) { if (hbyc.getOrs_given()) { @@ -738,6 +746,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { } + private void checkAndAddIncentives(List vaccinationList) { @@ -895,6 +904,32 @@ record = new IncentiveActivityRecord(); } } + private void createIncentiveRecordforOrsDistribution(OrsDistribution data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { + + // Convert to LocalDate + Timestamp visitDate = Timestamp.valueOf(data.getVisitDate().atStartOfDay()); + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), visitDate, benId); + + + if (record == null) { + + record = new IncentiveActivityRecord(); + record.setActivityId(immunizationActivity.getId()); + record.setCreatedDate(visitDate); + record.setCreatedBy(createdBy); + record.setStartDate(visitDate); + record.setEndDate(visitDate); + record.setUpdatedDate(visitDate); + record.setUpdatedBy(createdBy); + record.setBenId(benId); + record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); + record.setAmount(Long.valueOf(immunizationActivity.getRate()*Long.parseLong(data.getNumOrsPackets()))); + recordRepo.save(record); + } + } + + private Integer getImmunizationServiceIdForVaccine(Short vaccineId) { return vaccineRepo.getImmunizationServiceIdByVaccineId(vaccineId); } From 41f794c8317df05f27473bd9754be9a87ee78e5c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 16:27:52 +0530 Subject: [PATCH 474/792] eye check up vist api --- .../flw/service/impl/ChildCareServiceImpl.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index b295a311..ff3c58f4 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -667,12 +667,22 @@ private IfaDistribution mapToEntity(IfaDistributionDTO dto) { } private void checkAndAddOrdDistributionIncentive(List orsDistributionList){ orsDistributionList.forEach(orsDistribution -> { - IncentiveActivity OrsPacketActivityAM = + IncentiveActivity orsPacketActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.CHILD_HEALTH.getDisplayName()); - if(orsDistribution.getNumOrsPackets()!=null){ - createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),OrsPacketActivityAM,jwtUtil.getUserNameFromStorage()); + IncentiveActivity orsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); + if(orsPacketActivityAM!=null){ + if(orsDistribution.getNumOrsPackets()!=null){ + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityAM,jwtUtil.getUserNameFromStorage()); + } } + if(orsPacketActivityCH!=null){ + if(orsDistribution.getNumOrsPackets()!=null){ + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityCH,jwtUtil.getUserNameFromStorage()); + } + } + + }); } From 97e4f3b218d006916337289708a8f877bfe18487 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 16:38:27 +0530 Subject: [PATCH 475/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index ff3c58f4..bd6ddb6d 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -24,6 +24,7 @@ import java.sql.Timestamp; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.*; import java.util.stream.Collectors; @@ -504,7 +505,6 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque List entities = samVisitRepository.findByUserId(request.getAshaId()); List samResponseListDTO = new ArrayList<>(); - DateTimeFormatter outFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); for (SamVisit entity : entities) { SAMResponseDTO samResponseDTO = new SAMResponseDTO(); @@ -512,11 +512,10 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque samResponseDTO.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); samResponseDTO.setHouseHoldId(entity.getHouseholdId()); samResponseDTO.setId(entity.getId()); - String formatted = entity.getVisitDate().format(outFormatter); SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); - dto.setVisitDate(LocalDate.parse(formatted)); + dto.setVisitDate(parseDate(entity.getVisitDate().toString())); dto.setVisitLabel(entity.getVisitLabel()); dto.setMuac(entity.getMuac()); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); @@ -574,10 +573,8 @@ public String saveOrsDistributionDetails(List orsDistributio public List getOrdDistrubtion(GetBenRequestHandler request) { List entities = orsDistributionRepo.findByUserId(request.getAshaId()); List orsDistributionResponseDTOSList = new ArrayList<>(); - DateTimeFormatter outFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); for(OrsDistribution orsDistribution: entities){ - String formatted = orsDistribution.getVisitDate().format(outFormatter); OrsDistributionResponseDTO orsDistributionResponseDTO = new OrsDistributionResponseDTO(); OrsDistributionResponseListDTO orsDistributionResponseListDTO = new OrsDistributionResponseListDTO(); @@ -587,7 +584,7 @@ public List getOrdDistrubtion(GetBenRequestHandler r orsDistributionResponseListDTO.setNum_ors_packets(orsDistribution.getNumOrsPackets().toString()); orsDistributionResponseListDTO.setNum_under5_children(orsDistribution.getChildCount().toString()); orsDistributionResponseDTO.setFields(orsDistributionResponseListDTO); - orsDistributionResponseDTO.setVisitDate(formatted.toString()); + orsDistributionResponseDTO.setVisitDate(parseDate(orsDistribution.getVisitDate().toString()).toString()); orsDistributionResponseDTOSList.add(orsDistributionResponseDTO); @@ -597,6 +594,21 @@ public List getOrdDistrubtion(GetBenRequestHandler r } + private LocalDate parseDate(String dateStr) { + if (dateStr == null || dateStr.isEmpty()) return null; + List formatters = List.of( + DateTimeFormatter.ofPattern("dd-MM-yyyy"), + DateTimeFormatter.ofPattern("yyyy-MM-dd") + ); + + for (DateTimeFormatter f : formatters) { + try { + return LocalDate.parse(dateStr, f); + } catch (Exception ignored) {} + } + + throw new DateTimeParseException("Invalid date format: " + dateStr, dateStr, 0); + } @Override public List saveAllIfa(List dtoList) { return dtoList.stream() From 25ba69b28d4da0b714f47dfa2f7b3bd91158a049 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 16:52:35 +0530 Subject: [PATCH 476/792] eye check up vist api --- src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java index 3055bc35..7c2d9e0b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.domain.iemr; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; @@ -12,6 +13,7 @@ public class SamVisitResponseDTO { @JsonProperty("beneficiary_id") private Long beneficiaryId; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") @JsonProperty("visit_date") private LocalDate visitDate; From a0f7bd1a24e36cdfbb22578a19ac85943725759f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 30 Oct 2025 18:59:54 +0530 Subject: [PATCH 477/792] eye check up vist api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index bd6ddb6d..a8412d9a 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -515,8 +515,8 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); - dto.setVisitDate(parseDate(entity.getVisitDate().toString())); - dto.setVisitLabel(entity.getVisitLabel()); + dto.setVisitDate(entity.getVisitDate()); + dto.setVisitLabel("Visit-"+entity.getId().toString()); dto.setMuac(entity.getMuac()); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); dto.setIsChildReferredNrc(entity.getIsChildReferredNrc()); @@ -569,6 +569,7 @@ public String saveOrsDistributionDetails(List orsDistributio return "Fail"; } + @Override public List getOrdDistrubtion(GetBenRequestHandler request) { List entities = orsDistributionRepo.findByUserId(request.getAshaId()); From 7114d2765b6c5b47ade15091f84faeb40e93ec96 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 12:58:42 +0530 Subject: [PATCH 478/792] eye check up vist api --- .../com/iemr/flw/dto/iemr/OrsDistributionListDTO.java | 8 ++------ .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 +--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java index 5ffb039c..25ab11b5 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsDistributionListDTO.java @@ -6,6 +6,8 @@ @Data public class OrsDistributionListDTO { + @SerializedName("visit_date") + private String visit_date; @SerializedName("num_under5_children") private Double num_under5_children; @@ -13,11 +15,5 @@ public class OrsDistributionListDTO { @SerializedName("num_ors_packets") private Double num_ors_packets; - @SerializedName("ifa_provision_date") - private String ifa_provision_date; - - @SerializedName("mcp_card_upload") - private String mcp_card_upload; - } diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index a8412d9a..10a29363 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -496,8 +496,6 @@ public String saveSamDetails(List samRequest) { // } // } - - } @Override @@ -549,7 +547,7 @@ public String saveOrsDistributionDetails(List orsDistributio orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children().toString()); orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); - orsDistribution.setVisitDate(LocalDate.parse(orsDistributionDTO.getVisitDate(),formatter)); + orsDistribution.setVisitDate(LocalDate.parse(orsDistributionDTO.getFields().getVisit_date(),formatter)); orsDistributionList.add(orsDistribution); }); From 95a9b501045997936f29817f824c4a37288414c1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 13:03:15 +0530 Subject: [PATCH 479/792] eye check up vist api --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 10a29363..4ccc1251 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -560,7 +560,7 @@ public String saveOrsDistributionDetails(List orsDistributio } }catch (Exception e){ - logger.error("ORS Error"+e.getCause()); + logger.error("ORS Error"+e); } From a6c38d87cdc60402c729f7581bff1f7f509e9e35 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 13:32:51 +0530 Subject: [PATCH 480/792] eye check up vist api --- src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java | 3 +++ .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java index 9af61c9d..3480aa0b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/EyeCheckupListDTO.java @@ -23,4 +23,7 @@ public class EyeCheckupListDTO { @SerializedName("date_of_surgery") private String date_of_surgery; + @SerializedName("discharge_summary_upload") + private String discharge_summary_upload; + } diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index d2a55ab8..a6889af0 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -564,6 +564,7 @@ public List getEyeCheckUpVisit(GetBenRequestHandler reques fields.setFollow_up_status(v.getFollowUpStatus()); fields.setDate_of_surgery(v.getDateOfSurgery()); + dto.setFields(fields); return dto; }).collect(Collectors.toList()); From 422cb637f86d41c61968b8af8ec7103df94bb4ca Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 13:47:54 +0530 Subject: [PATCH 481/792] eye check up vist api --- src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java | 3 +++ .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java index 0c0deeec..c15e8410 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/EyeCheckupVisit.java @@ -43,6 +43,9 @@ public class EyeCheckupVisit { @Column(name = "created_by") private String createdBy; + @Column(name = "discharge_summary_upload") + private String dischargeSummaryUpload; + @Column(name = "created_date") private LocalDateTime createdDate = LocalDateTime.now(); diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index a6889af0..71eef732 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -531,6 +531,7 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO visit.setSymptomsObserved(f.getSymptoms_observed()); visit.setEyeAffected(f.getEye_affected()); visit.setReferredTo(f.getReferred_to()); + visit.setDischargeSummaryUpload(f.getDischarge_summary_upload()); visit.setFollowUpStatus(f.getFollow_up_status()); visit.setDateOfSurgery(f.getDate_of_surgery()); From 765049ef8b6f134ae0de63b6d9913adeea35e63a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 14:12:06 +0530 Subject: [PATCH 482/792] eye check up vist api --- .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 71eef732..0d0f234c 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -564,7 +564,7 @@ public List getEyeCheckUpVisit(GetBenRequestHandler reques fields.setReferred_to(v.getReferredTo()); fields.setFollow_up_status(v.getFollowUpStatus()); fields.setDate_of_surgery(v.getDateOfSurgery()); - + fields.setDischarge_summary_upload(v.getDischargeSummaryUpload()); dto.setFields(fields); return dto; From 4ec1008a9b4f2761662a13103ebe371ab9684518 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 14:43:19 +0530 Subject: [PATCH 483/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 4ccc1251..86489c98 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -926,28 +926,34 @@ record = new IncentiveActivityRecord(); } private void createIncentiveRecordforOrsDistribution(OrsDistribution data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { + try { + // Convert to LocalDate + Timestamp visitDate = Timestamp.valueOf(data.getVisitDate().atStartOfDay()); + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), visitDate, benId); + double packets = Double.parseDouble(data.getNumOrsPackets()); + double rate = immunizationActivity.getRate(); + + if (record == null) { + + record = new IncentiveActivityRecord(); + record.setActivityId(immunizationActivity.getId()); + record.setCreatedDate(visitDate); + record.setCreatedBy(createdBy); + record.setStartDate(visitDate); + record.setEndDate(visitDate); + record.setUpdatedDate(visitDate); + record.setUpdatedBy(createdBy); + record.setBenId(benId); + record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); + record.setAmount((long) (rate * packets)); + recordRepo.save(record); + } + }catch (Exception e){ + logger.error("Exp"+e.getMessage()); + + } - // Convert to LocalDate - Timestamp visitDate = Timestamp.valueOf(data.getVisitDate().atStartOfDay()); - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), visitDate, benId); - - - if (record == null) { - - record = new IncentiveActivityRecord(); - record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(visitDate); - record.setCreatedBy(createdBy); - record.setStartDate(visitDate); - record.setEndDate(visitDate); - record.setUpdatedDate(visitDate); - record.setUpdatedBy(createdBy); - record.setBenId(benId); - record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); - record.setAmount(Long.valueOf(immunizationActivity.getRate()*Long.parseLong(data.getNumOrsPackets()))); - recordRepo.save(record); - } } From eead85c26ae9fe15b6b91ffdc1de654863752d45 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 15:01:06 +0530 Subject: [PATCH 484/792] eye check up vist api --- .../iemr/flw/service/impl/BeneficiaryServiceImpl.java | 9 +++++++-- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 0d0f234c..86239d3d 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -524,14 +524,18 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO visit.setHouseholdId(dto.getHouseHoldId()); visit.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); // cache se lena hai visit.setCreatedBy(dto.getUserName()); + StringBuilder sb = new StringBuilder(); + // fields mapping EyeCheckupListDTO f = dto.getFields(); + sb.append(f.getDischarge_summary_upload()); + String longText = sb.toString(); visit.setVisitDate(LocalDate.parse(f.getVisit_date(), FORMATTER)); visit.setSymptomsObserved(f.getSymptoms_observed()); visit.setEyeAffected(f.getEye_affected()); visit.setReferredTo(f.getReferred_to()); - visit.setDischargeSummaryUpload(f.getDischarge_summary_upload()); + visit.setDischargeSummaryUpload(longText); visit.setFollowUpStatus(f.getFollow_up_status()); visit.setDateOfSurgery(f.getDate_of_surgery()); @@ -564,7 +568,8 @@ public List getEyeCheckUpVisit(GetBenRequestHandler reques fields.setReferred_to(v.getReferredTo()); fields.setFollow_up_status(v.getFollowUpStatus()); fields.setDate_of_surgery(v.getDateOfSurgery()); - fields.setDischarge_summary_upload(v.getDischargeSummaryUpload()); + fields.setDischarge_summary_upload(v.getDischargeSummaryUpload()); + dto.setFields(fields); return dto; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 86489c98..df908d5b 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -468,9 +468,9 @@ public String saveSamDetails(List samRequest) { return "Saved " + samRequest.size() + " SAM visit records successfully"; }catch (Exception e){ logger.error(e.getMessage()); - } - return "Fail"; + } + return null ; // Handle MultipartFile → Base64 JSON // MultipartFile file = dto.getViewDischargeDocs(); @@ -562,9 +562,10 @@ public String saveOrsDistributionDetails(List orsDistributio }catch (Exception e){ logger.error("ORS Error"+e); + } - return "Fail"; + return null ; } From cc4062486b3714b08097ec695ac17a767398df1f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 31 Oct 2025 15:01:43 +0530 Subject: [PATCH 485/792] eye check up vist api --- .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 86239d3d..49a86112 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -545,8 +545,9 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO return "Eye checkup data saved successfully."; } catch (Exception e) { e.printStackTrace(); - return "Error while saving Eye Checkup data: " + e.getMessage(); + } + return null ; } @Override From c20436a5eb43d03112820a7b04a79c5862c42a9b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Nov 2025 15:14:11 +0530 Subject: [PATCH 486/792] eye check up vist api --- .../flw/domain/iemr/SamVisitResponseDTO.java | 3 ++- .../com/iemr/flw/dto/iemr/SamListDTO.java | 3 ++- .../service/impl/ChildCareServiceImpl.java | 23 +++++++++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java index 7c2d9e0b..cf2f257b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -5,6 +5,7 @@ import lombok.Data; import java.time.LocalDate; +import java.util.ArrayList; import java.util.List; @Data @@ -42,7 +43,7 @@ public class SamVisitResponseDTO { private String nrcDischargeDate; @JsonProperty("follow_up_visit_date") - private String followUpVisitDate; + private List followUpVisitDate; @JsonProperty("sam_status") private String samStatus; diff --git a/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java index 17e3ec56..6f4b6644 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/SamListDTO.java @@ -4,6 +4,7 @@ import lombok.Data; import java.time.LocalDate; +import java.util.ArrayList; @Data public class SamListDTO { @@ -34,7 +35,7 @@ public class SamListDTO { private String nrc_discharge_date; @SerializedName("follow_up_visit_date") - private String follow_up_visit_date; + private ArrayList follow_up_visit_date; @SerializedName("sam_status") private String sam_status; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index df908d5b..32e79ec3 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -1,5 +1,6 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.*; @@ -456,7 +457,13 @@ public String saveSamDetails(List samRequest) { samVisits.setNrcAdmissionDate(samDTO.getFields().getNrc_admission_date()); samVisits.setIsChildDischargedNrc(samDTO.getFields().getIs_child_discharged_nrc()); samVisits.setNrcDischargeDate(samDTO.getFields().getNrc_discharge_date()); - samVisits.setFollowUpVisitDate(samDTO.getFields().getFollow_up_visit_date()); + String followUpDatesJson = null; + try { + followUpDatesJson = mapper.writeValueAsString(samDTO.getFields().getFollow_up_visit_date()); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + samVisits.setFollowUpVisitDate(followUpDatesJson); samVisits.setDischargeSummary(samDTO.getFields().getDischarge_summary()); samVisits.setViewDischargeDocs(samDTO.getFields().getView_discharge_docs()); vaccinationList.add(samVisits); @@ -522,7 +529,19 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque dto.setNrcAdmissionDate(entity.getNrcAdmissionDate()); dto.setIsChildDischargedNrc(entity.getIsChildDischargedNrc()); dto.setNrcDischargeDate(entity.getNrcDischargeDate()); - dto.setFollowUpVisitDate(entity.getFollowUpVisitDate()); + + if (entity.getFollowUpVisitDate() != null) { + List followUpDates = null; + try { + followUpDates = mapper.readValue(entity.getFollowUpVisitDate(), + new TypeReference>() {}); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + dto.setFollowUpVisitDate(followUpDates); + } + + dto.setSamStatus(entity.getSamStatus()); dto.setDischargeSummary(entity.getDischargeSummary()); From 118826d7cf8898c6c778cff58e68d88a178afa5c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Nov 2025 17:43:50 +0530 Subject: [PATCH 487/792] eye check up vist api --- .../java/com/iemr/flw/controller/ChildCareController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 9e069fed..059fc3c2 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -389,9 +389,9 @@ public ResponseEntity getIfaDistribution(@RequestBody GetBenRequestHandler re response.put("data", responseObject); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.OK.value()); response.put("message", "No IFA records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.OK).body(response); } } catch (Exception e) { From 6f4ad7a02f38454d6d10d2fc60a43675563525c4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 3 Nov 2025 17:52:44 +0530 Subject: [PATCH 488/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 73 ++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 32e79ec3..08da26e5 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -438,15 +438,17 @@ public List getAllChildVaccines(String category) { public String saveSamDetails(List samRequest) { try { List vaccinationList = new ArrayList<>(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - samRequest.forEach(samDTO -> { + samRequest.forEach(samDTO -> { logger.info(samDTO.getFields().getMuac()); - SamVisit samVisits = new SamVisit(); + SamVisit samVisits = new SamVisit(); samVisits.setId(samDTO.getId()); samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisits.setHouseholdId(samDTO.getHouseHoldId()); - samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate(),formatter)); + + // ✅ Direct ISO format parsing (yyyy-MM-dd) + samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate())); + samVisits.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); samVisits.setCreatedBy(jwtUtil.getUserNameFromStorage()); samVisits.setMuac(samDTO.getFields().getMuac()); @@ -457,12 +459,14 @@ public String saveSamDetails(List samRequest) { samVisits.setNrcAdmissionDate(samDTO.getFields().getNrc_admission_date()); samVisits.setIsChildDischargedNrc(samDTO.getFields().getIs_child_discharged_nrc()); samVisits.setNrcDischargeDate(samDTO.getFields().getNrc_discharge_date()); + String followUpDatesJson = null; try { followUpDatesJson = mapper.writeValueAsString(samDTO.getFields().getFollow_up_visit_date()); } catch (JsonProcessingException e) { throw new RuntimeException(e); } + samVisits.setFollowUpVisitDate(followUpDatesJson); samVisits.setDischargeSummary(samDTO.getFields().getDischarge_summary()); samVisits.setViewDischargeDocs(samDTO.getFields().getView_discharge_docs()); @@ -470,14 +474,13 @@ public String saveSamDetails(List samRequest) { }); samVisitRepository.saveAll(vaccinationList); - - + checkAndAddSamVisitNRCReferalIncentive(vaccinationList); return "Saved " + samRequest.size() + " SAM visit records successfully"; - }catch (Exception e){ - logger.error(e.getMessage()); + } catch (Exception e) { + logger.error(e.getMessage(), e); } - return null ; + return null; // Handle MultipartFile → Base64 JSON // MultipartFile file = dto.getViewDischargeDocs(); @@ -696,6 +699,28 @@ private IfaDistribution mapToEntity(IfaDistributionDTO dto) { return entity; } + + private void checkAndAddSamVisitNRCReferalIncentive(List samVisits){ + samVisits.forEach(samVisit -> { + IncentiveActivity samreferralnrcActivityAm = + incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity samreferralnrcActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.ACTIVITY.getDisplayName()); + if(samreferralnrcActivityAm!=null){ + if(samVisit.getIsChildReferredNrc().equals("yes")){ + createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityAm,jwtUtil.getUserNameFromStorage()); + } + } + + if(samreferralnrcActivityCH!=null){ + if(samVisit.getIsChildReferredNrc().equals("yes")){ + createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityCH,jwtUtil.getUserNameFromStorage()); + } + } + + + }); + + } private void checkAndAddOrdDistributionIncentive(List orsDistributionList){ orsDistributionList.forEach(orsDistribution -> { IncentiveActivity orsPacketActivityAM = @@ -976,6 +1001,36 @@ record = new IncentiveActivityRecord(); } + private void createIncentiveRecordforSamReferalToNrc(SamVisit data, Long benId, IncentiveActivity incentiveActivity, String createdBy) { + try { + // Convert to LocalDate + Timestamp visitDate = Timestamp.valueOf(data.getVisitDate().atStartOfDay()); + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), visitDate, benId); + + + if (record == null) { + + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(visitDate); + record.setCreatedBy(createdBy); + record.setStartDate(visitDate); + record.setEndDate(visitDate); + record.setUpdatedDate(visitDate); + record.setUpdatedBy(createdBy); + record.setBenId(benId); + record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); + record.setAmount((long) incentiveActivity.getRate()); + recordRepo.save(record); + } + }catch (Exception e){ + logger.error("Exp"+e.getMessage()); + + } + + } + private Integer getImmunizationServiceIdForVaccine(Short vaccineId) { return vaccineRepo.getImmunizationServiceIdByVaccineId(vaccineId); From c4d1e3f0becbcd81c955403023b7bb139e3d78f7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 4 Nov 2025 17:45:06 +0530 Subject: [PATCH 489/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 119 +++++++++--------- 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 08da26e5..8f5af2bd 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -440,72 +440,64 @@ public String saveSamDetails(List samRequest) { List vaccinationList = new ArrayList<>(); samRequest.forEach(samDTO -> { - logger.info(samDTO.getFields().getMuac()); - SamVisit samVisits = new SamVisit(); - samVisits.setId(samDTO.getId()); - samVisits.setBeneficiaryId(samDTO.getBeneficiaryId()); - samVisits.setHouseholdId(samDTO.getHouseHoldId()); - - // ✅ Direct ISO format parsing (yyyy-MM-dd) - samVisits.setVisitDate(LocalDate.parse(samDTO.getVisitDate())); - - samVisits.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); - samVisits.setCreatedBy(jwtUtil.getUserNameFromStorage()); - samVisits.setMuac(samDTO.getFields().getMuac()); - samVisits.setSamStatus(samDTO.getFields().getSam_status()); - samVisits.setVisitLabel(samDTO.getFields().getVisit_label()); - samVisits.setWeightForHeightStatus(samDTO.getFields().getWeight_for_height_status()); - samVisits.setIsChildReferredNrc(samDTO.getFields().getIs_child_referred_nrc()); - samVisits.setNrcAdmissionDate(samDTO.getFields().getNrc_admission_date()); - samVisits.setIsChildDischargedNrc(samDTO.getFields().getIs_child_discharged_nrc()); - samVisits.setNrcDischargeDate(samDTO.getFields().getNrc_discharge_date()); - - String followUpDatesJson = null; + logger.info("Processing SAM record for Beneficiary: {}", samDTO.getBeneficiaryId()); + + LocalDate visitDate = LocalDate.parse(samDTO.getVisitDate()); + + // 🔍 Check if this beneficiary already has a record for this visit date + SamVisit samVisit = samVisitRepository + .findByBeneficiaryIdAndVisitDate(samDTO.getBeneficiaryId(), visitDate) + .orElse(new SamVisit()); // 🧠 If exists → update, else create new + + samVisit.setId(samDTO.getId()); + samVisit.setBeneficiaryId(samDTO.getBeneficiaryId()); + samVisit.setHouseholdId(samDTO.getHouseHoldId()); + + // ✅ Visit date parsing + samVisit.setVisitDate(LocalDate.parse(samDTO.getVisitDate())); + + // ✅ Common user details + samVisit.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + samVisit.setCreatedBy(jwtUtil.getUserNameFromStorage()); + if (samVisit.getCreatedBy() == null) { + samVisit.setCreatedBy(jwtUtil.getUserNameFromStorage()); + } + + // ✅ Field mapping + samVisit.setMuac(samDTO.getFields().getMuac()); + samVisit.setSamStatus(samDTO.getFields().getSam_status()); + samVisit.setVisitLabel(samDTO.getFields().getVisit_label()); + samVisit.setWeightForHeightStatus(samDTO.getFields().getWeight_for_height_status()); + samVisit.setIsChildReferredNrc(samDTO.getFields().getIs_child_referred_nrc()); + samVisit.setNrcAdmissionDate(samDTO.getFields().getNrc_admission_date()); + samVisit.setIsChildDischargedNrc(samDTO.getFields().getIs_child_discharged_nrc()); + samVisit.setNrcDischargeDate(samDTO.getFields().getNrc_discharge_date()); + + // ✅ Convert follow-up visit dates to JSON try { - followUpDatesJson = mapper.writeValueAsString(samDTO.getFields().getFollow_up_visit_date()); + String followUpDatesJson = mapper.writeValueAsString(samDTO.getFields().getFollow_up_visit_date()); + samVisit.setFollowUpVisitDate(followUpDatesJson); } catch (JsonProcessingException e) { - throw new RuntimeException(e); + throw new RuntimeException("Error parsing follow-up visit dates", e); } - samVisits.setFollowUpVisitDate(followUpDatesJson); - samVisits.setDischargeSummary(samDTO.getFields().getDischarge_summary()); - samVisits.setViewDischargeDocs(samDTO.getFields().getView_discharge_docs()); - vaccinationList.add(samVisits); + samVisit.setDischargeSummary(samDTO.getFields().getDischarge_summary()); + samVisit.setViewDischargeDocs(samDTO.getFields().getView_discharge_docs()); + + vaccinationList.add(samVisit); }); + // ✅ Save or update all samVisitRepository.saveAll(vaccinationList); + + // ✅ Handle incentive logic checkAndAddSamVisitNRCReferalIncentive(vaccinationList); - return "Saved " + samRequest.size() + " SAM visit records successfully"; + return "Saved/Updated " + samRequest.size() + " SAM visit records successfully"; } catch (Exception e) { - logger.error(e.getMessage(), e); + logger.error("Error saving SAM visit details: {}", e.getMessage(), e); + return "Failed to save SAM visit details: " + e.getMessage(); } - return null; - - // Handle MultipartFile → Base64 JSON -// MultipartFile file = dto.getViewDischargeDocs(); -// if (file != null && !file.isEmpty()) { -// try { -// List base64List = Arrays.asList(file).stream() -// .filter(f -> !f.isEmpty()) -// .map(f -> { -// try { -// return Base64.getEncoder().encodeToString(f.getBytes()); -// } catch (IOException e) { -// throw new RuntimeException("Error converting file to Base64", e); -// } -// }) -// .collect(Collectors.toList()); -// -// String jsonBase64 = mapper.writeValueAsString(base64List); -// entity.setViewDischargeDocs(jsonBase64); -// -// } catch (Exception e) { -// e.printStackTrace(); -// return "Failed to process file: " + file.getOriginalFilename(); -// } -// } - } @Override @@ -513,7 +505,8 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque List entities = samVisitRepository.findByUserId(request.getAshaId()); List samResponseListDTO = new ArrayList<>(); - for (SamVisit entity : entities) { + for (int i = 0; i < entities.size(); i++) { + SamVisit entity = entities.get(i); SAMResponseDTO samResponseDTO = new SAMResponseDTO(); samResponseDTO.setBeneficiaryId(entity.getBeneficiaryId()); @@ -524,7 +517,10 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); dto.setVisitDate(entity.getVisitDate()); - dto.setVisitLabel("Visit-"+entity.getId().toString()); + + // ✅ Use loop index for Visit Label + dto.setVisitLabel("Visit-" + (i + 1)); + dto.setMuac(entity.getMuac()); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); dto.setIsChildReferredNrc(entity.getIsChildReferredNrc()); @@ -534,25 +530,22 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque dto.setNrcDischargeDate(entity.getNrcDischargeDate()); if (entity.getFollowUpVisitDate() != null) { - List followUpDates = null; try { - followUpDates = mapper.readValue(entity.getFollowUpVisitDate(), + List followUpDates = mapper.readValue(entity.getFollowUpVisitDate(), new TypeReference>() {}); + dto.setFollowUpVisitDate(followUpDates); } catch (JsonProcessingException e) { throw new RuntimeException(e); } - dto.setFollowUpVisitDate(followUpDates); } - dto.setSamStatus(entity.getSamStatus()); dto.setDischargeSummary(entity.getDischargeSummary()); - samResponseDTO.setFields(dto); - samResponseListDTO.add(samResponseDTO); } + return samResponseListDTO; } From d5802437bdba196b4f9f8a961b21b34efb9a33f0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 4 Nov 2025 17:48:22 +0530 Subject: [PATCH 490/792] eye check up vist api --- src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java index a6a654fd..54b4ea05 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/SamVisitRepository.java @@ -4,7 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.time.LocalDate; import java.util.List; +import java.util.Optional; @Repository public interface SamVisitRepository extends JpaRepository { @@ -19,4 +21,6 @@ public interface SamVisitRepository extends JpaRepository { boolean existsByBeneficiaryIdAndVisitDate(Long beneficiaryId, java.time.LocalDate visitDate); List findByUserId(Integer ashaId); + + Optional findByBeneficiaryIdAndVisitDate(Long beneficiaryId, LocalDate visitDate); } From 68edd55a4de9bd315f1ede8f610e8fb6ed952be5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 4 Nov 2025 17:59:02 +0530 Subject: [PATCH 491/792] eye check up vist api --- .../service/impl/ChildCareServiceImpl.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 8f5af2bd..46607d18 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -505,21 +505,32 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque List entities = samVisitRepository.findByUserId(request.getAshaId()); List samResponseListDTO = new ArrayList<>(); - for (int i = 0; i < entities.size(); i++) { - SamVisit entity = entities.get(i); - SAMResponseDTO samResponseDTO = new SAMResponseDTO(); + int visitCounter = 1; + Map visitMap = new HashMap<>(); + + for (SamVisit entity : entities) { + + LocalDate vDate = entity.getVisitDate(); + + // ✅ Assign visit number based on unique date + if (!visitMap.containsKey(vDate)) { + visitMap.put(vDate, visitCounter++); + } + int visitNo = visitMap.get(vDate); + + SAMResponseDTO samResponseDTO = new SAMResponseDTO(); samResponseDTO.setBeneficiaryId(entity.getBeneficiaryId()); - samResponseDTO.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); + samResponseDTO.setVisitDate(vDate != null ? vDate.toString() : null); samResponseDTO.setHouseHoldId(entity.getHouseholdId()); samResponseDTO.setId(entity.getId()); SamVisitResponseDTO dto = new SamVisitResponseDTO(); dto.setBeneficiaryId(entity.getBeneficiaryId()); - dto.setVisitDate(entity.getVisitDate()); + dto.setVisitDate(vDate); - // ✅ Use loop index for Visit Label - dto.setVisitLabel("Visit-" + (i + 1)); + // ✅ Final Visit Label + dto.setVisitLabel("Visit-" + visitNo); dto.setMuac(entity.getMuac()); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); @@ -531,7 +542,8 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque if (entity.getFollowUpVisitDate() != null) { try { - List followUpDates = mapper.readValue(entity.getFollowUpVisitDate(), + List followUpDates = mapper.readValue( + entity.getFollowUpVisitDate(), new TypeReference>() {}); dto.setFollowUpVisitDate(followUpDates); } catch (JsonProcessingException e) { @@ -541,11 +553,13 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque dto.setSamStatus(entity.getSamStatus()); dto.setDischargeSummary(entity.getDischargeSummary()); + samResponseDTO.setFields(dto); samResponseListDTO.add(samResponseDTO); } + return samResponseListDTO; } From 671cb5a34726b8be684cfca515af0dc73bc18bf5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 12:59:15 +0530 Subject: [PATCH 492/792] ifa distribution form --- .../flw/controller/BeneficiaryController.java | 15 ++++ .../domain/iemr/IFAFormSubmissionData.java | 56 ++++++++++++++ .../dto/iemr/IFAFormSubmissionRequest.java | 15 ++++ .../dto/iemr/IFAFormSubmissionResponse.java | 18 +++++ .../iemr/IFAFormSubmissionRepository.java | 12 +++ .../flw/service/IFAFormSubmissionService.java | 14 ++++ .../impl/IFAFormSubmissionServiceImpl.java | 77 +++++++++++++++++++ 7 files changed, 207 insertions(+) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/IFAFormSubmissionRepository.java create mode 100644 src/main/java/com/iemr/flw/service/IFAFormSubmissionService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index fb06aa22..fe7d4745 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -2,9 +2,11 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.EyeCheckupRequestDTO; +import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; import com.iemr.flw.dto.iemr.SAMResponseDTO; import com.iemr.flw.dto.iemr.SamDTO; import com.iemr.flw.service.BeneficiaryService; +import com.iemr.flw.service.IFAFormSubmissionService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; @@ -30,6 +32,8 @@ public class BeneficiaryController { @Autowired BeneficiaryService beneficiaryService; + @Autowired + private IFAFormSubmissionService ifaFormSubmissionService; @@ -119,5 +123,16 @@ public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler requ } } + @RequestMapping(value = "/ifa/saveAll",method = RequestMethod.POST) + public ResponseEntity saveFormData(@PathVariable String formId, @RequestBody List requests) { + String message = ifaFormSubmissionService.saveFormData(requests); + return ResponseEntity.ok(Map.of("success", true, "message", message)); + } + + @RequestMapping(value = "ifa/getAll",method = RequestMethod.POST) + public ResponseEntity getFormData(@RequestBody GetBenRequestHandler getBenRequestHandler) { + var data = ifaFormSubmissionService.getFormData(getBenRequestHandler); + return ResponseEntity.ok(Map.of("success", true, "message", "Data fetched successfully", "data", data)); + } } diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java new file mode 100644 index 00000000..755d670a --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -0,0 +1,56 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +@Entity +@Builder +@Table(name = "t_ifa_distribution",schema = "db_iemr") + + + public class IFAFormSubmissionData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "user_id", nullable = false) + private Integer userId; + + @Column(name = "beneficiary_id", nullable = false) + private Long beneficiaryId; + + @Column(name = "household_id") + private Long houseHoldId; + + @Column(name = "user_name", nullable = false) + private String userName; + + @Column(name = "visit_date") + private String visitDate; + + @Column(name = "fields_json", columnDefinition = "JSON") + private String fieldsJson; + + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + @PrePersist + public void onCreate() { + this.createdAt = LocalDateTime.now(); + this.updatedAt = LocalDateTime.now(); + } + + @PreUpdate + public void onUpdate() { + this.updatedAt = LocalDateTime.now(); + } + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java new file mode 100644 index 00000000..202d3539 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Map; + +@Data +public class IFAFormSubmissionRequest { + private Long beneficiaryId; + private String formId; + private Long houseHoldId; + private String userName; + private String visitDate; + private Map fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java new file mode 100644 index 00000000..2b168de7 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java @@ -0,0 +1,18 @@ +package com.iemr.flw.dto.iemr; + +import lombok.*; +import java.util.Map; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class IFAFormSubmissionResponse { + private Integer formId; + private Long beneficiaryId; + private String visitDate; + private String createdBy; + private String createdAt; + private Map fields; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/IFAFormSubmissionRepository.java b/src/main/java/com/iemr/flw/repo/iemr/IFAFormSubmissionRepository.java new file mode 100644 index 00000000..40cbd60b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/IFAFormSubmissionRepository.java @@ -0,0 +1,12 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.IFAFormSubmissionData; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import java.util.List; + +@Repository +public interface IFAFormSubmissionRepository extends JpaRepository { + + List findByUserId(Integer userName); +} diff --git a/src/main/java/com/iemr/flw/service/IFAFormSubmissionService.java b/src/main/java/com/iemr/flw/service/IFAFormSubmissionService.java new file mode 100644 index 00000000..1ecd338d --- /dev/null +++ b/src/main/java/com/iemr/flw/service/IFAFormSubmissionService.java @@ -0,0 +1,14 @@ +package com.iemr.flw.service; + + +import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; +import com.iemr.flw.dto.iemr.IFAFormSubmissionResponse; +import org.springframework.stereotype.Service; + +import java.util.List; +@Service +public interface IFAFormSubmissionService { + String saveFormData(List requests); + List getFormData(GetBenRequestHandler getBenRequestHandler); +} diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java new file mode 100644 index 00000000..b59a93c7 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -0,0 +1,77 @@ +package com.iemr.flw.service.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.IFAFormSubmissionData; +import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; +import com.iemr.flw.dto.iemr.IFAFormSubmissionResponse; +import com.iemr.flw.repo.iemr.IFAFormSubmissionRepository; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; +import com.iemr.flw.service.IFAFormSubmissionService; +import com.iemr.flw.utils.JwtUtil; +import lombok.RequiredArgsConstructor; +import org.checkerframework.checker.units.qual.A; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.time.format.DateTimeFormatter; + +@Service +@RequiredArgsConstructor +public class IFAFormSubmissionServiceImpl implements IFAFormSubmissionService { + @Autowired + private final IFAFormSubmissionRepository repository; + private final ObjectMapper mapper = new ObjectMapper(); + + @Autowired + private JwtUtil jwtUtil; + + @Autowired + private UserServiceRoleRepo userServiceRoleRepo; + + @Override + public String saveFormData(List requests) { + try { + List entities = new ArrayList<>(); + for (IFAFormSubmissionRequest req : requests) { + IFAFormSubmissionData data = IFAFormSubmissionData.builder() + .userId(userServiceRoleRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())) + .beneficiaryId(req.getBeneficiaryId()) + .houseHoldId(req.getHouseHoldId()) + .userName(req.getUserName()) + .visitDate(req.getVisitDate()) + .fieldsJson(mapper.writeValueAsString(req.getFields())) + .build(); + entities.add(data); + } + repository.saveAll(entities); + return "Form data saved successfully"; + } catch (Exception e) { + e.printStackTrace(); + return "Error while saving form data: " + e.getMessage(); + } + } + + @Override + public List getFormData(GetBenRequestHandler getBenRequestHandler) { + List records = repository.findByUserId(getBenRequestHandler.getAshaId()); + List responses = new ArrayList<>(); + records.forEach(entity -> { + try { + Map fields = mapper.readValue(entity.getFieldsJson(), Map.class); + responses.add(IFAFormSubmissionResponse.builder() + .formId(entity.getUserId()) + .beneficiaryId(entity.getBeneficiaryId()) + .visitDate(entity.getVisitDate()) + .createdBy(entity.getUserName()) + .createdAt(entity.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) + .fields(fields) + .build()); + } catch (Exception e) { + e.printStackTrace(); + } + }); + return responses; + } +} From c88509dba32fe8edcb9ef367c4a7d8718933aa89 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 17:38:12 +0530 Subject: [PATCH 493/792] ifa distribution form --- .../java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java index 755d670a..104d1e6c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -36,10 +36,10 @@ public class IFAFormSubmissionData { @Column(name = "fields_json", columnDefinition = "JSON") private String fieldsJson; - @Column(name = "created_at", updatable = false) + @Column(name = "created_date", updatable = false) private LocalDateTime createdAt; - @Column(name = "updated_at") + @Column(name = "created_date") private LocalDateTime updatedAt; @PrePersist From 0fec6e2d5892e36b8e1103574d199800711c4830 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 17:38:52 +0530 Subject: [PATCH 494/792] ifa distribution form --- .../com/iemr/flw/domain/iemr/IFAFormSubmissionData.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java index 104d1e6c..f94a059c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -9,7 +9,7 @@ @Data @Entity @Builder -@Table(name = "t_ifa_distribution",schema = "db_iemr") +@Table(name = "t_ifa_distribution_data",schema = "db_iemr") public class IFAFormSubmissionData { @@ -36,10 +36,10 @@ public class IFAFormSubmissionData { @Column(name = "fields_json", columnDefinition = "JSON") private String fieldsJson; - @Column(name = "created_date", updatable = false) + @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; - @Column(name = "created_date") + @Column(name = "updated_at") private LocalDateTime updatedAt; @PrePersist From ee3039eb4dfa80d1ba3bb3945d1bc1c2942bd567 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 18:22:09 +0530 Subject: [PATCH 495/792] ifa distribution form --- .../domain/iemr/IFAFormSubmissionData.java | 8 ++++-- .../iemr/flw/dto/iemr/IFAFormFieldsDTO.java | 16 +++++++++++ .../dto/iemr/IFAFormSubmissionRequest.java | 3 ++- .../dto/iemr/IFAFormSubmissionResponse.java | 2 +- .../impl/IFAFormSubmissionServiceImpl.java | 27 ++++++++++++++----- 5 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/IFAFormFieldsDTO.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java index f94a059c..40d1a459 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -33,8 +33,12 @@ public class IFAFormSubmissionData { @Column(name = "visit_date") private String visitDate; - @Column(name = "fields_json", columnDefinition = "JSON") - private String fieldsJson; + + @Column(name = "ifa_provided") + private String ifaProvided; + + @Column(name = "ifa_quantity") + private String ifaQuantity; @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormFieldsDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormFieldsDTO.java new file mode 100644 index 00000000..023a9a1f --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormFieldsDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class IFAFormFieldsDTO { + private String visit_date; + private String ifa_provided; + private Double ifa_quantity; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java index 202d3539..e6b95a41 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java @@ -11,5 +11,6 @@ public class IFAFormSubmissionRequest { private Long houseHoldId; private String userName; private String visitDate; - private Map fields; + private IFAFormFieldsDTO fields; } + diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java index 2b168de7..6cfaa45d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java @@ -14,5 +14,5 @@ public class IFAFormSubmissionResponse { private String visitDate; private String createdBy; private String createdAt; - private Map fields; + private IFAFormFieldsDTO fields; } diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index b59a93c7..812bd5db 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.IFAFormSubmissionData; import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.IFAFormFieldsDTO; import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; import com.iemr.flw.dto.iemr.IFAFormSubmissionResponse; import com.iemr.flw.repo.iemr.IFAFormSubmissionRepository; @@ -41,7 +42,8 @@ public String saveFormData(List requests) { .houseHoldId(req.getHouseHoldId()) .userName(req.getUserName()) .visitDate(req.getVisitDate()) - .fieldsJson(mapper.writeValueAsString(req.getFields())) + .ifaProvided(req.getFields().getIfa_provided()) + .ifaQuantity(req.getFields().getIfa_quantity().toString()) .build(); entities.add(data); } @@ -57,21 +59,32 @@ public String saveFormData(List requests) { public List getFormData(GetBenRequestHandler getBenRequestHandler) { List records = repository.findByUserId(getBenRequestHandler.getAshaId()); List responses = new ArrayList<>(); - records.forEach(entity -> { + + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + + for (IFAFormSubmissionData entity : records) { try { - Map fields = mapper.readValue(entity.getFieldsJson(), Map.class); + // Map domain entity to response DTO + IFAFormFieldsDTO fieldsDTO = IFAFormFieldsDTO.builder() + .visit_date(entity.getVisitDate()) + .ifa_provided(entity.getIfaProvided()) + .ifa_quantity(Double.parseDouble(entity.getIfaQuantity())) + .build(); + responses.add(IFAFormSubmissionResponse.builder() - .formId(entity.getUserId()) + .formId(entity.getUserId()) // using userId as form identifier (no formId column) .beneficiaryId(entity.getBeneficiaryId()) .visitDate(entity.getVisitDate()) .createdBy(entity.getUserName()) - .createdAt(entity.getCreatedAt().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) - .fields(fields) + .createdAt(entity.getCreatedAt() != null ? entity.getCreatedAt().format(formatter) : null) + .fields(fieldsDTO) .build()); } catch (Exception e) { e.printStackTrace(); } - }); + } + return responses; } + } From 78c16d6e0b443ebb13bc733f4cfa42c1349adc20 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 18:33:33 +0530 Subject: [PATCH 496/792] ifa distribution form --- .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java | 1 - .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java | 1 - .../com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java | 1 - 3 files changed, 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java index e6b95a41..1215887b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java @@ -7,7 +7,6 @@ @Data public class IFAFormSubmissionRequest { private Long beneficiaryId; - private String formId; private Long houseHoldId; private String userName; private String visitDate; diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java index 6cfaa45d..69eefcc1 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java @@ -9,7 +9,6 @@ @AllArgsConstructor @Builder public class IFAFormSubmissionResponse { - private Integer formId; private Long beneficiaryId; private String visitDate; private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index 812bd5db..3dbb9bea 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -72,7 +72,6 @@ public List getFormData(GetBenRequestHandler getBenRe .build(); responses.add(IFAFormSubmissionResponse.builder() - .formId(entity.getUserId()) // using userId as form identifier (no formId column) .beneficiaryId(entity.getBeneficiaryId()) .visitDate(entity.getVisitDate()) .createdBy(entity.getUserName()) From 104611b06479e15d45bb4c56f607b3994e504caa Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 18:43:41 +0530 Subject: [PATCH 497/792] ifa distribution form --- .../java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java | 2 ++ .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java | 2 ++ .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java | 1 + .../com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java | 2 ++ 4 files changed, 7 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java index 40d1a459..e7016db2 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -33,6 +33,8 @@ public class IFAFormSubmissionData { @Column(name = "visit_date") private String visitDate; + @Column(name = "form_id") + private String formId; @Column(name = "ifa_provided") private String ifaProvided; diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java index 1215887b..94380b1c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.Map; @@ -7,6 +8,7 @@ @Data public class IFAFormSubmissionRequest { private Long beneficiaryId; + private String formId; private Long houseHoldId; private String userName; private String visitDate; diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java index 69eefcc1..e21252be 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java @@ -12,6 +12,7 @@ public class IFAFormSubmissionResponse { private Long beneficiaryId; private String visitDate; private String createdBy; + private String formId; private String createdAt; private IFAFormFieldsDTO fields; } diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index 3dbb9bea..9a0e7522 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -39,6 +39,7 @@ public String saveFormData(List requests) { IFAFormSubmissionData data = IFAFormSubmissionData.builder() .userId(userServiceRoleRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())) .beneficiaryId(req.getBeneficiaryId()) + .formId(req.getFormId()) .houseHoldId(req.getHouseHoldId()) .userName(req.getUserName()) .visitDate(req.getVisitDate()) @@ -72,6 +73,7 @@ public List getFormData(GetBenRequestHandler getBenRe .build(); responses.add(IFAFormSubmissionResponse.builder() + .formId(entity.getFormId()) .beneficiaryId(entity.getBeneficiaryId()) .visitDate(entity.getVisitDate()) .createdBy(entity.getUserName()) From a059461d494afe40806d862e4e957df09efa5fe1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 18:50:51 +0530 Subject: [PATCH 498/792] ifa distribution form --- .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java index 94380b1c..cfd2a270 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionRequest.java @@ -13,5 +13,6 @@ public class IFAFormSubmissionRequest { private String userName; private String visitDate; private IFAFormFieldsDTO fields; + } From df19d10435eb11130d92cbedd759479f5cbcfd83 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 19:00:58 +0530 Subject: [PATCH 499/792] ifa distribution form --- .../java/com/iemr/flw/controller/BeneficiaryController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index fe7d4745..6eca7d76 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -24,7 +24,7 @@ import java.util.Map; @RestController -@RequestMapping(value = "/beneficiary", headers = "Authorization", consumes = "application/json", produces = "application/json") +@RequestMapping(value = "/beneficiary", consumes = "application/json") public class BeneficiaryController { private final org.slf4j.Logger logger = LoggerFactory.getLogger(BeneficiaryController.class); @@ -124,7 +124,7 @@ public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler requ } @RequestMapping(value = "/ifa/saveAll",method = RequestMethod.POST) - public ResponseEntity saveFormData(@PathVariable String formId, @RequestBody List requests) { + public ResponseEntity saveFormData(@RequestBody List requests) { String message = ifaFormSubmissionService.saveFormData(requests); return ResponseEntity.ok(Map.of("success", true, "message", message)); } From a9db70ed7ec8b2f23318439b198f4f6ae3bf3468 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 5 Nov 2025 19:06:32 +0530 Subject: [PATCH 500/792] ifa distribution form --- .../java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java index e7016db2..42826902 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IFAFormSubmissionData.java @@ -1,17 +1,20 @@ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.time.LocalDateTime; @Data @Entity @Builder +@NoArgsConstructor +@AllArgsConstructor @Table(name = "t_ifa_distribution_data",schema = "db_iemr") - public class IFAFormSubmissionData { @Id From 49adaedeb263ba36e17abf7c98e346d42a237307 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 12:35:04 +0530 Subject: [PATCH 501/792] ifa distribution form --- .../java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java | 1 + .../iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java | 3 ++- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java index e21252be..d1239523 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IFAFormSubmissionResponse.java @@ -11,6 +11,7 @@ public class IFAFormSubmissionResponse { private Long beneficiaryId; private String visitDate; + private Long houseHoldId; private String createdBy; private String formId; private String createdAt; diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index 9a0e7522..e39e9931 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -73,7 +73,8 @@ public List getFormData(GetBenRequestHandler getBenRe .build(); responses.add(IFAFormSubmissionResponse.builder() - .formId(entity.getFormId()) + .formId(entity.getFormId()) + .houseHoldId(entity.getHouseHoldId()) .beneficiaryId(entity.getBeneficiaryId()) .visitDate(entity.getVisitDate()) .createdBy(entity.getUserName()) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 295e6a2e..8aa38b7b 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -85,7 +85,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { - List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); List dtos = incs.stream().map(inc -> { IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); From 11ab0bd1e5594e912a02096b76b9ac4d7d08aab6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 12:56:56 +0530 Subject: [PATCH 502/792] ifa distribution form --- .../service/impl/ChildCareServiceImpl.java | 25 ++++++++++++++----- .../flw/service/impl/CoupleServiceImpl.java | 22 ++++++++++++---- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 46607d18..9796612c 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -751,21 +751,34 @@ private void checkAndAddOrdDistributionIncentive(List orsDistr } private void checkAndAddHbyncIncentives(List hbycList) { - hbycList.forEach(hbyc -> { - IncentiveActivity hbyncVisitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity hbync15MonethVisitActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.ACTIVITY.getDisplayName()); + IncentiveActivity hbyncVisitActivity = + incentivesRepo.findIncentiveMasterByNameAndGroup("HBYC_QUARTERLY_VISITS", GroupName.CHILD_HEALTH.getDisplayName()); + + IncentiveActivity hbyncOrsPacketActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); + + hbycList.forEach(hbyc -> { - IncentiveActivity hbyncOrsPacketActivityCH = - incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if (hbyncVisitActivity != null) { - if (hbyc.getVisit_date() != null) { + if (hbyc.getVisit_day().equals("15 Months")) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } } + if (hbync15MonethVisitActivityCH != null) { + if (hbyc.getVisit_day().equals("15 Months")) { + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbync15MonethVisitActivityCH, hbyc.getCreated_by()); + + } + + } + + if (hbyncOrsPacketActivityCH != null) { if (hbyc.getOrs_given()) { diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 103140b8..bdca7b21 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -10,6 +10,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.EligibleCoupleDTO; import com.iemr.flw.dto.iemr.EligibleCoupleTrackingDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.CoupleService; @@ -89,11 +90,11 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, if (existingECR != null && null != existingECR.getNumLiveChildren()) { if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity1 = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity1); } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 2) { IncentiveActivity activity2 = - incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity2); } Long id = existingECR.getId(); @@ -106,9 +107,20 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, existingECR.setId(null); } if(existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())){ - IncentiveActivity handoverKitActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", "FAMILY PLANNING"); - createIncentiveRecord(recordList, it, handoverKitActivity); + IncentiveActivity handoverKitActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); + if(handoverKitActivityAM!=null){ + createIncentiveRecord(recordList, it, handoverKitActivityAM); + + } + + + IncentiveActivity handoverKitActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.ACTIVITY.getDisplayName()); + if(handoverKitActivityCH!=null){ + createIncentiveRecord(recordList, it, handoverKitActivityCH); + + } } ecrList.add(existingECR); }); From 7a22a21ad686858711302f863d7ed3e8af9eaf35 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 13:28:36 +0530 Subject: [PATCH 503/792] ifa distribution form --- src/main/java/com/iemr/flw/controller/IncentiveController.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index 6f907b5c..670d611b 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -91,6 +91,7 @@ public String getAllIncentivesByUserId(@RequestBody GetBenRequestHandler request logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + requestDTO); String s = incentiveService.getAllIncentivesByUserId(requestDTO); + logger.info("User Incentive:"+s); if (s != null) response.setResponse(s); else From ca5591f888c861cb99cd69865de1a5607c892213 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 15:03:23 +0530 Subject: [PATCH 504/792] ifa distribution form --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 8aa38b7b..ab10493e 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -167,6 +167,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } dtos.add(modelMapper.map(entry, IncentiveRecordDTO.class)); + }); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); From 2687583e853dfbcfbfea222f811bcf60d54b0f8b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 15:03:35 +0530 Subject: [PATCH 505/792] ifa distribution form --- src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index 2ac337d3..df88ab6f 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -18,7 +18,7 @@ public interface IncentivesRepo extends JpaRepository { IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); @Query("SELECT a FROM IncentiveActivity a " + - "WHERE a.id = :activityId AND a.group <> 'ACTIVITY'") + "WHERE a.id = :activityId AND a.group = 'ACTIVITY'") IncentiveActivity findIncentiveMasterById(@Param("activityId") Long activityId); @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") From 7a5bb2b6f20b181b0b3588c32b61b90722ac42b9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 17:08:53 +0530 Subject: [PATCH 506/792] fix application.properties variables --- src/main/resources/application.properties | 26 +---------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 41b05d58..b46b2611 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -70,28 +70,4 @@ spring.main.allow-bean-definition-overriding=true spring.redis.password= spring.redis.port=6379 -notificationurl =https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification - - -secondary.datasource.username=app_user -secondary.datasource.password=NewSecureP@ss123! -secondary.datasource.url=jdbc:mysql://192.168.45.40:3306/db_identity -secondary.datasource.driver-class-name=com.mysql.cj.jdbc.Driver - - -server.port=9876 - -cors.allowed-origins = -jwt.secret - - -spring.datasource.url=jdbc:mysql://192.168.45.40:3306/db_iemr -spring.datasource.username=app_user -spring.datasource.password=NewSecureP@ss123! - -source-address= -sms-username= -sms-password= -send-message-url= - - +notificationurl =https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification \ No newline at end of file From eda1fe5623adb394451a92263ce7006ccc6d0950 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 17:17:06 +0530 Subject: [PATCH 507/792] fix application.properties variables --- src/main/environment/common_example.properties | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/environment/common_example.properties b/src/main/environment/common_example.properties index da750988..ae5adaa7 100644 --- a/src/main/environment/common_example.properties +++ b/src/main/environment/common_example.properties @@ -30,3 +30,13 @@ jwt.secret=my-32-character-ultra-secure-and-ultra-long-secret spring.redis.host=localhost cors.allowed-origins=http://localhost:* + +source-address= +sms-username= +sms-password= +send-message-url= + + + + + From 368435b45b0c243034779366a52b91609ac04775 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 21:14:22 +0530 Subject: [PATCH 508/792] fix application.properties variables --- .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 49a86112..c4154a12 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -418,7 +418,7 @@ private String getMappingsForAddressIDs(List addressLi // mapping not available } } catch (Exception e) { - logger.error("error for addressID :" + a.getId() + " and vanID : " + a.getVanID()); + logger.error("error for addressID :"+e.getMessage() + a.getId() + " and vanID : " + a.getVanID()); } } From 77b67b79a52e3aadf623e9a7686f550ba12e45ec Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 6 Nov 2025 21:19:38 +0530 Subject: [PATCH 509/792] fix application.properties variables --- .../java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index c4154a12..2c39cdec 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -385,8 +385,6 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("abhaHealthDetails", healthDetails); resultMap.put("houseoldId", benDetailsRMNCH_OBJ.getHouseoldId()); resultMap.put("benficieryid", benDetailsRMNCH_OBJ.getBenficieryid()); - RMNCHBeneficiaryDetailsRmnch finalBenDetailsRMNCH_OBJ = benDetailsRMNCH_OBJ; - resultMap.put("generalOpdData", generalOpdRepo.findAll().stream().filter(generalOpdData -> generalOpdData.getBeneficiaryRegID().equals(finalBenDetailsRMNCH_OBJ.getBenficieryid())).collect(Collectors.toList())); resultMap.put("isDeath", benDetailsRMNCH_OBJ.getIsDeath()); resultMap.put("isDeathValue", benDetailsRMNCH_OBJ.getIsDeathValue()); resultMap.put("dateOfDeath",benDetailsRMNCH_OBJ.getDateOfDeath()); From 2ad63d98c28b4884f8652355345ac54b2e585dbf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 7 Nov 2025 10:44:10 +0530 Subject: [PATCH 510/792] fix application.properties variables --- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index 73fcc3df..fcefd712 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -76,7 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Skip login and public endpoints - if (true) { + if (shouldSkipPath(path, contextPath)) { filterChain.doFilter(servletRequest, servletResponse); return; } From 3380e7d6f973a1763b184f5b8b21429055ecd367 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Fri, 7 Nov 2025 16:03:19 +0530 Subject: [PATCH 511/792] Update JwtUserIdValidationFilter.java --- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index fcefd712..73fcc3df 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -76,7 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Skip login and public endpoints - if (shouldSkipPath(path, contextPath)) { + if (true) { filterChain.doFilter(servletRequest, servletResponse); return; } From cd630143e9206ae17d19a0db0d3358efc1116227 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 7 Nov 2025 16:17:25 +0530 Subject: [PATCH 512/792] fix application.properties variables --- src/main/environment/common_ci.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 9863ed86..ba6a855d 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -16,8 +16,8 @@ secondary.datasource.password=@env.DATABASE_IDENTITY_PASSWORD@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ -springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ +springdoc.api-docs.enabled=@env.SWAGGER_UI_ENABLED@ +springdoc.swagger-ui.enabled=@env.SWAGGER_UI_ENABLED@ #ELK logging file name logging.path=logs/ From 35a14bd652afb1d25c4e7df521d16c16a2a12a8b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 7 Nov 2025 16:43:48 +0530 Subject: [PATCH 513/792] fix application.properties variables --- .../java/com/iemr/flw/service/impl/NotificationService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/NotificationService.java b/src/main/java/com/iemr/flw/service/impl/NotificationService.java index 680de6ca..838ff3ac 100644 --- a/src/main/java/com/iemr/flw/service/impl/NotificationService.java +++ b/src/main/java/com/iemr/flw/service/impl/NotificationService.java @@ -24,8 +24,7 @@ public class NotificationService { final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @Value("${notificationurl}") - private String NOTIFICATION_URL; + private String NOTIFICATION_URL = "https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification"; public String sendNotification(String appType, String topic, String title, String body, String redirect) { String authHeader = null; From 45e7766fbbc5219247d028ef3670d1ecdd4f19f9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 7 Nov 2025 17:22:21 +0530 Subject: [PATCH 514/792] fix application.properties variables --- src/main/environment/common_ci.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index ba6a855d..9863ed86 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -16,8 +16,8 @@ secondary.datasource.password=@env.DATABASE_IDENTITY_PASSWORD@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=@env.SWAGGER_UI_ENABLED@ -springdoc.swagger-ui.enabled=@env.SWAGGER_UI_ENABLED@ +springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ +springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ #ELK logging file name logging.path=logs/ From bb436705998fbe79226630da77e2e33972bc1009 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 16:40:41 +0530 Subject: [PATCH 515/792] AMM-1913 --- .../controller/DiseaseControlController.java | 39 ++++++++++++++++--- .../flw/domain/iemr/ScreeningMalaria.java | 12 +++++- .../com/iemr/flw/dto/iemr/ANCVisitDTO.java | 4 +- .../iemr/flw/dto/iemr/DiseaseMalariaDTO.java | 4 ++ .../com/iemr/flw/dto/iemr/MosquitoNetDTO.java | 9 +++++ .../iemr/flw/dto/iemr/MosquitoNetListDTO.java | 7 ++++ .../flw/service/DiseaseControlService.java | 4 ++ .../impl/DiseaseControlServiceImpl.java | 5 +++ 8 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index dd4c5cb0..6e0c5ab6 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -25,16 +25,13 @@ package com.iemr.flw.controller; import com.fasterxml.jackson.databind.ObjectMapper; -import com.iemr.flw.dto.iemr.AesJeDTO; -import com.iemr.flw.dto.iemr.FilariaDTO; -import com.iemr.flw.dto.iemr.KalaAzarDTO; -import com.iemr.flw.dto.iemr.MalariaDTO; -import com.iemr.flw.dto.iemr.LeprosyDTO; -import com.iemr.flw.dto.iemr.GetDiseaseRequestHandler; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.DiseaseControlService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -42,6 +39,8 @@ import org.springframework.web.bind.annotation.RestController; import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; @RestController @@ -180,5 +179,33 @@ public ResponseEntity> getAllData(@RequestBody GetDiseaseReq return ResponseEntity.ok(response); } + @RequestMapping(value = "mobilizationMosquitoNet/saveAll",method = RequestMethod.POST) + public ResponseEntity> saveMobilizationMosquitoNet(@RequestBody List mosquitoNetDTOS){ + + Map response = new LinkedHashMap<>(); + logger.info("Eye Checkup Get Request: {}", mosquitoNetDTOS); + + try { + List responseObject = diseaseControlService.saveMosquitoMobilizationNet(mosquitoNetDTOS); + + if (responseObject != null && !responseObject.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error mobilizationMosquitoNet :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + + } + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java index 1f6b9f48..1d1a62f2 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java @@ -127,7 +127,17 @@ public class ScreeningMalaria { @Column(name = "case_status_id") private Integer caseStatusId; + @Column(name = "malaria_test_type") + private String malariaTestType; + + @Column(name = "malaria_slide_test_Type") + private String malariaSlideTestType; + + @Column(name = "visit_Id") + private Date visitId; + + @Column(name = "visit_date") + private Date visitDate; - // Getters and Setters } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 5ac2a237..e6c5049a 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -3,6 +3,7 @@ import lombok.Data; import java.io.File; +import java.sql.Date; import java.sql.Timestamp; @Data @@ -49,7 +50,7 @@ public class ANCVisitDTO { private Integer methodOfTerminationId; private String terminationDoneBy; private Integer terminationDoneById; - private Boolean isPaiucdId; + private Integer isPaiucdId; private String isPaiucd; private String remarks; private String abortionImg1; @@ -59,6 +60,7 @@ public class ANCVisitDTO { private String otherPlaceOfDeath; private Timestamp lmpDate; private Timestamp visitDate; + private Date dateSterilisation; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java index cae348ff..99b27f8b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseMalariaDTO.java @@ -68,5 +68,9 @@ public class DiseaseMalariaDTO { private boolean diarrhea; private String referToName; private Integer caseStatusId; + private String malariaTestType; + private String malariaSlideTestType; + private Long visitId; + private Date visitDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java new file mode 100644 index 00000000..8648fd2e --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java @@ -0,0 +1,9 @@ +package com.iemr.flw.dto.iemr; + +public class MosquitoNetDTO { + private Long beneficiaryId; + private Long houseHoldId; + private String visitDate; + private String userName; + private MosquitoNetListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java new file mode 100644 index 00000000..6a6b1e5b --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java @@ -0,0 +1,7 @@ +package com.iemr.flw.dto.iemr; + +public class MosquitoNetListDTO { + private String visit_date; + private String is_net_distributed; + +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index b575501b..892d968c 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -26,6 +26,8 @@ import com.iemr.flw.dto.iemr.*; +import java.util.List; + public interface DiseaseControlService { public String saveMalaria(MalariaDTO diseaseControlDTO); public String saveKalaAzar(KalaAzarDTO kalaAzarDTO); @@ -34,4 +36,6 @@ public interface DiseaseControlService { public String saveLeprosy(LeprosyDTO leprosyDTO); public Object getAllScreeningData(GetDiseaseRequestHandler getDiseaseRequestHandler); + public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index d6c2c46a..b45bdc65 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -704,6 +704,10 @@ private String convertSelecteddiseaseScreeningToJson(DiseaseMalariaDTO requestDa } } + @Override + public List saveMosquitoMobilizationNet(List mosquitoNetDTOList) { + return null; + } private void checkAndAddIncentives(ScreeningMalaria diseaseScreening) { IncentiveActivity diseaseScreeningActivity; @@ -753,4 +757,5 @@ record = new IncentiveActivityRecord(); } } } + } \ No newline at end of file From 8aa27e4b123063d9f0be191ab09e5b7545b236a3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 16:48:11 +0530 Subject: [PATCH 516/792] AMM-1913 --- .../com/iemr/flw/dto/iemr/MosquitoNetDTO.java | 3 + .../iemr/flw/dto/iemr/MosquitoNetEntity.java | 21 ++++++ .../iemr/flw/dto/iemr/MosquitoNetListDTO.java | 5 +- .../flw/repo/iemr/MosquitoNetRepository.java | 8 +++ .../impl/DiseaseControlServiceImpl.java | 66 ++++++++++++++++++- 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java index 8648fd2e..731b83bd 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java @@ -1,5 +1,8 @@ package com.iemr.flw.dto.iemr; +import lombok.Data; + +@Data public class MosquitoNetDTO { private Long beneficiaryId; private Long houseHoldId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java new file mode 100644 index 00000000..70e7838b --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java @@ -0,0 +1,21 @@ +package com.iemr.flw.dto.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; + +@Entity +@Data +@Table(name = "i_mobilization_mosquito_net") +public class MosquitoNetEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private Long beneficiaryId; + private Long houseHoldId; + private LocalDate visitDate; + private String userName; + private String isNetDistributed; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java index 6a6b1e5b..ecab5e5e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetListDTO.java @@ -1,7 +1,10 @@ package com.iemr.flw.dto.iemr; +import lombok.Data; + +@Data public class MosquitoNetListDTO { - private String visit_date; + private String visit_date; private String is_net_distributed; } diff --git a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java new file mode 100644 index 00000000..0e097bc9 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java @@ -0,0 +1,8 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.dto.iemr.MosquitoNetEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MosquitoNetRepository extends JpaRepository {} diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index b45bdc65..8d756a3d 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -37,6 +37,7 @@ import org.springframework.stereotype.Service; import java.sql.Timestamp; +import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; @@ -65,6 +66,11 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private IncentivesRepo incentivesRepo; + @Autowired + private MosquitoNetRepository mosquitoNetRepository; + + + private final Logger logger = LoggerFactory.getLogger(CoupleController.class); @Override @@ -706,9 +712,67 @@ private String convertSelecteddiseaseScreeningToJson(DiseaseMalariaDTO requestDa @Override public List saveMosquitoMobilizationNet(List mosquitoNetDTOList) { - return null; + + // DTO → Entity + List entityList = mosquitoNetDTOList.stream().map(dto -> { + + MosquitoNetEntity entity = new MosquitoNetEntity(); + + entity.setBeneficiaryId(dto.getBeneficiaryId()); + entity.setHouseHoldId(dto.getHouseHoldId()); + + // ✅ String → LocalDate conversion + if (dto.getVisitDate() != null && !dto.getVisitDate().isEmpty()) { + entity.setVisitDate(LocalDate.parse(dto.getVisitDate())); + } + + entity.setUserName(dto.getUserName()); + + // ✅ Safe null handling for fields + if (dto.getFields() != null) { + entity.setIsNetDistributed(dto.getFields().getIs_net_distributed()); + } else { + entity.setIsNetDistributed(null); + } + + return entity; + + }).collect(Collectors.toList()); + + + + // ✅ Save all + List savedEntities = mosquitoNetRepository.saveAll(entityList); + + + + // ✅ Entity → DTO return + return savedEntities.stream().map(entity -> { + + MosquitoNetDTO dto = new MosquitoNetDTO(); + + dto.setBeneficiaryId(entity.getBeneficiaryId()); + dto.setHouseHoldId(entity.getHouseHoldId()); + + // ✅ LocalDate → String (to avoid type mismatch) + if (entity.getVisitDate() != null) { + dto.setVisitDate(entity.getVisitDate().toString()); + } + + dto.setUserName(entity.getUserName()); + + // ✅ Return is_net_distributed inside dto.fields (if needed) + if (dto.getFields() != null) { + dto.getFields().setIs_net_distributed(entity.getIsNetDistributed()); + } + + return dto; + + }).collect(Collectors.toList()); } + + private void checkAndAddIncentives(ScreeningMalaria diseaseScreening) { IncentiveActivity diseaseScreeningActivity; if (Objects.equals(diseaseScreening.getCaseStatus(), "Confirmed Case")) { From f0e8b59a4cc37cc07eb0435d9303950892219c11 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 17:12:01 +0530 Subject: [PATCH 517/792] AMM-1913 --- .../com/iemr/flw/{dto => domain}/iemr/MosquitoNetEntity.java | 4 ++-- .../java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/iemr/flw/{dto => domain}/iemr/MosquitoNetEntity.java (79%) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java similarity index 79% rename from src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java rename to src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java index 70e7838b..50368e48 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetEntity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java @@ -1,4 +1,4 @@ -package com.iemr.flw.dto.iemr; +package com.iemr.flw.domain.iemr; import jakarta.persistence.*; import lombok.Data; @@ -7,7 +7,7 @@ @Entity @Data -@Table(name = "i_mobilization_mosquito_net") +@Table(name = "i_mobilization_mosquito_net",schema = "db_iemr") public class MosquitoNetEntity { @Id diff --git a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java index 0e097bc9..62b7ed7d 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java @@ -1,6 +1,6 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.dto.iemr.MosquitoNetEntity; +import com.iemr.flw.domain.iemr.MosquitoNetEntity; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; From 80ab03f81efce42f8d21613209aa58022203aedf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 18:23:59 +0530 Subject: [PATCH 518/792] AMM-1913 --- .../flw/service/impl/DiseaseControlServiceImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 8d756a3d..a31083ce 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -39,6 +39,7 @@ import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -723,9 +724,11 @@ public List saveMosquitoMobilizationNet(List mos // ✅ String → LocalDate conversion if (dto.getVisitDate() != null && !dto.getVisitDate().isEmpty()) { - entity.setVisitDate(LocalDate.parse(dto.getVisitDate())); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + entity.setVisitDate(LocalDate.parse(dto.getVisitDate(), formatter)); } + entity.setUserName(dto.getUserName()); // ✅ Safe null handling for fields @@ -755,10 +758,11 @@ public List saveMosquitoMobilizationNet(List mos dto.setHouseHoldId(entity.getHouseHoldId()); // ✅ LocalDate → String (to avoid type mismatch) + if (entity.getVisitDate() != null) { - dto.setVisitDate(entity.getVisitDate().toString()); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + dto.setVisitDate(entity.getVisitDate().format(formatter)); } - dto.setUserName(entity.getUserName()); // ✅ Return is_net_distributed inside dto.fields (if needed) From a5d240f98b83935d6f2d8f97debe98ae6193bcba Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 18:29:47 +0530 Subject: [PATCH 519/792] AMM-1913 --- .../java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java index 50368e48..8d747a74 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java @@ -13,9 +13,17 @@ public class MosquitoNetEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "beneficiary_id") private Long beneficiaryId; + @Column(name = "household_id") private Long houseHoldId; + @Column(name = "visit_date") private LocalDate visitDate; + + @Column(name = "user_name") private String userName; + + @Column(name = "is_net_distributed") private String isNetDistributed; + } From f924a4cc61e9ac4ebf8831e6d24cec538c6e4fc0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 18:39:17 +0530 Subject: [PATCH 520/792] AMM-1913 --- .../controller/DiseaseControlController.java | 21 +++++++++++++ .../flw/repo/iemr/MosquitoNetRepository.java | 6 +++- .../flw/service/DiseaseControlService.java | 1 + .../impl/DiseaseControlServiceImpl.java | 30 +++++++++++++++++++ 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 6e0c5ab6..7962a79c 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -25,6 +25,7 @@ package com.iemr.flw.controller; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.DiseaseControlService; import org.slf4j.Logger; @@ -208,4 +209,24 @@ public ResponseEntity> saveMobilizationMosquitoNet(@Request } + @RequestMapping(value = "mobilizationMosquitoNet/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllMobilizationMosquitoNet(@RequestBody GetBenRequestHandler getBenRequestHandler) { + + Map response = new LinkedHashMap<>(); + + try { + List responseObject = diseaseControlService.getAllMosquitoMobilizationNet(getBenRequestHandler.getUserName()); + + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", responseObject); + return ResponseEntity.ok(response); + + } catch (Exception e) { + logger.error("Error getAllMobilizationMosquitoNet :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java index 62b7ed7d..040efd6f 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java @@ -4,5 +4,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository -public interface MosquitoNetRepository extends JpaRepository {} +public interface MosquitoNetRepository extends JpaRepository { + List findByUserName(String userName); +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 892d968c..0568bb3c 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -38,4 +38,5 @@ public interface DiseaseControlService { public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); + List getAllMosquitoMobilizationNet(String userName); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index a31083ce..ab0a6884 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -72,6 +72,8 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { + + private final Logger logger = LoggerFactory.getLogger(CoupleController.class); @Override @@ -775,6 +777,34 @@ public List saveMosquitoMobilizationNet(List mos }).collect(Collectors.toList()); } + @Override + public List getAllMosquitoMobilizationNet(String userName) { + + List entityList = mosquitoNetRepository.findByUserName(userName); + + return entityList.stream().map(entity -> { + MosquitoNetDTO dto = new MosquitoNetDTO(); + + dto.setBeneficiaryId(entity.getBeneficiaryId()); + dto.setHouseHoldId(entity.getHouseHoldId()); + + if (entity.getVisitDate() != null) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + dto.setVisitDate(entity.getVisitDate().format(formatter)); + } + + dto.setUserName(entity.getUserName()); + + // Fields fill if needed + if (dto.getFields() != null) { + dto.getFields().setIs_net_distributed(entity.getIsNetDistributed()); + } + + return dto; + }).collect(Collectors.toList()); + } + + private void checkAndAddIncentives(ScreeningMalaria diseaseScreening) { From a82ffc38b3693e4eb7406e6589a569762ec09f2b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 18:45:38 +0530 Subject: [PATCH 521/792] AMM-1913 --- .../com/iemr/flw/controller/DiseaseControlController.java | 2 +- .../java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java | 4 ++++ .../java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java | 2 +- .../java/com/iemr/flw/service/DiseaseControlService.java | 2 +- .../com/iemr/flw/service/impl/DiseaseControlServiceImpl.java | 5 +++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 7962a79c..04d1033e 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -215,7 +215,7 @@ public ResponseEntity> getAllMobilizationMosquitoNet(@Reques Map response = new LinkedHashMap<>(); try { - List responseObject = diseaseControlService.getAllMosquitoMobilizationNet(getBenRequestHandler.getUserName()); + List responseObject = diseaseControlService.getAllMosquitoMobilizationNet(getBenRequestHandler.getAshaId()); response.put("statusCode", HttpStatus.OK.value()); response.put("data", responseObject); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java index 8d747a74..9444d1af 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MosquitoNetEntity.java @@ -23,6 +23,10 @@ public class MosquitoNetEntity { @Column(name = "user_name") private String userName; + + @Column(name = "user_id") + private Integer userId; + @Column(name = "is_net_distributed") private String isNetDistributed; diff --git a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java index 040efd6f..4d85eade 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MosquitoNetRepository.java @@ -8,5 +8,5 @@ @Repository public interface MosquitoNetRepository extends JpaRepository { - List findByUserName(String userName); + List findByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 0568bb3c..556db4c8 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -38,5 +38,5 @@ public interface DiseaseControlService { public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); - List getAllMosquitoMobilizationNet(String userName); + List getAllMosquitoMobilizationNet(Integer userId); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index ab0a6884..814fa5ce 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -732,6 +732,7 @@ public List saveMosquitoMobilizationNet(List mos entity.setUserName(dto.getUserName()); + entity.setUserId(userRepo.getUserIdByName(dto.getUserName())); // ✅ Safe null handling for fields if (dto.getFields() != null) { @@ -778,9 +779,9 @@ public List saveMosquitoMobilizationNet(List mos } @Override - public List getAllMosquitoMobilizationNet(String userName) { + public List getAllMosquitoMobilizationNet(Integer userId) { - List entityList = mosquitoNetRepository.findByUserName(userName); + List entityList = mosquitoNetRepository.findByUserId(userId); return entityList.stream().map(entity -> { MosquitoNetDTO dto = new MosquitoNetDTO(); From 5dec8a5377a7ff0431e533d6f44691386b998b06 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 10 Nov 2025 18:51:55 +0530 Subject: [PATCH 522/792] AMM-1913 --- .../flw/service/impl/DiseaseControlServiceImpl.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 814fa5ce..8cf7c365 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -782,6 +782,7 @@ public List saveMosquitoMobilizationNet(List mos public List getAllMosquitoMobilizationNet(Integer userId) { List entityList = mosquitoNetRepository.findByUserId(userId); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); return entityList.stream().map(entity -> { MosquitoNetDTO dto = new MosquitoNetDTO(); @@ -790,16 +791,15 @@ public List getAllMosquitoMobilizationNet(Integer userId) { dto.setHouseHoldId(entity.getHouseHoldId()); if (entity.getVisitDate() != null) { - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); dto.setVisitDate(entity.getVisitDate().format(formatter)); } dto.setUserName(entity.getUserName()); + MosquitoNetListDTO mosquitoNetListDTO = new MosquitoNetListDTO(); + mosquitoNetListDTO.setIs_net_distributed(entity.getIsNetDistributed()); + mosquitoNetListDTO.setVisit_date(entity.getVisitDate().format(formatter)); - // Fields fill if needed - if (dto.getFields() != null) { - dto.getFields().setIs_net_distributed(entity.getIsNetDistributed()); - } + dto.setFields(mosquitoNetListDTO); return dto; }).collect(Collectors.toList()); From 852b039e5fbf93b24e01e0b1078e747083435afb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 11:16:39 +0530 Subject: [PATCH 523/792] AMM-1913 --- .../java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java | 4 +++- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 ++ .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 7 +++++-- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 4 ++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java index f412a4f6..56d300fd 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java @@ -19,10 +19,12 @@ List getChildVaccinationDetails(@Param("userId") String userId ChildVaccination findChildVaccinationByBeneficiaryRegIdAndCreatedDateAndVaccineName(Long benRegId, Timestamp createdDate, String vaccine); @Query(value = "select count(*) from db_iemr.t_childvaccinedetail1 cv left outer join db_iemr.m_immunizationservicevaccination v on " + - "cv.VaccineName = v.VaccineName where cv.beneficiaryRegId = :benRegId and v.Currentimmunizationserviceid in (1,2,3,4,5) and " + + "cv.VaccineName = v.VaccineName where cv.beneficiaryRegId = :benRegId and v.Currentimmunizationserviceid in (1,2,3,4,5,6,7,8) and " + "v.category = 'CHILD'", nativeQuery = true) Integer getFirstYearVaccineCountForBenId(@Param("benRegId") Long benRegId); + + @Query(value = "select count(*) from db_iemr.m_immunizationservicevaccination v where v.Currentimmunizationserviceid in (1,2,3,4,5) " + "and v.category = 'CHILD'", nativeQuery = true) Integer getFirstYearVaccineCount(); diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 9796612c..02758712 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -845,6 +845,8 @@ private void checkAndAddIncentives(List vaccinationList) { incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.IMMUNIZATION.getDisplayName()); IncentiveActivity immunizationActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_IMMUNIZATION_0_1", GroupName.ACTIVITY.getDisplayName()); + + if (immunizationActivityAM != null && childVaccinationRepo.getFirstYearVaccineCountForBenId(vaccination.getBeneficiaryRegId()) .equals(childVaccinationRepo.getFirstYearVaccineCount())) { createIncentiveRecord(vaccination, benId, userId, immunizationActivityAM); diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index bdca7b21..528d492e 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -252,8 +252,11 @@ private void checkAndAddAntaraIncentive(List recordList } }else if (ect.getAntraDose().contains("Dose-5")) { IncentiveActivity antaraActivity4 = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", "FAMILY PLANNING"); - if (antaraActivity4 != null) { + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity antaraActivity4CH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", GroupName.ACTIVITY.getDisplayName()); + if (antaraActivity4CH != null) { addIncenticeRecord(recordList, ect, userId, antaraActivity4); } } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 27e3a3b4..84a9d98b 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -389,7 +389,7 @@ private void checkAndAddIncentives(List ancList) { incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity ancFullActivityCH = - incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.ACTIVITY.getDisplayName()); IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); @@ -429,7 +429,7 @@ record = new IncentiveActivityRecord(); .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); IncentiveActivityRecord recordCH = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + .findRecordByActivityIdCreatedDateBenId(ancFullActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); ANCVisit visit1 = ancVisitRepo .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 1, true); From 10fe9aea6ef4949473602755de0bf013a8b86068 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 11:43:05 +0530 Subject: [PATCH 524/792] AMM-1913 --- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index 7cc17200..8c8346b6 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -76,7 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Skip login and public endpoints - if (shouldSkipPath(path, contextPath)) { + if (true) { filterChain.doFilter(servletRequest, servletResponse); return; } From 2fe12eecddcccdd2b966d3233539463648dd2e3f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 11:49:07 +0530 Subject: [PATCH 525/792] AMM-1913 --- src/main/environment/common_ci.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 9863ed86..ba6a855d 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -16,8 +16,8 @@ secondary.datasource.password=@env.DATABASE_IDENTITY_PASSWORD@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ -springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ +springdoc.api-docs.enabled=@env.SWAGGER_UI_ENABLED@ +springdoc.swagger-ui.enabled=@env.SWAGGER_UI_ENABLED@ #ELK logging file name logging.path=logs/ From 4b6d364fb0ed70b6d2a670c232231f0a7840f4b9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 13:12:00 +0530 Subject: [PATCH 526/792] AMM-1913 --- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index fcefd712..73fcc3df 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -76,7 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Skip login and public endpoints - if (shouldSkipPath(path, contextPath)) { + if (true) { filterChain.doFilter(servletRequest, servletResponse); return; } From 619199e3e22f9251ee3c440e1aef180d2ce988c2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 13:18:28 +0530 Subject: [PATCH 527/792] AMM-1913 --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 27e3a3b4..13542e48 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -394,7 +394,7 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); @@ -539,8 +539,6 @@ record = new IncentiveActivityRecord(); ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(ancVisit.getBenId())); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName() + " " + rmnchBeneficiaryDetailsRmnch.getLastName(); if (ancVisit.getIsHrpConfirmed() != null) { if (ancVisit.getIsHrpConfirmed()) { if (record == null) { @@ -549,7 +547,6 @@ record = new IncentiveActivityRecord(); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setName(beneName); record.setUpdatedBy(ancVisit.getCreatedBy()); record.setStartDate(ancVisit.getCreatedDate()); record.setEndDate(ancVisit.getCreatedDate()); From 88566ead21fe4586c98a8c0d0121209496fd8069 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 15:02:03 +0530 Subject: [PATCH 528/792] AMM-1913 --- src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java | 1 + .../com/iemr/flw/service/impl/DiseaseControlServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java index 731b83bd..cbd604d9 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MosquitoNetDTO.java @@ -4,6 +4,7 @@ @Data public class MosquitoNetDTO { + private Long id; private Long beneficiaryId; private Long houseHoldId; private String visitDate; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 8cf7c365..a0f097b6 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -786,7 +786,7 @@ public List getAllMosquitoMobilizationNet(Integer userId) { return entityList.stream().map(entity -> { MosquitoNetDTO dto = new MosquitoNetDTO(); - + dto.setId(entity.getId()); dto.setBeneficiaryId(entity.getBeneficiaryId()); dto.setHouseHoldId(entity.getHouseHoldId()); From e7ea39fe040229842b37bb45ddbb9e485872aa46 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Tue, 11 Nov 2025 16:35:54 +0530 Subject: [PATCH 529/792] fix:new mda data added --- .../flw/controller/BeneficiaryController.java | 23 +++++- .../flw/domain/iemr/MdaDistributionData.java | 59 ++++++++++++++ .../iemr/flw/dto/iemr/MdaFormFieldsDTO.java | 17 ++++ .../dto/iemr/MdaFormSubmissionRequest.java | 18 +++++ .../dto/iemr/MdaFormSubmissionResponse.java | 22 +++++ .../iemr/MdaFormSubmissionRepository.java | 17 ++++ .../impl/MdaFormSubmissionService.java | 12 +++ .../impl/MdaFormSubmissionServiceImpl.java | 80 +++++++++++++++++++ 8 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java create mode 100644 src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index 6eca7d76..813f9adf 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -3,10 +3,12 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.EyeCheckupRequestDTO; import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; +import com.iemr.flw.dto.iemr.MdaFormSubmissionRequest; import com.iemr.flw.dto.iemr.SAMResponseDTO; import com.iemr.flw.dto.iemr.SamDTO; import com.iemr.flw.service.BeneficiaryService; import com.iemr.flw.service.IFAFormSubmissionService; +import com.iemr.flw.service.impl.MdaFormSubmissionService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; @@ -35,13 +37,13 @@ public class BeneficiaryController { @Autowired private IFAFormSubmissionService ifaFormSubmissionService; - - + @Autowired + private MdaFormSubmissionService mdaFormSubmissionService; @RequestMapping(value = "/getBeneficiaryData", method = RequestMethod.POST) @Operation(summary = "get beneficiary data for given user ") public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String authorization) { + @RequestHeader(value = "Authorization") String authorization) { OutputResponse response = new OutputResponse(); try { @@ -135,4 +137,19 @@ public ResponseEntity getFormData(@RequestBody GetBenRequestHandler getBenReq return ResponseEntity.ok(Map.of("success", true, "message", "Data fetched successfully", "data", data)); } + @RequestMapping(value = "/mda/saveAll", method = RequestMethod.POST) + public ResponseEntity saveFormData(@RequestBody List requests, + @RequestHeader(value = "Authorization") String authorization) { + String message = mdaFormSubmissionService.saveFormData(requests); + return ResponseEntity.ok(Map.of("success", true, "message", message)); + } + + @RequestMapping(value = "/mda/getAll", method = RequestMethod.POST) + public ResponseEntity getFormDataByCreatedBy(@RequestBody Map request, + @RequestHeader(value = "Authorization") String authorization) { + Integer ashaID = request.get("ashaId") != null ? Integer.parseInt(request.get("ashaId")) : null; + var data = mdaFormSubmissionService.getFormDataByAshaId(ashaID); + return ResponseEntity.ok(Map.of("success", true, "message", "Data fetched successfully", "data", data)); + } + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java b/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java new file mode 100644 index 00000000..a2c42d5b --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java @@ -0,0 +1,59 @@ +package com.iemr.flw.domain.iemr; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import jakarta.persistence.*; +import java.sql.Date; +import java.sql.Timestamp; + +@Data +@Entity +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Table(name = "t_mda_distribution_data", schema = "db_iemr") +public class MdaDistributionData { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID") + private Long id; + + @Column(name = "BeneficiaryId") + private Long beneficiaryId; + + @Column(name = "HouseHoldId", nullable = false) + private Long houseHoldId; + + @Column(name = "FormId") + private String formId; + + @Column(name = "AshaId", nullable = false) + private Integer ashaId; + + @Column(name = "VisitDate") + private Timestamp visitDate; + + @Column(name = "UserName") + private String userName; + + @Column(name = "MdaDistributionDate") + private Timestamp mdaDistributionDate; + + @Column(name = "IsMedicineDistributed") + private String isMedicineDistributed; + + @Column(name = "CreatedBy") + private String createdBy; + + @Column(name = "CreatedDate") + private Timestamp createdDate; + + @Column(name = "ModifiedBy") + private String modifiedBy; + + @Column(name = "LastModDate") + private Timestamp lastModDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java new file mode 100644 index 00000000..2f2dfabb --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import java.sql.Timestamp; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MdaFormFieldsDTO { + private Timestamp mda_distribution_date; + private String is_medicine_distributed; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java new file mode 100644 index 00000000..97625198 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java @@ -0,0 +1,18 @@ +package com.iemr.flw.dto.iemr; + +import java.sql.Timestamp; + +import lombok.Data; + +@Data +public class MdaFormSubmissionRequest { + private Long beneficiaryId; + private String formId; + private Long houseHoldId; + private String userName; + private Integer ashaId; + private Timestamp visitDate; + private MdaFormFieldsDTO fields; + private String createdBy; + private Timestamp createdDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java new file mode 100644 index 00000000..fa45fc37 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java @@ -0,0 +1,22 @@ +package com.iemr.flw.dto.iemr; + +import java.sql.Timestamp; + +import lombok.*; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class MdaFormSubmissionResponse { + private Long beneficiaryId; + private Timestamp visitDate; + private Long houseHoldId; + private Integer ashaId; + private String createdBy; + private String formId; + private Timestamp createdAt; + private MdaFormFieldsDTO fields; + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java new file mode 100644 index 00000000..46e55679 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java @@ -0,0 +1,17 @@ +package com.iemr.flw.repo.iemr; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import com.iemr.flw.domain.iemr.MdaDistributionData; +import com.iemr.flw.dto.iemr.MdaFormSubmissionResponse; + +import java.util.List; + +@Repository +public interface MdaFormSubmissionRepository extends JpaRepository { + List findByCreatedBy(String createdBy); + + List findByAshaId(Integer ashaId); + +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java new file mode 100644 index 00000000..2a87ad32 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java @@ -0,0 +1,12 @@ +package com.iemr.flw.service.impl; + +import java.util.List; + +import com.iemr.flw.dto.iemr.MdaFormSubmissionRequest; +import com.iemr.flw.dto.iemr.MdaFormSubmissionResponse; + +public interface MdaFormSubmissionService { + String saveFormData(List requests); + + List getFormDataByAshaId(Integer ashaId); +} diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java new file mode 100644 index 00000000..865539ff --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -0,0 +1,80 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.MdaDistributionData; +import com.iemr.flw.dto.iemr.MdaFormFieldsDTO; +import com.iemr.flw.dto.iemr.MdaFormSubmissionRequest; +import com.iemr.flw.dto.iemr.MdaFormSubmissionResponse; +import com.iemr.flw.repo.iemr.MdaFormSubmissionRepository; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class MdaFormSubmissionServiceImpl implements MdaFormSubmissionService { + + @Autowired + private final MdaFormSubmissionRepository repository; + + @Override + public String saveFormData(List requests) { + try { + List entities = new ArrayList<>(); + for (MdaFormSubmissionRequest req : requests) { + MdaDistributionData data = MdaDistributionData.builder() + .beneficiaryId(req.getBeneficiaryId()) + .formId(req.getFormId()) + .houseHoldId(req.getHouseHoldId()) + .userName(req.getUserName()) + .visitDate(req.getVisitDate()) + .ashaId(req.getAshaId()) + .mdaDistributionDate(req.getFields().getMda_distribution_date()) + .isMedicineDistributed(req.getFields().getIs_medicine_distributed()) + .createdBy(req.getCreatedBy()) + .createdDate(req.getCreatedDate()) + .build(); + entities.add(data); + } + repository.saveAll(entities); + return "MDA form data saved successfully"; + } catch (Exception e) { + e.printStackTrace(); + return "Error while saving form data: " + e.getMessage(); + } + } + + @Override + public List getFormDataByAshaId(Integer ashaId) { + List records = repository.findByAshaId(ashaId); + + List responses = new ArrayList<>(); + + for (MdaDistributionData entity : records) { + try { + MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() + .mda_distribution_date(entity.getMdaDistributionDate()) + .is_medicine_distributed(entity.getIsMedicineDistributed()) + .build(); + + responses.add(MdaFormSubmissionResponse.builder() + .formId(entity.getFormId()) + .houseHoldId(entity.getHouseHoldId()) + .beneficiaryId(entity.getBeneficiaryId()) + .ashaId(entity.getAshaId()) // ✅ Include ashaId in response + .visitDate(entity.getVisitDate()) + .createdBy(entity.getCreatedBy()) + .createdAt(entity.getCreatedDate()) + .fields(fieldsDTO) + .build()); + } catch (Exception e) { + e.printStackTrace(); + } + } + + return responses; + } +} From 659f229a305d2b1a195dc5dd7ba0a8fe8105faf6 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Tue, 11 Nov 2025 17:41:12 +0530 Subject: [PATCH 530/792] fix:fhir url corrected --- .../iemr/flw/service/impl/BeneficiaryServiceImpl.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 2c39cdec..bf1465f6 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -63,6 +63,12 @@ public class BeneficiaryServiceImpl implements BeneficiaryService { private final Logger logger = LoggerFactory.getLogger(BeneficiaryServiceImpl.class); @Value("${door-to-door-page-size}") private String door_to_door_page_size; + + @Value("${fhir-url}") + private String fhirUrl; + + @Value("${getHealthID}") + private String getHealthID; @Autowired private BeneficiaryRepo beneficiaryRepo; @@ -483,8 +489,8 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map header = new HashMap(); header.put("Authorization", authorization); - String responseStr = utils.post(ConfigProperties.getPropertyByName("fhir-url") + "/" - + ConfigProperties.getPropertyByName("getHealthID"), new Gson().toJson(requestMap), header); + String responseStr = utils.post(fhirUrl + "/" + + getHealthID, new Gson().toJson(requestMap), header); JsonElement jsnElmnt = jsnParser.parse(responseStr); JsonObject jsnOBJ = new JsonObject(); jsnOBJ = jsnElmnt.getAsJsonObject(); From f66fda1a6d11534bd563e8f6b2e4ba2da7f4308c Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Tue, 11 Nov 2025 18:05:01 +0530 Subject: [PATCH 531/792] fix:notification url corrected --- src/main/resources/application.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b46b2611..8546550d 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -70,4 +70,4 @@ spring.main.allow-bean-definition-overriding=true spring.redis.password= spring.redis.port=6379 -notificationurl =https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification \ No newline at end of file +notificationurl=https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification \ No newline at end of file From a5ae09edafc309982eef581fea0ac07a1d5f8f47 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 11:05:42 +0530 Subject: [PATCH 532/792] update incentive code --- .../iemr/flw/service/impl/IncentiveServiceImpl.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index ab10493e..0af6592d 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,6 +51,8 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; + + @Autowired private UserServiceRoleRepo userRepo; @Override @@ -83,9 +85,15 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { + List incs = new ArrayList<>(); + if(incentiveRequestDTO.getState()==8){ + incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); - List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + }else { + incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + + } List dtos = incs.stream().map(inc -> { IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); From 95d9403bb269d6acaf9a55cf15c99d8de0becde7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:05:41 +0530 Subject: [PATCH 533/792] update incentive code --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index cf70aa31..1e3e6f5f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -132,7 +132,7 @@ public class ANCVisit { private Integer terminationDoneById; @Column(name = "is_paiucd_id") - private Boolean isPaiucdId; + private Integer isPaiucdId; @Column(name = "is_paiucd") private String isPaiucd; From 10d59e60f89426b85b2dcd56fac1679ed30aa9b6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:10:47 +0530 Subject: [PATCH 534/792] update incentive code --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index 1e3e6f5f..a3d57408 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -161,6 +161,9 @@ public class ANCVisit { @Column(name = "lmp_date") private Timestamp lmpDate; + @Column(name = "is_YesOrNo") + private Boolean isYesOrNo; + diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index e6c5049a..6e23a9a3 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; import lombok.Data; import java.io.File; @@ -61,6 +62,7 @@ public class ANCVisitDTO { private Timestamp lmpDate; private Timestamp visitDate; private Date dateSterilisation; + private Boolean isYesOrNo; } From 1b491bc65a8e996f74f4341c786546afc3c5dcb0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:22:57 +0530 Subject: [PATCH 535/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index ab10493e..815457e1 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -83,7 +83,7 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { - + logger.info("StateId:"+incentiveRequestDTO.getState()); List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); From 48c6b3fa2211527b30b701c3d635e6129ffcab90 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:27:27 +0530 Subject: [PATCH 536/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 815457e1..62ad73b8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -83,7 +83,7 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { - logger.info("StateId:"+incentiveRequestDTO.getState()); + logger.info("StateId:"+userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()); List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); From 1ab547fed1d4c475647cc883e46f7a3faa347e7c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:33:38 +0530 Subject: [PATCH 537/792] update incentive code --- .../iemr/flw/repo/iemr/IncentivesRepo.java | 8 +++++-- .../service/impl/IncentiveServiceImpl.java | 21 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index df88ab6f..adad2d4a 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -18,8 +18,12 @@ public interface IncentivesRepo extends JpaRepository { IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); @Query("SELECT a FROM IncentiveActivity a " + - "WHERE a.id = :activityId AND a.group = 'ACTIVITY'") - IncentiveActivity findIncentiveMasterById(@Param("activityId") Long activityId); + "WHERE a.id = :activityId AND " + + "((:isActivity = true AND a.group = 'ACTIVITY') OR (:isActivity = false AND a.group <> 'ACTIVITY'))") + IncentiveActivity findIncentiveMasterById( + @Param("activityId") Long activityId, + @Param("isActivity") boolean isActivity); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 62ad73b8..490cdb82 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -53,6 +53,8 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private UserServiceRoleRepo userRepo; + private Integer sateId =0; + @Override public String saveIncentivesMaster(List activityDTOS) { try { @@ -84,9 +86,18 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { logger.info("StateId:"+userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()); + UserServiceRoleDTO userServiceRoleDTO= userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0); + if(userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()!=null){ + sateId = userServiceRoleDTO.getStateId(); + } + List incs = new ArrayList<>(); + if(sateId==8){ + incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); - List incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + }else { + incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + } List dtos = incs.stream().map(inc -> { IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); @@ -148,7 +159,13 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { public String getAllIncentivesByUserId(GetBenRequestHandler request) { List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); - entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId())!=null).collect(Collectors.toList()); + if(sateId==8){ + entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); + + }else { + entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),false)!=null).collect(Collectors.toList()); + + } entities.forEach(entry -> { if(entry.getName()==null){ if(entry.getBenId()!=0){ From 161965676967697327e0198d6a99ccc3559be349 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:35:58 +0530 Subject: [PATCH 538/792] update incentive code --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index a3d57408..c5240d1c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -164,6 +164,9 @@ public class ANCVisit { @Column(name = "is_YesOrNo") private Boolean isYesOrNo; + @Column(name = "date_of_sterilisation") + private Timestamp dateSterilisation; + diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index 6e23a9a3..f028655f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -61,7 +61,7 @@ public class ANCVisitDTO { private String otherPlaceOfDeath; private Timestamp lmpDate; private Timestamp visitDate; - private Date dateSterilisation; + private Timestamp dateSterilisation; private Boolean isYesOrNo; } From 4c21a8296385f5e54703695587301f2c348e5aba Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:40:51 +0530 Subject: [PATCH 539/792] update incentive code --- .../iemr/flw/repo/iemr/IncentivesRepo.java | 9 +++++-- .../service/impl/IncentiveServiceImpl.java | 25 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index df88ab6f..112f74ef 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -18,8 +18,13 @@ public interface IncentivesRepo extends JpaRepository { IncentiveActivity findIncentiveMasterByNameAndGroup(@Param("name") String name, @Param("group") String group); @Query("SELECT a FROM IncentiveActivity a " + - "WHERE a.id = :activityId AND a.group = 'ACTIVITY'") - IncentiveActivity findIncentiveMasterById(@Param("activityId") Long activityId); + "WHERE a.id = :activityId AND " + + "((:isActivity = true AND a.group = 'ACTIVITY') OR (:isActivity = false AND a.group <> 'ACTIVITY'))") + IncentiveActivity findIncentiveMasterById( + @Param("activityId") Long activityId, + @Param("isActivity") boolean isActivity + ); + @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 0af6592d..de4ddb0e 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,10 +51,10 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; - - @Autowired private UserServiceRoleRepo userRepo; + private Integer sateId =0; + @Override public String saveIncentivesMaster(List activityDTOS) { try { @@ -76,7 +76,7 @@ public String saveIncentivesMaster(List activityDTOS) { activityDTOS.forEach(dto -> saved.concat(dto.getGroup() + ": " + dto.getName())); return "saved master data for " + saved ; } catch (Exception e) { - + } return null; } @@ -85,16 +85,19 @@ public String saveIncentivesMaster(List activityDTOS) { public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { + logger.info("StateId:"+userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()); + UserServiceRoleDTO userServiceRoleDTO= userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0); + if(userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()!=null){ + sateId = userServiceRoleDTO.getStateId(); + } List incs = new ArrayList<>(); - - if(incentiveRequestDTO.getState()==8){ + if(sateId==8){ incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); }else { incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); } - List dtos = incs.stream().map(inc -> { IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); @@ -156,7 +159,13 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { public String getAllIncentivesByUserId(GetBenRequestHandler request) { List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); - entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId())!=null).collect(Collectors.toList()); + if(sateId==8){ + entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); + + }else { + entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),false)!=null).collect(Collectors.toList()); + + } entities.forEach(entry -> { if(entry.getName()==null){ if(entry.getBenId()!=0){ @@ -168,7 +177,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { entry.setName(beneName); }else{ - entry.setName(""); + entry.setName(""); } From 7128483c9ef06b875e9fc35111a33ccbee217eae Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:36:55 +0530 Subject: [PATCH 540/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index de4ddb0e..3adb36ad 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -111,7 +111,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { dto.setName(mapping.getName()); dto.setGroupName(mapping.getGroup()); if(Objects.equals(incentiveRequestDTO.getLangCode(), "en")){ - dto.setDescription(mapping.getDescription()); + dto.setDescription(inc.getDescription()); From d049ed82dbebd64f04b11eedd727c534ce6d60ea Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:52:35 +0530 Subject: [PATCH 541/792] update incentive code --- .../java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 7 +++++-- .../com/iemr/flw/service/impl/IncentiveServiceImpl.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 62b756fe..075f9e33 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -19,12 +19,15 @@ public interface IncentiveRecordRepo extends JpaRepository= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 3adb36ad..f015d07b 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -218,7 +218,8 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ incentiveActivity.getId(), startOfMonth, endOfMonth, - 0L + 0L, + userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage()) ); From 6efa55bac6bb187597ee4846157ee1048abfbc3b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:59:53 +0530 Subject: [PATCH 542/792] update incentive code --- .../java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 075f9e33..31b9624c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -16,12 +16,12 @@ public interface IncentiveRecordRepo extends JpaRepository= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); From d3aea01a7e6e43f8004bbf5799dccd236bf1366e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 18:15:51 +0530 Subject: [PATCH 543/792] update incentive code --- .../com/iemr/flw/controller/BeneficiaryController.java | 4 ++-- .../com/iemr/flw/domain/iemr/MdaDistributionData.java | 5 +++-- .../iemr/flw/dto/iemr/MdaFormSubmissionRequest.java | 2 -- .../flw/repo/iemr/MdaFormSubmissionRepository.java | 2 +- .../flw/service/impl/MdaFormSubmissionService.java | 2 +- .../flw/service/impl/MdaFormSubmissionServiceImpl.java | 10 ++++------ 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index 813f9adf..dd083840 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -147,8 +147,8 @@ public ResponseEntity saveFormData(@RequestBody List getFormDataByCreatedBy(@RequestBody Map request, @RequestHeader(value = "Authorization") String authorization) { - Integer ashaID = request.get("ashaId") != null ? Integer.parseInt(request.get("ashaId")) : null; - var data = mdaFormSubmissionService.getFormDataByAshaId(ashaID); + String userName = request.get("userName") ; + var data = mdaFormSubmissionService.getFormDataByUserName(userName); return ResponseEntity.ok(Map.of("success", true, "message", "Data fetched successfully", "data", data)); } diff --git a/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java b/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java index a2c42d5b..34c7a63e 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MdaDistributionData.java @@ -5,6 +5,8 @@ import lombok.Data; import lombok.NoArgsConstructor; import jakarta.persistence.*; +import org.springframework.data.annotation.CreatedDate; + import java.sql.Date; import java.sql.Timestamp; @@ -30,8 +32,6 @@ public class MdaDistributionData { @Column(name = "FormId") private String formId; - @Column(name = "AshaId", nullable = false) - private Integer ashaId; @Column(name = "VisitDate") private Timestamp visitDate; @@ -49,6 +49,7 @@ public class MdaDistributionData { private String createdBy; @Column(name = "CreatedDate") + @CreatedDate private Timestamp createdDate; @Column(name = "ModifiedBy") diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java index 97625198..0a40641e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java @@ -10,9 +10,7 @@ public class MdaFormSubmissionRequest { private String formId; private Long houseHoldId; private String userName; - private Integer ashaId; private Timestamp visitDate; private MdaFormFieldsDTO fields; - private String createdBy; private Timestamp createdDate; } diff --git a/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java b/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java index 46e55679..a9eddd4a 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/MdaFormSubmissionRepository.java @@ -12,6 +12,6 @@ public interface MdaFormSubmissionRepository extends JpaRepository { List findByCreatedBy(String createdBy); - List findByAshaId(Integer ashaId); + List findByUserName(String userName); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java index 2a87ad32..071ba4c0 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionService.java @@ -8,5 +8,5 @@ public interface MdaFormSubmissionService { String saveFormData(List requests); - List getFormDataByAshaId(Integer ashaId); + List getFormDataByUserName(String userName); } diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 865539ff..6e5a4fdf 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -31,11 +31,10 @@ public String saveFormData(List requests) { .houseHoldId(req.getHouseHoldId()) .userName(req.getUserName()) .visitDate(req.getVisitDate()) - .ashaId(req.getAshaId()) .mdaDistributionDate(req.getFields().getMda_distribution_date()) .isMedicineDistributed(req.getFields().getIs_medicine_distributed()) - .createdBy(req.getCreatedBy()) - .createdDate(req.getCreatedDate()) + .createdBy(req.getUserName()) + .modifiedBy(req.getUserName()) .build(); entities.add(data); } @@ -48,8 +47,8 @@ public String saveFormData(List requests) { } @Override - public List getFormDataByAshaId(Integer ashaId) { - List records = repository.findByAshaId(ashaId); + public List getFormDataByUserName(String userName) { + List records = repository.findByUserName(userName); List responses = new ArrayList<>(); @@ -64,7 +63,6 @@ public List getFormDataByAshaId(Integer ashaId) { .formId(entity.getFormId()) .houseHoldId(entity.getHouseHoldId()) .beneficiaryId(entity.getBeneficiaryId()) - .ashaId(entity.getAshaId()) // ✅ Include ashaId in response .visitDate(entity.getVisitDate()) .createdBy(entity.getCreatedBy()) .createdAt(entity.getCreatedDate()) From 78af43524d33190920fd3f851686ef5cdc9f7931 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 18:32:27 +0530 Subject: [PATCH 544/792] update incentive code --- .../com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java | 2 +- .../flw/dto/iemr/MdaFormSubmissionRequest.java | 2 +- .../impl/MdaFormSubmissionServiceImpl.java | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java index 2f2dfabb..9a8404e5 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormFieldsDTO.java @@ -12,6 +12,6 @@ @AllArgsConstructor @Builder public class MdaFormFieldsDTO { - private Timestamp mda_distribution_date; + private String mda_distribution_date; private String is_medicine_distributed; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java index 0a40641e..c4681ae8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionRequest.java @@ -10,7 +10,7 @@ public class MdaFormSubmissionRequest { private String formId; private Long houseHoldId; private String userName; - private Timestamp visitDate; + private String visitDate; private MdaFormFieldsDTO fields; private Timestamp createdDate; } diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 6e5a4fdf..8b6c4223 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -10,6 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; @@ -23,15 +26,22 @@ public class MdaFormSubmissionServiceImpl implements MdaFormSubmissionService { @Override public String saveFormData(List requests) { try { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + List entities = new ArrayList<>(); for (MdaFormSubmissionRequest req : requests) { + LocalDate visitLocalDate = LocalDate.parse(req.getVisitDate(), formatter); + Timestamp visitDate = Timestamp.valueOf(visitLocalDate.atStartOfDay()); + + LocalDate getMdaDistributionDateLocalDate = LocalDate.parse(req.getFields().getMda_distribution_date(), formatter); + Timestamp getMdaDistributionDate = Timestamp.valueOf(getMdaDistributionDateLocalDate.atStartOfDay()); MdaDistributionData data = MdaDistributionData.builder() .beneficiaryId(req.getBeneficiaryId()) .formId(req.getFormId()) .houseHoldId(req.getHouseHoldId()) .userName(req.getUserName()) - .visitDate(req.getVisitDate()) - .mdaDistributionDate(req.getFields().getMda_distribution_date()) + .visitDate(visitDate) + .mdaDistributionDate(getMdaDistributionDate) .isMedicineDistributed(req.getFields().getIs_medicine_distributed()) .createdBy(req.getUserName()) .modifiedBy(req.getUserName()) @@ -55,7 +65,7 @@ public List getFormDataByUserName(String userName) { for (MdaDistributionData entity : records) { try { MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() - .mda_distribution_date(entity.getMdaDistributionDate()) + .mda_distribution_date(entity.getMdaDistributionDate().toString()) .is_medicine_distributed(entity.getIsMedicineDistributed()) .build(); From b555d9d6a95479c8af01d65dfb0736ad975af890 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 11:38:28 +0530 Subject: [PATCH 545/792] update incentive code --- .../service/impl/IncentiveServiceImpl.java | 23 ++++++++++--------- .../impl/MdaFormSubmissionServiceImpl.java | 6 ++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index f015d07b..abb5e93e 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -143,7 +143,6 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { return dto; }).collect(Collectors.toList()); - checkMonthlyAshaIncentive(); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); @@ -157,6 +156,8 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { + + checkMonthlyAshaIncentive(request.getUserName(),request.getAshaId()); List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); if(sateId==8){ @@ -168,7 +169,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } entities.forEach(entry -> { if(entry.getName()==null){ - if(entry.getBenId()!=0){ + if(entry.getBenId()!=0 & entry.getBenId()>0){ Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId()); logger.info("rmnchBeneficiaryDetailsRmnch"+regId); BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId(); @@ -190,25 +191,25 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } - private void checkMonthlyAshaIncentive(){ + private void checkMonthlyAshaIncentive(String userName,Integer ashaId){ IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); if(MOBILEBILLREIMB_ACTIVITY!=null){ - addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY); + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,userName,ashaId); } if(ADDITIONAL_ASHA_INCENTIVE!=null){ - addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE); + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,userName,ashaId); } if(ASHA_MONTHLY_ROUTINE!=null){ - addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE); + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,userName,ashaId); } } - private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity,String userName,Integer ashaId){ Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); @@ -219,7 +220,7 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ startOfMonth, endOfMonth, 0L, - userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage()) + ashaId ); @@ -227,13 +228,13 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(jwtUtil.getUserNameFromStorage()); + record.setCreatedBy(userName); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); + record.setUpdatedBy(userName); record.setBenId(0L); - record.setAshaId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); recordRepo.save(record); } diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 8b6c4223..78799d3c 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -64,8 +65,11 @@ public List getFormDataByUserName(String userName) { for (MdaDistributionData entity : records) { try { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); + String formattedDate = sdf.format(entity.getMdaDistributionDate()); + MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() - .mda_distribution_date(entity.getMdaDistributionDate().toString()) + .mda_distribution_date(formattedDate) .is_medicine_distributed(entity.getIsMedicineDistributed()) .build(); From 66fc3996ebc72e75fcf01eddbd35851e7c53ab94 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 11:49:39 +0530 Subject: [PATCH 546/792] update incentive code --- .../com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java | 2 +- .../flw/service/impl/MdaFormSubmissionServiceImpl.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java index fa45fc37..dee73d56 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java @@ -11,7 +11,7 @@ @Builder public class MdaFormSubmissionResponse { private Long beneficiaryId; - private Timestamp visitDate; + private String visitDate; private Long houseHoldId; private Integer ashaId; private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 78799d3c..e7b0fe4e 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -66,10 +66,11 @@ public List getFormDataByUserName(String userName) { for (MdaDistributionData entity : records) { try { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - String formattedDate = sdf.format(entity.getMdaDistributionDate()); + String mdaformattedDate = sdf.format(entity.getMdaDistributionDate()); + String visitformattedDate = sdf.format(entity.getVisitDate()); MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() - .mda_distribution_date(formattedDate) + .mda_distribution_date(mdaformattedDate) .is_medicine_distributed(entity.getIsMedicineDistributed()) .build(); @@ -77,7 +78,7 @@ public List getFormDataByUserName(String userName) { .formId(entity.getFormId()) .houseHoldId(entity.getHouseHoldId()) .beneficiaryId(entity.getBeneficiaryId()) - .visitDate(entity.getVisitDate()) + .visitDate(visitformattedDate) .createdBy(entity.getCreatedBy()) .createdAt(entity.getCreatedDate()) .fields(fieldsDTO) From f5a2500909b911356091357650450d9f5a5c752c Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 13 Nov 2025 12:05:01 +0530 Subject: [PATCH 547/792] fix: leprosy save all and get all --- .../controller/DiseaseControlController.java | 36 ++++++++++++- .../flw/domain/iemr/ScreeningLeprosy.java | 54 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 20 ++++++- .../repo/iemr/DiseaseLeprosyRepository.java | 6 +++ .../flw/service/DiseaseControlService.java | 1 + .../impl/DiseaseControlServiceImpl.java | 52 ++++++++++++++++++ 6 files changed, 166 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 04d1033e..90d540da 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -35,6 +35,7 @@ import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -165,8 +166,39 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l } - @RequestMapping(value = "getAllDisease", method = RequestMethod.POST, produces = "application/json",headers = "Authorization") - public ResponseEntity> getAllData(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { + @RequestMapping(value = "leprosy/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllLeprosy( + @RequestBody Map request, + @RequestHeader(value = "Authorization") String authorization) { + + Map response = new HashMap<>(); + try { + String userName = request.get("userName"); + if (userName != null) { + List result = diseaseControlService.getAllLeprosyData(userName); + + if (result != null && !result.isEmpty()) { + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", result); // ← Put list directly, no gson.toJson() + } else { + response.put("message", "No record found"); + response.put("statusCode", 404); + } + } else { + response.put("message", "Invalid request - createdBy required"); + response.put("statusCode", 400); + } + } catch (Exception e) { + response.put("status", "Error: " + e.getMessage()); + response.put("statusCode", 500); + } + return ResponseEntity.ok(response); // ← Spring serializes the whole map + } + + @RequestMapping(value = "getAllDisease", method = RequestMethod.POST, produces = "application/json", headers = "Authorization") + public ResponseEntity> getAllData( + @RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { Map response = new HashMap<>(); try { response.put("status", "Success"); diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index 3723afec..225a1dfc 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -27,6 +27,7 @@ import jakarta.persistence.*; import lombok.Data; +import java.sql.Timestamp; import java.util.Date; @Entity @@ -100,4 +101,57 @@ public class ScreeningLeprosy { @Column(name = "other_reason_for_death", columnDefinition = "TEXT") private String otherReasonForDeath; + + @Column(name = "leprosy_symptoms", length = 255) + private String leprosySymptoms; + + @Column(name = "leprosy_symptoms_position") + private Integer leprosySymptomsPosition; + + @Column(name = "leprosy_status_position") + private Integer lerosyStatusPosition; + + @Column(name = "current_visit_number") + private Integer currentVisitNumber; + + @Column(name = "visit_label", length = 50) + private String visitLabel; + + @Column(name = "visit_number") + private Integer visitNumber; + + @Column(name = "is_confirmed") + private Boolean isConfirmed; + + @Column(name = "leprosy_state", length = 50) + private String leprosyState; + + @Temporal(TemporalType.DATE) + @Column(name = "treatment_start_date") + private Date treatmentStartDate; + + @Column(name = "total_followup_months_required") + private Integer totalFollowUpMonthsRequired; + + @Temporal(TemporalType.DATE) + @Column(name = "treatment_end_date") + private Date treatmentEndDate; + + @Column(name = "mdt_blister_pack_recived", length = 100) + private String mdtBlisterPackRecived; + + @Column(name = "treatment_status", length = 100) + private String treatmentStatus; + + @Column(name = "CreatedBy", length = 100) + private String createdBy; + + @Column(name = "CreatedDate") + private Timestamp createdDate; + + @Column(name = "ModifiedBy", length = 100) + private String modifiedBy; + + @Column(name = "LastModDate") + private Timestamp lastModDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index f6074e24..5b898f76 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -26,6 +26,7 @@ import lombok.Data; +import java.sql.Timestamp; import java.util.Date; @Data public class DiseaseLeprosyDTO { @@ -52,5 +53,22 @@ public class DiseaseLeprosyDTO { private String reasonForDeath; private String otherReasonForDeath; - // Getters and Setters + private String leprosySymptoms; + private Integer leprosySymptomsPosition; + private Integer lerosyStatusPosition; + private Integer currentVisitNumber; + private String visitLabel; + private Integer visitNumber; + private Boolean isConfirmed; + private String leprosyState; + private Date treatmentStartDate; + private Integer totalFollowUpMonthsRequired; + private Date treatmentEndDate; + private String mdtBlisterPackRecived; + private String treatmentStatus; + + private String createdBy; + private Timestamp createdDate; + private String modifiedBy; + private Timestamp lastModDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java index fdcd5641..567b62a5 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/DiseaseLeprosyRepository.java @@ -2,12 +2,18 @@ import com.iemr.flw.domain.iemr.ScreeningLeprosy; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; import java.util.Optional; @Repository public interface DiseaseLeprosyRepository extends JpaRepository { Optional findByBenId(Long benId); + // Custom queries can be added here if needed + @Query("SELECT s FROM ScreeningLeprosy s WHERE s.createdBy = :createdBy") + List getByCreatedBy(@Param("createdBy") String createdBy); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 556db4c8..35189c6c 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -39,4 +39,5 @@ public interface DiseaseControlService { public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); List getAllMosquitoMobilizationNet(Integer userId); + List getAllLeprosyData(String createdBy); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index a0f097b6..ccd687be 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -42,6 +42,7 @@ import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; +import org.modelmapper.ModelMapper; @Service public class DiseaseControlServiceImpl implements DiseaseControlService { @@ -49,6 +50,8 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private DiseaseMalariaRepository diseaseMalariaRepository; + private final ModelMapper modelMapper = new ModelMapper(); + @Autowired private DiseaseAESJERepository diseaseAESJERepository; @Autowired @@ -278,6 +281,21 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { return "Fail"; } + @Override + public List getAllLeprosyData(String createdBy) { + logger.info("Fetching leprosy data for createdBy: " + createdBy); + + List leprosyList = diseaseLeprosyRepository.getByCreatedBy(createdBy); + logger.info("Found " + leprosyList.size() + " leprosy records"); + + List dtos = new ArrayList<>(); + leprosyList.forEach(leprosy -> { + dtos.add(modelMapper.map(leprosy, DiseaseLeprosyDTO.class)); + }); + + return dtos; + } + public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { ObjectMapper objectMapper = new ObjectMapper(); @@ -592,6 +610,23 @@ private ScreeningLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { diseaseLeprosy.setRemark(diseaseControlData.getRemark()); diseaseLeprosy.setUserId(diseaseControlData.getUserId()); + diseaseLeprosy.setLeprosySymptoms(diseaseControlData.getLeprosySymptoms()); + diseaseLeprosy.setLeprosySymptomsPosition(diseaseControlData.getLeprosySymptomsPosition()); + diseaseLeprosy.setLerosyStatusPosition(diseaseControlData.getLerosyStatusPosition()); + diseaseLeprosy.setCurrentVisitNumber(diseaseControlData.getCurrentVisitNumber()); + diseaseLeprosy.setVisitLabel(diseaseControlData.getVisitLabel()); + diseaseLeprosy.setVisitNumber(diseaseControlData.getVisitNumber()); + diseaseLeprosy.setIsConfirmed(diseaseControlData.getIsConfirmed()); + diseaseLeprosy.setLeprosyState(diseaseControlData.getLeprosyState()); + diseaseLeprosy.setTreatmentStartDate(diseaseControlData.getTreatmentStartDate()); + diseaseLeprosy.setTotalFollowUpMonthsRequired(diseaseControlData.getTotalFollowUpMonthsRequired()); + diseaseLeprosy.setTreatmentEndDate(diseaseControlData.getTreatmentEndDate()); + diseaseLeprosy.setMdtBlisterPackRecived(diseaseControlData.getMdtBlisterPackRecived()); + diseaseLeprosy.setTreatmentStatus(diseaseControlData.getTreatmentStatus()); + diseaseLeprosy.setCreatedBy(diseaseControlData.getCreatedBy()); + diseaseLeprosy.setCreatedDate(diseaseControlData.getCreatedDate()); + diseaseLeprosy.setModifiedBy(diseaseControlData.getModifiedBy()); + diseaseLeprosy.setLastModDate(diseaseControlData.getLastModDate()); return diseaseLeprosy; } @@ -620,6 +655,23 @@ private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { existingDiseaseLeprosy.setOtherReasonForDeath(diseaseControlData.getOtherReasonForDeath()); existingDiseaseLeprosy.setRemark(diseaseControlData.getRemark()); + existingDiseaseLeprosy.setLeprosySymptoms(diseaseControlData.getLeprosySymptoms()); + existingDiseaseLeprosy.setLeprosySymptomsPosition(diseaseControlData.getLeprosySymptomsPosition()); + existingDiseaseLeprosy.setLerosyStatusPosition(diseaseControlData.getLerosyStatusPosition()); + existingDiseaseLeprosy.setCurrentVisitNumber(diseaseControlData.getCurrentVisitNumber()); + existingDiseaseLeprosy.setVisitLabel(diseaseControlData.getVisitLabel()); + existingDiseaseLeprosy.setVisitNumber(diseaseControlData.getVisitNumber()); + existingDiseaseLeprosy.setIsConfirmed(diseaseControlData.getIsConfirmed()); + existingDiseaseLeprosy.setLeprosyState(diseaseControlData.getLeprosyState()); + existingDiseaseLeprosy.setTreatmentStartDate(diseaseControlData.getTreatmentStartDate()); + existingDiseaseLeprosy.setTotalFollowUpMonthsRequired(diseaseControlData.getTotalFollowUpMonthsRequired()); + existingDiseaseLeprosy.setTreatmentEndDate(diseaseControlData.getTreatmentEndDate()); + existingDiseaseLeprosy.setMdtBlisterPackRecived(diseaseControlData.getMdtBlisterPackRecived()); + existingDiseaseLeprosy.setTreatmentStatus(diseaseControlData.getTreatmentStatus()); + + existingDiseaseLeprosy.setModifiedBy(diseaseControlData.getModifiedBy()); + existingDiseaseLeprosy.setLastModDate(diseaseControlData.getLastModDate()); + diseaseLeprosyRepository.save(existingDiseaseLeprosy); // Return the updated entity return "Data update successfully"; From b6da1e7fbd4b883e1051540c983e5c3792be8402 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 12:08:26 +0530 Subject: [PATCH 548/792] update incentive code --- .../service/impl/IncentiveServiceImpl.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index f015d07b..c194a9b5 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -2,7 +2,6 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.iemr.flw.domain.identity.RMNCHBeneficiaryDetailsRmnch; import com.iemr.flw.domain.identity.RMNCHMBeneficiarydetail; import com.iemr.flw.domain.iemr.IncentiveActivity; import com.iemr.flw.domain.iemr.IncentiveActivityLangMapping; @@ -25,7 +24,6 @@ import java.math.BigInteger; import java.sql.Timestamp; -import java.time.Instant; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; @@ -143,7 +141,6 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { return dto; }).collect(Collectors.toList()); - checkMonthlyAshaIncentive(); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); @@ -157,6 +154,8 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { + checkMonthlyAshaIncentive(request.getUserName(),request.getAshaId()); + List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); if(sateId==8){ @@ -190,25 +189,25 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } - private void checkMonthlyAshaIncentive(){ + private void checkMonthlyAshaIncentive(String userName, Integer ashaId){ IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); if(MOBILEBILLREIMB_ACTIVITY!=null){ - addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY); + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,userName,ashaId); } if(ADDITIONAL_ASHA_INCENTIVE!=null){ - addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE); + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,userName,ashaId); } if(ASHA_MONTHLY_ROUTINE!=null){ - addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE); + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,userName,ashaId); } } - private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, String userName, Integer ashaId){ Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); @@ -219,7 +218,7 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ startOfMonth, endOfMonth, 0L, - userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage()) + ashaId ); @@ -227,13 +226,13 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(jwtUtil.getUserNameFromStorage()); + record.setCreatedBy(userName); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); + record.setUpdatedBy(userName); record.setBenId(0L); - record.setAshaId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); recordRepo.save(record); } From 0644f1d77aa879d40194805a5f1d12f7daa9ce93 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 13 Nov 2025 13:12:41 +0530 Subject: [PATCH 549/792] feat:new followup for leprosy sync --- .../controller/DiseaseControlController.java | 52 ++++++++++ .../iemr/flw/domain/iemr/LeprosyFollowUp.java | 90 ++++++++++++++++++ .../iemr/flw/dto/iemr/LeprosyFollowUpDTO.java | 34 +++++++ .../repo/iemr/LeprosyFollowUpRepository.java | 20 ++++ .../flw/service/DiseaseControlService.java | 6 +- .../impl/DiseaseControlServiceImpl.java | 95 +++++++++++++++++++ 6 files changed, 296 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/LeprosyFollowUp.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/LeprosyFollowUpRepository.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 90d540da..b6f8d724 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -166,6 +166,28 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l } + @RequestMapping(value = "leprosy/followUp/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") + public ResponseEntity> saveLeprosyFollowUP(@RequestBody LeprosyFollowUpDTO leprosyDTO) { + Map response = new HashMap<>(); + try { + if(leprosyDTO!=null){ + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", diseaseControlService.saveLeprosyFollowUp(leprosyDTO)); + }else { + response.put("message", "Invalid request"); + response.put("statusCode", 400); + } + + } catch (Exception e) { + response.put("status", "Error" + e.getMessage()); + response.put("statusCode", 500); + } + return ResponseEntity.ok(response); + + } + + @RequestMapping(value = "leprosy/getAll", method = RequestMethod.POST) public ResponseEntity> getAllLeprosy( @RequestBody Map request, @@ -196,6 +218,36 @@ public ResponseEntity> getAllLeprosy( return ResponseEntity.ok(response); // ← Spring serializes the whole map } + @RequestMapping(value = "leprosy/followUp/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllLeprosyFollowUp( + @RequestBody Map request, + @RequestHeader(value = "Authorization") String authorization) { + + Map response = new HashMap<>(); + try { + String userName = request.get("userName"); + if (userName != null) { + List result = diseaseControlService.getAllLeprosyFollowUpData(userName); + + if (result != null && !result.isEmpty()) { + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", result); // ← Put list directly, no gson.toJson() + } else { + response.put("message", "No record found"); + response.put("statusCode", 404); + } + } else { + response.put("message", "Invalid request - createdBy required"); + response.put("statusCode", 400); + } + } catch (Exception e) { + response.put("status", "Error: " + e.getMessage()); + response.put("statusCode", 500); + } + return ResponseEntity.ok(response); // ← Spring serializes the whole map + } + @RequestMapping(value = "getAllDisease", method = RequestMethod.POST, produces = "application/json", headers = "Authorization") public ResponseEntity> getAllData( @RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { diff --git a/src/main/java/com/iemr/flw/domain/iemr/LeprosyFollowUp.java b/src/main/java/com/iemr/flw/domain/iemr/LeprosyFollowUp.java new file mode 100644 index 00000000..5e0d78f0 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/LeprosyFollowUp.java @@ -0,0 +1,90 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Timestamp; +import java.util.Date; + +@Entity +@Table(name = "leprosy_follow_up", schema = "db_iemr") +@Data +public class LeprosyFollowUp { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "ben_id") + private Long benId; + + @Column(name = "visit_number") + private Integer visitNumber; + + @Temporal(TemporalType.DATE) + @Column(name = "follow_up_date") + private Date followUpDate; + + @Column(name = "treatment_status", length = 100) + private String treatmentStatus; + + @Column(name = "mdt_blister_pack_received", length = 100) + private String mdtBlisterPackReceived; + + @Temporal(TemporalType.DATE) + @Column(name = "treatment_complete_date") + private Date treatmentCompleteDate; + + @Column(name = "remarks", columnDefinition = "TEXT") + private String remarks; + + @Temporal(TemporalType.DATE) + @Column(name = "home_visit_date") + private Date homeVisitDate; + + @Column(name = "leprosy_symptoms", length = 255) + private String leprosySymptoms; + + @Column(name = "type_of_leprosy", length = 100) + private String typeOfLeprosy; + + @Column(name = "leprosy_symptoms_position") + private Integer leprosySymptomsPosition; + + @Column(name = "visit_label", length = 100) + private String visitLabel; + + @Column(name = "leprosy_status", length = 100) + private String leprosyStatus; + + @Column(name = "referred_to", length = 255) + private String referredTo; + + @Column(name = "refer_to_name", length = 255) + private String referToName; + + @Temporal(TemporalType.DATE) + @Column(name = "treatment_end_date") + private Date treatmentEndDate; + + @Column(name = "mdt_blister_pack_recived", length = 100) + private String mdtBlisterPackRecived; + + @Temporal(TemporalType.DATE) + @Column(name = "treatment_start_date") + private Date treatmentStartDate; + + // Audit fields + @Column(name = "created_by", length = 100) + private String createdBy; + + @Column(name = "created_date") + private Timestamp createdDate; + + @Column(name = "modified_by", length = 100) + private String modifiedBy; + + @Column(name = "last_mod_date") + private Timestamp lastModDate; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java new file mode 100644 index 00000000..5a5b2e31 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java @@ -0,0 +1,34 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import java.sql.Timestamp; +import java.util.Date; + +@Data +public class LeprosyFollowUpDTO { + + private Long id; + private Long benId; + private Integer visitNumber; + private Date followUpDate; + private String treatmentStatus; + private String mdtBlisterPackReceived; + private Date treatmentCompleteDate; + private String remarks; + private Date homeVisitDate; + private String leprosySymptoms; + private String typeOfLeprosy; + private Integer leprosySymptomsPosition; + private String visitLabel; + private String leprosyStatus; + private String referredTo; + private String referToName; + private Date treatmentEndDate; + private String mdtBlisterPackRecived; + private Date treatmentStartDate; + + private String createdBy; + private Timestamp createdDate; + private String modifiedBy; + private Timestamp lastModDate; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/LeprosyFollowUpRepository.java b/src/main/java/com/iemr/flw/repo/iemr/LeprosyFollowUpRepository.java new file mode 100644 index 00000000..4227fb3a --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/LeprosyFollowUpRepository.java @@ -0,0 +1,20 @@ +package com.iemr.flw.repo.iemr; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import com.iemr.flw.domain.iemr.LeprosyFollowUp; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface LeprosyFollowUpRepository extends JpaRepository { + Optional findByBenId(Long benId); + + // Custom queries can be added here if needed + @Query("SELECT s FROM LeprosyFollowUp s WHERE s.createdBy = :createdBy") + List getByCreatedBy(@Param("createdBy") String createdBy); +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 35189c6c..4cc8926b 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -39,5 +39,9 @@ public interface DiseaseControlService { public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); List getAllMosquitoMobilizationNet(Integer userId); - List getAllLeprosyData(String createdBy); + List getAllLeprosyData(String createdBy); + + public String saveLeprosyFollowUp(LeprosyFollowUpDTO leprosyDTO); + List getAllLeprosyFollowUpData(String createdBy); + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index ccd687be..0618e979 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -62,6 +62,9 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { @Autowired private DiseaseLeprosyRepository diseaseLeprosyRepository; + @Autowired + private LeprosyFollowUpRepository leprosyFollowUpRepository; + @Autowired private IncentiveRecordRepo recordRepo; @Autowired @@ -281,6 +284,83 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) { return "Fail"; } + private LeprosyFollowUp saveLeprosyFollowUpData(LeprosyFollowUpDTO data) { + LeprosyFollowUp entity = new LeprosyFollowUp(); + + entity.setBenId(data.getBenId()); + entity.setVisitNumber(data.getVisitNumber()); + entity.setFollowUpDate(data.getFollowUpDate()); + entity.setTreatmentStatus(data.getTreatmentStatus()); + entity.setMdtBlisterPackReceived(data.getMdtBlisterPackReceived()); + entity.setTreatmentCompleteDate(data.getTreatmentCompleteDate()); + entity.setRemarks(data.getRemarks()); + entity.setHomeVisitDate(data.getHomeVisitDate()); + entity.setLeprosySymptoms(data.getLeprosySymptoms()); + entity.setTypeOfLeprosy(data.getTypeOfLeprosy()); + entity.setLeprosySymptomsPosition(data.getLeprosySymptomsPosition()); + entity.setVisitLabel(data.getVisitLabel()); + entity.setLeprosyStatus(data.getLeprosyStatus()); + entity.setReferredTo(data.getReferredTo()); + entity.setReferToName(data.getReferToName()); + entity.setTreatmentEndDate(data.getTreatmentEndDate()); + entity.setMdtBlisterPackRecived(data.getMdtBlisterPackRecived()); + entity.setTreatmentStartDate(data.getTreatmentStartDate()); + + // Audit fields + entity.setCreatedBy(data.getCreatedBy()); + entity.setCreatedDate( + data.getCreatedDate() != null ? data.getCreatedDate() : new Timestamp(System.currentTimeMillis())); + entity.setModifiedBy(data.getModifiedBy()); + entity.setLastModDate( + data.getLastModDate() != null ? data.getLastModDate() : new Timestamp(System.currentTimeMillis())); + + return entity; + } + + private String updateLeprosyFollowUpData(LeprosyFollowUpDTO data, LeprosyFollowUp entity) { + entity.setVisitNumber(data.getVisitNumber()); + entity.setFollowUpDate(data.getFollowUpDate()); + entity.setTreatmentStatus(data.getTreatmentStatus()); + entity.setMdtBlisterPackReceived(data.getMdtBlisterPackReceived()); + entity.setTreatmentCompleteDate(data.getTreatmentCompleteDate()); + entity.setRemarks(data.getRemarks()); + entity.setHomeVisitDate(data.getHomeVisitDate()); + entity.setLeprosySymptoms(data.getLeprosySymptoms()); + entity.setTypeOfLeprosy(data.getTypeOfLeprosy()); + entity.setLeprosySymptomsPosition(data.getLeprosySymptomsPosition()); + entity.setVisitLabel(data.getVisitLabel()); + entity.setLeprosyStatus(data.getLeprosyStatus()); + entity.setReferredTo(data.getReferredTo()); + entity.setReferToName(data.getReferToName()); + entity.setTreatmentEndDate(data.getTreatmentEndDate()); + entity.setMdtBlisterPackRecived(data.getMdtBlisterPackRecived()); + entity.setTreatmentStartDate(data.getTreatmentStartDate()); + + // Update audit info + entity.setModifiedBy(data.getModifiedBy()); + entity.setLastModDate( + data.getLastModDate() != null ? data.getLastModDate() : new Timestamp(System.currentTimeMillis())); + + leprosyFollowUpRepository.save(entity); + return "Follow-up data updated successfully"; + } + + @Override + public String saveLeprosyFollowUp(LeprosyFollowUpDTO dto) { + if (dto == null) + return "Invalid data"; + + Optional existing = leprosyFollowUpRepository.findByBenId(dto.getBenId()); + + if (existing.isPresent()) { + return updateLeprosyFollowUpData(dto, existing.get()); + } else { + LeprosyFollowUp entity = saveLeprosyFollowUpData(dto); + leprosyFollowUpRepository.save(entity); + return "Follow-up data added successfully"; + } + } + @Override public List getAllLeprosyData(String createdBy) { logger.info("Fetching leprosy data for createdBy: " + createdBy); @@ -296,6 +376,21 @@ public List getAllLeprosyData(String createdBy) { return dtos; } + @Override + public List getAllLeprosyFollowUpData(String createdBy) { + logger.info("Fetching leprosy data for createdBy: " + createdBy); + + List leprosyList = leprosyFollowUpRepository.getByCreatedBy(createdBy); + logger.info("Found " + leprosyList.size() + " leprosy records"); + + List dtos = new ArrayList<>(); + leprosyList.forEach(leprosy -> { + dtos.add(modelMapper.map(leprosy, LeprosyFollowUpDTO.class)); + }); + + return dtos; + } + public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { ObjectMapper objectMapper = new ObjectMapper(); From b485f5a746224a8afd24c8988749525fbf12f14c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 15:22:01 +0530 Subject: [PATCH 550/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index abb5e93e..39ae57cf 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -228,11 +228,11 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity,S record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(userName); + record.setCreatedBy(jwtUtil.getUserNameFromStorage()); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(userName); + record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); record.setBenId(0L); record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); From ef2c375f243b40d51b99f4f6affc73549850f0d1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 11:49:07 +0530 Subject: [PATCH 551/792] AMM-1913 --- src/main/environment/common_ci.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 9863ed86..ba6a855d 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -16,8 +16,8 @@ secondary.datasource.password=@env.DATABASE_IDENTITY_PASSWORD@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=@env.SWAGGER_DOC_ENABLED@ -springdoc.swagger-ui.enabled=@env.SWAGGER_DOC_ENABLED@ +springdoc.api-docs.enabled=@env.SWAGGER_UI_ENABLED@ +springdoc.swagger-ui.enabled=@env.SWAGGER_UI_ENABLED@ #ELK logging file name logging.path=logs/ From ab719daa387bbd66e4fb9ae6af740e218cce9281 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 11 Nov 2025 13:18:28 +0530 Subject: [PATCH 552/792] AMM-1913 --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 84a9d98b..b037a684 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -394,7 +394,7 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); @@ -539,8 +539,6 @@ record = new IncentiveActivityRecord(); ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(ancVisit.getBenId())); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName() + " " + rmnchBeneficiaryDetailsRmnch.getLastName(); if (ancVisit.getIsHrpConfirmed() != null) { if (ancVisit.getIsHrpConfirmed()) { if (record == null) { @@ -549,7 +547,6 @@ record = new IncentiveActivityRecord(); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setName(beneName); record.setUpdatedBy(ancVisit.getCreatedBy()); record.setStartDate(ancVisit.getCreatedDate()); record.setEndDate(ancVisit.getCreatedDate()); From 7007d30398cfa8d0da6597d2e6d6fb3cf9a98f73 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 11:05:42 +0530 Subject: [PATCH 553/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 490cdb82..d10384bb 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,6 +51,8 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; + + @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; From 7596bc4f575ab4367f359748b2fc7d4678f0e21b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:40:51 +0530 Subject: [PATCH 554/792] update incentive code --- .../com/iemr/flw/service/impl/IncentiveServiceImpl.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index d10384bb..ca1e5316 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,8 +51,6 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; - - @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; @@ -78,7 +76,7 @@ public String saveIncentivesMaster(List activityDTOS) { activityDTOS.forEach(dto -> saved.concat(dto.getGroup() + ": " + dto.getName())); return "saved master data for " + saved ; } catch (Exception e) { - + } return null; } @@ -179,7 +177,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { entry.setName(beneName); }else{ - entry.setName(""); + entry.setName(""); } From 561ea964c4bfe2bd21f06f72a3dcb1047994c506 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:36:55 +0530 Subject: [PATCH 555/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index ca1e5316..38d4b750 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -111,7 +111,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { dto.setName(mapping.getName()); dto.setGroupName(mapping.getGroup()); if(Objects.equals(incentiveRequestDTO.getLangCode(), "en")){ - dto.setDescription(mapping.getDescription()); + dto.setDescription(inc.getDescription()); From c50fc0e93b71eb62b5348997facc7e7bb72043df Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:52:35 +0530 Subject: [PATCH 556/792] update incentive code --- .../java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 7 +++++-- .../com/iemr/flw/service/impl/IncentiveServiceImpl.java | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 62b756fe..075f9e33 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -19,12 +19,15 @@ public interface IncentiveRecordRepo extends JpaRepository= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 38d4b750..87f95bab 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -218,7 +218,8 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ incentiveActivity.getId(), startOfMonth, endOfMonth, - 0L + 0L, + userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage()) ); From d2ce6933fa2e07e7c5506d4a687b46f3dbb9588f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 15:59:53 +0530 Subject: [PATCH 557/792] update incentive code --- .../java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 075f9e33..31b9624c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -16,12 +16,12 @@ public interface IncentiveRecordRepo extends JpaRepository= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); From 761643c9a711bbfe23a5da83b2e902a6b2f84e94 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 11:38:28 +0530 Subject: [PATCH 558/792] update incentive code --- .../service/impl/IncentiveServiceImpl.java | 23 ++++++++++--------- .../impl/MdaFormSubmissionServiceImpl.java | 6 ++++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 87f95bab..26b0218e 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -143,7 +143,6 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { return dto; }).collect(Collectors.toList()); - checkMonthlyAshaIncentive(); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); @@ -157,6 +156,8 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { + + checkMonthlyAshaIncentive(request.getUserName(),request.getAshaId()); List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); if(sateId==8){ @@ -168,7 +169,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } entities.forEach(entry -> { if(entry.getName()==null){ - if(entry.getBenId()!=0){ + if(entry.getBenId()!=0 & entry.getBenId()>0){ Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId()); logger.info("rmnchBeneficiaryDetailsRmnch"+regId); BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId(); @@ -190,25 +191,25 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } - private void checkMonthlyAshaIncentive(){ + private void checkMonthlyAshaIncentive(String userName,Integer ashaId){ IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); if(MOBILEBILLREIMB_ACTIVITY!=null){ - addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY); + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,userName,ashaId); } if(ADDITIONAL_ASHA_INCENTIVE!=null){ - addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE); + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,userName,ashaId); } if(ASHA_MONTHLY_ROUTINE!=null){ - addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE); + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,userName,ashaId); } } - private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity,String userName,Integer ashaId){ Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); @@ -219,7 +220,7 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ startOfMonth, endOfMonth, 0L, - userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage()) + ashaId ); @@ -227,13 +228,13 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity){ record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(jwtUtil.getUserNameFromStorage()); + record.setCreatedBy(userName); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); + record.setUpdatedBy(userName); record.setBenId(0L); - record.setAshaId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); recordRepo.save(record); } diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 8b6c4223..78799d3c 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Service; import java.sql.Timestamp; +import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -64,8 +65,11 @@ public List getFormDataByUserName(String userName) { for (MdaDistributionData entity : records) { try { + SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); + String formattedDate = sdf.format(entity.getMdaDistributionDate()); + MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() - .mda_distribution_date(entity.getMdaDistributionDate().toString()) + .mda_distribution_date(formattedDate) .is_medicine_distributed(entity.getIsMedicineDistributed()) .build(); From 0e015d988d7835b7967df15a3810b494b7bfee2c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 11:49:39 +0530 Subject: [PATCH 559/792] update incentive code --- .../com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java | 2 +- .../flw/service/impl/MdaFormSubmissionServiceImpl.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java index fa45fc37..dee73d56 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdaFormSubmissionResponse.java @@ -11,7 +11,7 @@ @Builder public class MdaFormSubmissionResponse { private Long beneficiaryId; - private Timestamp visitDate; + private String visitDate; private Long houseHoldId; private Integer ashaId; private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java index 78799d3c..e7b0fe4e 100644 --- a/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MdaFormSubmissionServiceImpl.java @@ -66,10 +66,11 @@ public List getFormDataByUserName(String userName) { for (MdaDistributionData entity : records) { try { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); - String formattedDate = sdf.format(entity.getMdaDistributionDate()); + String mdaformattedDate = sdf.format(entity.getMdaDistributionDate()); + String visitformattedDate = sdf.format(entity.getVisitDate()); MdaFormFieldsDTO fieldsDTO = MdaFormFieldsDTO.builder() - .mda_distribution_date(formattedDate) + .mda_distribution_date(mdaformattedDate) .is_medicine_distributed(entity.getIsMedicineDistributed()) .build(); @@ -77,7 +78,7 @@ public List getFormDataByUserName(String userName) { .formId(entity.getFormId()) .houseHoldId(entity.getHouseHoldId()) .beneficiaryId(entity.getBeneficiaryId()) - .visitDate(entity.getVisitDate()) + .visitDate(visitformattedDate) .createdBy(entity.getCreatedBy()) .createdAt(entity.getCreatedDate()) .fields(fieldsDTO) From fced208dc67d91faec6bbe319c68b5d6c40f1405 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 15:22:01 +0530 Subject: [PATCH 560/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 26b0218e..670842c8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -228,11 +228,11 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity,S record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(userName); + record.setCreatedBy(jwtUtil.getUserNameFromStorage()); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(userName); + record.setUpdatedBy(jwtUtil.getUserNameFromStorage()); record.setBenId(0L); record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); From 73c64d932f4fb892697d2dcda51ddc6e63eea18d Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 13 Nov 2025 16:32:50 +0530 Subject: [PATCH 561/792] fix: leprosy save all and get all --- .../controller/DiseaseControlController.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index b6f8d724..367c0dad 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -166,21 +166,23 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l } - @RequestMapping(value = "leprosy/followUp/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json",headers = "Authorization") - public ResponseEntity> saveLeprosyFollowUP(@RequestBody LeprosyFollowUpDTO leprosyDTO) { + @RequestMapping(value = "leprosy/followUp/saveAll", method = RequestMethod.POST, consumes = "application/json", produces = "application/json", headers = "Authorization") + public ResponseEntity> saveLeprosyFollowUP(@RequestBody List followUps) { Map response = new HashMap<>(); try { - if(leprosyDTO!=null){ + if (followUps != null && !followUps.isEmpty()) { + for (LeprosyFollowUpDTO dto : followUps) { + diseaseControlService.saveLeprosyFollowUp(dto); + } response.put("status", "Success"); response.put("statusCode", 200); - response.put("data", diseaseControlService.saveLeprosyFollowUp(leprosyDTO)); - }else { - response.put("message", "Invalid request"); + response.put("message", "All follow-ups saved successfully"); + } else { + response.put("message", "Invalid request - no follow-up data"); response.put("statusCode", 400); } - } catch (Exception e) { - response.put("status", "Error" + e.getMessage()); + response.put("status", "Error: " + e.getMessage()); response.put("statusCode", 500); } return ResponseEntity.ok(response); From ec575582982debf7b30685fcaaaa7eba0c05e31a Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 13 Nov 2025 18:13:35 +0530 Subject: [PATCH 562/792] fix:new followup for leprosy sync --- .../iemr/flw/service/impl/DiseaseControlServiceImpl.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 0618e979..a3ca1851 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -349,16 +349,10 @@ private String updateLeprosyFollowUpData(LeprosyFollowUpDTO data, LeprosyFollowU public String saveLeprosyFollowUp(LeprosyFollowUpDTO dto) { if (dto == null) return "Invalid data"; - - Optional existing = leprosyFollowUpRepository.findByBenId(dto.getBenId()); - - if (existing.isPresent()) { - return updateLeprosyFollowUpData(dto, existing.get()); - } else { LeprosyFollowUp entity = saveLeprosyFollowUpData(dto); leprosyFollowUpRepository.save(entity); return "Follow-up data added successfully"; - } + } @Override From 1e03cc34b712cab7d8b505401132c1c030faa580 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 11:05:42 +0530 Subject: [PATCH 563/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 670842c8..942131fe 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,6 +51,8 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; + + @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; From dc28ca0003fb778b08896a6b9d121d99ad8ce05a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:40:51 +0530 Subject: [PATCH 564/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 942131fe..670842c8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,8 +51,6 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; - - @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; From 9c6c0bcb475cc8aee59c0e49e40eb6f145377154 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 13 Nov 2025 19:09:43 +0530 Subject: [PATCH 565/792] fix: repsonse value change --- .../com/iemr/flw/controller/DiseaseControlController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 367c0dad..e7af7049 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -210,7 +210,7 @@ public ResponseEntity> getAllLeprosy( response.put("statusCode", 404); } } else { - response.put("message", "Invalid request - createdBy required"); + response.put("message", "Invalid request - userName required"); response.put("statusCode", 400); } } catch (Exception e) { @@ -240,7 +240,7 @@ public ResponseEntity> getAllLeprosyFollowUp( response.put("statusCode", 404); } } else { - response.put("message", "Invalid request - createdBy required"); + response.put("message", "Invalid request - userName required"); response.put("statusCode", 400); } } catch (Exception e) { From 90c53a22ba3e7c36dfa15159f23da48168fddbe4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 23:15:39 +0530 Subject: [PATCH 566/792] update incentive code --- src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java index cf2f257b..17eb15c2 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -22,7 +22,7 @@ public class SamVisitResponseDTO { private String visitLabel; @JsonProperty("muac") - private String muac; + private Double muac; @JsonProperty("weight_for_height_status") private String weightForHeightStatus; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 02758712..2540bcaf 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -532,7 +532,7 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque // ✅ Final Visit Label dto.setVisitLabel("Visit-" + visitNo); - dto.setMuac(entity.getMuac()); + dto.setMuac(Double.parseDouble(entity.getMuac())); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); dto.setIsChildReferredNrc(entity.getIsChildReferredNrc()); dto.setIsChildAdmittedNrc(entity.getIsChildAdmittedNrc()); From 223beae6e863d016b5e64ef43446db22271006f3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 23:31:16 +0530 Subject: [PATCH 567/792] update incentive code --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2540bcaf..f0513984 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -449,7 +449,6 @@ public String saveSamDetails(List samRequest) { .findByBeneficiaryIdAndVisitDate(samDTO.getBeneficiaryId(), visitDate) .orElse(new SamVisit()); // 🧠 If exists → update, else create new - samVisit.setId(samDTO.getId()); samVisit.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisit.setHouseholdId(samDTO.getHouseHoldId()); From a9b227138beeda8f6c5644a87ca93e5a6e34b7fb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 00:16:45 +0530 Subject: [PATCH 568/792] update incentive code --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f0513984..c76190a7 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -712,13 +712,13 @@ private void checkAndAddSamVisitNRCReferalIncentive(List samVisits){ incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity samreferralnrcActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.ACTIVITY.getDisplayName()); if(samreferralnrcActivityAm!=null){ - if(samVisit.getIsChildReferredNrc().equals("yes")){ + if(samVisit.getIsChildReferredNrc().equals("Yes")){ createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityAm,jwtUtil.getUserNameFromStorage()); } } if(samreferralnrcActivityCH!=null){ - if(samVisit.getIsChildReferredNrc().equals("yes")){ + if(samVisit.getIsChildReferredNrc().equals("Yes")){ createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityCH,jwtUtil.getUserNameFromStorage()); } } From 21985559fc01f874693a945bc0a792d81ead7379 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 12:52:51 +0530 Subject: [PATCH 569/792] update incentive code --- .../iemr/flw/repo/iemr/UserServiceRoleRepo.java | 3 +++ .../iemr/flw/service/impl/CoupleServiceImpl.java | 2 +- .../flw/service/impl/IncentiveServiceImpl.java | 16 ++++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java index f04a912f..899a7ffd 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/UserServiceRoleRepo.java @@ -21,4 +21,7 @@ public interface UserServiceRoleRepo extends JpaRepository eligibleCoupleDTOs, modelMapper.map(it, existingECR); existingECR.setId(null); } - if(existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())){ + if(existingECR.getIsKitHandedOver() && (kitPhoto1!=null || kitPhoto2!=null)){ IncentiveActivity handoverKitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); if(handoverKitActivityAM!=null){ diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index c194a9b5..0976ce44 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -154,7 +154,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { - checkMonthlyAshaIncentive(request.getUserName(),request.getAshaId()); + checkMonthlyAshaIncentive(request.getAshaId()); List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); @@ -189,25 +189,25 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } - private void checkMonthlyAshaIncentive(String userName, Integer ashaId){ + private void checkMonthlyAshaIncentive(Integer ashaId){ IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); if(MOBILEBILLREIMB_ACTIVITY!=null){ - addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,userName,ashaId); + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,ashaId); } if(ADDITIONAL_ASHA_INCENTIVE!=null){ - addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,userName,ashaId); + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,ashaId); } if(ASHA_MONTHLY_ROUTINE!=null){ - addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,userName,ashaId); + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,ashaId); } } - private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, String userName, Integer ashaId){ + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, Integer ashaId){ Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); @@ -226,11 +226,11 @@ private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(userName); + record.setCreatedBy(userRepo.getUserNamedByUserId(ashaId)); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(userName); + record.setUpdatedBy(userRepo.getUserNamedByUserId(ashaId)); record.setBenId(0L); record.setAshaId(ashaId); record.setAmount(Long.valueOf(incentiveActivity.getRate())); From 76e9bbc01b1d9f8188330fdca8b02321c6dc1240 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 13:37:58 +0530 Subject: [PATCH 570/792] update incentive code --- .../flw/service/impl/CoupleServiceImpl.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index d070c0cf..f852bbdd 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -106,7 +106,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, modelMapper.map(it, existingECR); existingECR.setId(null); } - if(existingECR.getIsKitHandedOver() && (kitPhoto1!=null || kitPhoto2!=null)){ + if(existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())){ IncentiveActivity handoverKitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); if(handoverKitActivityAM!=null){ @@ -159,6 +159,23 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) modelMapper.map(it, existingECR); existingECR.setId(null); } + + if(existingECR.getIsKitHandedOver()){ + IncentiveActivity handoverKitActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); + if(handoverKitActivityAM!=null){ + createIncentiveRecord(recordList, it, handoverKitActivityAM); + + } + + + IncentiveActivity handoverKitActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.ACTIVITY.getDisplayName()); + if(handoverKitActivityCH!=null){ + createIncentiveRecord(recordList, it, handoverKitActivityCH); + + } + } ecrList.add(existingECR); }); eligibleCoupleRegisterRepo.saveAll(ecrList); From d1c1cf56cabcf61a33b3698c7e51c16d6b8f4f4f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 11:05:42 +0530 Subject: [PATCH 571/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 670842c8..942131fe 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,6 +51,8 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; + + @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; From ec099599a43eb8f74b09d77c783102d4101dc3e7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 12 Nov 2025 12:40:51 +0530 Subject: [PATCH 572/792] update incentive code --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 942131fe..670842c8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,8 +51,6 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; - - @Autowired private UserServiceRoleRepo userRepo; private Integer sateId =0; From 97960e99710f7cbfac0b6298bdf861e66ff3a7ee Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 23:15:39 +0530 Subject: [PATCH 573/792] update incentive code --- src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java | 2 +- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java index cf2f257b..17eb15c2 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SamVisitResponseDTO.java @@ -22,7 +22,7 @@ public class SamVisitResponseDTO { private String visitLabel; @JsonProperty("muac") - private String muac; + private Double muac; @JsonProperty("weight_for_height_status") private String weightForHeightStatus; diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 02758712..2540bcaf 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -532,7 +532,7 @@ public List getSamVisitsByBeneficiary(GetBenRequestHandler reque // ✅ Final Visit Label dto.setVisitLabel("Visit-" + visitNo); - dto.setMuac(entity.getMuac()); + dto.setMuac(Double.parseDouble(entity.getMuac())); dto.setWeightForHeightStatus(entity.getWeightForHeightStatus()); dto.setIsChildReferredNrc(entity.getIsChildReferredNrc()); dto.setIsChildAdmittedNrc(entity.getIsChildAdmittedNrc()); From 64fb1693eda6ed66409030c9480ff5dfb893302d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 13 Nov 2025 23:31:16 +0530 Subject: [PATCH 574/792] update incentive code --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 2540bcaf..f0513984 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -449,7 +449,6 @@ public String saveSamDetails(List samRequest) { .findByBeneficiaryIdAndVisitDate(samDTO.getBeneficiaryId(), visitDate) .orElse(new SamVisit()); // 🧠 If exists → update, else create new - samVisit.setId(samDTO.getId()); samVisit.setBeneficiaryId(samDTO.getBeneficiaryId()); samVisit.setHouseholdId(samDTO.getHouseHoldId()); From 767ba8348a676a28c74b1117fea8437f963edb9d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 00:16:45 +0530 Subject: [PATCH 575/792] update incentive code --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index f0513984..c76190a7 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -712,13 +712,13 @@ private void checkAndAddSamVisitNRCReferalIncentive(List samVisits){ incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity samreferralnrcActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("SAM_REFERRAL_NRC", GroupName.ACTIVITY.getDisplayName()); if(samreferralnrcActivityAm!=null){ - if(samVisit.getIsChildReferredNrc().equals("yes")){ + if(samVisit.getIsChildReferredNrc().equals("Yes")){ createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityAm,jwtUtil.getUserNameFromStorage()); } } if(samreferralnrcActivityCH!=null){ - if(samVisit.getIsChildReferredNrc().equals("yes")){ + if(samVisit.getIsChildReferredNrc().equals("Yes")){ createIncentiveRecordforSamReferalToNrc(samVisit,samVisit.getBeneficiaryId(),samreferralnrcActivityCH,jwtUtil.getUserNameFromStorage()); } } From f94a7469f8bed24e66190885c95c440a25e49d95 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 17:10:12 +0530 Subject: [PATCH 576/792] update incentive code --- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 13542e48..3fb960eb 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -234,6 +234,7 @@ public String savePmsmaRecords(List pmsmaDTOs) { }); pmsmaRepo.saveAll(pmsmaList); logger.info("PMSMA details saved"); + return "No. of PMSMA records saved: " + pmsmaList.size(); } catch (Exception e) { logger.info("Saving PMSMA details failed with error : " + e.getMessage()); @@ -480,8 +481,9 @@ record = new IncentiveActivityRecord(); ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); - if (Objects.equals(ancVisit.getIsAborted(), "true")) { + if (ancVisit.getIsAborted()) { if (record == null) { logger.info("record:"+record.getName()); @@ -508,8 +510,6 @@ record = new IncentiveActivityRecord(); ancList.forEach((ancVisit -> { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - RMNCHBeneficiaryDetailsRmnch rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.getDetailsByRegID(beneficiaryRepo.getRegIDFromBenId(ancVisit.getBenId())); - String beneName = rmnchBeneficiaryDetailsRmnch.getFirstName() + " " + rmnchBeneficiaryDetailsRmnch.getLastName(); if (ancVisit.getIsHrpConfirmed() != null) { if (ancVisit.getIsHrpConfirmed()) { if (record == null) { @@ -518,7 +518,6 @@ record = new IncentiveActivityRecord(); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setName(beneName); record.setUpdatedBy(ancVisit.getCreatedBy()); record.setStartDate(ancVisit.getCreatedDate()); record.setEndDate(ancVisit.getCreatedDate()); From 904f94eb5d9ee6d51020d638d33a2bcc1c249811 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 17:11:28 +0530 Subject: [PATCH 577/792] update incentive code --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 3fb960eb..1832736c 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -390,7 +390,7 @@ private void checkAndAddIncentives(List ancList) { incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity ancFullActivityCH = - incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); + incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.ACTIVITY.getDisplayName()); IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); From a8750684594c4a911fa217c19d838c6112e57ff3 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Fri, 14 Nov 2025 17:20:17 +0530 Subject: [PATCH 578/792] fix:date format --- .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 27 ++++++++++++++++++- .../iemr/flw/dto/iemr/LeprosyFollowUpDTO.java | 21 +++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index 5b898f76..b16ea8d7 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -28,26 +28,41 @@ import java.sql.Timestamp; import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + @Data public class DiseaseLeprosyDTO { private Long id; private Long benId; private Long houseHoldDetailsId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date homeVisitDate; + private String leprosyStatus; private String referredTo; private String otherReferredTo; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date leprosyStatusDate; + private String typeOfLeprosy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date followUpDate; + private String beneficiaryStatus; private String remark; private Integer userId; private Integer diseaseTypeId; private String referToName; private Integer beneficiaryStatusId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date dateOfDeath; + private String placeOfDeath; private String otherPlaceOfDeath; private String reasonForDeath; @@ -61,14 +76,24 @@ public class DiseaseLeprosyDTO { private Integer visitNumber; private Boolean isConfirmed; private String leprosyState; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentStartDate; + private Integer totalFollowUpMonthsRequired; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentEndDate; + private String mdtBlisterPackRecived; private String treatmentStatus; - private String createdBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp createdDate; + private String modifiedBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp lastModDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java index 5a5b2e31..4a152343 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java @@ -4,18 +4,29 @@ import java.sql.Timestamp; import java.util.Date; +import com.fasterxml.jackson.annotation.JsonFormat; + @Data public class LeprosyFollowUpDTO { private Long id; private Long benId; private Integer visitNumber; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date followUpDate; + private String treatmentStatus; private String mdtBlisterPackReceived; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentCompleteDate; + private String remarks; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date homeVisitDate; + private String leprosySymptoms; private String typeOfLeprosy; private Integer leprosySymptomsPosition; @@ -23,12 +34,22 @@ public class LeprosyFollowUpDTO { private String leprosyStatus; private String referredTo; private String referToName; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentEndDate; + private String mdtBlisterPackRecived; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentStartDate; private String createdBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp createdDate; + private String modifiedBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp lastModDate; } \ No newline at end of file From cbe0fa582cfefe417f31569c2e9b361e483dbccd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 14 Nov 2025 17:46:26 +0530 Subject: [PATCH 579/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 1832736c..6532d797 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -1,8 +1,6 @@ package com.iemr.flw.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; -import com.iemr.flw.domain.identity.RMNCHBeneficiaryDetailsRmnch; -import com.iemr.flw.domain.identity.RMNCHMBeneficiarydetail; import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; @@ -16,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.math.BigInteger; import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalTime; @@ -234,6 +231,7 @@ public String savePmsmaRecords(List pmsmaDTOs) { }); pmsmaRepo.saveAll(pmsmaList); logger.info("PMSMA details saved"); + checkAndAddHighRisk(pmsmaList); return "No. of PMSMA records saved: " + pmsmaList.size(); } catch (Exception e) { @@ -242,6 +240,41 @@ public String savePmsmaRecords(List pmsmaDTOs) { return null; } + private void checkAndAddHighRisk(List pmsmaList) { + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_HR_POSTNATAL",GroupName.MATERNAL_HEALTH.getDisplayName()); + if(incentiveActivity!=null){ + pmsmaList.forEach(pmsma -> { + if(pmsma.getHighRiskPregnant()){ + addIncentiveForHighRisk(incentiveActivity,pmsma); + + } + + }); + } + + } + + private void addIncentiveForHighRisk(IncentiveActivity incentiveActivity, PMSMA pmsma) { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), pmsma.getCreatedDate(), pmsma.getBenId()); + // get bene details + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(pmsma.getVisitDate()); + record.setCreatedBy(pmsma.getCreatedBy()); + record.setStartDate(pmsma.getVisitDate()); + record.setEndDate(pmsma.getVisitDate()); + record.setUpdatedDate(pmsma.getVisitDate()); + record.setUpdatedBy(pmsma.getCreatedBy()); + record.setBenId(pmsma.getBenId()); + record.setAshaId(userRepo.getUserIdByName(pmsma.getCreatedBy())); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + } + @Override public List getPNCVisits(GetBenRequestHandler dto) { try { From 046c405d1a57c7e7f9b19e15469eaf84142ef21d Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Fri, 14 Nov 2025 18:09:50 +0530 Subject: [PATCH 580/792] fix:date format --- .../controller/DiseaseControlController.java | 2 +- .../iemr/flw/dto/iemr/LeprosyFollowUpDTO.java | 13 ----- .../flw/dto/iemr/LeprosyGetFollowUpDTO.java | 55 +++++++++++++++++++ .../flw/service/DiseaseControlService.java | 2 +- .../impl/DiseaseControlServiceImpl.java | 6 +- 5 files changed, 60 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/LeprosyGetFollowUpDTO.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index e7af7049..dc170c72 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -229,7 +229,7 @@ public ResponseEntity> getAllLeprosyFollowUp( try { String userName = request.get("userName"); if (userName != null) { - List result = diseaseControlService.getAllLeprosyFollowUpData(userName); + List result = diseaseControlService.getAllLeprosyFollowUpData(userName); if (result != null && !result.isEmpty()) { response.put("status", "Success"); diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java index 4a152343..aaf28a29 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyFollowUpDTO.java @@ -4,27 +4,19 @@ import java.sql.Timestamp; import java.util.Date; -import com.fasterxml.jackson.annotation.JsonFormat; - @Data public class LeprosyFollowUpDTO { private Long id; private Long benId; private Integer visitNumber; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date followUpDate; private String treatmentStatus; private String mdtBlisterPackReceived; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentCompleteDate; private String remarks; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date homeVisitDate; private String leprosySymptoms; @@ -34,22 +26,17 @@ public class LeprosyFollowUpDTO { private String leprosyStatus; private String referredTo; private String referToName; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentEndDate; private String mdtBlisterPackRecived; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentStartDate; private String createdBy; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp createdDate; private String modifiedBy; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp lastModDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/LeprosyGetFollowUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/LeprosyGetFollowUpDTO.java new file mode 100644 index 00000000..0e2f59b0 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/LeprosyGetFollowUpDTO.java @@ -0,0 +1,55 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import java.sql.Timestamp; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +@Data +public class LeprosyGetFollowUpDTO { + + private Long id; + private Long benId; + private Integer visitNumber; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date followUpDate; + + private String treatmentStatus; + private String mdtBlisterPackReceived; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date treatmentCompleteDate; + + private String remarks; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date homeVisitDate; + + private String leprosySymptoms; + private String typeOfLeprosy; + private Integer leprosySymptomsPosition; + private String visitLabel; + private String leprosyStatus; + private String referredTo; + private String referToName; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date treatmentEndDate; + + private String mdtBlisterPackRecived; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date treatmentStartDate; + + private String createdBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Timestamp createdDate; + + private String modifiedBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Timestamp lastModDate; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 4cc8926b..7646734f 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -42,6 +42,6 @@ public interface DiseaseControlService { List getAllLeprosyData(String createdBy); public String saveLeprosyFollowUp(LeprosyFollowUpDTO leprosyDTO); - List getAllLeprosyFollowUpData(String createdBy); + List getAllLeprosyFollowUpData(String createdBy); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index a3ca1851..a3846dac 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -371,15 +371,15 @@ public List getAllLeprosyData(String createdBy) { } @Override - public List getAllLeprosyFollowUpData(String createdBy) { + public List getAllLeprosyFollowUpData(String createdBy) { logger.info("Fetching leprosy data for createdBy: " + createdBy); List leprosyList = leprosyFollowUpRepository.getByCreatedBy(createdBy); logger.info("Found " + leprosyList.size() + " leprosy records"); - List dtos = new ArrayList<>(); + List dtos = new ArrayList<>(); leprosyList.forEach(leprosy -> { - dtos.add(modelMapper.map(leprosy, LeprosyFollowUpDTO.class)); + dtos.add(modelMapper.map(leprosy, LeprosyGetFollowUpDTO.class)); }); return dtos; From 22585420c033e2e8cbe813c584c15b0329985506 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Fri, 14 Nov 2025 18:39:48 +0530 Subject: [PATCH 581/792] fix:date format --- .../controller/DiseaseControlController.java | 2 +- .../flw/dto/iemr/DiseaseGetLeprosyDTO.java | 99 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 24 ----- .../flw/service/DiseaseControlService.java | 2 +- .../impl/DiseaseControlServiceImpl.java | 6 +- 5 files changed, 104 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/DiseaseGetLeprosyDTO.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index dc170c72..2f5d4264 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -199,7 +199,7 @@ public ResponseEntity> getAllLeprosy( try { String userName = request.get("userName"); if (userName != null) { - List result = diseaseControlService.getAllLeprosyData(userName); + List result = diseaseControlService.getAllLeprosyData(userName); if (result != null && !result.isEmpty()) { response.put("status", "Success"); diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseGetLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseGetLeprosyDTO.java new file mode 100644 index 00000000..4f8a2ef7 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseGetLeprosyDTO.java @@ -0,0 +1,99 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +* +/* +* AMRIT – Accessible Medical Records via Integrated Technology +*/ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.sql.Timestamp; +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonFormat; + +@Data +public class DiseaseGetLeprosyDTO { + + private Long id; + private Long benId; + private Long houseHoldDetailsId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date homeVisitDate; + + private String leprosyStatus; + private String referredTo; + private String otherReferredTo; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date leprosyStatusDate; + + private String typeOfLeprosy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date followUpDate; + + private String beneficiaryStatus; + private String remark; + private Integer userId; + private Integer diseaseTypeId; + private String referToName; + private Integer beneficiaryStatusId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date dateOfDeath; + + private String placeOfDeath; + private String otherPlaceOfDeath; + private String reasonForDeath; + private String otherReasonForDeath; + + private String leprosySymptoms; + private Integer leprosySymptomsPosition; + private Integer lerosyStatusPosition; + private Integer currentVisitNumber; + private String visitLabel; + private Integer visitNumber; + private Boolean isConfirmed; + private String leprosyState; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date treatmentStartDate; + + private Integer totalFollowUpMonthsRequired; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Date treatmentEndDate; + + private String mdtBlisterPackRecived; + private String treatmentStatus; + private String createdBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Timestamp createdDate; + + private String modifiedBy; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") + private Timestamp lastModDate; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index b16ea8d7..c0acbe71 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -37,37 +37,24 @@ public class DiseaseLeprosyDTO { private Long id; private Long benId; private Long houseHoldDetailsId; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date homeVisitDate; - private String leprosyStatus; private String referredTo; private String otherReferredTo; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date leprosyStatusDate; - private String typeOfLeprosy; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date followUpDate; - private String beneficiaryStatus; private String remark; private Integer userId; private Integer diseaseTypeId; private String referToName; private Integer beneficiaryStatusId; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date dateOfDeath; - private String placeOfDeath; private String otherPlaceOfDeath; private String reasonForDeath; private String otherReasonForDeath; - private String leprosySymptoms; private Integer leprosySymptomsPosition; private Integer lerosyStatusPosition; @@ -76,24 +63,13 @@ public class DiseaseLeprosyDTO { private Integer visitNumber; private Boolean isConfirmed; private String leprosyState; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentStartDate; - private Integer totalFollowUpMonthsRequired; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Date treatmentEndDate; - private String mdtBlisterPackRecived; private String treatmentStatus; private String createdBy; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp createdDate; - private String modifiedBy; - - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy h:mm:ss a", timezone = "Asia/Kolkata") private Timestamp lastModDate; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 7646734f..92accf4a 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -39,7 +39,7 @@ public interface DiseaseControlService { public List saveMosquitoMobilizationNet(List mosquitoNetDTOList); List getAllMosquitoMobilizationNet(Integer userId); - List getAllLeprosyData(String createdBy); + List getAllLeprosyData(String createdBy); public String saveLeprosyFollowUp(LeprosyFollowUpDTO leprosyDTO); List getAllLeprosyFollowUpData(String createdBy); diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index a3846dac..bc780038 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -356,15 +356,15 @@ public String saveLeprosyFollowUp(LeprosyFollowUpDTO dto) { } @Override - public List getAllLeprosyData(String createdBy) { + public List getAllLeprosyData(String createdBy) { logger.info("Fetching leprosy data for createdBy: " + createdBy); List leprosyList = diseaseLeprosyRepository.getByCreatedBy(createdBy); logger.info("Found " + leprosyList.size() + " leprosy records"); - List dtos = new ArrayList<>(); + List dtos = new ArrayList<>(); leprosyList.forEach(leprosy -> { - dtos.add(modelMapper.map(leprosy, DiseaseLeprosyDTO.class)); + dtos.add(modelMapper.map(leprosy, DiseaseGetLeprosyDTO.class)); }); return dtos; From 3b2bef5a9cfd9a77f063e9b648ba7bc03a292205 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 10:53:47 +0530 Subject: [PATCH 582/792] update incentive code --- .../flw/service/impl/ChildCareServiceImpl.java | 2 +- .../flw/service/impl/IncentiveServiceImpl.java | 4 +++- .../service/impl/MaternalHealthServiceImpl.java | 17 ++++++++++++++--- .../impl/VillageLevelFormServiceImpl.java | 10 ++++++---- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 9796612c..1dba60f4 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -811,7 +811,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { } logger.info("getDischarged_from_sncu" + hbncVisit.getDischarged_from_sncu()); - if (hbncVisit.getVisit_day().equals("7th Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight() < 2.5) { + if (hbncVisit.getVisit_day().equals("42nd Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight() < 2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 0976ce44..51dc8bfc 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -154,7 +154,9 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { - checkMonthlyAshaIncentive(request.getAshaId()); + if(sateId!=8){ + checkMonthlyAshaIncentive(request.getAshaId()); + } List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 6532d797..399baebf 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -241,11 +241,22 @@ public String savePmsmaRecords(List pmsmaDTOs) { } private void checkAndAddHighRisk(List pmsmaList) { - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_HR_POSTNATAL",GroupName.MATERNAL_HEALTH.getDisplayName()); - if(incentiveActivity!=null){ + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED",GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED",GroupName.ACTIVITY.getDisplayName()); + if(incentiveActivityAM!=null){ pmsmaList.forEach(pmsma -> { if(pmsma.getHighRiskPregnant()){ - addIncentiveForHighRisk(incentiveActivity,pmsma); + addIncentiveForHighRisk(incentiveActivityAM,pmsma); + + } + + }); + } + + if(incentiveActivityCH!=null){ + pmsmaList.forEach(pmsma -> { + if(pmsma.getHighRiskPregnant()){ + addIncentiveForHighRisk(incentiveActivityCH,pmsma); } diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index e0c2db96..3821ecda 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -265,12 +265,13 @@ private void checkAndAddIncentives(String date, Integer userID, String formType, record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivityAM.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(createdBY); + record.setCreatedBy(userRepo.getUserNamedByUserId(userID)); record.setStartDate(timestamp); record.setEndDate(timestamp); record.setUpdatedDate(timestamp); - record.setUpdatedBy(createdBY); + record.setUpdatedBy(userRepo.getUserNamedByUserId(userID)); record.setAshaId(userID); + record.setBenId(0L); record.setAmount(Long.valueOf(villageFormEntryActivityAM.getRate())); recordRepo.save(record); @@ -284,11 +285,12 @@ record = new IncentiveActivityRecord(); record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivityCH.getId()); record.setCreatedDate(timestamp); - record.setCreatedBy(createdBY); + record.setCreatedBy(userRepo.getUserNamedByUserId(userID)); record.setStartDate(timestamp); record.setEndDate(timestamp); + record.setBenId(0L); record.setUpdatedDate(timestamp); - record.setUpdatedBy(createdBY); + record.setUpdatedBy(userRepo.getUserNamedByUserId(userID)); record.setAshaId(userID); record.setAmount(Long.valueOf(villageFormEntryActivityCH.getRate())); recordRepo.save(record); From 65537f86a9626956ea645a767333be469d35e855 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 14:06:19 +0530 Subject: [PATCH 583/792] update incentive code --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index f852bbdd..a07ee5d4 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -243,6 +243,12 @@ private void checkAndAddAntaraIncentive(List recordList logger.info("Antra"+ect.getMethodOfContraception()); logger.info("Antra"+ect.getAntraDose()); if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().contains("ANTRA Injection")) { + // for CG incentive + IncentiveActivity antaraActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", GroupName.ACTIVITY.getDisplayName()); + if (antaraActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, antaraActivityCH); + } if (ect.getAntraDose().contains("Dose-1")) { IncentiveActivity antaraActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", "FAMILY PLANNING"); From 6983d1a9f677f0a59b2da619a6d9e3e94f0b5f9c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 14:08:28 +0530 Subject: [PATCH 584/792] update incentive code --- .../flw/service/impl/CoupleServiceImpl.java | 55 +++++++++++-------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index a07ee5d4..3d81258a 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Arrays; import java.util.Base64; import java.util.List; import java.util.stream.Collectors; @@ -33,10 +34,10 @@ public class CoupleServiceImpl implements CoupleService { ObjectMapper mapper = new ObjectMapper(); ModelMapper modelMapper = new ModelMapper(); - + @Autowired private EligibleCoupleRegisterRepo eligibleCoupleRegisterRepo; - + @Autowired private EligibleCoupleTrackingRepo eligibleCoupleTrackingRepo; @@ -48,7 +49,7 @@ public class CoupleServiceImpl implements CoupleService { @Autowired private IncentiveRecordRepo recordRepo; - + @Autowired private BeneficiaryRepo beneficiaryRepo; @@ -88,7 +89,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, } if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { + if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity1 = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity1); @@ -106,10 +107,10 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, modelMapper.map(it, existingECR); existingECR.setId(null); } - if(existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())){ + if (existingECR.getIsKitHandedOver() && (!existingECR.getKitPhoto1().isEmpty() || !existingECR.getKitPhoto2().isEmpty())) { IncentiveActivity handoverKitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); - if(handoverKitActivityAM!=null){ + if (handoverKitActivityAM != null) { createIncentiveRecord(recordList, it, handoverKitActivityAM); } @@ -117,7 +118,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, IncentiveActivity handoverKitActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.ACTIVITY.getDisplayName()); - if(handoverKitActivityCH!=null){ + if (handoverKitActivityCH != null) { createIncentiveRecord(recordList, it, handoverKitActivityCH); } @@ -131,6 +132,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, return "error while saving ecr details: " + e.getMessage(); } } + @Override public String registerEligibleCouple(List eligibleCoupleDTOs) { try { @@ -142,7 +144,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if(existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { + if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity1 = incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", "FAMILY PLANNING"); createIncentiveRecord(recordList, it, activity1); @@ -160,10 +162,10 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) existingECR.setId(null); } - if(existingECR.getIsKitHandedOver()){ + if (existingECR.getIsKitHandedOver()) { IncentiveActivity handoverKitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); - if(handoverKitActivityAM!=null){ + if (handoverKitActivityAM != null) { createIncentiveRecord(recordList, it, handoverKitActivityAM); } @@ -171,7 +173,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) IncentiveActivity handoverKitActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.ACTIVITY.getDisplayName()); - if(handoverKitActivityCH!=null){ + if (handoverKitActivityCH != null) { createIncentiveRecord(recordList, it, handoverKitActivityCH); } @@ -240,15 +242,24 @@ public String registerEligibleCoupleTracking(List eli private void checkAndAddAntaraIncentive(List recordList, EligibleCoupleTracking ect) { Integer userId = userRepo.getUserIdByName(ect.getCreatedBy()); - logger.info("Antra"+ect.getMethodOfContraception()); - logger.info("Antra"+ect.getAntraDose()); - if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().contains("ANTRA Injection")) { + logger.info("Antra" + ect.getMethodOfContraception()); + logger.info("Antra" + ect.getAntraDose()); + if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().contains("ANTRA Injection")) { // for CG incentive IncentiveActivity antaraActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", GroupName.ACTIVITY.getDisplayName()); if (antaraActivityCH != null) { - addIncenticeRecord(recordList, ect, userId, antaraActivityCH); - } + String dose = ect.getAntraDose(); + + List validDoses = Arrays.asList("Dose-1", "Dose-2", "Dose-3", "Dose-4"); + + boolean isDose = validDoses.stream().anyMatch(dose::contains); + + if (isDose) { + addIncenticeRecord(recordList, ect, userId, antaraActivityCH); + + } + } if (ect.getAntraDose().contains("Dose-1")) { IncentiveActivity antaraActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", "FAMILY PLANNING"); @@ -273,42 +284,42 @@ private void checkAndAddAntaraIncentive(List recordList if (antaraActivity4 != null) { addIncenticeRecord(recordList, ect, userId, antaraActivity4); } - }else if (ect.getAntraDose().contains("Dose-5")) { + } else if (ect.getAntraDose().contains("Dose-5")) { IncentiveActivity antaraActivity4 = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", "FAMILY PLANNING"); if (antaraActivity4 != null) { addIncenticeRecord(recordList, ect, userId, antaraActivity4); } } - }else if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MALE STERILIZATION")){ + } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MALE STERILIZATION")) { IncentiveActivity maleSterilizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", "FAMILY PLANNING"); if (maleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); } - }else if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("FEMALE STERILIZATION")){ + } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("FEMALE STERILIZATION")) { IncentiveActivity femaleSterilizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", "FAMILY PLANNING"); if (femaleSterilizationActivity != null) { addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); } - }else if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MiniLap")){ + } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MiniLap")) { IncentiveActivity miniLapActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MINILAP", "FAMILY PLANNING"); if (miniLapActivity != null) { addIncenticeRecord(recordList, ect, userId, miniLapActivity); } - }else if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("Condom")){ + } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("Condom")) { IncentiveActivity comdomActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); if (comdomActivity != null) { addIncenticeRecord(recordList, ect, userId, comdomActivity); } - }else if(ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("Copper T (IUCD)")){ + } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("Copper T (IUCD)")) { IncentiveActivity copperTActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", "FAMILY PLANNING"); From 5932ff1fca41d6c93ceaac0d1d7ba88ee2736213 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 14:24:46 +0530 Subject: [PATCH 585/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 76 +++++++++++++++++-- 1 file changed, 71 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 399baebf..bbeac9bb 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -393,12 +393,19 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (comdomActivity != null) { addIncenticeRecord(recordList, ect, userId, comdomActivity); } - } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("Copper T (IUCD)")) { + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().contains("PPIUCD")) { - IncentiveActivity copperTActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_CONDOM", GroupName.FAMILY_PLANNING.getDisplayName()); - if (copperTActivity != null) { - addIncenticeRecord(recordList, ect, userId, copperTActivity); + IncentiveActivity copperTActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPIUCD", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity copperTActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPIUCD", GroupName.ACTIVITY.getDisplayName()); + if (copperTActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, copperTActivityAM); + } + + if (copperTActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, copperTActivityCH); } } } @@ -441,7 +448,66 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); + IncentiveActivity paiucdActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PAIUCD", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity paiucdActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PAIUCD", GroupName.ACTIVITY.getDisplayName()); + if (paiucdActivityAM != null) { + ancList.forEach((ancVisit -> { + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + if (ancVisit.getIsPaiucdId()) { + + if (record == null) { + logger.info("record:"+record.getName()); + logger.info("condition:"+ancVisit.getIsAborted()); + record = new IncentiveActivityRecord(); + record.setActivityId(paiucdActivityAM.getId()); + record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedBy(ancVisit.getCreatedBy()); + record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedBy(ancVisit.getCreatedBy()); + record.setStartDate(ancVisit.getCreatedDate()); + record.setEndDate(ancVisit.getCreatedDate()); + record.setBenId(ancVisit.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(paiucdActivityAM.getRate())); + recordRepo.save(record); + } + + } + })); + } + + if (paiucdActivityCH != null) { + ancList.forEach((ancVisit -> { + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + + if (ancVisit.getIsPaiucdId()) { + + if (record == null) { + logger.info("record:"+record.getName()); + logger.info("condition:"+ancVisit.getIsAborted()); + record = new IncentiveActivityRecord(); + record.setActivityId(paiucdActivityCH.getId()); + record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedBy(ancVisit.getCreatedBy()); + record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedBy(ancVisit.getCreatedBy()); + record.setStartDate(ancVisit.getCreatedDate()); + record.setEndDate(ancVisit.getCreatedDate()); + record.setBenId(ancVisit.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(paiucdActivityCH.getRate())); + recordRepo.save(record); + } + + } + })); + } if (anc1Activity != null) { From e2e39cd86cc98ec4e43829f04c6a0adbc2963cd1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 14:49:14 +0530 Subject: [PATCH 586/792] update incentive code --- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index bbeac9bb..94a16a65 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -458,11 +458,9 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - if (ancVisit.getIsPaiucdId()) { + if (ancVisit.getIsPaiucd().equals("Yes")) { if (record == null) { - logger.info("record:"+record.getName()); - logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); record.setActivityId(paiucdActivityAM.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); @@ -486,11 +484,10 @@ record = new IncentiveActivityRecord(); IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - if (ancVisit.getIsPaiucdId()) { + if (ancVisit.getIsPaiucd().equals("Yes")) { if (record == null) { logger.info("record:"+record.getName()); - logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); record.setActivityId(paiucdActivityCH.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); From 1cd51f1ae7a0841230ca88ca4f49341be7c29da3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sat, 15 Nov 2025 16:37:20 +0530 Subject: [PATCH 587/792] update incentive code --- .../flw/service/impl/CoupleServiceImpl.java | 28 +++++++--- .../impl/MaternalHealthServiceImpl.java | 54 ++++++++++++++----- .../impl/VillageLevelFormServiceImpl.java | 8 +-- 3 files changed, 66 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 3d81258a..764de67c 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -293,17 +293,31 @@ private void checkAndAddAntaraIncentive(List recordList } } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MALE STERILIZATION")) { - IncentiveActivity maleSterilizationActivity = + IncentiveActivity maleSterilizationActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", "FAMILY PLANNING"); - if (maleSterilizationActivity != null) { - addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); + + IncentiveActivity maleSterilizationActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.ACTIVITY.getDisplayName()); + if (maleSterilizationActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, maleSterilizationActivityAM); + } + + if (maleSterilizationActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, maleSterilizationActivityCH); } } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("FEMALE STERILIZATION")) { - IncentiveActivity femaleSterilizationActivity = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", "FAMILY PLANNING"); - if (femaleSterilizationActivity != null) { - addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); + IncentiveActivity femaleSterilizationActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity femaleSterilizationActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.ACTIVITY.getDisplayName()); + if (femaleSterilizationActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivityAM); + } + + if (femaleSterilizationActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivityCH); } } else if (ect.getMethodOfContraception() != null && ect.getMethodOfContraception().equals("MiniLap")) { diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 94a16a65..7e7e8b9d 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -367,17 +367,31 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) logger.info("ContraceptionMethod:" + ect.getContraceptionMethod()); if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")) { - IncentiveActivity maleSterilizationActivity = + IncentiveActivity maleSterilizationActivityAM= incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); - if (maleSterilizationActivity != null) { - addIncenticeRecord(recordList, ect, userId, maleSterilizationActivity); + + IncentiveActivity maleSterilizationActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.ACTIVITY.getDisplayName()); + if (maleSterilizationActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, maleSterilizationActivityAM); + } + if (maleSterilizationActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, maleSterilizationActivityCH); } + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("FEMALE STERILIZATION")) { - IncentiveActivity femaleSterilizationActivity = + IncentiveActivity femaleSterilizationActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); - if (femaleSterilizationActivity != null) { - addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivity); + + IncentiveActivity femaleSterilizationActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_FEMALE_STER", GroupName.ACTIVITY.getDisplayName()); + if (femaleSterilizationActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivityAM); + } + + if (femaleSterilizationActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, femaleSterilizationActivityCH); } } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MiniLap")) { @@ -393,19 +407,33 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (comdomActivity != null) { addIncenticeRecord(recordList, ect, userId, comdomActivity); } - } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().contains("PPIUCD")) { + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("POST PARTUM IUCD (PPIUCD) WITHIN 48 HRS OF DELIVERY")) { - IncentiveActivity copperTActivityAM = + IncentiveActivity PPIUCDActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPIUCD", GroupName.FAMILY_PLANNING.getDisplayName()); - IncentiveActivity copperTActivityCH = + IncentiveActivity PPIUCDActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPIUCD", GroupName.ACTIVITY.getDisplayName()); - if (copperTActivityAM != null) { - addIncenticeRecord(recordList, ect, userId, copperTActivityAM); + if (PPIUCDActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, PPIUCDActivityAM); + } + + if (PPIUCDActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, PPIUCDActivityCH); + } + }else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)")) { + + IncentiveActivity ppsActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPS", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity ppsActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPS", GroupName.ACTIVITY.getDisplayName()); + if (ppsActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, ppsActivityAM); } - if (copperTActivityCH != null) { - addIncenticeRecord(recordList, ect, userId, copperTActivityCH); + if (ppsActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, ppsActivityCH); } } } diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 3821ecda..7b485b4c 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -136,7 +136,7 @@ private Boolean saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { vhncForm.setFormType("VHNC"); vhncFormRepo.save(vhncForm); - checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), vhncForm.getFormType(), vhncForm.getCreatedBy()); + checkAndAddIncentives(vhncForm.getVhncDate(), Math.toIntExact(vhncForm.getUserId()), "VHSNC_MEETING", vhncForm.getCreatedBy()); return true; } @@ -152,7 +152,7 @@ private Boolean savePhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { phcReviewForm.setImage2(dto.getImage2()); phcReviewForm.setFormType("PHC"); phcReviewFormRepo.save(phcReviewForm); - checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), phcReviewForm.getFormType(), phcReviewForm.getCreatedBy()); + checkAndAddIncentives(phcReviewForm.getPhcReviewDate(), Math.toIntExact(phcReviewForm.getUserId()), "CLUSTER_MEETING", phcReviewForm.getCreatedBy()); return true; } @@ -168,7 +168,7 @@ private Boolean saveAhdForm(AhDMeetingFormDTO dto, Integer userID) { ahdForm.setFormType("AHD"); ahdFormRepo.save(ahdForm); if (Objects.equals(dto.getMobilizedForAHD(), "Yes")) { - checkAndAddIncentives(ahdForm.getAhdDate(), Math.toIntExact(ahdForm.getUserId()), ahdForm.getFormType(), ahdForm.getCreatedBy()); + checkAndAddIncentives(ahdForm.getAhdDate(), Math.toIntExact(ahdForm.getUserId()), "AH_MOBILIZE", ahdForm.getCreatedBy()); } @@ -204,7 +204,7 @@ private Boolean saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { vhndForm.setNoOfBeneficiariesAttended(vhndFormDTO.getNoOfBeneficiariesAttended()); vhndForm.setFormType("VHND"); vhndRepo.save(vhndForm); - checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), vhndForm.getFormType(), vhndForm.getCreatedBy()); + checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), "VHND_PARTICIPATION", vhndForm.getCreatedBy()); return true; From 237e38ecbe4187d14bff35b0a2af30f93ba17444 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 16 Nov 2025 11:14:12 +0530 Subject: [PATCH 588/792] update incentive code --- .../flw/service/impl/CoupleServiceImpl.java | 16 +++++- .../impl/MaternalHealthServiceImpl.java | 53 +++++++++++++++++-- 2 files changed, 63 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 764de67c..d1963d60 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -162,6 +162,7 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) existingECR.setId(null); } + if (existingECR.getIsKitHandedOver()) { IncentiveActivity handoverKitActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_NP_KIT", GroupName.FAMILY_PLANNING.getDisplayName()); @@ -259,7 +260,7 @@ private void checkAndAddAntaraIncentive(List recordList addIncenticeRecord(recordList, ect, userId, antaraActivityCH); } - } + } if (ect.getAntraDose().contains("Dose-1")) { IncentiveActivity antaraActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", "FAMILY PLANNING"); @@ -340,6 +341,19 @@ private void checkAndAddAntaraIncentive(List recordList if (copperTActivity != null) { addIncenticeRecord(recordList, ect, userId, copperTActivity); } + } else if (ect.getMethodOfContraception() != null && (ect.getMethodOfContraception().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getMethodOfContraception().contains("MiniLap") || ect.getMethodOfContraception().contains("MALE STERILIZATION") || ect.getMethodOfContraception().contains("FEMALE STERILIZATION"))) { + IncentiveActivity limitiing2ChildActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity limitiing2ChildActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.ACTIVITY.getDisplayName()); + if (limitiing2ChildActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityAM); + } + + if (limitiing2ChildActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityCH); + } } } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 7e7e8b9d..6d65a183 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -435,6 +435,19 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (ppsActivityCH != null) { addIncenticeRecord(recordList, ect, userId, ppsActivityCH); } + }else if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ + IncentiveActivity limitiing2ChildActivityAM = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity limitiing2ChildActivityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.ACTIVITY.getDisplayName()); + if (limitiing2ChildActivityAM != null) { + addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityAM); + } + + if (limitiing2ChildActivityCH != null) { + addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityCH); + } } } @@ -471,7 +484,8 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity ancFullActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.ACTIVITY.getDisplayName()); - IncentiveActivity comprehensiveAbortionActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity comprehensiveAbortionActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity comprehensiveAbortionActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); @@ -611,10 +625,39 @@ record = new IncentiveActivityRecord(); }); } - if (comprehensiveAbortionActivity != null) { + if (comprehensiveAbortionActivityAM != null) { + + ancList.forEach((ancVisit -> { + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); + + if (ancVisit.getIsAborted()) { + + if (record == null) { + logger.info("record:"+record.getName()); + logger.info("condition:"+ancVisit.getIsAborted()); + record = new IncentiveActivityRecord(); + record.setActivityId(comprehensiveAbortionActivityAM.getId()); + record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedBy(ancVisit.getCreatedBy()); + record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedBy(ancVisit.getCreatedBy()); + record.setStartDate(ancVisit.getCreatedDate()); + record.setEndDate(ancVisit.getCreatedDate()); + record.setBenId(ancVisit.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(comprehensiveAbortionActivityAM.getRate())); + recordRepo.save(record); + } + + } + })); + } + if (comprehensiveAbortionActivityCH != null) { ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); @@ -624,7 +667,7 @@ record = new IncentiveActivityRecord(); logger.info("record:"+record.getName()); logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); - record.setActivityId(comprehensiveAbortionActivity.getId()); + record.setActivityId(comprehensiveAbortionActivityCH.getId()); record.setCreatedDate(ancVisit.getCreatedDate()); record.setCreatedBy(ancVisit.getCreatedBy()); record.setUpdatedDate(ancVisit.getCreatedDate()); @@ -633,7 +676,7 @@ record = new IncentiveActivityRecord(); record.setEndDate(ancVisit.getCreatedDate()); record.setBenId(ancVisit.getBenId()); record.setAshaId(userId); - record.setAmount(Long.valueOf(comprehensiveAbortionActivity.getRate())); + record.setAmount(Long.valueOf(comprehensiveAbortionActivityCH.getRate())); recordRepo.save(record); } From 20d431a829cf48ba775e7f201836d157abaeb212 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 16 Nov 2025 13:18:29 +0530 Subject: [PATCH 589/792] update incentive code --- src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 3 ++- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index d1963d60..d517f2d8 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -341,7 +341,8 @@ private void checkAndAddAntaraIncentive(List recordList if (copperTActivity != null) { addIncenticeRecord(recordList, ect, userId, copperTActivity); } - } else if (ect.getMethodOfContraception() != null && (ect.getMethodOfContraception().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getMethodOfContraception().contains("MiniLap") || ect.getMethodOfContraception().contains("MALE STERILIZATION") || ect.getMethodOfContraception().contains("FEMALE STERILIZATION"))) { + } + if (ect.getMethodOfContraception() != null && (ect.getMethodOfContraception().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getMethodOfContraception().contains("MiniLap") || ect.getMethodOfContraception().contains("MALE STERILIZATION") || ect.getMethodOfContraception().contains("FEMALE STERILIZATION"))) { IncentiveActivity limitiing2ChildActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 6d65a183..263efae2 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -435,7 +435,8 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (ppsActivityCH != null) { addIncenticeRecord(recordList, ect, userId, ppsActivityCH); } - }else if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ + } + if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ IncentiveActivity limitiing2ChildActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); From 8c91449fb1e27061e4de929346f4c55aafdb1fdc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 17 Nov 2025 11:25:50 +0530 Subject: [PATCH 590/792] update incentive code --- .../com/iemr/flw/service/impl/DeathReportsServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index dab80e26..82cee5d0 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -148,12 +148,11 @@ private void checkAndAddIncentivesMdsr(List mdsrList) { mdsrList.forEach( mdsr -> { - Long benId = beneficiaryRepo.getBenIdFromRegID(mdsr.getBenId()).longValue(); Integer userId = userRepo.getUserIdByName(mdsr.getCreatedBy()); IncentiveActivity immunizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MATERNAL_DEATH_REPORT", GroupName.MATERNAL_HEALTH.getDisplayName()); - createIncentiveRecord(mdsr,benId,userId,immunizationActivity); + createIncentiveRecord(mdsr,mdsr.getBenId(),userId,immunizationActivity); }); } From 306bb395b1d38c6907f1d5aed485110560df5cb3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 17 Nov 2025 14:22:54 +0530 Subject: [PATCH 591/792] update incentive code --- .../java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 4 ++++ src/main/java/com/iemr/flw/service/MaaMeetingService.java | 2 +- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 31b9624c..9a67cc11 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -17,6 +17,10 @@ public interface IncentiveRecordRepo extends JpaRepository recordList, PNCVisit ect) if (PPIUCDActivityCH != null) { addIncenticeRecord(recordList, ect, userId, PPIUCDActivityCH); } - }else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)")) { + }else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("POST PARTUM STERILIZATION (PPS)")) { IncentiveActivity ppsActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPS", GroupName.FAMILY_PLANNING.getDisplayName()); @@ -436,7 +436,7 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) addIncenticeRecord(recordList, ect, userId, ppsActivityCH); } } - if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().contains("POST PARTUM STERILIZATION (PPS WITHIN 7 DAYS OF DELIVERY)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ + if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().equals("POST PARTUM STERILIZATION (PPS)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ IncentiveActivity limitiing2ChildActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); @@ -486,7 +486,7 @@ private void checkAndAddIncentives(List ancList) { incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.ACTIVITY.getDisplayName()); IncentiveActivity comprehensiveAbortionActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity comprehensiveAbortionActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity comprehensiveAbortionActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.ACTIVITY.getDisplayName()); IncentiveActivity identifiedHrpActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity identifiedHrpActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); From e278c8eafe7886a077ad3d6f7f87564000977b53 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 17 Nov 2025 14:31:56 +0530 Subject: [PATCH 592/792] update incentive code --- .../iemr/flw/domain/iemr/MalariaFollowUp.java | 22 ++----------------- .../flw/dto/iemr/MalariaFollowListUpDTO.java | 11 +--------- .../impl/MalariaFollowUpServiceImpl.java | 8 ------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java index e881b066..cd7384e1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MalariaFollowUp.java @@ -37,26 +37,8 @@ public class MalariaFollowUp { @Column(name = "treatment_given", nullable = false) private String treatmentGiven; - @Column(name = "pf_day_1") - private Boolean pfDay1; - - @Column(name = "pf_day_2") - private Boolean pfDay2; - - @Column(name = "pf_day_3") - private Boolean pfDay3; - - @Column(name = "pv_day_1") - private Boolean pvDay1; - - @Column(name = "pv_day_2") - private Boolean pvDay2; - - @Column(name = "pv_day_3") - private Boolean pvDay3; - - @Column(name = "pv_day_4") - private Boolean pvDay4; + @Column(name = "days", nullable = false) + private String day; @Column(name = "treatment_completion_date") @Temporal(TemporalType.DATE) diff --git a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java index 5be38876..1a8b8e6e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MalariaFollowListUpDTO.java @@ -37,16 +37,7 @@ public class MalariaFollowListUpDTO { private Date dateOfDiagnosis; private Date treatmentStartDate; private String treatmentGiven; - - private Boolean pfDay1; - private Boolean pfDay2; - private Boolean pfDay3; - - private Boolean pvDay1; - private Boolean pvDay2; - private Boolean pvDay3; - private Boolean pvDay4; - + private String day; private Date treatmentCompletionDate; private Date referralDate; } diff --git a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java index 6a1a5bf9..175c3666 100644 --- a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java @@ -36,15 +36,7 @@ public Boolean saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO) { return false; } - if ("Pf".equalsIgnoreCase(dto.getTreatmentGiven()) && - !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3())) { - return false; - } - if ("Pv".equalsIgnoreCase(dto.getTreatmentGiven()) && - !(dto.getPfDay1() || dto.getPvDay2() || dto.getPfDay3()|| dto.getPvDay4())) { - return false; - } MalariaFollowUp entity = new MalariaFollowUp(); BeanUtils.copyProperties(dto, entity); From 04c9a8960c46ee4fb92dd74ce4aec2be0f221a0d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 17 Nov 2025 15:32:28 +0530 Subject: [PATCH 593/792] update incentive code --- .../iemr/flw/service/impl/VillageLevelFormServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 7b485b4c..71bbdbad 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -260,7 +260,7 @@ private void checkAndAddIncentives(String date, Integer userID, String formType, if (villageFormEntryActivityAM != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityAM.getId(), timestamp, null); + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityAM.getId(), timestamp, 0L,userID); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivityAM.getId()); @@ -280,7 +280,7 @@ record = new IncentiveActivityRecord(); if (villageFormEntryActivityCH != null) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityCH.getId(), timestamp, null); + .findRecordByActivityIdCreatedDateBenId(villageFormEntryActivityCH.getId(), timestamp, 0L,userID); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(villageFormEntryActivityCH.getId()); From 1450e5af8fdec2176dc7285fc20d818e75a0acd6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 17 Nov 2025 17:35:01 +0530 Subject: [PATCH 594/792] update incentive code --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 1 + src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 2915d6b7..1a964878 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -122,6 +122,7 @@ public List getANCVisits(GetBenRequestHandler dto) { try { String user = beneficiaryRepo.getUserName(dto.getAshaId()); List ancVisits = ancVisitRepo.getANCForPW(user, dto.getFromDate(), dto.getToDate()); + checkAndAddIncentives(ancVisits); return ancVisits.stream() .map(anc -> mapper.convertValue(anc, ANCVisitDTO.class)) .collect(Collectors.toList()); diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index e834e2b8..56a9e555 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -92,6 +92,7 @@ record = recordRepo.save(record); } + @Override public List getSammelanHistory(Integer ashaId) { List records = recordRepo.findByAshaId(ashaId); From 065c1ea8c95abc6e4f9449eb4862ef6c352ddca0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 16:19:47 +0530 Subject: [PATCH 595/792] update incentive code --- .../iemr/flw/controller/ChildCareController.java | 1 + .../service/impl/MaternalHealthServiceImpl.java | 14 +------------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index 059fc3c2..d5e4335f 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -239,6 +239,7 @@ public ResponseEntity saveSevereAcuteMalnutrition(@RequestBody List s return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } + String responseObject = childCareService.saveSamDetails(samRequest); if (responseObject != null) { diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 1a964878..3c4effc1 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -366,6 +366,7 @@ public String savePNCVisit(List pncVisitDTOs) { private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) { Integer userId = userRepo.getUserIdByName(ect.getCreatedBy()); logger.info("ContraceptionMethod:" + ect.getContraceptionMethod()); + if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")) { IncentiveActivity maleSterilizationActivityAM= @@ -437,20 +438,7 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) addIncenticeRecord(recordList, ect, userId, ppsActivityCH); } } - if(ect.getContraceptionMethod() != null && (ect.getContraceptionMethod().equals("POST PARTUM STERILIZATION (PPS)") || ect.getContraceptionMethod().contains("MiniLap") || ect.getContraceptionMethod().contains("MALE STERILIZATION") || ect.getContraceptionMethod().contains("FEMALE STERILIZATION")) ){ - IncentiveActivity limitiing2ChildActivityAM = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.FAMILY_PLANNING.getDisplayName()); - - IncentiveActivity limitiing2ChildActivityCH = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_LIMIT_2CHILD", GroupName.ACTIVITY.getDisplayName()); - if (limitiing2ChildActivityAM != null) { - addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityAM); - } - if (limitiing2ChildActivityCH != null) { - addIncenticeRecord(recordList, ect, userId, limitiing2ChildActivityCH); - } - } } private void addIncenticeRecord(List recordList, PNCVisit ect, Integer userId, IncentiveActivity antaraActivity) { From aae09ac03045d2332938d29bc7305c3a200cb25f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 17:09:12 +0530 Subject: [PATCH 596/792] update incentive code --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index d517f2d8..f6c9ef4d 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -89,11 +89,11 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, } if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { + if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 2) { IncentiveActivity activity1 = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity1); - } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 2) { + } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && it.getFirstAndSecondChildGap()!=null && it.getFirstAndSecondChildGap() == 3) { IncentiveActivity activity2 = incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity2); From b5fed5e3e080909811d8139184ac1102f596f986 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 17:27:10 +0530 Subject: [PATCH 597/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 3c4effc1..7993cbc5 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -571,16 +571,8 @@ record = new IncentiveActivityRecord(); IncentiveActivityRecord recordCH = recordRepo .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - ANCVisit visit1 = ancVisitRepo - .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 1, true); - ANCVisit visit2 = ancVisitRepo - .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 2, true); - ANCVisit visit3 = ancVisitRepo - .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 3, true); - ANCVisit visit4 = ancVisitRepo - .findANCVisitByBenIdAndAncVisitAndIsActive(ancVisit.getBenId(), 4, true); - if (recordAM == null && (visit1 != null) && (visit2 != null) && (visit3 != null) && (visit4 != null)) { + if (recordAM == null) { recordAM = new IncentiveActivityRecord(); recordAM.setActivityId(ancFullActivityAM.getId()); @@ -588,15 +580,15 @@ record = new IncentiveActivityRecord(); recordAM.setCreatedBy(ancVisit.getCreatedBy()); recordAM.setUpdatedDate(ancVisit.getAncDate()); recordAM.setUpdatedBy(ancVisit.getCreatedBy()); - recordAM.setStartDate(visit1.getAncDate()); - recordAM.setEndDate(visit4.getAncDate()); + recordAM.setStartDate(ancVisit.getAncDate()); + recordAM.setEndDate(ancVisit.getAncDate()); recordAM.setBenId(ancVisit.getBenId()); recordAM.setAshaId(userId); recordAM.setAmount(Long.valueOf(ancFullActivityAM.getRate())); recordRepo.save(recordAM); } - if (recordCH == null && (visit1 != null) && (visit2 != null) && (visit3 != null) && (visit4 != null)) { + if (recordCH == null ) { recordCH = new IncentiveActivityRecord(); recordCH.setActivityId(ancFullActivityCH.getId()); @@ -604,8 +596,8 @@ record = new IncentiveActivityRecord(); recordCH.setCreatedBy(ancVisit.getCreatedBy()); recordCH.setUpdatedDate(ancVisit.getAncDate()); recordCH.setUpdatedBy(ancVisit.getCreatedBy()); - recordCH.setStartDate(visit1.getAncDate()); - recordCH.setEndDate(visit4.getAncDate()); + recordCH.setStartDate(ancVisit.getAncDate()); + recordCH.setEndDate(ancVisit.getAncDate()); recordCH.setBenId(ancVisit.getBenId()); recordCH.setAshaId(userId); recordCH.setAmount(Long.valueOf(ancFullActivityCH.getRate())); @@ -618,7 +610,7 @@ record = new IncentiveActivityRecord(); if (comprehensiveAbortionActivityAM != null) { ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getAbortionDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); @@ -629,12 +621,12 @@ record = new IncentiveActivityRecord(); logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); record.setActivityId(comprehensiveAbortionActivityAM.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedDate(ancVisit.getAbortionDate()); record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedDate(ancVisit.getAbortionDate()); record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); + record.setStartDate(ancVisit.getAbortionDate()); + record.setEndDate(ancVisit.getAbortionDate()); record.setBenId(ancVisit.getBenId()); record.setAshaId(userId); record.setAmount(Long.valueOf(comprehensiveAbortionActivityAM.getRate())); @@ -647,7 +639,7 @@ record = new IncentiveActivityRecord(); if (comprehensiveAbortionActivityCH != null) { ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getAbortionDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); @@ -658,12 +650,12 @@ record = new IncentiveActivityRecord(); logger.info("condition:"+ancVisit.getIsAborted()); record = new IncentiveActivityRecord(); record.setActivityId(comprehensiveAbortionActivityCH.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedDate(ancVisit.getAbortionDate()); record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedDate(ancVisit.getAbortionDate()); record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); + record.setStartDate(ancVisit.getAbortionDate()); + record.setEndDate(ancVisit.getAbortionDate()); record.setBenId(ancVisit.getBenId()); record.setAshaId(userId); record.setAmount(Long.valueOf(comprehensiveAbortionActivityCH.getRate())); From 5e648796e6ab1972756e35c754ffb11a3deed868 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 17:44:54 +0530 Subject: [PATCH 598/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 7993cbc5..dcbff40d 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -135,18 +135,14 @@ public List getANCVisits(GetBenRequestHandler dto) { @Override public String saveANCVisit(List ancVisitDTOs) { try { + List ancList = new ArrayList<>(); List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { - ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); + if(ancVisitDTOs!=null){ + + ANCVisit ancVisit = new ANCVisit(); - if (ancVisit != null) { - Long id = ancVisit.getId(); - modelMapper.map(it, ancVisit); - ancVisit.setId(id); - } else { - ancVisit = new ANCVisit(); modelMapper.map(it, ancVisit); ancVisit.setId(null); @@ -183,8 +179,10 @@ public String saveANCVisit(List ancVisitDTOs) { ancCare.setLastModDate(it.getUpdatedDate()); ancCare.setProcessed("N"); ancCareList.add(ancCare); + + ancList.add(ancVisit); } - ancList.add(ancVisit); + }); ancVisitRepo.saveAll(ancList); @@ -322,7 +320,6 @@ public String savePNCVisit(List pncVisitDTOs) { Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); // Saving data in BenVisitDetails table - PregnantWomanRegister pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); BenVisitDetail benVisitDetail = new BenVisitDetail(); modelMapper.map(it, benVisitDetail); benVisitDetail.setBeneficiaryRegId(benRegId); @@ -339,11 +336,6 @@ public String savePNCVisit(List pncVisitDTOs) { modelMapper.map(it, pncCare); pncCare.setBenVisitId(benVisitDetail.getBenVisitId()); pncCare.setBeneficiaryRegId(benRegId); -// pncCare.setLastMenstrualPeriodLmp(pwr.getLmpDate()); -// Calendar cal = Calendar.getInstance(); -// cal.setTime(pwr.getLmpDate()); -// cal.add(Calendar.DAY_OF_WEEK, 280); -// pncCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); pncCare.setVisitNo((short) PNC_PERIODS.indexOf(it.getPncPeriod())); pncCare.setModifiedBy(it.getUpdatedBy()); pncCare.setLastModDate(it.getUpdatedDate()); @@ -566,10 +558,10 @@ record = new IncentiveActivityRecord(); if (ancVisit.getAncVisit() == 4) { IncentiveActivityRecord recordAM = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getAncDate(), ancVisit.getBenId()); IncentiveActivityRecord recordCH = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getAncDate(), ancVisit.getBenId()); if (recordAM == null) { From 43120f6ce33e8dd210da6d93d69ccdb278b1e0ef Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 18:31:32 +0530 Subject: [PATCH 599/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 276 ++++-------------- 1 file changed, 59 insertions(+), 217 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index dcbff40d..c67be593 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -135,14 +135,11 @@ public List getANCVisits(GetBenRequestHandler dto) { @Override public String saveANCVisit(List ancVisitDTOs) { try { + ANCVisit ancVisit = new ANCVisit(); List ancList = new ArrayList<>(); List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { - if(ancVisitDTOs!=null){ - - ANCVisit ancVisit = new ANCVisit(); - modelMapper.map(it, ancVisit); ancVisit.setId(null); @@ -180,9 +177,7 @@ public String saveANCVisit(List ancVisitDTOs) { ancCare.setProcessed("N"); ancCareList.add(ancCare); - ancList.add(ancVisit); - } - + ancList.add(ancVisit); }); ancVisitRepo.saveAll(ancList); @@ -477,240 +472,87 @@ private void checkAndAddIncentives(List ancList) { IncentiveActivity paiucdActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PAIUCD", GroupName.ACTIVITY.getDisplayName()); - if (paiucdActivityAM != null) { - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + ancList.forEach(ancVisit -> { + if (paiucdActivityAM != null) { if (ancVisit.getIsPaiucd().equals("Yes")) { - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(paiucdActivityAM.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(paiucdActivityAM.getRate())); - recordRepo.save(record); - } + recordAncRelatedIncentive(paiucdActivityAM,ancVisit); } - })); - } + } + + if (paiucdActivityCH != null) { - if (paiucdActivityCH != null) { - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(paiucdActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); if (ancVisit.getIsPaiucd().equals("Yes")) { - if (record == null) { - logger.info("record:"+record.getName()); - record = new IncentiveActivityRecord(); - record.setActivityId(paiucdActivityCH.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(paiucdActivityCH.getRate())); - recordRepo.save(record); - } + recordAncRelatedIncentive(paiucdActivityCH,ancVisit); } - })); - } - - if (anc1Activity != null) { - ancList.forEach(ancVisit -> { - - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + } + if(anc1Activity!=null){ if (ancVisit.getAncVisit() == 1) { - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(anc1Activity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(anc1Activity.getId()); - record.setCreatedDate(ancVisit.getAncDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getAncDate()); - record.setEndDate(ancVisit.getAncDate()); - record.setUpdatedDate(ancVisit.getAncDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(anc1Activity.getRate())); - recordRepo.save(record); - } + recordAncRelatedIncentive(anc1Activity,ancVisit); } - - if (ancVisit.getAncVisit() == 4) { - - IncentiveActivityRecord recordAM = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getAncDate(), ancVisit.getBenId()); - - IncentiveActivityRecord recordCH = recordRepo - .findRecordByActivityIdCreatedDateBenId(ancFullActivityAM.getId(), ancVisit.getAncDate(), ancVisit.getBenId()); - - - if (recordAM == null) { - - recordAM = new IncentiveActivityRecord(); - recordAM.setActivityId(ancFullActivityAM.getId()); - recordAM.setCreatedDate(ancVisit.getAncDate()); - recordAM.setCreatedBy(ancVisit.getCreatedBy()); - recordAM.setUpdatedDate(ancVisit.getAncDate()); - recordAM.setUpdatedBy(ancVisit.getCreatedBy()); - recordAM.setStartDate(ancVisit.getAncDate()); - recordAM.setEndDate(ancVisit.getAncDate()); - recordAM.setBenId(ancVisit.getBenId()); - recordAM.setAshaId(userId); - recordAM.setAmount(Long.valueOf(ancFullActivityAM.getRate())); - recordRepo.save(recordAM); - } - - if (recordCH == null ) { - - recordCH = new IncentiveActivityRecord(); - recordCH.setActivityId(ancFullActivityCH.getId()); - recordCH.setCreatedDate(ancVisit.getAncDate()); - recordCH.setCreatedBy(ancVisit.getCreatedBy()); - recordCH.setUpdatedDate(ancVisit.getAncDate()); - recordCH.setUpdatedBy(ancVisit.getCreatedBy()); - recordCH.setStartDate(ancVisit.getAncDate()); - recordCH.setEndDate(ancVisit.getAncDate()); - recordCH.setBenId(ancVisit.getBenId()); - recordCH.setAshaId(userId); - recordCH.setAmount(Long.valueOf(ancFullActivityCH.getRate())); - recordRepo.save(recordCH); - } + } + if(ancFullActivityAM!=null){ + if(ancVisit.getAncVisit()==4){ + recordAncRelatedIncentive(ancFullActivityAM,ancVisit); } - - }); - } - if (comprehensiveAbortionActivityAM != null) { - - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getAbortionDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); - - if (ancVisit.getIsAborted()) { - - if (record == null) { - logger.info("record:"+record.getName()); - logger.info("condition:"+ancVisit.getIsAborted()); - record = new IncentiveActivityRecord(); - record.setActivityId(comprehensiveAbortionActivityAM.getId()); - record.setCreatedDate(ancVisit.getAbortionDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getAbortionDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getAbortionDate()); - record.setEndDate(ancVisit.getAbortionDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(comprehensiveAbortionActivityAM.getRate())); - recordRepo.save(record); - } - + + } + if(ancFullActivityCH!=null){ + if(ancVisit.getAncVisit()==4){ + recordAncRelatedIncentive(ancFullActivityCH,ancVisit); } - })); - } - if (comprehensiveAbortionActivityCH != null) { - - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(comprehensiveAbortionActivityAM.getId(), ancVisit.getAbortionDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - logger.info("ancVisit.getIsAborted()"+ancVisit.getIsAborted()); - - if (ancVisit.getIsAborted()) { - - if (record == null) { - logger.info("record:"+record.getName()); - logger.info("condition:"+ancVisit.getIsAborted()); - record = new IncentiveActivityRecord(); - record.setActivityId(comprehensiveAbortionActivityCH.getId()); - record.setCreatedDate(ancVisit.getAbortionDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getAbortionDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getAbortionDate()); - record.setEndDate(ancVisit.getAbortionDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(comprehensiveAbortionActivityCH.getRate())); - recordRepo.save(record); - } - + } + if(comprehensiveAbortionActivityAM!=null){ + if(ancVisit.getIsAborted()){ + recordAncRelatedIncentive(comprehensiveAbortionActivityAM,ancVisit); } - })); - } - - if (identifiedHrpActivityAM != null) { - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityAM.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - if (ancVisit.getIsHrpConfirmed() != null) { - if (ancVisit.getIsHrpConfirmed()) { - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(identifiedHrpActivityAM.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(identifiedHrpActivityAM.getRate())); - recordRepo.save(record); - } - } + } + if(comprehensiveAbortionActivityCH!=null){ + if(ancVisit.getIsAborted()){ + recordAncRelatedIncentive(comprehensiveAbortionActivityCH,ancVisit); + } + } + if(identifiedHrpActivityAM!=null){ + if(ancVisit.getIsHrpConfirmed()){ + recordAncRelatedIncentive(identifiedHrpActivityAM,ancVisit); + } + } + if(identifiedHrpActivityCH!=null){ + if(ancVisit.getIsHrpConfirmed()){ + recordAncRelatedIncentive(identifiedHrpActivityCH,ancVisit); } - })); - } + } + }); - if (identifiedHrpActivityCH != null) { - ancList.forEach((ancVisit -> { - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(identifiedHrpActivityCH.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); - Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); - if (ancVisit.getIsHrpConfirmed() != null) { - if (ancVisit.getIsHrpConfirmed()) { - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(identifiedHrpActivityCH.getId()); - record.setCreatedDate(ancVisit.getCreatedDate()); - record.setCreatedBy(ancVisit.getCreatedBy()); - record.setUpdatedDate(ancVisit.getCreatedDate()); - record.setUpdatedBy(ancVisit.getCreatedBy()); - record.setStartDate(ancVisit.getCreatedDate()); - record.setEndDate(ancVisit.getCreatedDate()); - record.setBenId(ancVisit.getBenId()); - record.setAshaId(userId); - record.setAmount(Long.valueOf(identifiedHrpActivityCH.getRate())); - recordRepo.save(record); - } - } - } - })); + } + private void recordAncRelatedIncentive(IncentiveActivity incentiveActivity,ANCVisit ancVisit){ + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); + Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(ancVisit.getCreatedDate()); + record.setCreatedBy(ancVisit.getCreatedBy()); + record.setUpdatedDate(ancVisit.getCreatedDate()); + record.setUpdatedBy(ancVisit.getCreatedBy()); + record.setStartDate(ancVisit.getCreatedDate()); + record.setEndDate(ancVisit.getCreatedDate()); + record.setBenId(ancVisit.getBenId()); + record.setAshaId(userId); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); } } From e0c2d1216ce3f50d0c1be51299caad3a558f2210 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 18:49:41 +0530 Subject: [PATCH 600/792] update incentive code --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index c67be593..245d1e40 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -122,7 +122,6 @@ public List getANCVisits(GetBenRequestHandler dto) { try { String user = beneficiaryRepo.getUserName(dto.getAshaId()); List ancVisits = ancVisitRepo.getANCForPW(user, dto.getFromDate(), dto.getToDate()); - checkAndAddIncentives(ancVisits); return ancVisits.stream() .map(anc -> mapper.convertValue(anc, ANCVisitDTO.class)) .collect(Collectors.toList()); @@ -186,7 +185,7 @@ public String saveANCVisit(List ancVisitDTOs) { logger.info("ANC visit details saved"); return "no of anc details saved: " + ancList.size(); } catch (Exception e) { - logger.info("Saving ANC visit details failed with error : " + e.getMessage()); + logger.info("Saving ANC visit details failed with error : " + e); } return null; } From 91811029c1e34cd0820c13cf02842b04fc860450 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 18 Nov 2025 18:50:47 +0530 Subject: [PATCH 601/792] update incentive code --- .../service/impl/MaternalHealthServiceImpl.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 245d1e40..0dfd5fd3 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -134,11 +134,18 @@ public List getANCVisits(GetBenRequestHandler dto) { @Override public String saveANCVisit(List ancVisitDTOs) { try { - ANCVisit ancVisit = new ANCVisit(); - List ancList = new ArrayList<>(); List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { + ANCVisit ancVisit = + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); + + if (ancVisit != null) { + Long id = ancVisit.getId(); + modelMapper.map(it, ancVisit); + ancVisit.setId(id); + } else { + ancVisit = new ANCVisit(); modelMapper.map(it, ancVisit); ancVisit.setId(null); @@ -175,7 +182,7 @@ public String saveANCVisit(List ancVisitDTOs) { ancCare.setLastModDate(it.getUpdatedDate()); ancCare.setProcessed("N"); ancCareList.add(ancCare); - + } ancList.add(ancVisit); }); @@ -185,6 +192,7 @@ public String saveANCVisit(List ancVisitDTOs) { logger.info("ANC visit details saved"); return "no of anc details saved: " + ancList.size(); } catch (Exception e) { + logger.info("Saving ANC visit details failed with error : " + e.getMessage()); logger.info("Saving ANC visit details failed with error : " + e); } return null; From d63edf334187da566160844721d5ac3408a53773 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 11:35:44 +0530 Subject: [PATCH 602/792] update incentive code --- src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java | 2 +- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java index 8fc40fc1..3d8b451b 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java @@ -18,5 +18,5 @@ List getANCForPW(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); @Query - ANCVisit findANCVisitByBenIdAndAncVisitAndIsActive(Long benId, Integer ancVisit, Boolean isActive); + ANCVisit findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(Long benId, Integer ancVisit, Boolean isActive,String createdBy); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 0dfd5fd3..7440dd2e 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -138,7 +138,7 @@ public String saveANCVisit(List ancVisitDTOs) { List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); if (ancVisit != null) { Long id = ancVisit.getId(); From 04fc3cb3ce7e5c674fe765fcf75d0a8ebe846e63 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 11:37:59 +0530 Subject: [PATCH 603/792] update incentive code --- .../com/iemr/flw/repo/iemr/ANCVisitRepo.java | 2 +- .../repo/iemr/PregnantWomanRegisterRepo.java | 2 +- .../impl/MaternalHealthServiceImpl.java | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java index 3d8b451b..8fc40fc1 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java @@ -18,5 +18,5 @@ List getANCForPW(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); @Query - ANCVisit findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(Long benId, Integer ancVisit, Boolean isActive,String createdBy); + ANCVisit findANCVisitByBenIdAndAncVisitAndIsActive(Long benId, Integer ancVisit, Boolean isActive); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java b/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java index 26071744..0d008a14 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java @@ -16,6 +16,6 @@ public interface PregnantWomanRegisterRepo extends JpaRepository getPWRWithBen(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); - PregnantWomanRegister findPregnantWomanRegisterByBenIdAndIsActive(Long benId, Boolean isActive); + List findPregnantWomanRegisterByBenIdAndIsActive(Long benId, Boolean isActive); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 7440dd2e..b0308d28 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -77,19 +77,19 @@ public String registerPregnantWoman(List pregnantWomanDTOs) { try { List pwrList = new ArrayList<>(); pregnantWomanDTOs.forEach(it -> { - PregnantWomanRegister pwr = + List< PregnantWomanRegister> pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); if (pwr != null) { - Long id = pwr.getId(); + Long id = pwr.get(0).getId(); modelMapper.map(it, pwr); - pwr.setId(id); + pwr.get(0).setId(id); } else { - pwr = new PregnantWomanRegister(); + pwr = new ArrayList<>(); modelMapper.map(it, pwr); - pwr.setId(null); + pwr.get(0).setId(null); } - pwrList.add(pwr); + pwrList.add(pwr.get(0)); }); pregnantWomanRegisterRepo.saveAll(pwrList); @@ -138,7 +138,7 @@ public String saveANCVisit(List ancVisitDTOs) { List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); if (ancVisit != null) { Long id = ancVisit.getId(); @@ -152,7 +152,7 @@ public String saveANCVisit(List ancVisitDTOs) { Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); // Saving data in BenVisitDetails table - PregnantWomanRegister pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); + List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); BenVisitDetail benVisitDetail = new BenVisitDetail(); modelMapper.map(it, benVisitDetail); benVisitDetail.setBeneficiaryRegId(benRegId); @@ -171,9 +171,9 @@ public String saveANCVisit(List ancVisitDTOs) { ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); ancCare.setBeneficiaryRegId(benRegId); if (pwr != null) { - ancCare.setLastMenstrualPeriodLmp(pwr.getLmpDate()); + ancCare.setLastMenstrualPeriodLmp(pwr.get(0).getLmpDate()); Calendar cal = Calendar.getInstance(); - cal.setTime(pwr.getLmpDate()); + cal.setTime(pwr.get(0).getLmpDate()); cal.add(Calendar.DAY_OF_WEEK, 280); ancCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); } From 550fe26322e357d68b1ffa94e42871c3c6588313 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 11:44:46 +0530 Subject: [PATCH 604/792] update incentive code --- src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java | 2 +- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java index 8fc40fc1..3d8b451b 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java @@ -18,5 +18,5 @@ List getANCForPW(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); @Query - ANCVisit findANCVisitByBenIdAndAncVisitAndIsActive(Long benId, Integer ancVisit, Boolean isActive); + ANCVisit findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(Long benId, Integer ancVisit, Boolean isActive,String createdBy); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index b0308d28..670442ea 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -138,7 +138,7 @@ public String saveANCVisit(List ancVisitDTOs) { List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); if (ancVisit != null) { Long id = ancVisit.getId(); From 51c1ffc81a34bc7f267a95f166d1211875db0a5d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 12:13:34 +0530 Subject: [PATCH 605/792] update incentive code --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 670442ea..d430bebf 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -77,7 +77,7 @@ public String registerPregnantWoman(List pregnantWomanDTOs) { try { List pwrList = new ArrayList<>(); pregnantWomanDTOs.forEach(it -> { - List< PregnantWomanRegister> pwr = + List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); if (pwr != null) { @@ -153,6 +153,7 @@ public String saveANCVisit(List ancVisitDTOs) { // Saving data in BenVisitDetails table List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); + logger.info("PWR"+pwr.size()); BenVisitDetail benVisitDetail = new BenVisitDetail(); modelMapper.map(it, benVisitDetail); benVisitDetail.setBeneficiaryRegId(benRegId); From c9a4607ad552cb2f96faf2033b233be2f3d7a63b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 12:45:43 +0530 Subject: [PATCH 606/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 123 +++++++++--------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index d430bebf..49676794 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -133,70 +133,73 @@ public List getANCVisits(GetBenRequestHandler dto) { @Override public String saveANCVisit(List ancVisitDTOs) { - try { - List ancList = new ArrayList<>(); - List ancCareList = new ArrayList<>(); - ancVisitDTOs.forEach(it -> { - ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); - - if (ancVisit != null) { - Long id = ancVisit.getId(); - modelMapper.map(it, ancVisit); - ancVisit.setId(id); - } else { - ancVisit = new ANCVisit(); - modelMapper.map(it, ancVisit); - ancVisit.setId(null); - - Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); - // Saving data in BenVisitDetails table - List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); - logger.info("PWR"+pwr.size()); - BenVisitDetail benVisitDetail = new BenVisitDetail(); - modelMapper.map(it, benVisitDetail); - benVisitDetail.setBeneficiaryRegId(benRegId); - benVisitDetail.setVisitCategory("ANC"); - benVisitDetail.setVisitReason("Follow Up"); - benVisitDetail.setPregnancyStatus("Yes"); - benVisitDetail.setProcessed("N"); - benVisitDetail.setModifiedBy(it.getUpdatedBy()); - benVisitDetail.setLastModDate(it.getUpdatedDate()); - benVisitDetail.setProviderServiceMapID(it.getProviderServiceMapID()); - benVisitDetail = benVisitDetailsRepo.save(benVisitDetail); + List ancList = new ArrayList<>(); + List ancCareList = new ArrayList<>(); + ancVisitDTOs.forEach(it -> { + ANCVisit ancVisit = + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); + + if (ancVisit != null) { + Long id = ancVisit.getId(); + modelMapper.map(it, ancVisit); + ancVisit.setId(id); + } else { + ancVisit = new ANCVisit(); + modelMapper.map(it, ancVisit); + ancVisit.setId(null); + + Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); + + // Saving data in BenVisitDetails table + BenVisitDetail benVisitDetail = new BenVisitDetail(); + modelMapper.map(it, benVisitDetail); + benVisitDetail.setBeneficiaryRegId(benRegId); + benVisitDetail.setVisitCategory("ANC"); + benVisitDetail.setVisitReason("Follow Up"); + benVisitDetail.setPregnancyStatus("Yes"); + benVisitDetail.setProcessed("N"); + benVisitDetail.setModifiedBy(it.getUpdatedBy()); + benVisitDetail.setLastModDate(it.getUpdatedDate()); + benVisitDetail.setProviderServiceMapID(it.getProviderServiceMapID()); + benVisitDetail = benVisitDetailsRepo.save(benVisitDetail); + + // Saving Data in AncCare table + AncCare ancCare = new AncCare(); + modelMapper.map(it, ancCare); + ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); + ancCare.setBeneficiaryRegId(benRegId); + List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); + logger.info("PWR"+pwr.size()); - // Saving Data in AncCare table - AncCare ancCare = new AncCare(); - modelMapper.map(it, ancCare); - ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); - ancCare.setBeneficiaryRegId(benRegId); - if (pwr != null) { - ancCare.setLastMenstrualPeriodLmp(pwr.get(0).getLmpDate()); - Calendar cal = Calendar.getInstance(); - cal.setTime(pwr.get(0).getLmpDate()); - cal.add(Calendar.DAY_OF_WEEK, 280); - ancCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); - } - ancCare.setTrimesterNumber(it.getAncVisit().shortValue()); - ancCare.setModifiedBy(it.getUpdatedBy()); - ancCare.setLastModDate(it.getUpdatedDate()); - ancCare.setProcessed("N"); - ancCareList.add(ancCare); + if (pwr != null) { + ancCare.setLastMenstrualPeriodLmp(pwr.get(0).getLmpDate()); + Calendar cal = Calendar.getInstance(); + cal.setTime(pwr.get(0).getLmpDate()); + cal.add(Calendar.DAY_OF_WEEK, 280); + ancCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); } - ancList.add(ancVisit); - }); + ancCare.setTrimesterNumber(it.getAncVisit().shortValue()); + ancCare.setModifiedBy(it.getUpdatedBy()); + ancCare.setLastModDate(it.getUpdatedDate()); + ancCare.setProcessed("N"); + ancCareList.add(ancCare); + } + ancList.add(ancVisit); + }); - ancVisitRepo.saveAll(ancList); - ancCareRepo.saveAll(ancCareList); - checkAndAddIncentives(ancList); - logger.info("ANC visit details saved"); - return "no of anc details saved: " + ancList.size(); - } catch (Exception e) { - logger.info("Saving ANC visit details failed with error : " + e.getMessage()); - logger.info("Saving ANC visit details failed with error : " + e); - } - return null; + ancVisitRepo.saveAll(ancList); + checkAndAddIncentives(ancList); + ancCareRepo.saveAll(ancCareList); + logger.info("ANC visit details saved"); + return "no of anc details saved: " + ancList.size(); +// try { +// +// } catch (Exception e) { +// logger.info("Saving ANC visit details failed with error : " + e.getMessage()); +// logger.info("Saving ANC visit details failed with error : " + e); +// } + // return null; } @Override From 993c3cc79b6aeba347b9137d0482e674344eacee Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 12:54:03 +0530 Subject: [PATCH 607/792] update incentive code --- src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java index 59ff225c..264fe6c1 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.sql.Timestamp; @@ -8,6 +9,8 @@ public class DeliveryOutcomeDTO { private Long id; private Long benId; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy, hh:mm:ss a", locale = "en") private Timestamp dateOfDelivery; private String timeOfDelivery; private String placeOfDelivery; From bb0437d9a80fe3cd38ab296500919ee4212db10a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 13:00:49 +0530 Subject: [PATCH 608/792] update incentive code --- .../java/com/iemr/flw/controller/MaternalHealthController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index a4eed784..c1ef826f 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -109,7 +109,8 @@ public String saveANCVisit(@RequestBody List ancVisitDTOs, } else response.setError(5000, "Invalid/NULL request obj"); } catch (Exception e) { - logger.error("Error in save ANC visit details : " + e); + logger.error("Error in save ANC visit details : " ,e); + response.setError(5000, "Error in save ANC visit details : " + e); } return response.toString(); From 2982f8b2cd956d86478b400ca848b3c72d27d555 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 13:42:35 +0530 Subject: [PATCH 609/792] update incentive code --- .../controller/MaternalHealthController.java | 2 +- .../com/iemr/flw/repo/iemr/ANCVisitRepo.java | 4 +- .../repo/iemr/PregnantWomanRegisterRepo.java | 2 +- .../impl/MaternalHealthServiceImpl.java | 142 +++++++++--------- 4 files changed, 74 insertions(+), 76 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index c1ef826f..e23cc8ed 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -109,7 +109,7 @@ public String saveANCVisit(@RequestBody List ancVisitDTOs, } else response.setError(5000, "Invalid/NULL request obj"); } catch (Exception e) { - logger.error("Error in save ANC visit details : " ,e); + logger.error("Error in save ANC visit details : ",e); response.setError(5000, "Error in save ANC visit details : " + e); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java index 3d8b451b..725bc0e2 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java @@ -17,6 +17,8 @@ public interface ANCVisitRepo extends JpaRepository { List getANCForPW(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); + @Query - ANCVisit findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(Long benId, Integer ancVisit, Boolean isActive,String createdBy); + ANCVisit findANCVisitByBenIdAndAncVisictAndIsActive(Long benId, Integer ancVisit, boolean b); + } diff --git a/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java b/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java index 0d008a14..26071744 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/PregnantWomanRegisterRepo.java @@ -16,6 +16,6 @@ public interface PregnantWomanRegisterRepo extends JpaRepository getPWRWithBen(@Param("userId") String userId, @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate); - List findPregnantWomanRegisterByBenIdAndIsActive(Long benId, Boolean isActive); + PregnantWomanRegister findPregnantWomanRegisterByBenIdAndIsActive(Long benId, Boolean isActive); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 49676794..97c28e02 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -77,19 +77,19 @@ public String registerPregnantWoman(List pregnantWomanDTOs) { try { List pwrList = new ArrayList<>(); pregnantWomanDTOs.forEach(it -> { - List pwr = + PregnantWomanRegister pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); if (pwr != null) { - Long id = pwr.get(0).getId(); + Long id = pwr.getId(); modelMapper.map(it, pwr); - pwr.get(0).setId(id); + pwr.setId(id); } else { - pwr = new ArrayList<>(); + pwr = new PregnantWomanRegister(); modelMapper.map(it, pwr); - pwr.get(0).setId(null); + pwr.setId(null); } - pwrList.add(pwr.get(0)); + pwrList.add(pwr); }); pregnantWomanRegisterRepo.saveAll(pwrList); @@ -133,73 +133,69 @@ public List getANCVisits(GetBenRequestHandler dto) { @Override public String saveANCVisit(List ancVisitDTOs) { + try { + List ancList = new ArrayList<>(); + List ancCareList = new ArrayList<>(); + ancVisitDTOs.forEach(it -> { + ANCVisit ancVisit = + ancVisitRepo.findANCVisitByBenIdAndAncVisictAndIsActive(it.getBenId(), it.getAncVisit(), true); + + if (ancVisit != null) { + Long id = ancVisit.getId(); + modelMapper.map(it, ancVisit); + ancVisit.setId(id); + } else { + ancVisit = new ANCVisit(); + modelMapper.map(it, ancVisit); + ancVisit.setId(null); - List ancList = new ArrayList<>(); - List ancCareList = new ArrayList<>(); - ancVisitDTOs.forEach(it -> { - ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActiveAndCreatedBy(it.getBenId(), it.getAncVisit(), true,it.getCreatedBy()); - - if (ancVisit != null) { - Long id = ancVisit.getId(); - modelMapper.map(it, ancVisit); - ancVisit.setId(id); - } else { - ancVisit = new ANCVisit(); - modelMapper.map(it, ancVisit); - ancVisit.setId(null); - - Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); - - // Saving data in BenVisitDetails table - BenVisitDetail benVisitDetail = new BenVisitDetail(); - modelMapper.map(it, benVisitDetail); - benVisitDetail.setBeneficiaryRegId(benRegId); - benVisitDetail.setVisitCategory("ANC"); - benVisitDetail.setVisitReason("Follow Up"); - benVisitDetail.setPregnancyStatus("Yes"); - benVisitDetail.setProcessed("N"); - benVisitDetail.setModifiedBy(it.getUpdatedBy()); - benVisitDetail.setLastModDate(it.getUpdatedDate()); - benVisitDetail.setProviderServiceMapID(it.getProviderServiceMapID()); - benVisitDetail = benVisitDetailsRepo.save(benVisitDetail); - - // Saving Data in AncCare table - AncCare ancCare = new AncCare(); - modelMapper.map(it, ancCare); - ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); - ancCare.setBeneficiaryRegId(benRegId); - List pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); - logger.info("PWR"+pwr.size()); + Long benRegId = beneficiaryRepo.getRegIDFromBenId(it.getBenId()); - if (pwr != null) { - ancCare.setLastMenstrualPeriodLmp(pwr.get(0).getLmpDate()); - Calendar cal = Calendar.getInstance(); - cal.setTime(pwr.get(0).getLmpDate()); - cal.add(Calendar.DAY_OF_WEEK, 280); - ancCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); + // Saving data in BenVisitDetails table + PregnantWomanRegister pwr = pregnantWomanRegisterRepo.findPregnantWomanRegisterByBenIdAndIsActive(it.getBenId(), true); + BenVisitDetail benVisitDetail = new BenVisitDetail(); + modelMapper.map(it, benVisitDetail); + benVisitDetail.setBeneficiaryRegId(benRegId); + benVisitDetail.setVisitCategory("ANC"); + benVisitDetail.setVisitReason("Follow Up"); + benVisitDetail.setPregnancyStatus("Yes"); + benVisitDetail.setProcessed("N"); + benVisitDetail.setModifiedBy(it.getUpdatedBy()); + benVisitDetail.setLastModDate(it.getUpdatedDate()); + benVisitDetail.setProviderServiceMapID(it.getProviderServiceMapID()); + benVisitDetail = benVisitDetailsRepo.save(benVisitDetail); + + // Saving Data in AncCare table + AncCare ancCare = new AncCare(); + modelMapper.map(it, ancCare); + ancCare.setBenVisitId(benVisitDetail.getBenVisitId()); + ancCare.setBeneficiaryRegId(benRegId); + if (pwr != null) { + ancCare.setLastMenstrualPeriodLmp(pwr.getLmpDate()); + Calendar cal = Calendar.getInstance(); + cal.setTime(pwr.getLmpDate()); + cal.add(Calendar.DAY_OF_WEEK, 280); + ancCare.setExpectedDateofDelivery(new Timestamp(cal.getTime().getTime())); + } + ancCare.setTrimesterNumber(it.getAncVisit().shortValue()); + ancCare.setModifiedBy(it.getUpdatedBy()); + ancCare.setLastModDate(it.getUpdatedDate()); + ancCare.setProcessed("N"); + ancCareList.add(ancCare); } - ancCare.setTrimesterNumber(it.getAncVisit().shortValue()); - ancCare.setModifiedBy(it.getUpdatedBy()); - ancCare.setLastModDate(it.getUpdatedDate()); - ancCare.setProcessed("N"); - ancCareList.add(ancCare); - } - ancList.add(ancVisit); - }); + ancList.add(ancVisit); + }); - ancVisitRepo.saveAll(ancList); - checkAndAddIncentives(ancList); - ancCareRepo.saveAll(ancCareList); - logger.info("ANC visit details saved"); - return "no of anc details saved: " + ancList.size(); -// try { -// -// } catch (Exception e) { -// logger.info("Saving ANC visit details failed with error : " + e.getMessage()); -// logger.info("Saving ANC visit details failed with error : " + e); -// } - // return null; + ancVisitRepo.saveAll(ancList); + ancCareRepo.saveAll(ancCareList); + checkAndAddIncentives(ancList); + logger.info("ANC visit details saved"); + return "no of anc details saved: " + ancList.size(); + } catch (Exception e) { + logger.info("Saving ANC visit details failed with error : " + e.getMessage()); + logger.info("Saving ANC visit details failed with error : " + e); + } + return null; } @Override @@ -236,7 +232,7 @@ public String savePmsmaRecords(List pmsmaDTOs) { }); pmsmaRepo.saveAll(pmsmaList); logger.info("PMSMA details saved"); - checkAndAddHighRisk(pmsmaList); + checkAndAddHighRisk(pmsmaList); return "No. of PMSMA records saved: " + pmsmaList.size(); } catch (Exception e) { @@ -498,21 +494,21 @@ private void checkAndAddIncentives(List ancList) { if (ancVisit.getIsPaiucd().equals("Yes")) { - recordAncRelatedIncentive(paiucdActivityCH,ancVisit); + recordAncRelatedIncentive(paiucdActivityCH,ancVisit); } } if(anc1Activity!=null){ if (ancVisit.getAncVisit() == 1) { - recordAncRelatedIncentive(anc1Activity,ancVisit); + recordAncRelatedIncentive(anc1Activity,ancVisit); } } if(ancFullActivityAM!=null){ if(ancVisit.getAncVisit()==4){ recordAncRelatedIncentive(ancFullActivityAM,ancVisit); } - + } if(ancFullActivityCH!=null){ if(ancVisit.getAncVisit()==4){ From 4181fddc143be9157b9033df5b74011b00801502 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 13:48:32 +0530 Subject: [PATCH 610/792] update incentive code --- src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java | 2 +- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java index 725bc0e2..067e6acc 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ANCVisitRepo.java @@ -19,6 +19,6 @@ List getANCForPW(@Param("userId") String userId, @Query - ANCVisit findANCVisitByBenIdAndAncVisictAndIsActive(Long benId, Integer ancVisit, boolean b); + ANCVisit findANCVisitByBenIdAndAncVisitAndIsActive(Long benId, Integer ancVisit, boolean b); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 97c28e02..798965eb 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -138,7 +138,7 @@ public String saveANCVisit(List ancVisitDTOs) { List ancCareList = new ArrayList<>(); ancVisitDTOs.forEach(it -> { ANCVisit ancVisit = - ancVisitRepo.findANCVisitByBenIdAndAncVisictAndIsActive(it.getBenId(), it.getAncVisit(), true); + ancVisitRepo.findANCVisitByBenIdAndAncVisitAndIsActive(it.getBenId(), it.getAncVisit(), true); if (ancVisit != null) { Long id = ancVisit.getId(); From 6a23658ef61e2fa57bfea0dc0b0563c6093d878e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 14:38:59 +0530 Subject: [PATCH 611/792] update incentive code --- .../flw/service/impl/MaternalHealthServiceImpl.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 798965eb..800f90a1 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -482,11 +482,13 @@ private void checkAndAddIncentives(List ancList) { ancList.forEach(ancVisit -> { if (paiucdActivityAM != null) { - if (ancVisit.getIsPaiucd().equals("Yes")) { - - recordAncRelatedIncentive(paiucdActivityAM,ancVisit); + if(ancVisit.getIsPaiucd()!=null){ + if (ancVisit.getIsPaiucd().equals("Yes")) { + recordAncRelatedIncentive(paiucdActivityAM,ancVisit); + } } + } if (paiucdActivityCH != null) { @@ -505,7 +507,7 @@ private void checkAndAddIncentives(List ancList) { } } if(ancFullActivityAM!=null){ - if(ancVisit.getAncVisit()==4){ + if(ancVisit.getAncVisit() == 4){ recordAncRelatedIncentive(ancFullActivityAM,ancVisit); } From 59732b8c4d484b1760b261fe08bce1743b662da0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 14:44:18 +0530 Subject: [PATCH 612/792] update incentive code --- .../iemr/flw/service/impl/MaternalHealthServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 800f90a1..ea484bc1 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -493,13 +493,15 @@ private void checkAndAddIncentives(List ancList) { if (paiucdActivityCH != null) { + if(ancVisit.getIsPaiucdId()!=null){ + if (ancVisit.getIsPaiucd().equals("Yes")) { - if (ancVisit.getIsPaiucd().equals("Yes")) { - - recordAncRelatedIncentive(paiucdActivityCH,ancVisit); + recordAncRelatedIncentive(paiucdActivityCH,ancVisit); + } } + } if(anc1Activity!=null){ if (ancVisit.getAncVisit() == 1) { From f7ce033598f2a7490f106b73afa22aa720535267 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 14:48:36 +0530 Subject: [PATCH 613/792] update incentive code --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index ea484bc1..21ce7990 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -493,7 +493,7 @@ private void checkAndAddIncentives(List ancList) { if (paiucdActivityCH != null) { - if(ancVisit.getIsPaiucdId()!=null){ + if(ancVisit.getIsPaiucd()!=null){ if (ancVisit.getIsPaiucd().equals("Yes")) { recordAncRelatedIncentive(paiucdActivityCH,ancVisit); From 0c9a69879196dcfec06037ed893bb3f091adeda9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 14:59:09 +0530 Subject: [PATCH 614/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 21ce7990..9d200586 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -504,8 +504,11 @@ private void checkAndAddIncentives(List ancList) { } if(anc1Activity!=null){ - if (ancVisit.getAncVisit() == 1) { - recordAncRelatedIncentive(anc1Activity,ancVisit); + if(ancVisit.getAncVisit()!=null) { + + if (ancVisit.getAncVisit() == 1) { + recordAncRelatedIncentive(anc1Activity, ancVisit); + } } } if(ancFullActivityAM!=null){ @@ -515,31 +518,46 @@ private void checkAndAddIncentives(List ancList) { } if(ancFullActivityCH!=null){ - if(ancVisit.getAncVisit()==4){ - recordAncRelatedIncentive(ancFullActivityCH,ancVisit); + if(ancVisit.getAncVisit()!=null){ + if(ancVisit.getAncVisit()==4){ + recordAncRelatedIncentive(ancFullActivityCH,ancVisit); + } } + } if(comprehensiveAbortionActivityAM!=null){ - if(ancVisit.getIsAborted()){ - recordAncRelatedIncentive(comprehensiveAbortionActivityAM,ancVisit); + if(ancVisit.getIsAborted()!=null){ + if(ancVisit.getIsAborted()){ + recordAncRelatedIncentive(comprehensiveAbortionActivityAM,ancVisit); + } } + } if(comprehensiveAbortionActivityCH!=null){ - if(ancVisit.getIsAborted()){ - recordAncRelatedIncentive(comprehensiveAbortionActivityCH,ancVisit); + if(ancVisit.getIsAborted()!=null){ + if(ancVisit.getIsAborted()){ + recordAncRelatedIncentive(comprehensiveAbortionActivityCH,ancVisit); + } } + } if(identifiedHrpActivityAM!=null){ - if(ancVisit.getIsHrpConfirmed()){ - recordAncRelatedIncentive(identifiedHrpActivityAM,ancVisit); + if(ancVisit.getIsHrpConfirmed()!=null){ + if(ancVisit.getIsHrpConfirmed()){ + recordAncRelatedIncentive(identifiedHrpActivityAM,ancVisit); + } } + } if(identifiedHrpActivityCH!=null){ - if(ancVisit.getIsHrpConfirmed()){ - recordAncRelatedIncentive(identifiedHrpActivityCH,ancVisit); + if(ancVisit.getIsHrpConfirmed()!=null){ + if(ancVisit.getIsHrpConfirmed()){ + recordAncRelatedIncentive(identifiedHrpActivityCH,ancVisit); + } } + } }); From 43832059072324dd3d725090818c68600486dcc5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 19 Nov 2025 17:16:53 +0530 Subject: [PATCH 615/792] update incentive code --- .../impl/MaternalHealthServiceImpl.java | 84 +++++++++---------- .../impl/MicroBirthPlanServiceImpl.java | 4 - .../service/impl/UwinSessionServiceImpl.java | 2 +- 3 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 9d200586..1de45e6e 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -242,22 +242,22 @@ public String savePmsmaRecords(List pmsmaDTOs) { } private void checkAndAddHighRisk(List pmsmaList) { - IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED",GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED",GroupName.ACTIVITY.getDisplayName()); - if(incentiveActivityAM!=null){ + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.MATERNAL_HEALTH.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("EPMSMA_HRP_IDENTIFIED", GroupName.ACTIVITY.getDisplayName()); + if (incentiveActivityAM != null) { pmsmaList.forEach(pmsma -> { - if(pmsma.getHighRiskPregnant()){ - addIncentiveForHighRisk(incentiveActivityAM,pmsma); + if (pmsma.getHighRiskPregnant()) { + addIncentiveForHighRisk(incentiveActivityAM, pmsma); } }); } - if(incentiveActivityCH!=null){ + if (incentiveActivityCH != null) { pmsmaList.forEach(pmsma -> { - if(pmsma.getHighRiskPregnant()){ - addIncentiveForHighRisk(incentiveActivityCH,pmsma); + if (pmsma.getHighRiskPregnant()) { + addIncentiveForHighRisk(incentiveActivityCH, pmsma); } @@ -363,7 +363,7 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("MALE STERILIZATION")) { - IncentiveActivity maleSterilizationActivityAM= + IncentiveActivity maleSterilizationActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_MALE_STER", GroupName.FAMILY_PLANNING.getDisplayName()); IncentiveActivity maleSterilizationActivityCH = @@ -417,7 +417,7 @@ private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) if (PPIUCDActivityCH != null) { addIncenticeRecord(recordList, ect, userId, PPIUCDActivityCH); } - }else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("POST PARTUM STERILIZATION (PPS)")) { + } else if (ect.getContraceptionMethod() != null && ect.getContraceptionMethod().equals("POST PARTUM STERILIZATION (PPS)")) { IncentiveActivity ppsActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_PPS", GroupName.FAMILY_PLANNING.getDisplayName()); @@ -466,7 +466,7 @@ private void checkAndAddIncentives(List ancList) { incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity ancFullActivityCH = - incentivesRepo.findIncentiveMasterByNameAndGroup("FULL_ANC", GroupName.ACTIVITY.getDisplayName()); + incentivesRepo.findIncentiveMasterByNameAndGroup("ANC_FOUR_CHECKUPS_SUPPORT", GroupName.ACTIVITY.getDisplayName()); IncentiveActivity comprehensiveAbortionActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity comprehensiveAbortionActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("COMPREHENSIVE_ABORTION_CARE", GroupName.ACTIVITY.getDisplayName()); @@ -482,9 +482,9 @@ private void checkAndAddIncentives(List ancList) { ancList.forEach(ancVisit -> { if (paiucdActivityAM != null) { - if(ancVisit.getIsPaiucd()!=null){ + if (ancVisit.getIsPaiucd()!= null) { if (ancVisit.getIsPaiucd().equals("Yes")) { - recordAncRelatedIncentive(paiucdActivityAM,ancVisit); + recordAncRelatedIncentive(paiucdActivityAM, ancVisit); } } @@ -493,68 +493,68 @@ private void checkAndAddIncentives(List ancList) { if (paiucdActivityCH != null) { - if(ancVisit.getIsPaiucd()!=null){ + if (ancVisit.getIsPaiucd()!= null) { if (ancVisit.getIsPaiucd().equals("Yes")) { - recordAncRelatedIncentive(paiucdActivityCH,ancVisit); + recordAncRelatedIncentive(paiucdActivityCH, ancVisit); } } } - if(anc1Activity!=null){ - if(ancVisit.getAncVisit()!=null) { + if (anc1Activity != null) { + if (ancVisit.getAncVisit() != null) { if (ancVisit.getAncVisit() == 1) { recordAncRelatedIncentive(anc1Activity, ancVisit); } } } - if(ancFullActivityAM!=null){ - if(ancVisit.getAncVisit() == 4){ - recordAncRelatedIncentive(ancFullActivityAM,ancVisit); + if (ancFullActivityAM != null) { + if (ancVisit.getAncVisit() == 4) { + recordAncRelatedIncentive(ancFullActivityAM, ancVisit); } } - if(ancFullActivityCH!=null){ - if(ancVisit.getAncVisit()!=null){ - if(ancVisit.getAncVisit()==4){ - recordAncRelatedIncentive(ancFullActivityCH,ancVisit); + if (ancFullActivityCH != null) { + if (ancVisit.getAncVisit() != null) { + if (ancVisit.getAncVisit() == 4) { + recordAncRelatedIncentive(ancFullActivityCH, ancVisit); } } } - if(comprehensiveAbortionActivityAM!=null){ - if(ancVisit.getIsAborted()!=null){ - if(ancVisit.getIsAborted()){ - recordAncRelatedIncentive(comprehensiveAbortionActivityAM,ancVisit); + if (comprehensiveAbortionActivityAM != null) { + if (ancVisit.getIsAborted() != null) { + if (ancVisit.getIsAborted()) { + recordAncRelatedIncentive(comprehensiveAbortionActivityAM, ancVisit); } } } - if(comprehensiveAbortionActivityCH!=null){ - if(ancVisit.getIsAborted()!=null){ - if(ancVisit.getIsAborted()){ - recordAncRelatedIncentive(comprehensiveAbortionActivityCH,ancVisit); + if (comprehensiveAbortionActivityCH != null) { + if (ancVisit.getIsAborted() != null) { + if (ancVisit.getIsAborted()) { + recordAncRelatedIncentive(comprehensiveAbortionActivityCH, ancVisit); } } } - if(identifiedHrpActivityAM!=null){ - if(ancVisit.getIsHrpConfirmed()!=null){ - if(ancVisit.getIsHrpConfirmed()){ - recordAncRelatedIncentive(identifiedHrpActivityAM,ancVisit); + if (identifiedHrpActivityAM != null) { + if (ancVisit.getIsHrpConfirmed() != null) { + if (ancVisit.getIsHrpConfirmed()) { + recordAncRelatedIncentive(identifiedHrpActivityAM, ancVisit); } } } - if(identifiedHrpActivityCH!=null){ - if(ancVisit.getIsHrpConfirmed()!=null){ - if(ancVisit.getIsHrpConfirmed()){ - recordAncRelatedIncentive(identifiedHrpActivityCH,ancVisit); + if (identifiedHrpActivityCH != null) { + if (ancVisit.getIsHrpConfirmed() != null) { + if (ancVisit.getIsHrpConfirmed()) { + recordAncRelatedIncentive(identifiedHrpActivityCH, ancVisit); } } @@ -563,9 +563,9 @@ private void checkAndAddIncentives(List ancList) { }); - } - private void recordAncRelatedIncentive(IncentiveActivity incentiveActivity,ANCVisit ancVisit){ + + private void recordAncRelatedIncentive(IncentiveActivity incentiveActivity, ANCVisit ancVisit) { IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), ancVisit.getCreatedDate(), ancVisit.getBenId()); Integer userId = userRepo.getUserIdByName(ancVisit.getCreatedBy()); diff --git a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java index 42e3be9a..1c9130a0 100644 --- a/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MicroBirthPlanServiceImpl.java @@ -47,10 +47,6 @@ public List getAllMicroBirthPlans(Integer userId) { } - - - - private MicroBirthPlan updateMicroBirthPlan(Long id, MicroBirthPlan updatedPlan){ return microBirthPlanRepository.findByBenId(id).map(existingPlan -> { existingPlan.setContactNumber1(updatedPlan.getContactNumber1()); diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index 1add9c38..a54c2db8 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -134,7 +134,7 @@ private void checkAndAddIncentive(UwinSession session) { if(incentiveActivityAM!=null){ IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivityAM.getId(), session.getDate(), 0L); + .findRecordByActivityIdCreatedDateBenId(incentiveActivityAM.getId(), session.getDate(), 0L,session.getAshaId()); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivityAM.getId()); From 4da89fae8bad9ad253ec28aeba7627ba49628c3f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 10:58:45 +0530 Subject: [PATCH 616/792] update incentive code --- .../iemr/flw/domain/iemr/SammelanRecord.java | 2 +- .../flw/service/impl/SammelanServiceImpl.java | 54 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java index 84f0af48..1ccc5bbd 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/SammelanRecord.java @@ -28,7 +28,7 @@ public class SammelanRecord { @Column(name = "meeting_date", nullable = false) - private Long meetingDate; + private Timestamp meetingDate; @Column(nullable = false) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 56a9e555..734b9b85 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -3,11 +3,13 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.domain.iemr.SammelanAttachment; import com.iemr.flw.domain.iemr.SammelanRecord; import com.iemr.flw.dto.iemr.*; -import com.iemr.flw.repo.iemr.SammelanAttachmentRepository; -import com.iemr.flw.repo.iemr.SammelanRecordRepository; +import com.iemr.flw.masterEnum.GroupName; +import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.SammelanService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,10 +38,21 @@ public class SammelanServiceImpl implements SammelanService { private SammelanRecord record; + @Autowired + private IncentiveRecordRepo incentiveRecordRepo; + @Autowired private ObjectMapper objectMapper; + @Autowired + private UserServiceRoleRepo userRepo; + + @Autowired + private IncentivesRepo incentivesRepo; + + + @Override public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO) { SammelanResponseDTO response = new SammelanResponseDTO(); @@ -50,7 +63,8 @@ public SammelanResponseDTO submitSammelan(SammelanRequestDTO sammelanRequestDTO) record = new SammelanRecord(); record.setAshaId(sammelanRequestDTO.getAshaId()); logger.info("Meeting Date:"+sammelanRequestDTO.getDate()); - record.setMeetingDate(sammelanRequestDTO.getDate()); + Timestamp timestamp = new Timestamp(sammelanRequestDTO.getDate()); + record.setMeetingDate(timestamp); record.setPlace(sammelanRequestDTO.getPlace()); record.setParticipants(sammelanRequestDTO.getParticipants()); @@ -75,10 +89,13 @@ record .setAttachments(imagesJson); record = recordRepo.save(record); } + checkIncentive(record); // Prepare Response DTO response.setId(record.getId()); response.setAshaId(record.getAshaId()); - response.setDate(record.getMeetingDate()); + Timestamp ts = Timestamp.valueOf(record.getMeetingDate().toLocalDateTime()); + long millis = ts.getTime(); + response.setDate(millis); response.setPlace(record.getPlace()); response.setParticipants(record.getParticipants()); @@ -92,6 +109,31 @@ record = recordRepo.save(record); } + private void checkIncentive(SammelanRecord record) { + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_SAAS_BAHU", GroupName.FAMILY_PLANNING.getDisplayName()); + if(incentiveActivity!=null){ + addSammelanIncentive(incentiveActivity,record); + } + } + + private void addSammelanIncentive(IncentiveActivity incentiveActivity, SammelanRecord record) { + IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), record.getMeetingDate(), 0L,record.getAshaId()); + if (incentiveActivityRecord == null) { + incentiveActivityRecord = new IncentiveActivityRecord(); + incentiveActivityRecord.setActivityId(incentiveActivity.getId()); + incentiveActivityRecord.setCreatedDate(record.getMeetingDate()); + incentiveActivityRecord.setCreatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); + incentiveActivityRecord.setStartDate(record.getMeetingDate()); + incentiveActivityRecord.setEndDate(record.getMeetingDate()); + incentiveActivityRecord.setUpdatedDate(record.getMeetingDate()); + incentiveActivityRecord.setUpdatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); + incentiveActivityRecord.setBenId(0L); + incentiveActivityRecord.setAshaId(record.getAshaId()); + incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + } + @Override public List getSammelanHistory(Integer ashaId) { @@ -100,7 +142,9 @@ public List getSammelanHistory(Integer ashaId) { SammelanResponseDTO dto = new SammelanResponseDTO(); dto.setId(record.getId()); dto.setAshaId(record.getAshaId()); - dto.setDate(record.getMeetingDate()); + Timestamp ts = Timestamp.valueOf(record.getMeetingDate().toLocalDateTime()); + long millis = ts.getTime(); + dto.setDate(millis); dto.setPlace(record.getPlace()); dto.setParticipants(record.getParticipants()); try { From e073389260a581eed50af157de7671f5bbbe769f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 11:25:53 +0530 Subject: [PATCH 617/792] update incentive code --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 734b9b85..497fbb3a 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -87,9 +87,10 @@ record .setAttachments(imagesJson); if(record!=null){ record = recordRepo.save(record); + checkIncentive(record); + } - checkIncentive(record); // Prepare Response DTO response.setId(record.getId()); response.setAshaId(record.getAshaId()); From 42ca5e4b93cea217187ed6f3d9a1f5afa2f755d3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 11:26:46 +0530 Subject: [PATCH 618/792] update incentive code --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 497fbb3a..3966973e 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -103,7 +103,7 @@ record = recordRepo.save(record); } catch (Exception e) { - logger.info("Exception: "+e.getMessage()); + logger.info("SammelanRecord Exception: "+e.getMessage()); } return response; @@ -112,6 +112,7 @@ record = recordRepo.save(record); private void checkIncentive(SammelanRecord record) { IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_SAAS_BAHU", GroupName.FAMILY_PLANNING.getDisplayName()); + logger.info("SammelanRecord: "+incentiveActivity.getRate()); if(incentiveActivity!=null){ addSammelanIncentive(incentiveActivity,record); } From f6560a14f1c5885642e70af7cfdf4af5bbbaeb7f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 11:40:01 +0530 Subject: [PATCH 619/792] update incentive code --- .../flw/service/impl/SammelanServiceImpl.java | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 3966973e..e2eaa23e 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -120,20 +120,27 @@ private void checkIncentive(SammelanRecord record) { private void addSammelanIncentive(IncentiveActivity incentiveActivity, SammelanRecord record) { IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), record.getMeetingDate(), 0L,record.getAshaId()); - if (incentiveActivityRecord == null) { - incentiveActivityRecord = new IncentiveActivityRecord(); - incentiveActivityRecord.setActivityId(incentiveActivity.getId()); - incentiveActivityRecord.setCreatedDate(record.getMeetingDate()); - incentiveActivityRecord.setCreatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); - incentiveActivityRecord.setStartDate(record.getMeetingDate()); - incentiveActivityRecord.setEndDate(record.getMeetingDate()); - incentiveActivityRecord.setUpdatedDate(record.getMeetingDate()); - incentiveActivityRecord.setUpdatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); - incentiveActivityRecord.setBenId(0L); - incentiveActivityRecord.setAshaId(record.getAshaId()); - incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivity.getRate())); - recordRepo.save(record); + logger.info("SammelanRecord incentiveActivityRecord: "+incentiveActivityRecord.getId()); + try { + if (incentiveActivityRecord == null) { + incentiveActivityRecord = new IncentiveActivityRecord(); + incentiveActivityRecord.setActivityId(incentiveActivity.getId()); + incentiveActivityRecord.setCreatedDate(record.getMeetingDate()); + incentiveActivityRecord.setCreatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); + incentiveActivityRecord.setStartDate(record.getMeetingDate()); + incentiveActivityRecord.setEndDate(record.getMeetingDate()); + incentiveActivityRecord.setUpdatedDate(record.getMeetingDate()); + incentiveActivityRecord.setUpdatedBy(userRepo.getUserNamedByUserId(record.getAshaId())); + incentiveActivityRecord.setBenId(0L); + incentiveActivityRecord.setAshaId(record.getAshaId()); + incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + }catch (Exception e){ + logger.info("SammelanRecord save Record: ",e); + } + } From 98e7bab4a7d6008afa35557ca8def173ddc96839 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 11:46:31 +0530 Subject: [PATCH 620/792] update incentive code --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index e2eaa23e..65782afb 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -120,7 +120,7 @@ private void checkIncentive(SammelanRecord record) { private void addSammelanIncentive(IncentiveActivity incentiveActivity, SammelanRecord record) { IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), record.getMeetingDate(), 0L,record.getAshaId()); - logger.info("SammelanRecord incentiveActivityRecord: "+incentiveActivityRecord.getId()); + logger.info("SammelanRecord incentiveActivityRecord: "+incentiveActivity.getId()); try { if (incentiveActivityRecord == null) { incentiveActivityRecord = new IncentiveActivityRecord(); From 589840b4be3e86e598afc5fe9c2b0021026f07c8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 11:47:05 +0530 Subject: [PATCH 621/792] update incentive code --- .../java/com/iemr/flw/service/impl/SammelanServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java index 65782afb..53497981 100644 --- a/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/SammelanServiceImpl.java @@ -120,7 +120,6 @@ private void checkIncentive(SammelanRecord record) { private void addSammelanIncentive(IncentiveActivity incentiveActivity, SammelanRecord record) { IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), record.getMeetingDate(), 0L,record.getAshaId()); - logger.info("SammelanRecord incentiveActivityRecord: "+incentiveActivity.getId()); try { if (incentiveActivityRecord == null) { incentiveActivityRecord = new IncentiveActivityRecord(); @@ -134,7 +133,7 @@ private void addSammelanIncentive(IncentiveActivity incentiveActivity, SammelanR incentiveActivityRecord.setBenId(0L); incentiveActivityRecord.setAshaId(record.getAshaId()); incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivity.getRate())); - recordRepo.save(record); + incentiveRecordRepo.save(incentiveActivityRecord); } }catch (Exception e){ logger.info("SammelanRecord save Record: ",e); From 57ae44db8b26ecbb485b4d287c15b311ca90d6b8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 12:30:50 +0530 Subject: [PATCH 622/792] update incentive code --- src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index ae4c912b..23e15e7b 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -51,8 +51,8 @@ public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { try { Objects.requireNonNull(ashaWorkerRequest, "ashaWorker must not be null"); AshaWorker savedWorker = ashaWorkerRequest.getId() != null - ? ashaProfileRepo.saveAndFlush(updateProfile(ashaWorkerRequest)) - : ashaProfileRepo.saveAndFlush(ashaWorkerRequest); + ? ashaProfileRepo.save(updateProfile(ashaWorkerRequest)) + : ashaProfileRepo.save(ashaWorkerRequest); logger.info("ASHA worker profile saved successfully: {}", savedWorker); return savedWorker; } catch (Exception e) { From f2b9510b47aa8a2108121c6d21c59dc0e6faca3a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 12:32:11 +0530 Subject: [PATCH 623/792] update incentive code --- src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 23e15e7b..fcab3315 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -50,7 +50,7 @@ public class AshaProfileImpl implements AshaProfileService { public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { try { Objects.requireNonNull(ashaWorkerRequest, "ashaWorker must not be null"); - AshaWorker savedWorker = ashaWorkerRequest.getId() != null + AshaWorker savedWorker = (ashaWorkerRequest.getId() >0 || ashaWorkerRequest.getId()!=null) ? ashaProfileRepo.save(updateProfile(ashaWorkerRequest)) : ashaProfileRepo.save(ashaWorkerRequest); logger.info("ASHA worker profile saved successfully: {}", savedWorker); From 1bbd75e5707842e4d3a06066055129358c9d146d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 12:38:03 +0530 Subject: [PATCH 624/792] update incentive code --- .../com/iemr/flw/controller/AshaProfileController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/AshaProfileController.java b/src/main/java/com/iemr/flw/controller/AshaProfileController.java index 1c8d2930..1bda4499 100644 --- a/src/main/java/com/iemr/flw/controller/AshaProfileController.java +++ b/src/main/java/com/iemr/flw/controller/AshaProfileController.java @@ -32,7 +32,7 @@ import java.util.Objects; @RestController -@RequestMapping(value = "/asha", headers = "Authorization", produces = "application/json") +@RequestMapping(value = "/asha", produces = "application/json") public class AshaProfileController { private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); @Autowired @@ -47,9 +47,9 @@ public class AshaProfileController { private EmployeeMasterInter employeeMasterInter; @RequestMapping(value = "editProfile", method = {RequestMethod.POST}, produces = { - "application/json"}, consumes = "application/json", headers = "Authorization") + "application/json"}, consumes = "application/json") - public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee,@RequestHeader(value = "Authorization") String authorization) { + public ResponseEntity> editEmployee(@RequestBody AshaWorker editEmployee) { try { System.out.println(editEmployee.toString()); @@ -69,7 +69,7 @@ public ResponseEntity> editEmployee(@RequestBody AshaWorker } - @RequestMapping(value = "getProfile", method = RequestMethod.GET, headers = "Authorization") + @RequestMapping(value = "getProfile", method = RequestMethod.GET) public ResponseEntity> getProfile(HttpServletRequest request, @Param("employeeId") Integer employeeId) { Map response = new HashMap<>(); From 6ffc2de1bbddf9b7f9607409c34b5f96ab5f8e2a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 13:33:34 +0530 Subject: [PATCH 625/792] update incentive code --- .../flw/service/impl/AshaProfileImpl.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index fcab3315..8c7f9059 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -49,18 +49,26 @@ public class AshaProfileImpl implements AshaProfileService { @Override public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { try { - Objects.requireNonNull(ashaWorkerRequest, "ashaWorker must not be null"); - AshaWorker savedWorker = (ashaWorkerRequest.getId() >0 || ashaWorkerRequest.getId()!=null) - ? ashaProfileRepo.save(updateProfile(ashaWorkerRequest)) - : ashaProfileRepo.save(ashaWorkerRequest); - logger.info("ASHA worker profile saved successfully: {}", savedWorker); - return savedWorker; + Objects.requireNonNull(ashaWorkerRequest, "ASHA worker request must not be null"); + + // If ID null or 0 → CREATE + if (ashaWorkerRequest.getId() == null || ashaWorkerRequest.getId() == 0) { + AshaWorker saved = ashaProfileRepo.save(ashaWorkerRequest); + logger.info("Created ASHA Worker: {}", saved.getId()); + return saved; + } + + // Otherwise → UPDATE + AshaWorker updated = updateProfile(ashaWorkerRequest); + logger.info("Updated ASHA Worker: {}", updated.getId()); + return updated; + } catch (Exception e) { - logger.error("Error saving ASHA worker profile: {}", e.getMessage(), e); - throw new RuntimeException("Failed to save ASHA worker profile", e); + logger.error("Error saving ASHA worker: {}", e.getMessage(), e); + throw new RuntimeException("Failed to save ASHA worker", e); } - } + @Override public AshaWorker getProfileData(Integer userId) { From 30724b6e41b9a5ab8268dc3b7224325c4232a580 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 13:34:16 +0530 Subject: [PATCH 626/792] update incentive code --- .../java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index a54c2db8..bb2a944c 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -153,7 +153,7 @@ record = new IncentiveActivityRecord(); if(incentiveActivityCH!=null){ IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivityCH.getId(), session.getDate(), 0L); + .findRecordByActivityIdCreatedDateBenId(incentiveActivityCH.getId(), session.getDate(), 0L,session.getAshaId()); if (record == null) { record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivityCH.getId()); From 92185bf3b39843bf2bf4370be6e3745e87998d88 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 13:42:33 +0530 Subject: [PATCH 627/792] update incentive code --- .../flw/service/impl/AshaProfileImpl.java | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 8c7f9059..584cf896 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -47,19 +47,26 @@ public class AshaProfileImpl implements AshaProfileService { private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); @Transactional @Override - public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { + public AshaWorker saveEditData(AshaWorker request) { try { - Objects.requireNonNull(ashaWorkerRequest, "ASHA worker request must not be null"); + Objects.requireNonNull(request, "ASHA worker request must not be null"); - // If ID null or 0 → CREATE - if (ashaWorkerRequest.getId() == null || ashaWorkerRequest.getId() == 0) { - AshaWorker saved = ashaProfileRepo.save(ashaWorkerRequest); + Long id = request.getId(); + + // ---------- CREATE Case ---------- + if (id == null || id == 0) { + // treat id=0 as null (frontend mistake) + if (id != null && id == 0) { + request.setId(null); + } + + AshaWorker saved = ashaProfileRepo.save(request); logger.info("Created ASHA Worker: {}", saved.getId()); return saved; } - // Otherwise → UPDATE - AshaWorker updated = updateProfile(ashaWorkerRequest); + // ---------- UPDATE Case ---------- + AshaWorker updated = updateProfile(request); logger.info("Updated ASHA Worker: {}", updated.getId()); return updated; @@ -69,6 +76,7 @@ public AshaWorker saveEditData(AshaWorker ashaWorkerRequest) { } } + @Override public AshaWorker getProfileData(Integer userId) { From 10a6b603da7ab921f41a6a2e837f85beb7b555a8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 14:39:52 +0530 Subject: [PATCH 628/792] update incentive code --- .../flw/service/impl/AshaProfileImpl.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 584cf896..9f884ced 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.Objects; import org.springframework.data.redis.core.RedisTemplate; @@ -41,10 +42,11 @@ public class AshaProfileImpl implements AshaProfileService { @Autowired JwtUtil jwtUtil; @Autowired - JwtAuthenticationUtil jwtAuthenticationUtil ; + JwtAuthenticationUtil jwtAuthenticationUtil; @Autowired private UserServiceRoleRepo userServiceRoleRepo; private final Logger logger = LoggerFactory.getLogger(AshaProfileImpl.class); + @Transactional @Override public AshaWorker saveEditData(AshaWorker request) { @@ -91,14 +93,22 @@ public AshaWorker getProfileData(Integer userId) { throw new RuntimeException("Failed to retrieve ASHA worker profile", e); } } + private AshaWorker getDetails(Integer userID) { try { M_User m_user = Objects.requireNonNull(employeeMasterInter.getUserDetails(userID), "User details not found for ID: " + userID); AshaWorker ashaWorker = new AshaWorker(); ashaWorker.setEmployeeId(m_user.getUserID()); ashaWorker.setDob(m_user.getDOB()); - ashaWorker.setDateOfJoining(m_user.getDOJ()); + LocalDate doj = m_user.getDOJ(); + + if (doj == null) { + doj = LocalDate.now(); + } + + ashaWorker.setDateOfJoining(doj); ashaWorker.setName(String.format("%s %s", Objects.toString(m_user.getFirstName(), ""), Objects.toString(m_user.getLastName(), "")).trim()); + ashaWorker.setMobileNumber(m_user.getContactNo()); ashaWorker.setAlternateMobileNumber(m_user.getEmergencyContactNo()); ashaWorker.setProviderServiceMapID(m_user.getServiceProviderID()); @@ -131,12 +141,14 @@ private AshaWorker getDetails(Integer userID) { throw new RuntimeException("Failed to create ASHA worker profile from user details", e); } } + public AshaWorker updateProfile(AshaWorker request) { AshaWorker existing = ashaProfileRepo.findByEmployeeId(request.getEmployeeId()).orElseThrow(() -> new RuntimeException("ASHA worker not found")); if (isValid(request.getAbhaNumber())) existing.setAbhaNumber(request.getAbhaNumber()); if (request.getEmployeeId() != null) existing.setEmployeeId(request.getEmployeeId()); if (request.getDob() != null) existing.setDob(request.getDob()); - if (isValid(request.getAlternateMobileNumber())) existing.setAlternateMobileNumber(request.getAlternateMobileNumber()); + if (isValid(request.getAlternateMobileNumber())) + existing.setAlternateMobileNumber(request.getAlternateMobileNumber()); if (isValid(request.getAnm1Mobile())) existing.setAnm1Mobile(request.getAnm1Mobile()); if (isValid(request.getAnm2Name())) existing.setAnm2Name(request.getAnm2Name()); if (isValid(request.getIfsc())) existing.setIfsc(request.getIfsc()); @@ -149,19 +161,22 @@ public AshaWorker updateProfile(AshaWorker request) { if (isValid(request.getAshaFamilyMember())) existing.setAshaFamilyMember(request.getAshaFamilyMember()); if (request.getDateOfJoining() != null) existing.setDateOfJoining(request.getDateOfJoining()); if (isValid(request.getMobileNumber())) existing.setMobileNumber(request.getMobileNumber()); - if (isValid(request.getAshaHouseholdRegistration())) existing.setAshaHouseholdRegistration(request.getAshaHouseholdRegistration()); + if (isValid(request.getAshaHouseholdRegistration())) + existing.setAshaHouseholdRegistration(request.getAshaHouseholdRegistration()); if (isValid(request.getFatherOrSpouseName())) existing.setFatherOrSpouseName(request.getFatherOrSpouseName()); if (request.getPopulationCovered() != null) existing.setPopulationCovered(request.getPopulationCovered()); if (isValid(request.getAnm1Name())) existing.setAnm1Name(request.getAnm1Name()); if (isValid(request.getAnm2Mobile())) existing.setAnm2Mobile(request.getAnm2Mobile()); if (isValid(request.getAwwMobile())) existing.setAwwMobile(request.getAwwMobile()); - if (request.getProviderServiceMapID() != null) existing.setProviderServiceMapID(request.getProviderServiceMapID()); + if (request.getProviderServiceMapID() != null) + existing.setProviderServiceMapID(request.getProviderServiceMapID()); if (isValid(request.getProfileImage())) existing.setProfileImage(request.getProfileImage()); if (request.getIsFatherOrSpouse() != null) existing.setIsFatherOrSpouse(request.getIsFatherOrSpouse()); if (isValid(request.getSupervisorName())) existing.setSupervisorName(request.getSupervisorName()); if (isValid(request.getSupervisorMobile())) existing.setSupervisorMobile(request.getSupervisorMobile()); return existing; } + private boolean isValid(String value) { return value != null && !value.trim().isEmpty() && !"null".equalsIgnoreCase(value.trim()); } From 696e90443153b3464ad0dd25c4a99908a0c769f6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 15:46:40 +0530 Subject: [PATCH 629/792] update incentive code --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index f6c9ef4d..378cbc45 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -144,11 +144,11 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 3) { + if (it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 2) { IncentiveActivity activity1 = incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", "FAMILY PLANNING"); createIncentiveRecord(recordList, it, activity1); - } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && null != it.getMarriageFirstChildGap() && it.getMarriageFirstChildGap() >= 2) { + } else if (it.getNumLiveChildren() >= 2 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity2 = incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", "FAMILY PLANNING"); createIncentiveRecord(recordList, it, activity2); From d858ded5079d50c46b40fd12584fbb87b148332d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 15:52:07 +0530 Subject: [PATCH 630/792] update incentive code --- .../flw/service/impl/CoupleServiceImpl.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 378cbc45..e0006f66 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -89,11 +89,11 @@ public String registerEligibleCouple(List eligibleCoupleDTOs, } if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 2) { + if (existingECR.getNumLiveChildren() == 0 && it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap() != null && it.getMarriageFirstChildGap() >= 2) { IncentiveActivity activity1 = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_DELAY_2Y", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity1); - } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && it.getFirstAndSecondChildGap()!=null && it.getFirstAndSecondChildGap() == 3) { + } else if (existingECR.getNumLiveChildren() == 1 && it.getNumLiveChildren() >= 2 && it.getFirstAndSecondChildGap() != null && it.getFirstAndSecondChildGap() == 3) { IncentiveActivity activity2 = incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName()); createIncentiveRecord(recordList, it, activity2); @@ -144,14 +144,23 @@ public String registerEligibleCouple(List eligibleCoupleDTOs) eligibleCoupleRegisterRepo.findEligibleCoupleRegisterByBenId(it.getBenId()); if (existingECR != null && null != existingECR.getNumLiveChildren()) { - if (it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 2) { + if (it.getNumLiveChildren() >= 1 && it.getMarriageFirstChildGap() != null && it.getMarriageFirstChildGap() >= 2) { IncentiveActivity activity1 = - incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName()) + ; + + IncentiveActivity activityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("MARRIAGE_1st_CHILD_GAP", GroupName.ACTIVITY.getDisplayName()); createIncentiveRecord(recordList, it, activity1); - } else if (it.getNumLiveChildren() >= 2 && it.getMarriageFirstChildGap()!=null && it.getMarriageFirstChildGap() >= 3) { + createIncentiveRecord(recordList, it, activityCH); + } else if (it.getNumLiveChildren() >= 2 && it.getMarriageFirstChildGap() != null && it.getMarriageFirstChildGap() >= 3) { IncentiveActivity activity2 = - incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", "FAMILY PLANNING"); + incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.FAMILY_PLANNING.getDisplayName()); + + IncentiveActivity activityCH = + incentivesRepo.findIncentiveMasterByNameAndGroup("1st_2nd_CHILD_GAP", GroupName.ACTIVITY.getDisplayName()); createIncentiveRecord(recordList, it, activity2); + createIncentiveRecord(recordList, it, activityCH); } Long id = existingECR.getId(); modelMapper.map(it, existingECR); From 1f1d720b6c61e348676091c86a5407033861b9d3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:23:38 +0530 Subject: [PATCH 631/792] update incentive code --- src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java index 264fe6c1..941721ca 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java @@ -10,7 +10,7 @@ public class DeliveryOutcomeDTO { private Long id; private Long benId; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM d, yyyy, hh:mm:ss a", locale = "en") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private Timestamp dateOfDelivery; private String timeOfDelivery; private String placeOfDelivery; From 01d982232ce80945355d713bfd56267a9fc15df6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:41:57 +0530 Subject: [PATCH 632/792] update incentive code --- .../impl/DeliveryOutcomeServiceImpl.java | 211 ++++++++++-------- 1 file changed, 123 insertions(+), 88 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 7b7f8053..d4e5be44 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -123,6 +123,35 @@ public void checkAndAddJsyIncentive(List delOutList){ delOutList.forEach(deliveryOutcome -> { logger.info("delOutList"+gson.toJson(deliveryOutcome)); + IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY1 != null) { + if(deliveryOutcome.getDeliveryOutcome()==1){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); + } + } + + + IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY2 != null) { + if(deliveryOutcome.getDeliveryOutcome()==2){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); + } + } + + IncentiveActivity incentiveActivityJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY3 != null) { + if(deliveryOutcome.getDeliveryOutcome()==3){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); + } + } + + IncentiveActivity incentiveActivityJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY4 != null) { + if(deliveryOutcome.getDeliveryOutcome()==3){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); + } + } + // Determine delivery number int deliveryNumber = deliveryOutcome.getDeliveryOutcome(); // 1,2,3,4 @@ -148,76 +177,76 @@ public void checkAndAddJsyIncentive(List delOutList){ List activityNames = new ArrayList<>(); - if(location.equalsIgnoreCase("Rural")) { - switch(deliveryNumber) { - case 1: - if(isJsyBeneficiary){ - if(deliveryOutcome.getLiveBirth()==0){ - activityNames.add("JSY_1ST_DEL_ANC_RURAL"); - } - } - if(institutionalDelivery) { - if(deliveryOutcome.getLiveBirth()==0) - activityNames.add("JSY_1ST_DEL_INST_RURAL"); - } - break; - - case 2: - if(isJsyBeneficiary){ - if(deliveryOutcome.getLiveBirth()==1){ - activityNames.add("JSY_2ND_DEL_ANC_RURAL"); - } - } - if(institutionalDelivery) { - if(deliveryOutcome.getLiveBirth()==1) - activityNames.add("JSY_2ND_DEL_INST_RURAL"); - } - break; - - case 3: - if(isJsyBeneficiary){ - if(deliveryOutcome.getLiveBirth()==2){ - activityNames.add("JSY_3RD_DEL_ANC_RURAL"); - } - } - if(institutionalDelivery) { - if(deliveryOutcome.getLiveBirth()==2) - activityNames.add("JSY_3RD_DEL_INST_RURAL"); - } - break; - - case 4: - if(isJsyBeneficiary){ - if(deliveryOutcome.getLiveBirth()==3){ - activityNames.add("JSY_4TH_DEL_ANC_RURAL"); - } - } - if(institutionalDelivery) { - if(deliveryOutcome.getLiveBirth()==3) - activityNames.add("JSY_4TH_DEL_INST_RURAL"); - } - break; - } - } else if(location.equalsIgnoreCase("Urban")) { - if(isJsyBeneficiary){ - if(deliveryOutcome.getLiveBirth()==0){ - activityNames.add("JSY_ANC_URBAN"); - } - } - if(institutionalDelivery){ - if(deliveryOutcome.getLiveBirth()==0) - activityNames.add("JSY_INST_URBAN"); - } - } +// if(location.equalsIgnoreCase("Rural")) { +// switch(deliveryNumber) { +// case 1: +// if(isJsyBeneficiary){ +// if(deliveryOutcome.getDeliveryOutcome()==0){ +// activityNames.add("JSY_1ST_DEL_ANC_RURAL"); +// } +// } +// if(institutionalDelivery) { +// if(deliveryOutcome.getLiveBirth()==0) +// activityNames.add("JSY_1ST_DEL_INST_RURAL"); +// } +// break; +// +// case 2: +// if(isJsyBeneficiary){ +// if(deliveryOutcome.getLiveBirth()==1){ +// activityNames.add("JSY_2ND_DEL_ANC_RURAL"); +// } +// } +// if(institutionalDelivery) { +// if(deliveryOutcome.getLiveBirth()==1) +// activityNames.add("JSY_2ND_DEL_INST_RURAL"); +// } +// break; +// +// case 3: +// if(isJsyBeneficiary){ +// if(deliveryOutcome.getLiveBirth()==2){ +// activityNames.add("JSY_3RD_DEL_ANC_RURAL"); +// } +// } +// if(institutionalDelivery) { +// if(deliveryOutcome.getLiveBirth()==2) +// activityNames.add("JSY_3RD_DEL_INST_RURAL"); +// } +// break; +// +// case 4: +// if(isJsyBeneficiary){ +// if(deliveryOutcome.getLiveBirth()==3){ +// activityNames.add("JSY_4TH_DEL_ANC_RURAL"); +// } +// } +// if(institutionalDelivery) { +// if(deliveryOutcome.getLiveBirth()==3) +// activityNames.add("JSY_4TH_DEL_INST_RURAL"); +// } +// break; +// } +// } else if(location.equalsIgnoreCase("Urban")) { +// if(isJsyBeneficiary){ +// if(deliveryOutcome.getLiveBirth()==0){ +// activityNames.add("JSY_ANC_URBAN"); +// } +// } +// if(institutionalDelivery){ +// if(deliveryOutcome.getLiveBirth()==0) +// activityNames.add("JSY_INST_URBAN"); +// } +// } // For each activity, create record - for(String activityName : activityNames){ - IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName, GroupName.JSY.getDisplayName()); - if(incentiveActivity != null){ - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivity); - } - } +// for(String activityName : activityNames){ +// IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName, GroupName.JSY.getDisplayName()); +// if(incentiveActivity != null){ +// createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivity); +// } +// } IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.ACTIVITY.getDisplayName()); String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); @@ -244,28 +273,34 @@ public void checkAndAddJsyIncentive(List delOutList){ private void createIncentiveRecordforJsy(DeliveryOutcome delOutList, Long benId, IncentiveActivity immunizationActivity) { logger.info("benId"+benId); - IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), delOutList.getCreatedDate(), benId); - - - if (record == null) { - logger.info("setStartDate"+delOutList.getDateOfDelivery()); - logger.info("setCreatedDate"+delOutList.getCreatedDate()); - record = new IncentiveActivityRecord(); - record.setActivityId(immunizationActivity.getId()); - record.setCreatedDate(delOutList.getDateOfDelivery()); - record.setCreatedBy(delOutList.getCreatedBy()); - record.setStartDate(delOutList.getDateOfDelivery()); - record.setEndDate(delOutList.getDateOfDelivery()); - record.setUpdatedDate(delOutList.getCreatedDate()); - record.setUpdatedBy(delOutList.getCreatedBy()); - record.setBenId(benId); - record.setAshaId(userRepo.getUserIdByName(delOutList.getUpdatedBy())); - record.setAmount(Long.valueOf(immunizationActivity.getRate())); - recordRepo.save(record); - }else { - logger.info("benId:"+record.getId()); + try { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), delOutList.getCreatedDate(), benId); + + + if (record == null) { + logger.info("setStartDate"+delOutList.getDateOfDelivery()); + logger.info("setCreatedDate"+delOutList.getCreatedDate()); + record = new IncentiveActivityRecord(); + record.setActivityId(immunizationActivity.getId()); + record.setCreatedDate(delOutList.getDateOfDelivery()); + record.setCreatedBy(delOutList.getCreatedBy()); + record.setStartDate(delOutList.getDateOfDelivery()); + record.setEndDate(delOutList.getDateOfDelivery()); + record.setUpdatedDate(delOutList.getCreatedDate()); + record.setUpdatedBy(delOutList.getCreatedBy()); + record.setBenId(benId); + record.setAshaId(userRepo.getUserIdByName(delOutList.getUpdatedBy())); + record.setAmount(Long.valueOf(immunizationActivity.getRate())); + recordRepo.save(record); + }else { + logger.info("benId:"+record.getId()); + + } + }catch (Exception e){ } + + } } From cbde4547d1804519c87eafc6e77fc9c74e683b5b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:42:18 +0530 Subject: [PATCH 633/792] update incentive code --- .../com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index d4e5be44..45ab56dc 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -147,7 +147,7 @@ public void checkAndAddJsyIncentive(List delOutList){ IncentiveActivity incentiveActivityJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY4 != null) { - if(deliveryOutcome.getDeliveryOutcome()==3){ + if(deliveryOutcome.getDeliveryOutcome()==4){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); } } From fd097b6f70577400b887830939ac22642fea87bc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:45:46 +0530 Subject: [PATCH 634/792] update incentive code --- .../flw/service/impl/DeliveryOutcomeServiceImpl.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 45ab56dc..5e51974b 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -122,11 +122,18 @@ public List getDeliveryOutcome(GetBenRequestHandler dto) { public void checkAndAddJsyIncentive(List delOutList){ delOutList.forEach(deliveryOutcome -> { + IncentiveActivity incentiveActivityInstJSY1= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY2= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + + logger.info("delOutList"+gson.toJson(deliveryOutcome)); IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY1 != null) { if(deliveryOutcome.getDeliveryOutcome()==1){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY1); } } @@ -135,6 +142,7 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY2 != null) { if(deliveryOutcome.getDeliveryOutcome()==2){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY2); } } @@ -142,6 +150,7 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY3 != null) { if(deliveryOutcome.getDeliveryOutcome()==3){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY3); } } @@ -149,10 +158,13 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY4 != null) { if(deliveryOutcome.getDeliveryOutcome()==4){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); } } + + // Determine delivery number int deliveryNumber = deliveryOutcome.getDeliveryOutcome(); // 1,2,3,4 if(deliveryOutcome.getIsJSYBenificiary()!=null){ From 47fbfb25e8107217f221fe182954e123ca8c6754 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:47:15 +0530 Subject: [PATCH 635/792] update incentive code --- .../com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 5e51974b..a5274d64 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -310,7 +310,7 @@ record = new IncentiveActivityRecord(); } }catch (Exception e){ - + logger.error("JSY Incentive:",e); } From e36421419055673d23850a57a831c9edc414f18d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 16:56:43 +0530 Subject: [PATCH 636/792] update incentive code --- .../impl/DeliveryOutcomeServiceImpl.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index a5274d64..a2e3ac46 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -133,7 +133,9 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY1 != null) { if(deliveryOutcome.getDeliveryOutcome()==1){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY1); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); + } } } @@ -142,7 +144,10 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY2 != null) { if(deliveryOutcome.getDeliveryOutcome()==2){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY2); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY2); + } } } @@ -150,7 +155,9 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY3 != null) { if(deliveryOutcome.getDeliveryOutcome()==3){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY3); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); + } } } @@ -158,7 +165,10 @@ public void checkAndAddJsyIncentive(List delOutList){ if (incentiveActivityJSY4 != null) { if(deliveryOutcome.getDeliveryOutcome()==4){ createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); + if(deliveryOutcome.getPlaceOfDelivery()!=null){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); + + } } } From 652ccc2f49fe738ab2d1abc5b986b5020e8c1892 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 21:59:47 +0530 Subject: [PATCH 637/792] update incentive code --- .../com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index a2e3ac46..26a75501 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -270,7 +270,7 @@ public void checkAndAddJsyIncentive(List delOutList){ // } // } IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); - IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.ACTIVITY.getDisplayName()); + IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("INST_DELIVERY_ESCORT", GroupName.ACTIVITY.getDisplayName()); String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); if (placeOfDelivery != null && From 4d987fcb7146828411d732c708b46da9c3db3f0f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 22:02:52 +0530 Subject: [PATCH 638/792] update incentive code --- .../impl/DeliveryOutcomeServiceImpl.java | 211 ++++++------------ 1 file changed, 63 insertions(+), 148 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 26a75501..669be702 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -122,161 +122,15 @@ public List getDeliveryOutcome(GetBenRequestHandler dto) { public void checkAndAddJsyIncentive(List delOutList){ delOutList.forEach(deliveryOutcome -> { - IncentiveActivity incentiveActivityInstJSY1= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY2= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - - - logger.info("delOutList"+gson.toJson(deliveryOutcome)); - IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY1 != null) { - if(deliveryOutcome.getDeliveryOutcome()==1){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); - } - } - } - - - IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY2 != null) { - if(deliveryOutcome.getDeliveryOutcome()==2){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { - - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY2); - } - } - } - - IncentiveActivity incentiveActivityJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY3 != null) { - if(deliveryOutcome.getDeliveryOutcome()==3){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); - } - } - } - - IncentiveActivity incentiveActivityJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY4 != null) { - if(deliveryOutcome.getDeliveryOutcome()==4){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); - if(deliveryOutcome.getPlaceOfDelivery()!=null){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); - - } - } - } - - - - // Determine delivery number - int deliveryNumber = deliveryOutcome.getDeliveryOutcome(); // 1,2,3,4 - if(deliveryOutcome.getIsJSYBenificiary()!=null){ - - isJsyBeneficiary = deliveryOutcome.getIsJSYBenificiary(); - - } - if(deliveryOutcome.getPlaceOfDelivery()!=null && !deliveryOutcome.getPlaceOfDelivery().isEmpty()){ - institutionalDelivery = true; - - }else { - institutionalDelivery = false; - } - Optional rmnchBeneficiaryDetailsRmnch = beneficiaryRepo.findById(deliveryOutcome.getBenId()); - if(rmnchBeneficiaryDetailsRmnch.isPresent()){ - logger.info("rmnchBeneficiaryDetailsRmnch"+rmnchBeneficiaryDetailsRmnch.get()); - } - - String location = "Rural"; - - // JSY incentive name construction - List activityNames = new ArrayList<>(); - - -// if(location.equalsIgnoreCase("Rural")) { -// switch(deliveryNumber) { -// case 1: -// if(isJsyBeneficiary){ -// if(deliveryOutcome.getDeliveryOutcome()==0){ -// activityNames.add("JSY_1ST_DEL_ANC_RURAL"); -// } -// } -// if(institutionalDelivery) { -// if(deliveryOutcome.getLiveBirth()==0) -// activityNames.add("JSY_1ST_DEL_INST_RURAL"); -// } -// break; -// -// case 2: -// if(isJsyBeneficiary){ -// if(deliveryOutcome.getLiveBirth()==1){ -// activityNames.add("JSY_2ND_DEL_ANC_RURAL"); -// } -// } -// if(institutionalDelivery) { -// if(deliveryOutcome.getLiveBirth()==1) -// activityNames.add("JSY_2ND_DEL_INST_RURAL"); -// } -// break; -// -// case 3: -// if(isJsyBeneficiary){ -// if(deliveryOutcome.getLiveBirth()==2){ -// activityNames.add("JSY_3RD_DEL_ANC_RURAL"); -// } -// } -// if(institutionalDelivery) { -// if(deliveryOutcome.getLiveBirth()==2) -// activityNames.add("JSY_3RD_DEL_INST_RURAL"); -// } -// break; -// -// case 4: -// if(isJsyBeneficiary){ -// if(deliveryOutcome.getLiveBirth()==3){ -// activityNames.add("JSY_4TH_DEL_ANC_RURAL"); -// } -// } -// if(institutionalDelivery) { -// if(deliveryOutcome.getLiveBirth()==3) -// activityNames.add("JSY_4TH_DEL_INST_RURAL"); -// } -// break; -// } -// } else if(location.equalsIgnoreCase("Urban")) { -// if(isJsyBeneficiary){ -// if(deliveryOutcome.getLiveBirth()==0){ -// activityNames.add("JSY_ANC_URBAN"); -// } -// } -// if(institutionalDelivery){ -// if(deliveryOutcome.getLiveBirth()==0) -// activityNames.add("JSY_INST_URBAN"); -// } -// } - - - // For each activity, create record -// for(String activityName : activityNames){ -// IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup(activityName, GroupName.JSY.getDisplayName()); -// if(incentiveActivity != null){ -// createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivity); -// } -// } IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("INST_DELIVERY_ESCORT", GroupName.ACTIVITY.getDisplayName()); String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); if (placeOfDelivery != null && (!placeOfDelivery.equalsIgnoreCase("home") || - !placeOfDelivery.equalsIgnoreCase("in transit") || - !placeOfDelivery.equalsIgnoreCase("other private hospital"))) { + !placeOfDelivery.equalsIgnoreCase("in transit") || + !placeOfDelivery.equalsIgnoreCase("other private hospital"))) { // Institutional delivery (eligible case) if (institutionalDeliveryActivityAM != null) { @@ -287,8 +141,69 @@ public void checkAndAddJsyIncentive(List delOutList){ createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityCH); } } + + if(deliveryOutcome.getIsJSYBenificiary()){ + IncentiveActivity incentiveActivityInstJSY1= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY2= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + + + logger.info("delOutList"+gson.toJson(deliveryOutcome)); + IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY1 != null) { + if(deliveryOutcome.getDeliveryOutcome()==1){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); + } + } + } + + + IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY2 != null) { + if(deliveryOutcome.getDeliveryOutcome()==2){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY2); + } + } + } + + IncentiveActivity incentiveActivityJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY3 != null) { + if(deliveryOutcome.getDeliveryOutcome()==3){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); + if(deliveryOutcome.getPlaceOfDelivery()!=null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); + } + } + } + + IncentiveActivity incentiveActivityJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY4 != null) { + if(deliveryOutcome.getDeliveryOutcome()==4){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); + if(deliveryOutcome.getPlaceOfDelivery()!=null){ + createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); + + } + } + } + + } + + + + }); +// JSY_ANC_URBAN +// JSY_INST_URBAN + + } From 8fa71ed3fb965832e165b8e48080be2dd0518b12 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 20 Nov 2025 22:08:18 +0530 Subject: [PATCH 639/792] update incentive code --- .../impl/DeliveryOutcomeServiceImpl.java | 146 +++++++++--------- 1 file changed, 73 insertions(+), 73 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 669be702..07b3e4a7 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -57,7 +57,7 @@ public class DeliveryOutcomeServiceImpl implements DeliveryOutcomeService { @Autowired private HouseHoldRepo houseHoldRepo; - private boolean isJsyBeneficiary; + private boolean isJsyBeneficiary; private Gson gson = new Gson(); @@ -104,9 +104,10 @@ public String registerDeliveryOutcome(List deliveryOutcomeDT return "error while saving delivery outcome details: " + e.getMessage(); } } + @Override public List getDeliveryOutcome(GetBenRequestHandler dto) { - try{ + try { String user = beneficiaryRepo.getUserName(dto.getAshaId()); List deliveryOutcomeList = deliveryOutcomeRepo.getDeliveryOutcomeByAshaId(user, dto.getFromDate(), dto.getToDate()); return deliveryOutcomeList.stream() @@ -119,83 +120,83 @@ public List getDeliveryOutcome(GetBenRequestHandler dto) { } - public void checkAndAddJsyIncentive(List delOutList){ + public void checkAndAddJsyIncentive(List delOutList) { delOutList.forEach(deliveryOutcome -> { IncentiveActivity institutionalDeliveryActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MH_MOTIVATE_INST_DEL", GroupName.MATERNAL_HEALTH.getDisplayName()); IncentiveActivity institutionalDeliveryActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("INST_DELIVERY_ESCORT", GroupName.ACTIVITY.getDisplayName()); - String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); - - if (placeOfDelivery != null && - (!placeOfDelivery.equalsIgnoreCase("home") || - !placeOfDelivery.equalsIgnoreCase("in transit") || - !placeOfDelivery.equalsIgnoreCase("other private hospital"))) { - - // Institutional delivery (eligible case) - if (institutionalDeliveryActivityAM != null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityAM); - } - - if (institutionalDeliveryActivityCH != null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityCH); + if (deliveryOutcome.getPlaceOfDelivery() != null) { + String placeOfDelivery = deliveryOutcome.getPlaceOfDelivery(); + + if (placeOfDelivery != null && + (!placeOfDelivery.equalsIgnoreCase("home") || + !placeOfDelivery.equalsIgnoreCase("in transit") || + !placeOfDelivery.equalsIgnoreCase("other private hospital"))) { + + // Institutional delivery (eligible case) + if (institutionalDeliveryActivityAM != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityAM); + } + + if (institutionalDeliveryActivityCH != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), institutionalDeliveryActivityCH); + } } } - if(deliveryOutcome.getIsJSYBenificiary()){ - IncentiveActivity incentiveActivityInstJSY1= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY2= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - IncentiveActivity incentiveActivityInstJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); - - - logger.info("delOutList"+gson.toJson(deliveryOutcome)); - IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY1 != null) { - if(deliveryOutcome.getDeliveryOutcome()==1){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY1); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); - } - } - } - - - IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY2 != null) { - if(deliveryOutcome.getDeliveryOutcome()==2){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY2); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { + if (deliveryOutcome.getIsJSYBenificiary()) { + IncentiveActivity incentiveActivityInstJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY3 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + IncentiveActivity incentiveActivityInstJSY4 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_INST_RURAL", GroupName.JSY.getDisplayName()); + + + logger.info("delOutList" + gson.toJson(deliveryOutcome)); + IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY1 != null) { + if (deliveryOutcome.getDeliveryOutcome() == 1 && deliveryOutcome.getLiveBirth()==0) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY1); + if (deliveryOutcome.getPlaceOfDelivery() != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); + } + } + } - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY2); - } - } - } - IncentiveActivity incentiveActivityJSY3= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY3 != null) { - if(deliveryOutcome.getDeliveryOutcome()==3){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY3); - if(deliveryOutcome.getPlaceOfDelivery()!=null) { - createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); - } - } - } + IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY2 != null) { + if (deliveryOutcome.getDeliveryOutcome() == 2 && deliveryOutcome.getLiveBirth()==1) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY2); + if (deliveryOutcome.getPlaceOfDelivery() != null) { - IncentiveActivity incentiveActivityJSY4= incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); - if (incentiveActivityJSY4 != null) { - if(deliveryOutcome.getDeliveryOutcome()==4){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityJSY4); - if(deliveryOutcome.getPlaceOfDelivery()!=null){ - createIncentiveRecordforJsy(deliveryOutcome,deliveryOutcome.getBenId(),incentiveActivityInstJSY4); + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY2); + } + } + } - } - } - } + IncentiveActivity incentiveActivityJSY3 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY3 != null) { + if (deliveryOutcome.getDeliveryOutcome() == 3 && deliveryOutcome.getLiveBirth()==2) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY3); + if (deliveryOutcome.getPlaceOfDelivery() != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); + } + } + } - } + IncentiveActivity incentiveActivityJSY4 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); + if (incentiveActivityJSY4 != null) { + if (deliveryOutcome.getDeliveryOutcome() == 4 && deliveryOutcome.getLiveBirth()==3) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY4); + if (deliveryOutcome.getPlaceOfDelivery() != null) { + createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY4); + } + } + } + } }); @@ -204,11 +205,10 @@ public void checkAndAddJsyIncentive(List delOutList){ // JSY_INST_URBAN - - } + private void createIncentiveRecordforJsy(DeliveryOutcome delOutList, Long benId, IncentiveActivity immunizationActivity) { - logger.info("benId"+benId); + logger.info("benId" + benId); try { IncentiveActivityRecord record = recordRepo @@ -216,8 +216,8 @@ private void createIncentiveRecordforJsy(DeliveryOutcome delOutList, Long benId, if (record == null) { - logger.info("setStartDate"+delOutList.getDateOfDelivery()); - logger.info("setCreatedDate"+delOutList.getCreatedDate()); + logger.info("setStartDate" + delOutList.getDateOfDelivery()); + logger.info("setCreatedDate" + delOutList.getCreatedDate()); record = new IncentiveActivityRecord(); record.setActivityId(immunizationActivity.getId()); record.setCreatedDate(delOutList.getDateOfDelivery()); @@ -230,12 +230,12 @@ record = new IncentiveActivityRecord(); record.setAshaId(userRepo.getUserIdByName(delOutList.getUpdatedBy())); record.setAmount(Long.valueOf(immunizationActivity.getRate())); recordRepo.save(record); - }else { - logger.info("benId:"+record.getId()); + } else { + logger.info("benId:" + record.getId()); } - }catch (Exception e){ - logger.error("JSY Incentive:",e); + } catch (Exception e) { + logger.error("JSY Incentive:", e); } From 39046a0d8e05f956b246ba655e81abc110c73164 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 10:42:41 +0530 Subject: [PATCH 640/792] add new column in RMNCHBeneficiaryDetailsRmnch --- .../identity/RMNCHBeneficiaryDetailsRmnch.java | 15 +++++++++++++++ .../flw/service/impl/BeneficiaryServiceImpl.java | 6 +++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java index c155d4cb..c1cd5efc 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java @@ -367,6 +367,21 @@ public class RMNCHBeneficiaryDetailsRmnch { @Expose private String otherPlaceOfDeath; + @Expose + private Boolean isSpouseAdded; + + + @Expose + private Boolean isChildrenAdded; + + @Expose + private Boolean isMarried; + + @Expose + private Integer doYouHavechildren; + @Expose + private Integer noofAlivechildren; + @Expose @Transient private Integer servicePointID; diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index bf1465f6..2e92b100 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -399,7 +399,11 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("reasonOfDeathId", benDetailsRMNCH_OBJ.getReasonOfDeathId()); resultMap.put("placeOfDeath", benDetailsRMNCH_OBJ.getPlaceOfDeath()); resultMap.put("placeOfDeathId", benDetailsRMNCH_OBJ.getPlaceOfDeathId()); - resultMap.put("otherPlaceOfDeath", benDetailsRMNCH_OBJ.getOtherPlaceOfDeath()); + resultMap.put("isSpouseAdded", benDetailsRMNCH_OBJ.getIsSpouseAdded()); + resultMap.put("isChildrenAdded", benDetailsRMNCH_OBJ.getIsChildrenAdded()); + resultMap.put("isMarried", benDetailsRMNCH_OBJ.getIsMarried()); + resultMap.put("doYouHavechildren", benDetailsRMNCH_OBJ.getDoYouHavechildren()); + resultMap.put("noofAlivechildren ",benDetailsRMNCH_OBJ.getNoofAlivechildren()); From 1966776cf79bd2979292ef5c7291c88a79cf540f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 13:52:51 +0530 Subject: [PATCH 641/792] add new column in RMNCHBeneficiaryDetailsRmnch --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 51dc8bfc..c3983301 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -169,7 +169,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } entities.forEach(entry -> { if(entry.getName()==null){ - if(entry.getBenId()!=0){ + if(entry.getId()>0){ Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId()); logger.info("rmnchBeneficiaryDetailsRmnch"+regId); BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId(); From 49b911e167152693765a107aa33952cbe9fb4a21 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 15:59:50 +0530 Subject: [PATCH 642/792] add new column in RMNCHBeneficiaryDetailsRmnch --- .../flw/service/impl/ChildCareServiceImpl.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 9f600422..cc88a279 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -734,13 +734,13 @@ private void checkAndAddOrdDistributionIncentive(List orsDistr IncentiveActivity orsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if(orsPacketActivityAM!=null){ if(orsDistribution.getNumOrsPackets()!=null){ - createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityAM,jwtUtil.getUserNameFromStorage()); + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityAM,jwtUtil.getUserNameFromStorage(),false); } } if(orsPacketActivityCH!=null){ if(orsDistribution.getNumOrsPackets()!=null){ - createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityCH,jwtUtil.getUserNameFromStorage()); + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityCH,jwtUtil.getUserNameFromStorage(),true); } } @@ -991,7 +991,7 @@ record = new IncentiveActivityRecord(); } } - private void createIncentiveRecordforOrsDistribution(OrsDistribution data, Long benId, IncentiveActivity immunizationActivity, String createdBy) { + private void createIncentiveRecordforOrsDistribution(OrsDistribution data, Long benId, IncentiveActivity immunizationActivity, String createdBy,boolean isCH) { try { // Convert to LocalDate Timestamp visitDate = Timestamp.valueOf(data.getVisitDate().atStartOfDay()); @@ -1012,7 +1012,13 @@ record = new IncentiveActivityRecord(); record.setUpdatedBy(createdBy); record.setBenId(benId); record.setAshaId(beneficiaryRepo.getUserIDByUserName(createdBy)); - record.setAmount((long) (rate * packets)); + if(isCH){ + record.setAmount((long) rate); + + }else { + record.setAmount((long) (rate * packets)); + + } recordRepo.save(record); } }catch (Exception e){ From 9a3e25bc7b0ea518c6b83d5fd9781f3ccff14f79 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 17:09:30 +0530 Subject: [PATCH 643/792] update Incentive of IFA --- .../impl/IFAFormSubmissionServiceImpl.java | 53 ++++++++++++++++++- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index e39e9931..d20163c4 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -2,19 +2,25 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.IFAFormSubmissionData; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.IFAFormFieldsDTO; import com.iemr.flw.dto.iemr.IFAFormSubmissionRequest; import com.iemr.flw.dto.iemr.IFAFormSubmissionResponse; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.IFAFormSubmissionRepository; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.IFAFormSubmissionService; import com.iemr.flw.utils.JwtUtil; import lombok.RequiredArgsConstructor; -import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.sql.Timestamp; +import java.time.LocalDate; import java.util.*; import java.time.format.DateTimeFormatter; @@ -31,13 +37,18 @@ public class IFAFormSubmissionServiceImpl implements IFAFormSubmissionService { @Autowired private UserServiceRoleRepo userServiceRoleRepo; + @Autowired + private IncentivesRepo incentivesRepo; + @Autowired + private IncentiveRecordRepo incentiveRecordRepo; + @Override public String saveFormData(List requests) { try { List entities = new ArrayList<>(); for (IFAFormSubmissionRequest req : requests) { IFAFormSubmissionData data = IFAFormSubmissionData.builder() - .userId(userServiceRoleRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())) + .userId(userServiceRoleRepo.getUserIdByName(req.getUserName())) .beneficiaryId(req.getBeneficiaryId()) .formId(req.getFormId()) .houseHoldId(req.getHouseHoldId()) @@ -49,6 +60,7 @@ public String saveFormData(List requests) { entities.add(data); } repository.saveAll(entities); + checkIFAIncentive(entities); return "Form data saved successfully"; } catch (Exception e) { e.printStackTrace(); @@ -56,6 +68,42 @@ public String saveFormData(List requests) { } } + private void checkIFAIncentive(List entities) { + IncentiveActivity incentiveActivityAM= incentivesRepo.findIncentiveMasterByNameAndGroup("NIPI_CHILDREN", GroupName.CHILD_HEALTH.getDisplayName()); + + if(incentiveActivityAM!=null){ + entities.forEach(ifaFormSubmissionData -> { + addIFAIncentive(ifaFormSubmissionData,incentiveActivityAM); + + }); + } + + } + + private void addIFAIncentive(IFAFormSubmissionData ifaFormSubmissionData, IncentiveActivity incentiveActivityAM) { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + + LocalDate ifaVisitDate = LocalDate.parse(ifaFormSubmissionData.getVisitDate(), formatter); + + Timestamp ifaVisitDateTimestamp = Timestamp.valueOf(ifaVisitDate.atStartOfDay()); + + IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo.findRecordByActivityIdCreatedDateBenId(incentiveActivityAM.getId(),ifaVisitDateTimestamp,ifaFormSubmissionData.getBeneficiaryId()); + if(incentiveActivityRecord==null){ + incentiveActivityRecord = new IncentiveActivityRecord(); + incentiveActivityRecord.setActivityId(ifaFormSubmissionData.getId()); + incentiveActivityRecord.setCreatedDate(ifaVisitDateTimestamp); + incentiveActivityRecord.setStartDate(ifaVisitDateTimestamp); + incentiveActivityRecord.setEndDate(ifaVisitDateTimestamp); + incentiveActivityRecord.setUpdatedDate(ifaVisitDateTimestamp); + incentiveActivityRecord.setUpdatedBy(ifaFormSubmissionData.getUserName()); + incentiveActivityRecord.setBenId(ifaFormSubmissionData.getBeneficiaryId()); + incentiveActivityRecord.setAshaId(userServiceRoleRepo.getUserIdByName(ifaFormSubmissionData.getUserName())); + incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivityAM.getRate())); + incentiveRecordRepo.save(incentiveActivityRecord); + } + } + + @Override public List getFormData(GetBenRequestHandler getBenRequestHandler) { List records = repository.findByUserId(getBenRequestHandler.getAshaId()); @@ -89,4 +137,5 @@ public List getFormData(GetBenRequestHandler getBenRe return responses; } + } From 461937271065b03a7f556d44e7d181a2e2fa2300 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 17:12:45 +0530 Subject: [PATCH 644/792] update Incentive of IFA --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index c3983301..ed3f3268 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -169,7 +169,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } entities.forEach(entry -> { if(entry.getName()==null){ - if(entry.getId()>0){ + if(entry.getBenId()!=0 && entry.getBenId()>0L){ Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId()); logger.info("rmnchBeneficiaryDetailsRmnch"+regId); BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId(); From 0f59017931e2f47d69d4ac3b8a2aa7db71fe388e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 17:22:21 +0530 Subject: [PATCH 645/792] update Incentive of IFA --- .../com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java index d20163c4..e4771229 100644 --- a/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IFAFormSubmissionServiceImpl.java @@ -96,6 +96,7 @@ private void addIFAIncentive(IFAFormSubmissionData ifaFormSubmissionData, Incent incentiveActivityRecord.setEndDate(ifaVisitDateTimestamp); incentiveActivityRecord.setUpdatedDate(ifaVisitDateTimestamp); incentiveActivityRecord.setUpdatedBy(ifaFormSubmissionData.getUserName()); + incentiveActivityRecord.setCreatedBy(ifaFormSubmissionData.getUserName()); incentiveActivityRecord.setBenId(ifaFormSubmissionData.getBeneficiaryId()); incentiveActivityRecord.setAshaId(userServiceRoleRepo.getUserIdByName(ifaFormSubmissionData.getUserName())); incentiveActivityRecord.setAmount(Long.valueOf(incentiveActivityAM.getRate())); From ba277e5759a30b082c2718f775a1b8a3fc27dca5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 18:06:47 +0530 Subject: [PATCH 646/792] update Incentive of IFA --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index cc88a279..da421726 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -762,7 +762,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { if (hbyncVisitActivity != null) { - if (hbyc.getVisit_day().equals("15 Months")) { + if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("15 Months")) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } @@ -770,7 +770,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { } if (hbync15MonethVisitActivityCH != null) { - if (hbyc.getVisit_day().equals("15 Months")) { + if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("15 Months")) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbync15MonethVisitActivityCH, hbyc.getCreated_by()); } From 125912d506e21e16f971a8f1f4eb717cae0a795f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 26 Nov 2025 20:05:24 +0530 Subject: [PATCH 647/792] update Incentive of IFA --- .../flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java | 6 +++++- .../com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java index c1cd5efc..ac336da1 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java @@ -378,7 +378,11 @@ public class RMNCHBeneficiaryDetailsRmnch { private Boolean isMarried; @Expose - private Integer doYouHavechildren; + private Boolean doYouHavechildren; + + @Expose + private Integer noOfchildren; + @Expose private Integer noofAlivechildren; diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 2e92b100..510d4b53 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -401,6 +401,7 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("placeOfDeathId", benDetailsRMNCH_OBJ.getPlaceOfDeathId()); resultMap.put("isSpouseAdded", benDetailsRMNCH_OBJ.getIsSpouseAdded()); resultMap.put("isChildrenAdded", benDetailsRMNCH_OBJ.getIsChildrenAdded()); + resultMap.put("noOfchildren", benDetailsRMNCH_OBJ.getNoOfchildren()); resultMap.put("isMarried", benDetailsRMNCH_OBJ.getIsMarried()); resultMap.put("doYouHavechildren", benDetailsRMNCH_OBJ.getDoYouHavechildren()); resultMap.put("noofAlivechildren ",benDetailsRMNCH_OBJ.getNoofAlivechildren()); From 549d89c3f698fc4a0b4e3310f3d2b31cc90d98fc Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 11:37:44 +0530 Subject: [PATCH 648/792] fix is sncu baby weight logic --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index da421726..cdd71c7a 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -810,7 +810,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { } logger.info("getDischarged_from_sncu" + hbncVisit.getDischarged_from_sncu()); - if (hbncVisit.getVisit_day().equals("42nd Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight() < 2.5) { + if (hbncVisit.getVisit_day().equals("42nd Day") && hbncVisit.getDischarged_from_sncu()) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); @@ -1037,7 +1037,6 @@ private void createIncentiveRecordforSamReferalToNrc(SamVisit data, Long benId, if (record == null) { - record = new IncentiveActivityRecord(); record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(visitDate); From 336e00f923bfc203f3ab0dd413fb572b6a86d3e9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 11:47:45 +0530 Subject: [PATCH 649/792] fix is sncu baby weight logic --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index cdd71c7a..558335ba 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -810,7 +810,7 @@ private void checkAndAddHbncIncentives(List hbncVisits) { } logger.info("getDischarged_from_sncu" + hbncVisit.getDischarged_from_sncu()); - if (hbncVisit.getVisit_day().equals("42nd Day") && hbncVisit.getDischarged_from_sncu()) { + if (hbncVisit.getVisit_day().equals("42nd Day") && hbncVisit.getDischarged_from_sncu() && hbncVisit.getBaby_weight() <=2.5) { IncentiveActivity babyDisChargeSNCUAActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("SNCU_LBW_FOLLOWUP", GroupName.CHILD_HEALTH.getDisplayName()); From 3f73a2b389ba9d73cfad0a27aaab63505ec26d03 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 12:20:46 +0530 Subject: [PATCH 650/792] fix hbyc incentive logic --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 558335ba..9c6448c9 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -762,7 +762,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { hbycList.forEach(hbyc -> { if (hbyncVisitActivity != null) { - if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("15 Months")) { + if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("12 Months") || hbyc.getVisit_day().equals("15 Months")) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } @@ -770,7 +770,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { } if (hbync15MonethVisitActivityCH != null) { - if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("15 Months")) { + if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("12 Months") || hbyc.getVisit_day().equals("15 Months")) { createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbync15MonethVisitActivityCH, hbyc.getCreated_by()); } @@ -779,6 +779,7 @@ private void checkAndAddHbyncIncentives(List hbycList) { + if (hbyncOrsPacketActivityCH != null) { if (hbyc.getOrs_given()) { createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); From 44bfe3e1532ef402c1b37595205e80f38f612559 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 12:28:48 +0530 Subject: [PATCH 651/792] fix hbyc incentive logic --- .../flw/service/impl/ChildCareServiceImpl.java | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 9c6448c9..7eb251f0 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -760,26 +760,20 @@ private void checkAndAddHbyncIncentives(List hbycList) { incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); hbycList.forEach(hbyc -> { + Set eligibleHbycVisits = Set.of("3 Months", "6 Months", "9 Months", "12 Months", "15 Months"); - if (hbyncVisitActivity != null) { - if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("12 Months") || hbyc.getVisit_day().equals("15 Months")) { - createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); - - } - + if (hbyncVisitActivity != null && eligibleHbycVisits.contains(hbyc.getVisit_day())) { + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncVisitActivity, hbyc.getCreated_by()); } - if (hbync15MonethVisitActivityCH != null) { - if (hbyc.getVisit_day().equals("3 Months")||hbyc.getVisit_day().equals("6 Months")|| hbyc.getVisit_day().equals("9 Months") || hbyc.getVisit_day().equals("12 Months") || hbyc.getVisit_day().equals("15 Months")) { - createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbync15MonethVisitActivityCH, hbyc.getCreated_by()); - - } - + if (hbync15MonethVisitActivityCH != null && eligibleHbycVisits.contains(hbyc.getVisit_day())) { + createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbync15MonethVisitActivityCH, hbyc.getCreated_by()); } + if (hbyncOrsPacketActivityCH != null) { if (hbyc.getOrs_given()) { createIncentiveRecordforHbyncOrsDistribution(hbyc, hbyc.getBeneficiaryId(), hbyncOrsPacketActivityCH, hbyc.getCreated_by()); From e1080ade7ff5217a7129772508c8c9d11d0d3792 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 13:33:25 +0530 Subject: [PATCH 652/792] fix incentive state code issue --- .../flw/service/impl/IncentiveServiceImpl.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index ed3f3268..391a08e8 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -51,7 +51,6 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private UserServiceRoleRepo userRepo; - private Integer sateId =0; @Override public String saveIncentivesMaster(List activityDTOS) { @@ -81,15 +80,10 @@ public String saveIncentivesMaster(List activityDTOS) { @Override public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { - try { - logger.info("StateId:"+userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()); - UserServiceRoleDTO userServiceRoleDTO= userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0); - if(userRepo.getUserRole(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())).get(0).getStateId()!=null){ - sateId = userServiceRoleDTO.getStateId(); - } + List incs = new ArrayList<>(); - if(sateId==8){ + if(incentiveRequestDTO.getState()==8){ incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); }else { @@ -154,13 +148,14 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { - if(sateId!=8){ + + if(request.getVillageID()!=8){ checkMonthlyAshaIncentive(request.getAshaId()); } List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); - if(sateId==8){ + if(request.getVillageID()==8){ entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); }else { From 5536c5b5e3c53ccbd515bb4bec4de87a7d434fc3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 13:53:27 +0530 Subject: [PATCH 653/792] add state enum class --- .../com/iemr/flw/masterEnum/StateCode.java | 28 +++++++++++++++++++ .../service/impl/IncentiveServiceImpl.java | 7 +++-- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/masterEnum/StateCode.java diff --git a/src/main/java/com/iemr/flw/masterEnum/StateCode.java b/src/main/java/com/iemr/flw/masterEnum/StateCode.java new file mode 100644 index 00000000..76a2ef31 --- /dev/null +++ b/src/main/java/com/iemr/flw/masterEnum/StateCode.java @@ -0,0 +1,28 @@ +package com.iemr.flw.masterEnum; + +public enum StateCode { + AM(5), + CG(8); + + private final int stateCode; + + StateCode(int stateCode) { + this.stateCode = stateCode; + } + + public int getStateCode() { + return stateCode; + } + + + + public static StateCode fromId(int id) { + for (StateCode stateCode : values()) { + if (stateCode.stateCode == id) { + return stateCode; + } + } + throw new IllegalArgumentException("Invalid State ID: " + id); + } + +} diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 391a08e8..386d63b3 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -9,6 +9,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.GroupName; +import com.iemr.flw.masterEnum.StateCode; import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.IncentiveActivityLangMappingRepo; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; @@ -83,7 +84,7 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { List incs = new ArrayList<>(); - if(incentiveRequestDTO.getState()==8){ + if(incentiveRequestDTO.getState()==StateCode.CG.getStateCode()){ incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); }else { @@ -149,13 +150,13 @@ public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { - if(request.getVillageID()!=8){ + if(request.getVillageID()!= StateCode.CG.getStateCode()){ checkMonthlyAshaIncentive(request.getAshaId()); } List dtos = new ArrayList<>(); List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); - if(request.getVillageID()==8){ + if(request.getVillageID()==StateCode.CG.getStateCode()){ entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); }else { From 933421d517755e2676f35ff5dc0f98844ea43b3f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 13:58:51 +0530 Subject: [PATCH 654/792] fix date range issue in incentive --- src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 9a67cc11..883fbc20 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -34,9 +34,11 @@ IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( @Param("ashaId") Integer ashaId ); - @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") + @Query("SELECT r FROM IncentiveActivityRecord r WHERE r.ashaId = :ashaId AND MONTH(r.startDate) = :month AND YEAR(r.startDate) = :year AND MONTH(r.endDate) = :month AND YEAR(r.endDate) = :year") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); + + @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId") List findRecordsByAsha(@Param("ashaId") Integer ashaId); } From 098c09c433a0839f91ae589f783b19358de13af8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 14:10:37 +0530 Subject: [PATCH 655/792] fix date range issue in incentive --- src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java | 2 +- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 883fbc20..6b8db13e 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -34,7 +34,7 @@ IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( @Param("ashaId") Integer ashaId ); - @Query("SELECT r FROM IncentiveActivityRecord r WHERE r.ashaId = :ashaId AND MONTH(r.startDate) = :month AND YEAR(r.startDate) = :year AND MONTH(r.endDate) = :month AND YEAR(r.endDate) = :year") + @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId and record.startDate >= :fromDate and record.startDate <= :toDate and record.endDate >= :fromDate and record.endDate <= :toDate ") List findRecordsByAsha(@Param("ashaId") Integer ashaId, @Param("fromDate") Timestamp fromDate,@Param("toDate") Timestamp toDate); diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 386d63b3..6a42b76d 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -155,7 +155,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { } List dtos = new ArrayList<>(); - List entities = recordRepo.findRecordsByAsha(request.getAshaId(), request.getFromDate(), request.getToDate()); + List entities = recordRepo.findRecordsByAsha(request.getAshaId()); if(request.getVillageID()==StateCode.CG.getStateCode()){ entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); From 3c38f5e31e3fa3c4a327dd7608a09a57ac50cdae Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 16:03:57 +0530 Subject: [PATCH 656/792] fix incentive for SNCU in infant reg --- .../flw/service/impl/InfantServiceImpl.java | 56 +++++++++++++++++++ .../impl/MaternalHealthServiceImpl.java | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java index f25f94eb..1615996b 100644 --- a/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java @@ -1,11 +1,17 @@ package com.iemr.flw.service.impl; import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.domain.iemr.IncentiveActivity; +import com.iemr.flw.domain.iemr.IncentiveActivityRecord; import com.iemr.flw.domain.iemr.InfantRegister; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.InfantRegisterDTO; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.identity.BeneficiaryRepo; +import com.iemr.flw.repo.iemr.IncentiveRecordRepo; +import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.InfantRegisterRepo; +import com.iemr.flw.repo.iemr.UserServiceRoleRepo; import com.iemr.flw.service.InfantService; import org.modelmapper.ModelMapper; import org.slf4j.Logger; @@ -13,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.sql.Timestamp; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -32,6 +39,15 @@ public class InfantServiceImpl implements InfantService { ModelMapper modelMapper = new ModelMapper(); + @Autowired + private IncentiveRecordRepo incentiveRecordRepo; + + @Autowired + private UserServiceRoleRepo userServiceRoleRepo; + + @Autowired + private IncentivesRepo incentivesRepo; + @Override public String registerInfant(List infantRegisterDTOs) { @@ -52,6 +68,7 @@ public String registerInfant(List infantRegisterDTOs) { infantList.add(infantRegister); }); infantRegisterRepo.saveAll(infantList); + checkAndGenerateIncentive(infantList); return "no of infant register details saved: " + infantList.size(); } catch (Exception e) { logger.info("error while saving infant register details: " + e.getMessage()); @@ -59,6 +76,45 @@ public String registerInfant(List infantRegisterDTOs) { return null; } + private void checkAndGenerateIncentive(List infantList) { + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("HBNC_0_42_DAYS", GroupName.ACTIVITY.getDisplayName()); + + infantList.forEach(infantRegister -> { + if(incentiveActivityAM!=null){ + if(infantRegister.getIsSNCU().equals("Yes")){ + addIsSncuIncentive(incentiveActivityAM,infantRegister.getBenId(),infantRegister.getCreatedBy(),infantRegister.getCreatedDate()); + } + + } + + if(incentiveActivityCH!=null){ + if(infantRegister.getIsSNCU().equals("Yes")){ + addIsSncuIncentive(incentiveActivityCH,infantRegister.getBenId(),infantRegister.getCreatedBy(),infantRegister.getCreatedDate()); + + } + } + }); + } + + private void addIsSncuIncentive(IncentiveActivity activity, Long benId, String createdBy, Timestamp createdDate) { + IncentiveActivityRecord incentiveActivityRecord = incentiveRecordRepo.findRecordByActivityIdCreatedDateBenId(activity.getId(),createdDate,benId); + + if(incentiveActivityRecord==null){ + incentiveActivityRecord = new IncentiveActivityRecord(); + incentiveActivityRecord.setActivityId(activity.getId()); + incentiveActivityRecord.setCreatedDate(createdDate); + incentiveActivityRecord.setCreatedBy(createdBy); + incentiveActivityRecord.setStartDate(createdDate); + incentiveActivityRecord.setEndDate(createdDate); + incentiveActivityRecord.setUpdatedDate(createdDate); + incentiveActivityRecord.setUpdatedBy(createdBy); + incentiveActivityRecord.setBenId(benId); + incentiveActivityRecord.setAshaId(userServiceRoleRepo.getUserIdByName(createdBy)); + incentiveActivityRecord.setAmount(Long.valueOf(activity.getRate())); + } + } + @Override public List getInfantDetails(GetBenRequestHandler dto) { try{ diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 1de45e6e..53ba1d28 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -512,7 +512,7 @@ private void checkAndAddIncentives(List ancList) { } } if (ancFullActivityAM != null) { - if (ancVisit.getAncVisit() == 4) { + if (ancVisit.getAncVisit() == 4 || ancVisit.getAncVisit() == 2 || ancVisit.getAncVisit() == 3) { recordAncRelatedIncentive(ancFullActivityAM, ancVisit); } From b77d965fc189ce89113d4c6ece2a4cdd76b5a08c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 16:18:25 +0530 Subject: [PATCH 657/792] fix isSncu incentive bug --- src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java index 1615996b..03af282a 100644 --- a/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/InfantServiceImpl.java @@ -112,6 +112,7 @@ private void addIsSncuIncentive(IncentiveActivity activity, Long benId, String c incentiveActivityRecord.setBenId(benId); incentiveActivityRecord.setAshaId(userServiceRoleRepo.getUserIdByName(createdBy)); incentiveActivityRecord.setAmount(Long.valueOf(activity.getRate())); + incentiveRecordRepo.save(incentiveActivityRecord); } } From 0b3edff9fa1637648257c9c27b17d4e975cb483b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 18:33:10 +0530 Subject: [PATCH 658/792] fix jsy incentive bug --- .../iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 07b3e4a7..0e329f4b 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -155,7 +155,7 @@ public void checkAndAddJsyIncentive(List delOutList) { logger.info("delOutList" + gson.toJson(deliveryOutcome)); IncentiveActivity incentiveActivityJSY1 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_1ST_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY1 != null) { - if (deliveryOutcome.getDeliveryOutcome() == 1 && deliveryOutcome.getLiveBirth()==0) { + if (deliveryOutcome.getDeliveryOutcome() == 1) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY1); if (deliveryOutcome.getPlaceOfDelivery() != null) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY1); @@ -166,7 +166,7 @@ public void checkAndAddJsyIncentive(List delOutList) { IncentiveActivity incentiveActivityJSY2 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_2ND_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY2 != null) { - if (deliveryOutcome.getDeliveryOutcome() == 2 && deliveryOutcome.getLiveBirth()==1) { + if (deliveryOutcome.getDeliveryOutcome() == 2) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY2); if (deliveryOutcome.getPlaceOfDelivery() != null) { @@ -177,7 +177,7 @@ public void checkAndAddJsyIncentive(List delOutList) { IncentiveActivity incentiveActivityJSY3 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_3RD_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY3 != null) { - if (deliveryOutcome.getDeliveryOutcome() == 3 && deliveryOutcome.getLiveBirth()==2) { + if (deliveryOutcome.getDeliveryOutcome() == 3) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY3); if (deliveryOutcome.getPlaceOfDelivery() != null) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY3); @@ -187,7 +187,7 @@ public void checkAndAddJsyIncentive(List delOutList) { IncentiveActivity incentiveActivityJSY4 = incentivesRepo.findIncentiveMasterByNameAndGroup("JSY_4TH_DEL_ANC_RURAL", GroupName.JSY.getDisplayName()); if (incentiveActivityJSY4 != null) { - if (deliveryOutcome.getDeliveryOutcome() == 4 && deliveryOutcome.getLiveBirth()==3) { + if (deliveryOutcome.getDeliveryOutcome() == 4) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityJSY4); if (deliveryOutcome.getPlaceOfDelivery() != null) { createIncentiveRecordforJsy(deliveryOutcome, deliveryOutcome.getBenId(), incentiveActivityInstJSY4); From 7e3a0e1f797dcb6134df6c57c818cb942ab21b3c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 18:49:22 +0530 Subject: [PATCH 659/792] fix antra injection incentive bug --- .../java/com/iemr/flw/service/impl/CoupleServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java index 1704987b..95b0557b 100644 --- a/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java @@ -294,13 +294,19 @@ private void checkAndAddAntaraIncentive(List recordList if (antaraActivity4 != null) { addIncenticeRecord(recordList, ect, userId, antaraActivity4); } + + } else if (ect.getAntraDose().contains("Dose-5")) { IncentiveActivity antaraActivity4 = incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", GroupName.FAMILY_PLANNING.getDisplayName()); IncentiveActivity antaraActivity4CH = - incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA5", GroupName.ACTIVITY.getDisplayName()); + incentivesRepo.findIncentiveMasterByNameAndGroup("FP_ANC_MPA1", GroupName.ACTIVITY.getDisplayName()); if (antaraActivity4CH != null) { + addIncenticeRecord(recordList, ect, userId, antaraActivity4CH); + } + + if (antaraActivity4 != null) { addIncenticeRecord(recordList, ect, userId, antaraActivity4); } } From 11ca60c8a69245e6626a7a4586420a5204116508 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 20:07:33 +0530 Subject: [PATCH 660/792] fix antra injection incentive bug --- src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java index 1d1a62f2..a310acb5 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningMalaria.java @@ -134,7 +134,7 @@ public class ScreeningMalaria { private String malariaSlideTestType; @Column(name = "visit_Id") - private Date visitId; + private Long visitId; @Column(name = "visit_date") private Date visitDate; From 29b59a16b3dd91b657e6166c4dd13cf4c32f6553 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 27 Nov 2025 23:59:03 +0530 Subject: [PATCH 661/792] fix Full Immunization incentive --- src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java b/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java index 56d300fd..9ed0943c 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ChildVaccinationRepo.java @@ -19,7 +19,7 @@ List getChildVaccinationDetails(@Param("userId") String userId ChildVaccination findChildVaccinationByBeneficiaryRegIdAndCreatedDateAndVaccineName(Long benRegId, Timestamp createdDate, String vaccine); @Query(value = "select count(*) from db_iemr.t_childvaccinedetail1 cv left outer join db_iemr.m_immunizationservicevaccination v on " + - "cv.VaccineName = v.VaccineName where cv.beneficiaryRegId = :benRegId and v.Currentimmunizationserviceid in (1,2,3,4,5,6,7,8) and " + + "cv.VaccineName = v.VaccineName where cv.beneficiaryRegId = :benRegId and v.Currentimmunizationserviceid in (1,2,3,4,5) and " + "v.category = 'CHILD'", nativeQuery = true) Integer getFirstYearVaccineCountForBenId(@Param("benRegId") Long benRegId); From 6483a5cca504afbb1ee897415901f57bc877c16c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 28 Nov 2025 10:29:49 +0530 Subject: [PATCH 662/792] fix Ors incentive logic --- .../com/iemr/flw/service/impl/ChildCareServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 7eb251f0..17c84b77 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -574,7 +574,7 @@ public String saveOrsDistributionDetails(List orsDistributio orsDistribution.setNumOrsPackets(orsDistributionDTO.getFields().getNum_ors_packets().toString()); orsDistribution.setChildCount(orsDistributionDTO.getFields().getNum_under5_children().toString()); orsDistribution.setHouseholdId(orsDistributionDTO.getHouseHoldId()); - orsDistribution.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); + orsDistribution.setUserId(userRepo.getUserIdByName(orsDistributionDTO.getUserName())); orsDistribution.setVisitDate(LocalDate.parse(orsDistributionDTO.getFields().getVisit_date(),formatter)); orsDistributionList.add(orsDistribution); @@ -734,13 +734,13 @@ private void checkAndAddOrdDistributionIncentive(List orsDistr IncentiveActivity orsPacketActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); if(orsPacketActivityAM!=null){ if(orsDistribution.getNumOrsPackets()!=null){ - createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityAM,jwtUtil.getUserNameFromStorage(),false); + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityAM,userRepo.getUserNamedByUserId(orsDistribution.getUserId()),false); } } if(orsPacketActivityCH!=null){ if(orsDistribution.getNumOrsPackets()!=null){ - createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityCH,jwtUtil.getUserNameFromStorage(),true); + createIncentiveRecordforOrsDistribution(orsDistribution,orsDistribution.getBeneficiaryId(),orsPacketActivityCH,userRepo.getUserNamedByUserId(orsDistribution.getUserId()),true); } } From 5ac503e930390c5988b8cecd338a894814c7d7ef Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 28 Nov 2025 16:29:31 +0530 Subject: [PATCH 663/792] fix bug in Incentive in IMMUNIZATION --- .../java/com/iemr/flw/service/impl/ChildCareServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java index 17c84b77..43a9eb1f 100644 --- a/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/ChildCareServiceImpl.java @@ -345,6 +345,7 @@ public List getChildVaccinationDetails(GetBenRequestHandler vaccinationDTO.setBeneficiaryId(benId.longValue()); result.add(vaccinationDTO); + checkAndAddIncentives(vaccinationDetails); }); return result; } catch (Exception e) { From db4ef716b7f6adeee5540d2151d9e213f041609b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 5 Dec 2025 12:52:33 +0530 Subject: [PATCH 664/792] increase war file version 3.7.0 to 3.10.0 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d87cbdec..512a160b 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.7.0 + 3.10.0 war FLW-API From 0e01a33fdd94e86b6997608df9751c44f989934a Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Mon, 8 Dec 2025 17:07:20 +0530 Subject: [PATCH 665/792] feat: added the new crash log --- src/main/environment/common_ci.properties | 2 + src/main/environment/common_docker.properties | 2 + .../environment/common_example.properties | 2 + .../flw/controller/CrashLogController.java | 63 +++++++++ .../java/com/iemr/flw/domain/iemr/M_User.java | 86 ++++++------ .../flw/dto/crashlogs/CrashLogRequest.java | 10 ++ .../com/iemr/flw/service/CrashLogService.java | 9 ++ .../flw/service/impl/AshaProfileImpl.java | 15 +- .../flw/service/impl/CrashLogServiceImpl.java | 128 ++++++++++++++++++ .../flw/utils/JwtUserIdValidationFilter.java | 2 +- 10 files changed, 268 insertions(+), 51 deletions(-) create mode 100644 src/main/java/com/iemr/flw/controller/CrashLogController.java create mode 100644 src/main/java/com/iemr/flw/dto/crashlogs/CrashLogRequest.java create mode 100644 src/main/java/com/iemr/flw/service/CrashLogService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index ba6a855d..347e06a3 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -36,3 +36,5 @@ source-address=@env.SMS_CONSENT_SOURCE_ADDRESS@ sms-username=@env.SMS_USERNAME@ sms-password=@env.SMS_PASSWORD@ send-message-url=@env.SMS_MESSAGE_URL@ + +crash.logs.base.path=@env.CRASH_LOGS_PATH@ diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index cb3a613a..958a9a19 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -34,3 +34,5 @@ sms-username=${SMS_USERNAME} sms-password=${SMS_PASSWORD} send-message-url=${SMS_MESSAGE_URL} + +crash.logs.base.path=${CRASH_LOGS_PATH} diff --git a/src/main/environment/common_example.properties b/src/main/environment/common_example.properties index ae5adaa7..51873ab6 100644 --- a/src/main/environment/common_example.properties +++ b/src/main/environment/common_example.properties @@ -36,6 +36,8 @@ sms-username= sms-password= send-message-url= +crash.logs.base.path= + diff --git a/src/main/java/com/iemr/flw/controller/CrashLogController.java b/src/main/java/com/iemr/flw/controller/CrashLogController.java new file mode 100644 index 00000000..335d7dbb --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/CrashLogController.java @@ -0,0 +1,63 @@ +package com.iemr.flw.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.iemr.flw.dto.crashlogs.CrashLogRequest; +import com.iemr.flw.service.CrashLogService; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.response.OutputResponse; + +@RestController +@RequestMapping(value = "/crash-logs", headers = "Authorization") +public class CrashLogController { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + @Autowired + private CrashLogService crashLogService; + + @Autowired + private JwtUtil jwtUtil; + + @Autowired + private ObjectMapper objectMapper; + + @PostMapping(value = "/upload", consumes = "multipart/form-data") + public String uploadCrashLog( + @RequestHeader(value = "JwtToken") String jwtToken, // Changed from Authorization + @RequestParam("file") MultipartFile file, + @RequestParam("metadata") String metadataJson) { + + OutputResponse response = new OutputResponse(); + + try { + // No need to remove "Bearer " prefix - JwtToken header contains raw JWT + Integer userId = jwtUtil.extractUserId(jwtToken); + + // Parse metadata JSON + CrashLogRequest request = objectMapper.readValue(metadataJson, CrashLogRequest.class); + + // Save crash log file + String filePath = crashLogService.saveCrashLog(request, userId, file); + + // Build success response + response.setResponse("Crash log saved successfully. File path: " + filePath); + logger.info("Crash log uploaded successfully for userId: " + userId); + + } catch (Exception e) { + logger.error("Error uploading crash log: " + e.getMessage(), e); + response.setError(e); + } + + return response.toString(); + } +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/M_User.java b/src/main/java/com/iemr/flw/domain/iemr/M_User.java index 38687573..0187a613 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/M_User.java +++ b/src/main/java/com/iemr/flw/domain/iemr/M_User.java @@ -3,6 +3,7 @@ import java.sql.Timestamp; import java.time.LocalDate; +import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.Expose; import jakarta.persistence.Column; @@ -21,135 +22,136 @@ import java.time.LocalDate; @Entity -@Table(name = "m_User",schema = "db_iemr") +@Table(name = "m_User", schema = "db_iemr") @Data public class M_User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose - @Column(name="UserID") + @Column(name = "UserID") private Integer userID; @Expose - @Column(name="TitleID") + @Column(name = "TitleID") private Integer titleID; @Expose - @Column(name="FirstName") + @Column(name = "FirstName") private String firstName; @Expose - @Column(name="MiddleName") + @Column(name = "MiddleName") private String middleName; @Expose - @Column(name="LastName") + @Column(name = "LastName") private String lastName; @Expose - @Column(name="GenderID") + @Column(name = "GenderID") private Short genderID; @Expose - @Column(name="MaritalStatusID") + @Column(name = "MaritalStatusID") private Integer maritalStatusID; @Expose - @Column(name="DesignationID") + @Column(name = "DesignationID") private Integer designationID; @Expose - @Column(name="AadhaarNo") + @Column(name = "AadhaarNo") private String aadhaarNo; @Expose - @Column(name="PAN") + @JsonProperty("pan") + @Column(name = "PAN") private String pAN; @Expose - @Column(name="DOB") - private LocalDate dOB; + @JsonProperty("dob") + @Column(name = "DOB") + private Timestamp dOB; @Expose - @Column(name="DOJ") - private LocalDate dOJ; + @JsonProperty("doj") + @Column(name = "DOJ") + private Timestamp dOJ; @Expose - @Column(name="QualificationID") + @Column(name = "QualificationID") private Integer qualificationID; @Expose - @Column(name="HealthProfessionalID") + @Column(name = "HealthProfessionalID") private String healthProfessionalID; @Expose - @Column(name="UserName") + @Column(name = "UserName") private String userName; @Expose - @Column(name="Password") + @Column(name = "Password") private String password; @Expose - @Column(name="IsExternal") + @Column(name = "IsExternal") private Boolean isExternal; @Expose - @Column(name="AgentID") + @Column(name = "AgentID") private String agentID; @Expose - @Column(name="AgentPassword") + @Column(name = "AgentPassword") private String agentPassword; @Expose - @Column(name="EmailID") + @Column(name = "EmailID") private String emailID; @Expose - @Column(name="StatusID") + @Column(name = "StatusID") private Integer statusID; @Expose - @Column(name="EmergencyContactPerson") + @Column(name = "EmergencyContactPerson") private String emergencyContactPerson; @Expose - @Column(name="EmergencyContactNo") + @Column(name = "EmergencyContactNo") private String emergencyContactNo; @Expose - @Column(name="IsSupervisor") + @Column(name = "IsSupervisor") private Boolean isSupervisor; @Expose - @Column(name="Deleted",insertable = false, updatable = true) + @Column(name = "Deleted", insertable = false, updatable = true) private Boolean deleted; @Expose - @Column(name="CreatedBy") + @Column(name = "CreatedBy") private String createdBy; @Expose - @Column(name="EmployeeID") + @Column(name = "EmployeeID") private String employeeID; @Expose - @Column(name="CreatedDate",insertable = false, updatable = false) + @Column(name = "CreatedDate", insertable = false, updatable = false) private Timestamp createdDate; @Expose - @Column(name="ModifiedBy") + @Column(name = "ModifiedBy") private String modifiedBy; @Expose - @Column(name="LastModDate",insertable = false, updatable = false) + @Column(name = "LastModDate", insertable = false, updatable = false) private Timestamp lastModDate; @Expose - @Column(name="Remarks") + @Column(name = "Remarks") private String remarks; @Expose - @Column(name="ContactNo") + @Column(name = "ContactNo") private String contactNo; - @Expose - @Column(name="IsProviderAdmin") + @Column(name = "IsProviderAdmin") private Boolean isProviderAdmin; @Expose - @Column(name="ServiceProviderID") + @Column(name = "ServiceProviderID") private Integer serviceProviderID; - - @Expose @Column(name = "failed_attempt", insertable = false) private Integer failedAttempt; + public M_User() { // TODO Auto-generated constructor stub } public M_User(Integer userID, String userName) { // TODO Auto-generated constructor stub - this.userID=userID; - this.userName=userName; + this.userID = userID; + this.userName = userName; } } diff --git a/src/main/java/com/iemr/flw/dto/crashlogs/CrashLogRequest.java b/src/main/java/com/iemr/flw/dto/crashlogs/CrashLogRequest.java new file mode 100644 index 00000000..2e0bf107 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/crashlogs/CrashLogRequest.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.crashlogs; + +import lombok.Data; + +@Data +public class CrashLogRequest { + private String appVersion; + private String deviceId; + private String timestamp; +} diff --git a/src/main/java/com/iemr/flw/service/CrashLogService.java b/src/main/java/com/iemr/flw/service/CrashLogService.java new file mode 100644 index 00000000..f0ffe35e --- /dev/null +++ b/src/main/java/com/iemr/flw/service/CrashLogService.java @@ -0,0 +1,9 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.crashlogs.CrashLogRequest; +import org.springframework.web.multipart.MultipartFile; +import com.iemr.flw.utils.exception.IEMRException; + +public interface CrashLogService { + String saveCrashLog(CrashLogRequest request, Integer userId, MultipartFile file) throws IEMRException; +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java index 9f884ced..29ca30da 100644 --- a/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/AshaProfileImpl.java @@ -99,16 +99,15 @@ private AshaWorker getDetails(Integer userID) { M_User m_user = Objects.requireNonNull(employeeMasterInter.getUserDetails(userID), "User details not found for ID: " + userID); AshaWorker ashaWorker = new AshaWorker(); ashaWorker.setEmployeeId(m_user.getUserID()); - ashaWorker.setDob(m_user.getDOB()); - LocalDate doj = m_user.getDOJ(); - - if (doj == null) { - doj = LocalDate.now(); - } - + // Convert DOB (Timestamp) to LocalDate + java.sql.Timestamp dobTimestamp = m_user.getDOB(); + LocalDate dob = dobTimestamp != null ? dobTimestamp.toLocalDateTime().toLocalDate() : null; + ashaWorker.setDob(dob); + // Convert DOJ (Timestamp) to LocalDate + java.sql.Timestamp dojTimestamp = m_user.getDOJ(); + LocalDate doj = dojTimestamp != null ? dojTimestamp.toLocalDateTime().toLocalDate() : LocalDate.now(); ashaWorker.setDateOfJoining(doj); ashaWorker.setName(String.format("%s %s", Objects.toString(m_user.getFirstName(), ""), Objects.toString(m_user.getLastName(), "")).trim()); - ashaWorker.setMobileNumber(m_user.getContactNo()); ashaWorker.setAlternateMobileNumber(m_user.getEmergencyContactNo()); ashaWorker.setProviderServiceMapID(m_user.getServiceProviderID()); diff --git a/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java new file mode 100644 index 00000000..da2fbaa0 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java @@ -0,0 +1,128 @@ +package com.iemr.flw.service.impl; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.nio.file.Paths; +import java.time.Instant; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import com.iemr.flw.dto.crashlogs.CrashLogRequest; +import com.iemr.flw.service.CrashLogService; +import com.iemr.flw.utils.exception.IEMRException; +import org.springframework.beans.factory.annotation.Value; + +@Service +public class CrashLogServiceImpl implements CrashLogService { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + @Value("${crash.logs.base.path}") + private String crashLogsBasePath; + + @Override + public String saveCrashLog(CrashLogRequest request, Integer userId, MultipartFile file) + throws IEMRException { + + try { + // 🛡️ Validate file + if (file.isEmpty()) { + throw new IEMRException("Uploaded file is empty"); + } + + String originalFilename = file.getOriginalFilename(); + if (originalFilename == null) { + throw new IEMRException("Invalid filename"); + } + + // Prevent path traversal + String safeOriginalName = Paths.get(originalFilename).getFileName().toString(); + + // Only allow .txt + if (!safeOriginalName.toLowerCase().endsWith(".txt")) { + throw new IEMRException("Only .txt files are allowed"); + } + + // Validate MIME + String contentType = file.getContentType(); + if (contentType == null || + (!contentType.equals("text/plain") && + !contentType.equals("application/octet-stream"))) { + throw new IEMRException("Invalid file type. Only plain text allowed."); + } + + // Block binary content + if (isBinaryFile(file.getBytes())) { + throw new IEMRException("Binary files are not allowed. Upload valid text logs only."); + } + + // 📁 Create date-based folder + LocalDate date = LocalDate.now(); + String dateFolder = date.format(DateTimeFormatter.ISO_LOCAL_DATE); + + File dateDir = new File(crashLogsBasePath, dateFolder); + if (!dateDir.exists() && !dateDir.mkdirs()) { + throw new IEMRException("Failed to create folder: " + dateDir.getAbsolutePath()); + } + + // Use timestamp as sent by frontend (NO conversion) + String rawTimestamp = request.getTimestamp(); // Already "yyyy-MM-dd HH:mm:ss" + + // Make timestamp filename-safe + String safeTimestamp = rawTimestamp + .replace(" ", "_") + .replace(":", "-"); + + // 📝 Final file name + String filename = String.format( + "%d_%s_%s_%s.txt", + userId, + sanitizeFilename(request.getAppVersion()), + sanitizeFilename(request.getDeviceId()), + sanitizeFilename(safeTimestamp)); + + File crashLogFile = new File(dateDir, filename); + + // 💾 Save file + try (FileOutputStream fos = new FileOutputStream(crashLogFile)) { + fos.write(file.getBytes()); + } + + String relativePath = dateFolder + "/" + filename; + logger.info("Crash log saved: " + relativePath); + + return relativePath; + + } catch (IOException e) { + logger.error("Error saving crash log", e); + throw new IEMRException("Error saving crash log: " + e.getMessage(), e); + } + } + + // Detect binary content + private boolean isBinaryFile(byte[] data) { + int len = Math.min(data.length, 2048); + for (int i = 0; i < len; i++) { + byte b = data[i]; + if (b < 0x09) + return true; + if (b > 0x0D && b < 0x20) + return true; + } + return false; + } + + // Sanitize metadata for filename safety + private String sanitizeFilename(String input) { + if (input == null) + return "unknown"; + return input.replaceAll("[^a-zA-Z0-9.-]", "_"); + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index 73fcc3df..fcefd712 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -76,7 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } // Skip login and public endpoints - if (true) { + if (shouldSkipPath(path, contextPath)) { filterChain.doFilter(servletRequest, servletResponse); return; } From 085e4a701b43ee1a2988f615ab90cafd270df8ad Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 17:05:41 +0530 Subject: [PATCH 666/792] update CI properties --- src/main/environment/common_docker.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index cb3a613a..85b7fe01 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -15,8 +15,8 @@ secondary.datasource.password=${DATABASE_IDENTITY_PASSWORD} secondary.datasource.url=${DATABASE_IDENTITY_URL} secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=true -springdoc.swagger-ui.enabled=true +springdoc.api-docs.enabled= ${SWAGGER_UI_ENABLED} +springdoc.swagger-ui.enabled= ${SWAGGER_UI_ENABLED} #ELK logging file name logging.path=logs/ From 01b45d331876abec75660bf4ef4fdae83c5abb37 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 17:19:28 +0530 Subject: [PATCH 667/792] update version in pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 512a160b..d87cbdec 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.10.0 + 3.7.0 war FLW-API From 92f5e2a7f781916547475a2f351325ad4628f2ff Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 18:44:41 +0530 Subject: [PATCH 668/792] update docker file --- src/main/environment/common_docker.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 85b7fe01..149a25ce 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -15,8 +15,8 @@ secondary.datasource.password=${DATABASE_IDENTITY_PASSWORD} secondary.datasource.url=${DATABASE_IDENTITY_URL} secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled= ${SWAGGER_UI_ENABLED} -springdoc.swagger-ui.enabled= ${SWAGGER_UI_ENABLED} +springdoc.api-docs.enabled=${SWAGGER_UI_ENABLED} +springdoc.swagger-ui.enabled=${SWAGGER_UI_ENABLED} #ELK logging file name logging.path=logs/ From d2297b4d69113029581d3456e4d92d91d84a4037 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 19:01:49 +0530 Subject: [PATCH 669/792] update properties file file --- src/main/environment/common_ci.properties | 2 -- src/main/environment/common_docker.properties | 3 +-- src/main/resources/application.properties | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index ba6a855d..44ef75ec 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -16,8 +16,6 @@ secondary.datasource.password=@env.DATABASE_IDENTITY_PASSWORD@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=@env.SWAGGER_UI_ENABLED@ -springdoc.swagger-ui.enabled=@env.SWAGGER_UI_ENABLED@ #ELK logging file name logging.path=logs/ diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 149a25ce..313e1fb2 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -15,8 +15,7 @@ secondary.datasource.password=${DATABASE_IDENTITY_PASSWORD} secondary.datasource.url=${DATABASE_IDENTITY_URL} secondary.datasource.driver-class-name=com.mysql.jdbc.Driver -springdoc.api-docs.enabled=${SWAGGER_UI_ENABLED} -springdoc.swagger-ui.enabled=${SWAGGER_UI_ENABLED} + #ELK logging file name logging.path=logs/ diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8546550d..3b106344 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -63,8 +63,8 @@ fhir-url= # TM Config tm-url= -springdoc.api-docs.enabled=true -springdoc.swagger-ui.enabled=true +springdoc.api-docs.enabled=false +springdoc.swagger-ui.enabled=false spring.redis.host=localhost spring.main.allow-bean-definition-overriding=true spring.redis.password= From c86370147514b0877a44e3503b9874391ace8545 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 19:03:31 +0530 Subject: [PATCH 670/792] update properties file file --- src/main/environment/common_ci.properties | 1 + src/main/environment/common_docker.properties | 1 + src/main/resources/application.properties | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 44ef75ec..b1ceae56 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -17,6 +17,7 @@ secondary.datasource.url=@env.DATABASE_IDENTITY_URL@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver + #ELK logging file name logging.path=logs/ logging.file.name=@env.FLW_API_LOGGING_FILE_NAME@ diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 313e1fb2..46022b87 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -17,6 +17,7 @@ secondary.datasource.driver-class-name=com.mysql.jdbc.Driver + #ELK logging file name logging.path=logs/ logging.file.name=${FLW_API_LOGGING_FILE_NAME} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3b106344..ab7eae2a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -65,6 +65,7 @@ fhir-url= tm-url= springdoc.api-docs.enabled=false springdoc.swagger-ui.enabled=false + spring.redis.host=localhost spring.main.allow-bean-definition-overriding=true spring.redis.password= From 09ad4162cba43d35bc14f0251d04ae829f887054 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 9 Dec 2025 21:55:30 +0530 Subject: [PATCH 671/792] Update incentive for missing supporting documents --- .../flw/controller/IncentiveController.java | 45 +++++-- .../flw/controller/MaaMeetingController.java | 48 +++++++- .../domain/iemr/IncentiveActivityRecord.java | 6 + .../domain/iemr/IncentivePendingActivity.java | 39 ++++++ .../flw/dto/iemr/MaaMeetingRequestDTO.java | 1 + .../iemr/flw/dto/iemr/PendingActivityDTO.java | 14 +++ .../IncentivePendingActivityRepository.java | 14 +++ .../iemr/flw/service/IncentiveService.java | 3 + .../iemr/flw/service/MaaMeetingService.java | 111 ++++++++++++++++-- .../service/impl/IncentiveServiceImpl.java | 39 +++++- 10 files changed, 292 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/IncentivePendingActivity.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java diff --git a/src/main/java/com/iemr/flw/controller/IncentiveController.java b/src/main/java/com/iemr/flw/controller/IncentiveController.java index 670d611b..c76d26ae 100644 --- a/src/main/java/com/iemr/flw/controller/IncentiveController.java +++ b/src/main/java/com/iemr/flw/controller/IncentiveController.java @@ -3,6 +3,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.IncentiveActivityDTO; import com.iemr.flw.dto.iemr.IncentiveRequestDTO; +import com.iemr.flw.dto.iemr.PendingActivityDTO; import com.iemr.flw.service.IncentiveService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; @@ -29,8 +30,8 @@ public class IncentiveController { IncentiveService incentiveService; @Operation(summary = "save incentive master") - @RequestMapping(value = { "/masterData/saveAll" }, method = { RequestMethod.POST }) - public String saveIncentiveMasterData(@RequestBody List activityDTOS,@RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { + @RequestMapping(value = {"/masterData/saveAll"}, method = {RequestMethod.POST}) + public String saveIncentiveMasterData(@RequestBody List activityDTOS, @RequestHeader(value = "Authorization") String authorization, HttpServletRequest request) { OutputResponse response = new OutputResponse(); try { logger.info("Saving All incentives"); @@ -50,9 +51,9 @@ public String saveIncentiveMasterData(@RequestBody List ac } @Operation(summary = "get incentive master") - @RequestMapping(value = { "/masterData/getAll" }, method = { RequestMethod.POST }) + @RequestMapping(value = {"/masterData/getAll"}, method = {RequestMethod.POST}) public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentiveRequestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { @@ -61,7 +62,7 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive // add logic for different state or district if (incentiveRequestDTO != null) { String s = incentiveService.getIncentiveMaster(incentiveRequestDTO); - logger.info("All incentives"+s); + logger.info("All incentives" + s); if (s != null) response.setResponse(s); @@ -77,13 +78,10 @@ public String saveIncentiveMasterData(@RequestBody IncentiveRequestDTO incentive } - - - @Operation(summary = "get high risk assessment data of all beneficiaries registered with given user id") - @RequestMapping(value = { "/fetchUserData" }, method = { RequestMethod.POST }) + @RequestMapping(value = {"/fetchUserData"}, method = {RequestMethod.POST}) public String getAllIncentivesByUserId(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); try { @@ -91,7 +89,30 @@ public String getAllIncentivesByUserId(@RequestBody GetBenRequestHandler request logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + requestDTO); String s = incentiveService.getAllIncentivesByUserId(requestDTO); - logger.info("User Incentive:"+s); + logger.info("User Incentive:" + s); + if (s != null) + response.setResponse(s); + else + response.setError(5000, "No record found"); + } else + response.setError(5000, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in high risk assessment data : " + e); + response.setError(5000, "Error in high risk assessment data : " + e); + } + return response.toString(); + } + + @RequestMapping(value = {"/update"}, method = RequestMethod.POST) + public String updateIncentive(@RequestBody PendingActivityDTO requestDTO) { + OutputResponse response = new OutputResponse(); + try { + + if (requestDTO != null) { + logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + + requestDTO); + String s = incentiveService.updateIncentive(requestDTO); + logger.info("User Incentive:" + s); if (s != null) response.setResponse(s); else @@ -103,6 +124,8 @@ public String getAllIncentivesByUserId(@RequestBody GetBenRequestHandler request response.setError(5000, "Error in high risk assessment data : " + e); } return response.toString(); + + } } diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index d9bcdb1b..0c73d46e 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -49,8 +49,54 @@ public ResponseEntity saveMeeting( dto.setAshaId(Integer.parseInt(ashaId)); dto.setCreatedBY(createdBy); dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); + if (dto != null) { + service.saveMeeting(dto); - service.saveMeeting(dto); + } + return ResponseEntity.ok("Saved Successfully"); + } catch (Exception e) { + return ResponseEntity.badRequest().body(e.getMessage()); + } + } + + @PostMapping(value = "/update", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity updateMeeting( + @RequestPart("meetingDate") String meetingDate, + @RequestPart("place") String place, + @RequestPart("participants") String participants, + @RequestPart("ashaId") String ashaId, + @RequestPart("createdBy") String createdBy, + @RequestPart(value = "meetingImages", required = false) List meetingImages) { + try { + MaaMeetingRequestDTO dto = new MaaMeetingRequestDTO(); + if (meetingDate != null) { + dto.setMeetingDate(LocalDate.parse(meetingDate)); + + } + if (place != null) { + dto.setPlace(place); + + } + if (participants != null) { + dto.setParticipants(Integer.parseInt(participants)); + + } + if (ashaId != null) { + dto.setAshaId(Integer.parseInt(ashaId)); + + } + if (createdBy != null) { + dto.setCreatedBY(createdBy); + + } + if (meetingImages != null) { + dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); + + } + if (dto != null) { + service.updateMeeting(dto); + + } return ResponseEntity.ok("Saved Successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); diff --git a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityRecord.java b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityRecord.java index 5b921bb4..f4adf8df 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityRecord.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IncentiveActivityRecord.java @@ -46,4 +46,10 @@ public class IncentiveActivityRecord { @Column(name = "updated_by") private String updatedBy; + + @Column(name = "is_eligible") + private Boolean isEligible; + + @Column(name = "is_default_activity") + private Boolean isDefaultActivity; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/IncentivePendingActivity.java b/src/main/java/com/iemr/flw/domain/iemr/IncentivePendingActivity.java new file mode 100644 index 00000000..870a48f5 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/IncentivePendingActivity.java @@ -0,0 +1,39 @@ +package com.iemr.flw.domain.iemr; + +import java.util.Date; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "incentive_pending_activity", schema = "db_iemr") +@Data +@NoArgsConstructor +@AllArgsConstructor +public class IncentivePendingActivity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Long id; + + @Column(name = "activity_id", nullable = false) + private Long activityId; + + @Column(name = "record_id", nullable = false) + private Long recordId; + + @Column(name = "module_name", nullable = false, length = 100) + private String moduleName; + + @Column(name = "user_id", nullable = false) + private Integer userId; + + @Column(name = "created_date") + private Date createdDate; + + @Column(name = "updated_date") + private Date updatedDate; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index c08c8d64..9d4c19b1 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -8,6 +8,7 @@ @Data public class MaaMeetingRequestDTO { + private Long id; private LocalDate meetingDate; private String place; private Integer participants; diff --git a/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java new file mode 100644 index 00000000..4d8dbd99 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java @@ -0,0 +1,14 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +@Data +public class PendingActivityDTO { + private Long id; + private Integer userId; + private List Images; + private String moduleName; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java new file mode 100644 index 00000000..bb53cb5b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java @@ -0,0 +1,14 @@ +package com.iemr.flw.repo.iemr; + +import java.util.Optional; +import com.iemr.flw.domain.iemr.IncentivePendingActivity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + + +@Repository +public interface IncentivePendingActivityRepository extends JpaRepository { + + Optional findByUserIdAndModuleNameActivityId(Integer userId, String moduleName,Long activityId); + +} diff --git a/src/main/java/com/iemr/flw/service/IncentiveService.java b/src/main/java/com/iemr/flw/service/IncentiveService.java index ab49a0cd..d6bb5550 100644 --- a/src/main/java/com/iemr/flw/service/IncentiveService.java +++ b/src/main/java/com/iemr/flw/service/IncentiveService.java @@ -3,6 +3,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.IncentiveActivityDTO; import com.iemr.flw.dto.iemr.IncentiveRequestDTO; +import com.iemr.flw.dto.iemr.PendingActivityDTO; import java.util.List; @@ -13,4 +14,6 @@ public interface IncentiveService { String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO); String getAllIncentivesByUserId(GetBenRequestHandler requestDTO); + + String updateIncentive(PendingActivityDTO pendingActivityDTO); } diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index d5f4c5bd..2c48df26 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -3,28 +3,20 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.iemr.flw.domain.iemr.IncentiveActivity; -import com.iemr.flw.domain.iemr.IncentiveActivityRecord; -import com.iemr.flw.domain.iemr.MaaMeeting; -import com.iemr.flw.domain.iemr.UwinSession; +import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.MaaMeetingRequestDTO; import com.iemr.flw.dto.iemr.MaaMeetingResponseDTO; import com.iemr.flw.masterEnum.GroupName; -import com.iemr.flw.repo.iemr.IncentiveRecordRepo; -import com.iemr.flw.repo.iemr.IncentivesRepo; -import com.iemr.flw.repo.iemr.MaaMeetingRepository; -import com.iemr.flw.repo.iemr.UserServiceRoleRepo; +import com.iemr.flw.repo.iemr.*; +import jakarta.persistence.EntityNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; @Service @@ -40,6 +32,9 @@ public class MaaMeetingService { private final MaaMeetingRepository repository; private final ObjectMapper objectMapper; + @Autowired + private IncentivePendingActivityRepository incentivePendingActivityRepository; + public MaaMeetingService(MaaMeetingRepository repository, ObjectMapper objectMapper) { this.repository = repository; this.objectMapper = objectMapper; @@ -69,12 +64,61 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { String imagesJson = objectMapper.writeValueAsString(base64Images); meeting.setMeetingImagesJson(imagesJson); } + checkAndAddIncentive(meeting); return repository.save(meeting); } + public MaaMeeting updateMeeting(MaaMeetingRequestDTO req) throws JsonProcessingException { + MaaMeeting existingMeeting = repository.findById(req.getId()) + .orElseThrow(() -> new EntityNotFoundException("Meeting not found: " + req.getId())); + + // ✅ NULL CHECK + if (req.getMeetingDate() != null) { + existingMeeting.setMeetingDate(req.getMeetingDate()); + } + if (req.getPlace() != null) { + existingMeeting.setPlace(req.getPlace()); + } + if (req.getParticipants() != null) { + existingMeeting.setParticipants(req.getParticipants()); + } + if (req.getAshaId() != null) { + existingMeeting.setAshaId(req.getAshaId()); + } + if (req.getCreatedBY() != null) { // ✅ Typo fixed: CreatedBY → CreatedBy + existingMeeting.setCreatedBy(req.getCreatedBY()); + } + + // Images - only if provided + if (req.getMeetingImages() != null && req.getMeetingImages().length > 0) { + List base64Images = Arrays.stream(req.getMeetingImages()) + .filter(file -> file != null && !file.isEmpty()) + .map(this::convertToBase64) + .collect(Collectors.toList()); + existingMeeting.setMeetingImagesJson(objectMapper.writeValueAsString(base64Images)); + } + + checkAndAddIncentive(existingMeeting); + if(existingMeeting.getMeetingImagesJson()!=null){ + checkAndUpdateIncentive(existingMeeting); + + } + return repository.save(existingMeeting); + } + + + private String convertToBase64(MultipartFile file) { + try { + return Base64.getEncoder().encodeToString(file.getBytes()); + } catch (IOException e) { + throw new RuntimeException("Failed to convert image to Base64: " + file.getOriginalFilename(), e); + } + } + + public List getAllMeetings(GetBenRequestHandler getBenRequestHandler) throws Exception { @@ -107,6 +151,29 @@ public List getAllMeetings(GetBenRequestHandler getBenReq return dto; }).collect(Collectors.toList()); } + private void updatePendingActivity(Integer userId,Long recordId,Long activityId,String moduleName){ + IncentivePendingActivity incentivePendingActivity = new IncentivePendingActivity(); + incentivePendingActivity.setActivityId(activityId); + incentivePendingActivity.setRecordId(recordId); + incentivePendingActivity.setUserId(userId); + incentivePendingActivity.setModuleName(moduleName); + if(incentivePendingActivity!=null){ + incentivePendingActivityRepository.save(incentivePendingActivity); + } + + } + private void checkAndUpdateIncentive(MaaMeeting meeting) { + IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.CHILD_HEALTH.getDisplayName()); + IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.ACTIVITY.getDisplayName()); + if(incentiveActivityAM!=null){ + updateIncentive(incentiveActivityAM,meeting); + } + if(incentiveActivityCH!=null){ + updateIncentive(incentiveActivityCH,meeting); + + } + + } private void checkAndAddIncentive(MaaMeeting meeting) { IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.ACTIVITY.getDisplayName()); @@ -135,10 +202,30 @@ record = new IncentiveActivityRecord(); record.setUpdatedBy(meeting.getCreatedBy()); record.setBenId(0L); record.setAshaId(meeting.getAshaId()); + if(meeting.getMeetingImagesJson()!=null){ + record.setIsEligible(true); + }else { + record.setIsEligible(false); + updatePendingActivity(meeting.getAshaId(),meeting.getId(),record.getId(),"MAA_MEETING"); + + } record.setAmount(Long.valueOf(incentiveActivity.getRate())); recordRepo.save(record); } } + private void updateIncentive(IncentiveActivity incentiveActivity,MaaMeeting meeting){ + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L,meeting.getAshaId()); + + if (record!= null) { + record = new IncentiveActivityRecord(); + record.setIsEligible(true); + recordRepo.save(record); + } + + } + + } diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 6a42b76d..9d5ede87 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -6,22 +6,22 @@ import com.iemr.flw.domain.iemr.IncentiveActivity; import com.iemr.flw.domain.iemr.IncentiveActivityLangMapping; import com.iemr.flw.domain.iemr.IncentiveActivityRecord; +import com.iemr.flw.domain.iemr.IncentivePendingActivity; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.masterEnum.StateCode; import com.iemr.flw.repo.identity.BeneficiaryRepo; -import com.iemr.flw.repo.iemr.IncentiveActivityLangMappingRepo; -import com.iemr.flw.repo.iemr.IncentiveRecordRepo; -import com.iemr.flw.repo.iemr.IncentivesRepo; -import com.iemr.flw.repo.iemr.UserServiceRoleRepo; +import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.IncentiveService; +import com.iemr.flw.service.MaaMeetingService; import com.iemr.flw.utils.JwtUtil; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.math.BigInteger; import java.sql.Timestamp; @@ -50,9 +50,15 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private JwtUtil jwtUtil; + @Autowired + private IncentivePendingActivityRepository incentivePendingActivityRepository; + @Autowired private UserServiceRoleRepo userRepo; + @Autowired + private MaaMeetingService maaMeetingService; + @Override public String saveIncentivesMaster(List activityDTOS) { try { @@ -187,6 +193,31 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } + + @Override + public String updateIncentive(PendingActivityDTO pendingActivityDTO) { + Optional incentivePendingActivity = incentivePendingActivityRepository.findByUserIdAndModuleNameActivityId(pendingActivityDTO.getUserId(),pendingActivityDTO.getModuleName(),pendingActivityDTO.getId()); + + if(incentivePendingActivity.isPresent()){ + IncentivePendingActivity existingIncentivePendingActivity = incentivePendingActivity.get(); + if(existingIncentivePendingActivity.getModuleName().equals("MAA_MEETING")){ + if(pendingActivityDTO.getImages()!=null){ + try { + MaaMeetingRequestDTO maaMeetingRequestDTO = new MaaMeetingRequestDTO(); + maaMeetingRequestDTO.setMeetingImages(pendingActivityDTO.getImages().toArray(new MultipartFile[0])); + maaMeetingService.updateMeeting(maaMeetingRequestDTO); + + }catch (Exception e){ + return e.getMessage(); + } + + } + } + } + return null; + + } + private void checkMonthlyAshaIncentive(Integer ashaId){ IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); From f383508c6dfdf6f5b2f0351e10615f60aac4c420 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 15 Dec 2025 17:39:44 +0530 Subject: [PATCH 672/792] fix jpa query issue --- .../flw/repo/iemr/IncentivePendingActivityRepository.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java index bb53cb5b..9bac8d21 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivePendingActivityRepository.java @@ -8,7 +8,11 @@ @Repository public interface IncentivePendingActivityRepository extends JpaRepository { - - Optional findByUserIdAndModuleNameActivityId(Integer userId, String moduleName,Long activityId); + Optional + findByUserIdAndModuleNameAndActivityId( + Integer userId, + String moduleName, + Long activityId + ); } From 1306881c8c9aa12de25bb246feb9a0d9c5698723 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 15 Dec 2025 18:39:38 +0530 Subject: [PATCH 673/792] fix jpa query issue --- .../java/com/iemr/flw/service/impl/IncentiveServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 9d5ede87..5580e896 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -196,7 +196,7 @@ public String getAllIncentivesByUserId(GetBenRequestHandler request) { @Override public String updateIncentive(PendingActivityDTO pendingActivityDTO) { - Optional incentivePendingActivity = incentivePendingActivityRepository.findByUserIdAndModuleNameActivityId(pendingActivityDTO.getUserId(),pendingActivityDTO.getModuleName(),pendingActivityDTO.getId()); + Optional incentivePendingActivity = incentivePendingActivityRepository.findByUserIdAndModuleNameAndActivityId(pendingActivityDTO.getUserId(),pendingActivityDTO.getModuleName(),pendingActivityDTO.getId()); if(incentivePendingActivity.isPresent()){ IncentivePendingActivity existingIncentivePendingActivity = incentivePendingActivity.get(); From 17d872d198579554f16997c8b7812350711080d6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:44:13 +0530 Subject: [PATCH 674/792] Update common_ci.properties --- src/main/environment/common_ci.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index 6dd8fd04..c24982b7 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -36,4 +36,4 @@ sms-username=@env.SMS_USERNAME@ sms-password=@env.SMS_PASSWORD@ send-message-url=@env.SMS_MESSAGE_URL@ -crash.logs.base.path=@env.CRASH_LOGS_PATH@ +//crash.logs.base.path=@env.CRASH_LOGS_PATH@ From 603e2e3ea1d2b88838bb81dfe7c476edebe38dc8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:44:26 +0530 Subject: [PATCH 675/792] Reformat common_docker.properties for consistency --- src/main/environment/common_docker.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 2351a47e..95012c97 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -35,4 +35,5 @@ sms-password=${SMS_PASSWORD} send-message-url=${SMS_MESSAGE_URL} -crash.logs.base.path=${CRASH_LOGS_PATH} +//crash.logs.base.path=${CRASH_LOGS_PATH} + From 2cdff4a64006e8c24f6e1046b473a28277346e7b Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:44:55 +0530 Subject: [PATCH 676/792] Reformat common_docker.properties for consistency --- src/main/environment/common_docker.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index 95012c97..b6650a5d 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -35,5 +35,6 @@ sms-password=${SMS_PASSWORD} send-message-url=${SMS_MESSAGE_URL} -//crash.logs.base.path=${CRASH_LOGS_PATH} +#crash.logs.base.path=${CRASH_LOGS_PATH} + From aa49f97cd5890a57cee57708ea1260e1beda0698 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:45:09 +0530 Subject: [PATCH 677/792] Update common_ci.properties --- src/main/environment/common_ci.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/environment/common_ci.properties b/src/main/environment/common_ci.properties index c24982b7..b5aa3f02 100644 --- a/src/main/environment/common_ci.properties +++ b/src/main/environment/common_ci.properties @@ -36,4 +36,4 @@ sms-username=@env.SMS_USERNAME@ sms-password=@env.SMS_PASSWORD@ send-message-url=@env.SMS_MESSAGE_URL@ -//crash.logs.base.path=@env.CRASH_LOGS_PATH@ +#crash.logs.base.path=@env.CRASH_LOGS_PATH@ From 2b74a485f5e7b523a1cc69e79729b793ad7cc1f2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 15 Dec 2025 18:47:52 +0530 Subject: [PATCH 678/792] Update CrashLogServiceImpl.java --- .../java/com/iemr/flw/service/impl/CrashLogServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java index da2fbaa0..4c85ae66 100644 --- a/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CrashLogServiceImpl.java @@ -24,7 +24,7 @@ public class CrashLogServiceImpl implements CrashLogService { private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); - @Value("${crash.logs.base.path}") + // @Value("${crash.logs.base.path}") private String crashLogsBasePath; @Override From edd3046f386b52b00e1c15bd3e36a1641b852599 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 22 Dec 2025 16:34:51 +0530 Subject: [PATCH 679/792] add new column in anc visit (Amm-2039) --- src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java | 6 ++++++ src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java index c5240d1c..4128f082 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ANCVisit.java @@ -167,6 +167,12 @@ public class ANCVisit { @Column(name = "date_of_sterilisation") private Timestamp dateSterilisation; + @Column (name = "place_of_anc") + private String placeOfAnc; + + @Column(name = "place_of_ancId") + private Integer placeOfAncId; + diff --git a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java index f028655f..b4cf0033 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ANCVisitDTO.java @@ -63,6 +63,8 @@ public class ANCVisitDTO { private Timestamp visitDate; private Timestamp dateSterilisation; private Boolean isYesOrNo; + private String placeOfAnc; + private Integer placeOfAncId; } From 1d65ac9d2e64ad4270b2d07fefe43151a800fef8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 23 Dec 2025 14:03:57 +0530 Subject: [PATCH 680/792] Household Soft-delete Option functionality --- .../com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java index 9ab4f822..1a53e8d1 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java @@ -325,4 +325,8 @@ public class RMNCHHouseHoldDetails { @Column(name = "mohallaName") private String mohallaName; + @Expose + @Column(name = "isDeactivate") + private String isDeactivate; + } From 128578bf0ed5019e957db40f15bcfa792a8191e1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 23 Dec 2025 17:58:32 +0530 Subject: [PATCH 681/792] change data type of isDeactivate --- .../com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java index 1a53e8d1..3a3ccec8 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java @@ -327,6 +327,6 @@ public class RMNCHHouseHoldDetails { @Expose @Column(name = "isDeactivate") - private String isDeactivate; + private Boolean isDeactivate; } From da327ecb13123d169a125f4c6912c9658f4812c8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Tue, 23 Dec 2025 18:02:17 +0530 Subject: [PATCH 682/792] Change isDeactivate type from String to Boolean --- .../com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java index 1a53e8d1..3a3ccec8 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHHouseHoldDetails.java @@ -327,6 +327,6 @@ public class RMNCHHouseHoldDetails { @Expose @Column(name = "isDeactivate") - private String isDeactivate; + private Boolean isDeactivate; } From 4ee69e32057912e8c24efcdf30c42ce2cf771861 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 24 Dec 2025 10:51:42 +0530 Subject: [PATCH 683/792] feature of Anc Counselling question --- .../controller/MaternalHealthController.java | 50 ++++++- .../flw/domain/iemr/AncCounsellingCare.java | 128 ++++++++++++++++++ .../flw/dto/iemr/AncCounsellingCareDTO.java | 16 +++ .../dto/iemr/AncCounsellingCareListDTO.java | 79 +++++++++++ .../flw/repo/iemr/AncCounsellingCareRepo.java | 10 ++ .../flw/service/MaternalHealthService.java | 2 + .../impl/MaternalHealthServiceImpl.java | 69 ++++++++++ 7 files changed, 353 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/AncCounsellingCare.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index e23cc8ed..3c601bb1 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -15,7 +15,6 @@ import io.swagger.v3.oas.annotations.Operation; import jakarta.servlet.http.HttpServletRequest; -import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -141,6 +140,55 @@ public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, return response.toString(); } + @Operation(summary = "save anc visit question") + @RequestMapping(value = { "/ancVisit/question/saveAll" }, method = { RequestMethod.POST }) + public String saveANCVisitQuestion(@RequestBody List ancVisitQuestionsDTOS, + @RequestHeader(value = "Authorization") String Authorization) { + OutputResponse response = new OutputResponse(); + try { + if (ancVisitQuestionsDTOS.size() != 0) { + + logger.info("Saving ANC visits with timestamp : " + new Timestamp(System.currentTimeMillis())); + String s = maternalHealthService.saveANCVisitQuestions(ancVisitQuestionsDTOS,Authorization); + if (s != null) + response.setResponse(s); + else + response.setError(500, "Saving anc data to db failed"); + } else + response.setError(500, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in save ANC visit details : ",e); + + response.setError(500, "Error in save ANC visit details : " + e); + } + return response.toString(); + } + + @Operation(summary = "get anc visit questions") + @RequestMapping(value = { "/ancVisit/questions/getAll" }, method = { RequestMethod.POST }) + public String getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, + @RequestHeader(value = "Authorization") String Authorization) { + OutputResponse response = new OutputResponse(); + try { + if (requestDTO != null) { + logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + + requestDTO); + List result = maternalHealthService.getANCVisits(requestDTO); + Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); + String s = gson.toJson(result); + if (s != null) + response.setResponse(s); + else + response.setError(5000, "No record found"); + } else + response.setError(5000, "Invalid/NULL request obj"); + } catch (Exception e) { + logger.error("Error in Anc visit get data : " + e); + response.setError(5000, "Error in Anc visit get data : " + e); + } + return response.toString(); + } + @Operation(summary = "save Delivery Outcome details") @RequestMapping(value = { "/deliveryOutcome/saveAll" }, method = { RequestMethod.POST }) public String saveDeliveryOutcome(@RequestBody List deliveryOutcomeDTOS, diff --git a/src/main/java/com/iemr/flw/domain/iemr/AncCounsellingCare.java b/src/main/java/com/iemr/flw/domain/iemr/AncCounsellingCare.java new file mode 100644 index 00000000..46737f12 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/AncCounsellingCare.java @@ -0,0 +1,128 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "anc_counselling_care", schema = "db_iemr") +@Data +public class AncCounsellingCare { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "beneficiary_id", nullable = false) + private Long beneficiaryId; + + @Column(name = "visit_date") + private LocalDate visitDate; + + @Column(name = "home_visit_date", nullable = false) + private LocalDate homeVisitDate; + + @Column(name = "anc_visit_id", nullable = false) + private Long ancVisitId; + + @Column(name = "user_id") + private Integer userId; + + @Column(name = "created_by") + private String createdBy; + + @Column(name = "updated_by") + private String updatedBy; + + @Column(name = "created_at", updatable = false) + private LocalDateTime createdAt; + + @Column(name = "updated_at") + private LocalDateTime updatedAt; + + /* ---------- BOOLEAN FLAGS ---------- */ + + @Column(name = "select_all") + private Boolean selectAll = false; + + @Column(name = "swelling") + private Boolean swelling = false; + + @Column(name = "high_bp") + private Boolean highBp = false; + + @Column(name = "convulsions") + private Boolean convulsions = false; + + @Column(name = "anemia") + private Boolean anemia = false; + + @Column(name = "reduced_fetal_movement") + private Boolean reducedFetalMovement = false; + + @Column(name = "age_risk") + private Boolean ageRisk = false; + + @Column(name = "child_gap") + private Boolean childGap = false; + + @Column(name = "short_height") + private Boolean shortHeight = false; + + @Column(name = "pre_preg_weight") + private Boolean prePregWeight = false; + + @Column(name = "bleeding") + private Boolean bleeding = false; + + @Column(name = "miscarriage_history") + private Boolean miscarriageHistory = false; + + @Column(name = "four_plus_delivery") + private Boolean fourPlusDelivery = false; + + @Column(name = "first_delivery") + private Boolean firstDelivery = false; + + @Column(name = "twin_pregnancy") + private Boolean twinPregnancy = false; + + @Column(name = "c_section_history") + private Boolean cSectionHistory = false; + + @Column(name = "pre_existing_disease") + private Boolean preExistingDisease = false; + + @Column(name = "fever_malaria") + private Boolean feverMalaria = false; + + @Column(name = "jaundice") + private Boolean jaundice = false; + + @Column(name = "sickle_cell") + private Boolean sickleCell = false; + + @Column(name = "prolonged_labor") + private Boolean prolongedLabor = false; + + @Column(name = "malpresentation") + private Boolean malpresentation = false; + + /* ---------- Lifecycle Hooks ---------- */ + + @PrePersist + protected void onCreate() { + this.createdAt = LocalDateTime.now(); + this.updatedAt = LocalDateTime.now(); + } + + @PreUpdate + protected void onUpdate() { + this.updatedAt = LocalDateTime.now(); + } + + /* ---------- Getters & Setters ---------- */ + // Lombok use kar raha ho toh @Getter @Setter laga sakta hai +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java new file mode 100644 index 00000000..04693322 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class AncCounsellingCareDTO { + private String formId; + private Long ancVisitId; + private Long beneficiaryId; + private String visitDate; + private AncCounsellingCareListDTO fields; + +} + + + diff --git a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java new file mode 100644 index 00000000..f73443d7 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java @@ -0,0 +1,79 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +@Data +public class AncCounsellingCareListDTO { + + @SerializedName("home_visit_date") + private String homeVisitDate; + + @SerializedName("select_all") + private String selectAll; + + @SerializedName("swelling") + private String swelling; + + @SerializedName("high_bp") + private String highBp; + + @SerializedName("convulsions") + private String convulsions; + + @SerializedName("anemia") + private String anemia; + + @SerializedName("reduced_fetal_movement") + private String reducedFetalMovement; + + @SerializedName("age_risk") + private String ageRisk; + + @SerializedName("child_gap") + private String childGap; + + @SerializedName("short_height") + private String shortHeight; + + @SerializedName("pre_preg_weight") + private String prePregWeight; + + @SerializedName("bleeding") + private String bleeding; + + @SerializedName("miscarriage_history") + private String miscarriageHistory; + + @SerializedName("four_plus_delivery") + private String fourPlusDelivery; + + @SerializedName("first_delivery") + private String firstDelivery; + + @SerializedName("twin_pregnancy") + private String twinPregnancy; + + @SerializedName("c_section_history") + private String cSectionHistory; + + @SerializedName("pre_existing_disease") + private String preExistingDisease; + + @SerializedName("fever_malaria") + private String feverMalaria; + + @SerializedName("jaundice") + private String jaundice; + + @SerializedName("sickle_cell") + private String sickleCell; + + @SerializedName("prolonged_labor") + private String prolongedLabor; + + @SerializedName("malpresentation") + private String malpresentation; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java new file mode 100644 index 00000000..6d9349b1 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.AncCare; +import com.iemr.flw.domain.iemr.AncCounsellingCare; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface AncCounsellingCareRepo extends JpaRepository { +} diff --git a/src/main/java/com/iemr/flw/service/MaternalHealthService.java b/src/main/java/com/iemr/flw/service/MaternalHealthService.java index c4af2768..e5081303 100644 --- a/src/main/java/com/iemr/flw/service/MaternalHealthService.java +++ b/src/main/java/com/iemr/flw/service/MaternalHealthService.java @@ -2,6 +2,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.utils.exception.IEMRException; import org.springframework.stereotype.Component; import java.util.List; @@ -25,4 +26,5 @@ public interface MaternalHealthService { String savePNCVisit(List pncVisitDTOs); + String saveANCVisitQuestions(List ancVisitQuestionsDTOS, String authorization) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 53ba1d28..9ba33c02 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -8,6 +8,8 @@ import com.iemr.flw.repo.identity.BeneficiaryRepo; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.MaternalHealthService; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.exception.IEMRException; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,6 +19,7 @@ import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; @@ -58,6 +61,9 @@ public class MaternalHealthServiceImpl implements MaternalHealthService { @Autowired private IncentiveRecordRepo recordRepo; + @Autowired + private JwtUtil jwtUtil; + ObjectMapper mapper = new ObjectMapper(); @@ -67,6 +73,9 @@ public class MaternalHealthServiceImpl implements MaternalHealthService { @Autowired private SMSServiceImpl smsServiceImpl; + @Autowired + private AncCounsellingCareRepo ancCounsellingCareRepo; + public static final List PNC_PERIODS = Arrays.asList("1st Day", "3rd Day", "7th Day", "14th Day", "21st Day", "28th Day", "42nd Day"); @@ -357,6 +366,66 @@ public String savePNCVisit(List pncVisitDTOs) { return null; } + @Override + public String saveANCVisitQuestions(List dtos, String authorization) throws IEMRException { + + List entities = new ArrayList<>(); + + for (AncCounsellingCareDTO dto : dtos) { + + AncCounsellingCare entity = new AncCounsellingCare(); + + entity.setBeneficiaryId(dto.getBeneficiaryId()); + entity.setAncVisitId(dto.getAncVisitId()); + + entity.setHomeVisitDate( + LocalDate.parse(dto.getVisitDate(), DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ); + AncCounsellingCareListDTO fields = dto.getFields(); + + entity.setHomeVisitDate( + LocalDate.parse(fields.getHomeVisitDate(), DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ); + + entity.setSelectAll(yesNoToBoolean(fields.getSelectAll())); + + entity.setSwelling(yesNoToBoolean(fields.getSwelling())); + entity.setHighBp(yesNoToBoolean(fields.getHighBp())); + entity.setConvulsions(yesNoToBoolean(fields.getConvulsions())); + entity.setAnemia(yesNoToBoolean(fields.getAnemia())); + entity.setReducedFetalMovement(yesNoToBoolean(fields.getReducedFetalMovement())); + entity.setAgeRisk(yesNoToBoolean(fields.getAgeRisk())); + entity.setChildGap(yesNoToBoolean(fields.getChildGap())); + entity.setUserId(jwtUtil.extractUserId(authorization)); + entity.setCreatedBy(jwtUtil.extractUsername(authorization)); + entity.setUpdatedBy(jwtUtil.extractUsername(authorization)); + entity.setShortHeight(yesNoToBoolean(fields.getShortHeight())); + entity.setPrePregWeight(yesNoToBoolean(fields.getPrePregWeight())); + entity.setBleeding(yesNoToBoolean(fields.getBleeding())); + entity.setMiscarriageHistory(yesNoToBoolean(fields.getMiscarriageHistory())); + entity.setFourPlusDelivery(yesNoToBoolean(fields.getFourPlusDelivery())); + entity.setFirstDelivery(yesNoToBoolean(fields.getFirstDelivery())); + entity.setTwinPregnancy(yesNoToBoolean(fields.getTwinPregnancy())); + entity.setCSectionHistory(yesNoToBoolean(fields.getCSectionHistory())); + entity.setPreExistingDisease(yesNoToBoolean(fields.getPreExistingDisease())); + entity.setFeverMalaria(yesNoToBoolean(fields.getFeverMalaria())); + entity.setJaundice(yesNoToBoolean(fields.getJaundice())); + entity.setSickleCell(yesNoToBoolean(fields.getSickleCell())); + entity.setProlongedLabor(yesNoToBoolean(fields.getProlongedLabor())); + entity.setMalpresentation(yesNoToBoolean(fields.getMalpresentation())); + + entities.add(entity); + } + + ancCounsellingCareRepo.saveAll(entities); + + return "ANC Counselling & Care data saved successfully"; + } + private Boolean yesNoToBoolean(String value) { + return "Yes".equalsIgnoreCase(value); + } + + private void checkAndAddAntaraIncentive(List recordList, PNCVisit ect) { Integer userId = userRepo.getUserIdByName(ect.getCreatedBy()); logger.info("ContraceptionMethod:" + ect.getContraceptionMethod()); From 8a5174dbebf1580429b0e2158a54815f3e2b1be7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 24 Dec 2025 11:48:36 +0530 Subject: [PATCH 684/792] feature of Anc Counselling getAll api --- .../controller/MaternalHealthController.java | 6 +- .../flw/repo/iemr/AncCounsellingCareRepo.java | 3 + .../flw/service/MaternalHealthService.java | 2 + .../impl/MaternalHealthServiceImpl.java | 57 +++++++++++++++++++ 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 3c601bb1..f0859890 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -141,7 +141,7 @@ public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, } @Operation(summary = "save anc visit question") - @RequestMapping(value = { "/ancVisit/question/saveAll" }, method = { RequestMethod.POST }) + @RequestMapping(value = { "/ancVisit/counselling/saveAll" }, method = { RequestMethod.POST }) public String saveANCVisitQuestion(@RequestBody List ancVisitQuestionsDTOS, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); @@ -165,7 +165,7 @@ public String saveANCVisitQuestion(@RequestBody List ancV } @Operation(summary = "get anc visit questions") - @RequestMapping(value = { "/ancVisit/questions/getAll" }, method = { RequestMethod.POST }) + @RequestMapping(value = { "/ancVisit/counselling/getAll" }, method = { RequestMethod.POST }) public String getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "Authorization") String Authorization) { OutputResponse response = new OutputResponse(); @@ -173,7 +173,7 @@ public String getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, if (requestDTO != null) { logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " + requestDTO); - List result = maternalHealthService.getANCVisits(requestDTO); + List result = maternalHealthService.getANCCounselling(requestDTO); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); String s = gson.toJson(result); if (s != null) diff --git a/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java b/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java index 6d9349b1..714dae59 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/AncCounsellingCareRepo.java @@ -5,6 +5,9 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface AncCounsellingCareRepo extends JpaRepository { + List findAllByUserId(Integer userId); } diff --git a/src/main/java/com/iemr/flw/service/MaternalHealthService.java b/src/main/java/com/iemr/flw/service/MaternalHealthService.java index e5081303..dae0e4eb 100644 --- a/src/main/java/com/iemr/flw/service/MaternalHealthService.java +++ b/src/main/java/com/iemr/flw/service/MaternalHealthService.java @@ -27,4 +27,6 @@ public interface MaternalHealthService { String savePNCVisit(List pncVisitDTOs); String saveANCVisitQuestions(List ancVisitQuestionsDTOS, String authorization) throws IEMRException; + + List getANCCounselling(GetBenRequestHandler requestDTO); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 9ba33c02..b9375b6b 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -421,6 +421,63 @@ public String saveANCVisitQuestions(List dtos, String aut return "ANC Counselling & Care data saved successfully"; } + + @Override + public List getANCCounselling(GetBenRequestHandler requestDTO) { + + List entities = + ancCounsellingCareRepo.findAllByUserId(requestDTO.getUserId()); + + List response = new ArrayList<>(); + + for (AncCounsellingCare entity : entities) { + + AncCounsellingCareListDTO fields = new AncCounsellingCareListDTO(); + + fields.setHomeVisitDate(entity.getHomeVisitDate().toString()); + fields.setSelectAll(booleanToYesNo(entity.getSelectAll())); + fields.setSwelling(booleanToYesNo(entity.getSwelling())); + fields.setHighBp(booleanToYesNo(entity.getHighBp())); + fields.setConvulsions(booleanToYesNo(entity.getConvulsions())); + fields.setAnemia(booleanToYesNo(entity.getAnemia())); + fields.setReducedFetalMovement(booleanToYesNo(entity.getReducedFetalMovement())); + fields.setAgeRisk(booleanToYesNo(entity.getAgeRisk())); + fields.setChildGap(booleanToYesNo(entity.getChildGap())); + + fields.setShortHeight(booleanToYesNo(entity.getShortHeight())); + fields.setPrePregWeight(booleanToYesNo(entity.getPrePregWeight())); + fields.setBleeding(booleanToYesNo(entity.getBleeding())); + fields.setMiscarriageHistory(booleanToYesNo(entity.getMiscarriageHistory())); + fields.setFourPlusDelivery(booleanToYesNo(entity.getFourPlusDelivery())); + fields.setFirstDelivery(booleanToYesNo(entity.getFirstDelivery())); + fields.setTwinPregnancy(booleanToYesNo(entity.getTwinPregnancy())); + fields.setCSectionHistory(booleanToYesNo(entity.getCSectionHistory())); + fields.setPreExistingDisease(booleanToYesNo(entity.getPreExistingDisease())); + fields.setFeverMalaria(booleanToYesNo(entity.getFeverMalaria())); + fields.setJaundice(booleanToYesNo(entity.getJaundice())); + fields.setSickleCell(booleanToYesNo(entity.getSickleCell())); + fields.setProlongedLabor(booleanToYesNo(entity.getProlongedLabor())); + fields.setMalpresentation(booleanToYesNo(entity.getMalpresentation())); + + AncCounsellingCareDTO dto = new AncCounsellingCareDTO(); + dto.setFormId("anc_form_001"); + dto.setAncVisitId(entity.getAncVisitId()); + dto.setBeneficiaryId(entity.getBeneficiaryId()); + dto.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); + dto.setFields(fields); + + response.add(dto); + } + + return response; + } + + private String booleanToYesNo(Boolean value) { + return Boolean.TRUE.equals(value) ? "Yes" : "No"; + } + + + private Boolean yesNoToBoolean(String value) { return "Yes".equalsIgnoreCase(value); } From 8aea9eaf471f23398f37d081804f94aa2a2732ac Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 24 Dec 2025 11:51:34 +0530 Subject: [PATCH 685/792] fix error code --- .../com/iemr/flw/controller/MaternalHealthController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index f0859890..c87595fb 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -179,12 +179,12 @@ public String getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in Anc visit get data : " + e); - response.setError(5000, "Error in Anc visit get data : " + e); + response.setError(500, "Error in Anc visit get data : " + e); } return response.toString(); } From c220538b6bbdd042c6850bb3d727bb5483f3d5a8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 29 Dec 2025 14:04:44 +0530 Subject: [PATCH 686/792] add soft delete key --- .../com/iemr/flw/service/impl/BeneficiaryServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 510d4b53..759edfb4 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -405,6 +405,13 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("isMarried", benDetailsRMNCH_OBJ.getIsMarried()); resultMap.put("doYouHavechildren", benDetailsRMNCH_OBJ.getDoYouHavechildren()); resultMap.put("noofAlivechildren ",benDetailsRMNCH_OBJ.getNoofAlivechildren()); + if(houseHoldRepo.getByHouseHoldID(benDetailsRMNCH_OBJ.getHouseoldId())!=null){ + resultMap.put("isDeactivate",true); + + }else { + resultMap.put("isDeactivate",false); + + } From af518c863fe1a0fbc74793f103391962598cf33b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 16:24:24 +0530 Subject: [PATCH 687/792] remove anc visit id --- src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java | 1 - .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java index 04693322..76aff81d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareDTO.java @@ -5,7 +5,6 @@ @Data public class AncCounsellingCareDTO { private String formId; - private Long ancVisitId; private Long beneficiaryId; private String visitDate; private AncCounsellingCareListDTO fields; diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index b9375b6b..87e3d446 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -376,7 +376,7 @@ public String saveANCVisitQuestions(List dtos, String aut AncCounsellingCare entity = new AncCounsellingCare(); entity.setBeneficiaryId(dto.getBeneficiaryId()); - entity.setAncVisitId(dto.getAncVisitId()); + entity.setAncVisitId(0L); entity.setHomeVisitDate( LocalDate.parse(dto.getVisitDate(), DateTimeFormatter.ofPattern("dd-MM-yyyy")) @@ -461,7 +461,6 @@ public List getANCCounselling(GetBenRequestHandler reques AncCounsellingCareDTO dto = new AncCounsellingCareDTO(); dto.setFormId("anc_form_001"); - dto.setAncVisitId(entity.getAncVisitId()); dto.setBeneficiaryId(entity.getBeneficiaryId()); dto.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); dto.setFields(fields); From 86665e632c5639fa089ffe0b8e9b54207190f778 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 16:50:31 +0530 Subject: [PATCH 688/792] add jwt token in header --- .../java/com/iemr/flw/controller/MaternalHealthController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index c87595fb..114201fb 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -143,7 +143,7 @@ public String getANCVisitDetails(@RequestBody GetBenRequestHandler requestDTO, @Operation(summary = "save anc visit question") @RequestMapping(value = { "/ancVisit/counselling/saveAll" }, method = { RequestMethod.POST }) public String saveANCVisitQuestion(@RequestBody List ancVisitQuestionsDTOS, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "JwtToken") String Authorization) { OutputResponse response = new OutputResponse(); try { if (ancVisitQuestionsDTOS.size() != 0) { From a6bca15135b3d298283aca890c3dfad3c64e3d0e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 17:00:39 +0530 Subject: [PATCH 689/792] fix null pomiter issue --- .../impl/MaternalHealthServiceImpl.java | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 87e3d446..95eea2e4 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.StringUtils; import java.sql.Timestamp; import java.time.LocalDate; @@ -369,6 +370,8 @@ public String savePNCVisit(List pncVisitDTOs) { @Override public String saveANCVisitQuestions(List dtos, String authorization) throws IEMRException { + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); + List entities = new ArrayList<>(); for (AncCounsellingCareDTO dto : dtos) { @@ -378,17 +381,28 @@ public String saveANCVisitQuestions(List dtos, String aut entity.setBeneficiaryId(dto.getBeneficiaryId()); entity.setAncVisitId(0L); - entity.setHomeVisitDate( - LocalDate.parse(dto.getVisitDate(), DateTimeFormatter.ofPattern("dd-MM-yyyy")) - ); + // ✅ visitDate (DTO level) + if (StringUtils.hasText(dto.getVisitDate())) { + entity.setVisitDate( + LocalDate.parse(dto.getVisitDate(), formatter) + ); + } else { + throw new IllegalArgumentException("visitDate is mandatory"); + } + AncCounsellingCareListDTO fields = dto.getFields(); + if (fields == null) { + throw new IllegalArgumentException("fields object is missing"); + } - entity.setHomeVisitDate( - LocalDate.parse(fields.getHomeVisitDate(), DateTimeFormatter.ofPattern("dd-MM-yyyy")) - ); + // ✅ homeVisitDate (fields level) + if (StringUtils.hasText(fields.getHomeVisitDate())) { + entity.setHomeVisitDate( + LocalDate.parse(fields.getHomeVisitDate(), formatter) + ); + } entity.setSelectAll(yesNoToBoolean(fields.getSelectAll())); - entity.setSwelling(yesNoToBoolean(fields.getSwelling())); entity.setHighBp(yesNoToBoolean(fields.getHighBp())); entity.setConvulsions(yesNoToBoolean(fields.getConvulsions())); @@ -396,9 +410,6 @@ public String saveANCVisitQuestions(List dtos, String aut entity.setReducedFetalMovement(yesNoToBoolean(fields.getReducedFetalMovement())); entity.setAgeRisk(yesNoToBoolean(fields.getAgeRisk())); entity.setChildGap(yesNoToBoolean(fields.getChildGap())); - entity.setUserId(jwtUtil.extractUserId(authorization)); - entity.setCreatedBy(jwtUtil.extractUsername(authorization)); - entity.setUpdatedBy(jwtUtil.extractUsername(authorization)); entity.setShortHeight(yesNoToBoolean(fields.getShortHeight())); entity.setPrePregWeight(yesNoToBoolean(fields.getPrePregWeight())); entity.setBleeding(yesNoToBoolean(fields.getBleeding())); @@ -414,12 +425,16 @@ public String saveANCVisitQuestions(List dtos, String aut entity.setProlongedLabor(yesNoToBoolean(fields.getProlongedLabor())); entity.setMalpresentation(yesNoToBoolean(fields.getMalpresentation())); + entity.setUserId(jwtUtil.extractUserId(authorization)); + entity.setCreatedBy(jwtUtil.extractUsername(authorization)); + entity.setUpdatedBy(jwtUtil.extractUsername(authorization)); + entities.add(entity); } ancCounsellingCareRepo.saveAll(entities); - return "ANC Counselling & Care data saved successfully"; + } @Override From 23fac7ed0d2ed0770e483d3c73e01e1d10dbc4a6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 17:31:36 +0530 Subject: [PATCH 690/792] fix null pomiter issue --- .../impl/MaternalHealthServiceImpl.java | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index 95eea2e4..d8c78e08 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -10,6 +10,7 @@ import com.iemr.flw.service.MaternalHealthService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.exception.IEMRException; +import jakarta.transaction.Transactional; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,6 +22,7 @@ import java.time.LocalDate; import java.time.LocalTime; import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; import java.util.*; import java.util.stream.Collectors; @@ -368,40 +370,45 @@ public String savePNCVisit(List pncVisitDTOs) { } @Override + @Transactional public String saveANCVisitQuestions(List dtos, String authorization) throws IEMRException { DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); - List entities = new ArrayList<>(); for (AncCounsellingCareDTO dto : dtos) { - AncCounsellingCare entity = new AncCounsellingCare(); - - entity.setBeneficiaryId(dto.getBeneficiaryId()); - entity.setAncVisitId(0L); - - // ✅ visitDate (DTO level) - if (StringUtils.hasText(dto.getVisitDate())) { - entity.setVisitDate( - LocalDate.parse(dto.getVisitDate(), formatter) - ); - } else { + if (!StringUtils.hasText(dto.getVisitDate())) { throw new IllegalArgumentException("visitDate is mandatory"); } AncCounsellingCareListDTO fields = dto.getFields(); if (fields == null) { - throw new IllegalArgumentException("fields object is missing"); + throw new IllegalArgumentException("fields object is mandatory"); + } + + LocalDate visitDate; + try { + visitDate = LocalDate.parse(dto.getVisitDate(), formatter); + } catch (DateTimeParseException e) { + throw new IllegalArgumentException("Invalid visitDate format, expected dd-MM-yyyy"); } - // ✅ homeVisitDate (fields level) - if (StringUtils.hasText(fields.getHomeVisitDate())) { - entity.setHomeVisitDate( - LocalDate.parse(fields.getHomeVisitDate(), formatter) - ); + LocalDate homeVisitDate; + try { + homeVisitDate = StringUtils.hasText(fields.getHomeVisitDate()) + ? LocalDate.parse(fields.getHomeVisitDate(), formatter) + : visitDate; // ✅ fallback + } catch (DateTimeParseException e) { + throw new IllegalArgumentException("Invalid home_visit_date format, expected dd-MM-yyyy"); } + AncCounsellingCare entity = new AncCounsellingCare(); + entity.setBeneficiaryId(dto.getBeneficiaryId()); + entity.setAncVisitId(0L); + entity.setVisitDate(visitDate); + entity.setHomeVisitDate(homeVisitDate); + entity.setSelectAll(yesNoToBoolean(fields.getSelectAll())); entity.setSwelling(yesNoToBoolean(fields.getSwelling())); entity.setHighBp(yesNoToBoolean(fields.getHighBp())); @@ -434,9 +441,9 @@ public String saveANCVisitQuestions(List dtos, String aut ancCounsellingCareRepo.saveAll(entities); return "ANC Counselling & Care data saved successfully"; - } + @Override public List getANCCounselling(GetBenRequestHandler requestDTO) { From dd418de4aafb454a3455f5a2696e34dbe0b0b18d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 18:17:39 +0530 Subject: [PATCH 691/792] fix response issue --- .../controller/MaternalHealthController.java | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 114201fb..5b74b572 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -18,6 +18,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.sql.Timestamp; @@ -90,6 +92,7 @@ public String getPregnantWomanList(@RequestBody GetBenRequestHandler requestDTO, response.setError(5000, "Error in pregnant woman get data : " + e); } return response.toString(); + } @Operation(summary = "save anc visit details") @@ -166,27 +169,39 @@ public String saveANCVisitQuestion(@RequestBody List ancV @Operation(summary = "get anc visit questions") @RequestMapping(value = { "/ancVisit/counselling/getAll" }, method = { RequestMethod.POST }) - public String getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, - @RequestHeader(value = "Authorization") String Authorization) { - OutputResponse response = new OutputResponse(); + public ResponseEntity>> getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, + @RequestHeader(value = "JwtToken") String Authorization) { + StandardResponse> response = new StandardResponse<>(); + try { if (requestDTO != null) { - logger.info("request object with timestamp : " + new Timestamp(System.currentTimeMillis()) + " " - + requestDTO); + logger.info("Request: " + requestDTO); + List result = maternalHealthService.getANCCounselling(requestDTO); - Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); - String s = gson.toJson(result); - if (s != null) - response.setResponse(s); - else - response.setError(500, "No record found"); - } else - response.setError(500, "Invalid/NULL request obj"); + + response.setStatusCode(200); + response.setStatus("Success"); + response.setErrorMessage("Success"); + response.setData(result); + + return ResponseEntity.ok(response); + + } else { + response.setStatusCode(400); + response.setStatus("Failed"); + response.setErrorMessage("Invalid request object"); + response.setData(null); + return ResponseEntity.badRequest().body(response); + } } catch (Exception e) { - logger.error("Error in Anc visit get data : " + e); - response.setError(500, "Error in Anc visit get data : " + e); + logger.error("Exception in fetching HBNC visits", e); + + response.setStatusCode(500); + response.setStatus("Failed"); + response.setErrorMessage("Internal Server Error: " + e.getMessage()); + response.setData(null); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } - return response.toString(); } @Operation(summary = "save Delivery Outcome details") @@ -211,6 +226,7 @@ public String saveDeliveryOutcome(@RequestBody List delivery response.setError(5000, "Error in save delivery outcome details : " + e); } return response.toString(); + } @Operation(summary = "get Delivery Outcome details") From 9f67b3f3b376155237edb53d178382d1c7dc84db Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 30 Dec 2025 18:20:28 +0530 Subject: [PATCH 692/792] fix response issue --- .../com/iemr/flw/service/impl/MaternalHealthServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index d8c78e08..ad577572 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -448,7 +448,7 @@ public String saveANCVisitQuestions(List dtos, String aut public List getANCCounselling(GetBenRequestHandler requestDTO) { List entities = - ancCounsellingCareRepo.findAllByUserId(requestDTO.getUserId()); + ancCounsellingCareRepo.findAllByUserId(requestDTO.getAshaId()); List response = new ArrayList<>(); From 552ce35bca0d55d34f56300ce784bbc7734cc6d1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 31 Dec 2025 08:20:10 +0530 Subject: [PATCH 693/792] fix response of get api --- .../controller/MaternalHealthController.java | 6 +- .../dto/iemr/AncCounsellingCareListDTO.java | 92 +++++++++---------- .../iemr/AncCounsellingCareResponseDTO.java | 17 ++++ .../flw/service/MaternalHealthService.java | 2 +- .../impl/MaternalHealthServiceImpl.java | 83 +++++++++-------- 5 files changed, 113 insertions(+), 87 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java index 5b74b572..e65eacda 100644 --- a/src/main/java/com/iemr/flw/controller/MaternalHealthController.java +++ b/src/main/java/com/iemr/flw/controller/MaternalHealthController.java @@ -169,15 +169,15 @@ public String saveANCVisitQuestion(@RequestBody List ancV @Operation(summary = "get anc visit questions") @RequestMapping(value = { "/ancVisit/counselling/getAll" }, method = { RequestMethod.POST }) - public ResponseEntity>> getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, + public ResponseEntity>> getANCVisitQuestion(@RequestBody GetBenRequestHandler requestDTO, @RequestHeader(value = "JwtToken") String Authorization) { - StandardResponse> response = new StandardResponse<>(); + StandardResponse> response = new StandardResponse<>(); try { if (requestDTO != null) { logger.info("Request: " + requestDTO); - List result = maternalHealthService.getANCCounselling(requestDTO); + List result = maternalHealthService.getANCCounselling(requestDTO); response.setStatusCode(200); response.setStatus("Success"); diff --git a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java index f73443d7..981e34e2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareListDTO.java @@ -6,74 +6,74 @@ @Data public class AncCounsellingCareListDTO { - @SerializedName("home_visit_date") - private String homeVisitDate; + @SerializedName("home_visit_date") + private String homeVisitDate; - @SerializedName("select_all") - private String selectAll; + @SerializedName("select_all") + private String selectAll; - @SerializedName("swelling") - private String swelling; + @SerializedName("swelling") + private String swelling; - @SerializedName("high_bp") - private String highBp; + @SerializedName("high_bp") + private String highBp; - @SerializedName("convulsions") - private String convulsions; + @SerializedName("convulsions") + private String convulsions; - @SerializedName("anemia") - private String anemia; + @SerializedName("anemia") + private String anemia; - @SerializedName("reduced_fetal_movement") - private String reducedFetalMovement; + @SerializedName("reduced_fetal_movement") + private String reducedFetalMovement; - @SerializedName("age_risk") - private String ageRisk; + @SerializedName("age_risk") + private String ageRisk; - @SerializedName("child_gap") - private String childGap; + @SerializedName("child_gap") + private String childGap; - @SerializedName("short_height") - private String shortHeight; + @SerializedName("short_height") + private String shortHeight; - @SerializedName("pre_preg_weight") - private String prePregWeight; + @SerializedName("pre_preg_weight") + private String prePregWeight; - @SerializedName("bleeding") - private String bleeding; + @SerializedName("bleeding") + private String bleeding; - @SerializedName("miscarriage_history") - private String miscarriageHistory; + @SerializedName("miscarriage_history") + private String miscarriageHistory; - @SerializedName("four_plus_delivery") - private String fourPlusDelivery; + @SerializedName("four_plus_delivery") + private String fourPlusDelivery; - @SerializedName("first_delivery") - private String firstDelivery; + @SerializedName("first_delivery") + private String firstDelivery; - @SerializedName("twin_pregnancy") - private String twinPregnancy; + @SerializedName("twin_pregnancy") + private String twinPregnancy; - @SerializedName("c_section_history") - private String cSectionHistory; + @SerializedName("c_section_history") + private String cSectionHistory; - @SerializedName("pre_existing_disease") - private String preExistingDisease; + @SerializedName("pre_existing_disease") + private String preExistingDisease; - @SerializedName("fever_malaria") - private String feverMalaria; + @SerializedName("fever_malaria") + private String feverMalaria; - @SerializedName("jaundice") - private String jaundice; + @SerializedName("jaundice") + private String jaundice; - @SerializedName("sickle_cell") - private String sickleCell; + @SerializedName("sickle_cell") + private String sickleCell; - @SerializedName("prolonged_labor") - private String prolongedLabor; + @SerializedName("prolonged_labor") + private String prolongedLabor; - @SerializedName("malpresentation") - private String malpresentation; + @SerializedName("malpresentation") + private String malpresentation; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareResponseDTO.java new file mode 100644 index 00000000..2e019558 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/AncCounsellingCareResponseDTO.java @@ -0,0 +1,17 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.util.Map; + +@Data +public class AncCounsellingCareResponseDTO { + private String formId; + private Long beneficiaryId; + private String visitDate; + private Map fields; // for dynamic form fields + +} + + + diff --git a/src/main/java/com/iemr/flw/service/MaternalHealthService.java b/src/main/java/com/iemr/flw/service/MaternalHealthService.java index dae0e4eb..33de9bc9 100644 --- a/src/main/java/com/iemr/flw/service/MaternalHealthService.java +++ b/src/main/java/com/iemr/flw/service/MaternalHealthService.java @@ -28,5 +28,5 @@ public interface MaternalHealthService { String saveANCVisitQuestions(List ancVisitQuestionsDTOS, String authorization) throws IEMRException; - List getANCCounselling(GetBenRequestHandler requestDTO); + List getANCCounselling(GetBenRequestHandler requestDTO); } diff --git a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java index ad577572..8914941f 100644 --- a/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MaternalHealthServiceImpl.java @@ -445,52 +445,61 @@ public String saveANCVisitQuestions(List dtos, String aut @Override - public List getANCCounselling(GetBenRequestHandler requestDTO) { + public List getANCCounselling(GetBenRequestHandler requestDTO) { List entities = ancCounsellingCareRepo.findAllByUserId(requestDTO.getAshaId()); - List response = new ArrayList<>(); + List responseDTOList = new ArrayList<>(); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); for (AncCounsellingCare entity : entities) { - AncCounsellingCareListDTO fields = new AncCounsellingCareListDTO(); - - fields.setHomeVisitDate(entity.getHomeVisitDate().toString()); - fields.setSelectAll(booleanToYesNo(entity.getSelectAll())); - fields.setSwelling(booleanToYesNo(entity.getSwelling())); - fields.setHighBp(booleanToYesNo(entity.getHighBp())); - fields.setConvulsions(booleanToYesNo(entity.getConvulsions())); - fields.setAnemia(booleanToYesNo(entity.getAnemia())); - fields.setReducedFetalMovement(booleanToYesNo(entity.getReducedFetalMovement())); - fields.setAgeRisk(booleanToYesNo(entity.getAgeRisk())); - fields.setChildGap(booleanToYesNo(entity.getChildGap())); - - fields.setShortHeight(booleanToYesNo(entity.getShortHeight())); - fields.setPrePregWeight(booleanToYesNo(entity.getPrePregWeight())); - fields.setBleeding(booleanToYesNo(entity.getBleeding())); - fields.setMiscarriageHistory(booleanToYesNo(entity.getMiscarriageHistory())); - fields.setFourPlusDelivery(booleanToYesNo(entity.getFourPlusDelivery())); - fields.setFirstDelivery(booleanToYesNo(entity.getFirstDelivery())); - fields.setTwinPregnancy(booleanToYesNo(entity.getTwinPregnancy())); - fields.setCSectionHistory(booleanToYesNo(entity.getCSectionHistory())); - fields.setPreExistingDisease(booleanToYesNo(entity.getPreExistingDisease())); - fields.setFeverMalaria(booleanToYesNo(entity.getFeverMalaria())); - fields.setJaundice(booleanToYesNo(entity.getJaundice())); - fields.setSickleCell(booleanToYesNo(entity.getSickleCell())); - fields.setProlongedLabor(booleanToYesNo(entity.getProlongedLabor())); - fields.setMalpresentation(booleanToYesNo(entity.getMalpresentation())); - - AncCounsellingCareDTO dto = new AncCounsellingCareDTO(); - dto.setFormId("anc_form_001"); - dto.setBeneficiaryId(entity.getBeneficiaryId()); - dto.setVisitDate(entity.getVisitDate() != null ? entity.getVisitDate().toString() : null); - dto.setFields(fields); - - response.add(dto); + AncCounsellingCareResponseDTO responseDTO = new AncCounsellingCareResponseDTO(); + responseDTO.setFormId("anc_form_001"); + responseDTO.setBeneficiaryId(entity.getBeneficiaryId()); // Update with actual value + responseDTO.setVisitDate(entity.getVisitDate().format(formatter)); // Format visit.getVisitDate() + + // 🔹 fields map + Map fields = new HashMap<>(); + + fields.put("home_visit_date", + entity.getHomeVisitDate() != null + ? entity.getHomeVisitDate().format(formatter) + : null); + + fields.put("select_all", booleanToYesNo(entity.getSelectAll())); + fields.put("swelling", booleanToYesNo(entity.getSwelling())); + fields.put("high_bp", booleanToYesNo(entity.getHighBp())); + fields.put("convulsions", booleanToYesNo(entity.getConvulsions())); + fields.put("anemia", booleanToYesNo(entity.getAnemia())); + fields.put("reduced_fetal_movement", booleanToYesNo(entity.getReducedFetalMovement())); + fields.put("age_risk", booleanToYesNo(entity.getAgeRisk())); + fields.put("child_gap", booleanToYesNo(entity.getChildGap())); + fields.put("short_height", booleanToYesNo(entity.getShortHeight())); + fields.put("pre_preg_weight", booleanToYesNo(entity.getPrePregWeight())); + fields.put("bleeding", booleanToYesNo(entity.getBleeding())); + fields.put("miscarriage_history", booleanToYesNo(entity.getMiscarriageHistory())); + fields.put("four_plus_delivery", booleanToYesNo(entity.getFourPlusDelivery())); + fields.put("first_delivery", booleanToYesNo(entity.getFirstDelivery())); + fields.put("twin_pregnancy", booleanToYesNo(entity.getTwinPregnancy())); + fields.put("c_section_history", booleanToYesNo(entity.getCSectionHistory())); + fields.put("pre_existing_disease", booleanToYesNo(entity.getPreExistingDisease())); + fields.put("fever_malaria", booleanToYesNo(entity.getFeverMalaria())); + fields.put("jaundice", booleanToYesNo(entity.getJaundice())); + fields.put("sickle_cell", booleanToYesNo(entity.getSickleCell())); + fields.put("prolonged_labor", booleanToYesNo(entity.getProlongedLabor())); + fields.put("malpresentation", booleanToYesNo(entity.getMalpresentation())); + + responseDTO.setFields(fields); + responseDTOList.add(responseDTO); + + + + } + return responseDTOList; - return response; } private String booleanToYesNo(Boolean value) { From 52de84cb4d49f7ba301e9d0765a39747df211009 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 5 Jan 2026 15:14:01 +0530 Subject: [PATCH 694/792] Beneficiary Soft-delete. --- .../identity/RMNCHBeneficiaryDetailsRmnch.java | 3 +++ .../flw/service/impl/BeneficiaryServiceImpl.java | 13 ++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java index ac336da1..297694b7 100644 --- a/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java +++ b/src/main/java/com/iemr/flw/domain/identity/RMNCHBeneficiaryDetailsRmnch.java @@ -386,6 +386,9 @@ public class RMNCHBeneficiaryDetailsRmnch { @Expose private Integer noofAlivechildren; + @Expose + private Boolean isDeactivate; + @Expose @Transient private Integer servicePointID; diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index 759edfb4..f5a75785 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -404,17 +404,8 @@ private String getMappingsForAddressIDs(List addressLi resultMap.put("noOfchildren", benDetailsRMNCH_OBJ.getNoOfchildren()); resultMap.put("isMarried", benDetailsRMNCH_OBJ.getIsMarried()); resultMap.put("doYouHavechildren", benDetailsRMNCH_OBJ.getDoYouHavechildren()); - resultMap.put("noofAlivechildren ",benDetailsRMNCH_OBJ.getNoofAlivechildren()); - if(houseHoldRepo.getByHouseHoldID(benDetailsRMNCH_OBJ.getHouseoldId())!=null){ - resultMap.put("isDeactivate",true); - - }else { - resultMap.put("isDeactivate",false); - - } - - - + resultMap.put("noofAlivechildren",benDetailsRMNCH_OBJ.getNoofAlivechildren()); + resultMap.put("isDeactivate",benDetailsRMNCH_OBJ.getIsDeactivate()); resultMap.put("BenRegId", m.getBenRegId()); // adding asha id / created by - user id From bb2f1fe1b8a046e600cdb7963ccc9c5957af04ab Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 6 Jan 2026 15:22:02 +0530 Subject: [PATCH 695/792] cdtf_visit_details AMM-2046 and AMM-2045 --- .../controller/DiseaseControlController.java | 37 ++++++++-- .../iemr/ChronicDiseaseVisitEntity.java | 72 +++++++++++++++++++ .../flw/dto/iemr/ChronicDiseaseVisitDTO.java | 38 ++++++++++ .../iemr/ChronicDiseaseVisitRepository.java | 10 +++ .../flw/service/DiseaseControlService.java | 2 + .../impl/DiseaseControlServiceImpl.java | 46 ++++++++++++ 6 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 2f5d4264..0c225e23 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -34,11 +34,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.HashMap; import java.util.LinkedHashMap; @@ -314,5 +310,36 @@ public ResponseEntity> getAllMobilizationMosquitoNet(@Reques return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } + @RequestMapping(value = "cdtfVisit/saveAll", method = RequestMethod.POST) + public ResponseEntity> saveVisit( + @RequestBody List requestList,@RequestHeader(value = "JwtToken") String token) { + + Map response = new LinkedHashMap<>(); + logger.info("Chronic Disease Visit Save Request: {}", requestList); + + try { + List savedList = + diseaseControlService.saveChronicDiseaseVisit(requestList,token); + + if (savedList != null && !savedList.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("message", "Data saved successfully"); + response.put("data", savedList); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "No data saved"); + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); + } + + } catch (Exception e) { + logger.error("Error saving Chronic Disease Visit :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java b/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java new file mode 100644 index 00000000..c236ffa7 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java @@ -0,0 +1,72 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "cdtf_visit_details") +@Data +public class ChronicDiseaseVisitEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "beneficiary_id") + private Long benId; + + @Column(name = "household_id") + private Long hhId; + + @Column(name = "form_id") + private String formId; + + @Column(name = "version") + private Integer version; + + @Column(name = "visit_no") + private Integer visitNo; + + @Column(name = "follow_up_no") + private Integer followUpNo; + + @Column(name = "diagnosis_codes", columnDefinition = "TEXT") + private String diagnosisCodes; + + @Column(name = "treatment_start_date") + private LocalDate treatmentStartDate; + + @Column(name = "form_data_json", columnDefinition = "JSON") + private String formDataJson; + + @Column(name = "user_id") + private Integer userID; + + @Column(name = "created_by") + private String createdBy; + + @Column(name = "created_date") + private LocalDateTime createdDate; + + @Column(name = "updated_by") + private Integer updatedBy; + + @Column(name = "updated_date") + private LocalDateTime updatedDate; + + // 🔹 Auto timestamps + @PrePersist + protected void onCreate() { + this.createdDate = LocalDateTime.now(); + this.updatedDate = LocalDateTime.now(); + } + + @PreUpdate + protected void onUpdate() { + this.updatedDate = LocalDateTime.now(); + } + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java new file mode 100644 index 00000000..7ec119c4 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java @@ -0,0 +1,38 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +@Data +public class ChronicDiseaseVisitDTO { + + @JsonProperty("id") + private Long id; + + @JsonProperty("benId") + private Long benId; + + @JsonProperty("hhId") + private Long hhId; + + @JsonProperty("formId") + private String formId; + + @JsonProperty("version") + private Integer version; + + @JsonProperty("visitNo") + private Integer visitNo; + + @JsonProperty("followUpNo") + private Integer followUpNo; + + @JsonProperty("diagnosisCodes") + private String diagnosisCodes; + + @JsonProperty("treatmentStartDate") + private String treatmentStartDate; // yyyy-MM-dd + + @JsonProperty("formDataJson") + private String formDataJson; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java b/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java new file mode 100644 index 00000000..dc422710 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java @@ -0,0 +1,10 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.ChronicDiseaseVisitEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ChronicDiseaseVisitRepository + extends JpaRepository { +} diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 92accf4a..08ad1013 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -25,6 +25,7 @@ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.utils.exception.IEMRException; import java.util.List; @@ -44,4 +45,5 @@ public interface DiseaseControlService { public String saveLeprosyFollowUp(LeprosyFollowUpDTO leprosyDTO); List getAllLeprosyFollowUpData(String createdBy); + List saveChronicDiseaseVisit(List requestList,String token) throws IEMRException; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index bc780038..377f50b6 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -31,6 +31,8 @@ import com.iemr.flw.masterEnum.DiseaseType; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.exception.IEMRException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -77,7 +79,11 @@ public class DiseaseControlServiceImpl implements DiseaseControlService { private MosquitoNetRepository mosquitoNetRepository; + @Autowired + private ChronicDiseaseVisitRepository chronicDiseaseVisitRepository; + @Autowired + private JwtUtil jwtUtil; private final Logger logger = LoggerFactory.getLogger(CoupleController.class); @@ -998,4 +1004,44 @@ record = new IncentiveActivityRecord(); } } + + + @Override + public List saveChronicDiseaseVisit( + List requestList,String token) throws IEMRException { + + List responseList = new ArrayList<>(); + + for (ChronicDiseaseVisitDTO dto : requestList) { + + ChronicDiseaseVisitEntity entity = new ChronicDiseaseVisitEntity(); + + entity.setBenId(dto.getBenId()); + entity.setHhId(dto.getHhId()); + entity.setFormId(dto.getFormId()); + entity.setVersion(dto.getVersion()); + entity.setVisitNo(dto.getVisitNo()); + entity.setFollowUpNo(dto.getFollowUpNo()); + entity.setDiagnosisCodes(dto.getDiagnosisCodes()); + entity.setFormDataJson(dto.getFormDataJson()); + entity.setUserID(jwtUtil.extractUserId(token)); + entity.setCreatedBy(jwtUtil.extractUsername(token)); + + + if (dto.getTreatmentStartDate() != null) { + entity.setTreatmentStartDate( + LocalDate.parse(dto.getTreatmentStartDate()) + ); + } + + ChronicDiseaseVisitEntity savedEntity = + chronicDiseaseVisitRepository.save(entity); + + dto.setId(savedEntity.getId()); + responseList.add(dto); + } + + return responseList; + } + } \ No newline at end of file From dd63a8946539e2e64cc74aef4054c7712b8862a7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 6 Jan 2026 15:45:59 +0530 Subject: [PATCH 696/792] cdtf_visit_details get api AMM-2046 and AMM-2045 --- .../controller/DiseaseControlController.java | 27 +++++++++++++++ .../iemr/ChronicDiseaseVisitRepository.java | 4 +++ .../flw/service/DiseaseControlService.java | 3 ++ .../impl/DiseaseControlServiceImpl.java | 34 +++++++++++++++++++ 4 files changed, 68 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 0c225e23..e89a5306 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -340,6 +340,33 @@ public ResponseEntity> saveVisit( } } + @RequestMapping(value = "cdtfVisit/getAll", method = RequestMethod.POST) + public ResponseEntity> getVisitDetails( + @RequestBody GetBenRequestHandler getBenRequestHandler) { + + Map response = new LinkedHashMap<>(); + + try { + List result = + diseaseControlService.getCdtfVisits(getBenRequestHandler); + + if (result != null && !result.isEmpty()) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error fetching Chronic Disease Visit :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java b/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java index dc422710..e63835a9 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/ChronicDiseaseVisitRepository.java @@ -4,7 +4,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import java.util.List; + @Repository public interface ChronicDiseaseVisitRepository extends JpaRepository { + + List findByUserID(Integer ashaId); } diff --git a/src/main/java/com/iemr/flw/service/DiseaseControlService.java b/src/main/java/com/iemr/flw/service/DiseaseControlService.java index 08ad1013..65e315dc 100644 --- a/src/main/java/com/iemr/flw/service/DiseaseControlService.java +++ b/src/main/java/com/iemr/flw/service/DiseaseControlService.java @@ -24,6 +24,7 @@ */ package com.iemr.flw.service; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.utils.exception.IEMRException; @@ -46,4 +47,6 @@ public interface DiseaseControlService { List getAllLeprosyFollowUpData(String createdBy); List saveChronicDiseaseVisit(List requestList,String token) throws IEMRException; + + List getCdtfVisits(GetBenRequestHandler getBenRequestHandler); } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 377f50b6..e26ef5af 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.controller.CoupleController; import com.iemr.flw.domain.iemr.*; +import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.DiseaseType; import com.iemr.flw.repo.iemr.*; @@ -1044,4 +1045,37 @@ public List saveChronicDiseaseVisit( return responseList; } + @Override + public List getCdtfVisits(GetBenRequestHandler getBenRequestHandler) { + + List entityList = chronicDiseaseVisitRepository.findByUserID(getBenRequestHandler.getAshaId()); + + List dtoList = new ArrayList<>(); + + for (ChronicDiseaseVisitEntity entity : entityList) { + + ChronicDiseaseVisitDTO dto = new ChronicDiseaseVisitDTO(); + + dto.setId(entity.getId()); + dto.setBenId(entity.getBenId()); + dto.setHhId(entity.getHhId()); + dto.setFormId(entity.getFormId()); + dto.setVersion(entity.getVersion()); + dto.setVisitNo(entity.getVisitNo()); + dto.setFollowUpNo(entity.getFollowUpNo()); + dto.setDiagnosisCodes(entity.getDiagnosisCodes()); + dto.setFormDataJson(entity.getFormDataJson()); + + if (entity.getTreatmentStartDate() != null) { + dto.setTreatmentStartDate( + entity.getTreatmentStartDate().toString() + ); + } + + dtoList.add(dto); + } + + return dtoList; + } + } \ No newline at end of file From b723320b47b8c43f999c0d937ec1ee8639d26567 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 6 Jan 2026 16:50:41 +0530 Subject: [PATCH 697/792] Add new parameters in leprosy suspected API AMM-2071 --- .../flw/domain/iemr/ScreeningLeprosy.java | 72 +++++++++++++++++++ .../iemr/flw/dto/iemr/DiseaseLeprosyDTO.java | 24 +++++++ .../impl/DiseaseControlServiceImpl.java | 54 ++++++++++++++ 3 files changed, 150 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index 225a1dfc..4efc6dcc 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -143,6 +143,78 @@ public class ScreeningLeprosy { @Column(name = "treatment_status", length = 100) private String treatmentStatus; + @Column(name = "recurrent_ulceration_id") + private Integer recurrentUlcerationId; + + @Column(name = "recurrent_tingling_id") + private Integer recurrentTinglingId; + + @Column(name = "hypopigmented_patch_id") + private Integer hypopigmentedPatchId; + + @Column(name = "thickened_skin_id") + private Integer thickenedSkinId; + + @Column(name = "skin_nodules_id") + private Integer skinNodulesId; + + @Column(name = "skin_patch_discoloration_id") + private Integer skinPatchDiscolorationId; + + @Column(name = "recurrent_numbness_id") + private Integer recurrentNumbnessId; + + @Column(name = "clawing_fingers_id") + private Integer clawingFingersId; + + @Column(name = "tingling_numbness_extremities_id") + private Integer tinglingNumbnessExtremitiesId; + + @Column(name = "inability_close_eyelid_id") + private Integer inabilityCloseEyelidId; + + @Column(name = "difficulty_holding_objects_id") + private Integer difficultyHoldingObjectsId; + + @Column(name = "weakness_feet_id") + private Integer weaknessFeetId; + + @Column(name = "recurrent_ulceration", length = 10) + private String recurrentUlceration; + + @Column(name = "recurrent_tingling", length = 10) + private String recurrentTingling; + + @Column(name = "hypopigmented_patch", length = 50) + private String hypopigmentedPatch; + + @Column(name = "thickened_skin", length = 10) + private String thickenedSkin; + + @Column(name = "skin_nodules", length = 10) + private String skinNodules; + + @Column(name = "skin_patch_discoloration", length = 50) + private String skinPatchDiscoloration; + + @Column(name = "recurrent_numbness", length = 10) + private String recurrentNumbness; + + @Column(name = "clawing_fingers", length = 10) + private String clawingFingers; + + @Column(name = "tingling_numbness_extremities", length = 50) + private String tinglingNumbnessExtremities; + + @Column(name = "inability_close_eyelid", length = 10) + private String inabilityCloseEyelid; + + @Column(name = "difficulty_holding_objects", length = 50) + private String difficultyHoldingObjects; + + @Column(name = "weakness_feet", length = 10) + private String weaknessFeet; + @Column(name = "CreatedBy", length = 100) private String createdBy; diff --git a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java index c0acbe71..47489c54 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DiseaseLeprosyDTO.java @@ -72,4 +72,28 @@ public class DiseaseLeprosyDTO { private Timestamp createdDate; private String modifiedBy; private Timestamp lastModDate; + private Integer recurrentUlcerationId; + private Integer recurrentTinglingId; + private Integer hypopigmentedPatchId; + private Integer thickenedSkinId; + private Integer skinNodulesId; + private Integer skinPatchDiscolorationId; + private Integer recurrentNumbnessId; + private Integer clawingFingersId; + private Integer tinglingNumbnessExtremitiesId; + private Integer inabilityCloseEyelidId; + private Integer difficultyHoldingObjectsId; + private Integer weaknessFeetId; + private String recurrentUlceration; + private String recurrentTingling; + private String hypopigmentedPatch; + private String thickenedSkin; + private String skinNodules; + private String skinPatchDiscoloration; + private String recurrentNumbness; + private String clawingFingers; + private String tinglingNumbnessExtremities; + private String inabilityCloseEyelid; + private String difficultyHoldingObjects; + private String weaknessFeet; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index e26ef5af..3ba522da 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -724,6 +724,33 @@ private ScreeningLeprosy saveLeprosyData(DiseaseLeprosyDTO diseaseControlData) { diseaseLeprosy.setModifiedBy(diseaseControlData.getModifiedBy()); diseaseLeprosy.setLastModDate(diseaseControlData.getLastModDate()); + diseaseLeprosy.setRecurrentUlcerationId(diseaseControlData.getRecurrentUlcerationId()); + diseaseLeprosy.setRecurrentTinglingId(diseaseControlData.getRecurrentTinglingId()); + diseaseLeprosy.setHypopigmentedPatchId(diseaseControlData.getHypopigmentedPatchId()); + diseaseLeprosy.setThickenedSkinId(diseaseControlData.getThickenedSkinId()); + diseaseLeprosy.setSkinNodulesId(diseaseControlData.getSkinNodulesId()); + diseaseLeprosy.setSkinPatchDiscolorationId(diseaseControlData.getSkinPatchDiscolorationId()); + diseaseLeprosy.setRecurrentNumbnessId(diseaseControlData.getRecurrentNumbnessId()); + diseaseLeprosy.setClawingFingersId(diseaseControlData.getClawingFingersId()); + diseaseLeprosy.setTinglingNumbnessExtremitiesId(diseaseControlData.getTinglingNumbnessExtremitiesId()); + diseaseLeprosy.setInabilityCloseEyelidId(diseaseControlData.getInabilityCloseEyelidId()); + diseaseLeprosy.setDifficultyHoldingObjectsId(diseaseControlData.getDifficultyHoldingObjectsId()); + diseaseLeprosy.setWeaknessFeetId(diseaseControlData.getWeaknessFeetId()); + + diseaseLeprosy.setRecurrentUlceration(diseaseControlData.getRecurrentUlceration()); + diseaseLeprosy.setRecurrentTingling(diseaseControlData.getRecurrentTingling()); + diseaseLeprosy.setHypopigmentedPatch(diseaseControlData.getHypopigmentedPatch()); + diseaseLeprosy.setThickenedSkin(diseaseControlData.getThickenedSkin()); + diseaseLeprosy.setSkinNodules(diseaseControlData.getSkinNodules()); + diseaseLeprosy.setSkinPatchDiscoloration(diseaseControlData.getSkinPatchDiscoloration()); + diseaseLeprosy.setRecurrentNumbness(diseaseControlData.getRecurrentNumbness()); + diseaseLeprosy.setClawingFingers(diseaseControlData.getClawingFingers()); + diseaseLeprosy.setTinglingNumbnessExtremities(diseaseControlData.getTinglingNumbnessExtremities()); + diseaseLeprosy.setInabilityCloseEyelid(diseaseControlData.getInabilityCloseEyelid()); + diseaseLeprosy.setDifficultyHoldingObjects(diseaseControlData.getDifficultyHoldingObjects()); + diseaseLeprosy.setWeaknessFeet(diseaseControlData.getWeaknessFeet()); + + return diseaseLeprosy; } @@ -768,6 +795,33 @@ private String updateLeprosyData(DiseaseLeprosyDTO diseaseControlData) { existingDiseaseLeprosy.setModifiedBy(diseaseControlData.getModifiedBy()); existingDiseaseLeprosy.setLastModDate(diseaseControlData.getLastModDate()); + existingDiseaseLeprosy.setRecurrentUlcerationId(diseaseControlData.getRecurrentUlcerationId()); + existingDiseaseLeprosy.setRecurrentTinglingId(diseaseControlData.getRecurrentTinglingId()); + existingDiseaseLeprosy.setHypopigmentedPatchId(diseaseControlData.getHypopigmentedPatchId()); + existingDiseaseLeprosy.setThickenedSkinId(diseaseControlData.getThickenedSkinId()); + existingDiseaseLeprosy.setSkinNodulesId(diseaseControlData.getSkinNodulesId()); + existingDiseaseLeprosy.setSkinPatchDiscolorationId(diseaseControlData.getSkinPatchDiscolorationId()); + existingDiseaseLeprosy.setRecurrentNumbnessId(diseaseControlData.getRecurrentNumbnessId()); + existingDiseaseLeprosy.setClawingFingersId(diseaseControlData.getClawingFingersId()); + existingDiseaseLeprosy.setTinglingNumbnessExtremitiesId(diseaseControlData.getTinglingNumbnessExtremitiesId()); + existingDiseaseLeprosy.setInabilityCloseEyelidId(diseaseControlData.getInabilityCloseEyelidId()); + existingDiseaseLeprosy.setDifficultyHoldingObjectsId(diseaseControlData.getDifficultyHoldingObjectsId()); + existingDiseaseLeprosy.setWeaknessFeetId(diseaseControlData.getWeaknessFeetId()); + + existingDiseaseLeprosy.setRecurrentUlceration(diseaseControlData.getRecurrentUlceration()); + existingDiseaseLeprosy.setRecurrentTingling(diseaseControlData.getRecurrentTingling()); + existingDiseaseLeprosy.setHypopigmentedPatch(diseaseControlData.getHypopigmentedPatch()); + existingDiseaseLeprosy.setThickenedSkin(diseaseControlData.getThickenedSkin()); + existingDiseaseLeprosy.setSkinNodules(diseaseControlData.getSkinNodules()); + existingDiseaseLeprosy.setSkinPatchDiscoloration(diseaseControlData.getSkinPatchDiscoloration()); + existingDiseaseLeprosy.setRecurrentNumbness(diseaseControlData.getRecurrentNumbness()); + existingDiseaseLeprosy.setClawingFingers(diseaseControlData.getClawingFingers()); + existingDiseaseLeprosy.setTinglingNumbnessExtremities(diseaseControlData.getTinglingNumbnessExtremities()); + existingDiseaseLeprosy.setInabilityCloseEyelid(diseaseControlData.getInabilityCloseEyelid()); + existingDiseaseLeprosy.setDifficultyHoldingObjects(diseaseControlData.getDifficultyHoldingObjects()); + existingDiseaseLeprosy.setWeaknessFeet(diseaseControlData.getWeaknessFeet()); + + diseaseLeprosyRepository.save(existingDiseaseLeprosy); // Return the updated entity return "Data update successfully"; From 42384974a298d120662059c5898e1da7e52d029e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 6 Jan 2026 16:59:47 +0530 Subject: [PATCH 698/792] add new column --- .../com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java | 5 ++++- .../java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java | 6 ++++++ .../iemr/flw/service/impl/DiseaseControlServiceImpl.java | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java b/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java index c236ffa7..10689cff 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ChronicDiseaseVisitEntity.java @@ -23,7 +23,7 @@ public class ChronicDiseaseVisitEntity { @Column(name = "form_id") private String formId; - @Column(name = "version") + @Column(name = "version") private Integer version; @Column(name = "visit_no") @@ -38,6 +38,9 @@ public class ChronicDiseaseVisitEntity { @Column(name = "treatment_start_date") private LocalDate treatmentStartDate; + @Column(name = "follow_up_date") + private LocalDate followUpDate; + @Column(name = "form_data_json", columnDefinition = "JSON") private String formDataJson; diff --git a/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java b/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java index 7ec119c4..2a2790ad 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/ChronicDiseaseVisitDTO.java @@ -1,8 +1,11 @@ package com.iemr.flw.dto.iemr; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Column; import lombok.Data; +import java.time.LocalDate; + @Data public class ChronicDiseaseVisitDTO { @@ -27,6 +30,9 @@ public class ChronicDiseaseVisitDTO { @JsonProperty("followUpNo") private Integer followUpNo; + @Column(name = "followUpDate") + private LocalDate followUpDate; + @JsonProperty("diagnosisCodes") private String diagnosisCodes; diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 3ba522da..d5f009ea 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1077,10 +1077,12 @@ public List saveChronicDiseaseVisit( entity.setVersion(dto.getVersion()); entity.setVisitNo(dto.getVisitNo()); entity.setFollowUpNo(dto.getFollowUpNo()); + entity.setFollowUpDate(dto.getFollowUpDate()); entity.setDiagnosisCodes(dto.getDiagnosisCodes()); entity.setFormDataJson(dto.getFormDataJson()); entity.setUserID(jwtUtil.extractUserId(token)); entity.setCreatedBy(jwtUtil.extractUsername(token)); + entity.setUpdatedBy(jwtUtil.extractUserId(token)); if (dto.getTreatmentStartDate() != null) { @@ -1117,6 +1119,7 @@ public List getCdtfVisits(GetBenRequestHandler getBenReq dto.setVersion(entity.getVersion()); dto.setVisitNo(entity.getVisitNo()); dto.setFollowUpNo(entity.getFollowUpNo()); + dto.setFollowUpDate(entity.getFollowUpDate()); dto.setDiagnosisCodes(entity.getDiagnosisCodes()); dto.setFormDataJson(entity.getFormDataJson()); From b85db376633e4671fd367cf9bdb88e0287e981b5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 7 Jan 2026 10:43:31 +0530 Subject: [PATCH 699/792] change release version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d87cbdec..fe37dd00 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.7.0 + 3.6.2 war FLW-API From bd5071911a053c560d3916ffa0cae41b2a6838e9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 8 Jan 2026 14:32:13 +0530 Subject: [PATCH 700/792] AMM-2079 --- .../com/iemr/flw/domain/iemr/VhncForm.java | 23 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/VhncFormDTO.java | 8 +++++++ .../impl/VillageLevelFormServiceImpl.java | 8 +++++++ 3 files changed, 39 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java index 5b53b27e..858554da 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VhncForm.java @@ -1,6 +1,7 @@ package com.iemr.flw.domain.iemr; import jakarta.persistence.*; +import jakarta.xml.bind.annotation.XmlAccessorOrder; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; @@ -43,4 +44,26 @@ public class VhncForm { @Column(name = "form_type") private String formType; + + @Column(name = "village_name") + private String villageName; + + @Column(name = "anm") + private Integer anm; + + @Column(name = "aww") + private Integer aww; + + @Column(name = "no_of_pragnent_women") + private Integer noOfPragnentWoment; + + @Column(name = "no_of_lacting_mother") + private Integer noOfLactingMother; + + @Column(name = "no_of_committee") + private Integer noOfCommittee; + + @Column(name = "followup_previous") + private Boolean followupPrevius; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java index 8a12be96..a2515b42 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java @@ -34,4 +34,12 @@ public class VhncFormDTO { private Integer noOfBeneficiariesAttended; private String image1; private String image2; + private String villageName; + private Integer anm; + private Integer aww; + private Integer noOfPragnentWoment; + private Integer noOfLactingMother; + private Integer noOfCommittee; + private Boolean followupPrevius; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 71bbdbad..8630d444 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -132,6 +132,14 @@ private Boolean saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { vhncForm.setImage2(vhncFormDTO.getImage2()); vhncForm.setImage1(vhncFormDTO.getImage1()); vhncForm.setPlace(vhncFormDTO.getPlace()); + vhncForm.setVillageName(vhncForm.getVillageName()); + vhncForm.setAnm(vhncForm.getAnm()); + vhncForm.setAww(vhncForm.getAww()); + vhncForm.setNoOfPragnentWoment(vhncForm.getNoOfPragnentWoment()); + vhncForm.setNoOfLactingMother(vhncForm.getNoOfLactingMother()); + vhncForm.setNoOfCommittee(vhncForm.getNoOfCommittee()); + vhncForm.setFollowupPrevius(vhncForm.getFollowupPrevius()); + vhncForm.setNoOfBeneficiariesAttended(vhncFormDTO.getNoOfBeneficiariesAttended()); vhncForm.setFormType("VHNC"); From fa30de33c8879f6af1a579752975f8e9d3df7f8a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 9 Jan 2026 16:23:50 +0530 Subject: [PATCH 701/792] AMM-2079 --- .../service/impl/VillageLevelFormServiceImpl.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 8630d444..9efd528b 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -132,13 +132,13 @@ private Boolean saveVhncFormData(VhncFormDTO vhncFormDTO, Integer userID) { vhncForm.setImage2(vhncFormDTO.getImage2()); vhncForm.setImage1(vhncFormDTO.getImage1()); vhncForm.setPlace(vhncFormDTO.getPlace()); - vhncForm.setVillageName(vhncForm.getVillageName()); - vhncForm.setAnm(vhncForm.getAnm()); - vhncForm.setAww(vhncForm.getAww()); - vhncForm.setNoOfPragnentWoment(vhncForm.getNoOfPragnentWoment()); - vhncForm.setNoOfLactingMother(vhncForm.getNoOfLactingMother()); - vhncForm.setNoOfCommittee(vhncForm.getNoOfCommittee()); - vhncForm.setFollowupPrevius(vhncForm.getFollowupPrevius()); + vhncForm.setVillageName(vhncFormDTO.getVillageName()); + vhncForm.setAnm(vhncFormDTO.getAnm()); + vhncForm.setAww(vhncFormDTO.getAww()); + vhncForm.setNoOfPragnentWoment(vhncFormDTO.getNoOfPragnentWoment()); + vhncForm.setNoOfLactingMother(vhncFormDTO.getNoOfLactingMother()); + vhncForm.setNoOfCommittee(vhncFormDTO.getNoOfCommittee()); + vhncForm.setFollowupPrevius(vhncFormDTO.getFollowupPrevius()); vhncForm.setNoOfBeneficiariesAttended(vhncFormDTO.getNoOfBeneficiariesAttended()); From 624752175b00dd1488c63b9a9de0e506462e60be Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:31:40 +0530 Subject: [PATCH 702/792] Update pom.xml --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index fe37dd00..42245b93 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.6.2 + 3.7.0 war FLW-API @@ -420,4 +420,4 @@ - \ No newline at end of file + From ec9f17bb82568944e11c18cb05ffe2fd28ba7470 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 9 Jan 2026 17:03:04 +0530 Subject: [PATCH 703/792] Amm-2081 --- .../com/iemr/flw/domain/iemr/VHNDForm.java | 33 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/VHNDFormDTO.java | 12 +++++++ .../impl/VillageLevelFormServiceImpl.java | 10 ++++++ 3 files changed, 55 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java b/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java index 488b33c4..758cc449 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java @@ -37,6 +37,39 @@ public class VHNDForm { @Column(name = "form_type") private String formType; + @Column(name = "vhnd_place_id") + private Integer vhndPlaceId; + + @Column(name = "pregnant_women_anc") + private String pregnantWomenAnc; + + @Column(name = "lactating_mothers_pnc") + private String lactatingMothersPnc; + + @Column(name = "children_immunization") + private String childrenImmunization; + + @Column(name = "select_all_education") + private Boolean selectAllEducation; + + @Column(name = "knowledge_balanced_diet") + private String knowledgeBalancedDiet; + + @Column(name = "care_during_pregnancy") + private String careDuringPregnancy; + + @Column(name = "importance_breastfeeding") + private String importanceBreastfeeding; + + @Column(name = "complementary_feeding") + private String complementaryFeeding; + + @Column(name = "hygiene_sanitation") + private String hygieneSanitation; + + @Column(name = "family_planning_healthcare") + private String familyPlanningHealthcare; + @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java index 0dec7976..bee7f247 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java @@ -24,6 +24,7 @@ */ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; import lombok.Data; @Data @@ -33,6 +34,17 @@ public class VHNDFormDTO { private Integer noOfBeneficiariesAttended; private String image1; private String image2; + private Integer vhndPlaceId; + private String pregnantWomenAnc; + private String lactatingMothersPnc; + private String childrenImmunization; + private Boolean selectAllEducation; + private String knowledgeBalancedDiet; + private String careDuringPregnancy; + private String importanceBreastfeeding; + private String complementaryFeeding; + private String hygieneSanitation; + private String familyPlanningHealthcare; } diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index 9efd528b..a4df2b7d 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -210,6 +210,16 @@ private Boolean saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { vhndForm.setImage1(vhndFormDTO.getImage1()); vhndForm.setPlace(vhndFormDTO.getPlace()); vhndForm.setNoOfBeneficiariesAttended(vhndFormDTO.getNoOfBeneficiariesAttended()); + vhndForm.setPregnantWomenAnc(vhndFormDTO.getPregnantWomenAnc()); + vhndForm.setLactatingMothersPnc(vhndFormDTO.getLactatingMothersPnc()); + vhndForm.setChildrenImmunization(vhndFormDTO.getChildrenImmunization()); + vhndForm.setSelectAllEducation(vhndFormDTO.getSelectAllEducation()); + vhndForm.setKnowledgeBalancedDiet(vhndFormDTO.getKnowledgeBalancedDiet()); + vhndForm.setCareDuringPregnancy(vhndFormDTO.getCareDuringPregnancy()); + vhndForm.setImportanceBreastfeeding(vhndFormDTO.getImportanceBreastfeeding()); + vhndForm.setComplementaryFeeding(vhndFormDTO.getComplementaryFeeding()); + vhndForm.setHygieneSanitation(vhndFormDTO.getHygieneSanitation()); + vhndForm.setFamilyPlanningHealthcare(vhndFormDTO.getFamilyPlanningHealthcare()); vhndForm.setFormType("VHND"); vhndRepo.save(vhndForm); checkAndAddIncentives(vhndForm.getVhndDate(), vhndForm.getUserId(), "VHND_PARTICIPATION", vhndForm.getCreatedBy()); From 9f0bfa571a125cbe829e81c0f554de28e31e4c3b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 9 Jan 2026 19:02:26 +0530 Subject: [PATCH 704/792] fix auth --- .../flw/controller/VillageLevelFormController.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index ddbb7a76..09df6833 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -36,13 +36,13 @@ import java.util.Map; @RestController -@RequestMapping(value = "/forms/villageLevel", headers = "Authorization") +@RequestMapping(value = "/forms/villageLevel") public class VillageLevelFormController { @Autowired private VillageLevelFormService villageLevelFormService; - @RequestMapping(value = "vhnd/saveAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "vhnd/saveAll") public ResponseEntity> saveVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { @@ -64,7 +64,7 @@ public ResponseEntity> saveVhndForm(@RequestBody VhndDto dto } - @RequestMapping(value = "vhnc/saveAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "vhnc/saveAll", method = RequestMethod.POST) public ResponseEntity> saveVhncForm(@RequestBody VhncDto dto) { Map response = new HashMap<>(); @@ -87,7 +87,7 @@ public ResponseEntity> saveVhncForm(@RequestBody VhncDto dto } - @RequestMapping(value = "phc/saveAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "phc/saveAll", method = RequestMethod.POST) public ResponseEntity> savePhcForm(@RequestBody PhcReviewMeetingDTO dto) { Map response = new HashMap<>(); @@ -109,7 +109,7 @@ public ResponseEntity> savePhcForm(@RequestBody PhcReviewMee } - @RequestMapping(value = "ahd/saveAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "ahd/saveAll", method = RequestMethod.POST) public ResponseEntity> saveAhdForm(@RequestBody AhdMeetingDto dto) { Map response = new HashMap<>(); @@ -129,7 +129,7 @@ public ResponseEntity> saveAhdForm(@RequestBody AhdMeetingDt } - @RequestMapping(value = "deworming/saveAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "deworming/saveAll", method = RequestMethod.POST) public ResponseEntity> saveDewormingForm(@RequestBody DewormingDto dto) { Map response = new HashMap<>(); @@ -150,7 +150,7 @@ public ResponseEntity> saveDewormingForm(@RequestBody Deworm } - @RequestMapping(value = "getAll", method = RequestMethod.POST, headers = "Authorization") + @RequestMapping(value = "getAll", method = RequestMethod.POST) public ResponseEntity> getVillageLevelFormData(@RequestBody GetVillageLevelRequestHandler getVillageLevelRequestHandler) { Map response = new LinkedHashMap<>(); From e8930c696c190ac94c7ccf823fd4c4b56cbecf7f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 9 Jan 2026 19:03:02 +0530 Subject: [PATCH 705/792] fix auth --- .../com/iemr/flw/controller/VillageLevelFormController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java index 09df6833..884f794d 100644 --- a/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java +++ b/src/main/java/com/iemr/flw/controller/VillageLevelFormController.java @@ -42,7 +42,7 @@ public class VillageLevelFormController { @Autowired private VillageLevelFormService villageLevelFormService; - @RequestMapping(value = "vhnd/saveAll") + @RequestMapping(value = "vhnd/saveAll",method = RequestMethod.POST) public ResponseEntity> saveVhndForm(@RequestBody VhndDto dto) { Map response = new HashMap<>(); if (!dto.getEntries().isEmpty()) { From 4bda32abd241f5856a7f830baadd441bef9108ce Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 11:21:51 +0530 Subject: [PATCH 706/792] enhancement in mam meeting api add new column AMM-2102 --- .../flw/controller/MaaMeetingController.java | 9 +++ .../com/iemr/flw/domain/iemr/MaaMeeting.java | 13 ++++ .../flw/dto/iemr/MaaMeetingRequestDTO.java | 6 ++ .../flw/dto/iemr/MaaMeetingResponseDTO.java | 5 ++ .../iemr/flw/service/MaaMeetingService.java | 70 ++++++++++++------- 5 files changed, 79 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 0c73d46e..1ed1bb01 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -35,6 +35,10 @@ public MaaMeetingController(MaaMeetingService service) { @PostMapping(value = "/saveAll", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity saveMeeting( + @RequestPart("villageName") String villageName, + @RequestPart("noOfPragnentWoment") String noOfPragnentWomen, + @RequestPart("noOfLactingMother") String noOfLactingMother, + @RequestPart("mitaninActivityCheckList") List mitaninActivityCheckList, @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @RequestPart("participants") String participants, @@ -48,6 +52,11 @@ public ResponseEntity saveMeeting( dto.setParticipants(Integer.parseInt(participants)); dto.setAshaId(Integer.parseInt(ashaId)); dto.setCreatedBY(createdBy); + dto.setVillageName(villageName); + dto.setNoOfLactingMother(Integer.parseInt(noOfLactingMother)); + dto.setNoOfPragnentWomen(Integer.parseInt(noOfPragnentWomen)); + dto.setMitaninActivityCheckList(mitaninActivityCheckList); + dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); if (dto != null) { service.saveMeeting(dto); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index 2bfb2970..0e843714 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -5,6 +5,7 @@ import java.sql.Timestamp; import java.time.LocalDate; +import java.util.List; @Entity @Data @@ -39,6 +40,18 @@ public class MaaMeeting { @Column(name = "meeting_images", columnDefinition = "LONGTEXT") private String meetingImagesJson; + @Column(name = "village_name") + private String villageName; + + @Column(name = "no_of_pragnent_women") + private Integer noOfPragnentWomen; + + @Column(name = "no_of_lacting_mother") + private Integer noOfLactingMother; + + @Column(name = "mitanin_activity_checkList") + private String mitaninActivityCheckList; + @Column(name = "created_by") private String createdBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index 9d4c19b1..8211be66 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -1,10 +1,12 @@ package com.iemr.flw.dto.iemr; import lombok.Data; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; import java.time.LocalDate; +import java.util.List; @Data public class MaaMeetingRequestDTO { @@ -14,5 +16,9 @@ public class MaaMeetingRequestDTO { private Integer participants; private MultipartFile[] meetingImages; // up to 5 images private Integer ashaId; + private String villageName; + private Integer noOfPragnentWomen; + private Integer noOfLactingMother; + private List mitaninActivityCheckList; private String createdBY; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 9ba81ad8..0f1f6e67 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -35,6 +35,11 @@ public class MaaMeetingResponseDTO { example = "[\"iVBORw0KGgoAAAANSUhEUgAA...\", \"iVBORw0KGgoAAAANSUhEUgBB...\"]") private List meetingImages; + private String villageName; + private String noOfPragnentWomen; + private String noOfLactingMother; + private List mitaninActivityCheckList; + @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 2c48df26..97a5a602 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -46,6 +46,12 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setPlace(req.getPlace()); meeting.setParticipants(req.getParticipants()); meeting.setAshaId(req.getAshaId()); + meeting.setNoOfLactingMother(req.getNoOfLactingMother()); + meeting.setNoOfPragnentWomen(req.getNoOfPragnentWomen()); + meeting.setVillageName(req.getVillageName()); + String checklistJson = + objectMapper.writeValueAsString(req.getMitaninActivityCheckList()); + meeting.setMitaninActivityCheckList(checklistJson); meeting.setCreatedBy(req.getCreatedBY()); // Convert meeting images to Base64 JSON @@ -102,7 +108,7 @@ public MaaMeeting updateMeeting(MaaMeetingRequestDTO req) throws JsonProcessingE } checkAndAddIncentive(existingMeeting); - if(existingMeeting.getMeetingImagesJson()!=null){ + if (existingMeeting.getMeetingImagesJson() != null) { checkAndUpdateIncentive(existingMeeting); } @@ -119,8 +125,6 @@ private String convertToBase64(MultipartFile file) { } - - public List getAllMeetings(GetBenRequestHandler getBenRequestHandler) throws Exception { List meetings = repository.findByAshaId(getBenRequestHandler.getAshaId()); @@ -131,13 +135,28 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setPlace(meeting.getPlace()); dto.setParticipants(meeting.getParticipants()); dto.setAshaId(meeting.getAshaId()); + dto.setVillageName(meeting.getVillageName()); + dto.setNoOfLactingMother(String.valueOf(meeting.getNoOfLactingMother())); + dto.setNoOfPragnentWomen(String.valueOf(meeting.getNoOfPragnentWomen())); + List checklist = + null; + try { + checklist = objectMapper.readValue( + meeting.getMitaninActivityCheckList(), + new TypeReference>() {} + ); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } + dto.setMitaninActivityCheckList(checklist); dto.setCreatedBy(meeting.getCreatedBy()); try { if (meeting.getMeetingImagesJson() != null) { List base64Images = objectMapper.readValue( meeting.getMeetingImagesJson(), - new TypeReference>() {} + new TypeReference>() { + } ); dto.setMeetingImages(base64Images); @@ -151,45 +170,48 @@ public List getAllMeetings(GetBenRequestHandler getBenReq return dto; }).collect(Collectors.toList()); } - private void updatePendingActivity(Integer userId,Long recordId,Long activityId,String moduleName){ + + private void updatePendingActivity(Integer userId, Long recordId, Long activityId, String moduleName) { IncentivePendingActivity incentivePendingActivity = new IncentivePendingActivity(); incentivePendingActivity.setActivityId(activityId); incentivePendingActivity.setRecordId(recordId); incentivePendingActivity.setUserId(userId); incentivePendingActivity.setModuleName(moduleName); - if(incentivePendingActivity!=null){ + if (incentivePendingActivity != null) { incentivePendingActivityRepository.save(incentivePendingActivity); } } + private void checkAndUpdateIncentive(MaaMeeting meeting) { IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.ACTIVITY.getDisplayName()); - if(incentiveActivityAM!=null){ - updateIncentive(incentiveActivityAM,meeting); + if (incentiveActivityAM != null) { + updateIncentive(incentiveActivityAM, meeting); } - if(incentiveActivityCH!=null){ - updateIncentive(incentiveActivityCH,meeting); + if (incentiveActivityCH != null) { + updateIncentive(incentiveActivityCH, meeting); } } + private void checkAndAddIncentive(MaaMeeting meeting) { IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.CHILD_HEALTH.getDisplayName()); IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("MAA_QUARTERLY_MEETING", GroupName.ACTIVITY.getDisplayName()); - if(incentiveActivityAM!=null){ - addIncentive(incentiveActivityAM,meeting); - } - if(incentiveActivityCH!=null){ - addIncentive(incentiveActivityCH,meeting); + if (incentiveActivityAM != null) { + addIncentive(incentiveActivityAM, meeting); + } + if (incentiveActivityCH != null) { + addIncentive(incentiveActivityCH, meeting); - } + } } - private void addIncentive(IncentiveActivity incentiveActivity,MaaMeeting meeting){ + private void addIncentive(IncentiveActivity incentiveActivity, MaaMeeting meeting) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L,meeting.getAshaId()); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L, meeting.getAshaId()); if (record == null) { record = new IncentiveActivityRecord(); @@ -202,11 +224,11 @@ record = new IncentiveActivityRecord(); record.setUpdatedBy(meeting.getCreatedBy()); record.setBenId(0L); record.setAshaId(meeting.getAshaId()); - if(meeting.getMeetingImagesJson()!=null){ + if (meeting.getMeetingImagesJson() != null) { record.setIsEligible(true); - }else { + } else { record.setIsEligible(false); - updatePendingActivity(meeting.getAshaId(),meeting.getId(),record.getId(),"MAA_MEETING"); + updatePendingActivity(meeting.getAshaId(), meeting.getId(), record.getId(), "MAA_MEETING"); } record.setAmount(Long.valueOf(incentiveActivity.getRate())); @@ -215,11 +237,11 @@ record = new IncentiveActivityRecord(); } - private void updateIncentive(IncentiveActivity incentiveActivity,MaaMeeting meeting){ + private void updateIncentive(IncentiveActivity incentiveActivity, MaaMeeting meeting) { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L,meeting.getAshaId()); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), Timestamp.valueOf(meeting.getMeetingDate().atStartOfDay()), 0L, meeting.getAshaId()); - if (record!= null) { + if (record != null) { record = new IncentiveActivityRecord(); record.setIsEligible(true); recordRepo.save(record); From 27d624dd803b1c7009c00bf9ad2362309756a16e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 12:05:27 +0530 Subject: [PATCH 707/792] fix column type issue --- .../flw/controller/MaaMeetingController.java | 2 +- .../iemr/flw/dto/iemr/MaaMeetingRequestDTO.java | 2 +- .../iemr/flw/dto/iemr/MaaMeetingResponseDTO.java | 2 +- .../com/iemr/flw/service/MaaMeetingService.java | 16 ++-------------- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 1ed1bb01..83741682 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -38,7 +38,7 @@ public ResponseEntity saveMeeting( @RequestPart("villageName") String villageName, @RequestPart("noOfPragnentWoment") String noOfPragnentWomen, @RequestPart("noOfLactingMother") String noOfLactingMother, - @RequestPart("mitaninActivityCheckList") List mitaninActivityCheckList, + @RequestPart("mitaninActivityCheckList") String mitaninActivityCheckList, @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @RequestPart("participants") String participants, diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index 8211be66..e4ca6af5 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -19,6 +19,6 @@ public class MaaMeetingRequestDTO { private String villageName; private Integer noOfPragnentWomen; private Integer noOfLactingMother; - private List mitaninActivityCheckList; + private String mitaninActivityCheckList; private String createdBY; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 0f1f6e67..b56356c2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -38,7 +38,7 @@ public class MaaMeetingResponseDTO { private String villageName; private String noOfPragnentWomen; private String noOfLactingMother; - private List mitaninActivityCheckList; + private String mitaninActivityCheckList; @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 97a5a602..9c103078 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -49,9 +49,7 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setNoOfLactingMother(req.getNoOfLactingMother()); meeting.setNoOfPragnentWomen(req.getNoOfPragnentWomen()); meeting.setVillageName(req.getVillageName()); - String checklistJson = - objectMapper.writeValueAsString(req.getMitaninActivityCheckList()); - meeting.setMitaninActivityCheckList(checklistJson); + meeting.setMitaninActivityCheckList(req.getMitaninActivityCheckList()); meeting.setCreatedBy(req.getCreatedBY()); // Convert meeting images to Base64 JSON @@ -138,17 +136,7 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setVillageName(meeting.getVillageName()); dto.setNoOfLactingMother(String.valueOf(meeting.getNoOfLactingMother())); dto.setNoOfPragnentWomen(String.valueOf(meeting.getNoOfPragnentWomen())); - List checklist = - null; - try { - checklist = objectMapper.readValue( - meeting.getMitaninActivityCheckList(), - new TypeReference>() {} - ); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - dto.setMitaninActivityCheckList(checklist); + dto.setMitaninActivityCheckList(meeting.getMitaninActivityCheckList()); dto.setCreatedBy(meeting.getCreatedBy()); try { From 862d708435b4920bdcab5cc5e9862cdf76972baf Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 12:12:33 +0530 Subject: [PATCH 708/792] AMM-2100 --- .../java/com/iemr/flw/domain/iemr/PHCReviewForm.java | 12 ++++++++++++ .../iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java index 50ec3375..d65ff551 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java @@ -42,6 +42,18 @@ public class PHCReviewForm { @Column(name = "created_date", updatable = false) private Timestamp createdDate; + @Column(name = "village_name ") + private String villageName; + + @Column(name = "mitanin_history") + private String mitaninHistory; + + @Column(name = "mitanin_activity_checkList") + private String mitaninActivityCheckList; + + @Column(name = "place_Id") + private Integer placeId; + @Column(name = "form_type") private String formType; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java index 00830988..e94e34b2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; import lombok.Data; @Data @@ -8,6 +9,10 @@ public class PhcReviewMeetingFormDTO { private String phcReviewDate; private String place; private Integer noOfBeneficiariesAttended; + private String villageName; + private String mitaninHistory; + private String mitaninActivityCheckList; + private Integer placeId; private String image1; private String image2; From d6c0aa0852cffd0abf190da6c9154c5bc07db976 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 12:12:54 +0530 Subject: [PATCH 709/792] AMM-2100 --- .../iemr/flw/service/impl/VillageLevelFormServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index a4df2b7d..fbaff0d5 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -157,6 +157,10 @@ private Boolean savePhcForm(PhcReviewMeetingFormDTO dto, Integer userID) { phcReviewForm.setPlace(dto.getPlace()); phcReviewForm.setNoOfBeneficiariesAttended(dto.getNoOfBeneficiariesAttended()); phcReviewForm.setImage1(dto.getImage1()); + phcReviewForm.setVillageName(dto.getVillageName()); + phcReviewForm.setMitaninActivityCheckList(dto.getMitaninActivityCheckList()); + phcReviewForm.setPlaceId(dto.getPlaceId()); + phcReviewForm.setMitaninHistory(dto.getMitaninHistory()); phcReviewForm.setImage2(dto.getImage2()); phcReviewForm.setFormType("PHC"); phcReviewFormRepo.save(phcReviewForm); From 18094526fee9dbf92e278a7fbc5a175b512480a7 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 12:14:31 +0530 Subject: [PATCH 710/792] AMM-2100 --- src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java | 1 + src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java | 1 - src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java | 1 + .../com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java index d65ff551..4dea0ce7 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java @@ -56,4 +56,5 @@ public class PHCReviewForm { @Column(name = "form_type") private String formType; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index 4efc6dcc..a943affe 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -26,7 +26,6 @@ import jakarta.persistence.*; import lombok.Data; - import java.sql.Timestamp; import java.util.Date; diff --git a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java index e94e34b2..b08386c6 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PhcReviewMeetingFormDTO.java @@ -17,4 +17,5 @@ public class PhcReviewMeetingFormDTO { private String image2; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java index fbaff0d5..c64654d3 100644 --- a/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/VillageLevelFormServiceImpl.java @@ -232,6 +232,7 @@ private Boolean saveVhndFormData(VHNDFormDTO vhndFormDTO, Integer userID) { } + @Override public List getAll(GetVillageLevelRequestHandler getVillageLevelRequestHandler) { if (Objects.equals(getVillageLevelRequestHandler.getFormType(), "VHND")) { From 40d8b228b098cc283f614ae7375766684c6a4496 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 18:16:03 +0530 Subject: [PATCH 711/792] AMM-2102 --- .../iemr/flw/controller/MaaMeetingController.java | 2 ++ .../java/com/iemr/flw/domain/iemr/MaaMeeting.java | 3 +++ .../com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java | 1 + .../iemr/flw/dto/iemr/MaaMeetingResponseDTO.java | 1 + .../com/iemr/flw/service/MaaMeetingService.java | 13 +++++++++++++ 5 files changed, 20 insertions(+) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 83741682..0b247fe3 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -38,6 +38,7 @@ public ResponseEntity saveMeeting( @RequestPart("villageName") String villageName, @RequestPart("noOfPragnentWoment") String noOfPragnentWomen, @RequestPart("noOfLactingMother") String noOfLactingMother, + @RequestPart("isSelectAll") String isSelectAll, @RequestPart("mitaninActivityCheckList") String mitaninActivityCheckList, @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @@ -53,6 +54,7 @@ public ResponseEntity saveMeeting( dto.setAshaId(Integer.parseInt(ashaId)); dto.setCreatedBY(createdBy); dto.setVillageName(villageName); + dto.setIsSelectAll(isSelectAll); dto.setNoOfLactingMother(Integer.parseInt(noOfLactingMother)); dto.setNoOfPragnentWomen(Integer.parseInt(noOfPragnentWomen)); dto.setMitaninActivityCheckList(mitaninActivityCheckList); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index 0e843714..90cca318 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -52,6 +52,9 @@ public class MaaMeeting { @Column(name = "mitanin_activity_checkList") private String mitaninActivityCheckList; + @Column(name = "is_select_all") + private Boolean isSelectAll; + @Column(name = "created_by") private String createdBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index e4ca6af5..b0a67e55 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -20,5 +20,6 @@ public class MaaMeetingRequestDTO { private Integer noOfPragnentWomen; private Integer noOfLactingMother; private String mitaninActivityCheckList; + private String isSelectAll; private String createdBY; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index b56356c2..29c57167 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -39,6 +39,7 @@ public class MaaMeetingResponseDTO { private String noOfPragnentWomen; private String noOfLactingMother; private String mitaninActivityCheckList; + private String isSelectAll; @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 9c103078..350c9125 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -50,6 +50,12 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setNoOfPragnentWomen(req.getNoOfPragnentWomen()); meeting.setVillageName(req.getVillageName()); meeting.setMitaninActivityCheckList(req.getMitaninActivityCheckList()); + if(Objects.equals(req.getIsSelectAll(), "Yes")){ + meeting.setIsSelectAll(true); + }else { + meeting.setIsSelectAll(false); + + } meeting.setCreatedBy(req.getCreatedBY()); // Convert meeting images to Base64 JSON @@ -137,6 +143,13 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setNoOfLactingMother(String.valueOf(meeting.getNoOfLactingMother())); dto.setNoOfPragnentWomen(String.valueOf(meeting.getNoOfPragnentWomen())); dto.setMitaninActivityCheckList(meeting.getMitaninActivityCheckList()); + if(meeting.getIsSelectAll()){ + dto.setIsSelectAll("Yes"); + + }else { + dto.setIsSelectAll("No"); + + } dto.setCreatedBy(meeting.getCreatedBy()); try { From de29668af3620e728f46c1837a69938ace87b247 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 13 Jan 2026 18:24:41 +0530 Subject: [PATCH 712/792] AMM-2102 --- .../java/com/iemr/flw/domain/iemr/MaaMeeting.java | 2 +- .../com/iemr/flw/service/MaaMeetingService.java | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index 90cca318..364ecb57 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -53,7 +53,7 @@ public class MaaMeeting { private String mitaninActivityCheckList; @Column(name = "is_select_all") - private Boolean isSelectAll; + private String isSelectAll; @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 350c9125..631398f9 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -50,12 +50,8 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setNoOfPragnentWomen(req.getNoOfPragnentWomen()); meeting.setVillageName(req.getVillageName()); meeting.setMitaninActivityCheckList(req.getMitaninActivityCheckList()); - if(Objects.equals(req.getIsSelectAll(), "Yes")){ - meeting.setIsSelectAll(true); - }else { - meeting.setIsSelectAll(false); + meeting.setIsSelectAll(req.getIsSelectAll()); - } meeting.setCreatedBy(req.getCreatedBY()); // Convert meeting images to Base64 JSON @@ -143,13 +139,7 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setNoOfLactingMother(String.valueOf(meeting.getNoOfLactingMother())); dto.setNoOfPragnentWomen(String.valueOf(meeting.getNoOfPragnentWomen())); dto.setMitaninActivityCheckList(meeting.getMitaninActivityCheckList()); - if(meeting.getIsSelectAll()){ - dto.setIsSelectAll("Yes"); - - }else { - dto.setIsSelectAll("No"); - - } + dto.setIsSelectAll(meeting.getIsSelectAll()); dto.setCreatedBy(meeting.getCreatedBy()); try { From 07e0cd5b4e85480d814f82bcfde919e8e7e062e8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 14 Jan 2026 12:08:26 +0530 Subject: [PATCH 713/792] AMM-2102 remove select all column --- .../java/com/iemr/flw/controller/MaaMeetingController.java | 2 -- src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java | 3 --- src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java | 1 - src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java | 1 - src/main/java/com/iemr/flw/service/MaaMeetingService.java | 2 -- 5 files changed, 9 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 0b247fe3..83741682 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -38,7 +38,6 @@ public ResponseEntity saveMeeting( @RequestPart("villageName") String villageName, @RequestPart("noOfPragnentWoment") String noOfPragnentWomen, @RequestPart("noOfLactingMother") String noOfLactingMother, - @RequestPart("isSelectAll") String isSelectAll, @RequestPart("mitaninActivityCheckList") String mitaninActivityCheckList, @RequestPart("meetingDate") String meetingDate, @RequestPart("place") String place, @@ -54,7 +53,6 @@ public ResponseEntity saveMeeting( dto.setAshaId(Integer.parseInt(ashaId)); dto.setCreatedBY(createdBy); dto.setVillageName(villageName); - dto.setIsSelectAll(isSelectAll); dto.setNoOfLactingMother(Integer.parseInt(noOfLactingMother)); dto.setNoOfPragnentWomen(Integer.parseInt(noOfPragnentWomen)); dto.setMitaninActivityCheckList(mitaninActivityCheckList); diff --git a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java index 364ecb57..0e843714 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java +++ b/src/main/java/com/iemr/flw/domain/iemr/MaaMeeting.java @@ -52,9 +52,6 @@ public class MaaMeeting { @Column(name = "mitanin_activity_checkList") private String mitaninActivityCheckList; - @Column(name = "is_select_all") - private String isSelectAll; - @Column(name = "created_by") private String createdBy; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java index b0a67e55..e4ca6af5 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingRequestDTO.java @@ -20,6 +20,5 @@ public class MaaMeetingRequestDTO { private Integer noOfPragnentWomen; private Integer noOfLactingMother; private String mitaninActivityCheckList; - private String isSelectAll; private String createdBY; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java index 29c57167..b56356c2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MaaMeetingResponseDTO.java @@ -39,7 +39,6 @@ public class MaaMeetingResponseDTO { private String noOfPragnentWomen; private String noOfLactingMother; private String mitaninActivityCheckList; - private String isSelectAll; @Column(name = "created_by") private String createdBy; diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index 631398f9..d3319821 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -50,7 +50,6 @@ public MaaMeeting saveMeeting(MaaMeetingRequestDTO req) throws Exception { meeting.setNoOfPragnentWomen(req.getNoOfPragnentWomen()); meeting.setVillageName(req.getVillageName()); meeting.setMitaninActivityCheckList(req.getMitaninActivityCheckList()); - meeting.setIsSelectAll(req.getIsSelectAll()); meeting.setCreatedBy(req.getCreatedBY()); @@ -139,7 +138,6 @@ public List getAllMeetings(GetBenRequestHandler getBenReq dto.setNoOfLactingMother(String.valueOf(meeting.getNoOfLactingMother())); dto.setNoOfPragnentWomen(String.valueOf(meeting.getNoOfPragnentWomen())); dto.setMitaninActivityCheckList(meeting.getMitaninActivityCheckList()); - dto.setIsSelectAll(meeting.getIsSelectAll()); dto.setCreatedBy(meeting.getCreatedBy()); try { From 33e1faf29cd831b1d81f85920624ccbef24139a3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 14 Jan 2026 12:47:46 +0530 Subject: [PATCH 714/792] fix pending incentive code --- src/main/java/com/iemr/flw/service/MaaMeetingService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/MaaMeetingService.java b/src/main/java/com/iemr/flw/service/MaaMeetingService.java index d3319821..cb23b7b9 100644 --- a/src/main/java/com/iemr/flw/service/MaaMeetingService.java +++ b/src/main/java/com/iemr/flw/service/MaaMeetingService.java @@ -217,7 +217,7 @@ record = new IncentiveActivityRecord(); record.setIsEligible(true); } else { record.setIsEligible(false); - updatePendingActivity(meeting.getAshaId(), meeting.getId(), record.getId(), "MAA_MEETING"); + // updatePendingActivity(meeting.getAshaId(), meeting.getId(), record.getId(), "MAA_MEETING"); } record.setAmount(Long.valueOf(incentiveActivity.getRate())); From e310c5c442866e610bc48c65149f8c2f4e86a9d2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:29:22 +0530 Subject: [PATCH 715/792] api for ORS campaign AMM-2104 --- .../flw/controller/CampaignController.java | 78 ++++++++++++++++ .../com/iemr/flw/domain/iemr/CampaignOrs.java | 63 +++++++++++++ .../com/iemr/flw/dto/iemr/OrsCampaignDTO.java | 10 ++ .../iemr/flw/dto/iemr/OrsCampaignListDTO.java | 16 ++++ .../iemr/flw/repo/iemr/OrsCampaignRepo.java | 17 ++++ .../com/iemr/flw/service/CampaignService.java | 11 +++ .../flw/service/impl/CampaignServiceImpl.java | 92 +++++++++++++++++++ 7 files changed, 287 insertions(+) create mode 100644 src/main/java/com/iemr/flw/controller/CampaignController.java create mode 100644 src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsCampaignDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/OrsCampaignRepo.java create mode 100644 src/main/java/com/iemr/flw/service/CampaignService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java new file mode 100644 index 00000000..3ee70aee --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -0,0 +1,78 @@ +package com.iemr.flw.controller; + +import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.service.CampaignService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping(value = "/Campaign") +public class CampaignController { + private final Logger logger = LoggerFactory.getLogger(CampaignController.class); + + @Autowired + private CampaignService campaignService; + + @RequestMapping(value = "ors/distribution/saveAll", method = RequestMethod.POST) + public ResponseEntity> saveOrsDistribution(@RequestBody List orsCampaignDTO, @RequestHeader(value = "jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + Object result = campaignService.saveOrsCampaign(orsCampaignDTO,token); + + + if (result != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error save ors distribution :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + + @RequestMapping(value = "ors/distribution/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllOrsDistribution(@RequestHeader(value = "jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + List result = campaignService.getOrsCampaign(token); + + + if (result != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error save ors distribution :", e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } +} diff --git a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java new file mode 100644 index 00000000..b9fab48e --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java @@ -0,0 +1,63 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "campaign_ors") +@Data +public class CampaignOrs { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "start_date", nullable = false) + private LocalDate startDate; + + @Column(name = "end_date", nullable = false) + private LocalDate endDate; + + @Column(name = "user_id", nullable = false) + private Integer userId; + + @Column(name = "number_of_families", nullable = false) + private Integer numberOfFamilies = 0; + + /** + * Store JSON array like ["img1.jpg","img2.jpg"] + * MySQL JSON column + */ + @Column(name = "campaign_photos", columnDefinition = "json") + private String campaignPhotos; + + @Column(name = "created_by", length = 200) + private String createdBy; + + @Column(name = "updated_by", length = 200) + private String updatedBy; + + @Column(name = "created_date", updatable = false) + private LocalDateTime createdDate; + + @Column(name = "updated_date") + private LocalDateTime updatedDate; + + /* ---------- Auto timestamps ---------- */ + + @PrePersist + protected void onCreate() { + this.createdDate = LocalDateTime.now(); + this.updatedDate = LocalDateTime.now(); + } + + @PreUpdate + protected void onUpdate() { + this.updatedDate = LocalDateTime.now(); + } + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignDTO.java new file mode 100644 index 00000000..dbd83c26 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OrsCampaignDTO { + private Long id; + private String visitDate; + private OrsCampaignListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java new file mode 100644 index 00000000..1b2d64f4 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -0,0 +1,16 @@ +package com.iemr.flw.dto.iemr; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; + +import java.sql.Timestamp; + +@Data +public class OrsCampaignListDTO { + private String visit_date; + private Timestamp end_date; + private String number_of_families; + private String campaign_photos; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/OrsCampaignRepo.java b/src/main/java/com/iemr/flw/repo/iemr/OrsCampaignRepo.java new file mode 100644 index 00000000..fbbe380b --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/OrsCampaignRepo.java @@ -0,0 +1,17 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface OrsCampaignRepo extends JpaRepository { + Page findByUserId(Integer userId, Pageable pageable); +} diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java new file mode 100644 index 00000000..05f1f4be --- /dev/null +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -0,0 +1,11 @@ +package com.iemr.flw.service; + +import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.utils.exception.IEMRException; + +import java.util.List; + +public interface CampaignService { + Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; + List getOrsCampaign(String token) throws IEMRException; +} diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java new file mode 100644 index 00000000..67d98fea --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -0,0 +1,92 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.repo.iemr.OrsCampaignRepo; +import com.iemr.flw.service.CampaignService; +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.exception.IEMRException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +public class CampaignServiceImpl implements CampaignService { + + @Autowired + private OrsCampaignRepo orsCampaignRepo; + + @Autowired + private JwtUtil jwtUtil; + + @Override + public Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException { + if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { + return null; + } + + List campaignOrsRequest = new ArrayList<>(); + Integer userId = jwtUtil.extractUserId(token); + String userName = jwtUtil.extractUsername(token); + + for (OrsCampaignDTO campaignDTO : orsCampaignDTO) { + if (campaignDTO.getFields() == null) { + continue; // or throw exception based on your requirements + } + + CampaignOrs campaignOrsEntity = new CampaignOrs(); // Create new entity for each DTO + campaignOrsEntity.setUserId(userId); + campaignOrsEntity.setCreatedBy(userName); + campaignOrsEntity.setUpdatedBy(userName); + + try { + campaignOrsEntity.setNumberOfFamilies( + Integer.parseInt(campaignDTO.getFields().getNumber_of_families()) + ); + } catch (NumberFormatException e) { + // Handle invalid number format - log or throw exception + throw new IEMRException("Invalid number format for families"); + } + + campaignOrsEntity.setCampaignPhotos(campaignDTO.getFields().getCampaign_photos()); + campaignOrsRequest.add(campaignOrsEntity); + } + + if (!campaignOrsRequest.isEmpty()) { + orsCampaignRepo.saveAll(campaignOrsRequest); + return campaignOrsRequest; + } + + return null; + } + + @Override + public List getOrsCampaign(String token) throws IEMRException { + Integer userId = jwtUtil.extractUserId(token); + List orsCampaignDTOSResponse = new ArrayList<>(); + int page=0; + int pageSize =10; + Page campaignOrsPage; + do{ + Pageable pageable = PageRequest.of(page,pageSize); + campaignOrsPage = orsCampaignRepo.findByUserId(userId,pageable); + for(CampaignOrs campaignOrs:campaignOrsPage.getContent()){ + OrsCampaignDTO dto = convertToDTO(campaignOrs); + orsCampaignDTOSResponse.add(dto); + } + page++; + }while (campaignOrsPage.hasNext()); + return orsCampaignDTOSResponse; + } + private OrsCampaignDTO convertToDTO(CampaignOrs campaign) { + OrsCampaignDTO dto = new OrsCampaignDTO(); + // Set DTO fields from entity + // dto.setXxx(campaign.getXxx()); + return dto; + } +} From ba717c66e5a8d2ae9f9610e0efd62993236d02df Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:33:10 +0530 Subject: [PATCH 716/792] api for ORS campaign AMM-2104 --- src/main/java/com/iemr/flw/controller/CampaignController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 3ee70aee..1ca2d695 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -14,7 +14,7 @@ import java.util.Map; @RestController -@RequestMapping(value = "/Campaign") +@RequestMapping(value = "/campaign") public class CampaignController { private final Logger logger = LoggerFactory.getLogger(CampaignController.class); From 8e7a8f34558a35c2f72e8a3bde6977086c4d1351 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:47:35 +0530 Subject: [PATCH 717/792] api for ORS campaign AMM-2104 --- .../java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java | 5 +++-- .../com/iemr/flw/service/impl/CampaignServiceImpl.java | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 1b2d64f4..f10ce4d1 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -4,11 +4,12 @@ import lombok.Data; import java.sql.Timestamp; +import java.time.LocalDate; @Data public class OrsCampaignListDTO { - private String visit_date; - private Timestamp end_date; + private LocalDate start_date; + private LocalDate end_date; private String number_of_families; private String campaign_photos; diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 67d98fea..f072144d 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -2,6 +2,7 @@ import com.iemr.flw.domain.iemr.CampaignOrs; import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.dto.iemr.OrsCampaignListDTO; import com.iemr.flw.repo.iemr.OrsCampaignRepo; import com.iemr.flw.service.CampaignService; import com.iemr.flw.utils.JwtUtil; @@ -85,8 +86,12 @@ public List getOrsCampaign(String token) throws IEMRException { } private OrsCampaignDTO convertToDTO(CampaignOrs campaign) { OrsCampaignDTO dto = new OrsCampaignDTO(); - // Set DTO fields from entity - // dto.setXxx(campaign.getXxx()); + OrsCampaignListDTO orsCampaignListDTO = new OrsCampaignListDTO(); + orsCampaignListDTO.setCampaign_photos(campaign.getCampaignPhotos()); + orsCampaignListDTO.setEnd_date(campaign.getEndDate()); + orsCampaignListDTO.setStart_date(campaign.getStartDate()); + orsCampaignListDTO.setNumber_of_families(String.valueOf(campaign.getNumberOfFamilies())); + dto.setFields(orsCampaignListDTO); return dto; } } From a2ea2ca3358b8f78a810b8a4ae689cabab9ea043 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:51:55 +0530 Subject: [PATCH 718/792] api for ORS campaign AMM-2104 --- .../iemr/flw/dto/iemr/OrsCampaignListDTO.java | 16 ++++++++++++---- .../flw/service/impl/CampaignServiceImpl.java | 12 ++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index f10ce4d1..3ed417b2 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; import lombok.Data; @@ -8,10 +9,17 @@ @Data public class OrsCampaignListDTO { - private LocalDate start_date; - private LocalDate end_date; - private String number_of_families; - private String campaign_photos; + @JsonProperty("start_date") + private LocalDate StartDate; + + @JsonProperty("end_date") + private LocalDate EndDate; + + @JsonProperty("number_of_families") + private String NumberOfFamilies; + + @JsonProperty("campaign_photos") + private String CampaignPhotos; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index f072144d..0955aee7 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -47,14 +47,14 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) try { campaignOrsEntity.setNumberOfFamilies( - Integer.parseInt(campaignDTO.getFields().getNumber_of_families()) + Integer.parseInt(campaignDTO.getFields().getNumberOfFamilies()) ); } catch (NumberFormatException e) { // Handle invalid number format - log or throw exception throw new IEMRException("Invalid number format for families"); } - campaignOrsEntity.setCampaignPhotos(campaignDTO.getFields().getCampaign_photos()); + campaignOrsEntity.setCampaignPhotos(campaignDTO.getFields().getCampaignPhotos()); campaignOrsRequest.add(campaignOrsEntity); } @@ -87,10 +87,10 @@ public List getOrsCampaign(String token) throws IEMRException { private OrsCampaignDTO convertToDTO(CampaignOrs campaign) { OrsCampaignDTO dto = new OrsCampaignDTO(); OrsCampaignListDTO orsCampaignListDTO = new OrsCampaignListDTO(); - orsCampaignListDTO.setCampaign_photos(campaign.getCampaignPhotos()); - orsCampaignListDTO.setEnd_date(campaign.getEndDate()); - orsCampaignListDTO.setStart_date(campaign.getStartDate()); - orsCampaignListDTO.setNumber_of_families(String.valueOf(campaign.getNumberOfFamilies())); + orsCampaignListDTO.setCampaignPhotos(campaign.getCampaignPhotos()); + orsCampaignListDTO.setEndDate(campaign.getEndDate()); + orsCampaignListDTO.setStartDate(campaign.getStartDate()); + orsCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); dto.setFields(orsCampaignListDTO); return dto; } From 5e3e951508ac35040a363c79bac39b8a7a2c10dd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:53:02 +0530 Subject: [PATCH 719/792] api for ORS campaign AMM-2104 --- src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java index b9fab48e..9d4c5c1a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java +++ b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java @@ -7,7 +7,7 @@ import java.time.LocalDateTime; @Entity -@Table(name = "campaign_ors") +@Table(name = "campaign_ors",schema = "db_iemr") @Data public class CampaignOrs { From f1cb12f9d2dbf0ff0fad634dd915a77737e31cf8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:54:43 +0530 Subject: [PATCH 720/792] api for ORS campaign AMM-2104 --- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 0955aee7..917b2662 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -12,6 +12,7 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -26,6 +27,7 @@ public class CampaignServiceImpl implements CampaignService { private JwtUtil jwtUtil; @Override + @Transactional public Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException { if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { return null; @@ -67,6 +69,7 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) } @Override + @Transactional public List getOrsCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); List orsCampaignDTOSResponse = new ArrayList<>(); From 6cdbbf8f7a1b2699d93820b0e17ab89e48c7d7b1 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:55:15 +0530 Subject: [PATCH 721/792] api for ORS campaign AMM-2104 --- src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 917b2662..3ef919d2 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -69,7 +69,6 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) } @Override - @Transactional public List getOrsCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); List orsCampaignDTOSResponse = new ArrayList<>(); From 33b0fa19f3a56ea5b74616bb14232087eb22a888 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 14:57:46 +0530 Subject: [PATCH 722/792] api for ORS campaign AMM-2104 --- .../flw/service/impl/CampaignServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 3ef919d2..98ae7eb2 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; +import java.util.Collections; import java.util.List; @Service @@ -28,9 +29,9 @@ public class CampaignServiceImpl implements CampaignService { @Override @Transactional - public Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException { + public List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException { if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { - return null; + return Collections.emptyList(); // } List campaignOrsRequest = new ArrayList<>(); @@ -39,10 +40,10 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) for (OrsCampaignDTO campaignDTO : orsCampaignDTO) { if (campaignDTO.getFields() == null) { - continue; // or throw exception based on your requirements + continue; } - CampaignOrs campaignOrsEntity = new CampaignOrs(); // Create new entity for each DTO + CampaignOrs campaignOrsEntity = new CampaignOrs(); campaignOrsEntity.setUserId(userId); campaignOrsEntity.setCreatedBy(userName); campaignOrsEntity.setUpdatedBy(userName); @@ -52,7 +53,6 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) Integer.parseInt(campaignDTO.getFields().getNumberOfFamilies()) ); } catch (NumberFormatException e) { - // Handle invalid number format - log or throw exception throw new IEMRException("Invalid number format for families"); } @@ -61,11 +61,11 @@ public Object saveOrsCampaign(List orsCampaignDTO, String token) } if (!campaignOrsRequest.isEmpty()) { - orsCampaignRepo.saveAll(campaignOrsRequest); - return campaignOrsRequest; + List savedCampaigns = orsCampaignRepo.saveAll(campaignOrsRequest); + return savedCampaigns; } - return null; + return Collections.emptyList(); } @Override From 2a87fea8a0cf9ebf0277e90097237e4a71740094 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 16:56:57 +0530 Subject: [PATCH 723/792] api for Pulse polio campaign AMM-2105 --- .../flw/controller/CampaignController.java | 61 ++++++++++++- .../flw/domain/iemr/PulsePolioCampaign.java | 63 +++++++++++++ .../iemr/flw/dto/iemr/PolioCampaignDTO.java | 10 +++ .../flw/dto/iemr/PolioCampaignListDTO.java | 23 +++++ .../flw/repo/iemr/PulsePolioCampaignRepo.java | 13 +++ .../com/iemr/flw/service/CampaignService.java | 4 + .../flw/service/impl/CampaignServiceImpl.java | 90 ++++++++++++++++++- 7 files changed, 260 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PolioCampaignDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/PulsePolioCampaignRepo.java diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 1ca2d695..730fb46d 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -1,6 +1,7 @@ package com.iemr.flw.controller; import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.dto.iemr.PolioCampaignDTO; import com.iemr.flw.service.CampaignService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +42,7 @@ public ResponseEntity> saveOrsDistribution(@RequestBody List } } catch (Exception e) { - logger.error("Error save ors distribution :", e); + logger.error("Error save ors distribution :", e.getMessage()); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); @@ -69,7 +70,63 @@ public ResponseEntity> getAllOrsDistribution(@RequestHeader( } } catch (Exception e) { - logger.error("Error save ors distribution :", e); + logger.error("Error save ors distribution :", e.getMessage()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + + @RequestMapping(value = "polio/campaign/saveAll", method = RequestMethod.POST) + public ResponseEntity> savePolioCampaign(@RequestBody List polioCampaignDTOS, @RequestHeader(value = "jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + Object result = campaignService.savePolioCampaign(polioCampaignDTOS,token); + + + if (result != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error save polio:", e.getMessage()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + + @RequestMapping(value = "polio/campaign/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllPolioCampaign(@RequestHeader(value = "jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + List result = campaignService.getPolioCampaign(token); + + + if (result != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error save ors distribution :", e.getMessage()); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); diff --git a/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java new file mode 100644 index 00000000..446217eb --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java @@ -0,0 +1,63 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "campaign_pulse_polio",schema = "db_iemr") +@Data +public class PulsePolioCampaign { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "start_date", nullable = false) + private LocalDate startDate; + + @Column(name = "end_date", nullable = false) + private LocalDate endDate; + + @Column(name = "user_id", nullable = false) + private Integer userId; + + @Column(name = "number_of_children", nullable = false) + private Integer numberOfChildren = 0; + + /** + * Store JSON array like ["img1.jpg","img2.jpg"] + * MySQL JSON column + */ + @Column(name = "campaign_photos", columnDefinition = "json") + private String campaignPhotos; + + @Column(name = "created_by", length = 200) + private String createdBy; + + @Column(name = "updated_by", length = 200) + private String updatedBy; + + @Column(name = "created_date", updatable = false) + private LocalDateTime createdDate; + + @Column(name = "updated_date") + private LocalDateTime updatedDate; + + /* ---------- Auto timestamps ---------- */ + + @PrePersist + protected void onCreate() { + this.createdDate = LocalDateTime.now(); + this.updatedDate = LocalDateTime.now(); + } + + @PreUpdate + protected void onUpdate() { + this.updatedDate = LocalDateTime.now(); + } + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignDTO.java new file mode 100644 index 00000000..7f6cfc87 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class PolioCampaignDTO { + private Long id; + private String visitDate; + private PolioCampaignListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java new file mode 100644 index 00000000..5c172ffa --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -0,0 +1,23 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class PolioCampaignListDTO { + @JsonProperty("start_date") + private LocalDate startDate; + + @JsonProperty("end_date") + private LocalDate endDate; + + @JsonProperty("number_of_children") + private String numberOfChildren; + + @JsonProperty("campaign_photos") + private String campaignPhotos; + + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/PulsePolioCampaignRepo.java b/src/main/java/com/iemr/flw/repo/iemr/PulsePolioCampaignRepo.java new file mode 100644 index 00000000..c2cded97 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/PulsePolioCampaignRepo.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.PulsePolioCampaign; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface PulsePolioCampaignRepo extends JpaRepository { + Page findByUserId(Integer userId, Pageable pageable); +} diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index 05f1f4be..e7301665 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -1,11 +1,15 @@ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.dto.iemr.PolioCampaignDTO; import com.iemr.flw.utils.exception.IEMRException; import java.util.List; public interface CampaignService { Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; + Object savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException; List getOrsCampaign(String token) throws IEMRException; + + List getPolioCampaign(String token) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 98ae7eb2..6baade1a 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -1,9 +1,13 @@ package com.iemr.flw.service.impl; import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.OrsCampaignDTO; import com.iemr.flw.dto.iemr.OrsCampaignListDTO; +import com.iemr.flw.dto.iemr.PolioCampaignDTO; +import com.iemr.flw.dto.iemr.PolioCampaignListDTO; import com.iemr.flw.repo.iemr.OrsCampaignRepo; +import com.iemr.flw.repo.iemr.PulsePolioCampaignRepo; import com.iemr.flw.service.CampaignService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.exception.IEMRException; @@ -24,6 +28,9 @@ public class CampaignServiceImpl implements CampaignService { @Autowired private OrsCampaignRepo orsCampaignRepo; + @Autowired + private PulsePolioCampaignRepo pulsePolioCampaignRepo; + @Autowired private JwtUtil jwtUtil; @@ -79,14 +86,77 @@ public List getOrsCampaign(String token) throws IEMRException { Pageable pageable = PageRequest.of(page,pageSize); campaignOrsPage = orsCampaignRepo.findByUserId(userId,pageable); for(CampaignOrs campaignOrs:campaignOrsPage.getContent()){ - OrsCampaignDTO dto = convertToDTO(campaignOrs); + OrsCampaignDTO dto = convertOrsToDTO(campaignOrs); orsCampaignDTOSResponse.add(dto); } page++; }while (campaignOrsPage.hasNext()); return orsCampaignDTOSResponse; } - private OrsCampaignDTO convertToDTO(CampaignOrs campaign) { + + + @Override + @Transactional + public List savePolioCampaign(List orsCampaignDTO, String token) throws IEMRException { + if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { + return Collections.emptyList(); // + } + + List campaignPolioRequest = new ArrayList<>(); + Integer userId = jwtUtil.extractUserId(token); + String userName = jwtUtil.extractUsername(token); + + for (PolioCampaignDTO campaignDTO : orsCampaignDTO) { + if (campaignDTO.getFields() == null) { + continue; + } + + PulsePolioCampaign campaignPolioEntity = new PulsePolioCampaign(); + campaignPolioEntity.setUserId(userId); + campaignPolioEntity.setCreatedBy(userName); + campaignPolioEntity.setUpdatedBy(userName); + + try { + campaignPolioEntity.setNumberOfChildren( + Integer.parseInt(campaignDTO.getFields().getNumberOfChildren()) + ); + } catch (NumberFormatException e) { + throw new IEMRException("Invalid number format for families"); + } + + campaignPolioEntity.setCampaignPhotos(campaignDTO.getFields().getCampaignPhotos()); + campaignPolioRequest.add(campaignPolioEntity); + } + + if (!campaignPolioRequest.isEmpty()) { + List savedCampaigns = pulsePolioCampaignRepo.saveAll(campaignPolioRequest); + return savedCampaigns; + } + + return Collections.emptyList(); + } + + @Override + public List getPolioCampaign(String token) throws IEMRException { + Integer userId = jwtUtil.extractUserId(token); + List polioCampaignDTOSResponse = new ArrayList<>(); + int page=0; + int pageSize =10; + Page campaignPolioPage; + do{ + Pageable pageable = PageRequest.of(page,pageSize); + campaignPolioPage = pulsePolioCampaignRepo.findByUserId(userId,pageable); + for(PulsePolioCampaign campaignOrs:campaignPolioPage.getContent()){ + PolioCampaignDTO dto = convertPolioToDTO(campaignOrs); + polioCampaignDTOSResponse.add(dto); + } + page++; + }while (campaignPolioPage.hasNext()); + return polioCampaignDTOSResponse; + } + + + private OrsCampaignDTO convertOrsToDTO(CampaignOrs campaign) { OrsCampaignDTO dto = new OrsCampaignDTO(); OrsCampaignListDTO orsCampaignListDTO = new OrsCampaignListDTO(); orsCampaignListDTO.setCampaignPhotos(campaign.getCampaignPhotos()); @@ -96,4 +166,20 @@ private OrsCampaignDTO convertToDTO(CampaignOrs campaign) { dto.setFields(orsCampaignListDTO); return dto; } + + private PolioCampaignDTO convertPolioToDTO(PulsePolioCampaign campaign) { + PolioCampaignDTO dto = new PolioCampaignDTO(); + PolioCampaignListDTO polioCampaignListDTO = new PolioCampaignListDTO(); + polioCampaignListDTO.setCampaignPhotos(campaign.getCampaignPhotos()); + polioCampaignListDTO.setEndDate(campaign.getEndDate()); + polioCampaignListDTO.setStartDate(campaign.getStartDate()); + polioCampaignListDTO.setNumberOfChildren(String.valueOf(campaign.getNumberOfChildren())); + dto.setFields(polioCampaignListDTO); + return dto; + } + + + + + } From 44c18f784d2c87060130b47da3eca9e664908e40 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 15 Jan 2026 19:09:59 +0530 Subject: [PATCH 724/792] fix option parameter issue --- .../flw/controller/MaaMeetingController.java | 59 +++++++++++++------ 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java index 83741682..49c2236b 100644 --- a/src/main/java/com/iemr/flw/controller/MaaMeetingController.java +++ b/src/main/java/com/iemr/flw/controller/MaaMeetingController.java @@ -35,35 +35,56 @@ public MaaMeetingController(MaaMeetingService service) { @PostMapping(value = "/saveAll", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity saveMeeting( - @RequestPart("villageName") String villageName, - @RequestPart("noOfPragnentWoment") String noOfPragnentWomen, - @RequestPart("noOfLactingMother") String noOfLactingMother, - @RequestPart("mitaninActivityCheckList") String mitaninActivityCheckList, - @RequestPart("meetingDate") String meetingDate, - @RequestPart("place") String place, - @RequestPart("participants") String participants, - @RequestPart("ashaId") String ashaId, - @RequestPart("createdBy") String createdBy, - @RequestPart(value = "meetingImages", required = false) List meetingImages) { + + @RequestPart(value = "villageName", required = false) String villageName, + @RequestPart(value = "noOfPragnentWoment", required = false) String noOfPragnentWomen, + @RequestPart(value = "noOfLactingMother", required = false) String noOfLactingMother, + @RequestPart(value = "mitaninActivityCheckList", required = false) String mitaninActivityCheckList, + @RequestPart(value = "meetingDate") String meetingDate, + @RequestPart(value = "place", required = false) String place, + @RequestPart(value = "participants") String participants, + @RequestPart(value = "ashaId", required = false) String ashaId, + @RequestPart(value = "createdBy", required = false) String createdBy, + @RequestPart(value = "meetingImages", required = false) List meetingImages + ) { try { MaaMeetingRequestDTO dto = new MaaMeetingRequestDTO(); - dto.setMeetingDate(LocalDate.parse(meetingDate)); + + if (meetingDate != null && !meetingDate.isEmpty()) { + dto.setMeetingDate(LocalDate.parse(meetingDate)); + } + dto.setPlace(place); - dto.setParticipants(Integer.parseInt(participants)); - dto.setAshaId(Integer.parseInt(ashaId)); - dto.setCreatedBY(createdBy); dto.setVillageName(villageName); - dto.setNoOfLactingMother(Integer.parseInt(noOfLactingMother)); - dto.setNoOfPragnentWomen(Integer.parseInt(noOfPragnentWomen)); dto.setMitaninActivityCheckList(mitaninActivityCheckList); + dto.setCreatedBY(createdBy); - dto.setMeetingImages(meetingImages != null ? meetingImages.toArray(new MultipartFile[0]) : null); - if (dto != null) { - service.saveMeeting(dto); + if (participants != null && !participants.isEmpty()) { + dto.setParticipants(Integer.parseInt(participants)); + } + if (ashaId != null && !ashaId.isEmpty()) { + dto.setAshaId(Integer.parseInt(ashaId)); } + + if (noOfLactingMother != null && !noOfLactingMother.isEmpty()) { + dto.setNoOfLactingMother(Integer.parseInt(noOfLactingMother)); + } + + if (noOfPragnentWomen != null && !noOfPragnentWomen.isEmpty()) { + dto.setNoOfPragnentWomen(Integer.parseInt(noOfPragnentWomen)); + } + + if (meetingImages != null && !meetingImages.isEmpty()) { + dto.setMeetingImages(meetingImages.toArray(new MultipartFile[0])); + } + + service.saveMeeting(dto); + return ResponseEntity.ok("Saved Successfully"); + } catch (Exception e) { + e.printStackTrace(); return ResponseEntity.badRequest().body(e.getMessage()); } } From 3c91469c4c78ab7b8bfd3938f1a6405ea35a21b9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 09:45:00 +0530 Subject: [PATCH 725/792] fix request issue in ors campaign --- .../flw/controller/CampaignController.java | 75 ++++++++++--- .../iemr/flw/dto/iemr/OrsCampaignListDTO.java | 3 +- .../dto/iemr/OrsCampaignListResponseDTO.java | 15 +++ .../flw/dto/iemr/OrsCampaignResponseDTO.java | 10 ++ .../com/iemr/flw/service/CampaignService.java | 3 +- .../flw/service/impl/CampaignServiceImpl.java | 101 +++++++++++++----- 6 files changed, 163 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 730fb46d..16a0080d 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -1,18 +1,22 @@ package com.iemr.flw.controller; -import com.iemr.flw.dto.iemr.OrsCampaignDTO; -import com.iemr.flw.dto.iemr.PolioCampaignDTO; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.CampaignService; +import com.iemr.flw.utils.exception.IEMRException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; +import java.sql.Timestamp; +import java.util.*; @RestController @RequestMapping(value = "/campaign") @@ -22,28 +26,69 @@ public class CampaignController { @Autowired private CampaignService campaignService; - @RequestMapping(value = "ors/distribution/saveAll", method = RequestMethod.POST) - public ResponseEntity> saveOrsDistribution(@RequestBody List orsCampaignDTO, @RequestHeader(value = "jwtToken") String token) { + @PostMapping("/ors/distribution/saveAll") + public ResponseEntity> saveOrsDistribution( + @RequestPart("formDataJson") String fields, + @RequestPart(value = "campaignPhotos", required = false) List campaignPhotos, + @RequestHeader("jwtToken") String token) { Map response = new LinkedHashMap<>(); try { - Object result = campaignService.saveOrsCampaign(orsCampaignDTO,token); + // Validate input + if (fields == null || fields.trim().isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Form data is required"); + return ResponseEntity.badRequest().body(response); + } + + // Parse JSON to DTO + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + OrsCampaignListDTO orsCampaignFields = objectMapper.readValue(fields, OrsCampaignListDTO.class); + + // Set campaign photos if present + if (campaignPhotos != null && !campaignPhotos.isEmpty()) { + orsCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); + } + // Create DTO + OrsCampaignDTO campaignDTO = new OrsCampaignDTO(); + campaignDTO.setFields(orsCampaignFields); + + List orsCampaignDTOList = Collections.singletonList(campaignDTO); + + // Save to database + Object result = campaignService.saveOrsCampaign(orsCampaignDTOList, token); if (result != null) { - response.put("statusCode", HttpStatus.OK.value()); + response.put("statusCode", HttpStatus.CREATED.value()); + response.put("message", "Campaign saved successfully"); response.put("data", result); - return ResponseEntity.ok(response); + return ResponseEntity.status(HttpStatus.CREATED).body(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); - response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save campaign"); + return ResponseEntity.badRequest().body(response); } + } catch (JsonProcessingException e) { + logger.error("JSON parsing error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Invalid JSON format"); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.badRequest().body(response); + + } catch (IEMRException e) { + logger.error("Business logic error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", e.getMessage()); + return ResponseEntity.badRequest().body(response); + } catch (Exception e) { - logger.error("Error save ors distribution :", e.getMessage()); + logger.error("Error saving ORS distribution: {}", e.getMessage(), e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("message", "Internal server error occurred"); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } @@ -56,7 +101,7 @@ public ResponseEntity> getAllOrsDistribution(@RequestHeader( Map response = new LinkedHashMap<>(); try { - List result = campaignService.getOrsCampaign(token); + List result = campaignService.getOrsCampaign(token); if (result != null) { diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 3ed417b2..7f8b6757 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.sql.Timestamp; import java.time.LocalDate; @@ -19,7 +20,7 @@ public class OrsCampaignListDTO { private String NumberOfFamilies; @JsonProperty("campaign_photos") - private String CampaignPhotos; + private MultipartFile[] CampaignPhotos; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java new file mode 100644 index 00000000..7b8ec2da --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java @@ -0,0 +1,15 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class OrsCampaignListResponseDTO { + private Long id; + private LocalDate startDate; + private LocalDate endDate; + private String numberOfFamilies; + private List campaignPhotos; // Base64 or URLs +} \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java new file mode 100644 index 00000000..44351ddb --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class OrsCampaignResponseDTO { + private Long id; + private String visitDate; + private OrsCampaignListResponseDTO fields; +} diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index e7301665..8c690e25 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -1,6 +1,7 @@ package com.iemr.flw.service; import com.iemr.flw.dto.iemr.OrsCampaignDTO; +import com.iemr.flw.dto.iemr.OrsCampaignResponseDTO; import com.iemr.flw.dto.iemr.PolioCampaignDTO; import com.iemr.flw.utils.exception.IEMRException; @@ -9,7 +10,7 @@ public interface CampaignService { Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; Object savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException; - List getOrsCampaign(String token) throws IEMRException; + List getOrsCampaign(String token) throws IEMRException; List getPolioCampaign(String token) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 6baade1a..f8a315a8 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -1,11 +1,11 @@ package com.iemr.flw.service.impl; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.CampaignOrs; import com.iemr.flw.domain.iemr.PulsePolioCampaign; -import com.iemr.flw.dto.iemr.OrsCampaignDTO; -import com.iemr.flw.dto.iemr.OrsCampaignListDTO; -import com.iemr.flw.dto.iemr.PolioCampaignDTO; -import com.iemr.flw.dto.iemr.PolioCampaignListDTO; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.repo.iemr.OrsCampaignRepo; import com.iemr.flw.repo.iemr.PulsePolioCampaignRepo; import com.iemr.flw.service.CampaignService; @@ -17,8 +17,11 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.io.IOException; import java.util.ArrayList; +import java.util.Base64; import java.util.Collections; import java.util.List; @@ -63,7 +66,11 @@ public List saveOrsCampaign(List orsCampaignDTO, St throw new IEMRException("Invalid number format for families"); } - campaignOrsEntity.setCampaignPhotos(campaignDTO.getFields().getCampaignPhotos()); + MultipartFile[] photos = campaignDTO.getFields().getCampaignPhotos(); + if (photos != null && photos.length > 0) { + String base64Json = convertPhotosToBase64Json(photos); + campaignOrsEntity.setCampaignPhotos(base64Json); + } campaignOrsRequest.add(campaignOrsEntity); } @@ -76,21 +83,21 @@ public List saveOrsCampaign(List orsCampaignDTO, St } @Override - public List getOrsCampaign(String token) throws IEMRException { + public List getOrsCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); - List orsCampaignDTOSResponse = new ArrayList<>(); - int page=0; - int pageSize =10; + List orsCampaignDTOSResponse = new ArrayList<>(); + int page = 0; + int pageSize = 10; Page campaignOrsPage; - do{ - Pageable pageable = PageRequest.of(page,pageSize); - campaignOrsPage = orsCampaignRepo.findByUserId(userId,pageable); - for(CampaignOrs campaignOrs:campaignOrsPage.getContent()){ - OrsCampaignDTO dto = convertOrsToDTO(campaignOrs); + do { + Pageable pageable = PageRequest.of(page, pageSize); + campaignOrsPage = orsCampaignRepo.findByUserId(userId, pageable); + for (CampaignOrs campaignOrs : campaignOrsPage.getContent()) { + OrsCampaignResponseDTO dto = convertOrsToDTO(campaignOrs); orsCampaignDTOSResponse.add(dto); } page++; - }while (campaignOrsPage.hasNext()); + } while (campaignOrsPage.hasNext()); return orsCampaignDTOSResponse; } @@ -140,27 +147,29 @@ public List savePolioCampaign(List orsCamp public List getPolioCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); List polioCampaignDTOSResponse = new ArrayList<>(); - int page=0; - int pageSize =10; + int page = 0; + int pageSize = 10; Page campaignPolioPage; - do{ - Pageable pageable = PageRequest.of(page,pageSize); - campaignPolioPage = pulsePolioCampaignRepo.findByUserId(userId,pageable); - for(PulsePolioCampaign campaignOrs:campaignPolioPage.getContent()){ + do { + Pageable pageable = PageRequest.of(page, pageSize); + campaignPolioPage = pulsePolioCampaignRepo.findByUserId(userId, pageable); + for (PulsePolioCampaign campaignOrs : campaignPolioPage.getContent()) { PolioCampaignDTO dto = convertPolioToDTO(campaignOrs); polioCampaignDTOSResponse.add(dto); } page++; - }while (campaignPolioPage.hasNext()); + } while (campaignPolioPage.hasNext()); return polioCampaignDTOSResponse; } - private OrsCampaignDTO convertOrsToDTO(CampaignOrs campaign) { - OrsCampaignDTO dto = new OrsCampaignDTO(); - OrsCampaignListDTO orsCampaignListDTO = new OrsCampaignListDTO(); - orsCampaignListDTO.setCampaignPhotos(campaign.getCampaignPhotos()); - orsCampaignListDTO.setEndDate(campaign.getEndDate()); + private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { + OrsCampaignResponseDTO dto = new OrsCampaignResponseDTO(); + OrsCampaignListResponseDTO orsCampaignListDTO = new OrsCampaignListResponseDTO(); + if (campaign.getCampaignPhotos() != null) { + List photosList = parseBase64Json(campaign.getCampaignPhotos()); + orsCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches + } orsCampaignListDTO.setEndDate(campaign.getEndDate()); orsCampaignListDTO.setStartDate(campaign.getStartDate()); orsCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); dto.setFields(orsCampaignListDTO); @@ -177,9 +186,47 @@ private PolioCampaignDTO convertPolioToDTO(PulsePolioCampaign campaign) { dto.setFields(polioCampaignListDTO); return dto; } + private List parseBase64Json(String jsonString) { + try { + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.readValue(jsonString, new TypeReference>() {}); + } catch (JsonProcessingException e) { + return Collections.emptyList(); + } + } + + + private String convertPhotosToBase64Json(MultipartFile[] photos) throws IEMRException { + try { + List base64Images = new ArrayList<>(); + for (MultipartFile photo : photos) { + if (photo != null && !photo.isEmpty()) { + // Get file bytes + byte[] bytes = photo.getBytes(); + // Convert to Base64 + String base64 = Base64.getEncoder().encodeToString(bytes); + // Get content type (image/jpeg, image/png, etc.) + String contentType = photo.getContentType(); + if (contentType == null) { + contentType = "image/jpeg"; // default + } + // Create data URL format: data:image/jpeg;base64,xxxxx + String base64Image = "data:" + contentType + ";base64," + base64; + base64Images.add(base64Image); + } + } + + // Convert list to JSON array string + ObjectMapper objectMapper = new ObjectMapper(); + return objectMapper.writeValueAsString(base64Images); + } catch (IOException e) { + throw new IEMRException("Error converting photos to base64: " + e.getMessage()); + } + } } + From 58b7a06c54feda72c06745e9d5db0e45167e3e5a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 09:53:43 +0530 Subject: [PATCH 726/792] fix request issue in pulse polio campaign --- .../flw/controller/CampaignController.java | 68 +++++++++++++++---- .../flw/dto/iemr/PolioCampaignListDTO.java | 3 +- .../iemr/PolioCampaignListResponseDTO.java | 25 +++++++ .../dto/iemr/PolioCampaignResponseDTO.java | 10 +++ .../com/iemr/flw/service/CampaignService.java | 9 ++- .../flw/service/impl/CampaignServiceImpl.java | 55 ++++++++++----- 6 files changed, 136 insertions(+), 34 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 16a0080d..e11bc744 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.CampaignService; import com.iemr.flw.utils.exception.IEMRException; @@ -59,9 +60,9 @@ public ResponseEntity> saveOrsDistribution( List orsCampaignDTOList = Collections.singletonList(campaignDTO); // Save to database - Object result = campaignService.saveOrsCampaign(orsCampaignDTOList, token); + List result = campaignService.saveOrsCampaign(orsCampaignDTOList, token); - if (result != null) { + if (result != null && !result.isEmpty()) { response.put("statusCode", HttpStatus.CREATED.value()); response.put("message", "Campaign saved successfully"); response.put("data", result); @@ -123,28 +124,69 @@ public ResponseEntity> getAllOrsDistribution(@RequestHeader( } - @RequestMapping(value = "polio/campaign/saveAll", method = RequestMethod.POST) - public ResponseEntity> savePolioCampaign(@RequestBody List polioCampaignDTOS, @RequestHeader(value = "jwtToken") String token) { + @PostMapping("/polio/campaign/saveAll") + public ResponseEntity> savePolioCampaign( + @RequestPart("formDataJson") String fields, + @RequestPart(value = "campaignPhotos", required = false) List campaignPhotos, + @RequestHeader("jwtToken") String token) { Map response = new LinkedHashMap<>(); try { - Object result = campaignService.savePolioCampaign(polioCampaignDTOS,token); + // Validate input + if (fields == null || fields.trim().isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Form data is required"); + return ResponseEntity.badRequest().body(response); + } + // Parse JSON to DTO + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + PolioCampaignListDTO polioCampaignFields = objectMapper.readValue(fields, PolioCampaignListDTO.class); - if (result != null) { - response.put("statusCode", HttpStatus.OK.value()); + // Set campaign photos if present + if (campaignPhotos != null && !campaignPhotos.isEmpty()) { + polioCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); + } + + // Create DTO + PolioCampaignDTO campaignDTO = new PolioCampaignDTO(); + campaignDTO.setFields(polioCampaignFields); + + List polioCampaignDTOList = Collections.singletonList(campaignDTO); + + // Save to database + List result = campaignService.savePolioCampaign(polioCampaignDTOList, token); + + if (result != null && !result.isEmpty()) { + response.put("statusCode", HttpStatus.CREATED.value()); + response.put("message", "Polio campaign saved successfully"); response.put("data", result); - return ResponseEntity.ok(response); + return ResponseEntity.status(HttpStatus.CREATED).body(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); - response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save polio campaign"); + return ResponseEntity.badRequest().body(response); } + } catch (JsonProcessingException e) { + logger.error("JSON parsing error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Invalid JSON format"); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.badRequest().body(response); + + } catch (IEMRException e) { + logger.error("Business logic error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", e.getMessage()); + return ResponseEntity.badRequest().body(response); + } catch (Exception e) { - logger.error("Error save polio:", e.getMessage()); + logger.error("Error saving polio campaign: {}", e.getMessage(), e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("message", "Internal server error occurred"); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } @@ -157,7 +199,7 @@ public ResponseEntity> getAllPolioCampaign(@RequestHeader(va Map response = new LinkedHashMap<>(); try { - List result = campaignService.getPolioCampaign(token); + List result = campaignService.getPolioCampaign(token); if (result != null) { diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java index 5c172ffa..649d3adf 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; +import org.springframework.web.multipart.MultipartFile; import java.time.LocalDate; @@ -17,7 +18,7 @@ public class PolioCampaignListDTO { private String numberOfChildren; @JsonProperty("campaign_photos") - private String campaignPhotos; + private MultipartFile[] campaignPhotos; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java new file mode 100644 index 00000000..603d1676 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java @@ -0,0 +1,25 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import org.springframework.web.multipart.MultipartFile; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class PolioCampaignListResponseDTO { + @JsonProperty("start_date") + private LocalDate startDate; + + @JsonProperty("end_date") + private LocalDate endDate; + + @JsonProperty("number_of_children") + private String numberOfChildren; + + @JsonProperty("campaign_photos") + private List campaignPhotos; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java new file mode 100644 index 00000000..06370ac0 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class PolioCampaignResponseDTO { + private Long id; + private String visitDate; + private PolioCampaignListResponseDTO fields; +} diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index 8c690e25..f443c0ed 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -1,16 +1,19 @@ package com.iemr.flw.service; +import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.OrsCampaignDTO; import com.iemr.flw.dto.iemr.OrsCampaignResponseDTO; import com.iemr.flw.dto.iemr.PolioCampaignDTO; +import com.iemr.flw.dto.iemr.PolioCampaignResponseDTO; import com.iemr.flw.utils.exception.IEMRException; import java.util.List; public interface CampaignService { - Object saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; - Object savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException; + List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; + List savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException; List getOrsCampaign(String token) throws IEMRException; - List getPolioCampaign(String token) throws IEMRException; + List getPolioCampaign(String token) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index f8a315a8..e1f2c1c0 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -104,16 +104,18 @@ public List getOrsCampaign(String token) throws IEMRExce @Override @Transactional - public List savePolioCampaign(List orsCampaignDTO, String token) throws IEMRException { - if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { - return Collections.emptyList(); // + public List savePolioCampaign(List polioCampaignDTOs, String token) + throws IEMRException { + + if (polioCampaignDTOs == null || polioCampaignDTOs.isEmpty()) { + throw new IEMRException("Campaign data is required"); } List campaignPolioRequest = new ArrayList<>(); Integer userId = jwtUtil.extractUserId(token); String userName = jwtUtil.extractUsername(token); - for (PolioCampaignDTO campaignDTO : orsCampaignDTO) { + for (PolioCampaignDTO campaignDTO : polioCampaignDTOs) { if (campaignDTO.getFields() == null) { continue; } @@ -123,15 +125,29 @@ public List savePolioCampaign(List orsCamp campaignPolioEntity.setCreatedBy(userName); campaignPolioEntity.setUpdatedBy(userName); + // Set start and end dates + campaignPolioEntity.setStartDate(campaignDTO.getFields().getStartDate()); + campaignPolioEntity.setEndDate(campaignDTO.getFields().getEndDate()); + + // Parse number of children try { - campaignPolioEntity.setNumberOfChildren( - Integer.parseInt(campaignDTO.getFields().getNumberOfChildren()) - ); + String childrenStr = campaignDTO.getFields().getNumberOfChildren(); + if (childrenStr != null && !childrenStr.trim().isEmpty()) { + campaignPolioEntity.setNumberOfChildren(Integer.parseInt(childrenStr)); + } else { + campaignPolioEntity.setNumberOfChildren(0); + } } catch (NumberFormatException e) { - throw new IEMRException("Invalid number format for families"); + throw new IEMRException("Invalid number format for children: " + e.getMessage()); + } + + // Convert photos to base64 JSON array + MultipartFile[] photos = campaignDTO.getFields().getCampaignPhotos(); + if (photos != null && photos.length > 0) { + String base64Json = convertPhotosToBase64Json(photos); + campaignPolioEntity.setCampaignPhotos(base64Json); } - campaignPolioEntity.setCampaignPhotos(campaignDTO.getFields().getCampaignPhotos()); campaignPolioRequest.add(campaignPolioEntity); } @@ -140,13 +156,14 @@ public List savePolioCampaign(List orsCamp return savedCampaigns; } - return Collections.emptyList(); + throw new IEMRException("No valid campaign data to save"); } + @Override - public List getPolioCampaign(String token) throws IEMRException { + public List getPolioCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); - List polioCampaignDTOSResponse = new ArrayList<>(); + List polioCampaignDTOSResponse = new ArrayList<>(); int page = 0; int pageSize = 10; Page campaignPolioPage; @@ -154,7 +171,7 @@ public List getPolioCampaign(String token) throws IEMRExceptio Pageable pageable = PageRequest.of(page, pageSize); campaignPolioPage = pulsePolioCampaignRepo.findByUserId(userId, pageable); for (PulsePolioCampaign campaignOrs : campaignPolioPage.getContent()) { - PolioCampaignDTO dto = convertPolioToDTO(campaignOrs); + PolioCampaignResponseDTO dto = convertPolioToDTO(campaignOrs); polioCampaignDTOSResponse.add(dto); } page++; @@ -170,16 +187,20 @@ private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { List photosList = parseBase64Json(campaign.getCampaignPhotos()); orsCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches } orsCampaignListDTO.setEndDate(campaign.getEndDate()); + orsCampaignListDTO.setStartDate(campaign.getStartDate()); orsCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); dto.setFields(orsCampaignListDTO); return dto; } - private PolioCampaignDTO convertPolioToDTO(PulsePolioCampaign campaign) { - PolioCampaignDTO dto = new PolioCampaignDTO(); - PolioCampaignListDTO polioCampaignListDTO = new PolioCampaignListDTO(); - polioCampaignListDTO.setCampaignPhotos(campaign.getCampaignPhotos()); + private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) { + PolioCampaignResponseDTO dto = new PolioCampaignResponseDTO(); + PolioCampaignListResponseDTO polioCampaignListDTO = new PolioCampaignListResponseDTO(); + if (campaign.getCampaignPhotos() != null) { + List photosList = parseBase64Json(campaign.getCampaignPhotos()); + polioCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches + } polioCampaignListDTO.setEndDate(campaign.getEndDate()); polioCampaignListDTO.setStartDate(campaign.getStartDate()); polioCampaignListDTO.setNumberOfChildren(String.valueOf(campaign.getNumberOfChildren())); From 9e0349902ef8988d60ba306ca13cae14d66d1c12 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 12:26:57 +0530 Subject: [PATCH 727/792] fix request issue in ors and pulse polio campaign --- .../flw/controller/CampaignController.java | 138 +++++++++++++++++- 1 file changed, 130 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index e11bc744..7b9daf3e 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -1,6 +1,7 @@ package com.iemr.flw.controller; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.iemr.flw.domain.iemr.CampaignOrs; @@ -30,12 +31,13 @@ public class CampaignController { @PostMapping("/ors/distribution/saveAll") public ResponseEntity> saveOrsDistribution( @RequestPart("formDataJson") String fields, - @RequestPart(value = "campaignPhotos", required = false) List campaignPhotos, @RequestHeader("jwtToken") String token) { Map response = new LinkedHashMap<>(); try { + logger.info("Received formDataJson: {}", fields.substring(0, Math.min(100, fields.length()))); // Log first 100 chars + // Validate input if (fields == null || fields.trim().isEmpty()) { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); @@ -46,16 +48,27 @@ public ResponseEntity> saveOrsDistribution( // Parse JSON to DTO ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JavaTimeModule()); - OrsCampaignListDTO orsCampaignFields = objectMapper.readValue(fields, OrsCampaignListDTO.class); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - // Set campaign photos if present - if (campaignPhotos != null && !campaignPhotos.isEmpty()) { - orsCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); + OrsCampaignDTO requestDTO = objectMapper.readValue(fields, OrsCampaignDTO.class); + + // Validate fields + if (requestDTO.getFields() == null) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Campaign fields are required"); + return ResponseEntity.badRequest().body(response); } + logger.info("Parsed DTO - Start Date: {}, End Date: {}, Families: {}, Photos: {}", + requestDTO.getFields().getStartDate(), + requestDTO.getFields().getEndDate(), + requestDTO.getFields().getNumberOfFamilies(), + requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().length : 0 + ); + // Create DTO OrsCampaignDTO campaignDTO = new OrsCampaignDTO(); - campaignDTO.setFields(orsCampaignFields); + campaignDTO.setFields(requestDTO.getFields()); List orsCampaignDTOList = Collections.singletonList(campaignDTO); @@ -126,6 +139,115 @@ public ResponseEntity> getAllOrsDistribution(@RequestHeader( @PostMapping("/polio/campaign/saveAll") public ResponseEntity> savePolioCampaign( + @RequestPart("formDataJson") String fields, + @RequestHeader("jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + logger.info("Received filariasis campaign data"); + + // Validate input + if (fields == null || fields.trim().isEmpty()) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Form data is required"); + return ResponseEntity.badRequest().body(response); + } + + // Parse JSON to DTO + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.registerModule(new JavaTimeModule()); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + PolioCampaignDTO requestDTO = objectMapper.readValue(fields, PolioCampaignDTO.class); + + // Validate fields + if (requestDTO.getFields() == null) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Campaign fields are required"); + return ResponseEntity.badRequest().body(response); + } + + logger.info("Parsed DTO - Start Date: {}, End Date: {}, Families: {}, Individuals: {}, Photos: {}", + requestDTO.getFields().getStartDate(), + requestDTO.getFields().getEndDate(), + requestDTO.getFields().getNumberOfChildren(), + requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().length : 0 + ); + + // Create DTO + PolioCampaignDTO campaignDTO = new PolioCampaignDTO(); + campaignDTO.setFields(requestDTO.getFields()); + + List filariasisCampaignDTOList = Collections.singletonList(campaignDTO); + + // Save to database + List result = campaignService.savePolioCampaign(filariasisCampaignDTOList, token); + + if (result != null && !result.isEmpty()) { + response.put("statusCode", HttpStatus.CREATED.value()); + response.put("message", "Filariasis (MDA) campaign saved successfully"); + response.put("data", result); + return ResponseEntity.status(HttpStatus.CREATED).body(response); + } else { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Failed to save filariasis campaign"); + return ResponseEntity.badRequest().body(response); + } + + } catch (JsonProcessingException e) { + logger.error("JSON parsing error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Invalid JSON format"); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.badRequest().body(response); + + } catch (IEMRException e) { + logger.error("Business logic error: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", e.getMessage()); + return ResponseEntity.badRequest().body(response); + + } catch (Exception e) { + logger.error("Error saving filariasis campaign: {}", e.getMessage(), e); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("message", "Internal server error occurred"); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + + @RequestMapping(value = "polio/campaign/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllPolioCampaign(@RequestHeader(value = "jwtToken") String token) { + + Map response = new LinkedHashMap<>(); + + try { + List result = campaignService.getPolioCampaign(token); + + + if (result != null) { + response.put("statusCode", HttpStatus.OK.value()); + response.put("data", result); + return ResponseEntity.ok(response); + } else { + response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("message", "No records found"); + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + } + + } catch (Exception e) { + logger.error("Error save ors distribution :", e.getMessage()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("errorMessage", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); + } + } + + + @PostMapping("/filariasis/campaign/saveAll") + public ResponseEntity> saveFilariasisCampaign( @RequestPart("formDataJson") String fields, @RequestPart(value = "campaignPhotos", required = false) List campaignPhotos, @RequestHeader("jwtToken") String token) { @@ -193,8 +315,8 @@ public ResponseEntity> savePolioCampaign( } - @RequestMapping(value = "polio/campaign/getAll", method = RequestMethod.POST) - public ResponseEntity> getAllPolioCampaign(@RequestHeader(value = "jwtToken") String token) { + @RequestMapping(value = "filariasis/campaign/getAll", method = RequestMethod.POST) + public ResponseEntity> getAllFilariasisCampaign(@RequestHeader(value = "jwtToken") String token) { Map response = new LinkedHashMap<>(); From 46eb10cb6fd9ba2c7c0845ca3478ee95341934dd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 12:34:35 +0530 Subject: [PATCH 728/792] make changes in tb api --- .../com/iemr/flw/controller/TBController.java | 15 ++- .../com/iemr/flw/domain/iemr/TBScreening.java | 113 ++++++++++++++--- .../com/iemr/flw/dto/iemr/TBScreeningDTO.java | 120 +++--------------- 3 files changed, 120 insertions(+), 128 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index 6beb9008..39f119e2 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -42,9 +42,9 @@ public String getAllScreeningByUserId(@RequestBody GetBenRequestHandler requestD if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in tb screening get data : " + e); response.setError(5000, "Error in tb screening get data : " + e); @@ -66,9 +66,9 @@ public String saveAllScreeningByUserId(@RequestBody TBScreeningRequestDTO reques if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in save tb screening details : " + e); response.setError(5000, "Error in save tb suspected details : " + e); @@ -91,12 +91,12 @@ public String getAllSuspectedByUserId(@RequestBody GetBenRequestHandler requestD if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in get data : " + e); - response.setError(5000, "Error in get data : " + e); + response.setError(500, "Error in get data : " + e); } return response.toString(); } @@ -124,4 +124,5 @@ public String saveAllSuspectedByUserId(@RequestBody TBSuspectedRequestDTO reques } return response.toString(); } + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java index 9bf7ea8d..3b6af4fa 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java @@ -4,9 +4,10 @@ import jakarta.persistence.*; import java.sql.Timestamp; +import java.time.LocalDateTime; @Entity -@Table(name = "tb_screening", schema = "db_iemr") +@Table(name = "screening_tb", schema = "db_iemr") @Data public class TBScreening { @@ -23,27 +24,105 @@ public class TBScreening { @Column(name = "visit_date") private Timestamp visitDate; - @Column(name = "cough_check") - private Boolean coughMoreThan2Weeks; + @Column(name = "visit_code", nullable = false) + private Long visitCode; - @Column(name = "blood_check") - private Boolean bloodInSputum; + // Visit Information + @Column(name = "visit_label", length = 100, nullable = false) + private String visitLabel; - @Column(name = "fever_check") - private Boolean feverMoreThan2Weeks; + @Column(name = "type_of_tb_case", length = 50, nullable = false) + private String typeOfTBCase; - @Column(name = "weight_check") - private Boolean lossOfWeight; + @Column(name = "reason_for_suspicion", length = 500) + private String reasonForSuspicion; - @Column(name = "sweats_check") - private Boolean nightSweats; + // Symptoms + @Column(name = "has_symptoms", nullable = false) + private Boolean hasSymptoms = false; - @Column(name = "history_check") - private Boolean historyOfTb; + // Sputum Test + @Column(name = "is_sputum_collected") + private Boolean isSputumCollected; - @Column(name = "drugs_check") - private Boolean takingAntiTBDrugs; + @Column(name = "sputum_submitted_at", length = 200) + private String sputumSubmittedAt; - @Column(name = "family_check") - private Boolean familySufferingFromTB; + @Column(name = "nikshay_id", length = 50) + private String nikshayId; + + @Column(name = "sputum_test_result", length = 50) + private String sputumTestResult; + + // Chest X-Ray + @Column(name = "is_chest_xray_done") + private Boolean isChestXRayDone; + + @Column(name = "chest_xray_result", length = 100) + private String chestXRayResult; + + // Referral & Confirmation + @Column(name = "referral_facility", length = 200) + private String referralFacility; + + @Column(name = "is_tb_confirmed") + private Boolean isTBConfirmed; + + @Column(name = "is_drtb_confirmed") + private Boolean isDRTBConfirmed; + + @Column(name = "is_confirmed", nullable = false) + private Boolean isConfirmed = false; + + @Column(name = "referred") + private Boolean referred; + + @Column(name = "follow_ups", columnDefinition = "TEXT") + private String followUps; + + + @Column(name = "provider_service_map_id") + private Integer providerServiceMapId; + + @Column(name = "created_by", length = 200) + private String createdBy; + + @Column(name = "updated_by", length = 200) + private String updatedBy; + + @Column(name = "created_date", updatable = false) + private LocalDateTime createdDate; + + @Column(name = "updated_date") + private LocalDateTime updatedDate; + + @Column(name = "deleted") + private Boolean deleted = false; + + @Column(name = "processed", length = 4) + private String processed = "N"; + + @PrePersist + protected void onCreate() { + this.createdDate = LocalDateTime.now(); + this.updatedDate = LocalDateTime.now(); + if (this.hasSymptoms == null) { + this.hasSymptoms = false; + } + if (this.isConfirmed == null) { + this.isConfirmed = false; + } + + if (this.deleted == null) { + this.deleted = false; + } + if (this.processed == null) { + this.processed = "N"; + } + } + + @PreUpdate + protected void onUpdate() { + this.updatedDate = LocalDateTime.now(); + } } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java index 270526bd..9b30b5ba 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java @@ -12,108 +12,20 @@ public class TBScreeningDTO { private Long benId; private Timestamp visitDate; - - private Boolean coughMoreThan2Weeks; - - private Boolean bloodInSputum; - - private Boolean feverMoreThan2Weeks; - - private Boolean lossOfWeight; - - private Boolean nightSweats; - - private Boolean historyOfTb; - - private Boolean takingAntiTBDrugs; - - private Boolean familySufferingFromTB; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getBenId() { - return benId; - } - - public void setBenId(Long benId) { - this.benId = benId; - } - - public Timestamp getVisitDate() { - return visitDate; - } - - public void setVisitDate(Timestamp visitDate) { - this.visitDate = visitDate; - } - - public Boolean getCoughMoreThan2Weeks() { - return coughMoreThan2Weeks; - } - - public void setCoughMoreThan2Weeks(Boolean coughMoreThan2Weeks) { - this.coughMoreThan2Weeks = coughMoreThan2Weeks; - } - - public Boolean getBloodInSputum() { - return bloodInSputum; - } - - public void setBloodInSputum(Boolean bloodInSputum) { - this.bloodInSputum = bloodInSputum; - } - - public Boolean getFeverMoreThan2Weeks() { - return feverMoreThan2Weeks; - } - - public void setFeverMoreThan2Weeks(Boolean feverMoreThan2Weeks) { - this.feverMoreThan2Weeks = feverMoreThan2Weeks; - } - - public Boolean getLossOfWeight() { - return lossOfWeight; - } - - public void setLossOfWeight(Boolean lossOfWeight) { - this.lossOfWeight = lossOfWeight; - } - - public Boolean getNightSweats() { - return nightSweats; - } - - public void setNightSweats(Boolean nightSweats) { - this.nightSweats = nightSweats; - } - - public Boolean getHistoryOfTb() { - return historyOfTb; - } - - public void setHistoryOfTb(Boolean historyOfTb) { - this.historyOfTb = historyOfTb; - } - - public Boolean getTakingAntiTBDrugs() { - return takingAntiTBDrugs; - } - - public void setTakingAntiTBDrugs(Boolean takingAntiTBDrugs) { - this.takingAntiTBDrugs = takingAntiTBDrugs; - } - - public Boolean getFamilySufferingFromTB() { - return familySufferingFromTB; - } - - public void setFamilySufferingFromTB(Boolean familySufferingFromTB) { - this.familySufferingFromTB = familySufferingFromTB; - } + private String visitLabel; + private String typeOfTBCase; + private String reasonForSuspicion; + private Boolean hasSymptoms; + private Boolean isSputumCollected; + private String sputumSubmittedAt; + private String nikshayId; + private String sputumTestResult; + private Boolean isChestXRayDone; + private String chestXRayResult; + private String referralFacility; + private Boolean isTBConfirmed; + private Boolean isDRTBConfirmed; + private Boolean isConfirmed = false; + private Boolean referred; + private String followUps; } From e96c8a8e8ad1f198d28858d62644ec3f3a660d0e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 12:50:31 +0530 Subject: [PATCH 729/792] make tb api changes --- .../com/iemr/flw/controller/TBController.java | 4 +- .../com/iemr/flw/domain/iemr/TBScreening.java | 113 +++-------------- .../com/iemr/flw/domain/iemr/TBSuspected.java | 43 +++++++ .../com/iemr/flw/dto/iemr/TBScreeningDTO.java | 120 +++++++++++++++--- .../com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 19 +-- 5 files changed, 177 insertions(+), 122 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index 39f119e2..56afcb98 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -115,9 +115,9 @@ public String saveAllSuspectedByUserId(@RequestBody TBSuspectedRequestDTO reques if (s != null) response.setResponse(s); else - response.setError(5000, "No record found"); + response.setError(500, "No record found"); } else - response.setError(5000, "Invalid/NULL request obj"); + response.setError(500, "Invalid/NULL request obj"); } catch (Exception e) { logger.error("Error in save tb suspected details : " + e); response.setError(5000, "Error in save tb suspected details : " + e); diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java index 3b6af4fa..9bf7ea8d 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java @@ -4,10 +4,9 @@ import jakarta.persistence.*; import java.sql.Timestamp; -import java.time.LocalDateTime; @Entity -@Table(name = "screening_tb", schema = "db_iemr") +@Table(name = "tb_screening", schema = "db_iemr") @Data public class TBScreening { @@ -24,105 +23,27 @@ public class TBScreening { @Column(name = "visit_date") private Timestamp visitDate; - @Column(name = "visit_code", nullable = false) - private Long visitCode; + @Column(name = "cough_check") + private Boolean coughMoreThan2Weeks; - // Visit Information - @Column(name = "visit_label", length = 100, nullable = false) - private String visitLabel; + @Column(name = "blood_check") + private Boolean bloodInSputum; - @Column(name = "type_of_tb_case", length = 50, nullable = false) - private String typeOfTBCase; + @Column(name = "fever_check") + private Boolean feverMoreThan2Weeks; - @Column(name = "reason_for_suspicion", length = 500) - private String reasonForSuspicion; + @Column(name = "weight_check") + private Boolean lossOfWeight; - // Symptoms - @Column(name = "has_symptoms", nullable = false) - private Boolean hasSymptoms = false; + @Column(name = "sweats_check") + private Boolean nightSweats; - // Sputum Test - @Column(name = "is_sputum_collected") - private Boolean isSputumCollected; + @Column(name = "history_check") + private Boolean historyOfTb; - @Column(name = "sputum_submitted_at", length = 200) - private String sputumSubmittedAt; + @Column(name = "drugs_check") + private Boolean takingAntiTBDrugs; - @Column(name = "nikshay_id", length = 50) - private String nikshayId; - - @Column(name = "sputum_test_result", length = 50) - private String sputumTestResult; - - // Chest X-Ray - @Column(name = "is_chest_xray_done") - private Boolean isChestXRayDone; - - @Column(name = "chest_xray_result", length = 100) - private String chestXRayResult; - - // Referral & Confirmation - @Column(name = "referral_facility", length = 200) - private String referralFacility; - - @Column(name = "is_tb_confirmed") - private Boolean isTBConfirmed; - - @Column(name = "is_drtb_confirmed") - private Boolean isDRTBConfirmed; - - @Column(name = "is_confirmed", nullable = false) - private Boolean isConfirmed = false; - - @Column(name = "referred") - private Boolean referred; - - @Column(name = "follow_ups", columnDefinition = "TEXT") - private String followUps; - - - @Column(name = "provider_service_map_id") - private Integer providerServiceMapId; - - @Column(name = "created_by", length = 200) - private String createdBy; - - @Column(name = "updated_by", length = 200) - private String updatedBy; - - @Column(name = "created_date", updatable = false) - private LocalDateTime createdDate; - - @Column(name = "updated_date") - private LocalDateTime updatedDate; - - @Column(name = "deleted") - private Boolean deleted = false; - - @Column(name = "processed", length = 4) - private String processed = "N"; - - @PrePersist - protected void onCreate() { - this.createdDate = LocalDateTime.now(); - this.updatedDate = LocalDateTime.now(); - if (this.hasSymptoms == null) { - this.hasSymptoms = false; - } - if (this.isConfirmed == null) { - this.isConfirmed = false; - } - - if (this.deleted == null) { - this.deleted = false; - } - if (this.processed == null) { - this.processed = "N"; - } - } - - @PreUpdate - protected void onUpdate() { - this.updatedDate = LocalDateTime.now(); - } + @Column(name = "family_check") + private Boolean familySufferingFromTB; } diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 7cb945a8..481e613d 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -40,4 +40,47 @@ public class TBSuspected { @Column(name = "followups") private String followUps; + + @Column(name = "visit_code", nullable = false) + private Long visitCode; + + // Visit Information + @Column(name = "visit_label", length = 100, nullable = false) + private String visitLabel; + + @Column(name = "type_of_tb_case", length = 50, nullable = false) + private String typeOfTBCase; + + @Column(name = "reason_for_suspicion", length = 500) + private String reasonForSuspicion; + + // Symptoms + @Column(name = "has_symptoms", nullable = false) + private Boolean hasSymptoms = false; + + // Chest X-Ray + @Column(name = "is_chest_xray_done") + private Boolean isChestXRayDone; + + @Column(name = "chest_xray_result", length = 100) + private String chestXRayResult; + + // Referral & Confirmation + @Column(name = "referral_facility", length = 200) + private String referralFacility; + + @Column(name = "is_tb_confirmed") + private Boolean isTBConfirmed; + + @Column(name = "is_drtb_confirmed") + private Boolean isDRTBConfirmed; + + @Column(name = "is_confirmed", nullable = false) + private Boolean isConfirmed = false; + + @Column(name = "provider_service_map_id") + private Integer providerServiceMapId; + + + } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java index 9b30b5ba..270526bd 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java @@ -12,20 +12,108 @@ public class TBScreeningDTO { private Long benId; private Timestamp visitDate; - private String visitLabel; - private String typeOfTBCase; - private String reasonForSuspicion; - private Boolean hasSymptoms; - private Boolean isSputumCollected; - private String sputumSubmittedAt; - private String nikshayId; - private String sputumTestResult; - private Boolean isChestXRayDone; - private String chestXRayResult; - private String referralFacility; - private Boolean isTBConfirmed; - private Boolean isDRTBConfirmed; - private Boolean isConfirmed = false; - private Boolean referred; - private String followUps; + + private Boolean coughMoreThan2Weeks; + + private Boolean bloodInSputum; + + private Boolean feverMoreThan2Weeks; + + private Boolean lossOfWeight; + + private Boolean nightSweats; + + private Boolean historyOfTb; + + private Boolean takingAntiTBDrugs; + + private Boolean familySufferingFromTB; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getBenId() { + return benId; + } + + public void setBenId(Long benId) { + this.benId = benId; + } + + public Timestamp getVisitDate() { + return visitDate; + } + + public void setVisitDate(Timestamp visitDate) { + this.visitDate = visitDate; + } + + public Boolean getCoughMoreThan2Weeks() { + return coughMoreThan2Weeks; + } + + public void setCoughMoreThan2Weeks(Boolean coughMoreThan2Weeks) { + this.coughMoreThan2Weeks = coughMoreThan2Weeks; + } + + public Boolean getBloodInSputum() { + return bloodInSputum; + } + + public void setBloodInSputum(Boolean bloodInSputum) { + this.bloodInSputum = bloodInSputum; + } + + public Boolean getFeverMoreThan2Weeks() { + return feverMoreThan2Weeks; + } + + public void setFeverMoreThan2Weeks(Boolean feverMoreThan2Weeks) { + this.feverMoreThan2Weeks = feverMoreThan2Weeks; + } + + public Boolean getLossOfWeight() { + return lossOfWeight; + } + + public void setLossOfWeight(Boolean lossOfWeight) { + this.lossOfWeight = lossOfWeight; + } + + public Boolean getNightSweats() { + return nightSweats; + } + + public void setNightSweats(Boolean nightSweats) { + this.nightSweats = nightSweats; + } + + public Boolean getHistoryOfTb() { + return historyOfTb; + } + + public void setHistoryOfTb(Boolean historyOfTb) { + this.historyOfTb = historyOfTb; + } + + public Boolean getTakingAntiTBDrugs() { + return takingAntiTBDrugs; + } + + public void setTakingAntiTBDrugs(Boolean takingAntiTBDrugs) { + this.takingAntiTBDrugs = takingAntiTBDrugs; + } + + public Boolean getFamilySufferingFromTB() { + return familySufferingFromTB; + } + + public void setFamilySufferingFromTB(Boolean familySufferingFromTB) { + this.familySufferingFromTB = familySufferingFromTB; + } } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 8d224a9c..b44e0ed4 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -10,18 +10,21 @@ public class TBSuspectedDTO { private Long id; private Long benId; - - private Timestamp visitDate; - + private Long visitCode; + private String visitLabel; + private String typeOfTBCase; + private String reasonForSuspicion; + private Boolean hasSymptoms; private Boolean isSputumCollected; - private String sputumSubmittedAt; - private String nikshayId; - private String sputumTestResult; - + private Boolean isChestXRayDone; + private String chestXRayResult; + private String referralFacility; + private Boolean isTBConfirmed; + private Boolean isDRTBConfirmed; + private Boolean isConfirmed; private Boolean referred; - private String followUps; } From 27f033a02629fdb0821811c58a5309743d8a04d0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 12:57:23 +0530 Subject: [PATCH 730/792] fix date issue in request --- src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java | 3 +++ src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 7f8b6757..5c92c3ac 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; import lombok.Data; @@ -10,9 +11,11 @@ @Data public class OrsCampaignListDTO { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") @JsonProperty("start_date") private LocalDate StartDate; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") @JsonProperty("end_date") private LocalDate EndDate; diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java index 649d3adf..86a2c6d6 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import org.springframework.web.multipart.MultipartFile; @@ -8,9 +9,11 @@ @Data public class PolioCampaignListDTO { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") @JsonProperty("start_date") private LocalDate startDate; + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") @JsonProperty("end_date") private LocalDate endDate; From 9964f790176ceeb7b2ab530a7fa0b24009c4747e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 13:14:05 +0530 Subject: [PATCH 731/792] fix image issue --- .../flw/controller/CampaignController.java | 7 ++- .../iemr/flw/dto/iemr/OrsCampaignListDTO.java | 3 +- .../flw/dto/iemr/PolioCampaignListDTO.java | 3 +- .../flw/service/impl/CampaignServiceImpl.java | 58 ++++++++++--------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 7b9daf3e..5304784a 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -63,7 +63,7 @@ public ResponseEntity> saveOrsDistribution( requestDTO.getFields().getStartDate(), requestDTO.getFields().getEndDate(), requestDTO.getFields().getNumberOfFamilies(), - requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().length : 0 + requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().size() : 0 ); // Create DTO @@ -172,7 +172,8 @@ public ResponseEntity> savePolioCampaign( requestDTO.getFields().getStartDate(), requestDTO.getFields().getEndDate(), requestDTO.getFields().getNumberOfChildren(), - requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().length : 0 + + requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().size() : 0 ); // Create DTO @@ -269,7 +270,7 @@ public ResponseEntity> saveFilariasisCampaign( // Set campaign photos if present if (campaignPhotos != null && !campaignPhotos.isEmpty()) { - polioCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); + // polioCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); } // Create DTO diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 5c92c3ac..552c4fc8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -8,6 +8,7 @@ import java.sql.Timestamp; import java.time.LocalDate; +import java.util.List; @Data public class OrsCampaignListDTO { @@ -23,7 +24,7 @@ public class OrsCampaignListDTO { private String NumberOfFamilies; @JsonProperty("campaign_photos") - private MultipartFile[] CampaignPhotos; + private List campaignPhotos; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java index 86a2c6d6..670e790b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -6,6 +6,7 @@ import org.springframework.web.multipart.MultipartFile; import java.time.LocalDate; +import java.util.List; @Data public class PolioCampaignListDTO { @@ -21,7 +22,7 @@ public class PolioCampaignListDTO { private String numberOfChildren; @JsonProperty("campaign_photos") - private MultipartFile[] campaignPhotos; + private List campaignPhotos; // base64 strings } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index e1f2c1c0..45992c98 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -66,11 +66,21 @@ public List saveOrsCampaign(List orsCampaignDTO, St throw new IEMRException("Invalid number format for families"); } - MultipartFile[] photos = campaignDTO.getFields().getCampaignPhotos(); - if (photos != null && photos.length > 0) { - String base64Json = convertPhotosToBase64Json(photos); - campaignOrsEntity.setCampaignPhotos(base64Json); + List photos = campaignDTO.getFields().getCampaignPhotos(); + + if (photos != null && !photos.isEmpty()) { + + // remove null / empty / invalid entries + List validPhotos = photos.stream() + .filter(p -> p != null && !p.trim().isEmpty()) + .toList(); + + if (!validPhotos.isEmpty()) { + String base64Json = convertPhotosToBase64Json(validPhotos); + campaignOrsEntity.setCampaignPhotos(base64Json); + } } + campaignOrsRequest.add(campaignOrsEntity); } @@ -142,12 +152,14 @@ public List savePolioCampaign(List polioCa } // Convert photos to base64 JSON array - MultipartFile[] photos = campaignDTO.getFields().getCampaignPhotos(); - if (photos != null && photos.length > 0) { + List photos = campaignDTO.getFields().getCampaignPhotos(); + + if (photos != null && !photos.isEmpty()) { String base64Json = convertPhotosToBase64Json(photos); campaignPolioEntity.setCampaignPhotos(base64Json); } + campaignPolioRequest.add(campaignPolioEntity); } @@ -217,37 +229,29 @@ private List parseBase64Json(String jsonString) { } - private String convertPhotosToBase64Json(MultipartFile[] photos) throws IEMRException { + private String convertPhotosToBase64Json(List photos) throws IEMRException { try { - List base64Images = new ArrayList<>(); + List cleanedBase64Images = new ArrayList<>(); - for (MultipartFile photo : photos) { - if (photo != null && !photo.isEmpty()) { - // Get file bytes - byte[] bytes = photo.getBytes(); + for (String photo : photos) { + if (photo != null && !photo.trim().isEmpty()) { - // Convert to Base64 - String base64 = Base64.getEncoder().encodeToString(bytes); + // remove data:image/...;base64, if present + String cleanBase64 = photo.contains(",") + ? photo.substring(photo.indexOf(",") + 1) + : photo; - // Get content type (image/jpeg, image/png, etc.) - String contentType = photo.getContentType(); - if (contentType == null) { - contentType = "image/jpeg"; // default - } - - // Create data URL format: data:image/jpeg;base64,xxxxx - String base64Image = "data:" + contentType + ";base64," + base64; - base64Images.add(base64Image); + cleanedBase64Images.add(cleanBase64); } } - // Convert list to JSON array string ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.writeValueAsString(base64Images); + return objectMapper.writeValueAsString(cleanedBase64Images); - } catch (IOException e) { - throw new IEMRException("Error converting photos to base64: " + e.getMessage()); + } catch (Exception e) { + throw new IEMRException("Error processing base64 photos: " + e.getMessage()); } } + } From 7266b1c985ec899ce4175ff2b45afd98e7829cbb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 14:30:00 +0530 Subject: [PATCH 732/792] fix base64 image issue --- .../com/iemr/flw/service/CampaignService.java | 5 ++-- .../flw/service/impl/CampaignServiceImpl.java | 28 ++++++------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index f443c0ed..1f2cf092 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -1,5 +1,6 @@ package com.iemr.flw.service; +import com.fasterxml.jackson.core.JsonProcessingException; import com.iemr.flw.domain.iemr.CampaignOrs; import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.OrsCampaignDTO; @@ -11,8 +12,8 @@ import java.util.List; public interface CampaignService { - List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException; - List savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException; + List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException, JsonProcessingException; + List savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException, JsonProcessingException; List getOrsCampaign(String token) throws IEMRException; List getPolioCampaign(String token) throws IEMRException; diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 45992c98..63e64212 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -39,7 +39,7 @@ public class CampaignServiceImpl implements CampaignService { @Override @Transactional - public List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException { + public List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException, JsonProcessingException { if (orsCampaignDTO == null || orsCampaignDTO.isEmpty()) { return Collections.emptyList(); // } @@ -66,20 +66,9 @@ public List saveOrsCampaign(List orsCampaignDTO, St throw new IEMRException("Invalid number format for families"); } - List photos = campaignDTO.getFields().getCampaignPhotos(); - - if (photos != null && !photos.isEmpty()) { - - // remove null / empty / invalid entries - List validPhotos = photos.stream() - .filter(p -> p != null && !p.trim().isEmpty()) - .toList(); - - if (!validPhotos.isEmpty()) { - String base64Json = convertPhotosToBase64Json(validPhotos); - campaignOrsEntity.setCampaignPhotos(base64Json); - } - } + ObjectMapper mapper = new ObjectMapper(); + String jsonPhotos = mapper.writeValueAsString(campaignDTO.getFields().getCampaignPhotos()); + campaignOrsEntity.setCampaignPhotos(jsonPhotos); campaignOrsRequest.add(campaignOrsEntity); } @@ -115,7 +104,7 @@ public List getOrsCampaign(String token) throws IEMRExce @Override @Transactional public List savePolioCampaign(List polioCampaignDTOs, String token) - throws IEMRException { + throws IEMRException, JsonProcessingException { if (polioCampaignDTOs == null || polioCampaignDTOs.isEmpty()) { throw new IEMRException("Campaign data is required"); @@ -154,10 +143,9 @@ public List savePolioCampaign(List polioCa // Convert photos to base64 JSON array List photos = campaignDTO.getFields().getCampaignPhotos(); - if (photos != null && !photos.isEmpty()) { - String base64Json = convertPhotosToBase64Json(photos); - campaignPolioEntity.setCampaignPhotos(base64Json); - } + ObjectMapper mapper = new ObjectMapper(); + String jsonPhotos = mapper.writeValueAsString(campaignDTO.getFields().getCampaignPhotos()); + campaignPolioEntity.setCampaignPhotos(jsonPhotos); campaignPolioRequest.add(campaignPolioEntity); From d24f9cda47a4a081fc40cf424e57d01bf6831fd8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 14:48:19 +0530 Subject: [PATCH 733/792] fix base64 image issue --- .../flw/controller/CampaignController.java | 14 +++++++------- .../iemr/flw/dto/iemr/OrsCampaignListDTO.java | 2 +- .../flw/dto/iemr/PolioCampaignListDTO.java | 2 +- .../flw/service/impl/CampaignServiceImpl.java | 19 ++++++++++++++++--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 5304784a..070a3ea8 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -63,7 +63,7 @@ public ResponseEntity> saveOrsDistribution( requestDTO.getFields().getStartDate(), requestDTO.getFields().getEndDate(), requestDTO.getFields().getNumberOfFamilies(), - requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().size() : 0 + requestDTO.getFields().getCampaignPhotos() ); // Create DTO @@ -145,7 +145,7 @@ public ResponseEntity> savePolioCampaign( Map response = new LinkedHashMap<>(); try { - logger.info("Received filariasis campaign data"); + logger.info("Received polio campaign data"); // Validate input if (fields == null || fields.trim().isEmpty()) { @@ -173,26 +173,26 @@ public ResponseEntity> savePolioCampaign( requestDTO.getFields().getEndDate(), requestDTO.getFields().getNumberOfChildren(), - requestDTO.getFields().getCampaignPhotos() != null ? requestDTO.getFields().getCampaignPhotos().size() : 0 + requestDTO.getFields().getCampaignPhotos() ); // Create DTO PolioCampaignDTO campaignDTO = new PolioCampaignDTO(); campaignDTO.setFields(requestDTO.getFields()); - List filariasisCampaignDTOList = Collections.singletonList(campaignDTO); + List polioCampaignDTOList = Collections.singletonList(campaignDTO); // Save to database - List result = campaignService.savePolioCampaign(filariasisCampaignDTOList, token); + List result = campaignService.savePolioCampaign(polioCampaignDTOList, token); if (result != null && !result.isEmpty()) { response.put("statusCode", HttpStatus.CREATED.value()); - response.put("message", "Filariasis (MDA) campaign saved successfully"); + response.put("message", "polio campaign saved successfully"); response.put("data", result); return ResponseEntity.status(HttpStatus.CREATED).body(response); } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", "Failed to save filariasis campaign"); + response.put("message", "Failed to save Polio campaign"); return ResponseEntity.badRequest().body(response); } diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 552c4fc8..71f54a5f 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -24,7 +24,7 @@ public class OrsCampaignListDTO { private String NumberOfFamilies; @JsonProperty("campaign_photos") - private List campaignPhotos; + private String campaignPhotos; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java index 670e790b..ef6b2268 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -22,7 +22,7 @@ public class PolioCampaignListDTO { private String numberOfChildren; @JsonProperty("campaign_photos") - private List campaignPhotos; // base64 strings + private String campaignPhotos; // base64 strings } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 63e64212..cda1479c 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -67,7 +67,14 @@ public List saveOrsCampaign(List orsCampaignDTO, St } ObjectMapper mapper = new ObjectMapper(); - String jsonPhotos = mapper.writeValueAsString(campaignDTO.getFields().getCampaignPhotos()); + String photosStr = campaignDTO.getFields().getCampaignPhotos(); + + List photosList = Collections.emptyList(); + if (photosStr != null && !photosStr.isEmpty()) { + photosList = mapper.readValue(photosStr, new TypeReference>() {}); + } + + String jsonPhotos = mapper.writeValueAsString(photosList); campaignOrsEntity.setCampaignPhotos(jsonPhotos); campaignOrsRequest.add(campaignOrsEntity); @@ -141,10 +148,16 @@ public List savePolioCampaign(List polioCa } // Convert photos to base64 JSON array - List photos = campaignDTO.getFields().getCampaignPhotos(); ObjectMapper mapper = new ObjectMapper(); - String jsonPhotos = mapper.writeValueAsString(campaignDTO.getFields().getCampaignPhotos()); + String photosStr = campaignDTO.getFields().getCampaignPhotos(); + + List photosList = Collections.emptyList(); + if (photosStr != null && !photosStr.isEmpty()) { + photosList = mapper.readValue(photosStr, new TypeReference>() {}); + } + + String jsonPhotos = mapper.writeValueAsString(photosList); campaignPolioEntity.setCampaignPhotos(jsonPhotos); From e35b9d0636e11e625c9bddb6808bfc44a317b11f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:05:54 +0530 Subject: [PATCH 734/792] fix base64 image issue --- src/main/java/com/iemr/flw/controller/CampaignController.java | 1 - src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 070a3ea8..bf7db306 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -36,7 +36,6 @@ public ResponseEntity> saveOrsDistribution( Map response = new LinkedHashMap<>(); try { - logger.info("Received formDataJson: {}", fields.substring(0, Math.min(100, fields.length()))); // Log first 100 chars // Validate input if (fields == null || fields.trim().isEmpty()) { diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index cda1479c..b66f430b 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -77,6 +77,7 @@ public List saveOrsCampaign(List orsCampaignDTO, St String jsonPhotos = mapper.writeValueAsString(photosList); campaignOrsEntity.setCampaignPhotos(jsonPhotos); + campaignOrsRequest.add(campaignOrsEntity); } From 7522177ec713ac2143b3de68eabdd68a1a018bf6 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:08:56 +0530 Subject: [PATCH 735/792] change status code --- .../com/iemr/flw/controller/CampaignController.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index bf7db306..c35ef03c 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -75,10 +75,10 @@ public ResponseEntity> saveOrsDistribution( List result = campaignService.saveOrsCampaign(orsCampaignDTOList, token); if (result != null && !result.isEmpty()) { - response.put("statusCode", HttpStatus.CREATED.value()); + response.put("statusCode", HttpStatus.OK.value()); response.put("message", "Campaign saved successfully"); response.put("data", result); - return ResponseEntity.status(HttpStatus.CREATED).body(response); + return ResponseEntity.status(HttpStatus.OK).body(response); } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); response.put("message", "Failed to save campaign"); @@ -185,10 +185,10 @@ public ResponseEntity> savePolioCampaign( List result = campaignService.savePolioCampaign(polioCampaignDTOList, token); if (result != null && !result.isEmpty()) { - response.put("statusCode", HttpStatus.CREATED.value()); + response.put("statusCode", HttpStatus.OK.value()); response.put("message", "polio campaign saved successfully"); response.put("data", result); - return ResponseEntity.status(HttpStatus.CREATED).body(response); + return ResponseEntity.status(HttpStatus.OK).body(response); } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); response.put("message", "Failed to save Polio campaign"); @@ -282,10 +282,10 @@ public ResponseEntity> saveFilariasisCampaign( List result = campaignService.savePolioCampaign(polioCampaignDTOList, token); if (result != null && !result.isEmpty()) { - response.put("statusCode", HttpStatus.CREATED.value()); + response.put("statusCode", HttpStatus.OK.value()); response.put("message", "Polio campaign saved successfully"); response.put("data", result); - return ResponseEntity.status(HttpStatus.CREATED).body(response); + return ResponseEntity.status(HttpStatus.OK).body(response); } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); response.put("message", "Failed to save polio campaign"); From 68d09dd04a409412963bae4993d375974cd1436a Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:14:08 +0530 Subject: [PATCH 736/792] change status code --- .../flw/controller/ChildCareController.java | 4 ++-- .../flw/service/impl/CampaignServiceImpl.java | 21 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index d5e4335f..e29193c1 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -40,7 +40,7 @@ public class ChildCareController { @Operation(summary = "save HBYC details") @RequestMapping(value = {"/hbycVisit/saveAll"}, method = {RequestMethod.POST}) public String saveHbycRecords(@RequestBody List hbycDTOs, - @RequestHeader(value = "Authorization") String Authorization) { + @RequestHeader(value = "JwtToken") String token) { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.INDENT_OUTPUT); // Pretty print @@ -52,7 +52,7 @@ public String saveHbycRecords(@RequestBody List hbycDTOs, logger.info("Saving All HBYC Details"); if (hbycDTOs != null) { - String s = childCareService.registerHBYC(hbycDTOs); + String s = childCareService.registerHBYC(hbycDTOs,token); if (s != null) response.setResponse(s); else diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index b66f430b..107eb67a 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -59,13 +59,18 @@ public List saveOrsCampaign(List orsCampaignDTO, St campaignOrsEntity.setUpdatedBy(userName); try { - campaignOrsEntity.setNumberOfFamilies( - Integer.parseInt(campaignDTO.getFields().getNumberOfFamilies()) - ); + String familiesStr = campaignDTO.getFields().getNumberOfFamilies(); + if (familiesStr != null && !familiesStr.trim().isEmpty()) { + double familiesDouble = Double.parseDouble(familiesStr); + campaignOrsEntity.setNumberOfFamilies((int) familiesDouble); + } else { + campaignOrsEntity.setNumberOfFamilies(0); // default 0 + } } catch (NumberFormatException e) { - throw new IEMRException("Invalid number format for families"); + throw new IEMRException("Invalid number format for families: " + campaignDTO.getFields().getNumberOfFamilies()); } + ObjectMapper mapper = new ObjectMapper(); String photosStr = campaignDTO.getFields().getCampaignPhotos(); @@ -140,7 +145,13 @@ public List savePolioCampaign(List polioCa try { String childrenStr = campaignDTO.getFields().getNumberOfChildren(); if (childrenStr != null && !childrenStr.trim().isEmpty()) { - campaignPolioEntity.setNumberOfChildren(Integer.parseInt(childrenStr)); + try { + // parse as double first, then cast to int + double childrenDouble = Double.parseDouble(childrenStr); + campaignPolioEntity.setNumberOfChildren((int) childrenDouble); + } catch (NumberFormatException e) { + campaignPolioEntity.setNumberOfChildren(0); // default 0 if invalid + } } else { campaignPolioEntity.setNumberOfChildren(0); } From 7aac355fe554df488dc641db19af8202feed1544 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Fri, 16 Jan 2026 15:20:14 +0530 Subject: [PATCH 737/792] Update ChildCareController.java --- src/main/java/com/iemr/flw/controller/ChildCareController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index e29193c1..e1e2c91f 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -52,7 +52,7 @@ public String saveHbycRecords(@RequestBody List hbycDTOs, logger.info("Saving All HBYC Details"); if (hbycDTOs != null) { - String s = childCareService.registerHBYC(hbycDTOs,token); + String s = childCareService.registerHBYC(hbycDTOs); if (s != null) response.setResponse(s); else From b57ab885530884faa18209bbeadb553f627e9e8b Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:32:57 +0530 Subject: [PATCH 738/792] fix issue image --- .../flw/service/impl/CampaignServiceImpl.java | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 107eb67a..6a806bce 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -71,16 +71,11 @@ public List saveOrsCampaign(List orsCampaignDTO, St } - ObjectMapper mapper = new ObjectMapper(); - String photosStr = campaignDTO.getFields().getCampaignPhotos(); - - List photosList = Collections.emptyList(); - if (photosStr != null && !photosStr.isEmpty()) { - photosList = mapper.readValue(photosStr, new TypeReference>() {}); - } - - String jsonPhotos = mapper.writeValueAsString(photosList); - campaignOrsEntity.setCampaignPhotos(jsonPhotos); + List photos = campaignDTO.getFields().getCampaignPhotos(); + String photosStr = (photos != null && !photos.isEmpty()) + ? String.join(",", photos) + : null; + campaignOrsEntity.setCampaignPhotos(photosStr); campaignOrsRequest.add(campaignOrsEntity); @@ -161,16 +156,12 @@ public List savePolioCampaign(List polioCa // Convert photos to base64 JSON array - ObjectMapper mapper = new ObjectMapper(); - String photosStr = campaignDTO.getFields().getCampaignPhotos(); - - List photosList = Collections.emptyList(); - if (photosStr != null && !photosStr.isEmpty()) { - photosList = mapper.readValue(photosStr, new TypeReference>() {}); - } + List photosList = campaignDTO.getFields().getCampaignPhotos(); + String photosStr = (photosList != null && !photosList.isEmpty()) + ? String.join(",", photosList) + : null; - String jsonPhotos = mapper.writeValueAsString(photosList); - campaignPolioEntity.setCampaignPhotos(jsonPhotos); + campaignPolioEntity.setCampaignPhotos(photosStr); campaignPolioRequest.add(campaignPolioEntity); From 9d4eb33b1cf4fc4cfe4234d96f8ae4ec205b85f8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:37:31 +0530 Subject: [PATCH 739/792] fix issue image --- src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java | 2 +- src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java index 71f54a5f..552c4fc8 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListDTO.java @@ -24,7 +24,7 @@ public class OrsCampaignListDTO { private String NumberOfFamilies; @JsonProperty("campaign_photos") - private String campaignPhotos; + private List campaignPhotos; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java index ef6b2268..a42ef3c6 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListDTO.java @@ -18,11 +18,11 @@ public class PolioCampaignListDTO { @JsonProperty("end_date") private LocalDate endDate; - @JsonProperty("number_of_children") + @JsonProperty("children_vaccinated") private String numberOfChildren; @JsonProperty("campaign_photos") - private String campaignPhotos; // base64 strings + private List campaignPhotos; } From 3c19e25141a3c3159499ca0570785d161feb635d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 15:50:31 +0530 Subject: [PATCH 740/792] fix date issue --- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 6a806bce..a2b09896 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -57,6 +57,8 @@ public List saveOrsCampaign(List orsCampaignDTO, St campaignOrsEntity.setUserId(userId); campaignOrsEntity.setCreatedBy(userName); campaignOrsEntity.setUpdatedBy(userName); + campaignOrsEntity.setStartDate(campaignDTO.getFields().getStartDate()); + campaignOrsEntity.setStartDate(campaignDTO.getFields().getEndDate()); try { String familiesStr = campaignDTO.getFields().getNumberOfFamilies(); From b296e9b2c1a0fc59993606e8223ed2ecba1246fa Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 16:42:09 +0530 Subject: [PATCH 741/792] Filariasis Campaign --- .../flw/controller/CampaignController.java | 42 +++++-- .../flw/domain/iemr/FilariasisCampaign.java | 66 ++++++++++ .../flw/dto/iemr/FilariasisCampaignDTO.java | 10 ++ .../dto/iemr/FilariasisCampaignListDTO.java | 30 +++++ .../FilariasisCampaignListResponseDTO.java | 30 +++++ .../flw/dto/iemr/FilariasisResponseDTO.java | 10 ++ .../flw/repo/iemr/FilariasisCampaignRepo.java | 13 ++ .../com/iemr/flw/service/CampaignService.java | 12 +- .../flw/service/impl/CampaignServiceImpl.java | 118 ++++++++++++++++++ 9 files changed, 314 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/FilariasisResponseDTO.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/FilariasisCampaignRepo.java diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index c35ef03c..93a19afd 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.FilariasisCampaign; import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.service.CampaignService; @@ -249,12 +250,13 @@ public ResponseEntity> getAllPolioCampaign(@RequestHeader(va @PostMapping("/filariasis/campaign/saveAll") public ResponseEntity> saveFilariasisCampaign( @RequestPart("formDataJson") String fields, - @RequestPart(value = "campaignPhotos", required = false) List campaignPhotos, @RequestHeader("jwtToken") String token) { Map response = new LinkedHashMap<>(); try { + logger.info("Received polio campaign data"); + // Validate input if (fields == null || fields.trim().isEmpty()) { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); @@ -265,30 +267,44 @@ public ResponseEntity> saveFilariasisCampaign( // Parse JSON to DTO ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JavaTimeModule()); - PolioCampaignListDTO polioCampaignFields = objectMapper.readValue(fields, PolioCampaignListDTO.class); + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - // Set campaign photos if present - if (campaignPhotos != null && !campaignPhotos.isEmpty()) { - // polioCampaignFields.setCampaignPhotos(campaignPhotos.toArray(new MultipartFile[0])); + FilariasisCampaignDTO requestDTO = objectMapper.readValue(fields, FilariasisCampaignDTO.class); + + // Validate fields + if (requestDTO.getFields() == null) { + response.put("statusCode", HttpStatus.BAD_REQUEST.value()); + response.put("message", "Campaign fields are required"); + return ResponseEntity.badRequest().body(response); } + logger.info("Parsed DTO - Start Date: {}, End Date: {}, Families: {}, Individuals: {}, Photos: {}", + requestDTO.getFields().getStartDate(), + requestDTO.getFields().getEndDate(), + requestDTO.getFields().getNumberOfIndividuals(), + requestDTO.getFields().getNumberOfIndividuals(), + + requestDTO.getFields().getMdaPhotos() + ); + // Create DTO - PolioCampaignDTO campaignDTO = new PolioCampaignDTO(); - campaignDTO.setFields(polioCampaignFields); + FilariasisCampaignDTO campaignDTO = new FilariasisCampaignDTO(); + campaignDTO.setFields(requestDTO.getFields()); + + List filariasisCampaignDTOS = Collections.singletonList(campaignDTO); - List polioCampaignDTOList = Collections.singletonList(campaignDTO); // Save to database - List result = campaignService.savePolioCampaign(polioCampaignDTOList, token); + List result = campaignService.saveFilariasisCampaign(filariasisCampaignDTOS, token); if (result != null && !result.isEmpty()) { response.put("statusCode", HttpStatus.OK.value()); - response.put("message", "Polio campaign saved successfully"); + response.put("message", "filariasis campaign saved successfully"); response.put("data", result); return ResponseEntity.status(HttpStatus.OK).body(response); } else { response.put("statusCode", HttpStatus.BAD_REQUEST.value()); - response.put("message", "Failed to save polio campaign"); + response.put("message", "Failed to save filariasis campaign"); return ResponseEntity.badRequest().body(response); } @@ -306,7 +322,7 @@ public ResponseEntity> saveFilariasisCampaign( return ResponseEntity.badRequest().body(response); } catch (Exception e) { - logger.error("Error saving polio campaign: {}", e.getMessage(), e); + logger.error("Error saving filariasis campaign: {}", e.getMessage(), e); response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "Internal server error occurred"); response.put("errorMessage", e.getMessage()); @@ -321,7 +337,7 @@ public ResponseEntity> getAllFilariasisCampaign(@RequestHead Map response = new LinkedHashMap<>(); try { - List result = campaignService.getPolioCampaign(token); + List result = campaignService.getAllFilariasisCampaign(token); if (result != null) { diff --git a/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java new file mode 100644 index 00000000..b9f98ee8 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java @@ -0,0 +1,66 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Entity +@Table(name = "campaign_filariasis_mda",schema = "db_iemr") +@Data +public class FilariasisCampaign { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "start_date", nullable = false) + private LocalDate startDate; + + @Column(name = "end_date", nullable = false) + private LocalDate endDate; + + @Column(name = "user_id", nullable = false) + private Integer userId; + + @Column(name = "no_of_families", nullable = false) + private Integer numberOfFamilies = 0; + + @Column(name = "no_of_individuals", nullable = false) + private Integer numberOfIndividuals = 0; + + /** + * Store JSON array like ["img1.jpg","img2.jpg"] + * MySQL JSON column + */ + @Column(name = "mda_photos", columnDefinition = "json") + private String campaignPhotos; + + @Column(name = "created_by", length = 200) + private String createdBy; + + @Column(name = "updated_by", length = 200) + private String updatedBy; + + @Column(name = "created_date", updatable = false) + private LocalDateTime createdDate; + + @Column(name = "updated_date") + private LocalDateTime updatedDate; + + /* ---------- Auto timestamps ---------- */ + + @PrePersist + protected void onCreate() { + this.createdDate = LocalDateTime.now(); + this.updatedDate = LocalDateTime.now(); + } + + @PreUpdate + protected void onUpdate() { + this.updatedDate = LocalDateTime.now(); + } + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignDTO.java new file mode 100644 index 00000000..2e53ee29 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class FilariasisCampaignDTO { + private Long id; + private String visitDate; + private FilariasisCampaignListDTO fields; +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListDTO.java new file mode 100644 index 00000000..81438df9 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListDTO.java @@ -0,0 +1,30 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class FilariasisCampaignListDTO { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("start_date") + private LocalDate startDate; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("end_date") + private LocalDate endDate; + + @JsonProperty("no_of_families") + private String numberOfFamilies; + + @JsonProperty("no_of_individuals") + private String numberOfIndividuals; + + @JsonProperty("mda_photos") + private List mdaPhotos; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java new file mode 100644 index 00000000..644448a7 --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java @@ -0,0 +1,30 @@ +package com.iemr.flw.dto.iemr; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; + +import java.time.LocalDate; +import java.util.List; + +@Data +public class FilariasisCampaignListResponseDTO { + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("start_date") + private LocalDate startDate; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("end_date") + private LocalDate endDate; + + @JsonProperty("no_of_families") + private String numberOfFamilies; + + @JsonProperty("no_of_individuals") + private String numberOfIndividuals; + + @JsonProperty("mda_photos") + private List mdaPhotos; + + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisResponseDTO.java new file mode 100644 index 00000000..7b6dc5aa --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisResponseDTO.java @@ -0,0 +1,10 @@ +package com.iemr.flw.dto.iemr; + +import lombok.Data; + +@Data +public class FilariasisResponseDTO { + private Long id; + private Long houseHoldId; + private FilariasisCampaignListResponseDTO fields; +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/FilariasisCampaignRepo.java b/src/main/java/com/iemr/flw/repo/iemr/FilariasisCampaignRepo.java new file mode 100644 index 00000000..1fe0d3e2 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/FilariasisCampaignRepo.java @@ -0,0 +1,13 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.FilariasisCampaign; +import com.iemr.flw.domain.iemr.PulsePolioCampaign; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface FilariasisCampaignRepo extends JpaRepository { + Page findByUserId(Integer userId, Pageable pageable); +} diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index 1f2cf092..d1ac0201 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -2,19 +2,23 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.FilariasisCampaign; import com.iemr.flw.domain.iemr.PulsePolioCampaign; -import com.iemr.flw.dto.iemr.OrsCampaignDTO; -import com.iemr.flw.dto.iemr.OrsCampaignResponseDTO; -import com.iemr.flw.dto.iemr.PolioCampaignDTO; -import com.iemr.flw.dto.iemr.PolioCampaignResponseDTO; +import com.iemr.flw.dto.iemr.*; import com.iemr.flw.utils.exception.IEMRException; import java.util.List; public interface CampaignService { List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException, JsonProcessingException; + List savePolioCampaign(List polioCampaignDTOS, String token) throws IEMRException, JsonProcessingException; + List getOrsCampaign(String token) throws IEMRException; List getPolioCampaign(String token) throws IEMRException; + + List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException; + + List getAllFilariasisCampaign(String token) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index a2b09896..32596222 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -4,8 +4,10 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.iemr.flw.domain.iemr.CampaignOrs; +import com.iemr.flw.domain.iemr.FilariasisCampaign; import com.iemr.flw.domain.iemr.PulsePolioCampaign; import com.iemr.flw.dto.iemr.*; +import com.iemr.flw.repo.iemr.FilariasisCampaignRepo; import com.iemr.flw.repo.iemr.OrsCampaignRepo; import com.iemr.flw.repo.iemr.PulsePolioCampaignRepo; import com.iemr.flw.service.CampaignService; @@ -34,6 +36,9 @@ public class CampaignServiceImpl implements CampaignService { @Autowired private PulsePolioCampaignRepo pulsePolioCampaignRepo; + @Autowired + private FilariasisCampaignRepo filariasisCampaignRepo; + @Autowired private JwtUtil jwtUtil; @@ -178,6 +183,85 @@ public List savePolioCampaign(List polioCa } + @Override + @Transactional + public List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException { + + if (filariasisCampaignDTOS == null || filariasisCampaignDTOS.isEmpty()) { + throw new IEMRException("Campaign data is required"); + } + + List campaignPolioRequest = new ArrayList<>(); + Integer userId = jwtUtil.extractUserId(token); + String userName = jwtUtil.extractUsername(token); + + for (FilariasisCampaignDTO campaignDTO : filariasisCampaignDTOS) { + if (campaignDTO.getFields() == null) { + continue; + } + + FilariasisCampaign filariasisCampaign = new FilariasisCampaign(); + filariasisCampaign.setUserId(userId); + filariasisCampaign.setCreatedBy(userName); + filariasisCampaign.setUpdatedBy(userName); + + // Set start and end dates + filariasisCampaign.setStartDate(campaignDTO.getFields().getStartDate()); + filariasisCampaign.setEndDate(campaignDTO.getFields().getEndDate()); + + // Parse number of children + try { + String numberOfFamilies = campaignDTO.getFields().getNumberOfFamilies(); + String numberOfIndividuals = campaignDTO.getFields().getNumberOfIndividuals(); + if (numberOfFamilies != null && !numberOfFamilies.trim().isEmpty()) { + try { + // parse as double first, then cast to int + double noDouble = Double.parseDouble(numberOfFamilies); + filariasisCampaign.setNumberOfFamilies((int) noDouble); + } catch (NumberFormatException e) { + filariasisCampaign.setNumberOfFamilies(0); // default 0 if invalid + } + } else { + filariasisCampaign.setNumberOfFamilies(0); + } + + if (numberOfIndividuals != null && !numberOfIndividuals.trim().isEmpty()) { + try { + // parse as double first, then cast to int + double noDouble = Double.parseDouble(numberOfIndividuals); + filariasisCampaign.setNumberOfFamilies((int) noDouble); + } catch (NumberFormatException e) { + filariasisCampaign.setNumberOfIndividuals(0); // default 0 if invalid + } + } else { + filariasisCampaign.setNumberOfIndividuals(0); + } + } catch (NumberFormatException e) { + throw new IEMRException("Invalid number format for children: " + e.getMessage()); + } + + // Convert photos to base64 JSON array + + List photosList = campaignDTO.getFields().getMdaPhotos(); + String photosStr = (photosList != null && !photosList.isEmpty()) + ? String.join(",", photosList) + : null; + + filariasisCampaign.setCampaignPhotos(photosStr); + + + campaignPolioRequest.add(filariasisCampaign); + } + + if (!campaignPolioRequest.isEmpty()) { + List savedCampaigns = filariasisCampaignRepo.saveAll(campaignPolioRequest); + return savedCampaigns; + } + + throw new IEMRException("No valid campaign data to save"); + } + + @Override public List getPolioCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); @@ -197,6 +281,25 @@ public List getPolioCampaign(String token) throws IEMR return polioCampaignDTOSResponse; } + @Override + public List getAllFilariasisCampaign(String token) throws IEMRException { + Integer userId = jwtUtil.extractUserId(token); + List filariasisResponseDTOS = new ArrayList<>(); + int page = 0; + int pageSize = 10; + Page campaignPolioPage; + do { + Pageable pageable = PageRequest.of(page, pageSize); + campaignPolioPage = filariasisCampaignRepo.findByUserId(userId, pageable); + for (FilariasisCampaign campaignOrs : campaignPolioPage.getContent()) { + FilariasisResponseDTO dto = convertFilariasisDTO(campaignOrs); + filariasisResponseDTOS.add(dto); + } + page++; + } while (campaignPolioPage.hasNext()); + return filariasisResponseDTOS; + } + private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { OrsCampaignResponseDTO dto = new OrsCampaignResponseDTO(); @@ -225,6 +328,21 @@ private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) dto.setFields(polioCampaignListDTO); return dto; } + + private FilariasisResponseDTO convertFilariasisDTO(FilariasisCampaign campaign) { + FilariasisResponseDTO dto = new FilariasisResponseDTO(); + FilariasisCampaignListResponseDTO filariasisCampaignListDTO = new FilariasisCampaignListResponseDTO(); + if (campaign.getCampaignPhotos() != null) { + List photosList = parseBase64Json(campaign.getCampaignPhotos()); + filariasisCampaignListDTO.setMdaPhotos(photosList); // ✅ Now List matches + } + filariasisCampaignListDTO.setEndDate(campaign.getEndDate()); + filariasisCampaignListDTO.setStartDate(campaign.getStartDate()); + filariasisCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); + filariasisCampaignListDTO.setNumberOfIndividuals(String.valueOf(campaign.getNumberOfIndividuals())); + dto.setFields(filariasisCampaignListDTO); + return dto; + } private List parseBase64Json(String jsonString) { try { ObjectMapper objectMapper = new ObjectMapper(); From 2aa90c8238c48442e873330b6811917e79106ff2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 16:49:13 +0530 Subject: [PATCH 742/792] Tb confirmed cases --- .../com/iemr/flw/controller/TBController.java | 66 ++++++++ .../flw/domain/iemr/TBConfirmedCaseDTO.java | 29 ++++ .../iemr/flw/dto/iemr/TBConfirmedCase.java | 75 +++++++++ .../iemr/TBConfirmedTreatmentRepository.java | 18 ++ .../flw/service/TBConfirmedCaseService.java | 18 ++ .../impl/TBConfirmedCaseServiceImpl.java | 154 ++++++++++++++++++ 6 files changed, 360 insertions(+) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCaseDTO.java create mode 100644 src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java create mode 100644 src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java create mode 100644 src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index 56afcb98..e18b1abb 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -1,14 +1,17 @@ package com.iemr.flw.controller; +import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.TBScreeningRequestDTO; import com.iemr.flw.dto.iemr.TBSuspectedRequestDTO; +import com.iemr.flw.service.TBConfirmedCaseService; import com.iemr.flw.service.TBScreeningService; import com.iemr.flw.service.TBSuspectedService; import com.iemr.flw.utils.response.OutputResponse; import io.swagger.v3.oas.annotations.Operation; +import org.checkerframework.checker.units.qual.A; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +31,9 @@ public class TBController { @Autowired private TBSuspectedService tbSuspectedService; + @Autowired + private TBConfirmedCaseService tbConfirmedCaseService; + @Operation(summary = "get tb screening data of all beneficiaries registered with given user id") @RequestMapping(value = { "/screening/getAll" }, method = { RequestMethod.POST }) public String getAllScreeningByUserId(@RequestBody GetBenRequestHandler requestDTO, @@ -125,4 +131,64 @@ public String saveAllSuspectedByUserId(@RequestBody TBSuspectedRequestDTO reques return response.toString(); } + @Operation(summary = "save tb confirmed case data of beneficiary") + @RequestMapping(value = { "/confirmed/save" }, method = { RequestMethod.POST }) + public String saveConfirmedCase( + @RequestBody TBConfirmedCaseDTO requestDTO, + @RequestHeader(value = "jwtToken") String token) { + + OutputResponse response = new OutputResponse(); + + try { + if (requestDTO != null) { + + logger.info("request object with timestamp : " + + new Timestamp(System.currentTimeMillis()) + " " + + requestDTO); + + String result = tbConfirmedCaseService.save(requestDTO, token); + + if (result != null) + response.setResponse(result); + else + response.setError(500, "No record saved"); + + } else { + response.setError(500, "Invalid/NULL request obj"); + } + } catch (Exception e) { + logger.error("Error in save tb confirmed case details : ", e); + response.setError(500, "Error in save tb confirmed case details : " + e.getMessage()); + } + + return response.toString(); + } + + @Operation(summary = "get tb confirmed case by beneficiary id") + @RequestMapping(value = { "/confirmed/getAll}" }, method = { RequestMethod.GET }) + public String getConfirmedByBenId( + @PathVariable Long benId, + @RequestHeader(value = "jwtToken") String token) { + + OutputResponse response = new OutputResponse(); + + try { + String result = + tbConfirmedCaseService.getByUserId(token); + + if (result != null) + response.setResponse(result); + else + response.setError(404, "No record found"); + + } catch (Exception e) { + logger.error("Error in get tb confirmed case details : ", e); + response.setError(500, "Error in get tb confirmed case details : " + e.getMessage()); + } + + return response.toString(); + } + + + } diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCaseDTO.java b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCaseDTO.java new file mode 100644 index 00000000..180c3bbe --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCaseDTO.java @@ -0,0 +1,29 @@ +package com.iemr.flw.domain.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class TBConfirmedCaseDTO { + + private Long benId; + private Integer userId; + private Integer suspectedTbId; + private String regimenType; + private LocalDate treatmentStartDate; + private LocalDate expectedTreatmentCompletionDate; + private LocalDate followUpDate; + private String monthlyFollowUpDone; + private String adherenceToMedicines; + private Boolean anyDiscomfort; + private Boolean treatmentCompleted; + private LocalDate actualTreatmentCompletionDate; + private String treatmentOutcome; + private LocalDate dateOfDeath; + private String placeOfDeath; + private String reasonForDeath ; + private String reasonForNotCompleting; + +} diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java new file mode 100644 index 00000000..2c01638b --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java @@ -0,0 +1,75 @@ +package com.iemr.flw.dto.iemr; + +import jakarta.persistence.*; +import lombok.Data; + +import java.sql.Timestamp; +import java.time.LocalDate; + +@Entity +@Data +@Table(name = "tb_confirmed_cases",schema = "db_iemr") +public class TBConfirmedCase { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Integer id; + + @Column(name = "ben_id", nullable = false) + private Long benId; + @Column(name = "user_id",nullable = false) + + private Integer userId; + + @Column(name = "suspected_tb_id", nullable = false) + private Integer suspectedTbId; + + @Column(name = "regimen_type") + private String regimenType; + + @Column(name = "treatment_start_date") + private LocalDate treatmentStartDate; + + @Column(name = "expected_treatment_completion_date") + private LocalDate expectedTreatmentCompletionDate; + + @Column(name = "follow_up_date") + private LocalDate followUpDate; + + @Column(name = "monthly_follow_up_done") + private String monthlyFollowUpDone; + + @Column(name = "adherence_to_medicines") + private String adherenceToMedicines; + + @Column(name = "any_discomfort") + private Boolean anyDiscomfort; + + @Column(name = "treatment_completed") + private Boolean treatmentCompleted; + + @Column(name = "actual_treatment_completion_date") + private LocalDate actualTreatmentCompletionDate; + + @Column(name = "treatment_outcome") + private String treatmentOutcome; + + @Column(name = "date_of_death") + private LocalDate dateOfDeath; + + @Column(name = "place_of_death") + private String placeOfDeath; + + @Column(name = "reason_for_death") + private String reasonForDeath = "Tuberculosis"; + + @Column(name = "reason_for_not_completing") + private String reasonForNotCompleting; + + @Column(name = "created_at") + private LocalDate createdAt = LocalDate.now(); + + @Column(name = "updated_at") + private LocalDate updatedAt; + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java new file mode 100644 index 00000000..d3cceaf2 --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java @@ -0,0 +1,18 @@ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.dto.iemr.TBConfirmedCase; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; + +@Repository +public interface TBConfirmedTreatmentRepository + extends JpaRepository { + + List findByBenId(Long benId); + List findByUserId(Integer benId); + + Optional findByBenIdAndSuspectedTbId(Long benId, Integer suspectedTbId); +} diff --git a/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java new file mode 100644 index 00000000..beaffa09 --- /dev/null +++ b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java @@ -0,0 +1,18 @@ +package com.iemr.flw.service; + +import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; +import com.iemr.flw.dto.iemr.TBConfirmedCase; +import io.swagger.v3.oas.annotations.info.License; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public interface TBConfirmedCaseService { + + String save(TBConfirmedCaseDTO tbConfirmedCaseDTO, String token) throws Exception; + + String getByBenId(Long benId, String authorisation) throws Exception; + + String getByUserId(String authorisation) throws Exception; +} diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java new file mode 100644 index 00000000..5a46795f --- /dev/null +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -0,0 +1,154 @@ +package com.iemr.flw.service.impl; + +import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; +import com.iemr.flw.dto.iemr.TBConfirmedCase; +import com.iemr.flw.repo.iemr.TBConfirmedTreatmentRepository; +import com.iemr.flw.service.TBConfirmedCaseService; + +import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.response.OutputResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.stream.Collectors; + +@Service +public class TBConfirmedCaseServiceImpl implements TBConfirmedCaseService { + + private static final Logger logger = LoggerFactory.getLogger(TBConfirmedCaseServiceImpl.class); + + private final TBConfirmedTreatmentRepository repository; + + @Autowired + private JwtUtil jwtUtil; + public TBConfirmedCaseServiceImpl(TBConfirmedTreatmentRepository repository) { + this.repository = repository; + } + + @Override + public String save(TBConfirmedCaseDTO dto, String authorisation) throws Exception { + OutputResponse response = new OutputResponse(); + + try { + if (dto != null) { + logger.info("Saving TB confirmed case: " + dto); + + TBConfirmedCase entity = new TBConfirmedCase(); + + entity.setBenId(dto.getBenId()); + entity.setUserId(dto.getUserId()); + entity.setSuspectedTbId(dto.getSuspectedTbId()); + entity.setRegimenType(dto.getRegimenType()); + entity.setTreatmentStartDate(dto.getTreatmentStartDate()); + entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); + entity.setFollowUpDate(dto.getFollowUpDate()); + entity.setMonthlyFollowUpDone(dto.getMonthlyFollowUpDone()); + entity.setAdherenceToMedicines(dto.getAdherenceToMedicines()); + entity.setAnyDiscomfort(dto.getAnyDiscomfort()); + entity.setTreatmentCompleted(dto.getTreatmentCompleted()); + entity.setActualTreatmentCompletionDate(dto.getActualTreatmentCompletionDate()); + entity.setTreatmentOutcome(dto.getTreatmentOutcome()); + entity.setDateOfDeath(dto.getDateOfDeath()); + entity.setPlaceOfDeath(dto.getPlaceOfDeath()); + entity.setReasonForDeath(dto.getReasonForDeath()); + entity.setReasonForNotCompleting(dto.getReasonForNotCompleting()); + + repository.save(entity); + + response.setResponse("TB Confirmed case saved successfully"); + + } else { + response.setError(500, "Invalid/NULL request obj"); + } + } catch (Exception e) { + logger.error("Error saving TB confirmed case", e); + response.setError(5000, "Error saving TB confirmed case: " + e.getMessage()); + } + + return response.toString(); + } + + @Override + public String getByBenId(Long benId, String authorisation) throws Exception { + OutputResponse response = new OutputResponse(); + + try { + List list = repository.findByBenId(benId); + + if (list != null && !list.isEmpty()) { + List dtoList = list.stream() + .map(this::toDTO) + .collect(Collectors.toList()); + + response.setResponse(dtoList.toString()); + } else { + response.setError(404, "No record found for benId: " + benId); + } + + } catch (Exception e) { + logger.error("Error getting TB confirmed case by benId", e); + response.setError(5000, "Error getting TB confirmed case: " + e.getMessage()); + } + + return response.toString(); + } + + @Override + public String getByUserId(String authorisation) throws Exception { + OutputResponse response = new OutputResponse(); + + + try { + Integer userId = jwtUtil.extractUserId(authorisation); + + List list = repository.findByUserId(userId) + .stream() + .filter(x -> x.getUserId() != null && x.getUserId().equals(userId)) + .collect(Collectors.toList()); + + if (!list.isEmpty()) { + List dtoList = list.stream() + .map(this::toDTO) + .collect(Collectors.toList()); + + response.setResponse(dtoList.toString()); + } else { + response.setError(404, "No record found for userId: " + userId); + } + + } catch (Exception e) { + logger.error("Error getting TB confirmed case by userId", e); + response.setError(5000, "Error getting TB confirmed case: " + e.getMessage()); + } + + return response.toString(); + } + + // Utility: convert entity -> DTO + private TBConfirmedCaseDTO toDTO(TBConfirmedCase entity) { + TBConfirmedCaseDTO dto = new TBConfirmedCaseDTO(); + + dto.setBenId(entity.getBenId()); + dto.setUserId(entity.getUserId()); + dto.setSuspectedTbId(entity.getSuspectedTbId()); + dto.setRegimenType(entity.getRegimenType()); + dto.setTreatmentStartDate(entity.getTreatmentStartDate()); + dto.setExpectedTreatmentCompletionDate(entity.getExpectedTreatmentCompletionDate()); + dto.setFollowUpDate(entity.getFollowUpDate()); + dto.setMonthlyFollowUpDone(entity.getMonthlyFollowUpDone()); + dto.setAdherenceToMedicines(entity.getAdherenceToMedicines()); + dto.setAnyDiscomfort(entity.getAnyDiscomfort()); + dto.setTreatmentCompleted(entity.getTreatmentCompleted()); + dto.setActualTreatmentCompletionDate(entity.getActualTreatmentCompletionDate()); + dto.setTreatmentOutcome(entity.getTreatmentOutcome()); + dto.setDateOfDeath(entity.getDateOfDeath()); + dto.setPlaceOfDeath(entity.getPlaceOfDeath()); + dto.setReasonForDeath(entity.getReasonForDeath()); + dto.setReasonForNotCompleting(entity.getReasonForNotCompleting()); + + return dto; + } +} From 66ba4e8261ef772574b2cb1c6cdddecd44bf62f4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 17:07:26 +0530 Subject: [PATCH 743/792] Tb confirmed cases --- src/main/java/com/iemr/flw/controller/TBController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index e18b1abb..f395f59b 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -165,7 +165,7 @@ public String saveConfirmedCase( } @Operation(summary = "get tb confirmed case by beneficiary id") - @RequestMapping(value = { "/confirmed/getAll}" }, method = { RequestMethod.GET }) + @RequestMapping(value = { "/confirmed/getAll" }, method = { RequestMethod.GET }) public String getConfirmedByBenId( @PathVariable Long benId, @RequestHeader(value = "jwtToken") String token) { From 539a3e16851b69c08ac105d1ada3fd92af0a9787 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 17:19:10 +0530 Subject: [PATCH 744/792] Tb confirmed cases --- .../com/iemr/flw/{dto => domain}/iemr/TBConfirmedCase.java | 2 +- .../iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java | 2 +- .../java/com/iemr/flw/service/TBConfirmedCaseService.java | 4 ---- .../com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java | 2 +- 4 files changed, 3 insertions(+), 7 deletions(-) rename src/main/java/com/iemr/flw/{dto => domain}/iemr/TBConfirmedCase.java (98%) diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java similarity index 98% rename from src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java rename to src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java index 2c01638b..2d0da6ea 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCase.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java @@ -1,4 +1,4 @@ -package com.iemr.flw.dto.iemr; +package com.iemr.flw.domain.iemr; import jakarta.persistence.*; import lombok.Data; diff --git a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java index d3cceaf2..c3fae1e2 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java @@ -1,6 +1,6 @@ package com.iemr.flw.repo.iemr; -import com.iemr.flw.dto.iemr.TBConfirmedCase; +import com.iemr.flw.domain.iemr.TBConfirmedCase; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java index beaffa09..61a8d2a3 100644 --- a/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java +++ b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java @@ -1,12 +1,8 @@ package com.iemr.flw.service; import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; -import com.iemr.flw.dto.iemr.TBConfirmedCase; -import io.swagger.v3.oas.annotations.info.License; import org.springframework.stereotype.Service; -import java.util.List; - @Service public interface TBConfirmedCaseService { diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 5a46795f..14c7acad 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -1,7 +1,7 @@ package com.iemr.flw.service.impl; import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; -import com.iemr.flw.dto.iemr.TBConfirmedCase; +import com.iemr.flw.domain.iemr.TBConfirmedCase; import com.iemr.flw.repo.iemr.TBConfirmedTreatmentRepository; import com.iemr.flw.service.TBConfirmedCaseService; From cc5dc006519a712ae8de12b393c92893e4b125d8 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 17:37:15 +0530 Subject: [PATCH 745/792] fix end date --- src/main/java/com/iemr/flw/controller/TBController.java | 1 - .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index f395f59b..96a89491 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -167,7 +167,6 @@ public String saveConfirmedCase( @Operation(summary = "get tb confirmed case by beneficiary id") @RequestMapping(value = { "/confirmed/getAll" }, method = { RequestMethod.GET }) public String getConfirmedByBenId( - @PathVariable Long benId, @RequestHeader(value = "jwtToken") String token) { OutputResponse response = new OutputResponse(); diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 32596222..56e3549a 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -63,7 +63,7 @@ public List saveOrsCampaign(List orsCampaignDTO, St campaignOrsEntity.setCreatedBy(userName); campaignOrsEntity.setUpdatedBy(userName); campaignOrsEntity.setStartDate(campaignDTO.getFields().getStartDate()); - campaignOrsEntity.setStartDate(campaignDTO.getFields().getEndDate()); + campaignOrsEntity.setEndDate(campaignDTO.getFields().getEndDate()); try { String familiesStr = campaignDTO.getFields().getNumberOfFamilies(); From 4ec2146aeef192f110b9f3262a6086263039f3b4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 16 Jan 2026 18:04:30 +0530 Subject: [PATCH 746/792] fix ors id issue --- .../com/iemr/flw/domain/iemr/CampaignOrs.java | 6 +----- .../flw/domain/iemr/PulsePolioCampaign.java | 7 ++----- .../dto/iemr/OrsCampaignListResponseDTO.java | 20 ++++++++++++++----- .../flw/dto/iemr/OrsCampaignResponseDTO.java | 1 - .../dto/iemr/PolioCampaignResponseDTO.java | 1 - .../flw/service/impl/CampaignServiceImpl.java | 6 ++++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java index 9d4c5c1a..1b53bfa1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java +++ b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java @@ -27,11 +27,7 @@ public class CampaignOrs { @Column(name = "number_of_families", nullable = false) private Integer numberOfFamilies = 0; - /** - * Store JSON array like ["img1.jpg","img2.jpg"] - * MySQL JSON column - */ - @Column(name = "campaign_photos", columnDefinition = "json") + @Column(name = "campaign_photos") private String campaignPhotos; @Column(name = "created_by", length = 200) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java index 446217eb..e4733b6f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java @@ -27,11 +27,8 @@ public class PulsePolioCampaign { @Column(name = "number_of_children", nullable = false) private Integer numberOfChildren = 0; - /** - * Store JSON array like ["img1.jpg","img2.jpg"] - * MySQL JSON column - */ - @Column(name = "campaign_photos", columnDefinition = "json") + + @Column(name = "campaign_photos") private String campaignPhotos; @Column(name = "created_by", length = 200) diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java index 7b8ec2da..8527b806 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java @@ -1,5 +1,7 @@ package com.iemr.flw.dto.iemr; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; import java.time.LocalDate; @@ -7,9 +9,17 @@ @Data public class OrsCampaignListResponseDTO { - private Long id; - private LocalDate startDate; - private LocalDate endDate; - private String numberOfFamilies; - private List campaignPhotos; // Base64 or URLs + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("start_date") + private LocalDate StartDate; + + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy") + @JsonProperty("end_date") + private LocalDate EndDate; + + @JsonProperty("number_of_families") + private String NumberOfFamilies; + + @JsonProperty("campaign_photos") + private List campaignPhotos; } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java index 44351ddb..5c8b954d 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignResponseDTO.java @@ -5,6 +5,5 @@ @Data public class OrsCampaignResponseDTO { private Long id; - private String visitDate; private OrsCampaignListResponseDTO fields; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java index 06370ac0..a6504236 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignResponseDTO.java @@ -5,6 +5,5 @@ @Data public class PolioCampaignResponseDTO { private Long id; - private String visitDate; private PolioCampaignListResponseDTO fields; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 56e3549a..326212c4 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -307,10 +307,11 @@ private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { if (campaign.getCampaignPhotos() != null) { List photosList = parseBase64Json(campaign.getCampaignPhotos()); orsCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches - } orsCampaignListDTO.setEndDate(campaign.getEndDate()); - + } + orsCampaignListDTO.setEndDate(campaign.getEndDate()); orsCampaignListDTO.setStartDate(campaign.getStartDate()); orsCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); + dto.setId(campaign.getId()); dto.setFields(orsCampaignListDTO); return dto; } @@ -325,6 +326,7 @@ private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) polioCampaignListDTO.setEndDate(campaign.getEndDate()); polioCampaignListDTO.setStartDate(campaign.getStartDate()); polioCampaignListDTO.setNumberOfChildren(String.valueOf(campaign.getNumberOfChildren())); + dto.setId(campaign.getId()); dto.setFields(polioCampaignListDTO); return dto; } From 28a231b2261db542278c5ba18b92905c35278e87 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Fri, 16 Jan 2026 20:36:54 +0530 Subject: [PATCH 747/792] Enable SpringDoc API docs and Swagger UI --- src/main/resources/application.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ab7eae2a..034fbcc4 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -63,12 +63,12 @@ fhir-url= # TM Config tm-url= -springdoc.api-docs.enabled=false -springdoc.swagger-ui.enabled=false +springdoc.api-docs.enabled=true +springdoc.swagger-ui.enabled=true spring.redis.host=localhost spring.main.allow-bean-definition-overriding=true spring.redis.password= spring.redis.port=6379 -notificationurl=https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification \ No newline at end of file +notificationurl=https://uatamrit.piramalswasthya.org/common-api/firebaseNotification/sendNotification From 41db3b3e4c8deac58311782cee3ca7d5e2bbee09 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 18 Jan 2026 22:31:29 +0530 Subject: [PATCH 748/792] remove has_symptoms --- src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java | 3 --- src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 481e613d..9ea5ce64 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -54,9 +54,6 @@ public class TBSuspected { @Column(name = "reason_for_suspicion", length = 500) private String reasonForSuspicion; - // Symptoms - @Column(name = "has_symptoms", nullable = false) - private Boolean hasSymptoms = false; // Chest X-Ray @Column(name = "is_chest_xray_done") diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index b44e0ed4..9c56df39 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -14,7 +14,6 @@ public class TBSuspectedDTO { private String visitLabel; private String typeOfTBCase; private String reasonForSuspicion; - private Boolean hasSymptoms; private Boolean isSputumCollected; private String sputumSubmittedAt; private String nikshayId; From 72fdce158a70401697d09a72cce86b3d7eff9ee4 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 18 Jan 2026 22:40:05 +0530 Subject: [PATCH 749/792] remove isConfirmed --- src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java | 3 --- src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 9ea5ce64..7a69a17f 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -72,9 +72,6 @@ public class TBSuspected { @Column(name = "is_drtb_confirmed") private Boolean isDRTBConfirmed; - @Column(name = "is_confirmed", nullable = false) - private Boolean isConfirmed = false; - @Column(name = "provider_service_map_id") private Integer providerServiceMapId; diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 9c56df39..821b0f03 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -23,7 +23,6 @@ public class TBSuspectedDTO { private String referralFacility; private Boolean isTBConfirmed; private Boolean isDRTBConfirmed; - private Boolean isConfirmed; private Boolean referred; private String followUps; } From cd6b0a24d362a094def426cab9ced9bbb85d21cd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 18 Jan 2026 22:47:49 +0530 Subject: [PATCH 750/792] remove visit_code --- src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java | 3 --- src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 7a69a17f..3fe2d66a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -41,9 +41,6 @@ public class TBSuspected { @Column(name = "followups") private String followUps; - @Column(name = "visit_code", nullable = false) - private Long visitCode; - // Visit Information @Column(name = "visit_label", length = 100, nullable = false) private String visitLabel; diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 821b0f03..52c46e5b 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -10,7 +10,6 @@ public class TBSuspectedDTO { private Long id; private Long benId; - private Long visitCode; private String visitLabel; private String typeOfTBCase; private String reasonForSuspicion; From 84a28bc6bf94978108c37e23f6226b5196ab8fbe Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 18 Jan 2026 22:48:33 +0530 Subject: [PATCH 751/792] remove visit_code --- src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 3fe2d66a..417600f1 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -42,10 +42,10 @@ public class TBSuspected { private String followUps; // Visit Information - @Column(name = "visit_label", length = 100, nullable = false) + @Column(name = "visit_label") private String visitLabel; - @Column(name = "type_of_tb_case", length = 50, nullable = false) + @Column(name = "type_of_tb_case") private String typeOfTBCase; @Column(name = "reason_for_suspicion", length = 500) From 169bafea9d98fa8b9236d88f6de6f9a0b2081824 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Sun, 18 Jan 2026 23:26:55 +0530 Subject: [PATCH 752/792] fix photo campaign issue --- .../flw/service/impl/CampaignServiceImpl.java | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 326212c4..b1d618b0 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -305,8 +305,26 @@ private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { OrsCampaignResponseDTO dto = new OrsCampaignResponseDTO(); OrsCampaignListResponseDTO orsCampaignListDTO = new OrsCampaignListResponseDTO(); if (campaign.getCampaignPhotos() != null) { - List photosList = parseBase64Json(campaign.getCampaignPhotos()); - orsCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches + ObjectMapper objectMapper = new ObjectMapper(); + List photosList = new ArrayList<>(); + + String photoStr = campaign.getCampaignPhotos(); + + if (photoStr != null && !photoStr.trim().isEmpty()) { + try { + // try JSON list + photosList = objectMapper.readValue( + photoStr, + new TypeReference>() {} + ); + } catch (Exception e) { + // fallback: single image + photosList.add(photoStr.trim()); + } + } + + orsCampaignListDTO.setCampaignPhotos(photosList); + // ✅ Now List matches } orsCampaignListDTO.setEndDate(campaign.getEndDate()); orsCampaignListDTO.setStartDate(campaign.getStartDate()); @@ -320,7 +338,26 @@ private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) PolioCampaignResponseDTO dto = new PolioCampaignResponseDTO(); PolioCampaignListResponseDTO polioCampaignListDTO = new PolioCampaignListResponseDTO(); if (campaign.getCampaignPhotos() != null) { - List photosList = parseBase64Json(campaign.getCampaignPhotos()); + ObjectMapper objectMapper = new ObjectMapper(); + List photosList = new ArrayList<>(); + + String photoStr = campaign.getCampaignPhotos(); + + if (photoStr != null && !photoStr.trim().isEmpty()) { + try { + // try JSON list + photosList = objectMapper.readValue( + photoStr, + new TypeReference>() {} + ); + } catch (Exception e) { + // fallback: single image + photosList.add(photoStr.trim()); + } + } + + polioCampaignListDTO.setCampaignPhotos(photosList); + polioCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches } polioCampaignListDTO.setEndDate(campaign.getEndDate()); From dedbc4aa5413333ca1f077d24d52f969e0f66809 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 10:43:36 +0530 Subject: [PATCH 753/792] fix data type issue --- .../FilariasisCampaignListResponseDTO.java | 2 +- .../dto/iemr/OrsCampaignListResponseDTO.java | 2 +- .../iemr/PolioCampaignListResponseDTO.java | 4 +- .../com/iemr/flw/service/CampaignService.java | 2 +- .../flw/service/impl/CampaignServiceImpl.java | 92 ++++++++----------- 5 files changed, 44 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java index 644448a7..be62cfe0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java @@ -21,7 +21,7 @@ public class FilariasisCampaignListResponseDTO { private String numberOfFamilies; @JsonProperty("no_of_individuals") - private String numberOfIndividuals; + private Double numberOfIndividuals; @JsonProperty("mda_photos") private List mdaPhotos; diff --git a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java index 8527b806..e72fb04c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/OrsCampaignListResponseDTO.java @@ -18,7 +18,7 @@ public class OrsCampaignListResponseDTO { private LocalDate EndDate; @JsonProperty("number_of_families") - private String NumberOfFamilies; + private Double NumberOfFamilies; @JsonProperty("campaign_photos") private List campaignPhotos; diff --git a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java index 603d1676..f27468f3 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PolioCampaignListResponseDTO.java @@ -15,8 +15,8 @@ public class PolioCampaignListResponseDTO { @JsonProperty("end_date") private LocalDate endDate; - @JsonProperty("number_of_children") - private String numberOfChildren; + @JsonProperty("children_vaccinated") + private Double numberOfChildren; @JsonProperty("campaign_photos") private List campaignPhotos; diff --git a/src/main/java/com/iemr/flw/service/CampaignService.java b/src/main/java/com/iemr/flw/service/CampaignService.java index d1ac0201..26c67a6a 100644 --- a/src/main/java/com/iemr/flw/service/CampaignService.java +++ b/src/main/java/com/iemr/flw/service/CampaignService.java @@ -18,7 +18,7 @@ public interface CampaignService { List getPolioCampaign(String token) throws IEMRException; - List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException; + List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException, JsonProcessingException; List getAllFilariasisCampaign(String token) throws IEMRException; } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index b1d618b0..08a966cd 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -42,6 +42,9 @@ public class CampaignServiceImpl implements CampaignService { @Autowired private JwtUtil jwtUtil; + @Autowired + private ObjectMapper objectMapper; + @Override @Transactional public List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException, JsonProcessingException { @@ -77,13 +80,11 @@ public List saveOrsCampaign(List orsCampaignDTO, St throw new IEMRException("Invalid number format for families: " + campaignDTO.getFields().getNumberOfFamilies()); } - - List photos = campaignDTO.getFields().getCampaignPhotos(); - String photosStr = (photos != null && !photos.isEmpty()) - ? String.join(",", photos) - : null; - campaignOrsEntity.setCampaignPhotos(photosStr); - + OrsCampaignListDTO campaignListDTO = new OrsCampaignListDTO(); + if(campaignListDTO!=null){ + String photosJson = objectMapper.writeValueAsString(campaignListDTO.getCampaignPhotos()); + campaignOrsEntity.setCampaignPhotos(photosJson); + } campaignOrsRequest.add(campaignOrsEntity); } @@ -163,13 +164,13 @@ public List savePolioCampaign(List polioCa // Convert photos to base64 JSON array - List photosList = campaignDTO.getFields().getCampaignPhotos(); - String photosStr = (photosList != null && !photosList.isEmpty()) - ? String.join(",", photosList) - : null; + PolioCampaignListDTO polioCampaignListDTO = campaignDTO.getFields(); + if(polioCampaignListDTO!=null){ + String photosJson = objectMapper.writeValueAsString(polioCampaignListDTO.getCampaignPhotos()); + campaignPolioEntity.setCampaignPhotos(photosJson); - campaignPolioEntity.setCampaignPhotos(photosStr); + } campaignPolioRequest.add(campaignPolioEntity); } @@ -185,7 +186,7 @@ public List savePolioCampaign(List polioCa @Override @Transactional - public List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException { + public List saveFilariasisCampaign(List filariasisCampaignDTOS, String token) throws IEMRException, JsonProcessingException { if (filariasisCampaignDTOS == null || filariasisCampaignDTOS.isEmpty()) { throw new IEMRException("Campaign data is required"); @@ -241,14 +242,13 @@ public List saveFilariasisCampaign(List photosList = campaignDTO.getFields().getMdaPhotos(); - String photosStr = (photosList != null && !photosList.isEmpty()) - ? String.join(",", photosList) - : null; - - filariasisCampaign.setCampaignPhotos(photosStr); + } campaignPolioRequest.add(filariasisCampaign); } @@ -322,13 +322,11 @@ private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { photosList.add(photoStr.trim()); } } - orsCampaignListDTO.setCampaignPhotos(photosList); - // ✅ Now List matches } orsCampaignListDTO.setEndDate(campaign.getEndDate()); orsCampaignListDTO.setStartDate(campaign.getStartDate()); - orsCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); + orsCampaignListDTO.setNumberOfFamilies(Double.valueOf(campaign.getNumberOfFamilies())); dto.setId(campaign.getId()); dto.setFields(orsCampaignListDTO); return dto; @@ -338,7 +336,6 @@ private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) PolioCampaignResponseDTO dto = new PolioCampaignResponseDTO(); PolioCampaignListResponseDTO polioCampaignListDTO = new PolioCampaignListResponseDTO(); if (campaign.getCampaignPhotos() != null) { - ObjectMapper objectMapper = new ObjectMapper(); List photosList = new ArrayList<>(); String photoStr = campaign.getCampaignPhotos(); @@ -357,12 +354,10 @@ private PolioCampaignResponseDTO convertPolioToDTO(PulsePolioCampaign campaign) } polioCampaignListDTO.setCampaignPhotos(photosList); - - polioCampaignListDTO.setCampaignPhotos(photosList); // ✅ Now List matches } polioCampaignListDTO.setEndDate(campaign.getEndDate()); polioCampaignListDTO.setStartDate(campaign.getStartDate()); - polioCampaignListDTO.setNumberOfChildren(String.valueOf(campaign.getNumberOfChildren())); + polioCampaignListDTO.setNumberOfChildren(Double.valueOf(campaign.getNumberOfChildren())); dto.setId(campaign.getId()); dto.setFields(polioCampaignListDTO); return dto; @@ -372,13 +367,27 @@ private FilariasisResponseDTO convertFilariasisDTO(FilariasisCampaign campaign) FilariasisResponseDTO dto = new FilariasisResponseDTO(); FilariasisCampaignListResponseDTO filariasisCampaignListDTO = new FilariasisCampaignListResponseDTO(); if (campaign.getCampaignPhotos() != null) { - List photosList = parseBase64Json(campaign.getCampaignPhotos()); - filariasisCampaignListDTO.setMdaPhotos(photosList); // ✅ Now List matches + List photosList = new ArrayList<>(); + String photoStr = campaign.getCampaignPhotos(); + + if (photoStr != null && !photoStr.trim().isEmpty()) { + try { + // try JSON list + photosList = objectMapper.readValue( + photoStr, + new TypeReference>() {} + ); + } catch (Exception e) { + // fallback: single image + photosList.add(photoStr.trim()); + } + } + + filariasisCampaignListDTO.setMdaPhotos(photosList); } filariasisCampaignListDTO.setEndDate(campaign.getEndDate()); filariasisCampaignListDTO.setStartDate(campaign.getStartDate()); - filariasisCampaignListDTO.setNumberOfFamilies(String.valueOf(campaign.getNumberOfFamilies())); - filariasisCampaignListDTO.setNumberOfIndividuals(String.valueOf(campaign.getNumberOfIndividuals())); + filariasisCampaignListDTO.setNumberOfIndividuals(Double.valueOf(campaign.getNumberOfIndividuals())); dto.setFields(filariasisCampaignListDTO); return dto; } @@ -392,29 +401,6 @@ private List parseBase64Json(String jsonString) { } - private String convertPhotosToBase64Json(List photos) throws IEMRException { - try { - List cleanedBase64Images = new ArrayList<>(); - - for (String photo : photos) { - if (photo != null && !photo.trim().isEmpty()) { - - // remove data:image/...;base64, if present - String cleanBase64 = photo.contains(",") - ? photo.substring(photo.indexOf(",") + 1) - : photo; - - cleanedBase64Images.add(cleanBase64); - } - } - - ObjectMapper objectMapper = new ObjectMapper(); - return objectMapper.writeValueAsString(cleanedBase64Images); - - } catch (Exception e) { - throw new IEMRException("Error processing base64 photos: " + e.getMessage()); - } - } } From b6e39e82c336d9ce395353da57aa421ce368faec Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 10:59:44 +0530 Subject: [PATCH 754/792] add column defination --- src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java | 2 +- src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java | 2 +- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java index 1b53bfa1..e33e1543 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java +++ b/src/main/java/com/iemr/flw/domain/iemr/CampaignOrs.java @@ -27,7 +27,7 @@ public class CampaignOrs { @Column(name = "number_of_families", nullable = false) private Integer numberOfFamilies = 0; - @Column(name = "campaign_photos") + @Column(name = "campaign_photos",columnDefinition = "LONGTEXT") private String campaignPhotos; @Column(name = "created_by", length = 200) diff --git a/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java index e4733b6f..ddf7b8b6 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java +++ b/src/main/java/com/iemr/flw/domain/iemr/PulsePolioCampaign.java @@ -28,7 +28,7 @@ public class PulsePolioCampaign { private Integer numberOfChildren = 0; - @Column(name = "campaign_photos") + @Column(name = "campaign_photos",columnDefinition = "LONGTEXT") private String campaignPhotos; @Column(name = "created_by", length = 200) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 08a966cd..0005bfb2 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -42,8 +42,7 @@ public class CampaignServiceImpl implements CampaignService { @Autowired private JwtUtil jwtUtil; - @Autowired - private ObjectMapper objectMapper; + private ObjectMapper objectMapper = new ObjectMapper(); @Override @Transactional From ca5d70cce6e19add5f1a8278a6057f4302410d1d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 11:25:33 +0530 Subject: [PATCH 755/792] add ors image --- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 0005bfb2..29c67a96 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -79,7 +79,8 @@ public List saveOrsCampaign(List orsCampaignDTO, St throw new IEMRException("Invalid number format for families: " + campaignDTO.getFields().getNumberOfFamilies()); } - OrsCampaignListDTO campaignListDTO = new OrsCampaignListDTO(); + OrsCampaignListDTO campaignListDTO = campaignDTO.getFields(); + if(campaignListDTO!=null){ String photosJson = objectMapper.writeValueAsString(campaignListDTO.getCampaignPhotos()); campaignOrsEntity.setCampaignPhotos(photosJson); From 08251ddd994d3c6e3805eb76be5549018d9b90eb Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 18:59:00 +0530 Subject: [PATCH 756/792] add NumberOfIndividuals --- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 29c67a96..04ad5c37 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -230,7 +230,7 @@ public List saveFilariasisCampaign(List Date: Mon, 19 Jan 2026 19:15:40 +0530 Subject: [PATCH 757/792] add NumberOfIndividuals --- .../iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java | 2 +- .../java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java index be62cfe0..6baa38d9 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java @@ -18,7 +18,7 @@ public class FilariasisCampaignListResponseDTO { private LocalDate endDate; @JsonProperty("no_of_families") - private String numberOfFamilies; + private Double numberOfFamilies; @JsonProperty("no_of_individuals") private Double numberOfIndividuals; diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 04ad5c37..4db9209a 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -388,6 +388,7 @@ private FilariasisResponseDTO convertFilariasisDTO(FilariasisCampaign campaign) filariasisCampaignListDTO.setEndDate(campaign.getEndDate()); filariasisCampaignListDTO.setStartDate(campaign.getStartDate()); filariasisCampaignListDTO.setNumberOfIndividuals(Double.valueOf(campaign.getNumberOfIndividuals())); + filariasisCampaignListDTO.setNumberOfFamilies(Double.valueOf(campaign.getNumberOfFamilies())); dto.setFields(filariasisCampaignListDTO); return dto; } From 5a5cdd3c04dd014923fbb6eb7d028c597a3da2a0 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 19:16:34 +0530 Subject: [PATCH 758/792] add NumberOfIndividuals --- .../com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java | 1 + src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java index 6baa38d9..700d4665 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/FilariasisCampaignListResponseDTO.java @@ -27,4 +27,5 @@ public class FilariasisCampaignListResponseDTO { private List mdaPhotos; + } diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 4db9209a..d989df6c 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -389,6 +389,7 @@ private FilariasisResponseDTO convertFilariasisDTO(FilariasisCampaign campaign) filariasisCampaignListDTO.setStartDate(campaign.getStartDate()); filariasisCampaignListDTO.setNumberOfIndividuals(Double.valueOf(campaign.getNumberOfIndividuals())); filariasisCampaignListDTO.setNumberOfFamilies(Double.valueOf(campaign.getNumberOfFamilies())); + dto.setFields(filariasisCampaignListDTO); return dto; } From 88238398f26aa13b7a0195f195ce1a8791bff605 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 19:32:49 +0530 Subject: [PATCH 759/792] add api for tb confirmed cases --- .../com/iemr/flw/controller/TBController.java | 5 +- .../iemr/flw/domain/iemr/TBConfirmedCase.java | 2 +- .../flw/dto/iemr/TBConfirmedRequestDTO.java | 13 +++++ .../flw/service/TBConfirmedCaseService.java | 4 +- .../impl/TBConfirmedCaseServiceImpl.java | 50 +++++++++++-------- 5 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/TBConfirmedRequestDTO.java diff --git a/src/main/java/com/iemr/flw/controller/TBController.java b/src/main/java/com/iemr/flw/controller/TBController.java index 96a89491..e95c3ab4 100644 --- a/src/main/java/com/iemr/flw/controller/TBController.java +++ b/src/main/java/com/iemr/flw/controller/TBController.java @@ -2,6 +2,7 @@ import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; import com.iemr.flw.dto.identity.GetBenRequestHandler; +import com.iemr.flw.dto.iemr.TBConfirmedRequestDTO; import com.iemr.flw.dto.iemr.TBScreeningRequestDTO; import com.iemr.flw.dto.iemr.TBSuspectedRequestDTO; import com.iemr.flw.service.TBConfirmedCaseService; @@ -134,7 +135,7 @@ public String saveAllSuspectedByUserId(@RequestBody TBSuspectedRequestDTO reques @Operation(summary = "save tb confirmed case data of beneficiary") @RequestMapping(value = { "/confirmed/save" }, method = { RequestMethod.POST }) public String saveConfirmedCase( - @RequestBody TBConfirmedCaseDTO requestDTO, + @RequestBody TBConfirmedRequestDTO requestDTO, @RequestHeader(value = "jwtToken") String token) { OutputResponse response = new OutputResponse(); @@ -146,7 +147,7 @@ public String saveConfirmedCase( + new Timestamp(System.currentTimeMillis()) + " " + requestDTO); - String result = tbConfirmedCaseService.save(requestDTO, token); + String result = tbConfirmedCaseService.save(requestDTO.getTbConfirmedList(), token); if (result != null) response.setResponse(result); diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java index 2d0da6ea..826fa290 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java @@ -17,8 +17,8 @@ public class TBConfirmedCase { @Column(name = "ben_id", nullable = false) private Long benId; - @Column(name = "user_id",nullable = false) + @Column(name = "user_id",nullable = false) private Integer userId; @Column(name = "suspected_tb_id", nullable = false) diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedRequestDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedRequestDTO.java new file mode 100644 index 00000000..d3e76a4a --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedRequestDTO.java @@ -0,0 +1,13 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; +import lombok.Data; +import java.util.List; + +@Data +public class TBConfirmedRequestDTO { + + private Long userId; + + private List tbConfirmedList; +} diff --git a/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java index 61a8d2a3..64505b79 100644 --- a/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java +++ b/src/main/java/com/iemr/flw/service/TBConfirmedCaseService.java @@ -3,10 +3,12 @@ import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; import org.springframework.stereotype.Service; +import java.util.List; + @Service public interface TBConfirmedCaseService { - String save(TBConfirmedCaseDTO tbConfirmedCaseDTO, String token) throws Exception; + String save(List tbConfirmedCaseDTO, String token) throws Exception; String getByBenId(Long benId, String authorisation) throws Exception; diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 14c7acad..c09e30e8 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -29,34 +29,40 @@ public TBConfirmedCaseServiceImpl(TBConfirmedTreatmentRepository repository) { } @Override - public String save(TBConfirmedCaseDTO dto, String authorisation) throws Exception { + public String save(List request, String authorisation) throws Exception { OutputResponse response = new OutputResponse(); try { - if (dto != null) { - logger.info("Saving TB confirmed case: " + dto); + if (request != null) { + logger.info("Saving TB confirmed case: " + request); TBConfirmedCase entity = new TBConfirmedCase(); + for(TBConfirmedCaseDTO dto:request){ + entity.setBenId(dto.getBenId()); + entity.setUserId(dto.getUserId()); + entity.setSuspectedTbId(dto.getSuspectedTbId()); + entity.setRegimenType(dto.getRegimenType()); + entity.setTreatmentStartDate(dto.getTreatmentStartDate()); + entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); + entity.setFollowUpDate(dto.getFollowUpDate()); + entity.setMonthlyFollowUpDone(dto.getMonthlyFollowUpDone()); + entity.setAdherenceToMedicines(dto.getAdherenceToMedicines()); + entity.setAnyDiscomfort(dto.getAnyDiscomfort()); + entity.setTreatmentCompleted(dto.getTreatmentCompleted()); + entity.setActualTreatmentCompletionDate(dto.getActualTreatmentCompletionDate()); + entity.setTreatmentOutcome(dto.getTreatmentOutcome()); + entity.setDateOfDeath(dto.getDateOfDeath()); + entity.setPlaceOfDeath(dto.getPlaceOfDeath()); + entity.setReasonForDeath(dto.getReasonForDeath()); + entity.setReasonForNotCompleting(dto.getReasonForNotCompleting()); + if(entity!=null){ + repository.save(entity); + + } + } + + - entity.setBenId(dto.getBenId()); - entity.setUserId(dto.getUserId()); - entity.setSuspectedTbId(dto.getSuspectedTbId()); - entity.setRegimenType(dto.getRegimenType()); - entity.setTreatmentStartDate(dto.getTreatmentStartDate()); - entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); - entity.setFollowUpDate(dto.getFollowUpDate()); - entity.setMonthlyFollowUpDone(dto.getMonthlyFollowUpDone()); - entity.setAdherenceToMedicines(dto.getAdherenceToMedicines()); - entity.setAnyDiscomfort(dto.getAnyDiscomfort()); - entity.setTreatmentCompleted(dto.getTreatmentCompleted()); - entity.setActualTreatmentCompletionDate(dto.getActualTreatmentCompletionDate()); - entity.setTreatmentOutcome(dto.getTreatmentOutcome()); - entity.setDateOfDeath(dto.getDateOfDeath()); - entity.setPlaceOfDeath(dto.getPlaceOfDeath()); - entity.setReasonForDeath(dto.getReasonForDeath()); - entity.setReasonForNotCompleting(dto.getReasonForNotCompleting()); - - repository.save(entity); response.setResponse("TB Confirmed case saved successfully"); From c6109b4dc5978fe003aae0063d67c5a0866aa8f5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 19:42:24 +0530 Subject: [PATCH 760/792] add api for tb confirmed cases --- src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java | 2 -- .../com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java index 826fa290..adacdb1b 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBConfirmedCase.java @@ -21,8 +21,6 @@ public class TBConfirmedCase { @Column(name = "user_id",nullable = false) private Integer userId; - @Column(name = "suspected_tb_id", nullable = false) - private Integer suspectedTbId; @Column(name = "regimen_type") private String regimenType; diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index c09e30e8..2f4a26b7 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -40,7 +40,6 @@ public String save(List request, String authorisation) throw for(TBConfirmedCaseDTO dto:request){ entity.setBenId(dto.getBenId()); entity.setUserId(dto.getUserId()); - entity.setSuspectedTbId(dto.getSuspectedTbId()); entity.setRegimenType(dto.getRegimenType()); entity.setTreatmentStartDate(dto.getTreatmentStartDate()); entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); @@ -139,7 +138,6 @@ private TBConfirmedCaseDTO toDTO(TBConfirmedCase entity) { dto.setBenId(entity.getBenId()); dto.setUserId(entity.getUserId()); - dto.setSuspectedTbId(entity.getSuspectedTbId()); dto.setRegimenType(entity.getRegimenType()); dto.setTreatmentStartDate(entity.getTreatmentStartDate()); dto.setExpectedTreatmentCompletionDate(entity.getExpectedTreatmentCompletionDate()); From 129fa37640e10d2525f82f73ef9d00ff1c6aa590 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:46:39 +0530 Subject: [PATCH 761/792] Update TBConfirmedTreatmentRepository.java --- .../com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java index c3fae1e2..31345dd4 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java @@ -14,5 +14,4 @@ public interface TBConfirmedTreatmentRepository List findByBenId(Long benId); List findByUserId(Integer benId); - Optional findByBenIdAndSuspectedTbId(Long benId, Integer suspectedTbId); } From f25f046afc34eab851f772d1bc52b8cbb68c692b Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 19 Jan 2026 19:55:42 +0530 Subject: [PATCH 762/792] Update TBConfirmedCaseServiceImpl.java --- .../com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 2f4a26b7..3040558c 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -39,7 +39,7 @@ public String save(List request, String authorisation) throw TBConfirmedCase entity = new TBConfirmedCase(); for(TBConfirmedCaseDTO dto:request){ entity.setBenId(dto.getBenId()); - entity.setUserId(dto.getUserId()); + entity.setUserId(jwtUtil.extractUserId(authorisation)); entity.setRegimenType(dto.getRegimenType()); entity.setTreatmentStartDate(dto.getTreatmentStartDate()); entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); From 726bfe145a091fb9c64bb7e758504ae85fb5e517 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 19 Jan 2026 20:02:15 +0530 Subject: [PATCH 763/792] Update TBConfirmedCaseServiceImpl.java --- .../impl/TBConfirmedCaseServiceImpl.java | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 3040558c..bd8dddfa 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -4,7 +4,8 @@ import com.iemr.flw.domain.iemr.TBConfirmedCase; import com.iemr.flw.repo.iemr.TBConfirmedTreatmentRepository; import com.iemr.flw.service.TBConfirmedCaseService; - +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import org.slf4j.Logger; @@ -103,33 +104,12 @@ public String getByBenId(Long benId, String authorisation) throws Exception { @Override public String getByUserId(String authorisation) throws Exception { - OutputResponse response = new OutputResponse(); - - - try { - Integer userId = jwtUtil.extractUserId(authorisation); - - List list = repository.findByUserId(userId) - .stream() - .filter(x -> x.getUserId() != null && x.getUserId().equals(userId)) - .collect(Collectors.toList()); - - if (!list.isEmpty()) { - List dtoList = list.stream() - .map(this::toDTO) - .collect(Collectors.toList()); + Integer userId = jwtUtil.extractUserId(authorisation); - response.setResponse(dtoList.toString()); - } else { - response.setError(404, "No record found for userId: " + userId); - } - - } catch (Exception e) { - logger.error("Error getting TB confirmed case by userId", e); - response.setError(5000, "Error getting TB confirmed case: " + e.getMessage()); - } - - return response.toString(); + List list = repository.findByUserId(userId); + + Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); + return gson.toJson(list); } // Utility: convert entity -> DTO From 6d9d005819fa1db1a4fa2d2858cf0d33f0087cfc Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 19 Jan 2026 20:27:19 +0530 Subject: [PATCH 764/792] Update TBSuspectedDTO.java --- src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 52c46e5b..2eb0950c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -12,6 +12,7 @@ public class TBSuspectedDTO { private Long benId; private String visitLabel; private String typeOfTBCase; + private Timestamp visitDate; private String reasonForSuspicion; private Boolean isSputumCollected; private String sputumSubmittedAt; From 05281620a1a688fdac4009de9c9afead51d9351e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 22:46:12 +0530 Subject: [PATCH 765/792] add api for tb confirmed cases --- .../com/iemr/flw/domain/iemr/TBSuspected.java | 2 ++ .../com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 2 ++ .../iemr/TBConfirmedTreatmentRepository.java | 2 -- .../impl/TBConfirmedCaseServiceImpl.java | 36 ++++++------------- .../com/iemr/flw/utils/LocalDateAdapter.java | 20 +++++++++++ 5 files changed, 35 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/iemr/flw/utils/LocalDateAdapter.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java index 417600f1..2de2baf8 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBSuspected.java @@ -72,6 +72,8 @@ public class TBSuspected { @Column(name = "provider_service_map_id") private Integer providerServiceMapId; + @Column(name = "is_confirmed") + private Boolean isConfirmed; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 52c46e5b..29fb25f6 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -11,6 +11,7 @@ public class TBSuspectedDTO { private Long benId; private String visitLabel; + private Timestamp visitDate; private String typeOfTBCase; private String reasonForSuspicion; private Boolean isSputumCollected; @@ -21,6 +22,7 @@ public class TBSuspectedDTO { private String chestXRayResult; private String referralFacility; private Boolean isTBConfirmed; + private Boolean isConfirmed; private Boolean isDRTBConfirmed; private Boolean referred; private String followUps; diff --git a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java index c3fae1e2..8b9303ea 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java +++ b/src/main/java/com/iemr/flw/repo/iemr/TBConfirmedTreatmentRepository.java @@ -13,6 +13,4 @@ public interface TBConfirmedTreatmentRepository List findByBenId(Long benId); List findByUserId(Integer benId); - - Optional findByBenIdAndSuspectedTbId(Long benId, Integer suspectedTbId); } diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 2f4a26b7..212a83d7 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -1,17 +1,21 @@ package com.iemr.flw.service.impl; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; import com.iemr.flw.domain.iemr.TBConfirmedCase; import com.iemr.flw.repo.iemr.TBConfirmedTreatmentRepository; import com.iemr.flw.service.TBConfirmedCaseService; import com.iemr.flw.utils.JwtUtil; +import com.iemr.flw.utils.LocalDateAdapter; import com.iemr.flw.utils.response.OutputResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.List; import java.util.stream.Collectors; @@ -39,7 +43,7 @@ public String save(List request, String authorisation) throw TBConfirmedCase entity = new TBConfirmedCase(); for(TBConfirmedCaseDTO dto:request){ entity.setBenId(dto.getBenId()); - entity.setUserId(dto.getUserId()); + entity.setUserId(jwtUtil.extractUserId(authorisation)); entity.setRegimenType(dto.getRegimenType()); entity.setTreatmentStartDate(dto.getTreatmentStartDate()); entity.setExpectedTreatmentCompletionDate(dto.getExpectedTreatmentCompletionDate()); @@ -103,33 +107,15 @@ public String getByBenId(Long benId, String authorisation) throws Exception { @Override public String getByUserId(String authorisation) throws Exception { - OutputResponse response = new OutputResponse(); - - - try { - Integer userId = jwtUtil.extractUserId(authorisation); - - List list = repository.findByUserId(userId) - .stream() - .filter(x -> x.getUserId() != null && x.getUserId().equals(userId)) - .collect(Collectors.toList()); - - if (!list.isEmpty()) { - List dtoList = list.stream() - .map(this::toDTO) - .collect(Collectors.toList()); - response.setResponse(dtoList.toString()); - } else { - response.setError(404, "No record found for userId: " + userId); - } + Integer userId = jwtUtil.extractUserId(authorisation); + List list = repository.findByUserId(userId); - } catch (Exception e) { - logger.error("Error getting TB confirmed case by userId", e); - response.setError(5000, "Error getting TB confirmed case: " + e.getMessage()); - } + Gson gson = new GsonBuilder() + .registerTypeAdapter(LocalDate.class, new LocalDateAdapter()) + .create(); - return response.toString(); + return gson.toJson(list); } // Utility: convert entity -> DTO diff --git a/src/main/java/com/iemr/flw/utils/LocalDateAdapter.java b/src/main/java/com/iemr/flw/utils/LocalDateAdapter.java new file mode 100644 index 00000000..d0081c29 --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/LocalDateAdapter.java @@ -0,0 +1,20 @@ +package com.iemr.flw.utils; + +import com.google.gson.*; +import java.lang.reflect.Type; +import java.time.LocalDate; + +public class LocalDateAdapter + implements JsonSerializer, JsonDeserializer { + + @Override + public JsonElement serialize(LocalDate src, Type typeOfSrc, JsonSerializationContext context) { + return new JsonPrimitive(src.toString()); // yyyy-MM-dd + } + + @Override + public LocalDate deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) + throws JsonParseException { + return LocalDate.parse(json.getAsString()); + } +} From 35355e38f69cd00727d1e2c8540de6b5a3346fc5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 19 Jan 2026 23:11:19 +0530 Subject: [PATCH 766/792] add api for tb confirmed cases --- src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java index 13231fd4..29fb25f6 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBSuspectedDTO.java @@ -13,7 +13,6 @@ public class TBSuspectedDTO { private String visitLabel; private Timestamp visitDate; private String typeOfTBCase; - private Timestamp visitDate; private String reasonForSuspicion; private Boolean isSputumCollected; private String sputumSubmittedAt; From 1f6d2c689f2724e0634772ee6190edf03c9c535c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 20 Jan 2026 11:01:48 +0530 Subject: [PATCH 767/792] add api for tb tb confirmed cases --- .../flw/dto/iemr/TBConfirmedCasesResponseDTO.java | 11 +++++++++++ .../flw/service/impl/TBConfirmedCaseServiceImpl.java | 8 +++++--- 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCasesResponseDTO.java diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCasesResponseDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCasesResponseDTO.java new file mode 100644 index 00000000..42504dcd --- /dev/null +++ b/src/main/java/com/iemr/flw/dto/iemr/TBConfirmedCasesResponseDTO.java @@ -0,0 +1,11 @@ +package com.iemr.flw.dto.iemr; + +import com.iemr.flw.domain.iemr.TBConfirmedCase; +import lombok.Data; + +import java.util.List; +@Data +public class TBConfirmedCasesResponseDTO { + Integer userId ; + List tbConfirmedCases; +} diff --git a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java index 9b4f80a7..39b12177 100644 --- a/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/TBConfirmedCaseServiceImpl.java @@ -4,6 +4,7 @@ import com.google.gson.GsonBuilder; import com.iemr.flw.domain.iemr.TBConfirmedCaseDTO; import com.iemr.flw.domain.iemr.TBConfirmedCase; +import com.iemr.flw.dto.iemr.TBConfirmedCasesResponseDTO; import com.iemr.flw.repo.iemr.TBConfirmedTreatmentRepository; import com.iemr.flw.service.TBConfirmedCaseService; import com.google.gson.Gson; @@ -108,15 +109,16 @@ public String getByBenId(Long benId, String authorisation) throws Exception { @Override public String getByUserId(String authorisation) throws Exception { - + TBConfirmedCasesResponseDTO tbConfirmedCasesResponseDTO = new TBConfirmedCasesResponseDTO(); Integer userId = jwtUtil.extractUserId(authorisation); List list = repository.findByUserId(userId); - + tbConfirmedCasesResponseDTO.setUserId(userId); + tbConfirmedCasesResponseDTO.setTbConfirmedCases(list); Gson gson = new GsonBuilder() .registerTypeAdapter(LocalDate.class, new LocalDateAdapter()) .create(); - return gson.toJson(list); + return gson.toJson(tbConfirmedCasesResponseDTO); } // Utility: convert entity -> DTO From 68e12262befbdd276cc1a5f0e49ac58e0bdda6bd Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 20 Jan 2026 16:52:04 +0530 Subject: [PATCH 768/792] AMM-2135 add More Parameters in the API --- .../com/iemr/flw/domain/iemr/TBScreening.java | 24 +++++++++++++++++++ .../com/iemr/flw/dto/iemr/TBScreeningDTO.java | 11 +++++++++ 2 files changed, 35 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java index 9bf7ea8d..aab7d251 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java @@ -46,4 +46,28 @@ public class TBScreening { @Column(name = "family_check") private Boolean familySufferingFromTB; + + @Column(name = "rise_of_fever") + private Boolean riseOfFever; + + @Column(name = "loss_of_appetite") + private Boolean lossOfAppetite; + + @Column(name = "age") + private Boolean age; + + @Column(name = "diabetic") + private Boolean diabetic; + + @Column(name = "tobacco_user") + private Boolean tobaccoUser; + + @Column(name = "bmi") + private Boolean bmi; + + @Column(name = "contact_with_tb_patient") + private Boolean contactWithTBPatient; + + @Column(name = "history_of_tb_in_last_five_yrs") + private Boolean historyOfTBInLastFiveYrs; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java index 270526bd..73e9a030 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java @@ -29,6 +29,17 @@ public class TBScreeningDTO { private Boolean familySufferingFromTB; + private Boolean riseOfFever; + private Boolean lossOfAppetite; + private Boolean age; + private Boolean diabetic; + private Boolean tobaccoUser; + private Boolean bmi; + private Boolean contactWithTBPatient; + private Boolean historyOfTBInLastFiveYrs; + + + public Long getId() { return id; } From 4cc15d4d46eb8ba52986d5db0752c6d57818ac83 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 21 Jan 2026 16:43:11 +0530 Subject: [PATCH 769/792] add new column in tb screening --- src/main/java/com/iemr/flw/domain/iemr/TBScreening.java | 9 +++++++++ src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java index aab7d251..6789f9bf 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java +++ b/src/main/java/com/iemr/flw/domain/iemr/TBScreening.java @@ -70,4 +70,13 @@ public class TBScreening { @Column(name = "history_of_tb_in_last_five_yrs") private Boolean historyOfTBInLastFiveYrs; + + @Column(name = "sympotomatic") + private String sympotomatic; + + @Column(name = "asymptomatic") + private String asymptomatic; + + @Column(name = "recommandate_test") + private String recommandateTest; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java index 73e9a030..017d73af 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java @@ -37,6 +37,10 @@ public class TBScreeningDTO { private Boolean bmi; private Boolean contactWithTBPatient; private Boolean historyOfTBInLastFiveYrs; + private String sympotomatic; + private String asymptomatic; + private String recommandateTest; + From 448d38361905f2b0f5ea1eb41c3088d3b384a760 Mon Sep 17 00:00:00 2001 From: Saurav Mishra <80103738+SauravBizbRolly@users.noreply.github.com> Date: Mon, 2 Feb 2026 17:49:26 +0530 Subject: [PATCH 770/792] Update common_docker.properties --- src/main/environment/common_docker.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/environment/common_docker.properties b/src/main/environment/common_docker.properties index b6650a5d..befe0069 100644 --- a/src/main/environment/common_docker.properties +++ b/src/main/environment/common_docker.properties @@ -1,5 +1,5 @@ -fhir-url = ${FHIR_URL} -tm-url = ${TM_URL} +fhir-url = ${FHIR_API} +tm-url = ${TM_API} ##--------------------------------------------## Primary db------------------------------------------------------------------- @@ -38,3 +38,4 @@ send-message-url=${SMS_MESSAGE_URL} #crash.logs.base.path=${CRASH_LOGS_PATH} + From 5fbfea4ab4d1ab845d10accfbe81e659718cf96c Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 3 Feb 2026 12:25:03 +0530 Subject: [PATCH 771/792] Check is document is upload during claim incentive --- src/main/java/com/iemr/flw/dto/iemr/IncentiveRecordDTO.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/iemr/flw/dto/iemr/IncentiveRecordDTO.java b/src/main/java/com/iemr/flw/dto/iemr/IncentiveRecordDTO.java index 58da9958..9a07f65c 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/IncentiveRecordDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/IncentiveRecordDTO.java @@ -1,5 +1,6 @@ package com.iemr.flw.dto.iemr; +import jakarta.persistence.Column; import lombok.Data; import java.sql.Timestamp; @@ -30,5 +31,9 @@ public class IncentiveRecordDTO { private Timestamp updatedDate; private String updatedBy; + + private Boolean isEligible; + + private Boolean isDefaultActivity; } From ad6a5025f1f6856dc57f8df4baf74eac779178a7 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 12 Mar 2026 11:35:44 +0530 Subject: [PATCH 772/792] fix: generic message for sql expose --- src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java | 2 +- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java index 9144ca3b..ae3f1985 100644 --- a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java +++ b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java @@ -87,7 +87,7 @@ public boolean validateUserIdAndJwtToken(String jwtToken) throws IEMRException { return true; // Valid userId and JWT token } catch (Exception e) { logger.error("Validation failed: " + e.getMessage(), e); - throw new IEMRException("Validation error: " + e.getMessage(), e); + throw new IEMRException("Validation error: Authentication failed", e); } } diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index fcefd712..1bb705ed 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -116,7 +116,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } catch (Exception e) { logger.error("Authorization error: ", e); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: " + e.getMessage()); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: Authentication failed"); } } From a4b22f6d806ea2c4dc1984624f4a6cf01ea396cf Mon Sep 17 00:00:00 2001 From: Vishwanath Balkur <118195001+vishwab1@users.noreply.github.com> Date: Thu, 12 Mar 2026 11:52:07 +0530 Subject: [PATCH 773/792] fix: generic message for sql expose (#214) --- src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java | 2 +- src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java index 9144ca3b..ae3f1985 100644 --- a/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java +++ b/src/main/java/com/iemr/flw/utils/JwtAuthenticationUtil.java @@ -87,7 +87,7 @@ public boolean validateUserIdAndJwtToken(String jwtToken) throws IEMRException { return true; // Valid userId and JWT token } catch (Exception e) { logger.error("Validation failed: " + e.getMessage(), e); - throw new IEMRException("Validation error: " + e.getMessage(), e); + throw new IEMRException("Validation error: Authentication failed", e); } } diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index fcefd712..1bb705ed 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -116,7 +116,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo } catch (Exception e) { logger.error("Authorization error: ", e); - response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: " + e.getMessage()); + response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization error: Authentication failed"); } } From 114075e51b90cad2b4465d68a42a10ea38122d33 Mon Sep 17 00:00:00 2001 From: vishwab1 Date: Thu, 12 Mar 2026 12:45:01 +0530 Subject: [PATCH 774/792] fix: path traversal --- .../iemr/flw/utils/PathTraversalFilter.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/iemr/flw/utils/PathTraversalFilter.java diff --git a/src/main/java/com/iemr/flw/utils/PathTraversalFilter.java b/src/main/java/com/iemr/flw/utils/PathTraversalFilter.java new file mode 100644 index 00000000..e63012bc --- /dev/null +++ b/src/main/java/com/iemr/flw/utils/PathTraversalFilter.java @@ -0,0 +1,56 @@ +package com.iemr.flw.utils; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; + +@Component +@Order(1) +public class PathTraversalFilter implements Filter { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getName()); + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) + throws IOException, ServletException { + + HttpServletRequest request = (HttpServletRequest) servletRequest; + HttpServletResponse response = (HttpServletResponse) servletResponse; + + String uri = request.getRequestURI(); + + // Decode once to catch %2e%2e and similar encoded variants + String decodedUri = URLDecoder.decode(uri, StandardCharsets.UTF_8); + + if (containsTraversalPattern(uri) || containsTraversalPattern(decodedUri)) { + logger.warn("Path traversal attempt blocked: {}", uri); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid request path"); + return; + } + + chain.doFilter(servletRequest, servletResponse); + } + + private boolean containsTraversalPattern(String path) { + if (path == null) return false; + String normalized = path.toLowerCase(); + return normalized.contains("../") + || normalized.contains("..\\") + || normalized.contains("..;") + || normalized.contains("%2e%2e") + || normalized.contains("%252e") // double-encoded + || normalized.endsWith(".."); + } +} From 490676784bdcbbe96d787821421b69b53b8737fb Mon Sep 17 00:00:00 2001 From: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com> Date: Thu, 12 Mar 2026 16:08:43 +0530 Subject: [PATCH 775/792] Cherry-pick health and version API enhancements to release-3.8.0 (#215) * feat(health,version): add health and version endpoints * fix(health): cancel in-flight futures on generic failure * fix: remove duplicate plugin and unused variable --- pom.xml | 26 + .../controller/health/HealthController.java | 83 +++ .../controller/version/VersionController.java | 80 +++ .../flw/service/health/HealthService.java | 517 ++++++++++++++++++ .../flw/utils/JwtUserIdValidationFilter.java | 4 +- 5 files changed, 709 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/iemr/flw/controller/health/HealthController.java create mode 100644 src/main/java/com/iemr/flw/controller/version/VersionController.java create mode 100644 src/main/java/com/iemr/flw/service/health/HealthService.java diff --git a/pom.xml b/pom.xml index 42245b93..f7681e6a 100644 --- a/pom.xml +++ b/pom.xml @@ -337,6 +337,32 @@ + + io.github.git-commit-id + git-commit-id-maven-plugin + 9.0.2 + + + get-the-git-infos + + revision + + initialize + + + + true + ${project.build.outputDirectory}/git.properties + + ^git.branch$ + ^git.commit.id.abbrev$ + ^git.build.version$ + ^git.build.time$ + + false + false + + org.apache.maven.plugins maven-antrun-plugin diff --git a/src/main/java/com/iemr/flw/controller/health/HealthController.java b/src/main/java/com/iemr/flw/controller/health/HealthController.java new file mode 100644 index 00000000..93308554 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/health/HealthController.java @@ -0,0 +1,83 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ + +package com.iemr.flw.controller.health; + +import java.time.Instant; +import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.iemr.flw.service.health.HealthService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; + +@RestController +@RequestMapping("/health") +@Tag(name = "Health Check", description = "APIs for checking infrastructure health status") +public class HealthController { + + private static final Logger logger = LoggerFactory.getLogger(HealthController.class); + + private final HealthService healthService; + + public HealthController(HealthService healthService) { + this.healthService = healthService; + } + + @GetMapping + @Operation(summary = "Check infrastructure health", + description = "Returns the health status of MySQL, Redis, and other configured services") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Services are UP or DEGRADED (operational with warnings)"), + @ApiResponse(responseCode = "503", description = "One or more critical services are DOWN") + }) + public ResponseEntity> checkHealth() { + logger.debug("Health check endpoint called"); + + try { + Map healthStatus = healthService.checkHealth(); + String overallStatus = (String) healthStatus.get("status"); + + HttpStatus httpStatus = "DOWN".equals(overallStatus) ? HttpStatus.SERVICE_UNAVAILABLE : HttpStatus.OK; + + logger.debug("Health check completed with status: {}", overallStatus); + return new ResponseEntity<>(healthStatus, httpStatus); + + } catch (Exception e) { + logger.error("Unexpected error during health check", e); + + Map errorResponse = Map.of( + "status", "DOWN", + "timestamp", Instant.now().toString() + ); + + return new ResponseEntity<>(errorResponse, HttpStatus.SERVICE_UNAVAILABLE); + } + } +} diff --git a/src/main/java/com/iemr/flw/controller/version/VersionController.java b/src/main/java/com/iemr/flw/controller/version/VersionController.java new file mode 100644 index 00000000..f2f2bf66 --- /dev/null +++ b/src/main/java/com/iemr/flw/controller/version/VersionController.java @@ -0,0 +1,80 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ + +package com.iemr.flw.controller.version; + +import java.io.IOException; +import java.io.InputStream; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Properties; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.v3.oas.annotations.Operation; + +@RestController +public class VersionController { + + private final Logger logger = LoggerFactory.getLogger(this.getClass().getSimpleName()); + + private static final String UNKNOWN_VALUE = "unknown"; + + @Operation(summary = "Get version information") + @GetMapping(value = "/version", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> versionInformation() { + Map response = new LinkedHashMap<>(); + try { + logger.info("version Controller Start"); + Properties gitProperties = loadGitProperties(); + response.put("buildTimestamp", gitProperties.getProperty("git.build.time", UNKNOWN_VALUE)); + response.put("version", gitProperties.getProperty("git.build.version", UNKNOWN_VALUE)); + response.put("branch", gitProperties.getProperty("git.branch", UNKNOWN_VALUE)); + response.put("commitHash", gitProperties.getProperty("git.commit.id.abbrev", UNKNOWN_VALUE)); + } catch (Exception e) { + logger.error("Failed to load version information", e); + response.put("buildTimestamp", UNKNOWN_VALUE); + response.put("version", UNKNOWN_VALUE); + response.put("branch", UNKNOWN_VALUE); + response.put("commitHash", UNKNOWN_VALUE); + } + logger.info("version Controller End"); + return ResponseEntity.ok(response); + } + + private Properties loadGitProperties() throws IOException { + Properties properties = new Properties(); + try (InputStream input = getClass().getClassLoader() + .getResourceAsStream("git.properties")) { + if (input != null) { + properties.load(input); + } + } + return properties; + } +} diff --git a/src/main/java/com/iemr/flw/service/health/HealthService.java b/src/main/java/com/iemr/flw/service/health/HealthService.java new file mode 100644 index 00000000..084ffe5e --- /dev/null +++ b/src/main/java/com/iemr/flw/service/health/HealthService.java @@ -0,0 +1,517 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ + +package com.iemr.flw.service.health; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.time.Instant; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.ExecutionException; +import java.util.function.Supplier; +import jakarta.annotation.PreDestroy; +import javax.sql.DataSource; +import com.zaxxer.hikari.HikariDataSource; +import com.zaxxer.hikari.HikariPoolMXBean; +import java.lang.management.ManagementFactory; +import javax.management.MBeanServer; +import javax.management.ObjectName; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; + +@Service +public class HealthService { + + private static final Logger logger = LoggerFactory.getLogger(HealthService.class); + + private static final String STATUS_KEY = "status"; + private static final String STATUS_UP = "UP"; + private static final String STATUS_DOWN = "DOWN"; + private static final String STATUS_DEGRADED = "DEGRADED"; + private static final String SEVERITY_KEY = "severity"; + private static final String SEVERITY_OK = "OK"; + private static final String SEVERITY_WARNING = "WARNING"; + private static final String SEVERITY_CRITICAL = "CRITICAL"; + private static final String ERROR_KEY = "error"; + private static final String MESSAGE_KEY = "message"; + private static final String RESPONSE_TIME_KEY = "responseTimeMs"; + private static final long MYSQL_TIMEOUT_SECONDS = 3; + private static final long REDIS_TIMEOUT_SECONDS = 3; + + private static final long ADVANCED_CHECKS_THROTTLE_SECONDS = 30; + private static final long RESPONSE_TIME_THRESHOLD_MS = 2000; + + private static final String DIAGNOSTIC_LOCK_WAIT = "MYSQL_LOCK_WAIT"; + private static final String DIAGNOSTIC_SLOW_QUERIES = "MYSQL_SLOW_QUERIES"; + private static final String DIAGNOSTIC_POOL_EXHAUSTED = "MYSQL_POOL_EXHAUSTED"; + private static final String DIAGNOSTIC_LOG_TEMPLATE = "Diagnostic: {}"; + + private final DataSource dataSource; + private final RedisTemplate redisTemplate; + private final ExecutorService executorService; + + private volatile long lastAdvancedCheckTime = 0; + private volatile AdvancedCheckResult cachedAdvancedCheckResult = null; + private final ReentrantReadWriteLock advancedCheckLock = new ReentrantReadWriteLock(); + private final AtomicBoolean advancedCheckInProgress = new AtomicBoolean(false); + + private static final boolean ADVANCED_HEALTH_CHECKS_ENABLED = true; + + public HealthService(DataSource dataSource, + @Autowired(required = false) RedisTemplate redisTemplate) { + this.dataSource = dataSource; + this.redisTemplate = redisTemplate; + this.executorService = Executors.newFixedThreadPool(6); + } + + @PreDestroy + public void shutdown() { + if (executorService != null && !executorService.isShutdown()) { + try { + executorService.shutdown(); + if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) { + executorService.shutdownNow(); + logger.warn("ExecutorService did not terminate gracefully"); + } + } catch (InterruptedException e) { + executorService.shutdownNow(); + Thread.currentThread().interrupt(); + logger.warn("ExecutorService shutdown interrupted", e); + } + } + } + + public Map checkHealth() { + Map response = new LinkedHashMap<>(); + response.put("timestamp", Instant.now().toString()); + + Map mysqlStatus = new ConcurrentHashMap<>(); + Map redisStatus = new ConcurrentHashMap<>(); + + if (!executorService.isShutdown()) { + performHealthChecks(mysqlStatus, redisStatus); + } + + ensurePopulated(mysqlStatus, "MySQL"); + ensurePopulated(redisStatus, "Redis"); + + Map> components = new LinkedHashMap<>(); + components.put("mysql", mysqlStatus); + components.put("redis", redisStatus); + + response.put("components", components); + response.put(STATUS_KEY, computeOverallStatus(components)); + + return response; + } + + private void performHealthChecks(Map mysqlStatus, Map redisStatus) { + Future mysqlFuture = null; + Future redisFuture = null; + try { + mysqlFuture = executorService.submit( + () -> performHealthCheck("MySQL", mysqlStatus, this::checkMySQLHealthSync)); + redisFuture = executorService.submit( + () -> performHealthCheck("Redis", redisStatus, this::checkRedisHealthSync)); + + awaitHealthChecks(mysqlFuture, redisFuture); + } catch (TimeoutException e) { + logger.warn("Health check aggregate timeout after {} seconds", getMaxTimeout()); + cancelFutures(mysqlFuture, redisFuture); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + logger.warn("Health check was interrupted"); + cancelFutures(mysqlFuture, redisFuture); + } catch (Exception e) { + logger.warn("Health check execution error: {}", e.getMessage()); + cancelFutures(mysqlFuture, redisFuture); + } + } + + private void awaitHealthChecks(Future mysqlFuture, Future redisFuture) throws TimeoutException, InterruptedException, ExecutionException { + long maxTimeout = getMaxTimeout(); + long deadlineNs = System.nanoTime() + TimeUnit.SECONDS.toNanos(maxTimeout); + + mysqlFuture.get(maxTimeout, TimeUnit.SECONDS); + long remainingNs = deadlineNs - System.nanoTime(); + + if (remainingNs > 0) { + redisFuture.get(remainingNs, TimeUnit.NANOSECONDS); + } else { + redisFuture.cancel(true); + } + } + + private long getMaxTimeout() { + return Math.max(MYSQL_TIMEOUT_SECONDS, REDIS_TIMEOUT_SECONDS) + 1; + } + + private void cancelFutures(Future mysqlFuture, Future redisFuture) { + if (mysqlFuture != null) mysqlFuture.cancel(true); + if (redisFuture != null) redisFuture.cancel(true); + } + + private void ensurePopulated(Map status, String componentName) { + if (!status.containsKey(STATUS_KEY)) { + status.put(STATUS_KEY, STATUS_DOWN); + status.put(SEVERITY_KEY, SEVERITY_CRITICAL); + status.put(ERROR_KEY, componentName + " health check did not complete in time"); + } + } + + private HealthCheckResult checkMySQLHealthSync() { + try (Connection connection = dataSource.getConnection(); + PreparedStatement stmt = connection.prepareStatement("SELECT 1 as health_check")) { + + stmt.setQueryTimeout((int) MYSQL_TIMEOUT_SECONDS); + + try (ResultSet rs = stmt.executeQuery()) { + if (!rs.next()) { + return new HealthCheckResult(false, "No result from health check query", false); + } + } + } catch (Exception e) { + logger.warn("MySQL health check failed: {}", e.getMessage(), e); + return new HealthCheckResult(false, "MySQL connection failed", false); + } + boolean isDegraded = performAdvancedMySQLChecksWithThrottle(); + return new HealthCheckResult(true, null, isDegraded); + } + + private HealthCheckResult checkRedisHealthSync() { + if (redisTemplate == null) { + return new HealthCheckResult(true, "Redis not configured — skipped", false); + } + + try { + String pong = redisTemplate.execute((org.springframework.data.redis.core.RedisCallback) (connection) -> connection.ping()); + + if ("PONG".equals(pong)) { + return new HealthCheckResult(true, null, false); + } + + return new HealthCheckResult(false, "Redis PING failed", false); + + } catch (Exception e) { + logger.warn("Redis health check failed: {}", e.getMessage(), e); + return new HealthCheckResult(false, "Redis connection failed", false); + } + } + + private Map performHealthCheck(String componentName, + Map status, + Supplier checker) { + long startTime = System.currentTimeMillis(); + + try { + HealthCheckResult result = checker.get(); + long responseTime = System.currentTimeMillis() - startTime; + + String componentStatus; + if (!result.isHealthy) { + componentStatus = STATUS_DOWN; + } else if (result.isDegraded) { + componentStatus = STATUS_DEGRADED; + } else { + componentStatus = STATUS_UP; + } + status.put(STATUS_KEY, componentStatus); + + status.put(RESPONSE_TIME_KEY, responseTime); + + String severity = determineSeverity(result.isHealthy, responseTime, result.isDegraded); + status.put(SEVERITY_KEY, severity); + + if (result.error != null) { + String fieldKey = result.isHealthy ? MESSAGE_KEY : ERROR_KEY; + status.put(fieldKey, result.error); + } + + return status; + + } catch (Exception e) { + long responseTime = System.currentTimeMillis() - startTime; + logger.error("{} health check failed with exception: {}", componentName, e.getMessage(), e); + + status.put(STATUS_KEY, STATUS_DOWN); + status.put(RESPONSE_TIME_KEY, responseTime); + status.put(SEVERITY_KEY, SEVERITY_CRITICAL); + status.put(ERROR_KEY, "Health check failed with an unexpected error"); + + return status; + } + } + + private String determineSeverity(boolean isHealthy, long responseTimeMs, boolean isDegraded) { + if (!isHealthy) { + return SEVERITY_CRITICAL; + } + + if (isDegraded) { + return SEVERITY_WARNING; + } + + if (responseTimeMs > RESPONSE_TIME_THRESHOLD_MS) { + return SEVERITY_WARNING; + } + + return SEVERITY_OK; + } + + private String computeOverallStatus(Map> components) { + boolean hasCritical = false; + boolean hasDegraded = false; + + for (Map componentStatus : components.values()) { + String status = (String) componentStatus.get(STATUS_KEY); + String severity = (String) componentStatus.get(SEVERITY_KEY); + + if (STATUS_DOWN.equals(status) || SEVERITY_CRITICAL.equals(severity)) { + hasCritical = true; + } + + if (STATUS_DEGRADED.equals(status)) { + hasDegraded = true; + } + + if (SEVERITY_WARNING.equals(severity)) { + hasDegraded = true; + } + } + + if (hasCritical) { + return STATUS_DOWN; + } + + if (hasDegraded) { + return STATUS_DEGRADED; + } + + return STATUS_UP; + } + + private boolean performAdvancedMySQLChecksWithThrottle() { + if (!ADVANCED_HEALTH_CHECKS_ENABLED) { + return false; + } + + long currentTime = System.currentTimeMillis(); + + advancedCheckLock.readLock().lock(); + try { + if (cachedAdvancedCheckResult != null && + (currentTime - lastAdvancedCheckTime) < ADVANCED_CHECKS_THROTTLE_SECONDS * 1000) { + return cachedAdvancedCheckResult.isDegraded; + } + } finally { + advancedCheckLock.readLock().unlock(); + } + + // Only one thread may submit; others fall back to the (stale) cache + if (!advancedCheckInProgress.compareAndSet(false, true)) { + advancedCheckLock.readLock().lock(); + try { + return cachedAdvancedCheckResult != null && cachedAdvancedCheckResult.isDegraded; + } finally { + advancedCheckLock.readLock().unlock(); + } + } + + try { + // Perform DB I/O outside the write lock to avoid lock contention + AdvancedCheckResult result; + try (Connection connection = dataSource.getConnection()) { + result = performAdvancedMySQLChecks(connection); + } catch (Exception e) { + if (e.getCause() instanceof InterruptedException) { + Thread.currentThread().interrupt(); + } + logger.debug("Failed to get connection for advanced checks: {}", e.getMessage()); + result = new AdvancedCheckResult(false); + } + + // Re-acquire write lock only to update the cache atomically + advancedCheckLock.writeLock().lock(); + try { + lastAdvancedCheckTime = currentTime; + cachedAdvancedCheckResult = result; + return result.isDegraded; + } finally { + advancedCheckLock.writeLock().unlock(); + } + } finally { + advancedCheckInProgress.set(false); + } + } + + private AdvancedCheckResult performAdvancedMySQLChecks(Connection connection) { + try { + boolean hasIssues = false; + + if (hasLockWaits(connection)) { + logger.warn(DIAGNOSTIC_LOG_TEMPLATE, DIAGNOSTIC_LOCK_WAIT); + hasIssues = true; + } + + if (hasSlowQueries(connection)) { + logger.warn(DIAGNOSTIC_LOG_TEMPLATE, DIAGNOSTIC_SLOW_QUERIES); + hasIssues = true; + } + + if (hasConnectionPoolExhaustion()) { + logger.warn(DIAGNOSTIC_LOG_TEMPLATE, DIAGNOSTIC_POOL_EXHAUSTED); + hasIssues = true; + } + + return new AdvancedCheckResult(hasIssues); + } catch (Exception e) { + logger.debug("Advanced MySQL checks encountered exception, marking degraded"); + return new AdvancedCheckResult(true); + } + } + + private boolean hasLockWaits(Connection connection) { + try (PreparedStatement stmt = connection.prepareStatement( + "SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST " + + "WHERE (state = 'Waiting for table metadata lock' " + + " OR state = 'Waiting for row lock' " + + " OR state = 'Waiting for lock') " + + "AND user = SUBSTRING_INDEX(USER(), '@', 1)")) { + stmt.setQueryTimeout(2); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + int lockCount = rs.getInt(1); + return lockCount > 0; + } + } + } catch (Exception e) { + logger.debug("Could not check for lock waits"); + } + return false; + } + + + private boolean hasSlowQueries(Connection connection) { + try (PreparedStatement stmt = connection.prepareStatement( + "SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST " + + "WHERE command != 'Sleep' AND time > ? AND user = SUBSTRING_INDEX(USER(), '@', 1)")) { + stmt.setQueryTimeout(2); + stmt.setInt(1, 10); + try (ResultSet rs = stmt.executeQuery()) { + if (rs.next()) { + int slowQueryCount = rs.getInt(1); + return slowQueryCount > 3; + } + } + } catch (Exception e) { + logger.debug("Could not check for slow queries"); + } + return false; + } + + private boolean hasConnectionPoolExhaustion() { + if (dataSource instanceof HikariDataSource hikariDataSource) { + try { + HikariPoolMXBean poolMXBean = hikariDataSource.getHikariPoolMXBean(); + + if (poolMXBean != null) { + int activeConnections = poolMXBean.getActiveConnections(); + int maxPoolSize = hikariDataSource.getMaximumPoolSize(); + + int threshold = (int) (maxPoolSize * 0.8); + return activeConnections > threshold; + } + } catch (Exception e) { + logger.debug("Could not retrieve HikariCP pool metrics"); + } + } + + return checkPoolMetricsViaJMX(); + } + + private boolean checkPoolMetricsViaJMX() { + try { + MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); + ObjectName objectName = new ObjectName("com.zaxxer.hikari:type=Pool (*)"); + var mBeans = mBeanServer.queryMBeans(objectName, null); + + for (var mBean : mBeans) { + if (evaluatePoolMetrics(mBeanServer, mBean.getObjectName())) { + return true; + } + } + } catch (Exception e) { + logger.debug("Could not access HikariCP pool metrics via JMX"); + } + + logger.debug("Pool exhaustion check disabled: HikariCP metrics unavailable"); + return false; + } + + private boolean evaluatePoolMetrics(MBeanServer mBeanServer, ObjectName objectName) { + try { + Integer activeConnections = (Integer) mBeanServer.getAttribute(objectName, "ActiveConnections"); + Integer maximumPoolSize = (Integer) mBeanServer.getAttribute(objectName, "MaximumPoolSize"); + + if (activeConnections != null && maximumPoolSize != null) { + int threshold = (int) (maximumPoolSize * 0.8); + return activeConnections > threshold; + } + } catch (Exception e) { + // Continue to next MBean + } + return false; + } + + private static class AdvancedCheckResult { + final boolean isDegraded; + + AdvancedCheckResult(boolean isDegraded) { + this.isDegraded = isDegraded; + } + } + + private static class HealthCheckResult { + final boolean isHealthy; + final String error; + final boolean isDegraded; + + HealthCheckResult(boolean isHealthy, String error, boolean isDegraded) { + this.isHealthy = isHealthy; + this.error = error; + this.isDegraded = isDegraded; + } + } +} diff --git a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java index 1bb705ed..9cf022f0 100644 --- a/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java @@ -152,7 +152,9 @@ private boolean shouldSkipPath(String path, String contextPath) { return path.equals(contextPath + "/user/userAuthenticate") || path.equalsIgnoreCase(contextPath + "/user/logOutUserFromConcurrentSession") || path.startsWith(contextPath + "/swagger-ui") || path.startsWith(contextPath + "/v3/api-docs") - || path.startsWith(contextPath + "/public"); + || path.startsWith(contextPath + "/public") + || path.equals(contextPath + "/health") + || path.equals(contextPath + "/version"); } private String getJwtTokenFromCookies(HttpServletRequest request) { From 164d17c5e8e2a6598fae6d3c899746c36ec0f3c9 Mon Sep 17 00:00:00 2001 From: Vanitha S <116701245+vanitha1822@users.noreply.github.com> Date: Wed, 18 Mar 2026 17:41:53 +0530 Subject: [PATCH 776/792] Bump version from 3.7.0 to 3.8.0 (#220) --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f7681e6a..707e18a2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.iemr.common.flw flw-api - 3.7.0 + 3.8.0 war FLW-API From c1eed26c7b9f4ce787b2586ff2621ef7240a49b2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Mar 2026 16:00:28 +0530 Subject: [PATCH 777/792] fix CBAC incentive --- .../iemr/flw/domain/iemr/CbacDetailsImer.java | 330 +++++++++++++++ .../flw/repo/identity/BeneficiaryRepo.java | 37 +- .../flw/repo/iemr/BenReferDetailsRepo.java | 6 + .../flw/repo/iemr/CbacIemrDetailsRepo.java | 44 ++ .../IncentiveActivityLangMappingRepo.java | 3 + .../flw/repo/iemr/IncentiveRecordRepo.java | 12 + .../iemr/flw/repo/iemr/IncentivesRepo.java | 18 +- .../service/impl/IncentiveServiceImpl.java | 400 +++++++++++++----- 8 files changed, 735 insertions(+), 115 deletions(-) create mode 100644 src/main/java/com/iemr/flw/domain/iemr/CbacDetailsImer.java create mode 100644 src/main/java/com/iemr/flw/repo/iemr/CbacIemrDetailsRepo.java diff --git a/src/main/java/com/iemr/flw/domain/iemr/CbacDetailsImer.java b/src/main/java/com/iemr/flw/domain/iemr/CbacDetailsImer.java new file mode 100644 index 00000000..989ed1d1 --- /dev/null +++ b/src/main/java/com/iemr/flw/domain/iemr/CbacDetailsImer.java @@ -0,0 +1,330 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.flw.domain.iemr; + +import java.sql.Timestamp; + +import jakarta.persistence.*; + +import com.google.gson.annotations.Expose; +import lombok.Data; + +@Entity +@Table(name = "t_cbacdetails") +@Data +public class CbacDetailsImer { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Expose + @Column(name = "Id", insertable = false) + private Long id; + @Expose + @Column(name = "BeneficiaryRegId") + private Long beneficiaryRegId; + + @Expose + @Column(name = "Visitcode") + private Long visitCode; + @Expose + @Column(name = "Cbac_Age") + private String cbacAge; + @Expose + @Column(name = "Cbac_Age_Score") + private Integer cbacAgeScore; + @Expose + @Column(name = "Cbac_ConusmeGutka") + private String cbacConsumeGutka; + @Expose + @Column(name = "Cbac_ConusmeGutka_Score") + private Integer cbacConsumeGutkaScore; + @Expose + @Column(name = "cbac_alcohol") + private String cbacAlcohol; + @Expose + @Column(name = "cbac_alcohol_Score") + private Integer cbacAlcoholScore; + @Expose + @Column(name = "Cbac_waist_Male") + private String cbacWaistMale; + @Expose + @Column(name = "Cbac_waist_Male_Score") + private Integer cbacWaistMaleScore; + @Expose + @Column(name = "Cbac_Waist_Female") + private String cbacWaistFemale; + @Expose + @Column(name = "Cbac_Waist_Female_Score") + private Integer cbacWaistFemaleScore; + @Expose + @Column(name = "Cbac_PhysicalActivity") + private String cbacPhysicalActivity; + @Expose + @Column(name = "Cbac_PhysicalActivity_Score") + private Integer cbacPhysicalActivityScore; + @Expose + @Column(name = "Cbac_FamilyHistory_bpdiabetes") + private String cbacFamilyHistoryBpdiabetes; + @Expose + @Column(name = "Cbac_FamilyHistory_bpdiabetes_Score") + private Integer cbacFamilyHistoryBpdiabetesScore; + @Expose + @Column(name = "Cbac_ShortnessBreath") + private String cbacShortnessBreath; + @Expose + @Column(name = "Cbac_Cough2weeks") + private String cbacCough2weeks; + @Expose + @Column(name = "Cbac_Bloodsputum") + private String cbacBloodsputum; + @Expose + @Column(name = "Cbac_fever2weeks") + private String cbacFever2weeks; + @Expose + @Column(name = "Cbac_WeightLoss") + private String cbacWeightLoss; + @Expose + @Column(name = "Cbac_NightSweats") + private String cbacNightSweats; + @Expose + @Column(name = "Cbac_AntiTBDrugs") + private String cbacAntiTBDrugs; + @Expose + @Column(name = "Cabc_TB") + private String cbacTb; + @Expose + @Column(name = "Cbac_TBHistory") + private String cbacTBHistory; + @Expose + @Column(name = "Cbac_Ulceration") + private String cbacUlceration; + @Expose + @Column(name = "Cbac_RecurrentTingling") + private String cbacRecurrentTingling; + @Expose + @Column(name = "Cbac_FitsHistory") + private String cbacFitsHistory; + @Expose + @Column(name = "Cbac_MouthopeningDifficulty") + private String cbacMouthopeningDifficulty; + @Expose + @Column(name = "Cbac_MouthUlcers") + private String cbacMouthUlcers; + @Expose + @Column(name = "Cbac_MouthUlcersGrowth") + private String cbacMouthUlcersGrowth; + @Expose + @Column(name = "Cbac_Mouthredpatch") + private String cbacMouthredpatch; + @Expose + @Column(name = "Cbac_Painchewing") + private String cbacPainchewing; + @Expose + @Column(name = "Cbac_Tonechange") + private String cbacTonechange; + @Expose + @Column(name = "Cbac_Hypopigmentedpatches") + private String cbacHypopigmentedpatches; + @Expose + @Column(name = "Cbac_Thickenedskin") + private String cbacThickenedskin; + @Expose + @Column(name = "Cbac_Nodulesonskin") + private String cbacNodulesonskin; + @Expose + @Column(name = "Cbac_RecurrentNumbness") + private String cbacRecurrentNumbness; + @Expose + @Column(name = "Cbac_BlurredVision") + private String cbacBlurredVision; + @Expose + @Column(name = "Cbac_Difficultyreading") + private String cbacDifficultyreading; + @Expose + @Column(name = "Cbac_Painineyes") + private String cbacPainineyes; + @Expose + @Column(name = "Cbac_RednessPain") + private String cbacRednessPain; + @Expose + @Column(name = "Cbac_DifficultyHearing") + private String cbacDifficultyHearing; + @Expose + @Column(name = "Cbac_Clawingfingers") + private String cbacClawingfingers; + @Expose + @Column(name = "Cbac_HandTingling") + private String cbacHandTingling; + @Expose + @Column(name = "Cbac_InabilityCloseeyelid") + private String cbacInabilityCloseeyelid; + @Expose + @Column(name = "Cbac_DifficultHoldingObjects") + private String cbacDifficultHoldingObjects; + @Expose + @Column(name = "Cbac_Feetweakness") + private String cbacFeetweakness; + @Expose + @Column(name = "Cbac_LumpBreast") + private String cbacLumpBreast; + @Expose + @Column(name = "Cbac_BloodnippleDischarge") + private String cbacBloodnippleDischarge; + @Expose + @Column(name = "Cbac_Breastsizechange") + private String cbacBreastsizechange; + @Expose + @Column(name = "Cbac_BleedingPeriods") + private String cbacBleedingPeriods; + @Expose + @Column(name = "Cbac_BleedingMenopause") + private String cbacBleedingMenopause; + @Expose + @Column(name = "Cbac_BleedingIntercourse") + private String cbacBleedingIntercourse; + @Expose + @Column(name = "Cbac_VaginalDischarge") + private String cbacVaginalDischarge; + @Expose + @Column(name = "Cbac_FeelingUnsteady") + private String cbacFeelingUnsteady; + @Expose + @Column(name = "Cbac_PhysicalDisabilitySuffering") + private String cbacPhysicalDisabilitySuffering; + @Expose + @Column(name = "Cbac_NeedhelpEverydayActivities") + private String cbacNeedhelpEverydayActivities; + @Expose + @Column(name = "Cbac_Forgetnearones") + private String cbacForgetnearones; + @Expose + @Column(name = "ProviderServiceMapID") + private Integer providerServiceMapId; + + @Expose + @Column(name = "Total_Score") + private Integer totalScore; + @Expose + @Column(name = "Deleted", insertable = false, updatable = true) + private Boolean deleted; + + @Expose + @Column(name = "Processed", insertable = false, updatable = true) + private Character processed; + + @Expose + @Column(name = "CreatedBy") + private String createdBy; + + @Expose + @Column(name = "CreatedDate", insertable = false, updatable = false) + private Timestamp createdDate; + + @Expose + @Column(name = "ModifiedBy") + private String modifiedBy; + + @Expose + @Column(name = "LastModDate", insertable = false, updatable = false) + private Timestamp lastModDate; + + @Expose + @Column(name = "VanSerialNo") + private Integer vanSerialNo; + @Expose + @Column(name = "VanID") + private Integer vanId; + @Expose + @Column(name = "VehicalNo") + private String vehicalNo; + @Expose + @Column(name = "ParkingPlaceID") + private Integer parkingPlaceId; + @Expose + @Column(name = "SyncedBy") + private String syncedBy; + @Expose + @Column(name = "SyncedDate") + private Timestamp syncedDate; + + @Transient + @Expose + private Long beneficiaryId; + + @Expose + @Column(name = "Cbac_OccupationalExposure") + private String CbacOccupationalExposure; + + @Expose + @Column(name = "Cbac_BotheredProblem_last2weeks") + private String CbacBotheredProblemLast2weeks; + + @Expose + @Column(name = "Cbac_LittleInterest_Pleasure") + private String CbacLittleInterestPleasure; + + @Expose + @Column(name = "Cbac_Depressed_hopeless") + private String CbacDepressedhopeless; + + @Expose + @Column(name = "Cbac_DiscolorationSkin") + private String CbacDiscolorationSkin; + + @Expose + @Column(name = "Cbac_Cooking_Oil") + private String CbacCookingOil; + + @Expose + @Column(name = "Cbac_OccupationalExposure_score") + private String CbacOccupationalExposureScore; + + @Expose + @Column(name = "Cbac_BotheredProblem_last2weeks_score") + private String CbacBotheredProblemLast2weeksScore; + + @Expose + @Column(name = "Cbac_LittleInterest_Pleasure_score") + private String CbacLittleInterestPleasureScore; + + @Expose + @Column(name = "Cbac_Depressed_hopeless_score") + private String CbacDepressedhopelessScore; + + @Expose + @Column(name = "Cbac_Cooking_Oil_score") + private String CbacCookingOilScore; + + + @Expose + @Column(name = "Cbac_Feeling_Down_score") + private String CbacFeelingDownScore; + + @Expose + @Column(name = "is_refer") + private Boolean isRefer; + + + + + + +} diff --git a/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java b/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java index 96301fb3..245b32f9 100644 --- a/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java +++ b/src/main/java/com/iemr/flw/repo/identity/BeneficiaryRepo.java @@ -12,6 +12,8 @@ import java.math.BigInteger; import java.sql.Timestamp; import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import java.util.Optional; @Repository @@ -28,10 +30,15 @@ public interface BeneficiaryRepo extends JpaRepository getBenDataWithinDates(@Param("userName") String userName, - @Param("fromDate") Timestamp fromDate, @Param("toDate") Timestamp toDate, Pageable pageable); + + @Query("SELECT t FROM RMNCHMBeneficiaryaddress t " + + "WHERE t.createdDate BETWEEN :fromDate AND :toDate " + + "AND t.createdBy = :userName") + Page getBenDataWithinDates( + @Param("userName") String userName, + @Param("fromDate") Timestamp fromDate, + @Param("toDate") Timestamp toDate, + Pageable pageable); @Query(value = " SELECT t FROM RMNCHMBeneficiaryaddress t WHERE t.createdBy = :userName ") Page getBenDataByUser(@Param("userName") String userName, Pageable pageable); @@ -83,6 +90,24 @@ Page getBenDataWithinDates(@Param("userName") String u RMNCHMBeneficiarydetail findByBeneficiaryDetailsId(@Param("beneficiaryDetailsId") BigInteger beneficiaryDetailsId); - - + // BeneficiaryRepo — replaces 3 separate queries per beneficiary + @Query(value = """ + SELECT + ibd.BeneficiaryId AS benId, + bd.firstName AS firstName, + bd.lastName AS lastName + FROM db_identity.i_beneficiarydetails_rmnch ibd + JOIN db_identity.i_beneficiarymapping bm + ON bm.BenRegId = ibd.BeneficiaryRegID + JOIN db_identity.i_beneficiarydetails bd + ON bd.beneficiaryDetailsId = bm.BenDetailsId + WHERE ibd.BeneficiaryId IN :benIds + """, nativeQuery = true) + List findBenNamesByBenIds(@Param("benIds") List benIds); + +// BeneficiaryRepo — replaces the per-row getBenIdFromRegID call +@Query("SELECT b.BenRegId, b.benficieryid " + + "FROM RMNCHBeneficiaryDetailsRmnch b " + + "WHERE b.BenRegId IN :regIds AND b.benficieryid IS NOT NULL") +List getBenIdsFromRegIDs(@Param("regIds") List regIds); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/BenReferDetailsRepo.java b/src/main/java/com/iemr/flw/repo/iemr/BenReferDetailsRepo.java index b5277c19..f2c915f4 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/BenReferDetailsRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/BenReferDetailsRepo.java @@ -24,11 +24,15 @@ import com.iemr.flw.domain.iemr.BenReferDetails; +import io.swagger.v3.oas.annotations.info.License; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; +import java.util.List; +import java.util.Optional; + @Repository public interface BenReferDetailsRepo extends JpaRepository { @@ -40,4 +44,6 @@ public interface BenReferDetailsRepo extends JpaRepository findByCreatedBy(String userName); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/CbacIemrDetailsRepo.java b/src/main/java/com/iemr/flw/repo/iemr/CbacIemrDetailsRepo.java new file mode 100644 index 00000000..5e93dfad --- /dev/null +++ b/src/main/java/com/iemr/flw/repo/iemr/CbacIemrDetailsRepo.java @@ -0,0 +1,44 @@ +/* +* AMRIT – Accessible Medical Records via Integrated Technology +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.flw.repo.iemr; + +import com.iemr.flw.domain.iemr.CbacDetailsImer; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + + +import java.util.List; + +@Repository +public interface CbacIemrDetailsRepo extends CrudRepository { + + public CbacDetailsImer findByBeneficiaryRegIdAndVisitCode(Long beneficiaryRegId, Long visitCode); + + List findByCreatedBy(String userName); + + @Query(value = "SELECT BeneficiaryID FROM db_identity.m_beneficiaryregidmapping " + + "WHERE BenRegId = :benRegId AND Deleted = 0", nativeQuery = true) + Long getBeneficiaryId(@Param("benRegId") Long benRegId); + +} diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java index f9807010..4ba40dc6 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveActivityLangMappingRepo.java @@ -3,9 +3,12 @@ import com.iemr.flw.domain.iemr.IncentiveActivityLangMapping; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Collection; import java.util.List; import java.util.Optional; public interface IncentiveActivityLangMappingRepo extends JpaRepository { IncentiveActivityLangMapping findByIdAndName(Long activityId,String activityName); + List findAllByIdIn(List ids); + } diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java index 6b8db13e..2c10f69e 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentiveRecordRepo.java @@ -41,4 +41,16 @@ IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId( @Query("select record from IncentiveActivityRecord record where record.ashaId = :ashaId") List findRecordsByAsha(@Param("ashaId") Integer ashaId); + + + // RecordRepo — existing records batch mein fetch karo + @Query("SELECT r FROM IncentiveActivityRecord r " + + "WHERE r.activityId = :activityId " + + "AND r.benId IN :benIds " + + "AND r.ashaId = :ashaId") + List findExistingRecords( + @Param("activityId") Long activityId, + @Param("benIds") List benIds, + @Param("ashaId") Integer ashaId + ); } diff --git a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java index 112f74ef..5dda5900 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/IncentivesRepo.java @@ -9,7 +9,9 @@ import org.springframework.stereotype.Repository; import java.sql.Timestamp; +import java.util.Collection; import java.util.List; +import java.util.Set; @Repository public interface IncentivesRepo extends JpaRepository { @@ -28,4 +30,18 @@ IncentiveActivity findIncentiveMasterById( @Query("select record from IncentiveActivityRecord record where record.activityId = :id and record.createdDate = :createdDate and record.benId = :benId") IncentiveActivityRecord findRecordByActivityIdCreatedDateBenId(@Param("id") Long id, @Param("createdDate") Timestamp createdDate, @Param("benId") Long benId); -} + + List findByGroupAndIsDeleted(String group, Boolean isDeleted); + + List findByGroupNotAndIsDeleted(String group, Boolean isDeleted); + + // IncentivesRepo — replaces N calls to findIncentiveMasterById() + @Query("SELECT i.id FROM IncentiveActivity i WHERE i.id IN :ids AND i.isDeleted = false AND " + + "(:isCG = true AND i.group = 'ACTIVITY' OR :isCG = false AND i.group != 'ACTIVITY')") + Set findValidActivityIds(@Param("ids") List ids, @Param("isCG") boolean isCG); + + @Query("SELECT i FROM IncentiveActivity i WHERE i.name IN :names AND i.group = :groupName") + List findIncentiveMasterByNameAndGroup( + @Param("names") List names, + @Param("groupName") String groupName + );} diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index 5580e896..e09af740 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -3,10 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.iemr.flw.domain.identity.RMNCHMBeneficiarydetail; -import com.iemr.flw.domain.iemr.IncentiveActivity; -import com.iemr.flw.domain.iemr.IncentiveActivityLangMapping; -import com.iemr.flw.domain.iemr.IncentiveActivityRecord; -import com.iemr.flw.domain.iemr.IncentivePendingActivity; +import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.GroupName; @@ -28,6 +25,8 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; import java.util.stream.Collectors; @Service @@ -59,6 +58,12 @@ public class IncentiveServiceImpl implements IncentiveService { @Autowired private MaaMeetingService maaMeetingService; + @Autowired + private BenReferDetailsRepo benReferDetailsRepo; + + @Autowired + private CbacIemrDetailsRepo cbacIemrDetailsRepo; + @Override public String saveIncentivesMaster(List activityDTOS) { try { @@ -78,7 +83,7 @@ public String saveIncentivesMaster(List activityDTOS) { }); String saved = ""; activityDTOS.forEach(dto -> saved.concat(dto.getGroup() + ": " + dto.getName())); - return "saved master data for " + saved ; + return "saved master data for " + saved; } catch (Exception e) { } @@ -88,183 +93,362 @@ public String saveIncentivesMaster(List activityDTOS) { @Override public String getIncentiveMaster(IncentiveRequestDTO incentiveRequestDTO) { try { + Integer stateCode = incentiveRequestDTO.getState(); + String langCode = incentiveRequestDTO.getLangCode(); - List incs = new ArrayList<>(); - if(incentiveRequestDTO.getState()==StateCode.CG.getStateCode()){ - incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + // Integer comparison using intValue() — safe and reliable + boolean isCG = stateCode != null && stateCode.intValue() == StateCode.CG.getStateCode(); + boolean isAM = stateCode != null && stateCode.intValue() == StateCode.AM.getStateCode(); - }else { - incs = incentivesRepo.findAll().stream().filter(incentiveActivity -> !incentiveActivity.getGroup().equals("ACTIVITY")).collect(Collectors.toList()); + // Single filtered DB query instead of findAll() + stream filter + List incs = isCG + ? incentivesRepo.findByGroupAndIsDeleted("ACTIVITY", false) + : incentivesRepo.findByGroupNotAndIsDeleted("ACTIVITY", false); + if (incs.isEmpty()) { + return new Gson().toJson(Collections.emptyList()); } - List dtos = incs.stream().map(inc -> { - IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); - // Fetch language mapping - IncentiveActivityLangMapping mapping = incentiveActivityLangMappingRepo - .findByIdAndName(inc.getId(),inc.getName()); + // Fetch ALL lang mappings in ONE query instead of N queries in loop + List ids = incs.stream() + .map(IncentiveActivity::getId) + .collect(Collectors.toList()); + Map mappingById = incentiveActivityLangMappingRepo + .findAllByIdIn(ids) + .stream() + .collect(Collectors.toMap( + IncentiveActivityLangMapping::getId, + Function.identity() + )); + List dtos = incs.stream().map(inc -> { + IncentiveActivityDTO dto = modelMapper.map(inc, IncentiveActivityDTO.class); + IncentiveActivityLangMapping mapping = mappingById.get(inc.getId()); if (mapping != null) { dto.setName(mapping.getName()); - dto.setGroupName(mapping.getGroup()); - if(Objects.equals(incentiveRequestDTO.getLangCode(), "en")){ - dto.setDescription(inc.getDescription()); - + if (isCG) { + dto.setGroupName(""); + } else if (isAM) { + dto.setGroupName(mapping.getGroup()); + } - }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "as")){ - - if(mapping.getAssameActivityDescription()!=null){ - dto.setDescription(mapping.getAssameActivityDescription()); - - }else { - dto.setDescription(mapping.getDescription()); - - } - - }else if(Objects.equals(incentiveRequestDTO.getLangCode(), "hi")){ - if(mapping.getHindiActivityDescription()!=null){ - dto.setDescription(mapping.getHindiActivityDescription()); - - }else { - dto.setDescription(mapping.getDescription()); + // Set description based on language + if ("as".equals(langCode)) { + dto.setDescription(mapping.getAssameActivityDescription() != null + ? mapping.getAssameActivityDescription() + : mapping.getDescription()); - } + } else if ("hi".equals(langCode)) { + dto.setDescription(mapping.getHindiActivityDescription() != null + ? mapping.getHindiActivityDescription() + : mapping.getDescription()); + } else { + // default "en" + dto.setDescription(inc.getDescription()); } - }else { + } else { dto.setGroupName(inc.getGroup()); - } return dto; }).collect(Collectors.toList()); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); - return gson.toJson(dtos); + } catch (Exception e) { - e.printStackTrace(); + logger.error("Error in getIncentiveMaster: ", e); } return null; - } @Override public String getAllIncentivesByUserId(GetBenRequestHandler request) { + try { + if (request.getVillageID() != StateCode.CG.getStateCode()) { + checkMonthlyAshaIncentive(request.getAshaId()); + } + } catch (Exception e) { + logger.error("Error in checkMonthlyAshaIncentive: ", e); + } - if(request.getVillageID()!= StateCode.CG.getStateCode()){ + try { + + incentiveOfNcdReferal(request.getAshaId(), request.getVillageID()); + + } catch (Exception e) { + logger.error("Error in incentiveOfNcdReferal: ", e); + } + + Integer villageID = request.getVillageID(); + boolean isCG = villageID != null && villageID.intValue() == StateCode.CG.getStateCode(); + + if (!isCG) { checkMonthlyAshaIncentive(request.getAshaId()); } - List dtos = new ArrayList<>(); + // Step 1: Fetch all records for this ASHA List entities = recordRepo.findRecordsByAsha(request.getAshaId()); - if(request.getVillageID()==StateCode.CG.getStateCode()){ - entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),true)!=null).collect(Collectors.toList()); - }else { - entities = entities.stream().filter(entitie-> incentivesRepo.findIncentiveMasterById(entitie.getActivityId(),false)!=null).collect(Collectors.toList()); + if (entities.isEmpty()) { + return new Gson().toJson(Collections.emptyList()); + } + // Step 2: Collect all activityIds — fetch valid ones in ONE query + List activityIds = entities.stream() + .map(IncentiveActivityRecord::getActivityId) + .distinct() + .collect(Collectors.toList()); + + // Single bulk query instead of N individual findIncentiveMasterById() calls + Set validActivityIds = isCG + ? incentivesRepo.findValidActivityIds(activityIds, true) + : incentivesRepo.findValidActivityIds(activityIds, false); + + // Filter entities based on valid activity IDs + entities = entities.stream() + .filter(e -> validActivityIds.contains(e.getActivityId())) + .collect(Collectors.toList()); + + // Step 3: Collect all benIds that need name lookup (name == null and benId > 0) + List benIdsToFetch = entities.stream() + .filter(e -> e.getName() == null && e.getBenId() != null && e.getBenId() > 0) + .map(IncentiveActivityRecord::getBenId) + .distinct() + .collect(Collectors.toList()); + + // Step 4: Bulk fetch all beneficiary names in ONE query instead of 3 queries per record + Map benIdToNameMap = new HashMap<>(); + if (!benIdsToFetch.isEmpty()) { + List benDetails = beneficiaryRepo.findBenNamesByBenIds(benIdsToFetch); + for (Object[] row : benDetails) { + Long benId = ((Number) row[0]).longValue(); + String first = row[1] != null ? (String) row[1] : ""; + String last = row[2] != null ? (String) row[2] : ""; + benIdToNameMap.put(benId, (first + " " + last).trim()); + } } - entities.forEach(entry -> { - if(entry.getName()==null){ - if(entry.getBenId()!=0 && entry.getBenId()>0L){ - Long regId = beneficiaryRepo.getBenRegIdFromBenId(entry.getBenId()); - logger.info("rmnchBeneficiaryDetailsRmnch"+regId); - BigInteger benDetailId = beneficiaryRepo.findByBenRegIdFromMapping(BigInteger.valueOf(regId)).getBenDetailsId(); - RMNCHMBeneficiarydetail rmnchBeneficiaryDetails = beneficiaryRepo.findByBeneficiaryDetailsId(benDetailId); - String beneName = rmnchBeneficiaryDetails.getFirstName()+" "+rmnchBeneficiaryDetails.getLastName(); - entry.setName(beneName); - - }else{ - entry.setName(""); + // Step 5: Map entities to DTOs + List dtos = entities.stream().map(entry -> { + if (entry.getName() == null) { + if (entry.getBenId() != null && entry.getBenId() > 0) { + String name = benIdToNameMap.getOrDefault(entry.getBenId(), ""); + entry.setName(name); + if (isCG) { + entry.setIsEligible(true); + } + } else { + entry.setName(""); } - } - - dtos.add(modelMapper.map(entry, IncentiveRecordDTO.class)); - - }); + return modelMapper.map(entry, IncentiveRecordDTO.class); + }).collect(Collectors.toList()); Gson gson = new GsonBuilder().setDateFormat("MMM dd, yyyy h:mm:ss a").create(); return gson.toJson(dtos); } + @Override public String updateIncentive(PendingActivityDTO pendingActivityDTO) { - Optional incentivePendingActivity = incentivePendingActivityRepository.findByUserIdAndModuleNameAndActivityId(pendingActivityDTO.getUserId(),pendingActivityDTO.getModuleName(),pendingActivityDTO.getId()); + Optional incentivePendingActivity = incentivePendingActivityRepository.findByUserIdAndModuleNameAndActivityId(pendingActivityDTO.getUserId(), pendingActivityDTO.getModuleName(), pendingActivityDTO.getId()); - if(incentivePendingActivity.isPresent()){ + if (incentivePendingActivity.isPresent()) { IncentivePendingActivity existingIncentivePendingActivity = incentivePendingActivity.get(); - if(existingIncentivePendingActivity.getModuleName().equals("MAA_MEETING")){ - if(pendingActivityDTO.getImages()!=null){ + if (existingIncentivePendingActivity.getModuleName().equals("MAA_MEETING")) { + if (pendingActivityDTO.getImages() != null) { try { MaaMeetingRequestDTO maaMeetingRequestDTO = new MaaMeetingRequestDTO(); maaMeetingRequestDTO.setMeetingImages(pendingActivityDTO.getImages().toArray(new MultipartFile[0])); maaMeetingService.updateMeeting(maaMeetingRequestDTO); - }catch (Exception e){ + } catch (Exception e) { return e.getMessage(); } } } } - return null; + return null; } - private void checkMonthlyAshaIncentive(Integer ashaId){ - IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); - IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); - IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); - if(MOBILEBILLREIMB_ACTIVITY!=null){ - addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY,ashaId); + private void incentiveOfNcdReferal(Integer ashaId, Integer stateId) { + try { + String userName = userRepo.getUserNamedByUserId(ashaId); + String groupName = resolveGroupName(stateId); + + Map activityMap = + incentivesRepo.findIncentiveMasterByNameAndGroup( + List.of("NCD_POP_ENUMERATION", "NCD_FOLLOWUP_TREATMENT"), groupName + ).stream().collect(Collectors.toMap(IncentiveActivity::getName, Function.identity())); + + IncentiveActivity ncdPopEnumeration = activityMap.get("NCD_POP_ENUMERATION"); + IncentiveActivity ncdFollowupTreatment = activityMap.get("NCD_FOLLOWUP_TREATMENT"); + + CompletableFuture> benReferFuture = + CompletableFuture.supplyAsync(() -> benReferDetailsRepo.findByCreatedBy(userName)); + CompletableFuture> cbacFuture = + CompletableFuture.supplyAsync(() -> cbacIemrDetailsRepo.findByCreatedBy(userName)); + + List benReferDetails = benReferFuture.get(); + List cbacDetailsImer = cbacFuture.get(); + + List recordsToSave = new ArrayList<>(); + + if (ncdFollowupTreatment != null && !benReferDetails.isEmpty()) { + + List benIds = benReferDetails.stream() + .map(BenReferDetails::getBeneficiaryRegID) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + + Set existingKeys = recordRepo + .findExistingRecords(ncdFollowupTreatment.getId(), benIds, ashaId) + .stream() + .map(r -> r.getActivityId() + "_" + r.getBenId() + "_" + r.getCreatedDate()) + .collect(Collectors.toSet()); + + final IncentiveActivity activity = ncdFollowupTreatment; + benReferDetails.forEach(ref -> { + Long benId = ref.getBeneficiaryRegID(); + if (benId != null) { + String key = activity.getId() + "_" + benId + "_" + ref.getCreatedDate(); + if (!existingKeys.contains(key)) { + recordsToSave.add(addNCDandCBACIncentiveRecord(activity, ashaId, benId, ref.getCreatedDate(), userName)); + } + } + }); + } + + if (ncdPopEnumeration != null && !cbacDetailsImer.isEmpty()) { + List cbacBenIds = cbacDetailsImer.stream() + .filter(c -> c != null && c.getBeneficiaryRegId() != null) + .map(CbacDetailsImer::getBeneficiaryRegId) + .collect(Collectors.toList()); + + // Batch fetch existing records — 1 query instead of N + Set existingKeys = recordRepo + .findExistingRecords(ncdPopEnumeration.getId(), cbacBenIds, ashaId) + .stream() + .map(r -> r.getActivityId() + "_" + r.getBenId() + "_" + r.getCreatedDate()) + .collect(Collectors.toSet()); + + final IncentiveActivity activity = ncdPopEnumeration; + cbacDetailsImer.stream() + .filter(c -> c != null && c.getBeneficiaryRegId() != null) + .forEach(c -> { + String key = activity.getId() + "_" + c.getBeneficiaryRegId() + "_" + c.getCreatedDate(); + if (!existingKeys.contains(key)) { + recordsToSave.add(addNCDandCBACIncentiveRecord(activity, ashaId, c.getBeneficiaryRegId(), c.getCreatedDate(), userName)); + } + }); + } + + // ---- Single batch insert instead of N individual saves ---- + if (!recordsToSave.isEmpty()) { + recordRepo.saveAll(recordsToSave); + } + + } catch (Exception e) { + logger.error("Error in incentiveOfNcdReferal for ashaId={}, stateId={}", ashaId, stateId, e); } - if(ADDITIONAL_ASHA_INCENTIVE!=null){ - addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE,ashaId); + } + // Helper — record banana + private IncentiveActivityRecord addNCDandCBACIncentiveRecord(IncentiveActivity activity, Integer ashaId, + Long benId, Timestamp createdDate, String userName) { + Timestamp now = Timestamp.valueOf(LocalDateTime.now()); + IncentiveActivityRecord record = new IncentiveActivityRecord(); + record.setActivityId(activity.getId()); + record.setCreatedDate(createdDate); + record.setCreatedBy(userName); + record.setStartDate(createdDate); + record.setEndDate(createdDate); + record.setUpdatedDate(now); + record.setUpdatedBy(userName); + record.setBenId(benId); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(activity.getRate())); + return record; + } + + private String resolveGroupName(Integer stateId) { + if (stateId.equals(StateCode.CG.getStateCode())) { + logger.info("State id: {}", StateCode.CG.getStateCode()); + return GroupName.ACTIVITY.getDisplayName(); } + logger.info("State id: {}", stateId); + return GroupName.NCD.getDisplayName(); + } + + private void checkMonthlyAshaIncentive(Integer ashaId) { + try { + String userName = userRepo.getUserNamedByUserId(ashaId); + + IncentiveActivity MOBILEBILLREIMB_ACTIVITY = incentivesRepo.findIncentiveMasterByNameAndGroup("MOBILE_BILL_REIMB", GroupName.OTHER_INCENTIVES.getDisplayName()); + IncentiveActivity ADDITIONAL_ASHA_INCENTIVE = incentivesRepo.findIncentiveMasterByNameAndGroup("ADDITIONAL_ASHA_INCENTIVE", GroupName.ADDITIONAL_INCENTIVE.getDisplayName()); + IncentiveActivity ASHA_MONTHLY_ROUTINE = incentivesRepo.findIncentiveMasterByNameAndGroup("ASHA_MONTHLY_ROUTINE", GroupName.ASHA_MONTHLY_ROUTINE.getDisplayName()); + if (MOBILEBILLREIMB_ACTIVITY != null) { + addMonthlyAshaIncentiveRecord(MOBILEBILLREIMB_ACTIVITY, ashaId,userName); + } + if (ADDITIONAL_ASHA_INCENTIVE != null) { + addMonthlyAshaIncentiveRecord(ADDITIONAL_ASHA_INCENTIVE, ashaId,userName); + + } - if(ASHA_MONTHLY_ROUTINE!=null){ - addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE,ashaId); + if (ASHA_MONTHLY_ROUTINE != null) { + addMonthlyAshaIncentiveRecord(ASHA_MONTHLY_ROUTINE, ashaId,userName); + + } + } catch (Exception e) { + logger.error("Error in addMonthlyAshaIncentiveRecord", e); } + } - private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, Integer ashaId){ - Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); - - Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); - Timestamp endOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()).atTime(23, 59, 59)); - - IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId( - incentiveActivity.getId(), - startOfMonth, - endOfMonth, - 0L, - ashaId - ); - - - if (record == null) { - record = new IncentiveActivityRecord(); - record.setActivityId(incentiveActivity.getId()); - record.setCreatedDate(timestamp); - record.setCreatedBy(userRepo.getUserNamedByUserId(ashaId)); - record.setStartDate(timestamp); - record.setEndDate(timestamp); - record.setUpdatedDate(timestamp); - record.setUpdatedBy(userRepo.getUserNamedByUserId(ashaId)); - record.setBenId(0L); - record.setAshaId(ashaId); - record.setAmount(Long.valueOf(incentiveActivity.getRate())); - recordRepo.save(record); + private void addMonthlyAshaIncentiveRecord(IncentiveActivity incentiveActivity, Integer ashaId,String userName) { + try { + Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); + + Timestamp startOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(1).atStartOfDay()); + Timestamp endOfMonth = Timestamp.valueOf(LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()).atTime(23, 59, 59)); + + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId( + incentiveActivity.getId(), + startOfMonth, + endOfMonth, + 0L, + ashaId + ); + + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(timestamp); + record.setCreatedBy(userName); + record.setStartDate(timestamp); + record.setEndDate(timestamp); + record.setUpdatedDate(timestamp); + record.setUpdatedBy(userName); + record.setBenId(0L); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + } catch (Exception e) { + logger.error("Error in addMonthlyAshaIncentiveRecord", e); + } + } From 44f9b6d4056a314034186922479f513ac7d88b2d Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Thu, 19 Mar 2026 21:50:48 +0530 Subject: [PATCH 778/792] fix production issues --- .../flw/controller/IRSRoundController.java | 12 +++++-- .../flw/domain/iemr/FilariasisCampaign.java | 2 +- .../com/iemr/flw/domain/iemr/IRSRound.java | 6 ++++ .../flw/domain/iemr/ScreeningKalaAzar.java | 4 +-- .../flw/domain/iemr/ScreeningLeprosy.java | 36 +++++++++---------- .../iemr/flw/dto/iemr/DeliveryOutcomeDTO.java | 1 - .../com/iemr/flw/service/IRSRoundService.java | 2 +- .../impl/DeliveryOutcomeServiceImpl.java | 7 ++-- .../flw/service/impl/IRSRoundServiceImpl.java | 4 +-- 9 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/IRSRoundController.java b/src/main/java/com/iemr/flw/controller/IRSRoundController.java index 4425cdeb..f138a0ef 100644 --- a/src/main/java/com/iemr/flw/controller/IRSRoundController.java +++ b/src/main/java/com/iemr/flw/controller/IRSRoundController.java @@ -4,6 +4,7 @@ import com.iemr.flw.dto.iemr.IRSRoundDTO; import com.iemr.flw.dto.iemr.IRSRoundListDTO; import com.iemr.flw.service.IRSRoundService; +import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.response.OutputResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -24,12 +25,19 @@ public class IRSRoundController { @Autowired private IRSRoundService irsRoundService; + @Autowired + private JwtUtil jwtUtil; + @PostMapping(value = "/add") - public ResponseEntity> addRound(@RequestBody IRSRoundListDTO dto) { + public ResponseEntity> addRound(@RequestBody IRSRoundListDTO dto,@RequestHeader("jwtToken") String token) { Map response = new LinkedHashMap<>(); try { if (dto.getRounds().size() != 0) { - List s = irsRoundService.addRounds(dto.getRounds()); + if(token==null){ + response.put("statusCode", 401); + return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response) ; + } + List s = irsRoundService.addRounds(dto.getRounds(),jwtUtil.extractUserId(token),jwtUtil.extractUsername(token)); if (s.size() != 0) { Map data = new HashMap<>(); data.put("entries", s); diff --git a/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java index b9f98ee8..869e9696 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java +++ b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java @@ -34,7 +34,7 @@ public class FilariasisCampaign { * Store JSON array like ["img1.jpg","img2.jpg"] * MySQL JSON column */ - @Column(name = "mda_photos", columnDefinition = "json") + @Column(name = "campaign_photos", columnDefinition = "json") private String campaignPhotos; @Column(name = "created_by", length = 200) diff --git a/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java index 0f078f5f..6f3143e0 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java +++ b/src/main/java/com/iemr/flw/domain/iemr/IRSRound.java @@ -28,4 +28,10 @@ public class IRSRound { @Column(name = "householdId") private Long householdId; + @Column(name = "created_by") + private String createdBy; + + @Column(name = "user_id") + private Integer userId; + } \ No newline at end of file diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java index eb8b0107..d6bcd7b6 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningKalaAzar.java @@ -45,7 +45,7 @@ public class ScreeningKalaAzar { @Column(name = "house_hold_details_Id",nullable = false) private Long houseHoldDetailsId; - @Column(name = "userID") + @Column(name = "user_id") private Integer userId; @Temporal(TemporalType.DATE) @@ -97,7 +97,7 @@ public class ScreeningKalaAzar { @Column(name = "created_by") private String createdBy; - @Column(name = "diseaseTypeID") + @Column(name = "disease_type_id") private Integer diseaseTypeId; @Column(name = "refer_to_name") diff --git a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java index a943affe..6a485eef 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java +++ b/src/main/java/com/iemr/flw/domain/iemr/ScreeningLeprosy.java @@ -83,25 +83,25 @@ public class ScreeningLeprosy { @Column(name = "beneficiary_statusId") private Integer beneficiaryStatusId; - @Column(name = "beneficiary_status", length = 50) + @Column(name = "beneficiary_status") private String beneficiaryStatus; @Column(name = "date_of_death") private Date dateOfDeath; - @Column(name = "place_of_death", length = 50) + @Column(name = "place_of_death") private String placeOfDeath; @Column(name = "other_place_of_death", columnDefinition = "TEXT") private String otherPlaceOfDeath; - @Column(name = "reason_for_death", length = 50) + @Column(name = "reason_for_death") private String reasonForDeath; @Column(name = "other_reason_for_death", columnDefinition = "TEXT") private String otherReasonForDeath; - @Column(name = "leprosy_symptoms", length = 255) + @Column(name = "leprosy_symptoms") private String leprosySymptoms; @Column(name = "leprosy_symptoms_position") @@ -113,7 +113,7 @@ public class ScreeningLeprosy { @Column(name = "current_visit_number") private Integer currentVisitNumber; - @Column(name = "visit_label", length = 50) + @Column(name = "visit_label") private String visitLabel; @Column(name = "visit_number") @@ -122,7 +122,7 @@ public class ScreeningLeprosy { @Column(name = "is_confirmed") private Boolean isConfirmed; - @Column(name = "leprosy_state", length = 50) + @Column(name = "leprosy_state", length = 255) private String leprosyState; @Temporal(TemporalType.DATE) @@ -178,40 +178,40 @@ public class ScreeningLeprosy { @Column(name = "weakness_feet_id") private Integer weaknessFeetId; - @Column(name = "recurrent_ulceration", length = 10) + @Column(name = "recurrent_ulceration") private String recurrentUlceration; - @Column(name = "recurrent_tingling", length = 10) + @Column(name = "recurrent_tingling") private String recurrentTingling; - @Column(name = "hypopigmented_patch", length = 50) + @Column(name = "hypopigmented_patch") private String hypopigmentedPatch; - @Column(name = "thickened_skin", length = 10) + @Column(name = "thickened_skin") private String thickenedSkin; - @Column(name = "skin_nodules", length = 10) + @Column(name = "skin_nodules") private String skinNodules; - @Column(name = "skin_patch_discoloration", length = 50) + @Column(name = "skin_patch_discoloration") private String skinPatchDiscoloration; - @Column(name = "recurrent_numbness", length = 10) + @Column(name = "recurrent_numbness") private String recurrentNumbness; - @Column(name = "clawing_fingers", length = 10) + @Column(name = "clawing_fingers") private String clawingFingers; - @Column(name = "tingling_numbness_extremities", length = 50) + @Column(name = "tingling_numbness_extremities") private String tinglingNumbnessExtremities; - @Column(name = "inability_close_eyelid", length = 10) + @Column(name = "inability_close_eyelid") private String inabilityCloseEyelid; - @Column(name = "difficulty_holding_objects", length = 50) + @Column(name = "difficulty_holding_objects") private String difficultyHoldingObjects; - @Column(name = "weakness_feet", length = 10) + @Column(name = "weakness_feet") private String weaknessFeet; @Column(name = "CreatedBy", length = 100) diff --git a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java index 941721ca..5e94697a 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/DeliveryOutcomeDTO.java @@ -10,7 +10,6 @@ public class DeliveryOutcomeDTO { private Long id; private Long benId; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd") private Timestamp dateOfDelivery; private String timeOfDelivery; private String placeOfDelivery; diff --git a/src/main/java/com/iemr/flw/service/IRSRoundService.java b/src/main/java/com/iemr/flw/service/IRSRoundService.java index d45cd621..438702d5 100644 --- a/src/main/java/com/iemr/flw/service/IRSRoundService.java +++ b/src/main/java/com/iemr/flw/service/IRSRoundService.java @@ -8,7 +8,7 @@ @Service public interface IRSRoundService { - List addRounds(List dtos); + List addRounds(List dtos,Integer userId,String userName); List getRounds(Long householdId); } diff --git a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java index 0e329f4b..3ccd9973 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeliveryOutcomeServiceImpl.java @@ -108,13 +108,14 @@ public String registerDeliveryOutcome(List deliveryOutcomeDT @Override public List getDeliveryOutcome(GetBenRequestHandler dto) { try { - String user = beneficiaryRepo.getUserName(dto.getAshaId()); - List deliveryOutcomeList = deliveryOutcomeRepo.getDeliveryOutcomeByAshaId(user, dto.getFromDate(), dto.getToDate()); + String user = userRepo.getUserNamedByUserId(dto.getAshaId()); + List deliveryOutcomeList = deliveryOutcomeRepo.getDeliveryOutcomeByAshaId(user,dto.getFromDate(),dto.getToDate()); + logger.info("DeliveryOutcome Response{}",deliveryOutcomeList); return deliveryOutcomeList.stream() .map(deliveryOutcome -> mapper.convertValue(deliveryOutcome, DeliveryOutcomeDTO.class)) .collect(Collectors.toList()); } catch (Exception e) { - logger.error(e.getMessage()); + logger.error("DeliveryOutcome Exception:"+e.getMessage()); } return null; } diff --git a/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java index b294a3dc..26a5c1c7 100644 --- a/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IRSRoundServiceImpl.java @@ -17,7 +17,7 @@ public class IRSRoundServiceImpl implements IRSRoundService { private IRSRoundRepo irsRoundRepository; @Override - public List addRounds(List dtos) { + public List addRounds(List dtos,Integer userId,String userName) { // Validate input DTOs for (IRSRoundDTO dto : dtos) { if (dto.getDate() == null || dto.getHouseholdId() == null) { @@ -26,7 +26,7 @@ public List addRounds(List dtos) { } return irsRoundRepository.saveAll( dtos.stream() - .map(dto -> new IRSRound(null, dto.getDate(), dto.getRounds(), dto.getHouseholdId())) + .map(dto -> new IRSRound(null, dto.getDate(), dto.getRounds(), dto.getHouseholdId(),userName,userId)) .collect(Collectors.toList()) ); } From 8620b1a5d60a9520f2b7ad772c4fdadf9e0d2d14 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 20 Mar 2026 11:15:49 +0530 Subject: [PATCH 779/792] fix production issues --- .../flw/controller/CampaignController.java | 12 +-- .../flw/controller/ChildCareController.java | 8 +- .../controller/DiseaseControlController.java | 4 +- .../flw/controller/GeneralOPDController.java | 2 +- .../controller/MalariaFollowUpController.java | 2 +- .../iemr/flw/domain/iemr/DeliveryOutcome.java | 1 - .../iemr/flw/domain/iemr/HbycChildVisit.java | 2 +- .../java/com/iemr/flw/dto/iemr/CdrDTO.java | 2 + .../java/com/iemr/flw/dto/iemr/HbycDTO.java | 2 +- .../java/com/iemr/flw/dto/iemr/MdsrDTO.java | 6 ++ .../iemr/flw/dto/iemr/PendingActivityDTO.java | 3 +- .../com/iemr/flw/dto/iemr/TBScreeningDTO.java | 93 +----------------- .../com/iemr/flw/masterEnum/GroupName.java | 3 + .../iemr/flw/service/UwinSessionService.java | 1 + .../flw/service/impl/CampaignServiceImpl.java | 94 +++++++++++++++++-- .../service/impl/UwinSessionServiceImpl.java | 18 +++- 16 files changed, 133 insertions(+), 120 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/CampaignController.java b/src/main/java/com/iemr/flw/controller/CampaignController.java index 93a19afd..f5f13d69 100644 --- a/src/main/java/com/iemr/flw/controller/CampaignController.java +++ b/src/main/java/com/iemr/flw/controller/CampaignController.java @@ -123,9 +123,9 @@ public ResponseEntity> getAllOrsDistribution(@RequestHeader( response.put("data", result); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { @@ -233,9 +233,9 @@ public ResponseEntity> getAllPolioCampaign(@RequestHeader(va response.put("data", result); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { @@ -345,9 +345,9 @@ public ResponseEntity> getAllFilariasisCampaign(@RequestHead response.put("data", result); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { diff --git a/src/main/java/com/iemr/flw/controller/ChildCareController.java b/src/main/java/com/iemr/flw/controller/ChildCareController.java index e1e2c91f..36da3ba7 100644 --- a/src/main/java/com/iemr/flw/controller/ChildCareController.java +++ b/src/main/java/com/iemr/flw/controller/ChildCareController.java @@ -272,9 +272,9 @@ public ResponseEntity getAllSevereAcuteMalnutrition(@RequestBody GetBenReques response.put("data", responseObject); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "No SAM records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { @@ -331,9 +331,9 @@ public ResponseEntity getAllOrDistribution(@RequestBody GetBenRequestHandler response.put("data", responseObject); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); response.put("message", "No ORS records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index e89a5306..2464b5e5 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -63,12 +63,12 @@ public ResponseEntity> saveMalaria(@RequestBody MalariaDTO m response.put("data", diseaseControlService.saveMalaria(malariaDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); diff --git a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java index 5e7823df..c683a9be 100644 --- a/src/main/java/com/iemr/flw/controller/GeneralOPDController.java +++ b/src/main/java/com/iemr/flw/controller/GeneralOPDController.java @@ -77,7 +77,7 @@ public ResponseEntity> getBeneficiaryDataByAsha(@RequestBody } catch (Exception e) { logger.error("Error in get data : " + e); - response.put("status", 500); + response.put("statusCode", 5000); response.put("message", "Error in get data : " + e); } return ResponseEntity.ok(response); diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index 4e3ae194..230ad591 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -78,7 +78,7 @@ public ResponseEntity> getFollowUpsByUserId(@RequestBody Get } } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); diff --git a/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java b/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java index 6050fab5..2b94cc7a 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java @@ -17,7 +17,6 @@ public class DeliveryOutcome { @Column(name = "ben_id") private Long benId; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM dd, yyyy, h:mm:ss a") @Column(name = "delivery_date") private Timestamp dateOfDelivery; diff --git a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java index bcaeabc4..205716cc 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java +++ b/src/main/java/com/iemr/flw/domain/iemr/HbycChildVisit.java @@ -53,7 +53,7 @@ public class HbycChildVisit { private String other_place_of_death; @Column(name = "baby_weight") - private BigDecimal baby_weight; // 0.5 - 7.0 + private Integer baby_weight; // 0.5 - 7.0 @Column(name = "is_child_sick") private Boolean is_child_sick; diff --git a/src/main/java/com/iemr/flw/dto/iemr/CdrDTO.java b/src/main/java/com/iemr/flw/dto/iemr/CdrDTO.java index 122f652d..ed1dc34e 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/CdrDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/CdrDTO.java @@ -55,6 +55,8 @@ public class CdrDTO { private String deathCertImage2; + private String cdrImage; + private Timestamp updatedDate; private String updatedBy; diff --git a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java index acc54ca8..172132e0 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/HbycDTO.java @@ -47,7 +47,7 @@ public class HbycDTO { private String other_place_of_death; @SerializedName("baby_weight") - private BigDecimal baby_weight; + private Integer baby_weight; @SerializedName("is_child_sick") private String is_child_sick; diff --git a/src/main/java/com/iemr/flw/dto/iemr/MdsrDTO.java b/src/main/java/com/iemr/flw/dto/iemr/MdsrDTO.java index 5b07e40a..e59047ab 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/MdsrDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/MdsrDTO.java @@ -35,4 +35,10 @@ public class MdsrDTO { private Timestamp updatedDate; private String updatedBy; + + private String mdsr1File; + + private String mdsr2File; + + private String mdsrDeathCertFile; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java b/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java index 4d8dbd99..5fcdd537 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/PendingActivityDTO.java @@ -9,6 +9,7 @@ public class PendingActivityDTO { private Long id; private Integer userId; - private List Images; + private List images; private String moduleName; + private String activityName; } diff --git a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java index 017d73af..36f48dfc 100644 --- a/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java +++ b/src/main/java/com/iemr/flw/dto/iemr/TBScreeningDTO.java @@ -37,98 +37,7 @@ public class TBScreeningDTO { private Boolean bmi; private Boolean contactWithTBPatient; private Boolean historyOfTBInLastFiveYrs; - private String sympotomatic; + private String sympotomatic; private String asymptomatic; private String recommandateTest; - - - - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getBenId() { - return benId; - } - - public void setBenId(Long benId) { - this.benId = benId; - } - - public Timestamp getVisitDate() { - return visitDate; - } - - public void setVisitDate(Timestamp visitDate) { - this.visitDate = visitDate; - } - - public Boolean getCoughMoreThan2Weeks() { - return coughMoreThan2Weeks; - } - - public void setCoughMoreThan2Weeks(Boolean coughMoreThan2Weeks) { - this.coughMoreThan2Weeks = coughMoreThan2Weeks; - } - - public Boolean getBloodInSputum() { - return bloodInSputum; - } - - public void setBloodInSputum(Boolean bloodInSputum) { - this.bloodInSputum = bloodInSputum; - } - - public Boolean getFeverMoreThan2Weeks() { - return feverMoreThan2Weeks; - } - - public void setFeverMoreThan2Weeks(Boolean feverMoreThan2Weeks) { - this.feverMoreThan2Weeks = feverMoreThan2Weeks; - } - - public Boolean getLossOfWeight() { - return lossOfWeight; - } - - public void setLossOfWeight(Boolean lossOfWeight) { - this.lossOfWeight = lossOfWeight; - } - - public Boolean getNightSweats() { - return nightSweats; - } - - public void setNightSweats(Boolean nightSweats) { - this.nightSweats = nightSweats; - } - - public Boolean getHistoryOfTb() { - return historyOfTb; - } - - public void setHistoryOfTb(Boolean historyOfTb) { - this.historyOfTb = historyOfTb; - } - - public Boolean getTakingAntiTBDrugs() { - return takingAntiTBDrugs; - } - - public void setTakingAntiTBDrugs(Boolean takingAntiTBDrugs) { - this.takingAntiTBDrugs = takingAntiTBDrugs; - } - - public Boolean getFamilySufferingFromTB() { - return familySufferingFromTB; - } - - public void setFamilySufferingFromTB(Boolean familySufferingFromTB) { - this.familySufferingFromTB = familySufferingFromTB; - } } diff --git a/src/main/java/com/iemr/flw/masterEnum/GroupName.java b/src/main/java/com/iemr/flw/masterEnum/GroupName.java index 8d6736eb..e53733b0 100644 --- a/src/main/java/com/iemr/flw/masterEnum/GroupName.java +++ b/src/main/java/com/iemr/flw/masterEnum/GroupName.java @@ -33,3 +33,6 @@ public String getDisplayName() { } + + + diff --git a/src/main/java/com/iemr/flw/service/UwinSessionService.java b/src/main/java/com/iemr/flw/service/UwinSessionService.java index 3f6ddf0a..0756de83 100644 --- a/src/main/java/com/iemr/flw/service/UwinSessionService.java +++ b/src/main/java/com/iemr/flw/service/UwinSessionService.java @@ -1,5 +1,6 @@ package com.iemr.flw.service; +import com.iemr.flw.domain.iemr.UwinSession; import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index d989df6c..55756130 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -3,13 +3,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import com.iemr.flw.domain.iemr.CampaignOrs; -import com.iemr.flw.domain.iemr.FilariasisCampaign; -import com.iemr.flw.domain.iemr.PulsePolioCampaign; +import com.iemr.flw.domain.iemr.*; import com.iemr.flw.dto.iemr.*; -import com.iemr.flw.repo.iemr.FilariasisCampaignRepo; -import com.iemr.flw.repo.iemr.OrsCampaignRepo; -import com.iemr.flw.repo.iemr.PulsePolioCampaignRepo; +import com.iemr.flw.masterEnum.GroupName; +import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.CampaignService; import com.iemr.flw.utils.JwtUtil; import com.iemr.flw.utils.exception.IEMRException; @@ -22,6 +19,9 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Base64; import java.util.Collections; @@ -42,8 +42,18 @@ public class CampaignServiceImpl implements CampaignService { @Autowired private JwtUtil jwtUtil; + @Autowired + IncentivesRepo incentivesRepo; + + @Autowired + IncentiveRecordRepo recordRepo; + + @Autowired private ObjectMapper objectMapper = new ObjectMapper(); + @Autowired + private UserServiceRoleRepo userServiceRoleRepo; + @Override @Transactional public List saveOrsCampaign(List orsCampaignDTO, String token) throws IEMRException, JsonProcessingException { @@ -91,6 +101,9 @@ public List saveOrsCampaign(List orsCampaignDTO, St if (!campaignOrsRequest.isEmpty()) { List savedCampaigns = orsCampaignRepo.saveAll(campaignOrsRequest); + savedCampaigns.forEach(ors->{ + checkMonthlyPulseOrsDistribution(ors.getUserId(),ors.getStartDate(),ors.getEndDate()); + }); return savedCampaigns; } @@ -177,6 +190,12 @@ public List savePolioCampaign(List polioCa if (!campaignPolioRequest.isEmpty()) { List savedCampaigns = pulsePolioCampaignRepo.saveAll(campaignPolioRequest); + savedCampaigns.forEach(pulsePolioCampaign -> { + checkMonthlyPulsePolioIncentive(pulsePolioCampaign.getUserId(),pulsePolioCampaign.getStartDate(),pulsePolioCampaign.getEndDate()); + + });{ + + } return savedCampaigns; } @@ -255,6 +274,13 @@ public List saveFilariasisCampaign(List savedCampaigns = filariasisCampaignRepo.saveAll(campaignPolioRequest); + + savedCampaigns.forEach(filariasisCampaign -> { + checkMonthlyFilariasisIncentive(filariasisCampaign.getUserId(),filariasisCampaign.getStartDate(),filariasisCampaign.getEndDate()); + + });{ + + } return savedCampaigns; } @@ -262,6 +288,7 @@ public List saveFilariasisCampaign(List getPolioCampaign(String token) throws IEMRException { Integer userId = jwtUtil.extractUserId(token); @@ -329,6 +356,7 @@ private OrsCampaignResponseDTO convertOrsToDTO(CampaignOrs campaign) { orsCampaignListDTO.setNumberOfFamilies(Double.valueOf(campaign.getNumberOfFamilies())); dto.setId(campaign.getId()); dto.setFields(orsCampaignListDTO); + return dto; } @@ -402,7 +430,61 @@ private List parseBase64Json(String jsonString) { } } + private void checkMonthlyPulsePolioIncentive(Integer ashaId,LocalDate startDate,LocalDate endDate) { + + IncentiveActivity CHILD_MOBILIZATION_SESSIONS = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.ACTIVITY.getDisplayName()); + if (CHILD_MOBILIZATION_SESSIONS != null) { + addAshaIncentiveRecord(CHILD_MOBILIZATION_SESSIONS, ashaId,startDate,endDate); + } + + } + + private void checkMonthlyFilariasisIncentive(Integer ashaId,LocalDate startDate,LocalDate endDate) { + IncentiveActivity FILARIASIS_MEDICINE_DISTRIBUTION = incentivesRepo.findIncentiveMasterByNameAndGroup("FILARIASIS_MEDICINE_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); + if (FILARIASIS_MEDICINE_DISTRIBUTION != null) { + addAshaIncentiveRecord(FILARIASIS_MEDICINE_DISTRIBUTION, ashaId,startDate,endDate); + } + } + + private void checkMonthlyPulseOrsDistribution(Integer ashaId,LocalDate startDate,LocalDate endDate) { + IncentiveActivity ORS_DISTRIBUTION = incentivesRepo.findIncentiveMasterByNameAndGroup("ORS_DISTRIBUTION", GroupName.ACTIVITY.getDisplayName()); + if (ORS_DISTRIBUTION != null) { + addAshaIncentiveRecord(ORS_DISTRIBUTION, ashaId,startDate,endDate); + } + + } + + private void addAshaIncentiveRecord(IncentiveActivity incentiveActivity, Integer ashaId,LocalDate startDate,LocalDate endDate) { + Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now()); + + Timestamp startOfMonth = Timestamp.valueOf(startDate.atStartOfDay()); + Timestamp endOfMonth = Timestamp.valueOf(endDate.atStartOfDay()); + + IncentiveActivityRecord record = recordRepo.findRecordByActivityIdCreatedDateBenId( + incentiveActivity.getId(), + startOfMonth, + endOfMonth, + 0L, + ashaId + ); + + + if (record == null) { + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); + record.setCreatedDate(timestamp); + record.setCreatedBy(userServiceRoleRepo.getUserNamedByUserId(ashaId)); + record.setStartDate(timestamp); + record.setEndDate(timestamp); + record.setUpdatedDate(timestamp); + record.setUpdatedBy(userServiceRoleRepo.getUserNamedByUserId(ashaId)); + record.setBenId(0L); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); + recordRepo.save(record); + } + } } diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index bb2a944c..63dc00dd 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -8,6 +8,7 @@ import com.iemr.flw.dto.iemr.UwinSessionRequestDTO; import com.iemr.flw.dto.iemr.UwinSessionResponseDTO; import com.iemr.flw.masterEnum.GroupName; +import com.iemr.flw.masterEnum.StateCode; import com.iemr.flw.repo.iemr.IncentiveRecordRepo; import com.iemr.flw.repo.iemr.IncentivesRepo; import com.iemr.flw.repo.iemr.UserServiceRoleRepo; @@ -130,9 +131,9 @@ public List getSessionsByAsha(Integer ashaId) throws Exc private void checkAndAddIncentive(UwinSession session) { IncentiveActivity incentiveActivityAM = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.IMMUNIZATION.getDisplayName()); IncentiveActivity incentiveActivityCH = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.ACTIVITY.getDisplayName()); + Integer stateId = userRepo.getUserRole(session.getAshaId()).get(0).getStateId(); - - if(incentiveActivityAM!=null){ + if(incentiveActivityAM!=null && stateId!=null && stateId.equals(StateCode.AM.getStateCode())){ IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivityAM.getId(), session.getDate(), 0L,session.getAshaId()); if (record == null) { @@ -147,11 +148,19 @@ record = new IncentiveActivityRecord(); record.setBenId(0L); record.setAshaId(session.getAshaId()); record.setAmount(Long.valueOf(incentiveActivityAM.getRate())); - recordRepo.save(record); + if(session.getAttachmentsJson()!=null){ + record.setIsEligible(true); + recordRepo.save(record); + + }else { + record.setIsEligible(false); + + } + } } - if(incentiveActivityCH!=null){ + if(incentiveActivityCH!=null && stateId!=null && stateId.equals(StateCode.CG.getStateCode())){ IncentiveActivityRecord record = recordRepo .findRecordByActivityIdCreatedDateBenId(incentiveActivityCH.getId(), session.getDate(), 0L,session.getAshaId()); if (record == null) { @@ -166,6 +175,7 @@ record = new IncentiveActivityRecord(); record.setBenId(0L); record.setAshaId(session.getAshaId()); record.setAmount(Long.valueOf(incentiveActivityCH.getRate())); + record.setIsEligible(true); recordRepo.save(record); } } From e4c9012e075a92d9fb6d7339136973c97f5a303f Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 20 Mar 2026 12:36:23 +0530 Subject: [PATCH 780/792] fix status code in disease module --- .../controller/DiseaseControlController.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java index 2464b5e5..816fb244 100644 --- a/src/main/java/com/iemr/flw/controller/DiseaseControlController.java +++ b/src/main/java/com/iemr/flw/controller/DiseaseControlController.java @@ -86,12 +86,12 @@ public ResponseEntity> saveKalaAzar(@RequestBody KalaAzarDTO response.put("data", diseaseControlService.saveKalaAzar(kalaAzarDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); @@ -108,12 +108,12 @@ public ResponseEntity> saveAESJE(@RequestBody AesJeDTO aesJe response.put("data", diseaseControlService.saveAES(aesJeDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); @@ -130,12 +130,12 @@ public ResponseEntity> saveFilaria(@RequestBody FilariaDTO f response.put("data", diseaseControlService.saveFilaria(filariaDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); @@ -151,12 +151,12 @@ public ResponseEntity> saveLeprosy(@RequestBody LeprosyDTO l response.put("data", diseaseControlService.saveLeprosy(leprosyDTO)); }else { response.put("message", "Invalid request"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); @@ -175,11 +175,11 @@ public ResponseEntity> saveLeprosyFollowUP(@RequestBody List response.put("message", "All follow-ups saved successfully"); } else { response.put("message", "Invalid request - no follow-up data"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); @@ -203,15 +203,15 @@ public ResponseEntity> getAllLeprosy( response.put("data", result); // ← Put list directly, no gson.toJson() } else { response.put("message", "No record found"); - response.put("statusCode", 404); + response.put("statusCode", 5000); } } else { response.put("message", "Invalid request - userName required"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); // ← Spring serializes the whole map } @@ -233,15 +233,15 @@ public ResponseEntity> getAllLeprosyFollowUp( response.put("data", result); // ← Put list directly, no gson.toJson() } else { response.put("message", "No record found"); - response.put("statusCode", 404); + response.put("statusCode", 5000); } } else { response.put("message", "Invalid request - userName required"); - response.put("statusCode", 400); + response.put("statusCode", 5000); } } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); // ← Spring serializes the whole map } @@ -257,7 +257,7 @@ public ResponseEntity> getAllData( } catch (Exception e) { response.put("status", "Error" + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); } From dac1e99c725fe9c2748bb97c73500ce20d02a6ab Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 20 Mar 2026 13:43:32 +0530 Subject: [PATCH 781/792] fix status code in disease module --- .../com/iemr/flw/controller/BeneficiaryController.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index dd083840..82b4cf7b 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -91,7 +91,7 @@ public ResponseEntity saveEyeSurgery(@RequestBody List } catch (Exception e) { logger.error("Error saving eye checkup visit:", e); - response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("statusCode", 5000); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } @@ -112,14 +112,14 @@ public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler requ response.put("data", responseObject); return ResponseEntity.ok(response); } else { - response.put("statusCode", HttpStatus.NOT_FOUND.value()); + response.put("statusCode", 5000); response.put("message", "No records found"); - return ResponseEntity.status(HttpStatus.NOT_FOUND).body(response); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } } catch (Exception e) { logger.error("Error fetching eye checkup visit:", e); - response.put("statusCode", HttpStatus.INTERNAL_SERVER_ERROR.value()); + response.put("statusCode", 5000); response.put("errorMessage", e.getMessage()); return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); } From ffe7d46ab2ea815776dda02aab43e9c19647f5a9 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Fri, 20 Mar 2026 16:31:57 +0530 Subject: [PATCH 782/792] fix session_date issue --- src/main/java/com/iemr/flw/domain/iemr/UwinSession.java | 3 +++ .../java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java b/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java index f995a71d..9ab6d5cb 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java +++ b/src/main/java/com/iemr/flw/domain/iemr/UwinSession.java @@ -23,6 +23,9 @@ public class UwinSession { @Column(name = "date", nullable = false) private Timestamp date; + @Column(name = "session_date", nullable = false) + private Timestamp sessionDate; + @Column(name = "place", nullable = false) private String place; diff --git a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java index 63dc00dd..156de1d8 100644 --- a/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/UwinSessionServiceImpl.java @@ -73,6 +73,7 @@ public UwinSessionResponseDTO saveSession(UwinSessionRequestDTO req) throws Exce session.setAshaId(req.getAshaId()); session.setDate(req.getDate()); session.setPlace(req.getPlace()); + session.setSessionDate(req.getDate()); session.setParticipants(req.getParticipants()); session.setCreatedBy(req.getCreatedBy()); if (req.getAttachments() != null && req.getAttachments().length > 0) { From 6e4aa7cefc50a1b1e763bf0f9f30887f8eb23477 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Mon, 23 Mar 2026 19:48:09 +0530 Subject: [PATCH 783/792] fix DeliveryOutcome date formate issue --- src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java | 1 - .../java/com/iemr/flw/domain/iemr/FilariasisCampaign.java | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java b/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java index 2b94cc7a..d3a1b56c 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java +++ b/src/main/java/com/iemr/flw/domain/iemr/DeliveryOutcome.java @@ -53,7 +53,6 @@ public class DeliveryOutcome { @Column(name = "still_birth") private Integer stillBirth; - @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "MMM dd, yyyy, h:mm:ss a") @Column(name = "discharge_date") private Timestamp dateOfDischarge; diff --git a/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java index 869e9696..7e0916bd 100644 --- a/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java +++ b/src/main/java/com/iemr/flw/domain/iemr/FilariasisCampaign.java @@ -24,10 +24,10 @@ public class FilariasisCampaign { @Column(name = "user_id", nullable = false) private Integer userId; - @Column(name = "no_of_families", nullable = false) + @Column(name = "number_of_families", nullable = false) private Integer numberOfFamilies = 0; - @Column(name = "no_of_individuals", nullable = false) + @Column(name = "number_of_individuals", nullable = false) private Integer numberOfIndividuals = 0; /** From 28d77893faeeeeb6fced5bdd2c4cdd9344782987 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 24 Mar 2026 11:31:35 +0530 Subject: [PATCH 784/792] fix DiseaseControl userId issue --- .../iemr/flw/controller/MicroBirthPlanController.java | 2 +- .../flw/service/impl/DiseaseControlServiceImpl.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index c501b405..c5cb04aa 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -55,7 +55,7 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic } - @RequestMapping(value = "getAll", method = RequestMethod.GET) + @RequestMapping(value = "getAll", method = RequestMethod.POST) public ResponseEntity> getAllMicroBirthPlans(@RequestParam("userId") Integer userId) { Map response = new HashMap<>(); diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index d5f009ea..1abf70f3 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -397,7 +397,7 @@ public Object getAllMalaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter malaria disease records List filteredList = diseaseMalariaRepository.findAll().stream() - .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) + .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getAshaId())) .collect(Collectors.toList()); // Check if the list is empty @@ -485,7 +485,7 @@ public Object getAllKalaAzar(GetDiseaseRequestHandler getDiseaseRequestHandler) // Fetch and filter Kala Azar disease records List filteredList = diseaseKalaAzarRepository.findAll().stream() - .filter(disease -> (Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId()))) + .filter(disease -> (Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getAshaId()))) .collect(Collectors.toList()); // Check if the list is empty @@ -532,14 +532,14 @@ public Object getAllKalaAES(GetDiseaseRequestHandler getDiseaseRequestHandler) { return Collections.singletonMap("message", "No data found for AES."); } - return diseaseAESJERepository.findAll().stream().filter(diseaseAesje -> Objects.equals(diseaseAesje.getUserId(), getDiseaseRequestHandler.getUserId())).collect(Collectors.toList()); + return diseaseAESJERepository.findAll().stream().filter(diseaseAesje -> Objects.equals(diseaseAesje.getUserId(), getDiseaseRequestHandler.getAshaId())).collect(Collectors.toList()); } public Object getAllFilaria(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter Filaria disease records - List filteredList = diseaseFilariasisRepository.findAll().stream().filter(screeningFilariasis -> Objects.equals(screeningFilariasis.getUserId(), getDiseaseRequestHandler.getUserId())).collect(Collectors.toList()); + List filteredList = diseaseFilariasisRepository.findAll().stream().filter(screeningFilariasis -> Objects.equals(screeningFilariasis.getUserId(), getDiseaseRequestHandler.getAshaId())).collect(Collectors.toList()); // Check if the list is empty if (filteredList.isEmpty()) { @@ -575,7 +575,7 @@ public Object getAllLeprosy(GetDiseaseRequestHandler getDiseaseRequestHandler) { // Fetch and filter Leprosy disease records List filteredList = diseaseLeprosyRepository.findAll().stream() - .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getUserId())) + .filter(disease -> Objects.equals(disease.getUserId(), getDiseaseRequestHandler.getAshaId())) .collect(Collectors.toList()); // Check if the list is empty From 71ae19741a6bc9a42b9c4b23974bb203d2c218a5 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 24 Mar 2026 11:33:19 +0530 Subject: [PATCH 785/792] fix DiseaseControl userId issue --- .../java/com/iemr/flw/controller/MicroBirthPlanController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java index c5cb04aa..c501b405 100644 --- a/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java +++ b/src/main/java/com/iemr/flw/controller/MicroBirthPlanController.java @@ -55,7 +55,7 @@ public ResponseEntity> createMicroBirthPlan(@RequestBody Mic } - @RequestMapping(value = "getAll", method = RequestMethod.POST) + @RequestMapping(value = "getAll", method = RequestMethod.GET) public ResponseEntity> getAllMicroBirthPlans(@RequestParam("userId") Integer userId) { Map response = new HashMap<>(); From 847e810818e23f9e7bd0b996f38189bb86fd88c2 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Tue, 24 Mar 2026 15:33:48 +0530 Subject: [PATCH 786/792] fix DiseaseControl userId issue --- .../flw/service/impl/CampaignServiceImpl.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java index 55756130..620ae6c6 100644 --- a/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/CampaignServiceImpl.java @@ -231,8 +231,13 @@ public List saveFilariasisCampaign(List Date: Tue, 24 Mar 2026 16:37:14 +0530 Subject: [PATCH 787/792] fix eye checkup get list issue --- .../com/iemr/flw/controller/BeneficiaryController.java | 8 ++++---- .../java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java | 1 + .../java/com/iemr/flw/service/BeneficiaryService.java | 4 ++-- .../iemr/flw/service/impl/BeneficiaryServiceImpl.java | 9 +++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java index 82b4cf7b..d7921ff0 100644 --- a/src/main/java/com/iemr/flw/controller/BeneficiaryController.java +++ b/src/main/java/com/iemr/flw/controller/BeneficiaryController.java @@ -66,7 +66,7 @@ public String getBeneficiaryDataByAsha(@RequestBody GetBenRequestHandler request } @RequestMapping(value = {"/eye_surgery/saveAll"}, method = RequestMethod.POST) - public ResponseEntity saveEyeSurgery(@RequestBody List eyeCheckupRequestDTOS) { + public ResponseEntity saveEyeSurgery(@RequestBody List eyeCheckupRequestDTOS,@RequestHeader(value = "JwtToken") String token) { Map response = new LinkedHashMap<>(); logger.info("Eye Checkup Save Request: {}", eyeCheckupRequestDTOS); @@ -77,7 +77,7 @@ public ResponseEntity saveEyeSurgery(@RequestBody List return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(response); } - String responseObject = beneficiaryService.saveEyeCheckupVsit(eyeCheckupRequestDTOS); + String responseObject = beneficiaryService.saveEyeCheckupVsit(eyeCheckupRequestDTOS,token); if (responseObject != null) { response.put("statusCode", HttpStatus.OK.value()); @@ -100,12 +100,12 @@ public ResponseEntity saveEyeSurgery(@RequestBody List @RequestMapping(value = {"/eye_surgery/getAll"}, method = RequestMethod.POST) - public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler request) { + public ResponseEntity getAllEyeSurgery(@RequestBody GetBenRequestHandler request,@RequestHeader(value = "JwtToken") String token) { Map response = new LinkedHashMap<>(); logger.info("Eye Checkup Get Request: {}", request); try { - List responseObject = beneficiaryService.getEyeCheckUpVisit(request); + List responseObject = beneficiaryService.getEyeCheckUpVisit(request,token); if (responseObject != null && !responseObject.isEmpty()) { response.put("statusCode", HttpStatus.OK.value()); diff --git a/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java b/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java index c0e3df73..fd713c44 100644 --- a/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java +++ b/src/main/java/com/iemr/flw/repo/iemr/EyeCheckUpVisitRepo.java @@ -10,4 +10,5 @@ public interface EyeCheckUpVisitRepo extends JpaRepository { List findByUserId(Integer userId); + List findByCreatedBy(String userName); } diff --git a/src/main/java/com/iemr/flw/service/BeneficiaryService.java b/src/main/java/com/iemr/flw/service/BeneficiaryService.java index 1db3026b..e69bc887 100644 --- a/src/main/java/com/iemr/flw/service/BeneficiaryService.java +++ b/src/main/java/com/iemr/flw/service/BeneficiaryService.java @@ -10,7 +10,7 @@ public interface BeneficiaryService { String getBenData(GetBenRequestHandler requestDTO, String authorisation) throws Exception; - String saveEyeCheckupVsit(List eyeCheckupRequestDTOS); + String saveEyeCheckupVsit(List eyeCheckupRequestDTOS,String token); - List getEyeCheckUpVisit(GetBenRequestHandler request); + List getEyeCheckUpVisit(GetBenRequestHandler request,String token); } diff --git a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java index f5a75785..9d60729d 100644 --- a/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/BeneficiaryServiceImpl.java @@ -521,7 +521,7 @@ public void fetchHealthIdByBenRegID(Long benRegID, String authorization, Map eyeCheckupRequestDTOS) { + public String saveEyeCheckupVsit(List eyeCheckupRequestDTOS,String token) { try { for (EyeCheckupRequestDTO dto : eyeCheckupRequestDTOS) { @@ -529,7 +529,7 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO visit.setBeneficiaryId(dto.getBeneficiaryId()); visit.setHouseholdId(dto.getHouseHoldId()); - visit.setUserId(userRepo.getUserIdByName(jwtUtil.getUserNameFromStorage())); // cache se lena hai + visit.setUserId(jwtUtil.extractUserId(token)); visit.setCreatedBy(dto.getUserName()); StringBuilder sb = new StringBuilder(); @@ -558,8 +558,9 @@ public String saveEyeCheckupVsit(List eyeCheckupRequestDTO } @Override - public List getEyeCheckUpVisit(GetBenRequestHandler request) { - List visits = eyeCheckUpVisitRepo.findByUserId(request.getAshaId()); + public List getEyeCheckUpVisit(GetBenRequestHandler request,String token) { + + List visits = eyeCheckUpVisitRepo.findByCreatedBy(jwtUtil.extractUsername(token)); return visits.stream().map(v -> { EyeCheckupRequestDTO dto = new EyeCheckupRequestDTO(); From 6ff151c5b019000823b35793dd4ca744b7e006d3 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 25 Mar 2026 17:32:17 +0530 Subject: [PATCH 788/792] fix ncd followup incentive issue --- .../controller/MalariaFollowUpController.java | 45 ++++++++------ .../flw/service/MalariaFollowUpService.java | 2 +- .../service/impl/DeathReportsServiceImpl.java | 9 ++- .../impl/DiseaseControlServiceImpl.java | 59 ++++++++++++++++++- .../impl/MalariaFollowUpServiceImpl.java | 53 +++++++++++------ 5 files changed, 129 insertions(+), 39 deletions(-) diff --git a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java index 230ad591..c2b421d6 100644 --- a/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java +++ b/src/main/java/com/iemr/flw/controller/MalariaFollowUpController.java @@ -28,6 +28,7 @@ import com.iemr.flw.dto.iemr.MalariaFollowListUpDTO; import com.iemr.flw.dto.iemr.MalariaFollowUpDTO; import com.iemr.flw.service.MalariaFollowUpService; +import com.iemr.flw.utils.JwtUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -40,42 +41,52 @@ @RequestMapping(value = "/follow-up", headers = "Authorization") public class MalariaFollowUpController { + @Autowired + private JwtUtil jwtUtil; + @Autowired private MalariaFollowUpService followUpService; @RequestMapping(value = "save", method = RequestMethod.POST) - public ResponseEntity> save(@RequestBody MalariaFollowUpDTO dto) { + public ResponseEntity> save(@RequestBody MalariaFollowUpDTO dto,@RequestHeader(value = "JwtToken") String token) { Map response = new HashMap<>(); try { - Boolean result = followUpService.saveFollowUp(dto); - if (result) { - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("message", "Follow-up saved successfully"); - } else { - response.put("status", "Failed"); - response.put("statusCode", 400); + if(token!=null){ + + Boolean result = followUpService.saveFollowUp(dto,token); + if (result) { + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("message", "Follow-up saved successfully"); + } else { + response.put("status", "Failed"); + response.put("statusCode", 5000); + } } + } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); - response.put("statusCode", 500); + response.put("statusCode", 5000); } return ResponseEntity.ok(response); } @RequestMapping(value = "get", method = RequestMethod.POST) - public ResponseEntity> getFollowUpsByUserId(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler) { + public ResponseEntity> getFollowUpsByUserId(@RequestBody GetDiseaseRequestHandler getDiseaseRequestHandler,@RequestHeader(value = "JwtToken") String token) { Map response = new HashMap<>(); try { - List data = followUpService.getByUserId(getDiseaseRequestHandler.getUserId()); - response.put("status", "Success"); - response.put("statusCode", 200); - response.put("data", data); - if (data.isEmpty()) { - response.put("message", "No records found"); + if(token!=null){ + List data = followUpService.getByUserId(jwtUtil.extractUserId(token)); + response.put("status", "Success"); + response.put("statusCode", 200); + response.put("data", data); + if (data.isEmpty()) { + response.put("message", "No records found"); + } } + } catch (Exception e) { response.put("status", "Error: " + e.getMessage()); response.put("statusCode", 5000); diff --git a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java index eb979318..324c6cd6 100644 --- a/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java +++ b/src/main/java/com/iemr/flw/service/MalariaFollowUpService.java @@ -9,7 +9,7 @@ public interface MalariaFollowUpService { - public Boolean saveFollowUp(MalariaFollowUpDTO dto) ; + public Boolean saveFollowUp(MalariaFollowUpDTO dto,String token) ; List getByUserId(Integer userId); diff --git a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java index 82cee5d0..684a03b2 100644 --- a/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DeathReportsServiceImpl.java @@ -139,7 +139,10 @@ private void checkAndAddIncentives(List cdrList) { Integer userId = userRepo.getUserIdByName(cdr.getCreatedBy()); IncentiveActivity immunizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_DEATH_REPORTING", GroupName.CHILD_HEALTH.getDisplayName()); - createIncentiveRecord(cdr,cdr.getBenId(),userId,immunizationActivity); + if(immunizationActivity!=null){ + createIncentiveRecord(cdr,cdr.getBenId(),userId,immunizationActivity); + + } }); } @@ -151,8 +154,10 @@ private void checkAndAddIncentivesMdsr(List mdsrList) { Integer userId = userRepo.getUserIdByName(mdsr.getCreatedBy()); IncentiveActivity immunizationActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("MATERNAL_DEATH_REPORT", GroupName.MATERNAL_HEALTH.getDisplayName()); + if(immunizationActivity!=null){ + createIncentiveRecord(mdsr,mdsr.getBenId(),userId,immunizationActivity); - createIncentiveRecord(mdsr,mdsr.getBenId(),userId,immunizationActivity); + } }); } diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 1abf70f3..78be64ec 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -30,6 +30,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.DiseaseType; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; import com.iemr.flw.utils.JwtUtil; @@ -1096,11 +1097,68 @@ public List saveChronicDiseaseVisit( dto.setId(savedEntity.getId()); responseList.add(dto); + checkIncentive(savedEntity,savedEntity.getUserID()); + + } return responseList; } + private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,Integer ashaId){ + String userName = userRepo.getUserNamedByUserId(ashaId); + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.NCD.getDisplayName()); + if (chronicDiseaseVisitEntity.getFollowUpNo() != null + && chronicDiseaseVisitEntity.getFollowUpDate() != null + && chronicDiseaseVisitEntity.getDiagnosisCodes() != null) { + + List targetDiseases = Arrays.asList( + "Hypertension (BP)", + "Diabetes (DM)", + "Cancer" + ); + + List diagnosisList = Arrays.asList( + chronicDiseaseVisitEntity.getDiagnosisCodes().split(",") + ); + + boolean matchFound = diagnosisList.stream() + .map(String::trim) + .anyMatch(targetDiseases::contains); + + if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { + + LocalDate localDate = chronicDiseaseVisitEntity.getFollowUpDate(); + Timestamp followUpTimestamp = Timestamp.valueOf(localDate.atStartOfDay()); + + addNCDFolloupIncentiveRecord( + incentiveActivity, + ashaId, + chronicDiseaseVisitEntity.getBenId(), + followUpTimestamp, + userName + ); + } + } + + + } + private IncentiveActivityRecord addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer ashaId, + Long benId, Timestamp createdDate, String userName) { + Timestamp now = Timestamp.valueOf(LocalDateTime.now()); + IncentiveActivityRecord record = new IncentiveActivityRecord(); + record.setActivityId(activity.getId()); + record.setCreatedDate(createdDate); + record.setCreatedBy(userName); + record.setStartDate(createdDate); + record.setEndDate(createdDate); + record.setUpdatedDate(now); + record.setUpdatedBy(userName); + record.setBenId(benId); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(activity.getRate())); + return record; + } @Override public List getCdtfVisits(GetBenRequestHandler getBenRequestHandler) { @@ -1131,7 +1189,6 @@ public List getCdtfVisits(GetBenRequestHandler getBenReq dtoList.add(dto); } - return dtoList; } diff --git a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java index 175c3666..3b6779bc 100644 --- a/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/MalariaFollowUpServiceImpl.java @@ -1,10 +1,16 @@ package com.iemr.flw.service.impl; +import com.iemr.flw.controller.CoupleController; import com.iemr.flw.domain.iemr.MalariaFollowUp; import com.iemr.flw.dto.iemr.MalariaFollowListUpDTO; import com.iemr.flw.dto.iemr.MalariaFollowUpDTO; import com.iemr.flw.repo.iemr.MalariaFollowUpRepository; import com.iemr.flw.service.MalariaFollowUpService; +import com.iemr.flw.utils.JwtUtil; +import io.jsonwebtoken.Jwt; +import org.checkerframework.checker.units.qual.A; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -19,30 +25,41 @@ public class MalariaFollowUpServiceImpl implements MalariaFollowUpService { @Autowired private MalariaFollowUpRepository repository; - public Boolean saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO) { + private final Logger logger = LoggerFactory.getLogger(MalariaFollowUpServiceImpl.class); - for(MalariaFollowListUpDTO dto : malariaFollowUpDTO.getMalariaFollowListUp()){ - if (dto.getTreatmentStartDate().after(new Date())) { - return false; - } + @Autowired + private JwtUtil jwtUtil; + + public Boolean saveFollowUp(MalariaFollowUpDTO malariaFollowUpDTO,String token) { + try { + for(MalariaFollowListUpDTO dto : malariaFollowUpDTO.getMalariaFollowListUp()){ + if (dto.getTreatmentStartDate().after(new Date())) { + return false; + } + + if (dto.getTreatmentCompletionDate() != null && + dto.getTreatmentCompletionDate().before(dto.getTreatmentStartDate())) { + return false; + } - if (dto.getTreatmentCompletionDate() != null && - dto.getTreatmentCompletionDate().before(dto.getTreatmentStartDate())) { - return false; - } + if (dto.getReferralDate() != null && + dto.getReferralDate().before(dto.getTreatmentStartDate())) { + return false; + } - if (dto.getReferralDate() != null && - dto.getReferralDate().before(dto.getTreatmentStartDate())) { - return false; - } + dto.setUserId(jwtUtil.extractUserId(token)); + MalariaFollowUp entity = new MalariaFollowUp(); + BeanUtils.copyProperties(dto, entity); + repository.save(entity); + return true; + } + }catch (Exception e){ + logger.error("Exception saveFollowUp: "+ e.getMessage()); + return false; + } - MalariaFollowUp entity = new MalariaFollowUp(); - BeanUtils.copyProperties(dto, entity); - repository.save(entity); - return true; - } return false; } From 2236b7944fc3dd0593362530b8a29f41819d4357 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 25 Mar 2026 17:48:50 +0530 Subject: [PATCH 789/792] fix ncd followup incentive issue --- .../impl/DiseaseControlServiceImpl.java | 100 ++++++++++-------- .../service/impl/IncentiveServiceImpl.java | 25 ----- 2 files changed, 57 insertions(+), 68 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 78be64ec..05979215 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1107,57 +1107,71 @@ public List saveChronicDiseaseVisit( private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,Integer ashaId){ String userName = userRepo.getUserNamedByUserId(ashaId); IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.NCD.getDisplayName()); - if (chronicDiseaseVisitEntity.getFollowUpNo() != null - && chronicDiseaseVisitEntity.getFollowUpDate() != null - && chronicDiseaseVisitEntity.getDiagnosisCodes() != null) { - - List targetDiseases = Arrays.asList( - "Hypertension (BP)", - "Diabetes (DM)", - "Cancer" - ); - - List diagnosisList = Arrays.asList( - chronicDiseaseVisitEntity.getDiagnosisCodes().split(",") - ); - - boolean matchFound = diagnosisList.stream() - .map(String::trim) - .anyMatch(targetDiseases::contains); - - if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { - - LocalDate localDate = chronicDiseaseVisitEntity.getFollowUpDate(); - Timestamp followUpTimestamp = Timestamp.valueOf(localDate.atStartOfDay()); - - addNCDFolloupIncentiveRecord( - incentiveActivity, - ashaId, - chronicDiseaseVisitEntity.getBenId(), - followUpTimestamp, - userName + if(incentiveActivity!=null){ + if (chronicDiseaseVisitEntity.getFollowUpNo() != null + && chronicDiseaseVisitEntity.getFollowUpDate() != null + && chronicDiseaseVisitEntity.getDiagnosisCodes() != null) { + + List targetDiseases = Arrays.asList( + "Hypertension (BP)", + "Diabetes (DM)", + "Cancer" ); + + List diagnosisList = Arrays.asList( + chronicDiseaseVisitEntity.getDiagnosisCodes().split(",") + ); + + boolean matchFound = diagnosisList.stream() + .map(String::trim) + .anyMatch(targetDiseases::contains); + + if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { + + LocalDate localDate = chronicDiseaseVisitEntity.getFollowUpDate(); + Timestamp followUpTimestamp = Timestamp.valueOf(localDate.atStartOfDay()); + + addNCDFolloupIncentiveRecord( + incentiveActivity, + ashaId, + chronicDiseaseVisitEntity.getBenId(), + followUpTimestamp, + userName + ); + } } } + } - private IncentiveActivityRecord addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer ashaId, + private void addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer ashaId, Long benId, Timestamp createdDate, String userName) { - Timestamp now = Timestamp.valueOf(LocalDateTime.now()); - IncentiveActivityRecord record = new IncentiveActivityRecord(); - record.setActivityId(activity.getId()); - record.setCreatedDate(createdDate); - record.setCreatedBy(userName); - record.setStartDate(createdDate); - record.setEndDate(createdDate); - record.setUpdatedDate(now); - record.setUpdatedBy(userName); - record.setBenId(benId); - record.setAshaId(ashaId); - record.setAmount(Long.valueOf(activity.getRate())); - return record; + try { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(activity.getId(), createdDate, benId); + + Timestamp now = Timestamp.valueOf(LocalDateTime.now()); + if(record==null){ + record.setActivityId(activity.getId()); + record.setCreatedDate(createdDate); + record.setCreatedBy(userName); + record.setStartDate(createdDate); + record.setEndDate(createdDate); + record.setUpdatedDate(now); + record.setUpdatedBy(userName); + record.setBenId(benId); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(activity.getRate())); + record .setIsEligible(true); + recordRepo.save(record); + } + }catch (Exception e){ + logger.error("Fail to save IncentiveActivityRecord " + e.getMessage()); + } + + } @Override public List getCdtfVisits(GetBenRequestHandler getBenRequestHandler) { diff --git a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java index e09af740..09523a4b 100644 --- a/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java @@ -290,42 +290,17 @@ private void incentiveOfNcdReferal(Integer ashaId, Integer stateId) { ).stream().collect(Collectors.toMap(IncentiveActivity::getName, Function.identity())); IncentiveActivity ncdPopEnumeration = activityMap.get("NCD_POP_ENUMERATION"); - IncentiveActivity ncdFollowupTreatment = activityMap.get("NCD_FOLLOWUP_TREATMENT"); CompletableFuture> benReferFuture = CompletableFuture.supplyAsync(() -> benReferDetailsRepo.findByCreatedBy(userName)); CompletableFuture> cbacFuture = CompletableFuture.supplyAsync(() -> cbacIemrDetailsRepo.findByCreatedBy(userName)); - List benReferDetails = benReferFuture.get(); List cbacDetailsImer = cbacFuture.get(); List recordsToSave = new ArrayList<>(); - if (ncdFollowupTreatment != null && !benReferDetails.isEmpty()) { - List benIds = benReferDetails.stream() - .map(BenReferDetails::getBeneficiaryRegID) - .filter(Objects::nonNull) - .collect(Collectors.toList()); - - Set existingKeys = recordRepo - .findExistingRecords(ncdFollowupTreatment.getId(), benIds, ashaId) - .stream() - .map(r -> r.getActivityId() + "_" + r.getBenId() + "_" + r.getCreatedDate()) - .collect(Collectors.toSet()); - - final IncentiveActivity activity = ncdFollowupTreatment; - benReferDetails.forEach(ref -> { - Long benId = ref.getBeneficiaryRegID(); - if (benId != null) { - String key = activity.getId() + "_" + benId + "_" + ref.getCreatedDate(); - if (!existingKeys.contains(key)) { - recordsToSave.add(addNCDandCBACIncentiveRecord(activity, ashaId, benId, ref.getCreatedDate(), userName)); - } - } - }); - } if (ncdPopEnumeration != null && !cbacDetailsImer.isEmpty()) { List cbacBenIds = cbacDetailsImer.stream() From c4bdf91ca5938703a639cff7f8f6f0d7d8d9e514 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 25 Mar 2026 19:16:06 +0530 Subject: [PATCH 790/792] fix ncd followup incentive issue --- .../impl/DiseaseControlServiceImpl.java | 85 ++++++++++++++++++- 1 file changed, 81 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 1abf70f3..a3436b90 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -30,6 +30,7 @@ import com.iemr.flw.dto.identity.GetBenRequestHandler; import com.iemr.flw.dto.iemr.*; import com.iemr.flw.masterEnum.DiseaseType; +import com.iemr.flw.masterEnum.GroupName; import com.iemr.flw.repo.iemr.*; import com.iemr.flw.service.DiseaseControlService; import com.iemr.flw.utils.JwtUtil; @@ -1077,7 +1078,10 @@ public List saveChronicDiseaseVisit( entity.setVersion(dto.getVersion()); entity.setVisitNo(dto.getVisitNo()); entity.setFollowUpNo(dto.getFollowUpNo()); - entity.setFollowUpDate(dto.getFollowUpDate()); + if(dto.getFollowUpDate()!=null){ + entity.setFollowUpDate(dto.getFollowUpDate()); + + } entity.setDiagnosisCodes(dto.getDiagnosisCodes()); entity.setFormDataJson(dto.getFormDataJson()); entity.setUserID(jwtUtil.extractUserId(token)); @@ -1096,11 +1100,82 @@ public List saveChronicDiseaseVisit( dto.setId(savedEntity.getId()); responseList.add(dto); + checkIncentive(savedEntity,savedEntity.getUserID()); + + } return responseList; } + private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,Integer ashaId){ + String userName = userRepo.getUserNamedByUserId(ashaId); + IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.NCD.getDisplayName()); + if(incentiveActivity!=null){ + if (chronicDiseaseVisitEntity.getFollowUpNo() != null + && chronicDiseaseVisitEntity.getCreatedDate() != null + && chronicDiseaseVisitEntity.getDiagnosisCodes() != null) { + + List targetDiseases = Arrays.asList( + "Hypertension (BP)", + "Diabetes (DM)", + "Cancer" + ); + + List diagnosisList = Arrays.asList( + chronicDiseaseVisitEntity.getDiagnosisCodes().split(",") + ); + boolean matchFound = diagnosisList.stream() + .map(String::trim) + .anyMatch(targetDiseases::contains); + + if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { + LocalDateTime localDateTime = chronicDiseaseVisitEntity.getCreatedDate(); + + Timestamp followUpTimestamp = Timestamp.valueOf(localDateTime); + + addNCDFolloupIncentiveRecord( + incentiveActivity, + ashaId, + chronicDiseaseVisitEntity.getBenId(), + followUpTimestamp, + userName + ); + } + } + } + + + + } + + private void addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer ashaId, + Long benId, Timestamp createdDate, String userName) { + try { + IncentiveActivityRecord record = recordRepo + .findRecordByActivityIdCreatedDateBenId(activity.getId(), createdDate, benId); + + Timestamp now = Timestamp.valueOf(LocalDateTime.now()); + if(record==null){ + record.setActivityId(activity.getId()); + record.setCreatedDate(createdDate); + record.setCreatedBy(userName); + record.setStartDate(createdDate); + record.setEndDate(createdDate); + record.setUpdatedDate(now); + record.setUpdatedBy(userName); + record.setBenId(benId); + record.setAshaId(ashaId); + record.setAmount(Long.valueOf(activity.getRate())); + record .setIsEligible(true); + recordRepo.save(record); + } + }catch (Exception e){ + logger.error("Fail to save IncentiveActivityRecord " + e.getMessage()); + } + + + } @Override public List getCdtfVisits(GetBenRequestHandler getBenRequestHandler) { @@ -1119,7 +1194,10 @@ public List getCdtfVisits(GetBenRequestHandler getBenReq dto.setVersion(entity.getVersion()); dto.setVisitNo(entity.getVisitNo()); dto.setFollowUpNo(entity.getFollowUpNo()); - dto.setFollowUpDate(entity.getFollowUpDate()); + if(entity.getFollowUpDate()!=null){ + dto.setFollowUpDate(entity.getFollowUpDate()); + + } dto.setDiagnosisCodes(entity.getDiagnosisCodes()); dto.setFormDataJson(entity.getFormDataJson()); @@ -1128,10 +1206,9 @@ public List getCdtfVisits(GetBenRequestHandler getBenReq entity.getTreatmentStartDate().toString() ); } - + checkIncentive(entity,entity.getUserID()); dtoList.add(dto); } - return dtoList; } From b4e3f2f2466c9ab0c61128262d5cf562f6a7a66e Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 25 Mar 2026 20:18:41 +0530 Subject: [PATCH 791/792] fix follow up date issue --- .../com/iemr/flw/service/impl/DiseaseControlServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index a3436b90..5f261dd9 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1129,7 +1129,7 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity, .map(String::trim) .anyMatch(targetDiseases::contains); - if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { + if (matchFound) { LocalDateTime localDateTime = chronicDiseaseVisitEntity.getCreatedDate(); Timestamp followUpTimestamp = Timestamp.valueOf(localDateTime); From 35fdc5424bf15b7f073dc324a81b2e57d9e38613 Mon Sep 17 00:00:00 2001 From: Saurav Mishra Date: Wed, 25 Mar 2026 20:51:12 +0530 Subject: [PATCH 792/792] fix follow up date issue --- .../impl/DiseaseControlServiceImpl.java | 66 +++++++++++-------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java index 5f261dd9..b005f2d6 100644 --- a/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java +++ b/src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java @@ -1110,6 +1110,7 @@ public List saveChronicDiseaseVisit( private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,Integer ashaId){ String userName = userRepo.getUserNamedByUserId(ashaId); IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.NCD.getDisplayName()); + logger.info("incentiveActivity:"+ incentiveActivity.getId()); if(incentiveActivity!=null){ if (chronicDiseaseVisitEntity.getFollowUpNo() != null && chronicDiseaseVisitEntity.getCreatedDate() != null @@ -1129,7 +1130,7 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity, .map(String::trim) .anyMatch(targetDiseases::contains); - if (matchFound) { + if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) { LocalDateTime localDateTime = chronicDiseaseVisitEntity.getCreatedDate(); Timestamp followUpTimestamp = Timestamp.valueOf(localDateTime); @@ -1149,15 +1150,16 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity, } - private void addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer ashaId, + private void addNCDFolloupIncentiveRecord(IncentiveActivity incentiveActivity, Integer ashaId, Long benId, Timestamp createdDate, String userName) { try { IncentiveActivityRecord record = recordRepo - .findRecordByActivityIdCreatedDateBenId(activity.getId(), createdDate, benId); + .findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), createdDate, benId); Timestamp now = Timestamp.valueOf(LocalDateTime.now()); if(record==null){ - record.setActivityId(activity.getId()); + record = new IncentiveActivityRecord(); + record.setActivityId(incentiveActivity.getId()); record.setCreatedDate(createdDate); record.setCreatedBy(userName); record.setStartDate(createdDate); @@ -1166,7 +1168,7 @@ private void addNCDFolloupIncentiveRecord(IncentiveActivity activity, Integer as record.setUpdatedBy(userName); record.setBenId(benId); record.setAshaId(ashaId); - record.setAmount(Long.valueOf(activity.getRate())); + record.setAmount(Long.valueOf(incentiveActivity.getRate())); record .setIsEligible(true); recordRepo.save(record); } @@ -1178,37 +1180,43 @@ record .setIsEligible(true); } @Override public List getCdtfVisits(GetBenRequestHandler getBenRequestHandler) { + List dtoList = new ArrayList<>(); - List entityList = chronicDiseaseVisitRepository.findByUserID(getBenRequestHandler.getAshaId()); + try { - List dtoList = new ArrayList<>(); + List entityList = chronicDiseaseVisitRepository.findByUserID(getBenRequestHandler.getAshaId()); - for (ChronicDiseaseVisitEntity entity : entityList) { - ChronicDiseaseVisitDTO dto = new ChronicDiseaseVisitDTO(); + for (ChronicDiseaseVisitEntity entity : entityList) { - dto.setId(entity.getId()); - dto.setBenId(entity.getBenId()); - dto.setHhId(entity.getHhId()); - dto.setFormId(entity.getFormId()); - dto.setVersion(entity.getVersion()); - dto.setVisitNo(entity.getVisitNo()); - dto.setFollowUpNo(entity.getFollowUpNo()); - if(entity.getFollowUpDate()!=null){ - dto.setFollowUpDate(entity.getFollowUpDate()); + ChronicDiseaseVisitDTO dto = new ChronicDiseaseVisitDTO(); - } - dto.setDiagnosisCodes(entity.getDiagnosisCodes()); - dto.setFormDataJson(entity.getFormDataJson()); + dto.setId(entity.getId()); + dto.setBenId(entity.getBenId()); + dto.setHhId(entity.getHhId()); + dto.setFormId(entity.getFormId()); + dto.setVersion(entity.getVersion()); + dto.setVisitNo(entity.getVisitNo()); + dto.setFollowUpNo(entity.getFollowUpNo()); + if(entity.getFollowUpDate()!=null){ + dto.setFollowUpDate(entity.getFollowUpDate()); + + } + dto.setDiagnosisCodes(entity.getDiagnosisCodes()); + dto.setFormDataJson(entity.getFormDataJson()); + + if (entity.getTreatmentStartDate() != null) { + dto.setTreatmentStartDate( + entity.getTreatmentStartDate().toString() + ); + } + checkIncentive(entity,entity.getUserID()); + dtoList.add(dto); + } + }catch (Exception e){ + + } - if (entity.getTreatmentStartDate() != null) { - dto.setTreatmentStartDate( - entity.getTreatmentStartDate().toString() - ); - } - checkIncentive(entity,entity.getUserID()); - dtoList.add(dto); - } return dtoList; }