Skip to content

Commit

Permalink
Merge pull request #195 from opensrp/check-vaccine-duplicates
Browse files Browse the repository at this point in the history
Add Duplicate Vaccines & Recurring Service Record Checks
  • Loading branch information
qiarie authored Dec 9, 2022
2 parents 5478d3a + f35eca3 commit 7df7c50
Show file tree
Hide file tree
Showing 39 changed files with 397 additions and 249 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.6-SNAPSHOT
VERSION_NAME=4.0.7-SNAPSHOT
VERSION_CODE=3
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Immunization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.smartregister.immunization.adapter;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.immunization.util.VaccinatorUtils.receivedVaccines;
import static org.smartregister.util.Utils.getValue;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -32,9 +35,7 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.immunization.util.VaccinatorUtils.receivedVaccines;
import static org.smartregister.util.Utils.getValue;
import timber.log.Timber;

/**
* Created by raihan on 13/03/2017.
Expand Down Expand Up @@ -90,7 +91,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
}
return vaccineCards.get(vaccineName);
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
Timber.e(e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.smartregister.immunization.adapter;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.immunization.util.VaccinatorUtils.nextServiceDue;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -32,10 +36,7 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.immunization.util.VaccinatorUtils.nextServiceDue;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;
import timber.log.Timber;

/**
* Created by keyman on 15/05/2017.
Expand Down Expand Up @@ -128,7 +129,7 @@ public View getView(int position, View convertView, ViewGroup parent) {

return serviceCards.get(type);
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
return null;
}

Expand Down Expand Up @@ -179,7 +180,7 @@ public void updateWrapperStatus(String type, ServiceWrapper tag, CommonPersonObj
for (ServiceRecord serviceRecord : getServiceRecordList()) {
//if (serviceRecord.getRecurringServiceId().equals(tag.getTypeId())) {
//if (serviceRecord.getName().equalsIgnoreCase(tag.getDefaultName())) {
serviceRecordList.add(serviceRecord);
serviceRecordList.add(serviceRecord);
//}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.smartregister.immunization.adapter;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -31,9 +34,7 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;
import timber.log.Timber;

/**
* Created by keyman on 15/05/2017.
Expand Down Expand Up @@ -95,7 +96,7 @@ public View getView(int position, View convertView, ViewGroup parent) {

return serviceRowCards.get(serviceType.getName());
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.smartregister.immunization.adapter;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;

import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
Expand Down Expand Up @@ -33,9 +36,7 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static org.smartregister.immunization.util.VaccinatorUtils.generateScheduleList;
import static org.smartregister.util.Utils.getName;
import static org.smartregister.util.Utils.getValue;
import timber.log.Timber;

/**
* Created by Jason Rogena - [email protected] on 22/02/2017.
Expand Down Expand Up @@ -99,7 +100,7 @@ public View getView(int position, View convertView, ViewGroup parent) {

return vaccineCards.get(vaccineName);
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
Timber.e(e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.smartregister.immunization.domain;

import android.util.Log;

import org.joda.time.DateTime;
import org.json.JSONException;
import org.json.JSONObject;
Expand All @@ -21,6 +19,8 @@
import java.util.List;
import java.util.Locale;

import timber.log.Timber;

/**
* Created by Keyman on 26/05/2017.
*/
Expand Down Expand Up @@ -102,7 +102,7 @@ public static void updateOfflineAlerts(String type, String baseEntityId, DateTim
alertService.create(newAlerts);

} catch (Exception e) {
Log.e(ServiceSchedule.class.getName(), e.toString(), e);
Timber.e(e);
}


