Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void importRchFrontLineWorker(Map<String, Object> record, State state) th
}
} else {
FrontLineWorker frontLineWorker = frontLineWorkerService.getByContactNumber(msisdn);
if (frontLineWorker != null && frontLineWorker.getStatus().equals(FrontLineWorkerStatus.ACTIVE)) {
if (frontLineWorker != null && FrontLineWorkerStatus.ACTIVE.equals(frontLineWorker.getStatus())) {
// check if anonymous FLW
if (frontLineWorker.getMctsFlwId() == null) {
FrontLineWorker flwInstance = updateFlw(frontLineWorker, record, location, SubscriptionOrigin.RCH_IMPORT);
Expand All @@ -227,7 +227,7 @@ public void importRchFrontLineWorker(Map<String, Object> record, State state) th
flwErrorDataService.create(new FlwError(flwId, (long) record.get(FlwConstants.STATE_ID), (long) record.get(FlwConstants.DISTRICT_ID), FlwErrorReason.PHONE_NUMBER_IN_USE));
throw new FlwExistingRecordException("Msisdn already in use.");
}
} else if (frontLineWorker != null && frontLineWorker.getStatus().equals(FrontLineWorkerStatus.ANONYMOUS)) {
} else if (frontLineWorker != null && FrontLineWorkerStatus.ANONYMOUS.equals(frontLineWorker.getStatus())) {
FrontLineWorker flwInstance = updateFlw(frontLineWorker, record, location, SubscriptionOrigin.RCH_IMPORT);
frontLineWorkerService.update(flwInstance);
} else {
Expand Down Expand Up @@ -293,7 +293,7 @@ public boolean createUpdate(Map<String, Object> flw, SubscriptionOrigin importOr
return true;
} else if ((!existingFlwByFlwId.getMctsFlwId().equalsIgnoreCase(existingFlwByNumber.getMctsFlwId()) ||
!existingFlwByFlwId.getState().equals(existingFlwByNumber.getState())) &&
existingFlwByNumber.getJobStatus().equals(FlwJobStatus.INACTIVE)) {
FlwJobStatus.INACTIVE.equals(existingFlwByNumber.getJobStatus())) {
LOGGER.debug("Updating existing user with same phone number");
frontLineWorkerService.update(FlwMapper.updateFlw(existingFlwByFlwId, flw, location, SubscriptionOrigin.MCTS_IMPORT));
flwRejectionService.createUpdate(RejectedObjectConverter.flwRejectionMcts(convertMapToAsha(flw), true, null, action));
Expand Down Expand Up @@ -368,7 +368,7 @@ public boolean createUpdate(Map<String, Object> flw, SubscriptionOrigin importOr
return true;
} else if ((!existingFlwByFlwId.getMctsFlwId().equalsIgnoreCase(existingFlwByNumber.getMctsFlwId()) ||
!existingFlwByFlwId.getState().equals(existingFlwByNumber.getState())) &&
existingFlwByNumber.getJobStatus().equals(FlwJobStatus.INACTIVE)) {
FlwJobStatus.INACTIVE.equals(existingFlwByNumber.getJobStatus())) {
LOGGER.debug("Updating existing user with same phone number");
frontLineWorkerService.update(FlwMapper.updateFlw(existingFlwByFlwId, flw, location, SubscriptionOrigin.RCH_IMPORT));
flwRejectionService.createUpdate(RejectedObjectConverter.flwRejectionRch(convertMapToRchAsha(flw), true, null, action));
Expand Down Expand Up @@ -399,7 +399,7 @@ public boolean createUpdate(Map<String, Object> flw, SubscriptionOrigin importOr
frontLineWorkerService.update(FlwMapper.updateFlw(existingFlwByNumber, flw, location, SubscriptionOrigin.RCH_IMPORT));
flwRejectionService.createUpdate(RejectedObjectConverter.flwRejectionRch(convertMapToRchAsha(flw), true, null, action));
return true;
} else if (existingFlwByNumber.getJobStatus().equals(FlwJobStatus.INACTIVE)) {
} else if (FlwJobStatus.INACTIVE.equals(existingFlwByNumber.getJobStatus())) {
LOGGER.debug("Adding new RCH flw user");
FrontLineWorker frontLineWorker = FlwMapper.createRchFlw(flw, location);
if (frontLineWorker != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public MotherImportRejection importMotherRecord(Map<String, Object> record, Subs
return createUpdateMotherRejections(flagForMcts, record, action, RejectionReasons.DATA_INTEGRITY_ERROR, false);
}

boolean isInvalidLMP = (mother.getId() == null || (mother.getId() != null && mother.getLastMenstrualPeriod() == null)) && !validateReferenceDate(lmp, SubscriptionPackType.PREGNANCY, msisdn, beneficiaryId, importOrigin);
boolean isInvalidLMP = !validateReferenceDate(lmp, SubscriptionPackType.PREGNANCY, msisdn, beneficiaryId, importOrigin);

if (isInvalidLMP) {
return createUpdateMotherRejections(flagForMcts, record, action, RejectionReasons.INVALID_LMP_DATE, false);
Expand Down Expand Up @@ -338,7 +338,7 @@ public ChildImportRejection importChildRecord(Map<String, Object> record, Subscr
return createUpdateChildRejections(flagForMcts, record, action, RejectionReasons.DATA_INTEGRITY_ERROR, false);
}

boolean isInValidDOB = child.getId() == null && !validateReferenceDate(dob, SubscriptionPackType.CHILD, msisdn, childId, importOrigin);
boolean isInValidDOB = !validateReferenceDate(dob, SubscriptionPackType.CHILD, msisdn, childId, importOrigin);
if (isInValidDOB) {
return createUpdateChildRejections(flagForMcts, record, action, RejectionReasons.INVALID_DOB, false);
}
Expand Down Expand Up @@ -532,7 +532,9 @@ public boolean validateReferenceDate(DateTime referenceDate, SubscriptionPackTyp
}

if (packType == SubscriptionPackType.PREGNANCY) {
LOGGER.debug("here2");
String referenceDateValidationError = pregnancyPack.isReferenceDateValidForPack(referenceDate);
LOGGER.debug("Result: {}", referenceDateValidationError);
if (!referenceDateValidationError.isEmpty()) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@
import org.motechproject.nms.region.domain.Taluka;
import org.motechproject.nms.region.domain.Village;
import org.motechproject.nms.region.exception.InvalidLocationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.jdo.annotations.Transactional;
import java.util.Map;

@Service("mctsBeneficiaryValueProcessor")
public class MctsBeneficiaryValueProcessorImpl implements MctsBeneficiaryValueProcessor {

private static final Logger LOGGER = LoggerFactory.getLogger(MctsBeneficiaryValueProcessorImpl.class);
@Autowired
private MctsMotherDataService mctsMotherDataService;

Expand Down Expand Up @@ -243,6 +245,7 @@ public Long getMsisdnByString(String value) {
@Override // NO CHECKSTYLE Cyclomatic Complexity
public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Object> record, MctsBeneficiary beneficiary) throws InvalidLocationException {

LOGGER.debug("Enter:: setLocationFieldsCSV %s" , beneficiary.getId());
StringBuffer mapKey = new StringBuffer(record.get(KilkariConstants.STATE_ID).toString());
if (isValidID(record, KilkariConstants.STATE_ID) && (locationFinder.getStateHashMap().get(mapKey.toString()) != null)) {
beneficiary.setState(locationFinder.getStateHashMap().get(mapKey.toString()));
Expand All @@ -268,6 +271,8 @@ public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Obje
String healthFacilityCode = record.get(KilkariConstants.PHC_ID) == null ? "0" : record.get(KilkariConstants.PHC_ID).toString();
String healthSubFacilityCode = record.get(KilkariConstants.SUB_CENTRE_ID) == null ? "0" : record.get(KilkariConstants.SUB_CENTRE_ID).toString();

LOGGER.debug("State:%s, District:%s, Taluka:%s, VilageSvid:%s, VillageCode:%s, HB:%s, HF:%s, HSF:%s", record.get(KilkariConstants.STATE_ID).toString(), districtCode,
talukaCode.toString(), villageSvid, villageCode, healthBlockCode, healthFacilityCode, healthSubFacilityCode);
Village village = locationFinder.getVillageHashMap().get(mapKey.toString() + "_" + Long.parseLong(villageCode) + "_" + Long.parseLong(villageSvid));
if (village != null && village.getId() != null) {
beneficiary.setVillage(village);
Expand Down Expand Up @@ -305,6 +310,7 @@ public void setLocationFieldsCSV(LocationFinder locationFinder, Map<String, Obje
} else {
throw new InvalidLocationException(String.format(KilkariConstants.INVALID_LOCATION, KilkariConstants.STATE_ID, record.get(KilkariConstants.STATE_ID)));
}
LOGGER.debug("Exit:: setLocationFieldsCSV");
}

private boolean isValidID(final Map<String, Object> map, final String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private List<Map<String, Object>> getLMPValidRecords(List<MotherRecord> motherR
rejectedMothers.put(motherImportRejection.getIdNo(), motherImportRejection);
rejectionStatus.put(motherImportRejection.getIdNo(), motherImportRejection.getAccepted());
} else {
boolean isValidLMP = (mother.getId() == null || (mother.getId() != null && mother.getLastMenstrualPeriod() == null)) && !mctsBeneficiaryImportService.validateReferenceDate(lmp, SubscriptionPackType.PREGNANCY, msisdn, beneficiaryId, SubscriptionOrigin.MCTS_IMPORT);
boolean isValidLMP = (!mctsBeneficiaryImportService.validateReferenceDate(lmp, SubscriptionPackType.PREGNANCY, msisdn, beneficiaryId, SubscriptionOrigin.MCTS_IMPORT));
if (isValidLMP) {
motherImportRejection = motherRejectionMcts(convertMapToMother(recordMap), false, RejectionReasons.INVALID_LMP_DATE.toString(), action);
rejectedMothers.put(motherImportRejection.getIdNo(), motherImportRejection);
Expand Down Expand Up @@ -503,7 +503,7 @@ private List<Map<String, Object>> getDOBValidChildRecords(List<ChildRecord> chi
rejectedChilds.put(childImportRejection.getIdNo(), childImportRejection);
rejectionStatus.put(childImportRejection.getIdNo(), childImportRejection.getAccepted());
} else {
boolean isInValidDOB = child.getId() == null && !mctsBeneficiaryImportService.validateReferenceDate(dob, SubscriptionPackType.CHILD, msisdn, childId, SubscriptionOrigin.MCTS_IMPORT);
boolean isInValidDOB = !mctsBeneficiaryImportService.validateReferenceDate(dob, SubscriptionPackType.CHILD, msisdn, childId, SubscriptionOrigin.MCTS_IMPORT);
if (isInValidDOB) {
childImportRejection = childRejectionMcts(convertMapToChild(recordMap), false, RejectionReasons.INVALID_DOB.toString(), action);
rejectedChilds.put(childImportRejection.getIdNo(), childImportRejection);
Expand Down Expand Up @@ -609,7 +609,7 @@ private MctsImportAudit saveImportedAnmAshaData(AnmAshaDataSet anmAshaDataSet, S
Long msisdn = Long.parseLong(record.getContactNo());
String mctsFlwId = record.getId().toString();
FrontLineWorker flw = frontLineWorkerService.getByContactNumber(msisdn);
if (flw != null && ((!mctsFlwId.equals(flw.getMctsFlwId()) || state.getId() != flw.getState().getId())) && flw.getStatus() != FrontLineWorkerStatus.ANONYMOUS) {
if (flw != null && ((!mctsFlwId.equals(flw.getMctsFlwId()) || !state.getId().equals(flw.getState().getId()))) && !FrontLineWorkerStatus.ANONYMOUS.equals(flw.getStatus())) {
LOGGER.debug("Existing FLW with same MSISDN but different MCTS ID");
flwRejectionService.createUpdate(flwRejectionMcts(record, false, RejectionReasons.MOBILE_NUMBER_ALREADY_IN_USE.toString(), action));
rejected++;
Expand Down
Loading