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

[V0.10] Additional Vaccine Schedule logging #339

Draft
wants to merge 3 commits into
base: v0.10
Choose a base branch
from
Draft
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=0.10.5-SNAPSHOT
VERSION_NAME=0.10.6-ALPHA1-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Child Library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ protected int[] updateGenderViews(Gender gender) {
identifier = getString(R.string.male_sex_id);
}

if (Locale.getDefault().toString().equalsIgnoreCase("ar") || Locale.getDefault().toString().equalsIgnoreCase("fr")) {
if (Locale.getDefault().toString().startsWith("ar") || Locale.getDefault().toString().equalsIgnoreCase("fr")) {
identifier = "";
}
toolbar.updateSeparatorView(toolbarResource);
Expand Down Expand Up @@ -1903,6 +1903,21 @@ protected void onPostExecute(Map<String, NamedObject<?>> map) {
updateVaccinationViews(vaccineList, alertList);
performRegisterActions();

// PRint Vaccine Schedule For logging
StringBuilder vaccineGiven = new StringBuilder();
for (Vaccine vaccine : vaccineList) {
vaccineGiven.append(vaccine.getName()).append("|").append(vaccine.getDate()).append("\n");
}
vaccineGiven.append("Current Device Time: " + DateTime.now().toString("yyyy-MM-dd'T'HH:mm:ssZ") + "\n");
Timber.e("Vaccines given for " + childDetails.name() + " with id " + childDetails.entityId() + " is: \n" + vaccineGiven);

String vaccineAlerts = "";
for (Alert vaccine : alertList) {
vaccineAlerts += vaccine.scheduleName() + "|" + vaccine.status() + "|" + vaccine.startDate() + "|" + vaccine.expiryDate() + "\n";
}
vaccineAlerts += "Current Device Time: " + DateTime.now().toString("yyyy-MM-dd'T'HH:mm:ssZ") + "\n";
Timber.e("Vaccine Schedule for " + childDetails.name() + " with id " + childDetails.entityId() + " is: \n" + vaccineAlerts);

hideProgressDialog();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public abstract class BaseAdvancedSearchFragment extends BaseChildRegisterFragme
private AdvanceSearchDatePickerDialog startDateDatePicker;
private AdvanceSearchDatePickerDialog endDateDatePicker;
private final SimpleDateFormat dateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN,
Locale.getDefault().toString().startsWith("ar") ? Locale.ENGLISH : Locale.getDefault());
Utils.getDefaultLocale());
@SuppressLint("StaticFieldLeak")
private final Listener<MoveToCatchmentEvent> moveToMyCatchmentListener = moveToCatchmentEvent -> {
if (moveToCatchmentEvent != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,10 @@ public String cleanValue(Field field, String raw) {
case JsonFormConstants.DATE_PICKER:
Date date = ChildJsonFormUtils.formatDate(raw.contains("T") ? raw.substring(0, raw.indexOf('T')) : raw, false);
if (date != null) {
result = new SimpleDateFormat(com.vijay.jsonwizard.utils.FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN,
Locale.getDefault().toString().startsWith("ar") ? Locale.ENGLISH : Locale.getDefault()).format(date);
result = new SimpleDateFormat(
com.vijay.jsonwizard.utils.FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN,
Utils.getDefaultLocale()
).format(date);
}
break;
case JsonFormConstants.SPINNER:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ private String getCurrentFieldValue(Map<String, String> columnMaps, String field
String value = getValue(columnMaps, fieldName, !getNonHumanizedFields().contains(fieldName));
if (getActivity() != null) {
Locale locale = getActivity().getResources().getConfiguration().locale;
SimpleDateFormat mlsLookupDateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN,
locale.getLanguage().equals("ar") ? Locale.ENGLISH : locale);
SimpleDateFormat mlsLookupDateFormatter = new SimpleDateFormat(FormUtils.NATIIVE_FORM_DATE_FORMAT_PATTERN, Utils.getDefaultLocale());
if (fieldName.equalsIgnoreCase(Constants.KEY.DOB)) {
String dobString = getValue(columnMaps, Constants.KEY.DOB, false);
Date motherDob = Utils.dobStringToDate(dobString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ public String getMainConditionString(Map<String, String> editMap) {

private void convertDateToDesiredFormat(Map<String, String> editMap) {
try {
if(editMap.containsKey(START_DATE) && editMap.containsKey(END_DATE)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault());
SimpleDateFormat desiredDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
if (editMap.containsKey(START_DATE) && editMap.containsKey(END_DATE)) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Utils.getDefaultLocale());
SimpleDateFormat desiredDateFormat = new SimpleDateFormat("yyyy-MM-dd", Utils.getDefaultLocale());
Date parsedStartDate = simpleDateFormat.parse(editMap.get(START_DATE));
Date parsedEndDate = simpleDateFormat.parse(editMap.get(END_DATE));
editMap.put(START_DATE, desiredDateFormat.format(parsedStartDate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ private void updateMotherDetails(ChildEventClient childHeadEventClient, Client c

String dob = null;
try {
dob = Utils.reverseHyphenatedString(Utils.convertDateFormat(childHeadEventClient.getClient().getBirthdate(), new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault())));

dob = Utils.reverseHyphenatedString(Utils.convertDateFormat(childHeadEventClient.getClient().getBirthdate(), new SimpleDateFormat("dd-MM-yyyy", org.smartregister.util.Utils.getDefaultLocale())));
} catch (Exception e) {
Timber.e(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
* Created by ndegwamartin on 25/02/2019.
*/
public class Utils extends org.smartregister.util.Utils {
public static final SimpleDateFormat DB_DF = new SimpleDateFormat(Constants.SQLITE_DATE_TIME_FORMAT);
public static final SimpleDateFormat DB_DF = new SimpleDateFormat(Constants.SQLITE_DATE_TIME_FORMAT, Utils.getDefaultLocale());

public static int getProfileImageResourceIDentifier() {
return R.mipmap.ic_child;
Expand Down Expand Up @@ -799,15 +799,15 @@ public static boolean isChildTemporaryOOC(@NotNull Map<String, String> childDeta

public static String getLocationIdFromChildTempOOCEvent(String baseEntityId) {
EventClientRepository eventClientRepository = ChildLibrary.getInstance().eventClientRepository();
String query = "SELECT "+ EventClientRepository.event_column.json.name() +" FROM "
String query = "SELECT " + EventClientRepository.event_column.json.name() + " FROM "
+ EventClientRepository.Table.event.name()
+ " WHERE "
+ "eventType = '"+ MOVE_TO_CATCHMENT_SYNC_EVENT +"' "
+ "AND baseEntityId = '"+ baseEntityId +"' "
+ "ORDER BY "+EventClientRepository.event_column.dateCreated.name()+" DESC LIMIT 1";
+ "eventType = '" + MOVE_TO_CATCHMENT_SYNC_EVENT + "' "
+ "AND baseEntityId = '" + baseEntityId + "' "
+ "ORDER BY " + EventClientRepository.event_column.dateCreated.name() + " DESC LIMIT 1";
List<EventClient> moveToCatchmentSyncEventClient = eventClientRepository.fetchEventClientsCore(query, null);
org.smartregister.domain.Event moveToCatchmentSyncEvent = moveToCatchmentSyncEventClient.get(0).getEvent();
String locationId = "";
String locationId = "";
for (int i = moveToCatchmentSyncEvent.getObs().size() - 1; i > -1; i--) {
org.smartregister.domain.Obs obs = moveToCatchmentSyncEvent.getObs().get(i);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -664,4 +664,4 @@ public void testGetProfilePhotoByClientObjectReturnsCorrectPhotoInstance() {
Assert.assertEquals(TEST_PHOTO_LINE_PATH, photo.getFilePath());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,4 @@ public void testIsChildHasNFCCardShouldReturnTrueIfCardIsBlacklisted() {
boolean isChildHasNFCCard = Utils.isChildHasNFCCard(childDetails);
Assert.assertFalse(isChildHasNFCCard);
}
}
}