Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed tasks disappearing from home visits when syncing immediately #408

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=2.0.24-SNAPSHOT
VERSION_NAME=2.0.25-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Chw Core Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ public static boolean memberHasBirthCert(String baseEntityID) {
return Integer.valueOf(values.get(0)) > 0;
}

public static String getBirthCertificateDate(String baseEntityID) {
String sql = "select d.updated_at from visit_details d " +
"inner join visits v on v.visit_id = d.visit_id COLLATE NOCASE " +
"where base_entity_id = '" + baseEntityID + "' COLLATE NOCASE and v.processed = 1 " +
"and (visit_key in ('birth_certificate','birth_cert') and (details = 'GIVEN' or human_readable_details = 'Yes'))";

DataMap<String> dataMap = c -> getCursorValue(c, "updated_at");
List<String> values = AbstractDao.readData(sql, dataMap);
if (values == null || values.size() == 0)
return "";

return values.get(0);
}

public static String getVaccineCardDate(String baseEntityID) {
String sql = "select d.updated_at from visit_details d inner join visits v on v.visit_id = d.visit_id " +
"COLLATE NOCASE where base_entity_id = '" + baseEntityID + "' " +
"COLLATE NOCASE and v.processed = 1 and (visit_key in ('vaccine_card', 'child_vaccine_card') and human_readable_details = 'Yes')";

DataMap<String> dataMap = c -> getCursorValue(c, "updated_at");
List<String> values = AbstractDao.readData(sql, dataMap);
if (values == null || values.size() == 0)
return "";

return values.get(0);
}

public static boolean memberHasVaccineCard(String baseEntityID) {
String sql = "select count(*) certificates " +
"from visit_details d " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static Map<String, List<ServiceType>> getServiceGroup(RecurringServiceMod
}

for (ServiceRecord serviceRecord : model.getServiceRecords()) {
if (serviceRecord.getSyncStatus().equals(RecurringServiceTypeRepository.TYPE_Unsynced) && serviceRecord.getType().equals(type)) {
if (serviceRecord.getType().equals(type)) {
foundServiceTypeMap.put(type, model.getServiceTypes().get(type));
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ public static List<VaccineGroup> getVaccineGroups(Context context, String vaccin
* @param group
* @return
*/
public static List<VaccineWrapper> getChildDueVaccines(String baseEntityID, Date dob, int group) {
List<Alert> alerts = VisitVaccineUtil.getNextVaccines(baseEntityID, new DateTime(dob), CoreConstants.SERVICE_GROUPS.CHILD, false);
public static List<VaccineWrapper> getChildDueVaccines(String baseEntityID, Date dob, int group, boolean isEditMode) {
List<Alert> alerts = VisitVaccineUtil.getNextVaccines(baseEntityID, new DateTime(dob), CoreConstants.SERVICE_GROUPS.CHILD, false, isEditMode);
List<VaccineWrapper> wrappers = new ArrayList<>();
List<VaccineGroup> vaccineGroups = VaccineScheduleUtil.getVaccineGroups(CoreChwApplication.getInstance().getApplicationContext(), CoreConstants.SERVICE_GROUPS.CHILD);
VaccineGroup vaccineGroup = vaccineGroups.get(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static Map<String, VaccineRepo.Vaccine> getAllVaccines() {
return vaccineMap;
}

public static List<Alert> getNextVaccines(String baseEntityID, DateTime anchorDate, String category, boolean includePending) {
public static List<Alert> getNextVaccines(String baseEntityID, DateTime anchorDate, String category, boolean includePending, boolean isEditMode) {

/// compute the alerts
HashMap<String, HashMap<String, VaccineSchedule>> vaccineSchedules = getVaccineSchedules(category);
Expand All @@ -87,7 +87,7 @@ public static List<Alert> getNextVaccines(String baseEntityID, DateTime anchorDa
String code = alert.scheduleName().toLowerCase().replace(" ", "");
Date dateIssued = issuedVaccines.get(code);

if (dateIssued == null) {
if (isEditMode || dateIssued == null) {
pending.add(alert);
}
}
Expand Down