diff --git a/opensrp-anc/build.gradle b/opensrp-anc/build.gradle
index 74142a1..ce04d81 100644
--- a/opensrp-anc/build.gradle
+++ b/opensrp-anc/build.gradle
@@ -191,7 +191,7 @@ dependencies {
exclude group: 'org.yaml', module: 'snakeyaml'
exclude group: 'io.ona.rdt-capture', module: 'lib'
}
- implementation('org.smartregister:opensrp-client-core:6.1.2-SNAPSHOT@aar') {
+ implementation('org.smartregister:opensrp-client-core:6.1.5-ALPHA8-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.github.bmelnychuk', module: 'atv'
exclude group: 'com.google.guava', module: 'guava'
@@ -259,6 +259,7 @@ dependencies {
implementation 'org.jacoco:org.jacoco.agent:0.8.7:runtime'
testImplementation 'org.jacoco:org.jacoco.agent:0.8.7:runtime'
implementation 'org.smartregister:android-p2p-sync:0.4.0-DEV-SNAPSHOT'
+ implementation 'com.fasterxml.jackson.datatype:jackson-datatype-joda'
testImplementation 'junit:junit:4.13.1'
testImplementation 'org.apache.maven:maven-ant-tasks:2.1.3'
@@ -283,6 +284,7 @@ dependencies {
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') {
exclude group: 'com.google.code.findbugs'
}
+ debugImplementation 'com.amitshekhar.android:debug-db-encrypt:1.0.6'
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', /*'createDebugCoverageReport'*/]) {
diff --git a/opensrp-anc/src/main/AndroidManifest.xml b/opensrp-anc/src/main/AndroidManifest.xml
index 42c1376..815925e 100644
--- a/opensrp-anc/src/main/AndroidManifest.xml
+++ b/opensrp-anc/src/main/AndroidManifest.xml
@@ -38,7 +38,9 @@
android:name="org.smartregister.sync.intent.P2pProcessRecordsService"
android:description="@string/component_desc_p2p_process_records_service"
android:exported="false" />
-
+
\ No newline at end of file
diff --git a/opensrp-anc/src/main/assets/config/profile-overview.yml b/opensrp-anc/src/main/assets/config/profile-overview.yml
index 2634781..9ecdf65 100644
--- a/opensrp-anc/src/main/assets/config/profile-overview.yml
+++ b/opensrp-anc/src/main/assets/config/profile-overview.yml
@@ -14,9 +14,9 @@ fields:
---
sub_group: current_pregnancy
fields:
- - template: "{{profile_overview.overview_of_pregnancy.current_pregnancy.ga}}: {gest_age}"
- relevance: "gest_age != ''"
- isRedFont: "gest_age > 40"
+ - template: "{{profile_overview.overview_of_pregnancy.current_pregnancy.ga}}: {current_gest_age}"
+ relevance: "current_gest_age != ''"
+ isRedFont: "current_gest_age > 40"
- template: "{{profile_overview.overview_of_pregnancy.current_pregnancy.edd}}: {edd}"
relevance: "edd != ''"
diff --git a/opensrp-anc/src/main/assets/ec_client_fields.json b/opensrp-anc/src/main/assets/ec_client_fields.json
index f9ecca1..bb127ce 100644
--- a/opensrp-anc/src/main/assets/ec_client_fields.json
+++ b/opensrp-anc/src/main/assets/ec_client_fields.json
@@ -209,8 +209,7 @@
"field": "attributes.sector"
}
- }
- ,
+ },
{
"column_name": "cell",
"type": "Client",
@@ -231,6 +230,13 @@
"json_mapping": {
"field": "attributes.visit_start_date"
}
+ },
+ {
+ "column_name": "visit_date",
+ "type": "Client",
+ "json_mapping": {
+ "field": "attributes.visit_date"
+ }
}
]
},
@@ -299,6 +305,13 @@
"json_mapping": {
"field": "addresses.address2"
}
+ },
+ {
+ "column_name": "data_migration_is_dirty",
+ "type": "Client",
+ "json_mapping": {
+ "field": "attributes.data_migration_is_dirty"
+ }
}
]
}
diff --git a/opensrp-anc/src/main/assets/json.form/anc_quick_check.json b/opensrp-anc/src/main/assets/json.form/anc_quick_check.json
index ccc98ec..93f680d 100644
--- a/opensrp-anc/src/main/assets/json.form/anc_quick_check.json
+++ b/opensrp-anc/src/main/assets/json.form/anc_quick_check.json
@@ -104,7 +104,7 @@
"type": "date_picker",
"hint": "Date of Contact",
"expanded": "false",
- "min_date": "today-1m",
+ "min_date": "today-6m",
"max_date": "today",
"v_required": {
"value": true,
diff --git a/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/BaseHomeRegisterActivity.java b/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/BaseHomeRegisterActivity.java
index f0a9462..8bf85e7 100644
--- a/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/BaseHomeRegisterActivity.java
+++ b/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/BaseHomeRegisterActivity.java
@@ -16,6 +16,7 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
+import com.amitshekhar.DebugDB;
import com.google.android.gms.vision.barcode.Barcode;
import com.google.android.material.bottomnavigation.LabelVisibilityMode;
import com.vijay.jsonwizard.activities.FormConfigurationJsonFormActivity;
@@ -28,6 +29,7 @@
import org.json.JSONObject;
import org.smartregister.AllConstants;
import org.smartregister.anc.library.AncLibrary;
+import org.smartregister.anc.library.BuildConfig;
import org.smartregister.anc.library.R;
import org.smartregister.anc.library.contract.RegisterContract;
import org.smartregister.anc.library.domain.AttentionFlag;
diff --git a/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/ProfileActivity.java b/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/ProfileActivity.java
index 402b44f..fc5af25 100644
--- a/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/ProfileActivity.java
+++ b/opensrp-anc/src/main/java/org/smartregister/anc/library/activity/ProfileActivity.java
@@ -3,11 +3,13 @@
import android.Manifest;
import android.app.Activity;
import android.app.AlertDialog;
+import android.content.ContentValues;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
+import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -17,16 +19,25 @@
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
+import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
+
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
+import org.joda.time.LocalDate;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.smartregister.anc.library.AncLibrary;
import org.smartregister.anc.library.R;
import org.smartregister.anc.library.adapter.ProfileViewPagerAdapter;
@@ -37,18 +48,31 @@
import org.smartregister.anc.library.fragment.ProfileOverviewFragment;
import org.smartregister.anc.library.fragment.ProfileTasksFragment;
import org.smartregister.anc.library.presenter.ProfilePresenter;
+import org.smartregister.anc.library.repository.PatientRepository;
+import org.smartregister.anc.library.rule.ContactRule;
+import org.smartregister.anc.library.sync.BaseAncClientProcessorForJava;
+import org.smartregister.anc.library.task.RegenerateContactSchedulesTask;
import org.smartregister.anc.library.util.ANCJsonFormUtils;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.DBConstantsUtils;
import org.smartregister.anc.library.util.Utils;
import org.smartregister.anc.library.view.CopyToClipboardDialog;
+import org.smartregister.domain.Event;
import org.smartregister.repository.AllSharedPreferences;
import org.smartregister.util.PermissionUtils;
import org.smartregister.util.StringUtil;
import org.smartregister.view.activity.BaseProfileActivity;
import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Calendar;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
import timber.log.Timber;
@@ -118,8 +142,10 @@ private void getButtonAlertStatus() {
detailMap = (HashMap) getIntent().getSerializableExtra(ConstantsUtils.IntentKeyUtils.CLIENT_MAP);
contactNo = String.valueOf(Utils.getTodayContact(detailMap.get(DBConstantsUtils.KeyUtils.NEXT_CONTACT)));
buttonAlertStatus = Utils.processContactDoneToday(detailMap.get(DBConstantsUtils.KeyUtils.LAST_CONTACT_RECORD_DATE),
- ConstantsUtils.AlertStatusUtils.ACTIVE.equals(detailMap.get(DBConstantsUtils.KeyUtils.CONTACT_STATUS)) ?
- ConstantsUtils.AlertStatusUtils.IN_PROGRESS : "");
+ ConstantsUtils.AlertStatusUtils.ACTIVE.equals(detailMap.get(DBConstantsUtils.KeyUtils.CONTACT_STATUS)) ?
+ ConstantsUtils.AlertStatusUtils.IN_PROGRESS : "");
+
+
}
protected void updateTasksTabTitle() {
@@ -151,12 +177,18 @@ protected ViewPager setupViewPager(ViewPager viewPager) {
public void onClick(View view) {
if (view.getId() == R.id.profile_overview_due_button) {
String baseEntityId = getIntent().getStringExtra(ConstantsUtils.IntentKeyUtils.BASE_ENTITY_ID);
-
- if (StringUtils.isNotBlank(baseEntityId)) {
- Utils.proceedToContact(baseEntityId, detailMap, getActivity());
- finish();
+ Object viewTag = view.getTag(R.string.regenerate_contact_schedule);
+ if (viewTag!= null && (viewTag).equals(ConstantsUtils.AlertStatusUtils.REGENERATE)) {
+ new RegenerateContactSchedulesTask(getActivity(), baseEntityId).execute();
+ } else {
+ if (StringUtils.isNotBlank(baseEntityId)) {
+ Utils.proceedToContact(baseEntityId, detailMap, getActivity());
+ finish();
+ }
}
+
+
} else {
super.onClick(view);
}
@@ -394,4 +426,5 @@ public Button getDueButton() {
public ProfilePresenter getProfilePresenter() {
return (ProfilePresenter) presenter;
}
+
}
diff --git a/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileContactsFragment.java b/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileContactsFragment.java
index c92b5e3..4226368 100644
--- a/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileContactsFragment.java
+++ b/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileContactsFragment.java
@@ -1,6 +1,9 @@
package org.smartregister.anc.library.fragment;
+import android.app.Activity;
+import android.content.ContentValues;
import android.content.Intent;
+import android.os.AsyncTask;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
@@ -10,13 +13,21 @@
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
-import org.apache.commons.lang3.StringUtils;
+import android.widget.Toast;
+
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
-import org.apache.commons.lang3.StringUtils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.datatype.joda.JodaModule;
+
import org.jeasy.rules.api.Facts;
+import org.joda.time.LocalDate;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
import org.smartregister.anc.library.AncLibrary;
import org.smartregister.anc.library.R;
import org.smartregister.anc.library.activity.PreviousContactsDetailsActivity;
@@ -29,25 +40,33 @@
import org.smartregister.anc.library.domain.YamlConfig;
import org.smartregister.anc.library.domain.YamlConfigItem;
import org.smartregister.anc.library.domain.YamlConfigWrapper;
-import org.smartregister.anc.library.model.PreviousContact;
import org.smartregister.anc.library.model.Task;
import org.smartregister.anc.library.presenter.ProfileFragmentPresenter;
+import org.smartregister.anc.library.repository.PatientRepository;
+import org.smartregister.anc.library.rule.ContactRule;
+import org.smartregister.anc.library.sync.BaseAncClientProcessorForJava;
import org.smartregister.anc.library.util.ANCJsonFormUtils;
-import org.smartregister.anc.library.util.AppExecutors;
import org.smartregister.anc.library.util.ConstantsUtils;
import org.smartregister.anc.library.util.DBConstantsUtils;
import org.smartregister.anc.library.util.FilePathUtils;
import org.smartregister.anc.library.util.Utils;
+import org.smartregister.domain.Event;
import org.smartregister.view.fragment.BaseProfileFragment;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
import timber.log.Timber;
@@ -108,7 +127,9 @@ protected void onCreation() {
clientDetails =
(HashMap) getActivity().getIntent().getSerializableExtra(ConstantsUtils.IntentKeyUtils.CLIENT_MAP);
}
+
buttonAlertStatus = Utils.getButtonAlertStatus(clientDetails, getActivity(), true);
+
}
}
@@ -183,51 +204,52 @@ private void populatePreviousContactMissingEssentials(HashMap cl
}
private void setUpAlertStatusButton() {
+// if (clientDetails.get(ConstantsUtils.DATA_MIGRATION_IS_DIRTY) != null && clientDetails.get(ConstantsUtils.DATA_MIGRATION_IS_DIRTY).equals("1")) {
+// buttonAlertStatus.buttonAlertStatus = ConstantsUtils.AlertStatusUtils.REGENERATE;
+// }
Utils.processButtonAlertStatus(getActivity(), dueButton, buttonAlertStatus);
+
}
private void initializeLastContactDetails(HashMap clientDetails) {
if (clientDetails != null) {
- List lastContactDetailsWrapperList = new ArrayList<>();
- List lastContactDetailsTestsWrapperList = new ArrayList<>();
- Facts facts = presenter.getImmediatePreviousContact(clientDetails, baseEntityId, contactNo);
- try {
- addOtherRuleObjects(facts);
- addAttentionFlagsRuleObjects(facts);
- contactNo = (String) facts.asMap().get(ConstantsUtils.CONTACT_NO);
-
- addTestsRuleObjects(facts);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
+ List lastContactDetailsWrapperList = new ArrayList<>();
+ List lastContactDetailsTestsWrapperList = new ArrayList<>();
+ Facts facts = presenter.getImmediatePreviousContact(clientDetails, baseEntityId, contactNo);
+ try {
+ addOtherRuleObjects(facts);
+ addAttentionFlagsRuleObjects(facts);
+ contactNo = (String) facts.asMap().get(ConstantsUtils.CONTACT_NO);
+
+ addTestsRuleObjects(facts);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
String displayContactDate = "";
- // Extract visit date from facts
- String manualEncounterDate = (String) facts.asMap().get(ConstantsUtils.JsonFormKeyUtils.VISIT_DATE);
+ // If no visit date, try to get contact date
+ String contactDate = (String) facts.asMap().get(ConstantsUtils.JsonFormKeyUtils.VISIT_DATE);
+ if (contactDate != null) {
+ contactDate = Utils.reverseHyphenSeperatedValues(contactDate, "-");
+ } else {
+ contactDate =
+ clientDetails.get(DBConstantsUtils.KeyUtils.LAST_CONTACT_RECORD_DATE) != null ?
+ clientDetails.get(DBConstantsUtils.KeyUtils.LAST_CONTACT_RECORD_DATE) :
+ (String) facts.asMap().get(ConstantsUtils.CONTACT_DATE);
+ }
+
- if (!TextUtils.isEmpty(manualEncounterDate)) {
- // If there's a visit date, parse it and format for display
+ if (!TextUtils.isEmpty(contactDate)) {
+ // If contact date exists, parse and format for display
try {
- Date lastContactDate = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).parse(manualEncounterDate);
+ Date lastContactDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(contactDate);
displayContactDate = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(lastContactDate);
} catch (ParseException e) {
// Handle parsing exceptions
throw new RuntimeException(e);
}
- } else {
- // If no visit date, try to get contact date
- String contactDate = (String) facts.asMap().get(ConstantsUtils.CONTACT_DATE);
- if (!TextUtils.isEmpty(contactDate)) {
- // If contact date exists, parse and format for display
- try {
- Date lastContactDate = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).parse(contactDate);
- displayContactDate = new SimpleDateFormat("dd MMM yyyy", Locale.getDefault()).format(lastContactDate);
- } catch (ParseException e) {
- // Handle parsing exceptions
- throw new RuntimeException(e);
- }
- }
+
}
if (lastContactDetails.isEmpty()) {
@@ -360,9 +382,9 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
dueButton = ((ProfileActivity) getActivity()).getDueButton();
// if (!ConstantsUtils.AlertStatusUtils.TODAY.equals(buttonAlertStatus.buttonAlertStatus)) {
- dueButton.setOnClickListener((ProfileActivity) getActivity());
+ dueButton.setOnClickListener((ProfileActivity) getActivity());
// } else {
- dueButton.setEnabled(true);
+ dueButton.setEnabled(true);
// }
return fragmentView;
@@ -421,4 +443,6 @@ public void onClick(View view) {
}
}
+
+
}
diff --git a/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileOverviewFragment.java b/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileOverviewFragment.java
index 385e654..442f96c 100644
--- a/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileOverviewFragment.java
+++ b/opensrp-anc/src/main/java/org/smartregister/anc/library/fragment/ProfileOverviewFragment.java
@@ -10,6 +10,9 @@
import androidx.recyclerview.widget.RecyclerView;
import org.jeasy.rules.api.Facts;
+import org.joda.time.DateTime;
+import org.joda.time.format.DateTimeFormat;
+import org.joda.time.format.DateTimeFormatter;
import org.smartregister.anc.library.AncLibrary;
import org.smartregister.anc.library.R;
import org.smartregister.anc.library.activity.ProfileActivity;
@@ -97,6 +100,28 @@ protected void onResumption() {
fetchContactAndAlertStatus();
yamlConfigListGlobal = new ArrayList<>(); //This makes sure no data duplication happens
Facts facts = presenter.getImmediatePreviousContact(clientDetails, baseEntityId, contactNo);
+ String usgEdd = facts.get("ultrasound_edd").toString();
+ String lmpEdd = facts.get("lmp_edd").toString();
+ String sfhEdd = facts.get("sfh_edd").toString();
+ String eddDate = !usgEdd.isEmpty() && !usgEdd.equals("0")?
+ usgEdd: !lmpEdd.isEmpty() && !lmpEdd.equals("0")? lmpEdd:
+ sfhEdd;
+
+ // Define the date format pattern from ConstantsUtils
+ String pattern = ConstantsUtils.OPENSRP_DATE_TIME_FORMAT;
+
+ // Create a DateTimeFormatter with the pattern
+ DateTimeFormatter formatter = DateTimeFormat.forPattern(pattern);
+
+ // Get the current date and time
+ DateTime now = new DateTime();
+
+ // Format the current date and time as a string
+ String todaysDateString = now.toString(formatter);
+ String currentGestAge = Utils.calculateGaBasedOnUltrasoundEdd(eddDate, todaysDateString);
+
+// String currentGestAge = updateGaAsOfTodaysDate(facts);
+ facts.put("current_gest_age", currentGestAge);
Iterable