Skip to content

Commit

Permalink
Merge pull request #180 from opensrp/outreach-ehnancement
Browse files Browse the repository at this point in the history
added vaccine outreach enhancement
  • Loading branch information
junaidwarsivd authored Oct 18, 2021
2 parents 9eed514 + ca33942 commit 4ff6acf
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=4.0.0-SNAPSHOT
VERSION_NAME=4.0.1-SNAPSHOT
VERSION_CODE=2
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Immunization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,31 @@ public class Vaccine {
private String formSubmissionId;
private Integer isVoided;
private Integer outOfCatchment;
private Integer outreach;
private Date createdAt;

public Vaccine() {
}

public Vaccine(Long id, String baseEntityId, String name, Integer calculation, Date date,
String anmId, String locationId, String syncStatus, String hia2Status, Long
updatedAt, String eventId, String formSubmissionId) {
this.id = id;
this.baseEntityId = baseEntityId;
programClientId = null;
this.name = name;
this.calculation = calculation;
this.date = date;
this.anmId = anmId;
this.locationId = locationId;
this.syncStatus = syncStatus;
this.hia2Status = hia2Status;
this.updatedAt = updatedAt;
this.eventId = eventId;
this.formSubmissionId = formSubmissionId;

}

public Vaccine(Long id, String baseEntityId, String name, Integer calculation, Date date,
String anmId, String locationId, String syncStatus, String hia2Status, Long
updatedAt, String eventId, String formSubmissionId, Integer
Expand All @@ -54,7 +74,7 @@ public Vaccine(Long id, String baseEntityId, String name, Integer calculation, D
public Vaccine(Long id, String baseEntityId, String programClientId, String name, Integer
calculation, Date date, String anmId, String locationId, String syncStatus, String
hia2Status, Long updatedAt, String eventId, String formSubmissionId, Integer
outOfCatchment, Date createdAt) {
outOfCatchment, Date createdAt, Integer isVoided) {
this.id = id;
this.baseEntityId = baseEntityId;
this.programClientId = programClientId;
Expand All @@ -70,12 +90,15 @@ public Vaccine(Long id, String baseEntityId, String programClientId, String name
this.formSubmissionId = formSubmissionId;
this.outOfCatchment = outOfCatchment;
this.createdAt = createdAt;
this.isVoided = isVoided;

}


public Vaccine(Long id, String baseEntityId, String programClientId, String name, Integer
calculation, Date date, String anmId, String locationId, String syncStatus, String
hia2Status, Long updatedAt, String eventId, String formSubmissionId, Integer
outOfCatchment, Date createdAt, Integer isVoided) {
outOfCatchment, Date createdAt, Integer isVoided,Integer outreach) {
this.id = id;
this.baseEntityId = baseEntityId;
this.programClientId = programClientId;
Expand All @@ -92,6 +115,7 @@ public Vaccine(Long id, String baseEntityId, String programClientId, String name
this.outOfCatchment = outOfCatchment;
this.createdAt = createdAt;
this.isVoided = isVoided;
this.outreach = outreach;
}

public Long getId() {
Expand Down Expand Up @@ -254,4 +278,12 @@ public String getChildLocationId() {
public void setChildLocationId(String childLocationId) {
this.childLocationId = childLocationId;
}

public Integer getOutreach() {
return outreach;
}

public void setOutreach(Integer outreach) {
this.outreach = outreach;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ public class VaccineRepository extends BaseRepository {
public static final String UPDATED_AT_COLUMN = "updated_at";
public static final String OUT_OF_AREA = "out_of_area";
public static final String IS_VOIDED = "is_voided";
public static final String OUTREACH = "outreach";
public static final String CREATED_AT = "created_at";
public static final String TEAM_ID = "team_id";
public static final String TEAM = "team";
public static final String[] VACCINE_TABLE_COLUMNS = {ID_COLUMN, BASE_ENTITY_ID, PROGRAM_CLIENT_ID, NAME, CALCULATION, DATE, ANMID, LOCATION_ID, CHILD_LOCATION_ID, TEAM, TEAM_ID, SYNC_STATUS, HIA2_STATUS, UPDATED_AT_COLUMN, EVENT_ID, FORMSUBMISSION_ID, OUT_OF_AREA, IS_VOIDED, CREATED_AT};
public static final String[] VACCINE_TABLE_COLUMNS = {ID_COLUMN, BASE_ENTITY_ID, PROGRAM_CLIENT_ID, NAME, CALCULATION, DATE, ANMID, LOCATION_ID, CHILD_LOCATION_ID, TEAM, TEAM_ID, SYNC_STATUS, HIA2_STATUS, UPDATED_AT_COLUMN, EVENT_ID, FORMSUBMISSION_ID, OUT_OF_AREA, IS_VOIDED, CREATED_AT,OUTREACH};
public static final String UPDATE_TABLE_ADD_EVENT_ID_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + EVENT_ID + " VARCHAR;";
public static final String EVENT_ID_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + EVENT_ID + "_index ON " + VACCINE_TABLE_NAME + "(" + EVENT_ID + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_FORMSUBMISSION_ID_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + FORMSUBMISSION_ID + " VARCHAR;";
Expand All @@ -54,6 +55,7 @@ public class VaccineRepository extends BaseRepository {
public static final String UPDATE_TABLE_ADD_IS_VOIDED_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + IS_VOIDED + " INTEGER;";
public static final String UPDATE_TABLE_ADD_OUT_OF_AREA_COL_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + OUT_OF_AREA + "_index ON " + VACCINE_TABLE_NAME + "(" + OUT_OF_AREA + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_IS_VOIDED_COL_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + IS_VOIDED + "_index ON " + VACCINE_TABLE_NAME + "(" + IS_VOIDED + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_OUTREACH_COL_INDEX = "CREATE INDEX " + VACCINE_TABLE_NAME + "_" + OUTREACH + "_index ON " + VACCINE_TABLE_NAME + "(" + OUTREACH + " COLLATE NOCASE);";
public static final String UPDATE_TABLE_ADD_HIA2_STATUS_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + HIA2_STATUS + " VARCHAR;";
public static final String ALTER_ADD_CREATED_AT_COLUMN = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + CREATED_AT + " DATETIME NULL ";
public static final String UPDATE_TABLE_ADD_TEAM_COL = "ALTER TABLE " + VACCINE_TABLE_NAME + " ADD COLUMN " + TEAM + " VARCHAR;";
Expand Down Expand Up @@ -186,6 +188,7 @@ private ContentValues createValuesFor(Vaccine vaccine) {
values.put(FORMSUBMISSION_ID, vaccine.getFormSubmissionId());
values.put(OUT_OF_AREA, vaccine.getOutOfCatchment());
values.put(IS_VOIDED, vaccine.getIsVoided());
values.put(OUTREACH, vaccine.getOutreach());
values.put(CREATED_AT,
vaccine.getCreatedAt() != null ? EventClientRepository.dateFormat.format(vaccine.getCreatedAt()) : null);
return values;
Expand Down Expand Up @@ -276,7 +279,8 @@ public List<Vaccine> readAllVaccines(Cursor cursor) {
cursor.getString(cursor.getColumnIndex(FORMSUBMISSION_ID)),
cursor.getInt(cursor.getColumnIndex(OUT_OF_AREA)),
createdAt,
cursor.getInt(cursor.getColumnIndex(IS_VOIDED))
cursor.getInt(cursor.getColumnIndex(IS_VOIDED)),
cursor.getInt(cursor.getColumnIndex(OUTREACH))
);

vaccine.setTeam(cursor.getString(cursor.getColumnIndex(TEAM)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class VaccineScheduleTest extends BaseUnitTest {
private Vaccine newVaccine = new Vaccine(0l, VaccineTest.BASEENTITYID, VaccineTest.PROGRAMCLIENTID, magicOPV0, 0,
new Date(),
VaccineTest.ANMID, VaccineTest.LOCATIONID, VaccineTest.SYNCSTATUS, VaccineTest.HIA2STATUS, 0l,
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date());
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(),1);

@Before
public void setUp() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.smartregister.immunization.domain;

import org.junit.Assert;
import org.junit.Test;
import org.smartregister.immunization.BaseUnitTest;

Expand Down Expand Up @@ -33,10 +34,15 @@ public class VaccineTest extends BaseUnitTest {
@Test
public void assertDefaultConstructorsCreateNonNullObjectOnInstantiation() {
junit.framework.Assert.assertNotNull(new Vaccine());
junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID));
junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0));
junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, PROGRAMCLIENTID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0, new Date(), 1));

junit.framework.Assert.assertNotNull(new Vaccine(0l, BASEENTITYID, PROGRAMCLIENTID, NAME, 0, new Date(),
ANMID, LOCATIONID, SYNCSTATUS, HIA2STATUS, 0l, EVENTID, FORMSUBMISSIONID, 0, new Date(), 1,1));
}

@Test
Expand Down Expand Up @@ -119,6 +125,8 @@ public void assetTestallgettersandsetters() {
vaccine.setOutOfCatchment(1);
junit.framework.Assert.assertEquals(1, vaccine.getOutOfCatchment().intValue());

vaccine.setOutreach(1);
Assert.assertEquals(1,vaccine.getOutreach().intValue());
vaccine.setProgramClientId(PROGRAMCLIENTID);
junit.framework.Assert.assertEquals(PROGRAMCLIENTID, vaccine.getProgramClientId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ public void testReadAllReturnsListOfVaccines(){
VaccineRepository.TEAM,
VaccineRepository.TEAM_ID,
VaccineRepository.CHILD_LOCATION_ID,
VaccineRepository.IS_VOIDED
VaccineRepository.IS_VOIDED,
VaccineRepository.OUTREACH
};

MatrixCursor cursor = new MatrixCursor(columns);
cursor.addRow(new Object[]{1l, "", "", magicName, magic10, magicTime, "", "", "", "", 1l, "", "", 1,magicTime,"","","", 1});
cursor.addRow(new Object[]{1l, "", "", magicName, magic10, magicTime, "", "", "", "", 1l, "", "", 1,magicTime,"","","", 1,1});

List<Vaccine> vaccines = vaccineRepository.readAllVaccines(cursor);
Assert.assertFalse(vaccines.isEmpty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void setUp() throws Exception {
Vaccine vaccine = new Vaccine(0l, VaccineTest.BASEENTITYID, VaccineTest.PROGRAMCLIENTID, VaccineTest.NAME, 0,
new Date(),
VaccineTest.ANMID, VaccineTest.LOCATIONID, VaccineTest.SYNCSTATUS, VaccineTest.HIA2STATUS, 0l,
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(), 1);
VaccineTest.EVENTID, VaccineTest.FORMSUBMISSIONID, 0, new Date(), 1,1);
Event event = new Event();
event.setEventId("1");
event.setDateCreated(new DateTime());
Expand Down

0 comments on commit 4ff6acf

Please sign in to comment.