diff --git a/api/pom.xml b/api/pom.xml
index 5df72dc6b..785ed0a7e 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
api
- 1.0.21
+ 1.0.22
bundle
API module
diff --git a/csv/pom.xml b/csv/pom.xml
index acff587fe..99f41ac58 100644
--- a/csv/pom.xml
+++ b/csv/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
csv
- 1.0.21
+ 1.0.22
bundle
CSV Module
diff --git a/flw/pom.xml b/flw/pom.xml
index fee7320f3..632c593ea 100644
--- a/flw/pom.xml
+++ b/flw/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
flw
- 1.0.21
+ 1.0.22
bundle
FLW module
diff --git a/flwUpdate/pom.xml b/flwUpdate/pom.xml
index 709d5b924..395d0691f 100644
--- a/flwUpdate/pom.xml
+++ b/flwUpdate/pom.xml
@@ -7,12 +7,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
flwUpdate
- 1.0.21
+ 1.0.22
bundle
FLW Update Module
diff --git a/imi/pom.xml b/imi/pom.xml
index 8315b3c7a..1147f2083 100644
--- a/imi/pom.xml
+++ b/imi/pom.xml
@@ -7,12 +7,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
imi
- 1.0.21
+ 1.0.22
bundle
IMI module
diff --git a/kilkari/pom.xml b/kilkari/pom.xml
index fc2270f89..8aee663d5 100644
--- a/kilkari/pom.xml
+++ b/kilkari/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
kilkari
- 1.0.21
+ 1.0.22
bundle
Kilkari module
diff --git a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java
index e2f50a963..e034df07e 100644
--- a/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java
+++ b/kilkari/src/main/java/org/motechproject/nms/kilkari/service/impl/MctsBeneficiaryImportServiceImpl.java
@@ -193,6 +193,8 @@ public boolean importMotherRecord(Map record) {
//validate if it's an updated record compared to one from database
if (mother.getUpdatedDateNic() != null && (mctsUpdatedDateNic == null || mother.getUpdatedDateNic().isAfter(mctsUpdatedDateNic))) {
+ subscriptionErrorDataService.create(new SubscriptionError(msisdn, mother.getBeneficiaryId(),
+ SubscriptionRejectionReason.ALREADY_SUBSCRIBED, SubscriptionPackType.PREGNANCY, "Updated Record exits"));
return false;
}
@@ -267,6 +269,8 @@ public boolean importChildRecord(Map record) {
//validate if it's an updated record compared to one from database
if (child.getUpdatedDateNic() != null && (mctsUpdatedDateNic == null || child.getUpdatedDateNic().isAfter(mctsUpdatedDateNic))) {
+ subscriptionErrorDataService.create(new SubscriptionError(msisdn, child.getBeneficiaryId(),
+ SubscriptionRejectionReason.ALREADY_SUBSCRIBED, SubscriptionPackType.CHILD, "Updated Record exits"));
return false;
}
@@ -419,7 +423,12 @@ public Boolean retrieve(String value) {
return mctsBeneficiaryValueProcessor.getDeathFromString(value);
}
}));
-
+ mapping.put(KilkariConstants.LAST_UPDATE_DATE, new Optional(new GetInstanceByString() {
+ @Override
+ public LocalDate retrieve(String value) {
+ return (LocalDate) mctsBeneficiaryValueProcessor.getDateByString(value).toLocalDate();
+ }
+ }));
return mapping;
}
@@ -459,7 +468,12 @@ public Boolean retrieve(String value) {
return mctsBeneficiaryValueProcessor.getDeathFromString(value);
}
}));
-
+ mapping.put(KilkariConstants.LAST_UPDATE_DATE, new Optional(new GetInstanceByString() {
+ @Override
+ public LocalDate retrieve(String value) {
+ return (LocalDate) mctsBeneficiaryValueProcessor.getDateByString(value).toLocalDate();
+ }
+ }));
return mapping;
}
}
diff --git a/mcts/pom.xml b/mcts/pom.xml
index 9f3803aab..0b74cd5e2 100644
--- a/mcts/pom.xml
+++ b/mcts/pom.xml
@@ -6,12 +6,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
mcts
- 1.0.21
+ 1.0.22
bundle
Mother Children Tracking Service
diff --git a/mobile-academy/pom.xml b/mobile-academy/pom.xml
index f784c6006..a4e349686 100644
--- a/mobile-academy/pom.xml
+++ b/mobile-academy/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
mobile-academy
- 1.0.21
+ 1.0.22
bundle
Mobile Academy module
diff --git a/pom.xml b/pom.xml
index 48fe15997..8a93ca0da 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
pom
National Motech System
diff --git a/props/pom.xml b/props/pom.xml
index f324e28fa..86318d8c3 100644
--- a/props/pom.xml
+++ b/props/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
props
- 1.0.21
+ 1.0.22
bundle
Properties module
diff --git a/region/pom.xml b/region/pom.xml
index ab8a75668..edbd2e357 100644
--- a/region/pom.xml
+++ b/region/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
region
- 1.0.21
+ 1.0.22
bundle
Region Module
diff --git a/testing/pom.xml b/testing/pom.xml
index 0a23bca39..55d36ff94 100644
--- a/testing/pom.xml
+++ b/testing/pom.xml
@@ -7,12 +7,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
testing
- 1.0.21
+ 1.0.22
bundle
Testing module
diff --git a/testing/src/test/java/org/motechproject/nms/testing/it/kilkari/MctsBeneficiaryImportServiceBundleIT.java b/testing/src/test/java/org/motechproject/nms/testing/it/kilkari/MctsBeneficiaryImportServiceBundleIT.java
index e4c540cf4..95aa3cbd6 100644
--- a/testing/src/test/java/org/motechproject/nms/testing/it/kilkari/MctsBeneficiaryImportServiceBundleIT.java
+++ b/testing/src/test/java/org/motechproject/nms/testing/it/kilkari/MctsBeneficiaryImportServiceBundleIT.java
@@ -65,6 +65,7 @@
import java.util.List;
import java.util.Set;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -217,7 +218,7 @@ public void testImportMotherNewSubscriber() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -237,7 +238,7 @@ public void testImportMotherAlternateDateFormat() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = lmp.toString("dd/MM/yyyy");
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
Subscriber subscriber = subscriberDataService.findByNumber(9439986187L);
@@ -250,7 +251,7 @@ public void testImportMotherWhoAlreadyExistsUpdateLmp() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -266,7 +267,7 @@ public void testImportMotherWhoAlreadyExistsUpdateLmp() throws Exception {
DateTime newLmp = DateTime.now().minusDays(150);
String newLmpString = getDateString(newLmp);
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- newLmpString + "\t\t\t");
+ newLmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -279,9 +280,46 @@ public void testImportMotherWhoAlreadyExistsUpdateLmp() throws Exception {
transactionManager.commit(status);
}
+ /*
+ * Update of kilkari should fail if Last_Update_Date is earlier than that in the database
+ */
+ @Test
+ public void testMotherUpdateWithLastUpdateDate() throws Exception {
+ DateTime lmp = DateTime.now().minusDays(100);
+ String lmpString = getDateString(lmp);
+ Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
+ lmpString + "\t\t\t\t03-10-2016");
+ mctsBeneficiaryImportService.importMotherData(reader);
+
+ TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
+ Subscriber subscriber = subscriberDataService.findByNumber(9439986187L);
+ assertNotNull(subscriber);
+ assertEquals(lmp.toLocalDate(), subscriber.getLastMenstrualPeriod().toLocalDate());
+ assertEquals("Shanti Ekka", subscriber.getMother().getName());
+ List se = subscriptionErrorDataService.findByContactNumber(9439986187L);
+ assertEquals(0, se.size());
+ transactionManager.commit(status);
+
+ DateTime newLmp = DateTime.now().minusDays(150);
+ String newLmpString = getDateString(newLmp);
+ reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
+ newLmpString + "\t\t\t\t01-10-2016");
+ mctsBeneficiaryImportService.importMotherData(reader);
+
+ status = transactionManager.getTransaction(new DefaultTransactionDefinition());
+ subscriber = subscriberDataService.findByNumber(9439986187L);
+ assertNotNull(subscriber);
+
+ // Lmp update should fail
+ assertNotEquals(newLmp.toLocalDate(), subscriber.getLastMenstrualPeriod().toLocalDate());
+ assertEquals(lmp.toLocalDate(), subscriber.getLastMenstrualPeriod().toLocalDate());
+ assertSubscriptionError(9439986187L, SubscriptionPackType.PREGNANCY, SubscriptionRejectionReason.ALREADY_SUBSCRIBED);
+ transactionManager.commit(status);
+ }
+
@Test
public void testImportMotherInvalidState() throws Exception {
- Reader reader = createMotherDataReader("9\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t22-11-2015\t\t\t");
+ Reader reader = createMotherDataReader("9\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t22-11-2015\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
List se = subscriptionErrorDataService.findByContactNumber(9439986187L);
assertEquals(1, se.size());
@@ -293,7 +331,7 @@ public void testImportChildNewSubscriberNoMotherId() throws Exception {
DateTime dob = DateTime.now().minusDays(100);
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -315,7 +353,7 @@ public void testImportMotherAndChildSameMsisdn() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -330,7 +368,7 @@ public void testImportMotherAndChildSameMsisdn() throws Exception {
DateTime dob = DateTime.now().minusDays(200);
String dobString = getDateString(dob);
reader = createChildDataReader("21\t3\t\t\t\t\t9876543210\tBaby1 of Shanti Ekka\t1234567890\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -357,7 +395,7 @@ public void testDeactivateMotherSubscriptionDueToAbortion() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -376,7 +414,7 @@ public void testDeactivateMotherSubscriptionDueToAbortion() throws Exception {
// import record for same mother with Abortion set to "Spontaneous" -- her subscription should be deactivated
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\tSpontaneous\t\t");
+ lmpString + "\tSpontaneous\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -396,7 +434,7 @@ public void testDeactivateMotherSubscriptionDueToStillbirth() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -415,7 +453,7 @@ public void testDeactivateMotherSubscriptionDueToStillbirth() throws Exception {
// import record for same mother with Outcome_Nos set to 0 -- her subscription should be deactivated
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t0\t");
+ lmpString + "\t\t0\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -435,7 +473,7 @@ public void testDeactivateMotherSubscriptionDueToDeath() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -454,7 +492,7 @@ public void testDeactivateMotherSubscriptionDueToDeath() throws Exception {
// import record for same mother with Entry_Type set to 9 -- her subscription should be deactivated
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t9");
+ lmpString + "\t\t\t9\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -474,7 +512,7 @@ public void testDeactivateChildSubscriptionDueToDeath() throws Exception {
DateTime dob = DateTime.now().minusDays(100);
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -493,7 +531,7 @@ public void testDeactivateChildSubscriptionDueToDeath() throws Exception {
// import record for same child with Entry_Type set to 9 -- her subscription should be deactivated
reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t9");
+ + dobString + "\t9\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -579,7 +617,7 @@ private DateTime getDateTime(String dateString) {
private Reader createChildDataReader(String... lines) {
StringBuilder builder = new StringBuilder();
- builder.append("StateID\tDistrict_ID\tTaluka_ID\tHealthBlock_ID\tPHC_ID\tVillage_ID\tID_No\tName\tMother_ID\tWhom_PhoneNo\tBirthdate\tEntry_Type");
+ builder.append("StateID\tDistrict_ID\tTaluka_ID\tHealthBlock_ID\tPHC_ID\tVillage_ID\tID_No\tName\tMother_ID\tWhom_PhoneNo\tBirthdate\tEntry_Type\tLast_Update_Date");
builder.append("\n");
for (String line : lines) {
@@ -591,7 +629,7 @@ private Reader createChildDataReader(String... lines) {
private Reader createMotherDataReader(String... lines) {
StringBuilder builder = new StringBuilder();
builder.append("StateID\tDistrict_ID\tTaluka_ID\tHealthBlock_ID\tPHC_ID\tVillage_ID\tID_No\tName\tWhom_PhoneNo\tBirthdate\tLMP_Date\t");
- builder.append("Abortion\tOutcome_Nos\tEntry_Type");
+ builder.append("Abortion\tOutcome_Nos\tEntry_Type\tLast_Update_Date");
builder.append("\n");
for (String line : lines) {
@@ -612,7 +650,7 @@ public void verifyFT282() throws Exception {
DateTime lmp = DateTime.now().plusDays(1);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_LMP'.
@@ -628,7 +666,7 @@ public void verifyFT283() throws Exception {
DateTime dob = DateTime.now().plusDays(1);
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_DOB'.
@@ -644,7 +682,7 @@ public void verifyFT284() throws Exception {
DateTime lmp = DateTime.now().minusDays(7 * 72 + 90);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_LMP'.
@@ -660,7 +698,7 @@ public void verifyFT285() throws Exception {
DateTime dob = DateTime.now().minusDays(7 * 48);
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_DOB'.
@@ -680,12 +718,12 @@ public void verifyFT287() throws Exception {
// create subscriber and subscription
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
// attempt to create subscriber with same msisdn but different mcts.
reader = createChildDataReader("21\t3\t\t\t\t\t1234567891\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//rejected entry should be in nms_subscription_errors with reason 'ALREADY_SUBSCRIBED'.
@@ -699,7 +737,7 @@ public void verifyFT287() throws Exception {
public void verifyFT288_1() throws Exception {
//DOB is missing
- Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t\t");
+ Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'MISSING_DOB'.
@@ -714,7 +752,7 @@ public void verifyFT288_1() throws Exception {
public void verifyFT288_2() throws Exception {
//LMP is missing
- Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t\t\t\t");
+ Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'MISSING_LMP'.
@@ -746,7 +784,7 @@ public void verifyFT289() throws Exception {
// create subscriber and subscription
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
//Make subscription completed
@@ -757,7 +795,7 @@ public void verifyFT289() throws Exception {
//create a new subscription for subscriber whose subscription is completed.
lmpString = getDateString(lmp.minus(200));
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" + lmpString
- + "\t\t\t");
+ + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -781,7 +819,7 @@ public void verifyFT290() throws Exception {
// create subscriber and subscription
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -794,7 +832,7 @@ public void verifyFT290() throws Exception {
//create a new subscription for subscriber whose subscription is deactivated.
lmpString = getDateString(lmp.minus(200));
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" + lmpString
- + "\t\t\t");
+ + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -819,7 +857,7 @@ public void verifyFT286() throws Exception {
//attempt to create subscriber and subscription with wrong state-district combination. it should be rejected
Reader reader = createChildDataReader("31\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_LOCATION'.
@@ -834,7 +872,7 @@ public void verifyRejectedWithNoState() throws Exception {
DateTime dob = DateTime.now();
String dobString = getDateString(dob);
- Reader reader = createChildDataReader("\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t" + dobString + "\t");
+ Reader reader = createChildDataReader("\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t" + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_LOCATION'.
@@ -849,7 +887,7 @@ public void verifyRejectedWithNoDistrict() throws Exception {
DateTime dob = DateTime.now();
String dobString = getDateString(dob);
- Reader reader = createChildDataReader("31\t\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t" + dobString + "\t");
+ Reader reader = createChildDataReader("31\t\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t" + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//subscriber should not be created and rejected entry should be in nms_subscription_errors with reason 'INVALID_LOCATION'.
@@ -866,7 +904,7 @@ public void verifyFT309() throws Exception {
DateTime dob = DateTime.now();
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -879,7 +917,7 @@ public void verifyFT309() throws Exception {
//create a new subscription for subscriber whose subscription is deactivated.
dobString = getDateString(dob.minus(50));
reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -899,7 +937,7 @@ public void verifyFT310() throws Exception {
DateTime dob = DateTime.now();
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
//Make subscription completed
@@ -910,7 +948,7 @@ public void verifyFT310() throws Exception {
//create a new subscription for subscriber whose subscription is deactivated.
dobString = getDateString(dob.minus(50));
reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -930,7 +968,7 @@ public void verifyFT311() throws Exception {
DateTime dob = DateTime.now();
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -948,7 +986,7 @@ public void verifyFT311() throws Exception {
DateTime newDob = DateTime.now().minusDays(150);
String newDobString = getDateString(newDob);
reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t" +
- newDobString + "\t");
+ newDobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -973,7 +1011,7 @@ public void verifyFT322() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -988,7 +1026,7 @@ public void verifyFT322() throws Exception {
DateTime dob = DateTime.now().minusDays(200);
String dobString = getDateString(dob);
reader = createChildDataReader("21\t3\t\t\t\t\t9876543210\tBaby1 of Shanti Ekka\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1010,7 +1048,7 @@ public void verifyFT322() throws Exception {
// import child with same MSISDN and above MotherID --> child should be updated and mother be deactivated
reader = createChildDataReader("21\t3\t\t\t\t\t9876543210\tBaby1 of Shanti Ekka\t1234567890\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1036,7 +1074,7 @@ public void verifyFT308() throws Exception {
DateTime lmp = DateTime.now().minusDays(30);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1053,7 +1091,7 @@ public void verifyFT308() throws Exception {
DateTime newLmp = DateTime.now().minusDays(90);
String newLmpString = getDateString(newLmp);
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- newLmpString + "\t\t\t");
+ newLmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1123,7 +1161,7 @@ public void verifyFT313_1() throws Exception {
//attempt to create mother data with abortion value 'MTP<12 Weeks'
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\tMTP<12 Weeks\t\t");
+ lmpString + "\tMTP<12 Weeks\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1147,7 +1185,7 @@ public void verifyFT313_2() throws Exception {
//attempt to create mother data with abortion value 'Spontaneous'
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\tSpontaneous\t\t");
+ lmpString + "\tSpontaneous\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1171,7 +1209,7 @@ public void verifyFT313_3() throws Exception {
//attempt to create mother data with abortion value 'MTP>12 Weeks'
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\tMTP>12 Weeks\t\t");
+ lmpString + "\tMTP>12 Weeks\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1194,7 +1232,7 @@ public void verifyFT315() throws Exception {
//attempt to create mother data with Outcome_Nos value '0'
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t0\t");
+ lmpString + "\t\t0\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1219,7 +1257,7 @@ public void verifyFT525() throws Exception {
String dobString = getDateString(DateTime.now().minusDays(30));
//state id is missing
Reader reader = createChildDataReader("\t6\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
assertNoSubscriber(9439986187L);
@@ -1234,7 +1272,7 @@ public void verifyFT526() throws Exception {
String dobString = getDateString(DateTime.now().minusDays(30));
//state id with invalid value
Reader reader = createChildDataReader("31\t6\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
assertNoSubscriber(9439986187L);
@@ -1248,7 +1286,7 @@ public void verifyFT526() throws Exception {
public void verifyFT527() throws Exception {
String dobString = getDateString(DateTime.now().minusDays(30));
Reader reader = createChildDataReader("21\t6\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
//district id with invalid value
mctsBeneficiaryImportService.importChildData(reader);
@@ -1267,7 +1305,7 @@ public void verifyFT529() throws Exception {
String dobString = getDateString(dob);
//district id is missing
Reader reader = createChildDataReader("21\t\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
assertNoSubscriber(9439986187L);
@@ -1283,7 +1321,7 @@ public void verifyFT530() throws Exception {
String dobString = getDateString(dob);
//state id with invalid value
Reader reader = createChildDataReader("31\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
assertNoSubscriber(9439986187L);
@@ -1299,7 +1337,7 @@ public void verifyFT531() throws Exception {
String dobString = getDateString(dob);
//district id with invalid value
Reader reader = createChildDataReader("21\t6\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
assertNoSubscriber(9439986187L);
@@ -1316,7 +1354,7 @@ public void verifyFT314() throws Exception {
//attempt to create mother data with entry_type value '9'
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t9");
+ lmpString + "\t\t\t9\t");
mctsBeneficiaryImportService.importMotherData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1339,7 +1377,7 @@ public void verifyFT316() throws Exception {
//attempt to create child data with entry_type '9'
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t9");
+ + dobString + "\t9\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1363,7 +1401,7 @@ public void testCreateMotherSubscriptionWhenDeactivatedChildSubscriptionExists()
DateTime dob = DateTime.now().minusDays(100);
String dobString = getDateString(dob);
Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1386,7 +1424,7 @@ public void testCreateMotherSubscriptionWhenDeactivatedChildSubscriptionExists()
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
reader = createMotherDataReader("21\t3\t\t\t\t\t1234567891\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1407,9 +1445,9 @@ public void testImportIntoStateWithTwoCircles() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t",
+ lmpString + "\t\t\t\t",
"21\t5\t\t\t\t\t1234567890\tShanti Ekka\t9439986188\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
Subscriber subscriber = subscriberDataService.findByNumber(9439986187L);
@@ -1427,14 +1465,14 @@ public void testMotherDeactivatesIfChildActive() throws Exception {
DateTime lmp = DateTime.now().minusDays(100);
String lmpString = getDateString(lmp);
Reader reader = createMotherDataReader("21\t3\t\t\t\t\t1234567890\tShanti Ekka\t9439986187\t\t" +
- lmpString + "\t\t\t");
+ lmpString + "\t\t\t\t");
mctsBeneficiaryImportService.importMotherData(reader);
// import child
DateTime dob = DateTime.now().minusDays(5);
String dobString = getDateString(dob);
reader = createChildDataReader("21\t3\t\t\t\t\t1234567891\tBaby1 of Shanti Ekka\t1234567890\t9439986187\t"
- + dobString + "\t");
+ + dobString + "\t\t");
mctsBeneficiaryImportService.importChildData(reader);
TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
@@ -1454,4 +1492,39 @@ public void testMotherDeactivatesIfChildActive() throws Exception {
}
+ /*
+ * To verify child subscription is rejected when Last_Update_Date is earlier than that in database
+ */
+ @Test
+ public void testChildUpdateWithLastUpdateDate() throws Exception {
+ DateTime dob = DateTime.now().minusDays(100);
+ String dobString = getDateString(dob);
+ Reader reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
+ + dobString + "\t\t03-10-2016");
+ mctsBeneficiaryImportService.importChildData(reader);
+
+ TransactionStatus status = transactionManager.getTransaction(new DefaultTransactionDefinition());
+ Subscriber subscriber = subscriberDataService.findByNumber(9439986187L);
+ assertNotNull(subscriber);
+ assertEquals(dob.toLocalDate(), subscriber.getDateOfBirth().toLocalDate());
+ List se = subscriptionErrorDataService.findByContactNumber(9439986187L);
+ assertEquals(0, se.size());
+ transactionManager.commit(status);
+
+ DateTime newdob = DateTime.now().minusDays(150);
+ String newdobString = getDateString(newdob);
+ reader = createChildDataReader("21\t3\t\t\t\t\t1234567890\tBaby1 of Lilima Kua\t\t9439986187\t"
+ + newdobString + "\t\t01-10-2016");
+ mctsBeneficiaryImportService.importChildData(reader);
+
+ status = transactionManager.getTransaction(new DefaultTransactionDefinition());
+ subscriber = subscriberDataService.findByNumber(9439986187L);
+ assertNotNull(subscriber);
+ // Update DOB should fail
+ assertNotEquals(newdob.toLocalDate(), subscriber.getDateOfBirth().toLocalDate());
+ assertEquals(dob.toLocalDate(), subscriber.getDateOfBirth().toLocalDate());
+ assertSubscriptionError(9439986187L, SubscriptionPackType.CHILD, SubscriptionRejectionReason.ALREADY_SUBSCRIBED);
+ transactionManager.commit(status);
+ }
+
}
\ No newline at end of file
diff --git a/tracking/pom.xml b/tracking/pom.xml
index 4f2cec493..a38459788 100644
--- a/tracking/pom.xml
+++ b/tracking/pom.xml
@@ -5,12 +5,12 @@
nms
org.motechproject.nms
- 1.0.21
+ 1.0.22
../
tracking
- 1.0.21
+ 1.0.22
bundle
Tracking Module