From c40b0032cbd8f9f81cf6c8ae7525bdf9cacb0d15 Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Fri, 17 Jan 2025 14:41:00 +0530 Subject: [PATCH 01/12] MAde changes to prevent duplicate records in obd file if we receive an update from frch for lmp --- .../nms/imi/domain/CallSummaryRecord.java | 3 +- .../nms/kilkari/dto/CallSummaryRecordDto.java | 17 +++++- .../kilkari/service/SubscriptionService.java | 2 + .../kilkari/service/impl/CsrServiceImpl.java | 56 +++++++++++++++++-- .../service/impl/SubscriberServiceImpl.java | 4 +- .../service/impl/SubscriptionServiceImpl.java | 9 +++ .../nms/props/domain/DayOfTheWeek.java | 12 ++++ 7 files changed, 94 insertions(+), 9 deletions(-) diff --git a/imi/src/main/java/org/motechproject/nms/imi/domain/CallSummaryRecord.java b/imi/src/main/java/org/motechproject/nms/imi/domain/CallSummaryRecord.java index 4c64f11eb..99e5a15bf 100644 --- a/imi/src/main/java/org/motechproject/nms/imi/domain/CallSummaryRecord.java +++ b/imi/src/main/java/org/motechproject/nms/imi/domain/CallSummaryRecord.java @@ -203,7 +203,8 @@ public CallSummaryRecordDto toDto() { circle, timestamp, opt_in_call_eligibility, - opt_in_input + opt_in_input, + serviceId ); } } diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/dto/CallSummaryRecordDto.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/dto/CallSummaryRecordDto.java index e612ecdb8..2bc9dd59d 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/dto/CallSummaryRecordDto.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/dto/CallSummaryRecordDto.java @@ -37,6 +37,8 @@ public class CallSummaryRecordDto implements Serializable { private String opt_in_input; + private String serviceId; + public CallSummaryRecordDto() { } //CHECKSTYLE:OFF @@ -53,7 +55,7 @@ public CallSummaryRecordDto(String subscriptionId, int statusCode, int finalStat } public CallSummaryRecordDto(String subscriptionId, int statusCode, int finalStatus, String contentFileName, - String weekId, String languageCode, String circleName, String targetFileTimeStamp, Boolean opt_in_call_eligibility, String opt_in_input) { + String weekId, String languageCode, String circleName, String targetFileTimeStamp, Boolean opt_in_call_eligibility, String opt_in_input,String serviceId) { this.subscriptionId = subscriptionId; this.statusCode = statusCode; this.finalStatus = finalStatus; @@ -64,6 +66,7 @@ public CallSummaryRecordDto(String subscriptionId, int statusCode, int finalStat this.targetFileTimeStamp = targetFileTimeStamp; this.opt_in_call_eligibility = opt_in_call_eligibility; this.opt_in_input = opt_in_input; + this.serviceId = serviceId; } // Helper constructor for ITs @@ -155,6 +158,14 @@ public void setTargetFileTimeStamp(String targetFileTimeStamp) { this.targetFileTimeStamp = targetFileTimeStamp; } + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + @Ignore public static CallSummaryRecordDto fromParams(Map params) { CallSummaryRecordDto csr; @@ -168,7 +179,8 @@ public static CallSummaryRecordDto fromParams(Map params) { (String) params.get("circleName"), (String) params.get("targetFileTimeStamp"), (Boolean) params.get("opt_in_call_eligibility"), - (String) params.get("opt_in_input") + (String) params.get("opt_in_input"), + (String) params.get("serviceId") ); return csr; } @@ -186,6 +198,7 @@ public static Map toParams(CallSummaryRecordDto csr) { params.put("targetFileTimeStamp", csr.targetFileTimeStamp); params.put("opt_in_call_eligibility", csr.opt_in_call_eligibility); params.put("opt_in_input", csr.opt_in_input); + params.put("serviceId", csr.serviceId); return params; } } diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/SubscriptionService.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/SubscriptionService.java index f3a285432..544045bfe 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/SubscriptionService.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/SubscriptionService.java @@ -106,6 +106,8 @@ Subscription createSubscription(Subscriber subscriber, long callingNumber, Langu void deleteCallRetry(String subscriptionId); + void updateCallRetry(String subscriptionId,Long msisdn); + void deleteBlockedMsisdn(Long motherId, Long oldCallingNumber, Long newCallingNumber); /** diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java index 283c0efdf..dc7948009 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java @@ -24,9 +24,11 @@ import org.motechproject.nms.kilkari.service.CsrVerifierService; import org.motechproject.nms.kilkari.service.SubscriptionService; import org.motechproject.nms.kilkari.utils.KilkariConstants; +import org.motechproject.nms.props.domain.DayOfTheWeek; import org.motechproject.nms.props.domain.FinalCallStatus; import org.motechproject.nms.props.domain.StatusCode; import org.motechproject.nms.props.domain.WhatsAppOptInStatusCode; +import org.motechproject.server.config.SettingsFacade; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -145,8 +147,10 @@ private void handleDndForSubscription(Subscription subscription) { private void doReschedule(Subscription subscription, CallRetry existingCallRetry, CallSummaryRecordDto csrDto) { boolean invalidNr = StatusCode.fromInt(csrDto.getStatusCode()).equals(StatusCode.OBD_FAILED_INVALIDNUMBER); - +LOGGER.info("inside doreshedule method"); +LOGGER.info("this is the data inside: {},{},{]",subscription,existingCallRetry, csrDto); if (existingCallRetry == null && SubscriptionStatus.ACTIVE.equals(subscription.getStatus())) { + LOGGER.info("inside condition 1"); // We've never retried this call, let's do it callRetryDataService.create(new CallRetry( subscription.getSubscriptionId(), @@ -167,13 +171,14 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry if ((subscription.getSubscriptionPack().retryCount() == 1) || (existingCallRetry !=null && existingCallRetry.getCallStage() == CallStage.RETRY_LAST)) { - + LOGGER.info("inside condition 2"); // This call should not be retried // Deactivate subscription for persistent invalid numbers // See https://github.com/motech-implementations/mim/issues/169 if (existingCallRetry != null && existingCallRetry.getInvalidNumberCount() != null && existingCallRetry.getInvalidNumberCount() == subscription.getSubscriptionPack().retryCount()) { + LOGGER.info("inside condition 3"); subscription.setStatus(SubscriptionStatus.DEACTIVATED); subscription.setDeactivationReason(DeactivationReason.INVALID_NUMBER); subscriptionDataService.update(subscription); @@ -181,8 +186,10 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry } if (existingCallRetry != null && existingCallRetry.isOpt_in_call_eligibility() && existingCallRetry.getCallStage() == CallStage.RETRY_LAST && existingCallRetry.getWeekId().equals("w1_1")) { + LOGGER.info("inside condition 4"); boolean optInCall = existingCallRetry.getContentFileName().equals("opt_in.wav"); if(!optInCall) { + LOGGER.info("inside condition 5"); /*callRetryDataService.delete(existingCallRetry); callRetryDataService.create(new CallRetry( subscription.getSubscriptionId(), @@ -201,6 +208,7 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry existingCallRetry.setContentFileName("opt_in.wav"); callRetryDataService.update(existingCallRetry); } else { + LOGGER.info("inside condition 6"); completeSubscriptionIfNeeded(subscription, csrDto.getContentFileName()); callRetryDataService.delete(existingCallRetry); LOGGER.info("subscription is : {}", subscription); @@ -222,6 +230,7 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry return; } if (existingCallRetry != null) { + LOGGER.info("inside condition 7"); callRetryDataService.delete(existingCallRetry); } @@ -234,6 +243,7 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry // This call should indeed be re-rescheduled if (existingCallRetry != null) { + LOGGER.info("inside condition 8"); existingCallRetry.setCallStage(existingCallRetry.getCallStage().nextStage()); existingCallRetry.setInvalidNumberCount(existingCallRetry.getInvalidNumberCount() == null ? 0 : (existingCallRetry.getInvalidNumberCount() + (invalidNr ? 1 : 0))); @@ -290,13 +300,16 @@ private void doRescheduleOptIn(Subscription subscription,CallSummaryRecordDto ca @Transactional public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCount + LOGGER.info("inside process call summary record"); Timer timer = new Timer(); String whatHappened = "##"; String subscriptionId = "###INVALID###"; try { CallSummaryRecordDto csrDto = CallSummaryRecordDto.fromParams(event.getParameters()); + LOGGER.info("this is csr dto : {}",csrDto); subscriptionId = csrDto.getSubscriptionId(); + LOGGER.info("this is the subscriptionId: {}",subscriptionId); csrVerifierService.verify(csrDto); Subscription subscription = subscriptionDataService.findBySubscriptionId(subscriptionId); @@ -305,10 +318,13 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun } CallRetry callRetry = callRetryDataService.findBySubscriptionId(subscriptionId); + LOGGER.info("this is call retry: {}",callRetry); + LOGGER.info("this is the final status: {}",FinalCallStatus.fromInt(csrDto.getFinalStatus())); switch (FinalCallStatus.fromInt(csrDto.getFinalStatus())) { case SUCCESS: completeSubscriptionIfNeeded(subscription, csrDto.getContentFileName()); if (callRetry != null) { + if (!callRetry.getContentFileName().equals("opt_in.wav")) { callRetryDataService.delete(callRetry); } @@ -325,13 +341,31 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun //If there was a DOB/LMP update during RCH import, number of weeks into subscription would have changed. //No need to reschedule this call. Exception for w1, because regardless of which week the subscription starts in, user //always gets w1 message initially + LOGGER.info("this is the data: {},{}",csrDto.getWeekId(),weekId); + + + + + LOGGER.info("this is data in db for week: {}",subscription.getFirstMessageDayOfWeek()); + LOGGER.info("this is data in csrdto: {}",DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())); + LOGGER.info("this is the condition1: {}",!subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp()))); + LOGGER.info("this is condition 2: {}", "1".equals(extractRouteNumber(csrDto.getServiceId()))); + LOGGER.info("this is condition 2 and return : {}",extractRouteNumber(csrDto.getServiceId())); + LOGGER.info("this is service id: {}",csrDto.getServiceId()); if(!csrDto.getWeekId().equals("w1_1")&&!weekId.equals(csrDto.getWeekId())){ if(callRetry!=null){ + LOGGER.info("inside call retry condition"); callRetryDataService.delete(callRetry); } - } else { + }else if(callRetry == null && !subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())) && "1".equals(extractRouteNumber(csrDto.getServiceId()))) { + LOGGER.info("inside fresh call condition after rch update"); + }else if(callRetry == null && "2".equals(extractRouteNumber(csrDto.getServiceId()))){ + LOGGER.info("inside retry call condition after rch update"); + }else { + LOGGER.info("this is the data2: {}",csrDto.getTargetFileTimeStamp()); if (callRetry == null || - !csrDto.getTargetFileTimeStamp().equals(callRetry.getTargetFiletimestamp())) { + !csrDto.getTargetFileTimeStamp().equals(callRetry.getTargetFiletimestamp())){ + LOGGER.info("inside fresh or retryupdate else condition"); doReschedule(subscription, callRetry, csrDto); } } @@ -339,11 +373,13 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun break; case REJECTED: + LOGGER.info("inside rejected"); handleDndForSubscription(subscription); whatHappened = "RE"; break; default: + LOGGER.info("inside default"); String error = String.format("Invalid FinalCallStatus: %s", csrDto.getFinalStatus()); LOGGER.error(error); alertService.create(subscriptionId, KilkariConstants.NMS_IMI_KK_PROCESS_CSR_SUBJECT, error, AlertType.CRITICAL, @@ -372,6 +408,18 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun LOGGER.debug(String.format("processCallSummaryRecord %s %s %s", subscriptionId, whatHappened, timer.time())); } + private String extractRouteNumber(String serviceId) { + if (serviceId != null && serviceId.contains("Retryonroute")) { + LOGGER.info("inside this1"); + int startIndex = serviceId.indexOf("Retryonroute") + "Retryonroute".length(); + if (startIndex < serviceId.length()) { + LOGGER.info("inside this2"); + return String.valueOf(serviceId.charAt(startIndex)); + } + } + return ""; + } + @MotechListener(subjects = {KilkariConstants.NMS_IMI_KK_WHATSAPP_SMS_PROCESS_CSR_SUBJECT}) //NO CHECKSTYLE Cyclomatic Complexity @Transactional public void processWhatsAppSMSCsr(MotechEvent event) { //NOPMD NcssMethodCount diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index c630d6a68..7f8cc2644 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -414,7 +414,7 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda motherUpdate.setLastMenstrualPeriod(lmp); motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); motherUpdate.setRegistrationDate(motherRegistrationDate); - if(subscription != null){subscriptionService.deleteCallRetry(subscription.getSubscriptionId());} + if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { @@ -732,7 +732,7 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil subscriberByRchId.setDateOfBirth(dob); subscriberByRchId.setModificationDate(DateTime.now()); // Delete that record from retry table as beneficiary gets their mobile number update - if(subscription != null){subscriptionService.deleteCallRetry(subscription.getSubscriptionId());} + if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false); } else { //subscriber found with provided msisdn diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriptionServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriptionServiceImpl.java index 67045b5bb..909175509 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriptionServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriptionServiceImpl.java @@ -944,6 +944,15 @@ public void deleteCallRetry(String subscriptionId) { } } + @Override + public void updateCallRetry(String subscriptionId,Long msisdn) { + CallRetry callRetry = callRetryDataService.findBySubscriptionId(subscriptionId); + if (callRetry != null) { + callRetry.setMsisdn(msisdn); + callRetryDataService.update(callRetry); + } + } + @Override public void deactivateSubscription(Subscription subscription, DeactivationReason reason) { if (subscription != null && (subscription.getStatus() == SubscriptionStatus.ACTIVE || diff --git a/props/src/main/java/org/motechproject/nms/props/domain/DayOfTheWeek.java b/props/src/main/java/org/motechproject/nms/props/domain/DayOfTheWeek.java index 7286386c7..08a9051b6 100644 --- a/props/src/main/java/org/motechproject/nms/props/domain/DayOfTheWeek.java +++ b/props/src/main/java/org/motechproject/nms/props/domain/DayOfTheWeek.java @@ -1,6 +1,8 @@ package org.motechproject.nms.props.domain; import org.joda.time.DateTime; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; public enum DayOfTheWeek { MONDAY(1), @@ -38,6 +40,16 @@ public static DayOfTheWeek fromDateTime(DateTime dt) { return fromInt(dt.getDayOfWeek()); } + public static DayOfTheWeek getDayOfTheWeekFromTimestamp(String timestamp) { + DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyyMMddHHmmss"); + + DateTime dateTime = formatter.parseDateTime(timestamp); + + int dayOfWeek = dateTime.getDayOfWeek(); // 1 = Monday, 7 = Sunday + + return DayOfTheWeek.fromInt(dayOfWeek); + } + public DayOfTheWeek nextDay() { if (value == SUNDAY.getValue()) { return MONDAY; From 0342d2bb8f1e8e955cb6fe77ed23fa04630fc836 Mon Sep 17 00:00:00 2001 From: Kantas2601 Date: Mon, 20 Jan 2025 11:56:15 +0530 Subject: [PATCH 02/12] Updating Modification Date for deactivated and completed record --- .../nms/kilkari/service/impl/SubscriberServiceImpl.java | 1 + 1 file changed, 1 insertion(+) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index 7f8cc2644..9857b1075 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -1023,6 +1023,7 @@ public Subscription updateOrCreateSubscription(Subscriber subscriber, Subscripti return deactivatedSubscripion; } } else if (subscription != null && !subscription.getDeactivationReason().equals(DeactivationReason.INVALID_NUMBER)){ + subscription.setModificationDate(DateTime.now()); return subscription; } else { return subscriptionService.createSubscription(subscriber, subscriber.getCallingNumber(), language, circle, pack, origin); From 351bd1fffb21a856918b937ec85681f9c4acef54 Mon Sep 17 00:00:00 2001 From: Kantas2601 Date: Mon, 20 Jan 2025 12:29:38 +0530 Subject: [PATCH 03/12] Updating Modification Date for deactivated and completed record --- .../nms/kilkari/service/impl/SubscriberServiceImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index 9857b1075..fd6dbf985 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -1023,6 +1023,10 @@ public Subscription updateOrCreateSubscription(Subscriber subscriber, Subscripti return deactivatedSubscripion; } } else if (subscription != null && !subscription.getDeactivationReason().equals(DeactivationReason.INVALID_NUMBER)){ + Set activeSubscriptions = subscriber.getActiveAndPendingSubscriptions(); + if (activeSubscriptions != null && !activeSubscriptions.isEmpty()) { + activeSubscriptions.forEach(sub -> sub.setModificationDate(DateTime.now())); + } subscription.setModificationDate(DateTime.now()); return subscription; } else { From 9223cc94ae51c25726929043bd1a200bd1e3ff2f Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Mon, 20 Jan 2025 14:18:18 +0530 Subject: [PATCH 04/12] changes according to java 7 --- .../nms/kilkari/service/impl/SubscriberServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index fd6dbf985..e55f79a9f 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -1025,7 +1025,9 @@ public Subscription updateOrCreateSubscription(Subscriber subscriber, Subscripti } else if (subscription != null && !subscription.getDeactivationReason().equals(DeactivationReason.INVALID_NUMBER)){ Set activeSubscriptions = subscriber.getActiveAndPendingSubscriptions(); if (activeSubscriptions != null && !activeSubscriptions.isEmpty()) { - activeSubscriptions.forEach(sub -> sub.setModificationDate(DateTime.now())); + for(Subscription sub : activeSubscriptions ){ + sub.setModificationDate(DateTime.now()); + } } subscription.setModificationDate(DateTime.now()); return subscription; From f175bfdbe1de9ee18f3147e514bec2c0068f9df5 Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Mon, 20 Jan 2025 17:59:44 +0530 Subject: [PATCH 05/12] changes made for lmp and mobile update on same day --- .../service/impl/SubscriberServiceImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index e55f79a9f..e50c3152c 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -414,7 +414,14 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda motherUpdate.setLastMenstrualPeriod(lmp); motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); motherUpdate.setRegistrationDate(motherRegistrationDate); - if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} + + if(subscription != null){ + if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { + subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); + }else { + subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); + } + } return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { @@ -732,7 +739,13 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil subscriberByRchId.setDateOfBirth(dob); subscriberByRchId.setModificationDate(DateTime.now()); // Delete that record from retry table as beneficiary gets their mobile number update - if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} + if(subscription != null){ + if ((subscriberByRchId.getDateOfBirth().getDayOfYear() != dob.getDayOfYear())){ + subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); + }else { + subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); + } + } finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false); } else { //subscriber found with provided msisdn From 2a2accfbc2f435cb3e6d532cccd4526abffaf077 Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Tue, 21 Jan 2025 13:34:10 +0530 Subject: [PATCH 06/12] changes made for lmp and mobile update on same day --- .../service/impl/SubscriberServiceImpl.java | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index e50c3152c..a8e136fe9 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -407,21 +407,32 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda subscriberByRchId.setCaseNo(caseNo); motherUpdate.setMaxCaseNo(caseNo); } - subscriberByRchId.setLastMenstrualPeriod(lmp); - subscriberByRchId.setModificationDate(DateTime.now()); - motherUpdate.setName(name); - motherUpdate.setDateOfBirth(motherDOB); - motherUpdate.setLastMenstrualPeriod(lmp); - motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); - motherUpdate.setRegistrationDate(motherRegistrationDate); + if(subscription != null){ + LOGGER.info("we are inside not null condition"); + LOGGER.info("1st value: {}",subscriberByRchId.getLastMenstrualPeriod().getDayOfYear()); + LOGGER.info("second value: {}",lmp.getDayOfYear()); + LOGGER.info("third value: {}",subscriberByRchId.getLastMenstrualPeriod().getYear()); + LOGGER.info("second value: {}",lmp.getYear()); + LOGGER.info("this is the first case: {}",(subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear())); + LOGGER.info("this is the second case2: {}",(subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear())); if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { + LOGGER.info("inside delete condition"); subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); + }else { + LOGGER.info("we are inside else null condition"); subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); } } + subscriberByRchId.setLastMenstrualPeriod(lmp); + subscriberByRchId.setModificationDate(DateTime.now()); + motherUpdate.setName(name); + motherUpdate.setDateOfBirth(motherDOB); + motherUpdate.setLastMenstrualPeriod(lmp); + motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); + motherUpdate.setRegistrationDate(motherRegistrationDate); return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { @@ -736,8 +747,7 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil subscription = latestDeactivatedSubscription; } } - subscriberByRchId.setDateOfBirth(dob); - subscriberByRchId.setModificationDate(DateTime.now()); + // Delete that record from retry table as beneficiary gets their mobile number update if(subscription != null){ if ((subscriberByRchId.getDateOfBirth().getDayOfYear() != dob.getDayOfYear())){ @@ -746,6 +756,8 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); } } + subscriberByRchId.setDateOfBirth(dob); + subscriberByRchId.setModificationDate(DateTime.now()); finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false); } else { //subscriber found with provided msisdn From d3dd66c55fe19c499f8f2e0294aceb47e332bb9c Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Wed, 22 Jan 2025 17:33:08 +0530 Subject: [PATCH 07/12] updated condition for week 1 --- .../nms/kilkari/service/impl/CsrServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java index dc7948009..c76b50857 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java @@ -357,9 +357,9 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun LOGGER.info("inside call retry condition"); callRetryDataService.delete(callRetry); } - }else if(callRetry == null && !subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())) && "1".equals(extractRouteNumber(csrDto.getServiceId()))) { + }else if(callRetry == null && !csrDto.getWeekId().equals("w1_1") && !subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())) && "1".equals(extractRouteNumber(csrDto.getServiceId()))) { LOGGER.info("inside fresh call condition after rch update"); - }else if(callRetry == null && "2".equals(extractRouteNumber(csrDto.getServiceId()))){ + }else if(callRetry == null && !csrDto.getWeekId().equals("w1_1") && "2".equals(extractRouteNumber(csrDto.getServiceId()))){ LOGGER.info("inside retry call condition after rch update"); }else { LOGGER.info("this is the data2: {}",csrDto.getTargetFileTimeStamp()); From a26d229ef97b1a3c11ae5ed18edd6b9efe4e1d6b Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Fri, 17 Jan 2025 14:41:00 +0530 Subject: [PATCH 08/12] MAde changes to prevent duplicate records in obd file if we receive an update from frch for lmp --- .../nms/kilkari/service/impl/SubscriberServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index a8e136fe9..aec08f48c 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -433,6 +433,7 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda motherUpdate.setLastMenstrualPeriod(lmp); motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); motherUpdate.setRegistrationDate(motherRegistrationDate); + if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { @@ -758,6 +759,8 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil } subscriberByRchId.setDateOfBirth(dob); subscriberByRchId.setModificationDate(DateTime.now()); + // Delete that record from retry table as beneficiary gets their mobile number update + if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false); } else { //subscriber found with provided msisdn From 1003bb3317f32bfda14598aa4e970bf742911c56 Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Mon, 20 Jan 2025 17:59:44 +0530 Subject: [PATCH 09/12] changes made for lmp and mobile update on same day --- .../service/impl/SubscriberServiceImpl.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index aec08f48c..da012abe8 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -433,7 +433,14 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda motherUpdate.setLastMenstrualPeriod(lmp); motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); motherUpdate.setRegistrationDate(motherRegistrationDate); - if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} + + if(subscription != null){ + if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { + subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); + }else { + subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); + } + } return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { @@ -760,7 +767,13 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil subscriberByRchId.setDateOfBirth(dob); subscriberByRchId.setModificationDate(DateTime.now()); // Delete that record from retry table as beneficiary gets their mobile number update - if(subscription != null){subscriptionService.updateCallRetry(subscription.getSubscriptionId(),msisdn);} + if(subscription != null){ + if ((subscriberByRchId.getDateOfBirth().getDayOfYear() != dob.getDayOfYear())){ + subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); + }else { + subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); + } + } finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false); } else { //subscriber found with provided msisdn From 880faefb65e32f6bd2d093eef5eebb3dc27cdcb7 Mon Sep 17 00:00:00 2001 From: "dinesh.c" Date: Tue, 21 Jan 2025 13:34:10 +0530 Subject: [PATCH 10/12] changes made for lmp and mobile update on same day --- .../nms/kilkari/service/impl/SubscriberServiceImpl.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index da012abe8..516aad9f4 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -433,14 +433,6 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda motherUpdate.setLastMenstrualPeriod(lmp); motherUpdate.setUpdatedDateNic(lastUpdatedDateNic); motherUpdate.setRegistrationDate(motherRegistrationDate); - - if(subscription != null){ - if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { - subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); - }else { - subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); - } - } return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase); } else { // we have a subscriber by phone# and also one with the RCH id if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) { From 5d21f8c5e65d33a1fcce361a256c998e458b64f9 Mon Sep 17 00:00:00 2001 From: Kantas2601 Date: Fri, 27 Jun 2025 16:05:07 +0530 Subject: [PATCH 11/12] Removing reduntant loggers --- .../kilkari/service/impl/CsrServiceImpl.java | 32 ------------------- .../service/impl/SubscriberServiceImpl.java | 7 ---- 2 files changed, 39 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java index c76b50857..a421e1bd8 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java @@ -147,8 +147,6 @@ private void handleDndForSubscription(Subscription subscription) { private void doReschedule(Subscription subscription, CallRetry existingCallRetry, CallSummaryRecordDto csrDto) { boolean invalidNr = StatusCode.fromInt(csrDto.getStatusCode()).equals(StatusCode.OBD_FAILED_INVALIDNUMBER); -LOGGER.info("inside doreshedule method"); -LOGGER.info("this is the data inside: {},{},{]",subscription,existingCallRetry, csrDto); if (existingCallRetry == null && SubscriptionStatus.ACTIVE.equals(subscription.getStatus())) { LOGGER.info("inside condition 1"); // We've never retried this call, let's do it @@ -171,14 +169,12 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry if ((subscription.getSubscriptionPack().retryCount() == 1) || (existingCallRetry !=null && existingCallRetry.getCallStage() == CallStage.RETRY_LAST)) { - LOGGER.info("inside condition 2"); // This call should not be retried // Deactivate subscription for persistent invalid numbers // See https://github.com/motech-implementations/mim/issues/169 if (existingCallRetry != null && existingCallRetry.getInvalidNumberCount() != null && existingCallRetry.getInvalidNumberCount() == subscription.getSubscriptionPack().retryCount()) { - LOGGER.info("inside condition 3"); subscription.setStatus(SubscriptionStatus.DEACTIVATED); subscription.setDeactivationReason(DeactivationReason.INVALID_NUMBER); subscriptionDataService.update(subscription); @@ -186,10 +182,8 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry } if (existingCallRetry != null && existingCallRetry.isOpt_in_call_eligibility() && existingCallRetry.getCallStage() == CallStage.RETRY_LAST && existingCallRetry.getWeekId().equals("w1_1")) { - LOGGER.info("inside condition 4"); boolean optInCall = existingCallRetry.getContentFileName().equals("opt_in.wav"); if(!optInCall) { - LOGGER.info("inside condition 5"); /*callRetryDataService.delete(existingCallRetry); callRetryDataService.create(new CallRetry( subscription.getSubscriptionId(), @@ -208,12 +202,8 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry existingCallRetry.setContentFileName("opt_in.wav"); callRetryDataService.update(existingCallRetry); } else { - LOGGER.info("inside condition 6"); completeSubscriptionIfNeeded(subscription, csrDto.getContentFileName()); callRetryDataService.delete(existingCallRetry); - LOGGER.info("subscription is : {}", subscription); - LOGGER.info("csrDto is : {}", csrDto); - LOGGER.info("whatsAppOptSMSDataService is : {}", whatsAppOptSMSDataService); // write message table logic here whatsAppOptSMSDataService.create(new WhatsAppOptSMS(csrDto.getCircleName(), "SMS_CONTENT", @@ -230,7 +220,6 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry return; } if (existingCallRetry != null) { - LOGGER.info("inside condition 7"); callRetryDataService.delete(existingCallRetry); } @@ -243,7 +232,6 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry // This call should indeed be re-rescheduled if (existingCallRetry != null) { - LOGGER.info("inside condition 8"); existingCallRetry.setCallStage(existingCallRetry.getCallStage().nextStage()); existingCallRetry.setInvalidNumberCount(existingCallRetry.getInvalidNumberCount() == null ? 0 : (existingCallRetry.getInvalidNumberCount() + (invalidNr ? 1 : 0))); @@ -307,9 +295,7 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun String subscriptionId = "###INVALID###"; try { CallSummaryRecordDto csrDto = CallSummaryRecordDto.fromParams(event.getParameters()); - LOGGER.info("this is csr dto : {}",csrDto); subscriptionId = csrDto.getSubscriptionId(); - LOGGER.info("this is the subscriptionId: {}",subscriptionId); csrVerifierService.verify(csrDto); Subscription subscription = subscriptionDataService.findBySubscriptionId(subscriptionId); @@ -318,13 +304,10 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun } CallRetry callRetry = callRetryDataService.findBySubscriptionId(subscriptionId); - LOGGER.info("this is call retry: {}",callRetry); - LOGGER.info("this is the final status: {}",FinalCallStatus.fromInt(csrDto.getFinalStatus())); switch (FinalCallStatus.fromInt(csrDto.getFinalStatus())) { case SUCCESS: completeSubscriptionIfNeeded(subscription, csrDto.getContentFileName()); if (callRetry != null) { - if (!callRetry.getContentFileName().equals("opt_in.wav")) { callRetryDataService.delete(callRetry); } @@ -341,20 +324,8 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun //If there was a DOB/LMP update during RCH import, number of weeks into subscription would have changed. //No need to reschedule this call. Exception for w1, because regardless of which week the subscription starts in, user //always gets w1 message initially - LOGGER.info("this is the data: {},{}",csrDto.getWeekId(),weekId); - - - - - LOGGER.info("this is data in db for week: {}",subscription.getFirstMessageDayOfWeek()); - LOGGER.info("this is data in csrdto: {}",DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())); - LOGGER.info("this is the condition1: {}",!subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp()))); - LOGGER.info("this is condition 2: {}", "1".equals(extractRouteNumber(csrDto.getServiceId()))); - LOGGER.info("this is condition 2 and return : {}",extractRouteNumber(csrDto.getServiceId())); - LOGGER.info("this is service id: {}",csrDto.getServiceId()); if(!csrDto.getWeekId().equals("w1_1")&&!weekId.equals(csrDto.getWeekId())){ if(callRetry!=null){ - LOGGER.info("inside call retry condition"); callRetryDataService.delete(callRetry); } }else if(callRetry == null && !csrDto.getWeekId().equals("w1_1") && !subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())) && "1".equals(extractRouteNumber(csrDto.getServiceId()))) { @@ -365,7 +336,6 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun LOGGER.info("this is the data2: {}",csrDto.getTargetFileTimeStamp()); if (callRetry == null || !csrDto.getTargetFileTimeStamp().equals(callRetry.getTargetFiletimestamp())){ - LOGGER.info("inside fresh or retryupdate else condition"); doReschedule(subscription, callRetry, csrDto); } } @@ -410,10 +380,8 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun private String extractRouteNumber(String serviceId) { if (serviceId != null && serviceId.contains("Retryonroute")) { - LOGGER.info("inside this1"); int startIndex = serviceId.indexOf("Retryonroute") + "Retryonroute".length(); if (startIndex < serviceId.length()) { - LOGGER.info("inside this2"); return String.valueOf(serviceId.charAt(startIndex)); } } diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index 516aad9f4..d746a3999 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -410,13 +410,6 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda if(subscription != null){ - LOGGER.info("we are inside not null condition"); - LOGGER.info("1st value: {}",subscriberByRchId.getLastMenstrualPeriod().getDayOfYear()); - LOGGER.info("second value: {}",lmp.getDayOfYear()); - LOGGER.info("third value: {}",subscriberByRchId.getLastMenstrualPeriod().getYear()); - LOGGER.info("second value: {}",lmp.getYear()); - LOGGER.info("this is the first case: {}",(subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear())); - LOGGER.info("this is the second case2: {}",(subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear())); if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { LOGGER.info("inside delete condition"); subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); From f5c16c15c060e5a2a9f7ef0ae04f95fd4efd45d0 Mon Sep 17 00:00:00 2001 From: Kantas2601 Date: Fri, 27 Jun 2025 18:26:57 +0530 Subject: [PATCH 12/12] Removing reduntant loggers --- .../kilkari/service/impl/CsrServiceImpl.java | 23 ++++++++----------- .../service/impl/SubscriberServiceImpl.java | 2 -- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java index a421e1bd8..b5554aebb 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/CsrServiceImpl.java @@ -36,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Objects; import static java.lang.Math.min; @@ -148,7 +149,6 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry boolean invalidNr = StatusCode.fromInt(csrDto.getStatusCode()).equals(StatusCode.OBD_FAILED_INVALIDNUMBER); if (existingCallRetry == null && SubscriptionStatus.ACTIVE.equals(subscription.getStatus())) { - LOGGER.info("inside condition 1"); // We've never retried this call, let's do it callRetryDataService.create(new CallRetry( subscription.getSubscriptionId(), @@ -200,6 +200,9 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry ) );*/ existingCallRetry.setContentFileName("opt_in.wav"); + if(!Objects.equals(existingCallRetry.getMsisdn(), subscription.getSubscriber().getCallingNumber())){ + existingCallRetry.setMsisdn(subscription.getSubscriber().getCallingNumber()); + } callRetryDataService.update(existingCallRetry); } else { completeSubscriptionIfNeeded(subscription, csrDto.getContentFileName()); @@ -235,6 +238,9 @@ private void doReschedule(Subscription subscription, CallRetry existingCallRetry existingCallRetry.setCallStage(existingCallRetry.getCallStage().nextStage()); existingCallRetry.setInvalidNumberCount(existingCallRetry.getInvalidNumberCount() == null ? 0 : (existingCallRetry.getInvalidNumberCount() + (invalidNr ? 1 : 0))); + if(!Objects.equals(existingCallRetry.getMsisdn(), subscription.getSubscriber().getCallingNumber())){ + existingCallRetry.setMsisdn(subscription.getSubscriber().getCallingNumber()); + } callRetryDataService.update(existingCallRetry); } @@ -287,8 +293,6 @@ private void doRescheduleOptIn(Subscription subscription,CallSummaryRecordDto ca @MotechListener(subjects = {KilkariConstants.NMS_IMI_KK_PROCESS_CSR_SUBJECT}) //NO CHECKSTYLE Cyclomatic Complexity @Transactional public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCount - - LOGGER.info("inside process call summary record"); Timer timer = new Timer(); String whatHappened = "##"; @@ -329,11 +333,10 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun callRetryDataService.delete(callRetry); } }else if(callRetry == null && !csrDto.getWeekId().equals("w1_1") && !subscription.getFirstMessageDayOfWeek().equals(DayOfTheWeek.getDayOfTheWeekFromTimestamp(csrDto.getTargetFileTimeStamp())) && "1".equals(extractRouteNumber(csrDto.getServiceId()))) { - LOGGER.info("inside fresh call condition after rch update"); + LOGGER.info("Fresh call condition after rch update"); }else if(callRetry == null && !csrDto.getWeekId().equals("w1_1") && "2".equals(extractRouteNumber(csrDto.getServiceId()))){ - LOGGER.info("inside retry call condition after rch update"); + LOGGER.info("Retry call condition after rch update"); }else { - LOGGER.info("this is the data2: {}",csrDto.getTargetFileTimeStamp()); if (callRetry == null || !csrDto.getTargetFileTimeStamp().equals(callRetry.getTargetFiletimestamp())){ doReschedule(subscription, callRetry, csrDto); @@ -343,13 +346,11 @@ public void processCallSummaryRecord(MotechEvent event) { //NOPMD NcssMethodCoun break; case REJECTED: - LOGGER.info("inside rejected"); handleDndForSubscription(subscription); whatHappened = "RE"; break; default: - LOGGER.info("inside default"); String error = String.format("Invalid FinalCallStatus: %s", csrDto.getFinalStatus()); LOGGER.error(error); alertService.create(subscriptionId, KilkariConstants.NMS_IMI_KK_PROCESS_CSR_SUBJECT, error, AlertType.CRITICAL, @@ -397,16 +398,13 @@ public void processWhatsAppSMSCsr(MotechEvent event) { //NOPMD NcssMethodCount String subscriptionId = "###INVALID###"; try { - LOGGER.debug("test 20 - WhatsAppOptSMSCsrDto.fromParams"); WhatsAppOptSMSCsrDto csrDto = WhatsAppOptSMSCsrDto.fromParams(event.getParameters()); subscriptionId = csrDto.getRequestId(); // csrVerifierService.verify(csrDto); - LOGGER.debug("test 21 - subscriptionDataService.findBySubscriptionIdAndStatus"); Subscription subscription = subscriptionDataService.findBySubscriptionIdAndStatus(subscriptionId, SubscriptionStatus.ACTIVE); if (subscription == null) { throw new NoSuchSubscriptionException(subscriptionId); } - LOGGER.debug("test 22 - updateSubscriptionServiceStatusForWhatsAppSMS"); updateSubscriptionServiceStatusForWhatsAppSMS(subscription, csrDto.getResponse(), (List) event.getParameters().get("subscriptions")); } catch (NoSuchSubscriptionException e) { @@ -435,18 +433,15 @@ public void processWhatsAppCsr(MotechEvent event) { //NOPMD NcssMethodCount String subscriptionId = "###INVALID###"; try { - LOGGER.debug("test 20 - WhatsAppOptCsrDto.fromParams"); WhatsAppOptCsrDto csrDto = WhatsAppOptCsrDto.fromParams(event.getParameters()); LOGGER.debug("csrDto: {}", csrDto); subscriptionId = csrDto.getExternalId(); // csrVerifierService.verify(csrDto); - LOGGER.debug("test 21 - subscriptionDataService.findBySubscriptionIdAndStatus"); Subscription subscription = subscriptionDataService.findBySubscriptionIdAndStatus(subscriptionId, SubscriptionStatus.ACTIVE); LOGGER.debug("subscription: {}", subscription); if (subscription == null) { throw new NoSuchSubscriptionException(subscriptionId); } - LOGGER.debug("test 22 - updateSubscriptionServiceStatusForWhatsApp"); updateSubscriptionServiceStatusForWhatsApp(subscription, csrDto.getMessageStatus(), (List) event.getParameters().get("subscriptions")); LOGGER.debug("subscription: {}", subscription); } catch (NoSuchSubscriptionException e) { diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java index d746a3999..e0b7f58dd 100644 --- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java +++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java @@ -411,11 +411,9 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda if(subscription != null){ if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) { - LOGGER.info("inside delete condition"); subscriptionService.deleteCallRetry(subscription.getSubscriptionId()); }else { - LOGGER.info("we are inside else null condition"); subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn); } }