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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/main/java/com/iemr/flw/domain/iemr/AHDForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public class AHDForm {
@Column(name = "ahd_date")
private String ahdDate;

@Lob
@Column(name = "image1")
private byte[] image1;
private String image1;

@Lob
@Column(name = "image2")
private byte[] image2;
private String image2;

@Column(name = "user_id")
private Long userId;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iemr/flw/domain/iemr/DewormingForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ public class DewormingForm {
@Column(name = "age_group")
private Integer ageGroup;

@Lob
@Column(name = "image1")
private byte[] image1;
private String image1;

@Lob
@Column(name = "image2")
private byte[] image2;
private String image2;

@Column(name = "user_id")
private Long userId;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iemr/flw/domain/iemr/PHCReviewForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public class PHCReviewForm {
@Column(name = "no_of_beneficiaries_attended")
private Integer noOfBeneficiariesAttended;

@Lob
@Column(name = "image1")
private byte[] image1;
private String image1;

@Lob
@Column(name = "image2")
private byte[] image2;
private String image2;

@Column(name = "user_id")
private Long userId;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iemr/flw/domain/iemr/VHNDForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public class VHNDForm {
@Column(name = "no_of_beneficiaries_attended")
private Integer noOfBeneficiariesAttended;

@Lob
@Column(name = "image1")
private byte[] image1;
private String image1;

@Lob
@Column(name = "image2")
private byte[] image2;
private String image2;

@Column(name = "form_type")
private String formType;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/com/iemr/flw/domain/iemr/VhncForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ public class VhncForm {
@Column(name = "no_of_beneficiaries_attended")
private Integer noOfBeneficiariesAttended;

@Lob
@Column(name = "image1")
private byte[] image1;
private String image1;

@Lob
@Column(name = "image2")
private byte[] image2;
private String image2;

@Column(name = "user_id")
private Long userId;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/iemr/flw/dto/iemr/AhDMeetingFormDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class AhDMeetingFormDTO {
private String mobilizedForAHD;
private String ahdPlace;
private String ahdDate;
private byte[] image1;
private byte[] image2;
private String image1;
private String image2;
}
4 changes: 2 additions & 2 deletions src/main/java/com/iemr/flw/dto/iemr/DewormingFormDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class DewormingFormDTO {
private String dewormingDate;
private String dewormingLocation;
private Integer ageGroup;
private byte[] image1;
private byte[] image2;
private String image1;
private String image2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class PhcReviewMeetingFormDTO {
private String mitaninHistory;
private String mitaninActivityCheckList;
private Integer placeId;
private byte[] image1;
private byte[] image2;
private String image1;
private String image2;



Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/iemr/flw/dto/iemr/VHNDFormDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public class VHNDFormDTO {
private String vhndDate;
private String place;
private Integer noOfBeneficiariesAttended;
private byte[] image1;
private byte[] image2;
private String image1;
private String image2;
private Integer vhndPlaceId;
private String pregnantWomenAnc;
private String lactatingMothersPnc;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/iemr/flw/dto/iemr/VhncFormDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class VhncFormDTO {
private String vhncDate;
private String place;
private Integer noOfBeneficiariesAttended;
private byte[] image1;
private byte[] image2;
private String image1;
private String image2;
private String villageName;
private Integer anm;
private Integer aww;
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/iemr/flw/repo/iemr/BenReferDetailsRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.sql.Timestamp;
import java.util.List;
import java.util.Optional;

Expand All @@ -53,6 +54,21 @@ public interface BenReferDetailsRepo extends JpaRepository<BenReferDetails, Long
@Query(value = "SELECT COUNT(*) FROM db_iemr.t_benreferdetails WHERE CreatedBy = :userName AND revisitDate >= :startDate AND revisitDate < :endDate", nativeQuery = true)
Long countMonthlyReferralsByDateRange(@Param("userName") String userName, @Param("startDate") java.sql.Timestamp startDate, @Param("endDate") java.sql.Timestamp endDate);

@Query(value = """
SELECT revisitDate
FROM db_iemr.t_benreferdetails
WHERE CreatedBy = :userName
AND revisitDate >= :startDate
AND revisitDate < :endDate
ORDER BY revisitDate ASC
LIMIT 1 OFFSET 9
""", nativeQuery = true)
Timestamp findTenthReferralDate(
@Param("userName") String userName,
@Param("startDate") Timestamp startDate,
@Param("endDate") Timestamp endDate
);

@Query(value = """
SELECT COUNT(*)
FROM db_iemr.t_benreferdetails
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ private void checkAndAddHbyncIncentives(List<HbycChildVisit> hbycList) {
}
if(hbyc.getIfa_given() && eligibleHbycVisits.contains(hbyc.getVisit_day())){
if(hbyncLactatingIronPacketActivityCH!=null){
createIncentiveRecordforHbyncVisit(hbyc, hbyc.getBeneficiaryId(), hbyncLactatingIronPacketActivityCH, hbyc.getCreated_by());
createIncentiveRecordforHbyncVisit(hbyc, 0L, hbyncLactatingIronPacketActivityCH, hbyc.getCreated_by());

}

Expand Down Expand Up @@ -1296,16 +1296,16 @@ private void checkAndAddIncentives(List<ChildVaccination> vaccinationList) {

private void createIncentiveRecord(ChildVaccination vaccination, Long benId, Integer userId, IncentiveActivity immunizationActivity) {
IncentiveActivityRecord record = recordRepo
.findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), vaccination.getCreatedDate(), benId,userId);
.findRecordByActivityIdCreatedDateBenId(immunizationActivity.getId(), vaccination.getReceivedDate(), benId,userId);

if (record == null) {
record = new IncentiveActivityRecord();
record.setActivityId(immunizationActivity.getId());
record.setCreatedDate(vaccination.getCreatedDate());
record.setCreatedDate(vaccination.getReceivedDate());
record.setCreatedBy(vaccination.getCreatedBy());
record.setStartDate(vaccination.getCreatedDate());
record.setEndDate(vaccination.getCreatedDate());
record.setUpdatedDate(vaccination.getCreatedDate());
record.setStartDate(vaccination.getReceivedDate());
record.setEndDate(vaccination.getReceivedDate());
record.setUpdatedDate(vaccination.getReceivedDate());
record.setUpdatedBy(vaccination.getCreatedBy());
record.setBenId(benId);
record.setAshaId(userId);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/iemr/flw/service/impl/CoupleServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,15 @@ private void createIncentiveRecord(EligibleCoupleRegister eligibleCoupleDTO, Inc
Integer userId = userRepo.getUserIdByName(eligibleCoupleDTO.getCreatedBy());

IncentiveActivityRecord record = recordRepo
.findRecordByActivityIdCreatedDateBenId(activity.getId(), eligibleCoupleDTO.getCreatedDate(), eligibleCoupleDTO.getBenId(),userId);
.findRecordByActivityIdCreatedDateBenId(activity.getId(), eligibleCoupleDTO.getRegistrationDate(), eligibleCoupleDTO.getBenId(),userId);
if (record == null) {
record = new IncentiveActivityRecord();
record.setActivityId(activity.getId());
record.setCreatedDate(eligibleCoupleDTO.getCreatedDate());
record.setCreatedDate(eligibleCoupleDTO.getRegistrationDate());
record.setCreatedBy(eligibleCoupleDTO.getCreatedBy());
record.setStartDate(eligibleCoupleDTO.getCreatedDate());
record.setEndDate(eligibleCoupleDTO.getCreatedDate());
record.setUpdatedDate(eligibleCoupleDTO.getCreatedDate());
record.setStartDate(eligibleCoupleDTO.getRegistrationDate());
record.setEndDate(eligibleCoupleDTO.getRegistrationDate());
record.setUpdatedDate(eligibleCoupleDTO.getRegistrationDate());
record.setUpdatedBy(eligibleCoupleDTO.getCreatedBy());
record.setBenId(eligibleCoupleDTO.getBenId());
record.setAshaId(userId);
Expand Down
25 changes: 16 additions & 9 deletions src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@
}
}

private void incentiveOfNcdReferal(Integer ashaId, Integer stateId, GetBenRequestHandler request, String userName) {

Check failure on line 976 in src/main/java/com/iemr/flw/service/impl/IncentiveServiceImpl.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 50 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=PSMRI_FLW-API&issues=AaGvm7kyRVlkm00GqRAj&open=AaGvm7kyRVlkm00GqRAj&pullRequest=406
try {
if (userName == null) {
userName = userRepo.getUserNamedByUserId(ashaId);
Expand Down Expand Up @@ -1046,36 +1046,43 @@
// 2. Optimize HWC_REFERRAL_10_CASES: check if monthly incentive already exists FIRST,
// and use index-friendly date range query instead of MONTH()/YEAR() functions.
if (hwcReferralEnumeration != null) {

LocalDate now = LocalDate.now();
Timestamp startOfMonth = Timestamp.valueOf(now.withDayOfMonth(1).atStartOfDay());
Timestamp endOfMonth = Timestamp.valueOf(now.withDayOfMonth(now.lengthOfMonth()).atTime(23, 59, 59));

LocalDate requestDate = (request != null && request.getFromDate() != null)
? request.getFromDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()
: now;
LocalDate reqMonthFirst = requestDate.withDayOfMonth(1);
Timestamp reqStart = Timestamp.valueOf(reqMonthFirst.atStartOfDay());
Timestamp reqEnd = Timestamp.valueOf(reqMonthFirst.plusMonths(1).atStartOfDay());

IncentiveActivityRecord existingHwcRecord = recordRepo.findRecordByActivityIdCreatedDateBenId(
hwcReferralEnumeration.getId(),
0L,
ashaId,
startOfMonth,
endOfMonth
reqStart,
reqEnd
);

logger.info("HWC Incentive Request Start Date: {}", reqStart);
logger.info("HWC Incentive Request End Date: {}", reqEnd);

if (existingHwcRecord == null) {
LocalDate requestDate = (request != null && request.getFromDate() != null)
? request.getFromDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate()
: now;
LocalDate reqMonthFirst = requestDate.withDayOfMonth(1);
Timestamp reqStart = Timestamp.valueOf(reqMonthFirst.atStartOfDay());
Timestamp reqEnd = Timestamp.valueOf(reqMonthFirst.plusMonths(1).atStartOfDay());


Long referralCount = benReferDetailsRepo.countMonthlyReferralsByDateRange(
userName,
reqStart,
reqEnd
);
Timestamp timestamp = benReferDetailsRepo.findTenthReferralDate(userName,reqStart,reqEnd);


logger.info("referralCount: {}", referralCount);

if (referralCount != null && referralCount >= 10) {
Timestamp timestamp = Timestamp.valueOf(LocalDateTime.now());
IncentiveActivityRecord record = new IncentiveActivityRecord();
record.setActivityId(hwcReferralEnumeration.getId());
record.setCreatedDate(timestamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ private void checkAndAddHighRisk(List<PMSMA> pmsmaList) {

private void addIncentiveForHighRisk(IncentiveActivity incentiveActivity, PMSMA pmsma) {
IncentiveActivityRecord record = recordRepo
.findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), pmsma.getCreatedDate(), pmsma.getBenId(),userRepo.getUserIdByName(pmsma.getCreatedBy()));
.findRecordByActivityIdCreatedDateBenId(incentiveActivity.getId(), pmsma.getVisitDate(), pmsma.getBenId(),userRepo.getUserIdByName(pmsma.getCreatedBy()));
// get bene details

if (record == null) {
Expand Down Expand Up @@ -968,7 +968,7 @@ private void checkAndAddIncentives(List<ANCVisit> ancList, Integer userId) {


if (identifiedHrpActivityCH != null && ancVisit.getIsHrpConfirmed() != null
&& ancVisit.getIsHrpConfirmed()) {
&& ancVisit.getIsHrpConfirmed() && ancVisit.getPlaceOfAnc().equals("PMSMA Visit") ) {
recordAncRelatedIncentive(identifiedHrpActivityCH, ancVisit);
}
});
Expand Down
Loading