Skip to content

Commit 7617257

Browse files
dinesh-beehyvKantas2601
authored andcommitted
changes made for lmp and mobile update on same day
1 parent 0f0a619 commit 7617257

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/SubscriberServiceImpl.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,14 @@ public Subscription updateRchMotherSubscriber(Long msisdn, MctsMother motherUpda
433433
motherUpdate.setLastMenstrualPeriod(lmp);
434434
motherUpdate.setUpdatedDateNic(lastUpdatedDateNic);
435435
motherUpdate.setRegistrationDate(motherRegistrationDate);
436-
if(subscription != null){subscriptionService.deleteCallRetry(subscription.getSubscriptionId());}
436+
437+
if(subscription != null){
438+
if ( !((subscriberByRchId.getLastMenstrualPeriod().getDayOfYear() == lmp.getDayOfYear()) && (subscriberByRchId.getLastMenstrualPeriod().getYear() == lmp.getYear()))) {
439+
subscriptionService.deleteCallRetry(subscription.getSubscriptionId());
440+
}else {
441+
subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn);
442+
}
443+
}
437444
return updateOrCreateSubscription(subscriberByRchId, subscription, lmp, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, greaterCase);
438445
} else { // we have a subscriber by phone# and also one with the RCH id
439446
if (subscriptionService.activeSubscriptionByMsisdnRch(subscribersByMsisdn,msisdn, SubscriptionPackType.PREGNANCY, motherUpdate.getRchId(), null)) {
@@ -759,6 +766,14 @@ public ChildImportRejection updateRchChildSubscriber(Long msisdn, MctsChild chil
759766
}
760767
subscriberByRchId.setDateOfBirth(dob);
761768
subscriberByRchId.setModificationDate(DateTime.now());
769+
// Delete that record from retry table as beneficiary gets their mobile number update
770+
if(subscription != null){
771+
if ((subscriberByRchId.getDateOfBirth().getDayOfYear() != dob.getDayOfYear())){
772+
subscriptionService.deleteCallRetry(subscription.getSubscriptionId());
773+
}else {
774+
subscriptionService.updateCallRetry(subscription.getSubscriptionId(), msisdn);
775+
}
776+
}
762777
finalSubscription = updateOrCreateSubscription(subscriberByRchId, subscription, dob, pack, language, circle, SubscriptionOrigin.RCH_IMPORT, false);
763778
} else {
764779
//subscriber found with provided msisdn

0 commit comments

Comments
 (0)