From 043eecefc6fb000598ba47454f5958c190c27b21 Mon Sep 17 00:00:00 2001 From: Hamza Ahmed Khan Date: Tue, 10 May 2022 13:24:56 +0500 Subject: [PATCH] Pick event location from child selected facility --- gradle.properties | 2 +- .../child/util/ChildJsonFormUtils.java | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index e947640b1..36103dc30 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=0.8.0-SNAPSHOT +VERSION_NAME=0.8.1-SNAPSHOT VERSION_CODE=1 GROUP=org.smartregister POM_SETTING_DESCRIPTION=OpenSRP Client Child Library diff --git a/opensrp-child/src/main/java/org/smartregister/child/util/ChildJsonFormUtils.java b/opensrp-child/src/main/java/org/smartregister/child/util/ChildJsonFormUtils.java index 3fb99e6e4..810cf339f 100644 --- a/opensrp-child/src/main/java/org/smartregister/child/util/ChildJsonFormUtils.java +++ b/opensrp-child/src/main/java/org/smartregister/child/util/ChildJsonFormUtils.java @@ -819,18 +819,25 @@ public static Event addMetaData(Context context, Event event, Date start) { return event; } - /** - * Tag an event with metadata fields LocationId, ChildLocationId, Data strategy in use, Team, TeamId, Database Version and Client App Version - * - * @param event to tag - * @return Tagged event - */ public static Event tagSyncMetadata(@NonNull Event event) { + return tagSyncMetadata(event, null); + } + /** + * Tag an event with metadata fields LocationId, ChildLocationId, Data strategy in use, Team, TeamId, Database Version and Client App Version + * + * @param event to tag + * @param locationId for event + * @return Tagged event + */ + public static Event tagSyncMetadata(@NonNull Event event, String locationId) { AllSharedPreferences allSharedPreferences = Utils.getAllSharedPreferences(); String providerId = allSharedPreferences.fetchRegisteredANM(); event.setProviderId(providerId); - event.setLocationId(getProviderLocationId(ChildLibrary.getInstance().context().applicationContext())); + if (locationId != null) { + event.setLocationId(locationId); + } else + event.setLocationId(getProviderLocationId(ChildLibrary.getInstance().context().applicationContext())); String childLocationId = getChildLocationId(allSharedPreferences.fetchDefaultLocalityId(providerId), allSharedPreferences); event.setChildLocationId(childLocationId); @@ -965,7 +972,7 @@ public static ChildEventClient processChildDetailsForm(String jsonString, FormTa } } - ChildJsonFormUtils.tagSyncMetadata(baseEvent);// tag docs + ChildJsonFormUtils.tagSyncMetadata(baseEvent, getFieldValue(fields, Constants.HOME_FACILITY));// tag docs //Add previous relational ids if they existed. addRelationships(baseClient, jsonString);