Skip to content

Commit

Permalink
Merge branch 'main' into harmonize-sync-status
Browse files Browse the repository at this point in the history
  • Loading branch information
Lentumunai-Mark authored Jan 10, 2025
2 parents 936094e + becf27f commit bd9b1b8
Show file tree
Hide file tree
Showing 12 changed files with 312 additions and 90 deletions.
4 changes: 2 additions & 2 deletions android/buildSrc/src/main/kotlin/BuildConfigs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ object BuildConfigs {
const val minSdk = 26
const val compileSdk = 34
const val targetSdk = 34
const val versionCode = 11
const val versionName = "2.0.1"
const val versionCode = 12
const val versionName = "2.0.2"
const val applicationId = "org.smartregister.opensrp"
const val jvmToolchain = 17
const val kotlinCompilerExtensionVersion = "1.5.8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import org.hl7.fhir.r4.model.ImplementationGuide
import org.hl7.fhir.r4.model.ListResource
import org.hl7.fhir.r4.model.MetadataResource
import org.hl7.fhir.r4.model.Parameters
import org.hl7.fhir.r4.model.Reference
import org.hl7.fhir.r4.model.Resource
import org.hl7.fhir.r4.model.ResourceType
import org.hl7.fhir.r4.model.SearchParameter
Expand Down Expand Up @@ -361,26 +362,46 @@ constructor(
}
}
} else {
composition.retrieveCompositionSections().forEach {
if (it.hasFocus() && it.focus.hasReferenceElement() && it.focus.hasIdentifier()) {
val configIdentifier = it.focus.identifier.value
val referenceResourceType = it.focus.reference.substringBefore(TYPE_REFERENCE_DELIMITER)
if (isAppConfig(referenceResourceType) && !isIconConfig(configIdentifier)) {
val extractedId = it.focus.extractId()
try {
val configBinary = fhirEngine.get<Binary>(extractedId)
configsJsonMap[configIdentifier] = configBinary.content.decodeToString()
} catch (resourceNotFoundException: ResourceNotFoundException) {
Timber.e("Missing Binary file with ID :$extractedId")
withContext(dispatcherProvider.main()) { configsLoadedCallback(false) }
}
composition.retrieveCompositionSections().forEach { sectionComponent ->
if (sectionComponent.hasFocus()) {
addBinaryToConfigsJsonMap(
sectionComponent.focus,
configsLoadedCallback,
)
}
if (sectionComponent.hasEntry() && sectionComponent.entry.isNotEmpty()) {
sectionComponent.entry.forEach { entryReference ->
addBinaryToConfigsJsonMap(
entryReference,
configsLoadedCallback,
)
}
}
}
}
configsLoadedCallback(true)
}

private suspend fun addBinaryToConfigsJsonMap(
entryReference: Reference,
configsLoadedCallback: (Boolean) -> Unit,
) {
if (entryReference.hasReferenceElement() && entryReference.hasIdentifier()) {
val configIdentifier = entryReference.identifier.value
val referenceResourceType = entryReference.reference.substringBefore(TYPE_REFERENCE_DELIMITER)
if (isAppConfig(referenceResourceType) && !isIconConfig(configIdentifier)) {
val extractedId = entryReference.extractId()
try {
val configBinary = fhirEngine.get<Binary>(extractedId.toString())
configsJsonMap[configIdentifier] = configBinary.content.decodeToString()
} catch (resourceNotFoundException: ResourceNotFoundException) {
Timber.e("Missing Binary file with ID :$extractedId")
withContext(dispatcherProvider.main()) { configsLoadedCallback(false) }
}
}
}
}

private fun isAppConfig(referenceResourceType: String) =
referenceResourceType in arrayOf(ResourceType.Binary.name, ResourceType.Parameters.name)

Expand Down Expand Up @@ -438,41 +459,30 @@ constructor(
val parsedAppId = appId.substringBefore(TYPE_REFERENCE_DELIMITER).trim()
val compositionResource = fetchRemoteCompositionByAppId(parsedAppId)
compositionResource?.let { composition ->
composition
.retrieveCompositionSections()
.asSequence()
.filter { it.hasFocus() && it.focus.hasReferenceElement() }
.groupBy { section ->
section.focus.reference.substringBefore(
TYPE_REFERENCE_DELIMITER,
missingDelimiterValue = "",
)
val compositionSections = composition.retrieveCompositionSections()
val sectionComponentMap = mutableMapOf<String, MutableList<Composition.SectionComponent>>()
compositionSections.forEach { sectionComponent ->
if (sectionComponent.hasFocus() && sectionComponent.focus.hasReferenceElement()) {
val key =
sectionComponent.focus.reference.substringBefore(
delimiter = TYPE_REFERENCE_DELIMITER,
missingDelimiterValue = "",
)
sectionComponentMap.getOrPut(key) { mutableListOf() }.apply { add(sectionComponent) }
}
.filter { entry -> entry.key in FILTER_RESOURCE_LIST }
.forEach { entry: Map.Entry<String, List<Composition.SectionComponent>> ->
if (entry.key == ResourceType.List.name) {
processCompositionListResources(entry)
} else {
val chunkedResourceIdList = entry.value.chunked(MANIFEST_PROCESSOR_BATCH_SIZE)

chunkedResourceIdList.forEach { sectionComponents ->
Timber.d(
"Fetching config resource ${entry.key}: with ids ${
sectionComponents.joinToString(
",",
)
}",
if (sectionComponent.hasEntry() && sectionComponent.entry.isNotEmpty()) {
sectionComponent.entry.forEach {
val key =
it.reference.substringBefore(
delimiter = TYPE_REFERENCE_DELIMITER,
missingDelimiterValue = "",
)
fetchResources(
resourceType = entry.key,
resourceIdList =
sectionComponents.map { sectionComponent ->
sectionComponent.focus.extractId()
},
)
}
sectionComponentMap.getOrPut(key) { mutableListOf() }.apply { add(sectionComponent) }
}
}
}

processCompositionSectionComponent(sectionComponentMap)

// Save composition after fetching all the referenced section resources
addOrUpdate(compositionResource)
Expand All @@ -482,6 +492,35 @@ constructor(
}
}

private suspend fun processCompositionSectionComponent(
sectionComponentMap: Map<String, List<Composition.SectionComponent>>,
) {
sectionComponentMap
.filter { entry -> entry.key in FILTER_RESOURCE_LIST }
.forEach { entry: Map.Entry<String, List<Composition.SectionComponent>> ->
if (entry.key == ResourceType.List.name) {
processCompositionListResources(entry)
} else {
val chunkedResourceIdList = entry.value.chunked(MANIFEST_PROCESSOR_BATCH_SIZE)

chunkedResourceIdList.forEach { sectionComponents ->
Timber.d(
"Fetching config resource ${entry.key}: with ids ${
sectionComponents.joinToString(
",",
)
}",
)
fetchResources(
resourceType = entry.key,
resourceIdList =
sectionComponents.map { sectionComponent -> sectionComponent.focus.extractId() },
)
}
}
}
}

suspend fun fetchRemoteImplementationGuideByAppId(
appId: String?,
appVersionCode: Int?,
Expand Down
8 changes: 6 additions & 2 deletions android/engine/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<string name="sync_completed">Synchronisation terminée</string>
<string name="syncing">Synchronisation</string>
<string name="syncing_up" >Synchronisation&#8230;</string>
<string name="syncing_down" >Synchronisation en cours&#8230;</string>
<string name="syncing_down" >Synchronisation&#8230;</string>
<string name="syncing_initiated">Synchronisation initiée&#8230;</string>
<string name="sync_failed">La synchronisation a échoué. Vérifier la connexion internet ou réessayer plus tard</string>
<string name="sync_completed_with_errors">La synchronisation s\'est terminée avec des erreurs. Réessayer...</string>
Expand Down Expand Up @@ -55,7 +55,7 @@
<string name="syncing_retry">Réessayer la synchronisation</string>
<string name="syncing_in_progress">Synchronisation en cours</string>
<string name="loading">Chargement</string>
<string name="loading_ellipsis">Chargement</string>
<string name="loading_ellipsis">Chargement</string>
<string name="error_logging_out">Message d\'erreur de déconnexion %1$s</string>
<string name="cannot_logout_user">Impossible de se déconnecter : Déjà déconnecté ou l\'appareil est hors ligne.</string>
<string name="error_loading_config_http_error">Impossible de charger la configuration. Veuillez réessayer plus tard</string>
Expand All @@ -75,6 +75,8 @@
<string name="questionnaire_alert_invalid_message">Des erreurs de validation ont été détectées. Corrigez les erreurs et soumettez à nouveau.</string>
<string name="questionnaire_alert_invalid_title">Échec de la validation</string>
<string name="questionnaire_alert_ack_button_title">D\'ACCORD</string>
<string name="questionnaire_alert_open_draft_button_title">Projet ouvert</string>
<string name="questionnaire_alert_delete_draft_button_title">Supprimer le projet</string>
<string name="username">Nom d\'utilisateur</string>
<string name="password">Mot de passe</string>
<string name="forgot_password">Mot de passe oublié</string>
Expand Down Expand Up @@ -184,4 +186,6 @@
<string name="apply_filter">APPLIQUER LE FILLTRE</string>
<string name="questionnaire_save_draft_title">Enregistrer les modifications du brouillon</string>
<string name="questionnaire_save_draft_message">Voulez-vous enregistrer les modifications du brouillon ?</string>
<string name="open_draft_changes_title">Modifications du projet en cours</string>
<string name="open_draft_changes_message">Vous pouvez rouvrir un projet de formulaire enregistré pour le poursuivre ou le supprimer</string>
</resources>
32 changes: 31 additions & 1 deletion android/engine/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<resources>
<string name="manual_sync">Sinkronisasi manual</string>
<string name="sync">Sinkronkan</string>
<string name="language">Bahasa</string>
<string name="logout_as_user">Keluar sebagai </string>
<string name="show_overdue">Tampilkan yang terlambat</string>
<string name="search_hint">Cari nama atau nomor ID</string>
<string name="search">Cari nama</string>
<string name="sync_data">SINKRONKAN DATA</string>
<string name="scan_bar_code">PINDAI BARCODE</string>
<string name="empty_client_list_message_title">Tidak Ada Hasil</string>
<string name="empty_client_list_message_details">Maaf, kami tidak dapat menemukan klien dengan nama atau nomor ID tersebut</string>
Expand Down Expand Up @@ -65,12 +68,15 @@
<string name="questionnaire_in_progress_alert_back_pressed_message">Apakah Anda yakin ingin membuang jawabannya?</string>
<string name="questionnaire_alert_back_pressed_title">Buang perubahan</string>
<string name="questionnaire_alert_back_pressed_button_title">Buang</string>
<string name="questionnaire_alert_back_pressed_save_draft_button_title">Simpan sebagian draf</string>
<string name="questionnaire_alert_back_pressed_save_draft_button_title">Simpan sebagai draf</string>
<string name="questionnaire_alert_neutral_button_title">Batal</string>
<string name="questionnaire_alert_negative_button_title">Batalkan Perubahan</string>
<string name="questionnaire_alert_confirm_button_title">Ya</string>
<string name="questionnaire_alert_invalid_message">Detail yang diberikan mengalami kesalahan validasi. Atasi kesalahan dan kirim lagi</string>
<string name="questionnaire_alert_invalid_title">Validasi Gagal</string>
<string name="questionnaire_alert_ack_button_title">OK</string>
<string name="questionnaire_alert_open_draft_button_title">Buka draf</string>
<string name="questionnaire_alert_delete_draft_button_title">Hapus draf</string>
<string name="username">Username</string>
<string name="password">Password</string>
<string name="forgot_password">Lupa Password</string>
Expand Down Expand Up @@ -123,6 +129,7 @@
<string name="upcoming_services">PELAYANAN SELANJUTNYA</string>
<string name="service_card">KARTU PELAYANAN</string>
<string name="other_patients">Pasien lainnya</string>
<string name="select_location">Pilih lokasi</string>
<string name="responses">RESPONS (%1$s)</string>
<string name="multi_user_login_attempt">Mencoba masuk dengan pengguna lain</string>
<string name="please_wait">Mohon tunggu...</string>
Expand All @@ -144,6 +151,7 @@
<string name="weeks">Pekan/minggu</string>
<string name="days">Hari</string>
<string name="initializing">Menginisiasi pengaturan &#8230;</string>
<string name="initializing_application">Initializing application &#8230;</string>
<string name="username_sample" translatable="false">e.g JohnDoe</string>
<string name="percentage_progress" translatable="false">%1$d%%</string>
<string name="error_occurred">Ada yang salah...</string>
Expand All @@ -157,6 +165,7 @@
<string name="device_info">Info perangkat</string>
<string name="refresh">Muat ulang</string>
<string name="unsynced_resources">Resources Tidak Disinkronkan</string>
<string name="all_resources_synced">Semua data telah tersinkronisasi</string>
<string name="synced_statistics">Statistik Tersinkronisasi</string>
<string name="all_data_synced">Semua data disinkronkan</string>
<string name="invalid_offline_login_state">Diperlukan pengaturan pengguna. Aktifkan koneksi internet Anda</string>
Expand All @@ -175,4 +184,25 @@
<string name="device_date">Tanggal</string>
<string name="device">Perangkat</string>
<string name="data_migration_version">Versi migrasi data</string>
<string name="ok">Oke</string>
<string name="add">TAMBAH</string>
<string name="data_migration_started">Memulai migrasi data dari versi %1$d</string>
<string name="data_migration_completed">Data aplikasi berhasil dimigrasikan ke versi %1$d</string>
<string name="help">Bantu</string>
<string name="no_data">Tidak ada data yang disetel</string>
<string name="sync_complete">Sinkronisasi selesai</string>
<string name="sync_error">Kesalahan sinkronisasi</string>
<string name="minutes_remaining">Menghitung sisa waktu dalam menit…</string>
<string name="sync_up_inprogress">%1$d%% Sinkronisasi ke atas…</string>
<string name="sync_down_inprogress">%1$d%% Sinkronisasi ke bawah…</string>
<string name="retry">COBA LAGI</string>
<string name="unsynced_data_present">Ada beberapa data yang belum tersinkronisasi</string>
<string name="missing_supervisor_contact">Kontak supervisor hilang atau nomor telepon yang diberikan tidak valid</string>
<string name="apply_filter">TERAPKAN FILTER</string>
<string name="questionnaire_save_draft_title">Simpan perubahan draf</string>
<string name="questionnaire_save_draft_message">Apakah Anda ingin menyimpan perubahan draf?</string>
<string name="open_draft_changes_title">Buka perubahan draf</string>
<string name="open_draft_changes_message">Anda dapat membuka kembali formulir draf yang disimpan untuk melanjutkan atau menghapusnya</string>
<string name="button_pagination_next">Berikutnya</string>
<string name="button_pagination_previous">Sebelumnya</string>
</resources>
Loading

0 comments on commit bd9b1b8

Please sign in to comment.