Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ public class TBConfirmedCase {
@Column(name = "updated_at")
private LocalDate updatedAt;


}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public interface DiseaseLeprosyRepository extends JpaRepository<ScreeningLeprosy
// Custom queries can be added here if needed
@Query("SELECT s FROM ScreeningLeprosy s WHERE s.createdBy = :createdBy")
List<ScreeningLeprosy> getByCreatedBy(@Param("createdBy") String createdBy);


}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

@Repository
public interface LeprosyFollowUpRepository extends JpaRepository<LeprosyFollowUp, Long> {
Optional<LeprosyFollowUp> findByBenId(Long benId);
List<LeprosyFollowUp> findByBenId(Long benId);

// Custom queries can be added here if needed
@Query("SELECT s FROM LeprosyFollowUp s WHERE s.createdBy = :createdBy")
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/com/iemr/flw/service/MaaMeetingService.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,20 +239,23 @@ record = new IncentiveActivityRecord();
record.setBenId(0L);
record.setAshaId(meeting.getAshaId());
record.setAmount(Long.valueOf(incentiveActivity.getRate()));
record.setIsEligible(true);
recordRepo.save(record);

if (meeting.getMeetingImagesJson() != null) {
record.setIsEligible(true);
recordRepo.save(record);

} else {
record.setIsEligible(false);
IncentiveActivityRecord activityRecord = recordRepo.save(record);
if (activityRecord != null) {
updatePendingActivity(meeting.getAshaId(), meeting.getId(), activityRecord.getId(), incentiveActivity.getId());

}

}
// if (meeting.getMeetingImagesJson() != null) {
// record.setIsEligible(true);
// recordRepo.save(record);
//
// } else {
// record.setIsEligible(false);
// IncentiveActivityRecord activityRecord = recordRepo.save(record);
// if (activityRecord != null) {
// updatePendingActivity(meeting.getAshaId(), meeting.getId(), activityRecord.getId(), incentiveActivity.getId());
//
// }
//
// }
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ private List<String> parseBase64Json(String jsonString) {

private void checkMonthlyPulsePolioIncentive(Integer ashaId,LocalDate startDate,LocalDate endDate) {

IncentiveActivity CHILD_MOBILIZATION_SESSIONS = incentivesRepo.findIncentiveMasterByNameAndGroup("CHILD_MOBILIZATION_SESSIONS", GroupName.ACTIVITY.getDisplayName());
IncentiveActivity CHILD_MOBILIZATION_SESSIONS = incentivesRepo.findIncentiveMasterByNameAndGroup("PULSE_POLIO_SUPPORT", GroupName.ACTIVITY.getDisplayName());
if (CHILD_MOBILIZATION_SESSIONS != null) {
addAshaIncentiveRecord(CHILD_MOBILIZATION_SESSIONS, ashaId,startDate,endDate);
}
Expand Down
196 changes: 62 additions & 134 deletions src/main/java/com/iemr/flw/service/impl/DiseaseControlServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) {
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForIdentificationLeprosy(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
screeningLeprosy.getHomeVisitDate(),
screeningLeprosy.getHomeVisitDate(),
diseaseControlDTO.getUserId());

if (incentiveActivityRecord != null) {
Expand All @@ -316,44 +316,6 @@ public String saveLeprosy(LeprosyDTO diseaseControlDTO) {
logger.info("Incentive not created");
}
}
if (screeningLeprosy.getIsConfirmed()) {
if(screeningLeprosy.getTypeOfLeprosy()!=null){
if (screeningLeprosy.getTypeOfLeprosy().equals("PB (Paucibacillary)")) {
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyPaucibacillaryConfirmed(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
diseaseControlDTO.getUserId());

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}

}
if (screeningLeprosy.getTypeOfLeprosy().equals("MB (Multibacillary)")) {
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyMultibacillaryConfirmed(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
diseaseControlDTO.getUserId());

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}

}
}


}

return "Data add successfully";

Expand Down Expand Up @@ -391,38 +353,46 @@ private LeprosyFollowUp saveLeprosyFollowUpData(LeprosyFollowUpDTO data) {
entity.setModifiedBy(data.getModifiedBy());
entity.setLastModDate(
data.getLastModDate() != null ? data.getLastModDate() : new Timestamp(System.currentTimeMillis()));

if(!leprosyFollowUpRepository.findByBenId(entity.getBenId()).isEmpty()){
if(leprosyFollowUpRepository.findByBenId(entity.getBenId()).size()>=6 && leprosyFollowUpRepository.findByBenId(entity.getBenId()).size()<=12){
Integer userId = userRepo.getUserIdByName(entity.getCreatedBy());
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyPaucibacillaryConfirmed(
entity.getBenId(),
entity.getTreatmentEndDate(),
entity.getTreatmentEndDate(),
userId);

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}
}
}

if(!leprosyFollowUpRepository.findByBenId(entity.getBenId()).isEmpty()){
if(leprosyFollowUpRepository.findByBenId(entity.getBenId()).size()>=12){
Integer userId = userRepo.getUserIdByName(entity.getCreatedBy());
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyMultibacillaryConfirmed(
entity.getBenId(),
entity.getTreatmentEndDate(),
entity.getTreatmentEndDate(),
userId);

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}
}
}
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)
Expand All @@ -443,68 +413,10 @@ public List<DiseaseGetLeprosyDTO> getAllLeprosyData(String createdBy) {
List<DiseaseGetLeprosyDTO> dtos = new ArrayList<>();
leprosyList.forEach(leprosy -> {
dtos.add(modelMapper.map(leprosy, DiseaseGetLeprosyDTO.class));
checkAndIncentive(leprosy,leprosy.getUserId());
});

return dtos;
}
private void checkAndIncentive(ScreeningLeprosy screeningLeprosy,Integer userId){
if(screeningLeprosy.getIsConfirmed()){
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForIdentificationLeprosy(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
userId);

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}
}
if (screeningLeprosy.getIsConfirmed()) {
if(screeningLeprosy.getTypeOfLeprosy()!=null){
if (screeningLeprosy.getTypeOfLeprosy().equals("PB (Paucibacillary)")) {
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyPaucibacillaryConfirmed(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
userId);

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}

}
if (screeningLeprosy.getTypeOfLeprosy().equals("MB (Multibacillary)")) {
IncentiveActivityRecord incentiveActivityRecord =
incentiveLogicService.incentiveForLeprosyMultibacillaryConfirmed(
screeningLeprosy.getBenId(),
screeningLeprosy.getTreatmentStartDate(),
screeningLeprosy.getTreatmentEndDate(),
userId);

if (incentiveActivityRecord != null) {
logger.info("Incentive processed for Screening Leprosy successfully. RecordId={}",
incentiveActivityRecord.getId());
} else {
logger.info("Incentive not created");
}

}
}



}
}

