Skip to content

Commit

Permalink
Refactor code to support single apk approach (#1211)
Browse files Browse the repository at this point in the history
* Migrate to targetSDK 31
- Bump up dependency versions
- Update manifest configs
- Remove kotlin-extension plugin; use view binding instead

Signed-off-by: Elly Kitoto <[email protected]>

* Implement generic register
- Refactor navigation
- Use compose navigation for screens
- Refactor main register to use compose views
- Harmonize register data model
- Activate app features via configuration

Signed-off-by: Elly Kitoto <[email protected]>

* Move navigation screens to NavigationScreen class

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor register pagination and filter
- Harmonized the two operations into a common register

Signed-off-by: Elly Kitoto <[email protected]>

* Fix outlined text design
- Also ignore case when filtering register data by name

Signed-off-by: Elly Kitoto <[email protected]>

* Implement FHIRPath data extractor

Signed-off-by: Elly Kitoto <[email protected]>

* Display last sync time on side menu

Signed-off-by: Elly Kitoto <[email protected]>

* Add language switcher action

Signed-off-by: Elly Kitoto <[email protected]>

* Implement FhirTaskGenerator

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor register client action

Signed-off-by: Elly Kitoto <[email protected]>

* Implement generic app profile

Signed-off-by: Elly Kitoto <[email protected]>

* Rename data providers to data access objects
- This is done so to allow other operations like save and update on
the DAOs not just data retrieval
- Also renamed DomainMapper to DataMapper

Signed-off-by: Elly Kitoto <[email protected]>

* Careplan and task generation via StructureMap (#1174)

* Careplan generation from StrcutureMap

* Scheduler for task updates

* Test and add sample call

* ECBIS SAA config added

* Change invalid log message

Co-authored-by: Elly Kitoto <[email protected]>

* Rename UI data models

Signed-off-by: Elly Kitoto <[email protected]>

* Move relevant UI packages to quest app module (#1178)

* Migrate ui package to quest app module

Signed-off-by: Elly Kitoto <[email protected]>

* Use sealed class on RegisterData domain model

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor register client implementation

Signed-off-by: Elly Kitoto <[email protected]>

* Load saved binary resource questionnaire configs (#1177)

* Questionnire config from config registry

* Update formConfigurationOf method defaults

Signed-off-by: Elly Kitoto <[email protected]>

Co-authored-by: Elly Kitoto <[email protected]>

* Open profile on list item click

Signed-off-by: Elly Kitoto <[email protected]>

* Fix loading data to member profile

Signed-off-by: Elly Kitoto <[email protected]>

* Show progress dialog when loading configs

Signed-off-by: Elly Kitoto <[email protected]>

* Rename components package

Signed-off-by: Elly Kitoto <[email protected]>

* Rename components package

Signed-off-by: Elly Kitoto <[email protected]>

* Start family profile implementation

Signed-off-by: Elly Kitoto <[email protected]>

* Format PersonalData UI

Signed-off-by: Elly Kitoto <[email protected]>

* Rename PatientProfileData to ProfileData

Signed-off-by: Elly Kitoto <[email protected]>

* Implement family member view component

Signed-off-by: Elly Kitoto <[email protected]>

* Rename event

Signed-off-by: Elly Kitoto <[email protected]>

* Implement FamilyDao (#1190)

* Add filters

* Add filters

* Family Register and Profile DAO

* Fix compile issue with Date class

* Refactor Family DAO

* Update family profile

Signed-off-by: Elly Kitoto <[email protected]>

* Implement AncDao (#1193)

* ANC DAO | structure map condition | auto load config on login

* Remove extra todo

* Implement default profile DAO (#1194)

* ANC DAO | structure map condition | auto load config on login

* Remove extra todo

* Default Register DAO | search subject resource refactor

* Add questionnaire and responses to default dao

* Update family register row UI

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor family and anc models

Signed-off-by: Elly Kitoto <[email protected]>

* Update individual profile views

Signed-off-by: Elly Kitoto <[email protected]>

* Implement add member action

Signed-off-by: Elly Kitoto <[email protected]>

* Fix ANC register UI

Signed-off-by: Elly Kitoto <[email protected]>

* Populate extra personal data information

Signed-off-by: Elly Kitoto <[email protected]>

* Implement family profile bottomsheet

Signed-off-by: Elly Kitoto <[email protected]>

* Implement action for opening family member task form

Signed-off-by: Elly Kitoto <[email protected]>

* Resolve force app crash when wrong sync config provided

Signed-off-by: Elly Kitoto <[email protected]>

* Implement app flavors (#1217)

* Implement app flavors

Signed-off-by: Elly Kitoto <[email protected]>

* Correct g6pd flavor versionNameSuffix config

Signed-off-by: Elly Kitoto <[email protected]>

* Fix pin login logo

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor household representation (#1216)

* Refactor family to Group

* Rename patientId to resourceId

The mentioned Id could be a patientId or groupId,
hence it's renamed to resourceId.

* Use official identifier

* Use constant FAMILY_CARE_PLAN

* Fix sync

* Fix filtering

* Use suffix from strings.xml

* Update CHANGELOG.md

* Move family name translation to view mapper

Signed-off-by: Elly Kitoto <[email protected]>

* Remove redundant filter

Signed-off-by: Elly Kitoto <[email protected]>

* Fix households display
- Filter only households with names. Implemented a workaround
for counting family groups

Signed-off-by: Elly Kitoto <[email protected]>

Co-authored-by: Elly Kitoto <[email protected]>

* Add family member task (#1221)

* Add family member task

* Change to subject

* Refactor generic function for launching questionnaires

Signed-off-by: Elly Kitoto <[email protected]>

* Implement change family head action (#1228)

* Implement action for change family head

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor overflow menu to use id.xml resources

Signed-off-by: Elly Kitoto <[email protected]>

* Move SideMenuOptionFactory to quest app module

Signed-off-by: Elly Kitoto <[email protected]>

* Activate device to device sync feature (#1229)

Signed-off-by: Elly Kitoto <[email protected]>

* Refactor register data access objects (#1223)

* refactor register data access classes

refactor anc and family register data access classes

* clean up register data access classes

update Official Identifier to use enum, update FamilyRegisterDao to use load and fetch methods provided in defaultRepository

* Resolve missing references

Signed-off-by: Elly Kitoto <[email protected]>

Co-authored-by: Elly Kitoto <[email protected]>

* Fix loading register data (#1230)

* Migrate measure report UI implementation to quest

Signed-off-by: Elly Kitoto <[email protected]>

* Clean up measure report UI

Signed-off-by: Elly Kitoto <[email protected]>

* Fix loading family/anc register data

Signed-off-by: Elly Kitoto <[email protected]>

* Remove unnecessary null check

Signed-off-by: Elly Kitoto <[email protected]>

* Fix app crash on API versions below 8

Signed-off-by: Elly Kitoto <[email protected]>

* Make login screen scrollable

Signed-off-by: Elly Kitoto <[email protected]>

* Add member and household head to household (#1240)

* ✨ Updated the Questionnaire View Model to add patients and related persons to the group resource

* 🎨 Reformat code

* 📝 Updated the Change log

* ♻️ Rename the method names

* 🎨 Spotless code reformat

* Add member and household head to household (#1241)

* ✨ Updated the Questionnaire View Model to add patients and related persons to the group resource

* 🎨 Reformat code

* 📝 Updated the Change log

* ♻️ Rename the method names

* 🎨 Spotless code reformat

* ✨ Added the family ID as part of the variables on the ad family member profile

* ♻️ update the variable naming

* Migrate measure reporting to quest app (#1242)

* Migrate measure report UI implementation to quest

Signed-off-by: Elly Kitoto <[email protected]>

* Clean up measure report UI

Signed-off-by: Elly Kitoto <[email protected]>

* Migrate measure reporting to quest app module

Signed-off-by: Elly Kitoto <[email protected]>

* 1082 (P2P) implement sending receiving data (#1226)

* Trigger CI

* Integrate p2p

* Add P2P sender and receiver dao implementations

* Implement fetching of data to be sent via P2P

* Add p2p lib as a project

* Initialize P2P library

* Init P2P lib options with sender and receiver transfer daos

* Update p2p receiver transfer dao with constructor

* Fix filter by lastupdated
Fix getting data types for sender and receiver transfer DAOs

* Sort records by last updated ascending
return resources as json data

* Fix JSON encoding resources for p2p transfer

* Resolve merge conflicts

* Add generically fetching each resource type for p2p transfer

* Save records on receiver device

* Filter records by greater than last updated at

* Add P2P menu icon on bottom navigation

* Fix resources search query for p2p (#1222)

* Add generically fetching each resource type for p2p transfer

* Fix resources search query for p2p

* Update engine to 0.1.0-alpha06-preview-p2p-SNAPSHOT

* Handle array index out of bounds when returned records is empty

* Use generic methoad to load various resources

* Make resource type dynamic

* Make resource type dynamic

* Use correct resorce type when parsing resources

Co-authored-by: Richard Kareko <[email protected]>

* Move data P2P retrieval and saving logic to base transfer DAO

* Hook up opening of P2P screen

* Set large heapsize setting to true

* Log ids of transferred resources to terminal

* Add group to list of resources for sync

* Update Resource.meta.lastUpdated date for inserts and updates

* Handle retrieval of Group class type

* Update p2p-lib directory

* Use published p2p lib snapshot

* Bump up p2p lib version

Co-authored-by: Ephraim Kigamba <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>

* Implement family questionnaire (#1232)

* WIP Moving FamilyQuestionnaireActivity along with dependencies

* Restored FamilyQuestionnaireActivity on Anc for all old references

* Restored FamilyQuestionnaireActivity on Anc for all old references

* ran spotless script for code styling

* Fixed save button texts on config file, moved constants to companion object in Family Questionnaire

* Fixed using familyId when opening Add Member Questionnaire

* Implement change family head functionality

* Fix app crash

Signed-off-by: Elly Kitoto <[email protected]>

* Activate in app reporting via config

Signed-off-by: Elly Kitoto <[email protected]>

* Add quick fix for showing register action for specific register

Signed-off-by: Elly Kitoto <[email protected]>

* ✨ Propagating the family name

* Update count on sync complete

Signed-off-by: Elly Kitoto <[email protected]>

* Remove deprecated environment variables

* Automation of Product Flavor releases via CI/CD

- Add support for releasing APKs from Flavors via CI/CD
- Add configuration to simulate flavors in build.gradle

* Disable CI configurations for deprecated modules

* Fix build 💚

* Close drawer on click report

Signed-off-by: Elly Kitoto <[email protected]>

* React to sync state on sync complete (#1248)

* React to sync state on sync complete

Signed-off-by: Elly Kitoto <[email protected]>

* Delete unused class

Signed-off-by: Elly Kitoto <[email protected]>

* Fix holding composable reference in viewmodel

Signed-off-by: Elly Kitoto <[email protected]>

* Implement remove family and family member  (#1236)

* remove family by group

* add deactivate family members toggle config

* refactor remove family package

* resolve family provile merge conflict

* update family profile event

* correct parameters for OverflowMenuClick event

* 1205 Remove family member (#1235)

* Add overflow and remove button

* Refactor RemoveFamilyQuestionnaireActivity

* spotlessApply

* Move RemoveProfile to other package

* Create MemberQuestionnaireActivity

* delete family member. ongoing

* Filter only active family members

Signed-off-by: Elly Kitoto <[email protected]>

Co-authored-by: Fikri Milano <[email protected]>
Co-authored-by: Elly Kitoto <[email protected]>

* 🎨 Update the task genration

* Refactor p2p implementation (#1243)

* Trigger CI

* Integrate p2p

* Add P2P sender and receiver dao implementations

* Implement fetching of data to be sent via P2P

* Add p2p lib as a project

* Initialize P2P library

* Init P2P lib options with sender and receiver transfer daos

* Update p2p receiver transfer dao with constructor

* Fix filter by lastupdated
Fix getting data types for sender and receiver transfer DAOs

* Sort records by last updated ascending
return resources as json data

* Fix JSON encoding resources for p2p transfer

* Resolve merge conflicts

* Add generically fetching each resource type for p2p transfer

* Save records on receiver device

* Filter records by greater than last updated at

* Add P2P menu icon on bottom navigation

* Fix resources search query for p2p (#1222)

* Add generically fetching each resource type for p2p transfer

* Fix resources search query for p2p

* Update engine to 0.1.0-alpha06-preview-p2p-SNAPSHOT

* Handle array index out of bounds when returned records is empty

* Use generic methoad to load various resources

* Make resource type dynamic

* Make resource type dynamic

* Use correct resorce type when parsing resources

Co-authored-by: Richard Kareko <[email protected]>

* Move data P2P retrieval and saving logic to base transfer DAO

* Hook up opening of P2P screen

* Set large heapsize setting to true

* Log ids of transferred resources to terminal

* Add group to list of resources for sync

* Update Resource.meta.lastUpdated date for inserts and updates

* Handle retrieval of Group class type

* Update p2p-lib directory

* Use published p2p lib snapshot

* Bump up p2p lib version

* Refactor p2p implementation
- Permoved some code cleanups on QuestApplication class

Signed-off-by: Elly Kitoto <[email protected]>

* Run spotlessApply

Signed-off-by: Elly Kitoto <[email protected]>

* Code clean up

* Remove unused import

* Run spotless apply

Co-authored-by: Richard Kareko <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>

* Fix task color code; refresh data when activity in foreground (#1262)

* Fix tasks color codes

Signed-off-by: Elly Kitoto <[email protected]>

* Refresh composable screens when the activity is resumed

Implemented a workaround based on the following recommendation (compose UI by default is not refreshed
when lifecycle is updated)
https://stackoverflow.com/questions/66546962/jetpack-compose-how-do-i-refresh-a-screen-when-app-returns-to-foreground

Signed-off-by: Elly Kitoto <[email protected]>

* refactor remove family and member (#1263)

add condition to remove managing entity if member is head

move remove functionality to FamilyRegisterDao

* Implement family edit button (#1259)

* implement edit family details

load register family questionnaire with type as edit

* implement view/edit family-member/patient details

load register family member questionnaire with type as edit

* handle family profile null checks

* rename bundleEntry variable

* Fix loading task form

Signed-off-by: Elly Kitoto <[email protected]>

* Task plan worker fix | Missing Careplan handiling

* Enable loading new config by re-opening the app (#1261)

* Enable loading new config by re-opening the app

* Load AppMainActivity if user is not logged out

* Address review comments

* Filter tasks with status-READY only

* Fix careplan not found bug

* Task completion feature

* Fix app crash on login

Signed-off-by: Elly Kitoto <[email protected]>

* Implement ANC enrollment (#1267)

* Launch anc enrollment questionnaire

Signed-off-by: Elly Kitoto <[email protected]>

* Fix refreshing register count

Signed-off-by: Elly Kitoto <[email protected]>

* Implement action for launching task form (#1266)

* Task plan worker fix | Missing Careplan handiling

* Filter tasks with status-READY only

* Task completion feature

* Task completes for Profile button

* Fix app crash

Signed-off-by: Elly Kitoto <[email protected]>

* Implement task form action (#1268)

* Task plan worker fix | Missing Careplan handiling

* Filter tasks with status-READY only

* Task completion feature

* Task completes for Profile button

* Fix task color coding on patient profile(#1270)

* Implement family edit functionality (#1272)

* fix family edit questionnaire not populating data

* implement view family overflow menu item

* spotlessApply

* resolve conflicts

Co-authored-by: Elly Kitoto <[email protected]>

* Refresh profile data

Signed-off-by: Elly Kitoto <[email protected]>

* Configure action icon and color

Signed-off-by: Elly Kitoto <[email protected]>

* Apply background color on patient profile

Signed-off-by: Elly Kitoto <[email protected]>

* Update ecbis version to v0.0.6

Signed-off-by: Elly Kitoto <[email protected]>

* reference configs for afyayangu app

* Fix failing tests; Ignore failing to be deleted test

Signed-off-by: Elly Kitoto <[email protected]>

* Remove unnecessary class TaskStatus

Signed-off-by: Elly Kitoto <[email protected]>

* Remove unnecessary code

Signed-off-by: Elly Kitoto <[email protected]>

Co-authored-by: maimoonak <[email protected]>
Co-authored-by: Fikri Milano <[email protected]>
Co-authored-by: roywanyaga <[email protected]>
Co-authored-by: Benjamin Mwalimu <[email protected]>
Co-authored-by: Rkareko <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>
Co-authored-by: Ephraim Kigamba <[email protected]>
Co-authored-by: aurangzaibumer <[email protected]>
Co-authored-by: Raazia Tariq <[email protected]>
Co-authored-by: Martin Ndegwa <[email protected]>
Co-authored-by: Richard Kareko <[email protected]>
Co-authored-by: maimoonak <[email protected]>
  • Loading branch information
13 people authored May 17, 2022
1 parent 67e2f0f commit 219659e
Show file tree
Hide file tree
Showing 356 changed files with 47,587 additions and 2,390 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "android/p2p"]
path = android/p2p
url = [email protected]:opensrp/p2p.git
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Quest | Swahili localization
- Quest | Added G6PD Patient Details page to show G6PD Status and Test Results
- Quest | Add tasking list
- Quest | Added ability to reference Related Persons and Patients to the Groups representing families

- EIR | Added workflow configurations
- EIR | Add Adverse Events feature to log any reactions after the first dose of vaccine using Structure map
Expand All @@ -51,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Engine | Fixed login authentication issue.
- Engine | Implement language switcher on profile page
- Engine | Add tasking abstraction
- Engine | Integrate Group resource for family representation
- Engine | Performance improvement when openning questionnaires and saving QRs
- Engine | Add debug mode to optionally load local config

Expand Down
21 changes: 10 additions & 11 deletions android/anc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,20 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '1.8'
jvmTarget = JavaVersion.VERSION_11.toString()
freeCompilerArgs = ['-Xjvm-default=compatibility']
}
buildFeatures {
compose true
viewBinding true
}
composeOptions {
kotlinCompilerExtensionVersion '1.0.4'
kotlinCompilerExtensionVersion '1.1.1'
}
packagingOptions {
exclude 'META-INF/ASL-2.0.txt'
Expand Down Expand Up @@ -139,12 +140,10 @@ android {
dependencies {
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
implementation(project(":engine"))
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation deps.lifecycle.viewmodel
implementation deps.work.runtime
Expand All @@ -155,7 +154,7 @@ dependencies {
androidTestImplementation "com.google.dagger:hilt-android-testing:$hiltVersion"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:$hiltVersion"

testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.4.2'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0'

testImplementation deps.junit5_api
testRuntimeOnly deps.junit5_engine
Expand Down
41 changes: 5 additions & 36 deletions android/anc/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.smartregister.fhircore.anc">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />

<application
android:name=".AncApplication"
android:allowBackup="true"
Expand All @@ -16,49 +13,21 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<activity
android:name="org.smartregister.fhircore.engine.ui.appsetting.AppSettingActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="org.smartregister.fhircore.engine.ui.login.LoginActivity"
android:exported="false" />
<activity
android:name="org.smartregister.fhircore.engine.ui.pin.PinLoginActivity"
android:exported="false" />
<activity
android:name="org.smartregister.fhircore.engine.ui.pin.PinSetupActivity"
android:exported="false" />
<activity
android:name=".ui.family.register.FamilyRegisterActivity"
android:exported="false" />
<activity
android:name=".ui.report.ReportHomeActivity"
android:exported="false" />
<activity android:name=".ui.family.register.FamilyRegisterActivity" />
<activity android:name=".ui.report.ReportHomeActivity" />
<activity
android:name=".ui.details.bmicompute.BmiQuestionnaireActivity"
android:exported="false"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.family.removefamily.RemoveFamilyQuestionnaireActivity"
android:exported="false"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.family.form.FamilyQuestionnaireActivity"
android:exported="false"
android:noHistory="true"
android:theme="@style/AppTheme" />
<activity
android:name="org.smartregister.fhircore.anc.ui.details.PatientDetailsActivity"
android:name=".ui.details.PatientDetailsActivity"
android:exported="false" />
<activity
android:name="org.smartregister.fhircore.engine.ui.questionnaire.QuestionnaireActivity"
android:exported="false"
android:theme="@style/AppTheme" />
<activity
android:name=".ui.anccare.encounters.EncounterListActivity"
android:exported="false" />
Expand All @@ -68,7 +37,7 @@

<service
android:name="org.smartregister.fhircore.engine.auth.AuthAndroidService"
android:exported="true">
android:exported="false">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.google.android.fhir.search.search
import javax.inject.Inject
import org.hl7.fhir.r4.model.Encounter
import org.smartregister.fhircore.anc.data.model.EncounterItem
import org.smartregister.fhircore.engine.data.domain.util.PaginationUtil
import org.smartregister.fhircore.engine.domain.util.PaginationConstant

class EncounterRepository @Inject constructor(val fhirEngine: FhirEngine) :
PagingSource<Int, EncounterItem>() {
Expand All @@ -43,8 +43,8 @@ class EncounterRepository @Inject constructor(val fhirEngine: FhirEngine) :
val encounters =
fhirEngine.search<Encounter> {
apply { filter(Encounter.SUBJECT, { value = "Patient/$patientId" }) }.getQuery()
from = nextPage * PaginationUtil.DEFAULT_PAGE_SIZE
count = PaginationUtil.DEFAULT_PAGE_SIZE
from = nextPage * PaginationConstant.DEFAULT_PAGE_SIZE
count = PaginationConstant.DEFAULT_PAGE_SIZE
}

val data =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import javax.inject.Inject
import kotlinx.coroutines.withContext
import org.hl7.fhir.r4.model.Flag
import org.hl7.fhir.r4.model.Patient
import org.hl7.fhir.r4.model.ResourceType
import org.smartregister.fhircore.anc.data.family.model.FamilyItem
import org.smartregister.fhircore.anc.data.family.model.FamilyMemberItem
import org.smartregister.fhircore.anc.data.patient.PatientRepository
Expand All @@ -40,8 +39,8 @@ import org.smartregister.fhircore.anc.util.asCodeableConcept
import org.smartregister.fhircore.anc.util.filterBy
import org.smartregister.fhircore.anc.util.filterByPatientName
import org.smartregister.fhircore.anc.util.loadRegisterConfig
import org.smartregister.fhircore.engine.data.domain.util.PaginationUtil
import org.smartregister.fhircore.engine.data.domain.util.RegisterRepository
import org.smartregister.fhircore.engine.domain.util.PaginationConstant
import org.smartregister.fhircore.engine.util.DispatcherProvider
import org.smartregister.fhircore.engine.util.extension.asReference
import org.smartregister.fhircore.engine.util.extension.extractFamilyTag
Expand All @@ -52,7 +51,7 @@ class FamilyRepository
constructor(
@ApplicationContext val context: Context,
override val fhirEngine: FhirEngine,
override val domainMapper: FamilyItemMapper,
override val dataMapper: FamilyItemMapper,
val dispatcherProvider: DispatcherProvider,
val ancPatientRepository: PatientRepository
) : RegisterRepository<Family, FamilyItem> {
Expand All @@ -72,15 +71,15 @@ constructor(
filterByPatientName(query)

sort(Patient.NAME, Order.ASCENDING)
count = if (loadAll) countAll().toInt() else PaginationUtil.DEFAULT_PAGE_SIZE
from = pageNumber * PaginationUtil.DEFAULT_PAGE_SIZE
count = if (loadAll) countAll().toInt() else PaginationConstant.DEFAULT_PAGE_SIZE
from = pageNumber * PaginationConstant.DEFAULT_PAGE_SIZE
}

patients.map { p ->
val members = searchFamilyMembers(p.logicalId)

val familyServices = ancPatientRepository.searchCarePlan(p.logicalId, p.extractFamilyTag())
domainMapper.mapToDomainModel(Family(p, members, familyServices))
dataMapper.transformInputToOutputModel(Family(p, members, familyServices))
}
}
}
Expand All @@ -99,7 +98,7 @@ constructor(
.map {
val services = ancPatientRepository.searchCarePlan(it.logicalId)
val conditions = ancPatientRepository.searchCondition(it.logicalId)
domainMapper.toFamilyMemberItem(it, conditions, services)
dataMapper.toFamilyMemberItem(it, conditions, services)
}
.sortedBy {
var weight = 0
Expand Down Expand Up @@ -141,7 +140,7 @@ constructor(
newHead.link.clear()

val newHeadFlag = Flag()
newHeadFlag.id = ResourceType.Flag.generateUniqueId()
newHeadFlag.id = generateUniqueId()
newHeadFlag.status = Flag.FlagStatus.ACTIVE
newHeadFlag.subject = newHead.asReference()
newHeadFlag.code = familyTag.asCodeableConcept()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import com.google.android.fhir.FhirEngine
import com.google.android.fhir.get
import com.google.android.fhir.logicalId
import com.google.android.fhir.search.count
import com.google.android.fhir.search.getQuery
import com.google.android.fhir.search.search
import dagger.hilt.android.qualifiers.ApplicationContext
import java.util.Date
Expand Down Expand Up @@ -58,8 +57,8 @@ import org.smartregister.fhircore.anc.util.SearchFilter
import org.smartregister.fhircore.anc.util.filterBy
import org.smartregister.fhircore.anc.util.loadRegisterConfig
import org.smartregister.fhircore.anc.util.loadRegisterConfigAnc
import org.smartregister.fhircore.engine.data.domain.util.PaginationUtil
import org.smartregister.fhircore.engine.data.domain.util.RegisterRepository
import org.smartregister.fhircore.engine.domain.util.PaginationConstant
import org.smartregister.fhircore.engine.util.DispatcherProvider
import org.smartregister.fhircore.engine.util.extension.due
import org.smartregister.fhircore.engine.util.extension.extractAddress
Expand All @@ -85,7 +84,7 @@ class PatientRepository
constructor(
@ApplicationContext val context: Context,
override val fhirEngine: FhirEngine,
override val domainMapper: AncItemMapper,
override val dataMapper: AncItemMapper,
val dispatcherProvider: DispatcherProvider
) : RegisterRepository<Anc, PatientItem> {

Expand All @@ -106,8 +105,8 @@ constructor(
filterBy(registerConfig.primaryFilter!!)
registerConfig.secondaryFilter?.let { filterBy(it) }

count = if (loadAll) countAll().toInt() else PaginationUtil.DEFAULT_PAGE_SIZE
from = pageNumber * PaginationUtil.DEFAULT_PAGE_SIZE
count = if (loadAll) countAll().toInt() else PaginationConstant.DEFAULT_PAGE_SIZE
from = pageNumber * PaginationConstant.DEFAULT_PAGE_SIZE
}
.distinctBy { it.subject.extractId() }

Expand All @@ -125,7 +124,7 @@ constructor(

val carePlans = searchCarePlan(it.logicalId)
val conditions = searchCondition(it.logicalId)
domainMapper.mapToDomainModel(Anc(it, head, conditions, carePlans))
dataMapper.transformInputToOutputModel(Anc(it, head, conditions, carePlans))
}
}
}
Expand Down Expand Up @@ -259,7 +258,9 @@ constructor(
}

fun fetchCarePlanItem(carePlan: List<CarePlan>): List<CarePlanItem> =
carePlan.filter { it.due() || it.overdue() }.map { CarePlanItemMapper.mapToDomainModel(it) }
carePlan.filter { it.due() || it.overdue() }.map {
CarePlanItemMapper.transformInputToOutputModel(it)
}

suspend fun fetchCarePlan(patientId: String): List<CarePlan> =
withContext(dispatcherProvider.io()) {
Expand Down Expand Up @@ -385,10 +386,8 @@ constructor(
withContext(dispatcherProvider.io()) {
val carePlanId = it.logicalId
val tasks =
fhirEngine.search<Task> {
apply { filter(Task.FOCUS, { value = "CarePlan/$carePlanId" }) }.getQuery()
}
if (!tasks.isNullOrEmpty()) {
fhirEngine.search<Task> { filter(Task.FOCUS, { value = "CarePlan/$carePlanId" }) }
if (tasks.isNotEmpty()) {
task = tasks[0]
listCarePlan.add(
UpcomingServiceItem(
Expand All @@ -408,7 +407,7 @@ constructor(
val listCarePlan = arrayListOf<EncounterItem>()
if (encounters.isNotEmpty()) {
for (i in encounters.indices) {
listCarePlan.add(EncounterItemMapper.mapToDomainModel(encounters[i]))
listCarePlan.add(EncounterItemMapper.transformInputToOutputModel(encounters[i]))
}
}
return listCarePlan
Expand Down Expand Up @@ -457,7 +456,7 @@ constructor(
val bmiEncounter = loadConfig(Template.BMI_ENCOUNTER, Encounter::class.java, bmiEncounterData)
fhirEngine.create(bmiEncounter)

val bmiWeightObservationRecordId = ResourceType.Observation.generateUniqueId()
val bmiWeightObservationRecordId = generateUniqueId()
val bmiWeightObservationData =
buildBmiConfigData(
patientId = patientId,
Expand All @@ -471,7 +470,7 @@ constructor(
loadConfig(Template.BMI_PATIENT_WEIGHT, Observation::class.java, bmiWeightObservationData)
fhirEngine.create(bmiWeightObservation)

val bmiHeightObservationRecordId = ResourceType.Observation.generateUniqueId()
val bmiHeightObservationRecordId = generateUniqueId()
val bmiHeightObservationData =
buildBmiConfigData(
patientId = patientId,
Expand All @@ -485,7 +484,7 @@ constructor(
loadConfig(Template.BMI_PATIENT_HEIGHT, Observation::class.java, bmiHeightObservationData)
fhirEngine.create(bmiHeightObservation)

val bmiObservationRecordId = ResourceType.Observation.generateUniqueId()
val bmiObservationRecordId = generateUniqueId()
val bmiObservationData =
buildBmiConfigData(
patientId = patientId,
Expand Down Expand Up @@ -538,7 +537,7 @@ constructor(
}

fun setAncItemMapperType(ancItemMapperType: AncItemMapper.AncItemMapperType) {
domainMapper.setAncItemMapperType(ancItemMapperType)
dataMapper.setAncItemMapperType(ancItemMapperType)
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ package org.smartregister.fhircore.anc.ui.anccare.details

import org.hl7.fhir.r4.model.CarePlan
import org.smartregister.fhircore.anc.data.model.CarePlanItem
import org.smartregister.fhircore.engine.data.domain.util.DomainMapper
import org.smartregister.fhircore.engine.domain.util.DataMapper
import org.smartregister.fhircore.engine.util.extension.due
import org.smartregister.fhircore.engine.util.extension.overdue

object CarePlanItemMapper : DomainMapper<CarePlan, CarePlanItem> {
object CarePlanItemMapper : DataMapper<CarePlan, CarePlanItem> {

override fun mapToDomainModel(dto: CarePlan): CarePlanItem {
override fun transformInputToOutputModel(inputModel: CarePlan): CarePlanItem {
var typeString = ""
for (j in dto.activity.indices) {
if (dto.activity[j].hasDetail())
if (dto.activity[j].detail.hasDescription()) typeString = dto.activity[j].detail.description
for (j in inputModel.activity.indices) {
if (inputModel.activity[j].hasDetail())
if (inputModel.activity[j].detail.hasDescription())
typeString = inputModel.activity[j].detail.description
}
return CarePlanItem(
carePlanIdentifier = dto.id,
carePlanIdentifier = inputModel.id,
title = typeString,
due = dto.due(),
overdue = dto.overdue()
due = inputModel.due(),
overdue = inputModel.overdue()
)
}
}
Loading

0 comments on commit 219659e

Please sign in to comment.