From 85733c8e208c115619ff0b2628588427cd2fc42a Mon Sep 17 00:00:00 2001 From: cozej4 Date: Tue, 9 Jun 2020 15:14:58 +0300 Subject: [PATCH 0001/2456] Implemented hiv and tb registers --- opensrp-chw-hf/build.gradle | 6 +- opensrp-chw-hf/src/main/AndroidManifest.xml | 17 ++ .../main/assets/ec_client_classification.json | 21 +++ .../src/main/assets/ec_client_fields.json | 153 ++++++++++++++++ .../chw/hf/HealthFacilityApplication.java | 17 ++ .../FamilyOtherMemberProfileActivity.java | 11 ++ .../hf/activity/FamilyProfileActivity.java | 12 ++ .../chw/hf/activity/HivProfileActivity.java | 164 +++++++++++++++++ .../chw/hf/activity/HivRegisterActivity.java | 78 ++++++++ .../hf/activity/PncMemberProfileActivity.java | 11 ++ .../chw/hf/activity/TbProfileActivity.java | 171 ++++++++++++++++++ .../chw/hf/activity/TbRegisterActivity.java | 70 +++++++ .../chw/hf/contract/HivProfileContract.java | 24 +++ .../chw/hf/contract/TbProfileContract.java | 24 +++ .../chw/hf/fragment/HivRegisterFragment.java | 65 +++++++ .../chw/hf/fragment/TbRegisterFragment.java | 64 +++++++ .../hf/interactor/HfHivProfileInteractor.java | 36 ++++ .../hf/interactor/HfTbProfileInteractor.java | 36 ++++ .../hf/model/HivRegisterFragmentModel.java | 56 ++++++ .../chw/hf/model/NavigationModel.java | 2 + .../chw/hf/model/TbRegisterFragmentModel.java | 56 ++++++ .../chw/hf/presenter/HivProfilePresenter.java | 34 ++++ .../HivRegisterFragmentPresenter.java | 37 ++++ .../chw/hf/presenter/TbProfilePresenter.java | 34 ++++ .../TbRegisterFragmentPresenter.java | 38 ++++ .../hf/provider/HfHivRegisterProvider.java | 54 ++++++ .../chw/hf/provider/HfTbRegisterProvider.java | 54 ++++++ .../layout/hf_hiv_register_list_row_item.xml | 125 +++++++++++++ .../layout/hf_tb_register_list_row_item.xml | 124 +++++++++++++ .../src/main/res/mipmap-hdpi/sidemenu_tb.png | Bin 0 -> 3468 bytes .../res/mipmap-hdpi/sidemenu_tb_active.png | Bin 0 -> 3645 bytes .../src/main/res/mipmap-mdpi/sidemenu_tb.png | Bin 0 -> 2090 bytes .../res/mipmap-mdpi/sidemenu_tb_active.png | Bin 0 -> 2211 bytes .../src/main/res/mipmap-xhdpi/sidemenu_tb.png | Bin 0 -> 4837 bytes .../res/mipmap-xhdpi/sidemenu_tb_active.png | Bin 0 -> 5137 bytes .../main/res/mipmap-xxhdpi/sidemenu_tb.png | Bin 0 -> 8028 bytes .../res/mipmap-xxhdpi/sidemenu_tb_active.png | Bin 0 -> 8488 bytes .../main/res/mipmap-xxxhdpi/sidemenu_tb.png | Bin 0 -> 11490 bytes .../res/mipmap-xxxhdpi/sidemenu_tb_active.png | Bin 0 -> 12112 bytes 39 files changed, 1591 insertions(+), 3 deletions(-) create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivProfileActivity.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivRegisterActivity.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbProfileActivity.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbRegisterActivity.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/HivProfileContract.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/TbProfileContract.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/HivRegisterFragment.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/TbRegisterFragment.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfHivProfileInteractor.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfTbProfileInteractor.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/HivRegisterFragmentModel.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/TbRegisterFragmentModel.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivProfilePresenter.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivRegisterFragmentPresenter.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbProfilePresenter.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbRegisterFragmentPresenter.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfHivRegisterProvider.java create mode 100644 opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfTbRegisterProvider.java create mode 100644 opensrp-chw-hf/src/main/res/layout/hf_hiv_register_list_row_item.xml create mode 100644 opensrp-chw-hf/src/main/res/layout/hf_tb_register_list_row_item.xml create mode 100644 opensrp-chw-hf/src/main/res/mipmap-hdpi/sidemenu_tb.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-hdpi/sidemenu_tb_active.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-mdpi/sidemenu_tb.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-mdpi/sidemenu_tb_active.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xhdpi/sidemenu_tb.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xhdpi/sidemenu_tb_active.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xxhdpi/sidemenu_tb.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xxhdpi/sidemenu_tb_active.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xxxhdpi/sidemenu_tb.png create mode 100644 opensrp-chw-hf/src/main/res/mipmap-xxxhdpi/sidemenu_tb_active.png diff --git a/opensrp-chw-hf/build.gradle b/opensrp-chw-hf/build.gradle index 27ae311e4..b2c834e48 100644 --- a/opensrp-chw-hf/build.gradle +++ b/opensrp-chw-hf/build.gradle @@ -35,8 +35,8 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled true buildConfigField "String", 'opensrp_url', '"https://boresha-afya.smartregister.org/opensrp/"' - buildConfigField "String", 'opensrp_url_debug', '"https://boresha-afya-stage.smartregister.org/opensrp/"' -// buildConfigField "String", 'opensrp_url_debug', '"https://ba-unified-stage.smartregister.org/opensrp/"' +// buildConfigField "String", 'opensrp_url_debug', '"https://boresha-afya-stage.smartregister.org/opensrp/"' + buildConfigField "String", 'opensrp_url_debug', '"https://ba-unified-stage.smartregister.org/opensrp/"' buildConfigField "boolean", 'SUPPORT_QR', 'true' buildConfigField "int", "DATABASE_VERSION", '9' buildConfigField "int", "DATA_SYNC_DURATION_MINUTES", '15' @@ -119,7 +119,7 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation('org.smartregister:opensrp-client-chw-core:1.2.11-SNAPSHOT@aar') { + implementation('org.smartregister:opensrp-client-chw-core:1.3.0-Test-SNAPSHOT@aar') { transitive = true exclude group: 'org.smartregister', module: 'opensrp-client-chw-referral' exclude group: 'com.rengwuxian.materialedittext', module: 'library' diff --git a/opensrp-chw-hf/src/main/AndroidManifest.xml b/opensrp-chw-hf/src/main/AndroidManifest.xml index e9ae9581d..67d1e2a87 100644 --- a/opensrp-chw-hf/src/main/AndroidManifest.xml +++ b/opensrp-chw-hf/src/main/AndroidManifest.xml @@ -194,6 +194,23 @@ android:theme="@style/HFTheme.NoActionBar" /> + + + + + + + + + diff --git a/opensrp-chw-hf/src/main/assets/ec_client_classification.json b/opensrp-chw-hf/src/main/assets/ec_client_classification.json index 3c39f4c53..987d8546f 100644 --- a/opensrp-chw-hf/src/main/assets/ec_client_classification.json +++ b/opensrp-chw-hf/src/main/assets/ec_client_classification.json @@ -248,6 +248,27 @@ "creates_case": [ "ec_family_planning_update" ] + }, + { + "field": "eventType", + "field_value": "Hiv Registration", + "creates_case": [ + "ec_hiv_register" + ] + }, + { + "field": "eventType", + "field_value": "Tb Registration", + "creates_case": [ + "ec_tb_register" + ] + }, + { + "field": "eventType", + "field_value": "TB Case Closure", + "creates_case": [ + "ec_tb_register" + ] } ] } diff --git a/opensrp-chw-hf/src/main/assets/ec_client_fields.json b/opensrp-chw-hf/src/main/assets/ec_client_fields.json index a869529a7..9f5cf5639 100644 --- a/opensrp-chw-hf/src/main/assets/ec_client_fields.json +++ b/opensrp-chw-hf/src/main/assets/ec_client_fields.json @@ -2278,6 +2278,159 @@ } } ] + }, + { + "name": "ec_hiv_register", + "columns": [ + { + "column_name": "base_entity_id", + "type": "Event", + "json_mapping": { + "field": "baseEntityId" + } + }, + { + "column_name": "relational_id", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "relational_id" + } + }, + { + "column_name": "last_interacted_with", + "type": "Event", + "json_mapping": { + "field": "version" + } + }, + { + "column_name": "ctc_number", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "ctc_number" + } + }, + { + "column_name": "cbhs_number", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "cbhs_number" + } + }, + { + "column_name": "client_hiv_status_during_registration", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "client_hiv_status_during_registration" + } + }, + { + "column_name": "client_hiv_status_after_testing", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "client_hiv_status_after_testing" + } + }, + { + "column_name": "hiv_registration_date", + "type": "Event", + "data_type": "date", + "json_mapping": { + "field": "obs.formSubmissionField", + "concept": "hiv_registration_date" + } + } + ] + }, + { + "name": "ec_tb_register", + "columns": [ + { + "column_name": "base_entity_id", + "type": "Event", + "json_mapping": { + "field": "baseEntityId" + } + }, + { + "column_name": "relational_id", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "relational_id" + } + }, + { + "column_name": "last_interacted_with", + "type": "Event", + "json_mapping": { + "field": "version" + } + }, + { + "column_name": "community_client_tb_registration_number", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "community_client_tb_registration_number" + } + }, + { + "column_name": "client_tb_status_during_registration", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "client_tb_status_during_registration" + } + }, + { + "column_name": "client_tb_status_after_testing", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "client_tb_status_after_testing" + } + }, + { + "column_name": "place_of_domicile", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "place_of_domicile" + } + }, + { + "column_name": "client_tb_screening_results", + "type": "Event", + "json_mapping": { + "field": "obs.fieldCode", + "concept": "client_tb_screening_results" + } + }, + { + "column_name": "tb_registration_date", + "type": "Event", + "data_type": "date", + "json_mapping": { + "field": "obs.formSubmissionField", + "concept": "tb_registration_date" + } + }, + { + "column_name": "tb_case_closure_date", + "type": "Event", + "data_type": "date", + "json_mapping": { + "field": "obs.formSubmissionField", + "concept": "tb_case_closure_date" + } + } + ] } ] } \ No newline at end of file diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java index 94b37ea61..8005e159a 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/HealthFacilityApplication.java @@ -30,10 +30,12 @@ import org.smartregister.chw.hf.activity.FamilyProfileActivity; import org.smartregister.chw.hf.activity.FamilyRegisterActivity; import org.smartregister.chw.hf.activity.FpRegisterActivity; +import org.smartregister.chw.hf.activity.HivRegisterActivity; import org.smartregister.chw.hf.activity.LoginActivity; import org.smartregister.chw.hf.activity.MalariaRegisterActivity; import org.smartregister.chw.hf.activity.PncRegisterActivity; import org.smartregister.chw.hf.activity.ReferralRegisterActivity; +import org.smartregister.chw.hf.activity.TbRegisterActivity; import org.smartregister.chw.hf.configs.AllClientsRegisterRowOptions; import org.smartregister.chw.hf.custom_view.HfNavigationMenu; import org.smartregister.chw.hf.job.HfJobCreator; @@ -41,8 +43,10 @@ import org.smartregister.chw.hf.repository.HfChwRepository; import org.smartregister.chw.hf.repository.HfTaskRepository; import org.smartregister.chw.hf.sync.HfSyncConfiguration; +import org.smartregister.chw.hiv.HivLibrary; import org.smartregister.chw.malaria.MalariaLibrary; import org.smartregister.chw.pnc.PncLibrary; +import org.smartregister.chw.tb.TbLibrary; import org.smartregister.configurableviews.ConfigurableViewsLibrary; import org.smartregister.configurableviews.helper.JsonSpecHelper; import org.smartregister.family.FamilyLibrary; @@ -100,6 +104,8 @@ public String getDefaultLocationLevel() { registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.ALL_CLIENTS_REGISTERED_ACTIVITY, AllClientsRegisterActivity.class); registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.MALARIA_REGISTER_ACTIVITY, MalariaRegisterActivity.class); registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.FP_REGISTER_ACTIVITY, FpRegisterActivity.class); + registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.HIV_REGISTER_ACTIVITY, HivRegisterActivity.class); + registeredActivities.put(CoreConstants.REGISTERED_ACTIVITIES.TB_REGISTER_ACTIVITY, TbRegisterActivity.class); return registeredActivities; } @@ -180,6 +186,17 @@ public void onCreate() { PncLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); MalariaLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); FpLibrary.init(context, getRepository(), BuildConfig.VERSION_CODE, BuildConfig.DATABASE_VERSION); + + //Setup hiv library + HivLibrary.init(this); + HivLibrary.getInstance().setAppVersion(BuildConfig.VERSION_CODE); + HivLibrary.getInstance().setDatabaseVersion(BuildConfig.DATABASE_VERSION); + + //Setup tb library + TbLibrary.init(this); + TbLibrary.getInstance().setAppVersion(BuildConfig.VERSION_CODE); + TbLibrary.getInstance().setDatabaseVersion(BuildConfig.DATABASE_VERSION); + //Needed for all clients register OpdLibrary.init(context, getRepository(), new OpdConfiguration.Builder(CoreAllClientsRegisterQueryProvider.class) diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyOtherMemberProfileActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyOtherMemberProfileActivity.java index 6bea8b35e..f1c5fd9f9 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyOtherMemberProfileActivity.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyOtherMemberProfileActivity.java @@ -30,6 +30,7 @@ import timber.log.Timber; +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; import static org.smartregister.chw.core.utils.Utils.updateToolbarTitle; public class FamilyOtherMemberProfileActivity extends CoreFamilyOtherMemberProfileActivity { @@ -76,6 +77,16 @@ protected void startMalariaRegister() { //TODO implement start malaria register for HF } + @Override + protected void startHivRegister() { + HivRegisterActivity.startHIVFormActivity(this, baseEntityId,CoreConstants.JSON_FORM.getHivRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivRegistration()).toString()); + } + + @Override + protected void startTbRegister() { + TbRegisterActivity.startTbFormActivity(this, baseEntityId,CoreConstants.JSON_FORM.getTbRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbRegistration()).toString()); + } + @Override protected void startMalariaFollowUpVisit() { // TODO -> Implement for HF diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyProfileActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyProfileActivity.java index 792958418..4261637c6 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyProfileActivity.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/FamilyProfileActivity.java @@ -25,6 +25,8 @@ import java.util.HashMap; +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; + public class FamilyProfileActivity extends CoreFamilyProfileActivity { @Override @@ -112,6 +114,16 @@ protected void goToFpProfile(String baseEntityId, Activity activity) { FamilyPlanningMemberProfileActivity.startFpMemberProfileActivity(activity, FpDao.getMember(baseEntityId)); } + @Override + protected void goToHivProfile(String baseEntityId, Activity activity) { + HivRegisterActivity.startHIVFormActivity(this, baseEntityId,CoreConstants.JSON_FORM.getHivRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivRegistration()).toString()); + } + + @Override + protected void goToTbProfile(String baseEntityId, Activity activity) { + TbRegisterActivity.startTbFormActivity(this, baseEntityId,CoreConstants.JSON_FORM.getTbRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbRegistration()).toString()); + } + @Override protected boolean isAncMember(String baseEntityId) { return getFamilyProfilePresenter().isAncMember(baseEntityId); diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivProfileActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivProfileActivity.java new file mode 100644 index 000000000..ee8040da8 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivProfileActivity.java @@ -0,0 +1,164 @@ +package org.smartregister.chw.hf.activity; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; + +import org.smartregister.chw.core.activity.CoreHivProfileActivity; +import org.smartregister.chw.core.activity.CoreHivUpcomingServicesActivity; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.hf.adapter.ReferralCardViewAdapter; +import org.smartregister.chw.hf.contract.HivProfileContract; +import org.smartregister.chw.hf.interactor.HfHivProfileInteractor; +import org.smartregister.chw.hf.presenter.HivProfilePresenter; +import org.smartregister.chw.hiv.activity.BaseHivRegistrationFormsActivity; +import org.smartregister.chw.hiv.domain.HivMemberObject; +import org.smartregister.chw.hiv.util.HivUtil; +import org.smartregister.chw.tb.util.Constants; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.domain.Task; + +import java.util.Date; +import java.util.Set; + +import static android.view.View.GONE; +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; + +public class HivProfileActivity extends CoreHivProfileActivity implements HivProfileContract.View { + + private CommonPersonObjectClient commonPersonObjectClient; + + public static void startHivProfileActivity(Activity activity, HivMemberObject memberObject) { + Intent intent = new Intent(activity, HivProfileActivity.class); + intent.putExtra(Constants.ActivityPayload.MEMBER_OBJECT, memberObject); + activity.startActivity(intent); + } + + public static void startHivFollowupActivity(Activity activity, String baseEntityID) { + Intent intent = new Intent(activity, BaseHivRegistrationFormsActivity.class); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.BASE_ENTITY_ID, baseEntityID); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.JSON_FORM, getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivFollowupVisit()).toString()); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.ACTION, Constants.ActivityPayloadType.FOLLOW_UP_VISIT); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.USE_DEFAULT_NEAT_FORM_LAYOUT, false); + + activity.startActivityForResult(intent, org.smartregister.chw.anc.util.Constants.REQUEST_CODE_HOME_VISIT); + } + + public void setReferralTasks(Set taskList) { + if (notificationAndReferralRecyclerView != null && taskList.size() > 0) { + RecyclerView.Adapter mAdapter = new ReferralCardViewAdapter(taskList, this, getCommonPersonObjectClient(), CoreConstants.REGISTERED_ACTIVITIES.FP_REGISTER_ACTIVITY); + notificationAndReferralRecyclerView.setAdapter(mAdapter); + notificationAndReferralLayout.setVisibility(View.VISIBLE); + findViewById(R.id.view_notification_and_referral_row).setVisibility(View.VISIBLE); + } + } + + @Override + protected void onCreation() { + super.onCreation(); + setCommonPersonObjectClient(getClientDetailsByBaseEntityID(getHivMemberObject().getBaseEntityId())); + } + + @Override + protected void onResume() { + super.onResume(); + ((HivProfileContract.Presenter) getHivProfilePresenter()).fetchReferralTasks(); + if (notificationAndReferralRecyclerView != null && notificationAndReferralRecyclerView.getAdapter() != null) { + notificationAndReferralRecyclerView.getAdapter().notifyDataSetChanged(); + } + } + + public CommonPersonObjectClient getCommonPersonObjectClient() { + return commonPersonObjectClient; + } + + public void setCommonPersonObjectClient(CommonPersonObjectClient commonPersonObjectClient) { + this.commonPersonObjectClient = commonPersonObjectClient; + } + + @Override + protected void initializePresenter() { + showProgressBar(true); + setHivProfilePresenter(new HivProfilePresenter(this, new HfHivProfileInteractor(this), getHivMemberObject())); + fetchProfileData(); + } + + + @Override + public void updateLastVisitRow(Date lastVisitDate){ + //overriding showing of last visit row + } + @Override + public void setupFollowupVisitEditViews(boolean isWithin24Hours){ + //overriding setupFollowupVisitEditViews row + } + + + @Override + public void openHivRegistrationForm() { + HivRegisterActivity.startHIVFormActivity(this, getHivMemberObject().getBaseEntityId(), CoreConstants.JSON_FORM.getHivRegistration(), getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivRegistration()).toString()); + } + + @Override + public void openUpcomingServices() { + CoreHivUpcomingServicesActivity.startMe(this, HivUtil.toMember(getHivMemberObject())); + } + + @Override + public void openFamilyDueServices() { + Intent intent = new Intent(this, FamilyProfileActivity.class); + + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_BASE_ENTITY_ID, getHivMemberObject().getFamilyBaseEntityId()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_HEAD, getHivMemberObject().getFamilyHead()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.PRIMARY_CAREGIVER, getHivMemberObject().getPrimaryCareGiver()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_NAME, getHivMemberObject().getFamilyName()); + + intent.putExtra(CoreConstants.INTENT_KEY.SERVICE_DUE, true); + startActivity(intent); + } + + @Override + public void openFollowUpVisitForm(boolean isEdit) { + if (!isEdit) + startHivFollowupActivity(this, getHivMemberObject().getBaseEntityId()); + } + + @Override + protected void removeMember() { + // Not required for HF (as seen in other profile activities)? + } + + @Override + public void onClick(View view) { + super.onClick(view); + int id = view.getId(); + if (id == R.id.record_hiv_followup_visit) { + openFollowUpVisitForm(false); + } + } + + @Override + public Context getContext() { + return null; + } + + @Override + public void verifyHasPhone() { + // TODO -> Implement for HF + } + + @Override + public void notifyHasPhone(boolean b) { + // TODO -> Implement for HF + } + + @Override + public void openMedicalHistory() { + //TODO implement + } +} + diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivRegisterActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivRegisterActivity.java new file mode 100644 index 000000000..e12f34c6d --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/HivRegisterActivity.java @@ -0,0 +1,78 @@ +package org.smartregister.chw.hf.activity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import com.google.android.material.bottomnavigation.LabelVisibilityMode; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.activity.CoreHivRegisterActivity; +import org.smartregister.chw.core.custom_views.NavigationMenu; +import org.smartregister.chw.hf.fragment.HivRegisterFragment; +import org.smartregister.chw.hiv.fragment.BaseHivRegisterFragment; +import org.smartregister.helper.BottomNavigationHelper; +import org.smartregister.listener.BottomNavigationListener; + +import java.util.List; + +public class HivRegisterActivity extends CoreHivRegisterActivity { + private String baseEntityID; + + public static void startHIVFormActivity(Activity activity, String baseEntityID, String formName, String payloadType) { + Intent intent = new Intent(activity, HivRegisterActivity.class); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.BASE_ENTITY_ID, baseEntityID); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.ACTION, payloadType); + intent.putExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.HIV_REGISTRATION_FORM_NAME, formName); + activity.startActivity(intent); + } + + @NotNull + @Override + protected Fragment[] getOtherFragments() { + return new Fragment[]{}; + } + + @NotNull + @Override + protected BaseHivRegisterFragment getRegisterFragment() { + return new HivRegisterFragment(); + } + + @Override + public List getViewIdentifiers() { + return null; + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + baseEntityID = getIntent().getStringExtra(org.smartregister.chw.hiv.util.Constants.ActivityPayload.BASE_ENTITY_ID); + super.onCreate(savedInstanceState); + NavigationMenu.getInstance(this, null, null); + } + + @Override + protected void registerBottomNavigation() { + bottomNavigationHelper = new BottomNavigationHelper(); + bottomNavigationView = findViewById(org.smartregister.R.id.bottom_navigation); + + if (bottomNavigationView != null) { + bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_clients); + bottomNavigationView.getMenu().removeItem(org.smartregister.chw.hiv.R.id.action_register); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_search); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_library); + + bottomNavigationView.inflateMenu(getMenuResource()); + bottomNavigationHelper.disableShiftMode(bottomNavigationView); + + BottomNavigationListener hivBottomNavigationListener = getBottomNavigation(this); + bottomNavigationView.setOnNavigationItemSelectedListener(hivBottomNavigationListener); + + } + } + +} + \ No newline at end of file diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/PncMemberProfileActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/PncMemberProfileActivity.java index d23942282..007a97486 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/PncMemberProfileActivity.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/PncMemberProfileActivity.java @@ -44,6 +44,7 @@ import timber.log.Timber; +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; import static org.smartregister.chw.core.utils.Utils.passToolbarTitle; public class PncMemberProfileActivity extends CorePncMemberProfileActivity implements PncMemberProfileContract.View { @@ -78,6 +79,16 @@ protected void startMalariaFollowUpVisit() { // TODO -> Implement for HF } + @Override + protected void startHivRegister() { + HivRegisterActivity.startHIVFormActivity(this, memberObject.getBaseEntityId(),CoreConstants.JSON_FORM.getHivRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivRegistration()).toString()); + } + + @Override + protected void startTbRegister() { + TbRegisterActivity.startTbFormActivity(this, memberObject.getBaseEntityId(),CoreConstants.JSON_FORM.getTbRegistration(),getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbRegistration()).toString()); + } + @Override protected void getRemoveBabyMenuItem(MenuItem menuItem) { // TODO -> Implement for HF diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbProfileActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbProfileActivity.java new file mode 100644 index 000000000..49989a230 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbProfileActivity.java @@ -0,0 +1,171 @@ +package org.smartregister.chw.hf.activity; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.view.View; + +import androidx.recyclerview.widget.RecyclerView; + +import org.smartregister.chw.core.activity.CoreTbProfileActivity; +import org.smartregister.chw.core.activity.CoreTbUpcomingServicesActivity; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.hf.adapter.ReferralCardViewAdapter; +import org.smartregister.chw.hf.contract.TbProfileContract; +import org.smartregister.chw.hf.interactor.HfTbProfileInteractor; +import org.smartregister.chw.hf.presenter.TbProfilePresenter; +import org.smartregister.chw.tb.activity.BaseTbRegistrationFormsActivity; +import org.smartregister.chw.tb.domain.TbMemberObject; +import org.smartregister.chw.tb.util.Constants; +import org.smartregister.chw.tb.util.TbUtil; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.domain.Task; + +import java.util.Date; +import java.util.Set; + +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; + +public class TbProfileActivity extends CoreTbProfileActivity + implements TbProfileContract.View { + + private CommonPersonObjectClient commonPersonObjectClient; + + public static void startTbProfileActivity(Activity activity, TbMemberObject memberObject) { + Intent intent = new Intent(activity, TbProfileActivity.class); + intent.putExtra(Constants.ActivityPayload.MEMBER_OBJECT, memberObject); + activity.startActivity(intent); + } + + public void startTbFollowupActivity(Activity activity, String baseEntityID) { + Intent intent = new Intent(activity, BaseTbRegistrationFormsActivity.class); + intent.putExtra(Constants.ActivityPayload.BASE_ENTITY_ID, baseEntityID); + intent.putExtra(Constants.ActivityPayload.JSON_FORM, getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbFollowupVisit()).toString()); + intent.putExtra(Constants.ActivityPayload.USE_DEFAULT_NEAT_FORM_LAYOUT, false); + + activity.startActivityForResult(intent, org.smartregister.chw.anc.util.Constants.REQUEST_CODE_HOME_VISIT); + } + + public void setReferralTasks(Set taskList) { + if (notificationAndReferralRecyclerView != null && taskList.size() > 0) { + RecyclerView.Adapter mAdapter = new ReferralCardViewAdapter(taskList, this, getCommonPersonObjectClient(), CoreConstants.REGISTERED_ACTIVITIES.FP_REGISTER_ACTIVITY); + notificationAndReferralRecyclerView.setAdapter(mAdapter); + notificationAndReferralLayout.setVisibility(View.VISIBLE); + findViewById(R.id.view_notification_and_referral_row).setVisibility(View.VISIBLE); + } + } + + @Override + protected void onCreation() { + super.onCreation(); + setCommonPersonObjectClient(getClientDetailsByBaseEntityID(getTbMemberObject().getBaseEntityId())); + } + + @Override + protected void onResume() { + super.onResume(); + ((TbProfileContract.Presenter) getTbProfilePresenter()).fetchReferralTasks(); + if (notificationAndReferralRecyclerView != null && notificationAndReferralRecyclerView.getAdapter() != null) { + notificationAndReferralRecyclerView.getAdapter().notifyDataSetChanged(); + } + } + + public CommonPersonObjectClient getCommonPersonObjectClient() { + return commonPersonObjectClient; + } + + public void setCommonPersonObjectClient(CommonPersonObjectClient commonPersonObjectClient) { + this.commonPersonObjectClient = commonPersonObjectClient; + } + + @Override + protected void initializePresenter() { + showProgressBar(true); + setTbProfilePresenter(new TbProfilePresenter(this, new HfTbProfileInteractor(this), getTbMemberObject())); + fetchProfileData(); + } + + @Override + protected void removeMember() { + // Not required for HF (as seen in other profile activities)? + } + + @Override + protected void startTbCaseClosure() { + TbRegisterActivity.startTbFormActivity(this, getTbMemberObject().getBaseEntityId(), CoreConstants.JSON_FORM.getTbCaseClosure(), getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbCaseClosure()).toString()); + } + + @Override + public void onClick(View view) { + super.onClick(view); + int id = view.getId(); + if (id == R.id.record_tb_followup_visit) { + openFollowUpVisitForm(false); + } + } + + @Override + public Context getContext() { + return null; + } + + @Override + public void verifyHasPhone() { + // Implement + } + + @Override + public void notifyHasPhone(boolean b) { + // Implement + } + + @Override + public void openMedicalHistory() { + //TODO implement + } + + @Override + public void openTbRegistrationForm() { + TbRegisterActivity.startTbFormActivity(this, getTbMemberObject().getBaseEntityId(), CoreConstants.JSON_FORM.getTbRegistration(), getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbRegistration()).toString()); + + } + + @Override + public void openUpcomingServices() { + CoreTbUpcomingServicesActivity.startMe(this, TbUtil.toMember(getTbMemberObject())); + } + + @Override + public void openFamilyDueServices() { + Intent intent = new Intent(this, FamilyProfileActivity.class); + + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_BASE_ENTITY_ID, getTbMemberObject().getFamilyBaseEntityId()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_HEAD, getTbMemberObject().getFamilyHead()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.PRIMARY_CAREGIVER, getTbMemberObject().getPrimaryCareGiver()); + intent.putExtra(org.smartregister.family.util.Constants.INTENT_KEY.FAMILY_NAME, getTbMemberObject().getFamilyName()); + + intent.putExtra(CoreConstants.INTENT_KEY.SERVICE_DUE, true); + startActivity(intent); + } + + @Override + public void openFollowUpVisitForm(boolean isEdit) { + if (!isEdit) + startTbFollowupActivity(this, getTbMemberObject().getBaseEntityId()); + } + + + @Override + public void updateLastVisitRow(Date lastVisitDate) { + //overriding showing of last visit row + } + + @Override + public void setupFollowupVisitEditViews(boolean isWithin24Hours) { + //overriding setupFollowupVisitEditViews row + } + + +} + diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbRegisterActivity.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbRegisterActivity.java new file mode 100644 index 000000000..2e1d49655 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/activity/TbRegisterActivity.java @@ -0,0 +1,70 @@ +package org.smartregister.chw.hf.activity; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import com.google.android.material.bottomnavigation.LabelVisibilityMode; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.activity.CoreTbRegisterActivity; +import org.smartregister.chw.core.custom_views.NavigationMenu; +import org.smartregister.chw.hf.fragment.TbRegisterFragment; +import org.smartregister.chw.tb.fragment.BaseTbRegisterFragment; +import org.smartregister.family.util.JsonFormUtils; +import org.smartregister.helper.BottomNavigationHelper; +import org.smartregister.listener.BottomNavigationListener; + +public class TbRegisterActivity extends CoreTbRegisterActivity { + + public static void startTbFormActivity(Activity activity, String baseEntityID, String formName, String payloadType) { + Intent intent = new Intent(activity, TbRegisterActivity.class); + intent.putExtra(org.smartregister.chw.tb.util.Constants.ActivityPayload.BASE_ENTITY_ID, baseEntityID); + intent.putExtra(org.smartregister.chw.tb.util.Constants.ActivityPayload.ACTION, payloadType); + intent.putExtra(org.smartregister.chw.tb.util.Constants.ActivityPayload.TB_REGISTRATION_FORM_NAME, formName); + activity.startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON); + } + + @NotNull + @Override + protected Fragment[] getOtherFragments() { + return new Fragment[]{}; + } + + @NotNull + @Override + protected BaseTbRegisterFragment getRegisterFragment() { + return new TbRegisterFragment(); + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + NavigationMenu.getInstance(this, null, null); + } + + @Override + protected void registerBottomNavigation() { + bottomNavigationHelper = new BottomNavigationHelper(); + bottomNavigationView = findViewById(org.smartregister.R.id.bottom_navigation); + + if (bottomNavigationView != null) { + bottomNavigationView.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_clients); + bottomNavigationView.getMenu().removeItem(org.smartregister.chw.tb.R.id.action_register); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_search); + bottomNavigationView.getMenu().removeItem(org.smartregister.R.id.action_library); + + bottomNavigationView.inflateMenu(getMenuResource()); + bottomNavigationHelper.disableShiftMode(bottomNavigationView); + + BottomNavigationListener tbBottomNavigationListener = getBottomNavigation(this); + bottomNavigationView.setOnNavigationItemSelectedListener(tbBottomNavigationListener); + + } + } + +} + \ No newline at end of file diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/HivProfileContract.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/HivProfileContract.java new file mode 100644 index 000000000..4882ee0ce --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/HivProfileContract.java @@ -0,0 +1,24 @@ +package org.smartregister.chw.hf.contract; + +import org.smartregister.chw.core.contract.CoreHivProfileContract; +import org.smartregister.domain.Task; + +import java.util.Set; + +public interface HivProfileContract extends CoreHivProfileContract { + interface View extends CoreHivProfileContract.View { + void setReferralTasks(Set taskList); + } + + interface Presenter extends CoreHivProfileContract.Presenter { + void fetchReferralTasks(); + } + + interface Interactor { + void getReferralTasks(String planId, String baseEntityId, HivProfileContract.InteractorCallback callback); + } + + interface InteractorCallback { + void updateReferralTasks(Set taskList); + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/TbProfileContract.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/TbProfileContract.java new file mode 100644 index 000000000..f6b620679 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/contract/TbProfileContract.java @@ -0,0 +1,24 @@ +package org.smartregister.chw.hf.contract; + +import org.smartregister.chw.core.contract.CoreTbProfileContract; +import org.smartregister.domain.Task; + +import java.util.Set; + +public interface TbProfileContract extends CoreTbProfileContract { + interface View extends CoreTbProfileContract.View { + void setReferralTasks(Set taskList); + } + + interface Presenter extends CoreTbProfileContract.Presenter { + void fetchReferralTasks(); + } + + interface Interactor { + void getReferralTasks(String planId, String baseEntityId, TbProfileContract.InteractorCallback callback); + } + + interface InteractorCallback { + void updateReferralTasks(Set taskList); + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/HivRegisterFragment.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/HivRegisterFragment.java new file mode 100644 index 000000000..96879c1ba --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/HivRegisterFragment.java @@ -0,0 +1,65 @@ +package org.smartregister.chw.hf.fragment; + +import org.jetbrains.annotations.Nullable; +import org.smartregister.chw.core.fragment.CoreHivRegisterFragment; +import org.smartregister.chw.core.provider.CoreHivProvider; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.activity.HivProfileActivity; +import org.smartregister.chw.hf.activity.HivRegisterActivity; +import org.smartregister.chw.hf.model.HivRegisterFragmentModel; +import org.smartregister.chw.hf.presenter.HivRegisterFragmentPresenter; +import org.smartregister.chw.hf.provider.HfHivRegisterProvider; +import org.smartregister.chw.hiv.dao.HivDao; +import org.smartregister.chw.hiv.domain.HivMemberObject; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.configurableviews.model.View; +import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter; + +import java.util.Objects; +import java.util.Set; + +import timber.log.Timber; + +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; + +public class HivRegisterFragment extends CoreHivRegisterFragment { + + @Override + public void initializeAdapter(@Nullable Set visibleColumns) { + CoreHivProvider hivRegisterProvider = new HfHivRegisterProvider(getActivity(), visibleColumns, registerActionHandler, paginationViewHandler); + clientAdapter = new RecyclerViewPaginatedAdapter(null, hivRegisterProvider, context().commonrepository(this.tablename)); + clientAdapter.setCurrentlimit(20); + clientsView.setAdapter(clientAdapter); + } + + @Override + protected void initializePresenter() { + if (getActivity() == null) { + return; + } + String viewConfigurationIdentifier = null; + try { + viewConfigurationIdentifier = ((HivRegisterActivity) getActivity()).getViewIdentifiers().get(0); + } catch (NullPointerException e) { + Timber.e(e); + } + presenter = new HivRegisterFragmentPresenter(this, new HivRegisterFragmentModel(), viewConfigurationIdentifier); + } + + @Override + protected void openProfile(CommonPersonObjectClient client) { + if (getActivity() != null) + HivProfileActivity.startHivProfileActivity(getActivity(), Objects.requireNonNull(HivDao.getMember(client.getCaseId()))); + } + + + @Override + protected void openFollowUpVisit(@Nullable HivMemberObject hivMemberObject) { + if (getActivity() != null) + HivRegisterActivity.startHIVFormActivity(getActivity(), hivMemberObject.getBaseEntityId(), CoreConstants.JSON_FORM.getHivRegistration(), getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getHivFollowupVisit()).toString()); + } + + +} + + diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/TbRegisterFragment.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/TbRegisterFragment.java new file mode 100644 index 000000000..e4b0d07f9 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/fragment/TbRegisterFragment.java @@ -0,0 +1,64 @@ +package org.smartregister.chw.hf.fragment; + +import androidx.annotation.Nullable; + +import org.smartregister.chw.core.fragment.CoreTbRegisterFragment; +import org.smartregister.chw.core.provider.CoreTbProvider; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.activity.TbProfileActivity; +import org.smartregister.chw.hf.activity.TbRegisterActivity; +import org.smartregister.chw.hf.model.TbRegisterFragmentModel; +import org.smartregister.chw.hf.presenter.TbRegisterFragmentPresenter; +import org.smartregister.chw.hf.provider.HfTbRegisterProvider; +import org.smartregister.chw.tb.dao.TbDao; +import org.smartregister.chw.tb.domain.TbMemberObject; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.configurableviews.model.View; +import org.smartregister.cursoradapter.RecyclerViewPaginatedAdapter; + +import java.util.Objects; +import java.util.Set; + +import timber.log.Timber; + +import static org.smartregister.chw.core.utils.FormUtils.getFormUtils; + +public class TbRegisterFragment extends CoreTbRegisterFragment { + + @Override + public void initializeAdapter(@org.jetbrains.annotations.Nullable Set visibleColumns) { + CoreTbProvider tbRegisterProvider = new HfTbRegisterProvider(getActivity(), visibleColumns, registerActionHandler, paginationViewHandler); + clientAdapter = new RecyclerViewPaginatedAdapter(null, tbRegisterProvider, context().commonrepository(this.tablename)); + clientAdapter.setCurrentlimit(20); + clientsView.setAdapter(clientAdapter); + } + + @Override + protected void initializePresenter() { + if (getActivity() == null) { + return; + } + String viewConfigurationIdentifier = null; + try { + viewConfigurationIdentifier = ((TbRegisterActivity) getActivity()).getViewIdentifiers().get(0); + } catch (NullPointerException e) { + Timber.e(e); + } + presenter = new TbRegisterFragmentPresenter(this, new TbRegisterFragmentModel(), viewConfigurationIdentifier); + } + + @Override + protected void openProfile(CommonPersonObjectClient client) { + if (getActivity() != null) + TbProfileActivity.startTbProfileActivity(getActivity(), Objects.requireNonNull(TbDao.getMember(client.getCaseId()))); + } + + @Override + protected void openFollowUpVisit(@Nullable TbMemberObject tbMemberObject) { + if (getActivity() != null) + TbRegisterActivity.startTbFormActivity(getActivity(), tbMemberObject.getBaseEntityId(), CoreConstants.JSON_FORM.getTbFollowupVisit(), getFormUtils().getFormJsonFromRepositoryOrAssets(CoreConstants.JSON_FORM.getTbFollowupVisit()).toString()); + } + +} + + diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfHivProfileInteractor.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfHivProfileInteractor.java new file mode 100644 index 000000000..dbed6dabc --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfHivProfileInteractor.java @@ -0,0 +1,36 @@ +package org.smartregister.chw.hf.interactor; + +import android.content.Context; + +import org.smartregister.chw.core.application.CoreChwApplication; +import org.smartregister.chw.core.interactor.CoreHivProfileInteractor; +import org.smartregister.chw.core.repository.ChwTaskRepository; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.contract.HivProfileContract; +import org.smartregister.chw.hiv.contract.BaseHivProfileContract; +import org.smartregister.chw.hiv.domain.HivMemberObject; +import org.smartregister.domain.Task; +import org.smartregister.repository.TaskRepository; + +import java.util.Set; + +public class HfHivProfileInteractor extends CoreHivProfileInteractor implements HivProfileContract.Interactor { + private Context context; + + public HfHivProfileInteractor(Context context) { + super(context); + this.context = context; + } + + @Override + public void getReferralTasks(String planId, String baseEntityId, HivProfileContract.InteractorCallback callback) { + TaskRepository taskRepository = CoreChwApplication.getInstance().getTaskRepository(); + Set taskList = ((ChwTaskRepository) taskRepository).getReferralTasksForClientByStatus(planId, baseEntityId, CoreConstants.BUSINESS_STATUS.REFERRED); + callback.updateReferralTasks(taskList); + } + + @Override + public void updateProfileHivStatusInfo(HivMemberObject memberObject, BaseHivProfileContract.InteractorCallback callback) { + //overriding updateProfileHivStatusInfo + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfTbProfileInteractor.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfTbProfileInteractor.java new file mode 100644 index 000000000..dab9831e8 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/interactor/HfTbProfileInteractor.java @@ -0,0 +1,36 @@ +package org.smartregister.chw.hf.interactor; + +import android.content.Context; + +import org.smartregister.chw.core.application.CoreChwApplication; +import org.smartregister.chw.core.interactor.CoreTbProfileInteractor; +import org.smartregister.chw.core.repository.ChwTaskRepository; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.contract.TbProfileContract; +import org.smartregister.chw.tb.contract.BaseTbProfileContract; +import org.smartregister.chw.tb.domain.TbMemberObject; +import org.smartregister.domain.Task; +import org.smartregister.repository.TaskRepository; + +import java.util.Set; + +public class HfTbProfileInteractor extends CoreTbProfileInteractor implements TbProfileContract.Interactor { + private Context context; + + public HfTbProfileInteractor(Context context) { + super(context); + this.context = context; + } + + @Override + public void getReferralTasks(String planId, String baseEntityId, TbProfileContract.InteractorCallback callback) { + TaskRepository taskRepository = CoreChwApplication.getInstance().getTaskRepository(); + Set taskList = ((ChwTaskRepository) taskRepository).getReferralTasksForClientByStatus(planId, baseEntityId, CoreConstants.BUSINESS_STATUS.REFERRED); + callback.updateReferralTasks(taskList); + } + + @Override + public void updateProfileTbStatusInfo(TbMemberObject memberObject, BaseTbProfileContract.InteractorCallback callback) { + //overriding updateProfileHivStatusInfo + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/HivRegisterFragmentModel.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/HivRegisterFragmentModel.java new file mode 100644 index 000000000..5265db557 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/HivRegisterFragmentModel.java @@ -0,0 +1,56 @@ +package org.smartregister.chw.hf.model; + + +import androidx.annotation.NonNull; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.utils.ChildDBConstants; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hiv.model.BaseHivRegisterFragmentModel; +import org.smartregister.chw.hiv.util.Constants.Tables; +import org.smartregister.chw.hiv.util.DBConstants.Key; +import org.smartregister.cursoradapter.SmartRegisterQueryBuilder; +import org.smartregister.family.util.DBConstants; + +import java.util.HashSet; +import java.util.Set; + +public class HivRegisterFragmentModel extends BaseHivRegisterFragmentModel { + + @NonNull + @Override + public String mainSelect(@NonNull String tableName, @NonNull String mainCondition) { + SmartRegisterQueryBuilder queryBuilder = new SmartRegisterQueryBuilder(); + queryBuilder.selectInitiateMainTable(tableName, mainColumns(tableName)); + queryBuilder.customJoin("INNER JOIN " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + " ON " + tableName + "." + DBConstants.KEY.BASE_ENTITY_ID + " = " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.BASE_ENTITY_ID + " COLLATE NOCASE "); + queryBuilder.customJoin("INNER JOIN " + CoreConstants.TABLE_NAME.FAMILY + " ON " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID + " = " + CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.BASE_ENTITY_ID); + queryBuilder.customJoin("LEFT JOIN (select base_entity_id , max(visit_date) visit_date from visits GROUP by base_entity_id) VISIT_SUMMARY ON VISIT_SUMMARY.base_entity_id = " + tableName + "." + DBConstants.KEY.BASE_ENTITY_ID); + return queryBuilder.mainCondition(mainCondition); + } + + @Override + @NotNull + public String[] mainColumns(String tableName) { + Set columnList = new HashSet<>(); + + columnList.add(tableName + "." + DBConstants.KEY.BASE_ENTITY_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID + " as " + ChildDBConstants.KEY.RELATIONAL_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.FIRST_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.MIDDLE_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.LAST_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.DOB); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.GENDER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.UNIQUE_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.PHONE_NUMBER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.OTHER_PHONE_NUMBER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.VILLAGE_TOWN); + columnList.add(CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.FIRST_NAME + " as " + org.smartregister.chw.anc.util.DBConstants.KEY.FAMILY_NAME); + columnList.add(Tables.HIV + "." + Key.CTC_NUMBER); + columnList.add(Tables.HIV + "." + Key.CBHS_NUMBER); + columnList.add(Tables.HIV + "." + Key.CLIENT_HIV_STATUS_DURING_REGISTRATION); + columnList.add(Tables.HIV + "." + Key.CLIENT_HIV_STATUS_AFTER_TESTING); + + return columnList.toArray(new String[columnList.size()]); + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/NavigationModel.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/NavigationModel.java index 6116266e9..ae0827012 100644 --- a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/NavigationModel.java +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/NavigationModel.java @@ -20,6 +20,8 @@ public List getNavigationItems() { navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_children, R.mipmap.sidemenu_children_active, R.string.menu_child_clients, CoreConstants.DrawerMenu.CHILD_CLIENTS, 0)); navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_fp, R.mipmap.sidemenu_fp_active, R.string.menu_family_planning, CoreConstants.DrawerMenu.FAMILY_PLANNING, 0)); navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_malaria, R.mipmap.sidemenu_malaria_active, R.string.menu_malaria, CoreConstants.DrawerMenu.MALARIA, 0)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_hiv, R.mipmap.sidemenu_hiv_active, R.string.menu_hiv, CoreConstants.DrawerMenu.HIV_CLIENTS, 0)); + navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_tb, R.mipmap.sidemenu_tb_active, R.string.menu_tb, CoreConstants.DrawerMenu.TB_CLIENTS, 0)); navigationOptions.add(new NavigationOption(R.mipmap.sidemenu_referrals, R.mipmap.sidemenu_referrals_active, R.string.menu_referrals, CoreConstants.DrawerMenu.REFERRALS, 0)); } diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/TbRegisterFragmentModel.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/TbRegisterFragmentModel.java new file mode 100644 index 000000000..8392c6a6e --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/model/TbRegisterFragmentModel.java @@ -0,0 +1,56 @@ +package org.smartregister.chw.hf.model; + + +import androidx.annotation.NonNull; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.utils.ChildDBConstants; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.tb.model.BaseTbRegisterFragmentModel; +import org.smartregister.chw.tb.util.Constants.Tables; +import org.smartregister.chw.tb.util.DBConstants.Key; +import org.smartregister.cursoradapter.SmartRegisterQueryBuilder; +import org.smartregister.family.util.DBConstants; + +import java.util.HashSet; +import java.util.Set; + +public class TbRegisterFragmentModel extends BaseTbRegisterFragmentModel { + + @NonNull + @Override + public String mainSelect(@NonNull String tableName, @NonNull String mainCondition) { + SmartRegisterQueryBuilder queryBuilder = new SmartRegisterQueryBuilder(); + queryBuilder.selectInitiateMainTable(tableName, mainColumns(tableName)); + queryBuilder.customJoin("INNER JOIN " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + " ON " + tableName + "." + DBConstants.KEY.BASE_ENTITY_ID + " = " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.BASE_ENTITY_ID + " COLLATE NOCASE "); + queryBuilder.customJoin("INNER JOIN " + CoreConstants.TABLE_NAME.FAMILY + " ON " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID + " = " + CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.BASE_ENTITY_ID); + queryBuilder.customJoin("LEFT JOIN (select base_entity_id , max(visit_date) visit_date from visits GROUP by base_entity_id) VISIT_SUMMARY ON VISIT_SUMMARY.base_entity_id = " + tableName + "." + DBConstants.KEY.BASE_ENTITY_ID); + return queryBuilder.mainCondition(mainCondition); + } + + @Override + @NotNull + public String[] mainColumns(String tableName) { + Set columnList = new HashSet<>(); + + columnList.add(tableName + "." + DBConstants.KEY.BASE_ENTITY_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID + " as " + ChildDBConstants.KEY.RELATIONAL_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.FIRST_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.MIDDLE_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.LAST_NAME); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.DOB); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.GENDER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.UNIQUE_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.RELATIONAL_ID); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.PHONE_NUMBER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.KEY.OTHER_PHONE_NUMBER); + columnList.add(CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.VILLAGE_TOWN); + columnList.add(CoreConstants.TABLE_NAME.FAMILY + "." + DBConstants.KEY.FIRST_NAME + " as " + org.smartregister.chw.anc.util.DBConstants.KEY.FAMILY_NAME); + columnList.add(Tables.TB + "." + Key.PLACE_OF_DOMICILE); + columnList.add(Tables.TB + "." + Key.COMMUNITY_CLIENT_TB_REGISTRATION_NUMBER); + columnList.add(Tables.TB + "." + Key.CLIENT_TB_STATUS_DURING_REGISTRATION); + columnList.add(Tables.TB + "." + Key.CLIENT_TB_STATUS_AFTER_TESTING); + + return columnList.toArray(new String[columnList.size()]); + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivProfilePresenter.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivProfilePresenter.java new file mode 100644 index 000000000..87f688c9a --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivProfilePresenter.java @@ -0,0 +1,34 @@ +package org.smartregister.chw.hf.presenter; + +import org.smartregister.chw.core.contract.CoreHivProfileContract; +import org.smartregister.chw.core.presenter.CoreHivProfilePresenter; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.contract.HivProfileContract; +import org.smartregister.chw.hiv.domain.HivMemberObject; +import org.smartregister.domain.Task; + +import java.util.Set; + +public class HivProfilePresenter extends CoreHivProfilePresenter + implements HivProfileContract.Presenter, HivProfileContract.InteractorCallback { + + private HivMemberObject hivMemberObject; + private HivProfileContract.Interactor interactor; + + public HivProfilePresenter(CoreHivProfileContract.View view, CoreHivProfileContract.Interactor interactor, + HivMemberObject hivMemberObject) { + super(view, interactor, hivMemberObject); + this.hivMemberObject = hivMemberObject; + this.interactor = (HivProfileContract.Interactor) interactor; + } + + @Override + public void fetchReferralTasks() { + interactor.getReferralTasks(CoreConstants.REFERRAL_PLAN_ID, hivMemberObject.getBaseEntityId(), this); + } + + @Override + public void updateReferralTasks(Set taskList) { + ((HivProfileContract.View) getView()).setReferralTasks(taskList); + } +} \ No newline at end of file diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivRegisterFragmentPresenter.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivRegisterFragmentPresenter.java new file mode 100644 index 000000000..0fcf77f05 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/HivRegisterFragmentPresenter.java @@ -0,0 +1,37 @@ +package org.smartregister.chw.hf.presenter; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.hiv.contract.BaseHivRegisterFragmentContract; +import org.smartregister.chw.hiv.presenter.BaseHivRegisterFragmentPresenter; +import org.smartregister.chw.hiv.util.Constants.Tables; +import org.smartregister.chw.hiv.util.DBConstants; + +public class HivRegisterFragmentPresenter extends BaseHivRegisterFragmentPresenter { + + public HivRegisterFragmentPresenter(BaseHivRegisterFragmentContract.View view, BaseHivRegisterFragmentContract.Model model, String viewConfigurationIdentifier) { + super(view, model, viewConfigurationIdentifier); + } + + @Override + @NotNull + public String getMainCondition() { + return " " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.Key.DATE_REMOVED + " is null " + + "AND " + Tables.HIV + "." + DBConstants.Key.IS_CLOSED + " = '0' "; + + } + + @Override + public void processViewConfigurations() { + super.processViewConfigurations(); + if (getConfig().getSearchBarText() != null && getView() != null) { + getView().updateSearchBarHint(getView().getContext().getString(R.string.search_name_or_id)); + } + } + + @Override + public String getMainTable() { + return Tables.HIV; + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbProfilePresenter.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbProfilePresenter.java new file mode 100644 index 000000000..e82e663da --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbProfilePresenter.java @@ -0,0 +1,34 @@ +package org.smartregister.chw.hf.presenter; + +import org.smartregister.chw.core.contract.CoreTbProfileContract; +import org.smartregister.chw.core.presenter.CoreTbProfilePresenter; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.contract.TbProfileContract; +import org.smartregister.chw.tb.domain.TbMemberObject; +import org.smartregister.domain.Task; + +import java.util.Set; + +public class TbProfilePresenter extends CoreTbProfilePresenter + implements TbProfileContract.Presenter, TbProfileContract.InteractorCallback { + + private TbMemberObject tbMemberObject; + private TbProfileContract.Interactor interactor; + + public TbProfilePresenter(CoreTbProfileContract.View view, CoreTbProfileContract.Interactor interactor, + TbMemberObject tbMemberObject) { + super(view, interactor, tbMemberObject); + this.tbMemberObject = tbMemberObject; + this.interactor = (TbProfileContract.Interactor) interactor; + } + + @Override + public void fetchReferralTasks() { + interactor.getReferralTasks(CoreConstants.REFERRAL_PLAN_ID, tbMemberObject.getBaseEntityId(), this); + } + + @Override + public void updateReferralTasks(Set taskList) { + ((TbProfileContract.View) getView()).setReferralTasks(taskList); + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbRegisterFragmentPresenter.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbRegisterFragmentPresenter.java new file mode 100644 index 000000000..fac232c50 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/presenter/TbRegisterFragmentPresenter.java @@ -0,0 +1,38 @@ +package org.smartregister.chw.hf.presenter; + +import org.jetbrains.annotations.NotNull; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.tb.contract.BaseTbRegisterFragmentContract; +import org.smartregister.chw.tb.presenter.BaseTbRegisterFragmentPresenter; +import org.smartregister.chw.tb.util.Constants.Tables; +import org.smartregister.chw.tb.util.DBConstants; + +public class TbRegisterFragmentPresenter extends BaseTbRegisterFragmentPresenter { + + public TbRegisterFragmentPresenter(BaseTbRegisterFragmentContract.View view, BaseTbRegisterFragmentContract.Model model, String viewConfigurationIdentifier) { + super(view, model, viewConfigurationIdentifier); + } + + @Override + @NotNull + public String getMainCondition() { + return " " + CoreConstants.TABLE_NAME.FAMILY_MEMBER + "." + DBConstants.Key.DATE_REMOVED + " is null " + + "AND " + Tables.TB + "." + DBConstants.Key.TB_CASE_CLOSURE_DATE + " is null " + + "AND " + Tables.TB + "." + DBConstants.Key.IS_CLOSED + " = '0' "; + + } + + @Override + public void processViewConfigurations() { + super.processViewConfigurations(); + if (getConfig().getSearchBarText() != null && getView() != null) { + getView().updateSearchBarHint(getView().getContext().getString(R.string.search_name_or_id)); + } + } + + @Override + public String getMainTable() { + return Tables.TB; + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfHivRegisterProvider.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfHivRegisterProvider.java new file mode 100644 index 000000000..9cc81d848 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfHivRegisterProvider.java @@ -0,0 +1,54 @@ +package org.smartregister.chw.hf.provider; + +import android.content.Context; +import android.database.Cursor; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import org.smartregister.chw.core.provider.CoreHivProvider; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.hf.utils.HfReferralUtils; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.view.contract.SmartRegisterClient; + +import java.util.Set; + +public class HfHivRegisterProvider extends CoreHivProvider { + + private final LayoutInflater inflater; + + public HfHivRegisterProvider(Context context, Set visibleColumns, View.OnClickListener onClickListener, View.OnClickListener paginationClickListener) { + super(context, visibleColumns, onClickListener, paginationClickListener); + inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + @Override + public void getView(Cursor cursor, SmartRegisterClient smartRegisterClient, RegisterViewHolder registerViewHolder) { + super.getView(cursor, smartRegisterClient, registerViewHolder); + registerViewHolder.getDueWrapper().setVisibility(View.GONE); + + showLatestHivReferralDay((CommonPersonObjectClient) smartRegisterClient, (HfRegisterViewHolder) registerViewHolder); + } + + @Override + public RegisterViewHolder createViewHolder(ViewGroup parent) { + View view = inflater.inflate(R.layout.hf_hiv_register_list_row_item, parent, false); + return new HfRegisterViewHolder(view); + } + + private void showLatestHivReferralDay(CommonPersonObjectClient client, HfHivRegisterProvider.HfRegisterViewHolder viewHolder) { + HfReferralUtils.displayReferralDay(client, CoreConstants.TASKS_FOCUS.SUSPECTED_HIV, viewHolder.textViewReferralDay); + } + + public class HfRegisterViewHolder extends RegisterViewHolder { + TextView textViewReferralDay; + + public HfRegisterViewHolder(View itemView) { + super(itemView); + textViewReferralDay = itemView.findViewById(R.id.text_view_referral_day); + } + } +} diff --git a/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfTbRegisterProvider.java b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfTbRegisterProvider.java new file mode 100644 index 000000000..af4c512b6 --- /dev/null +++ b/opensrp-chw-hf/src/main/java/org/smartregister/chw/hf/provider/HfTbRegisterProvider.java @@ -0,0 +1,54 @@ +package org.smartregister.chw.hf.provider; + +import android.content.Context; +import android.database.Cursor; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import org.smartregister.chw.core.provider.CoreTbProvider; +import org.smartregister.chw.core.utils.CoreConstants; +import org.smartregister.chw.hf.R; +import org.smartregister.chw.hf.utils.HfReferralUtils; +import org.smartregister.commonregistry.CommonPersonObjectClient; +import org.smartregister.view.contract.SmartRegisterClient; + +import java.util.Set; + +public class HfTbRegisterProvider extends CoreTbProvider { + + private final LayoutInflater inflater; + + public HfTbRegisterProvider(Context context, Set visibleColumns, View.OnClickListener onClickListener, View.OnClickListener paginationClickListener) { + super(context, visibleColumns, onClickListener, paginationClickListener); + inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + @Override + public void getView(Cursor cursor, SmartRegisterClient smartRegisterClient, RegisterViewHolder registerViewHolder) { + super.getView(cursor, smartRegisterClient, registerViewHolder); + registerViewHolder.getDueWrapper().setVisibility(View.GONE); + + showLatestTbReferralDay((CommonPersonObjectClient) smartRegisterClient, (HfRegisterViewHolder) registerViewHolder); + } + + @Override + public RegisterViewHolder createViewHolder(ViewGroup parent) { + View view = inflater.inflate(R.layout.hf_tb_register_list_row_item, parent, false); + return new HfRegisterViewHolder(view); + } + + private void showLatestTbReferralDay(CommonPersonObjectClient client, HfTbRegisterProvider.HfRegisterViewHolder viewHolder) { + HfReferralUtils.displayReferralDay(client, CoreConstants.TASKS_FOCUS.SUSPECTED_TB, viewHolder.textViewReferralDay); + } + + public class HfRegisterViewHolder extends RegisterViewHolder { + TextView textViewReferralDay; + + public HfRegisterViewHolder(View itemView) { + super(itemView); + textViewReferralDay = itemView.findViewById(R.id.text_view_referral_day); + } + } +} diff --git a/opensrp-chw-hf/src/main/res/layout/hf_hiv_register_list_row_item.xml b/opensrp-chw-hf/src/main/res/layout/hf_hiv_register_list_row_item.xml new file mode 100644 index 000000000..f61739e6b --- /dev/null +++ b/opensrp-chw-hf/src/main/res/layout/hf_hiv_register_list_row_item.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + +