Skip to content

Commit

Permalink
Merge pull request #464 from OpenSRP/issue1593-syncing-events
Browse files Browse the repository at this point in the history
Added the ability to void the event instead of deleting it
  • Loading branch information
qaziabubakar-vd authored Jan 7, 2021
2 parents b280953 + c3cf8d0 commit 00cf7e5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion opensrp-chw-anc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies {
exclude group: 'com.android.support', module: 'appcompat-v7'
}

implementation('org.smartregister:opensrp-client-immunization:2.0.1-SNAPSHOT@aar') {
implementation('org.smartregister:opensrp-client-immunization:3.0.3-SNAPSHOT@aar') {
transitive = true
exclude group: 'org.smartregister', module: 'opensrp-client-core'
exclude group: 'org.smartregister', module: 'opensrp-client-native-form'
Expand Down
2 changes: 1 addition & 1 deletion opensrp-chw-anc/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
POM_SETTING_NAME=OpenSRP Client Chw Anc
POM_SETTING_ARTIFACT_ID=opensrp-client-chw-anc
POM_SETTING_PACKAGING=aar
VERSION_NAME=2.0.1-SNAPSHOT
VERSION_NAME=2.0.2-SNAPSHOT
VERSION_CODE=1
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public static List<Vaccine> fetchVaccinesSubmissionIdByProgramId(String programC
cursor.getString(cursor.getColumnIndex("event_id")),
cursor.getString(cursor.getColumnIndex("formSubmissionId")),
cursor.getInt(cursor.getColumnIndex("out_of_area")),
createdAt
createdAt,
cursor.getInt(cursor.getColumnIndex("is_voided"))
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
import org.smartregister.chw.anc.util.VisitUtils;
import org.smartregister.clientandeventmodel.Event;
import org.smartregister.clientandeventmodel.Obs;
import org.smartregister.clientandeventmodel.User;
import org.smartregister.domain.SyncStatus;
import org.smartregister.immunization.ImmunizationLibrary;
import org.smartregister.immunization.domain.ServiceRecord;
import org.smartregister.immunization.domain.Vaccine;
Expand All @@ -42,7 +44,6 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

import timber.log.Timber;

Expand Down Expand Up @@ -304,15 +305,17 @@ protected void deleteSavedEvent(AllSharedPreferences allSharedPreferences, Strin
Event event = (Event) new Event()
.withBaseEntityId(baseEntityId)
.withEventDate(new Date())
.withEventType(Constants.EVENT_TYPE.DELETE_EVENT)
.withEventType(Constants.EVENT_TYPE.VOID_EVENT)
.withLocationId(JsonFormUtils.locationId(allSharedPreferences))
.withProviderId(allSharedPreferences.fetchRegisteredANM())
.withEntityType(type)
.withFormSubmissionId(UUID.randomUUID().toString())
.withDateCreated(new Date());
.withFormSubmissionId(formSubmissionId)
.withVoided(true)
.withVoider(new User(null, allSharedPreferences.fetchRegisteredANM(), null, null))
.withVoidReason("Edited Event")
.withDateVoided(new Date());

event.addDetails(Constants.JSON_FORM_EXTRA.DELETE_EVENT_ID, eventId);
event.addDetails(Constants.JSON_FORM_EXTRA.DELETE_FORM_SUBMISSION_ID, formSubmissionId);
event.setSyncStatus(SyncStatus.PENDING.value());

try {
syncHelper.addEvent(event.getBaseEntityId(), new JSONObject(JsonFormUtils.gson.toJson(event)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface EVENT_TYPE {
String PREGNANCY_OUTCOME = "Pregnancy Outcome";
String CHILD_REGISTRATION = "Child Registration";
String DELETE_EVENT = "Delete Event";
String VOID_EVENT = "Void Event";
}

interface FORMS {
Expand Down

0 comments on commit 00cf7e5

Please sign in to comment.