Expand Down Expand Up @@ -132,7 +132,7 @@ public static Alert getOfflineAlert(ServiceType serviceType, List<ServiceRecord>
}
return null;
} catch (Exception e) {
Log.e(ServiceSchedule.class.getName(), e.toString(), e);
Timber.e(e);
return null;
}
}
Expand Down Expand Up @@ -204,7 +204,7 @@ public static DateTime addOffsetToDateTime(DateTime dateTime, String offset) {

return afterOffset;
} catch (Exception e) {
Log.e(ServiceSchedule.class.getName(), e.toString(), e);
Timber.e(e);
return dateTime;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.smartregister.immunization.domain;

import android.util.Log;

import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.json.JSONObject;
Expand All @@ -14,6 +12,8 @@
import java.util.HashMap;
import java.util.Map;

import timber.log.Timber;

/**
* Created by keyman on 22/11/2016.
*/
Expand Down Expand Up @@ -139,7 +139,7 @@ public String updateFormSubmission() {
String data = XML.toString(formSubmission);
return data;
} catch (Exception e) {
Log.e(VaccinateFormSubmissionWrapper.class.getName(), "", e);
Timber.e(e);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.smartregister.immunization.domain.jsonmapping;

import android.util.Log;

import java.util.Map;

import timber.log.Timber;

/**
* Created by samuelgithengi on 2/27/18.
*/

public class Vaccine implements Cloneable{
public class Vaccine implements Cloneable {

public String name;

Expand Down Expand Up @@ -85,7 +85,7 @@ public Vaccine clone() {
try {
return (Vaccine) super.clone();
} catch (CloneNotSupportedException e) {
Log.e(Vaccine.class.getCanonicalName(), e.getMessage());
Timber.e(e);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.ContentValues;
import android.database.Cursor;
import android.util.Log;

import net.sqlcipher.database.SQLiteDatabase;

Expand Down Expand Up @@ -76,7 +75,7 @@ public static void migrateCreatedAt(SQLiteDatabase database) {
" WHERE " + CREATED_AT + " is null ";
database.execSQL(sql);
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}

Expand Down Expand Up @@ -116,7 +115,7 @@ public void add(ServiceRecord serviceRecord) {
update(database, serviceRecord);
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}

Expand Down Expand Up @@ -153,7 +152,7 @@ public ServiceRecord findUnique(SQLiteDatabase database_, ServiceRecord serviceR
return serviceRecordList.get(0);
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}

return null;
Expand All @@ -174,7 +173,7 @@ public void update(SQLiteDatabase database_, ServiceRecord serviceRecord) {
database.update(TABLE_NAME, createValuesFor(serviceRecord), idSelection,
new String[] {serviceRecord.getId().toString()});
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}

Expand Down Expand Up @@ -215,7 +214,7 @@ private List<ServiceRecord> readAllServiceRecords(Cursor cursor) {
try {
createdAt = EventClientRepository.dateFormat.parse(dateCreatedString);
} catch (ParseException e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}
ServiceRecord serviceRecord = new ServiceRecord(cursor.getLong(cursor.getColumnIndex(ID_COLUMN)),
Expand Down Expand Up @@ -258,7 +257,7 @@ private List<ServiceRecord> readAllServiceRecords(Cursor cursor) {
}
}
} catch (Exception e) {
Log.e(TAG, e.getMessage(), e);
Timber.e(e);
} finally {
if (cursor != null) {
cursor.close();
Expand Down Expand Up @@ -331,7 +330,7 @@ public void deleteServiceRecord(Long caseId) {
getWritableDatabase().delete(TABLE_NAME, ID_COLUMN + "= ?", new String[] {caseId.toString()});
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}

Expand All @@ -347,7 +346,37 @@ public ServiceRecord find(Long caseId) {
serviceRecord = serviceRecords.get(0);
}
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
} finally {
if (cursor != null) {
cursor.close();
}
}
return serviceRecord;
}

public ServiceRecord findByBaseEntityIdAndRecurringServiceId(String baseEntityId, Long recurringServiceId) {
ServiceRecord serviceRecord = null;
Cursor cursor = null;

try {
cursor = getReadableDatabase().query(
TABLE_NAME,
TABLE_COLUMNS,
BASE_ENTITY_ID + " = ? AND " + RECURRING_SERVICE_ID + " = ?",
new String[]{baseEntityId, String.valueOf(recurringServiceId)},
null,
null,
null,
null
);

List<ServiceRecord> serviceRecords = readAllServiceRecords(cursor);
if (!serviceRecords.isEmpty()) {
serviceRecord = serviceRecords.get(0);
}
} catch (Exception e) {
Timber.e(e);
} finally {
if (cursor != null) {
cursor.close();
Expand All @@ -362,7 +391,7 @@ public void close(Long caseId) {
values.put(SYNC_STATUS, TYPE_Synced);
getWritableDatabase().update(TABLE_NAME, values, ID_COLUMN + " = ?", new String[] {caseId.toString()});
} catch (Exception e) {
Log.e(TAG, Log.getStackTraceString(e));
Timber.e(e);
}
}
}
Loading

0 comments on commit 7df7c50

Please sign in to comment.