@Override
public List<LeprosyGetFollowUpDTO> getAllLeprosyFollowUpData(String createdBy) {
logger.info("Fetching leprosy data for createdBy: " + createdBy);
Expand Down Expand Up @@ -1394,16 +1306,19 @@ record = new IncentiveActivityRecord();

private void addIncentive(IncentiveActivity diseaseScreeningActivity, ScreeningMalaria diseaseScreening) {
try {
Timestamp screeningTimestamp = diseaseScreening.getScreeningDate() != null
? new Timestamp(diseaseScreening.getScreeningDate().getTime())
: null;
IncentiveActivityRecord record = recordRepo
.findRecordByActivityIdCreatedDateBenId(diseaseScreeningActivity.getId(), Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()), diseaseScreening.getBenId().longValue());
if (record == null) {
record = new IncentiveActivityRecord();
record.setActivityId(diseaseScreeningActivity.getId());
record.setCreatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()));
record.setCreatedDate(screeningTimestamp);
record.setCreatedBy(userService.getUserDetail(diseaseScreening.getUserId()).getUserName());
record.setStartDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()));
record.setEndDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()));
record.setUpdatedDate(Timestamp.valueOf(diseaseScreening.getCreatedDate().toString()));
record.setStartDate(screeningTimestamp);
record.setEndDate(screeningTimestamp);
record.setUpdatedDate(screeningTimestamp);
record.setUpdatedBy(userService.getUserDetail(diseaseScreening.getUserId()).getUserName());
record.setUpdatedBy(userService.getUserDetail(diseaseScreening.getUserId()).getUserName());
record.setBenId(diseaseScreening.getBenId().longValue());
Expand Down Expand Up @@ -1475,8 +1390,9 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,
Integer stateId = userService.getUserDetail(ashaId).getStateId();
IncentiveActivity incentiveActivity = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.NCD.getDisplayName());
IncentiveActivity incentiveActivityCG = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_FOLLOWUP_TREATMENT", GroupName.ACTIVITY.getDisplayName());
IncentiveActivity incentiveActivityCGForNCDnewPatient = incentivesRepo.findIncentiveMasterByNameAndGroup("NCD_NEW_PATIENT_MEDICATION_SUPPORT", GroupName.ACTIVITY.getDisplayName());
logger.info("incentiveActivity:" + incentiveActivity.getId());
if (incentiveActivity != null) {

if (chronicDiseaseVisitEntity.getFollowUpNo() != null
&& chronicDiseaseVisitEntity.getCreatedDate() != null
&& chronicDiseaseVisitEntity.getDiagnosisCodes() != null) {
Expand All @@ -1487,14 +1403,26 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,
"Cancer"
);


List<String> diagnosisList = Arrays.asList(
chronicDiseaseVisitEntity.getDiagnosisCodes().split(",")
);

boolean matchFound = diagnosisList.stream()
.map(String::trim)
.anyMatch(targetDiseases::contains);

if(matchFound & Integer.valueOf(0).equals(chronicDiseaseVisitEntity.getFollowUpNo()) ){
LocalDateTime localDateTime = chronicDiseaseVisitEntity.getTreatmentStartDate().atStartOfDay();

Timestamp treatmentStartDate = Timestamp.valueOf(localDateTime);
addNCDFolloupIncentiveRecord(
incentiveActivityCGForNCDnewPatient,
ashaId,
chronicDiseaseVisitEntity.getBenId(),
treatmentStartDate,
userName
);
}
if (matchFound && Integer.valueOf(6).equals(chronicDiseaseVisitEntity.getFollowUpNo())) {
LocalDateTime localDateTime = chronicDiseaseVisitEntity.getFollowUpDate().atStartOfDay();

Expand All @@ -1520,7 +1448,7 @@ private void checkIncentive(ChronicDiseaseVisitEntity chronicDiseaseVisitEntity,

}
}
}



}
Expand Down
Loading