Skip to content

Commit c08e6e1

Browse files
Fix enhancements conflicts (#3612)
🐛 Fix conflicts
1 parent 00a71a9 commit c08e6e1

File tree

43 files changed

+2103
-1336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2103
-1336
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
1. Added a new class (PdfGenerator) for generating PDF documents from HTML content using Android's WebView and PrintManager
1313
2. Introduced a new class (HtmlPopulator) to populate HTML templates with data from a Questionnaire Response
1414
3. Implemented functionality to launch PDF generation using a configuration setup
15+
- Added Save draft MVP functionality
1516

1617
## [1.1.0] - 2024-02-15
1718

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
same "printed page" as the copyright notice for easier
188188
identification within third-party archives.
189189

190-
Copyright 2021-2023, Ona Systems, Inc.
190+
Copyright 2021-2024, Ona Systems, Inc.
191191

192192
Licensed under the Apache License, Version 2.0 (the "License");
193193
you may not use this file except in compliance with the License.

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/ConfigurationRegistry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ constructor(
613613
context = context,
614614
configService = configService,
615615
metadataResource = resource,
616-
filePath =
616+
subFilePath =
617617
"${KnowledgeManagerUtil.KNOWLEDGE_MANAGER_ASSETS_SUBFOLDER}/${resource.resourceType}/${resource.idElement.idPart}.json",
618618
),
619619
)

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/register/RegisterContentConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.smartregister.fhircore.engine.domain.model.RuleConfig
2323
data class RegisterContentConfig(
2424
val separator: String? = null,
2525
val display: String? = null,
26+
val placeholderColor: String? = null,
2627
val rules: List<RuleConfig>? = null,
2728
val visible: Boolean? = null,
2829
val computedRules: List<String>? = null,

android/engine/src/main/java/org/smartregister/fhircore/engine/configuration/view/CompoundTextProperties.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ data class CompoundTextProperties(
5555
val textCase: TextCase? = null,
5656
val overflow: TextOverFlow? = null,
5757
val letterSpacing: Int = 0,
58+
val textInnerPadding: Int = 0,
5859
) : ViewProperties(), Parcelable {
5960
override fun interpolate(computedValuesMap: Map<String, Any>): CompoundTextProperties {
6061
return this.copy(

android/engine/src/main/java/org/smartregister/fhircore/engine/di/FhirValidatorModule.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import ca.uhn.fhir.context.FhirContext
2020
import ca.uhn.fhir.context.support.DefaultProfileValidationSupport
2121
import ca.uhn.fhir.context.support.IValidationSupport
2222
import ca.uhn.fhir.validation.FhirValidator
23+
import dagger.Lazy
2324
import dagger.Module
2425
import dagger.Provides
2526
import dagger.hilt.InstallIn
@@ -30,6 +31,8 @@ import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerVali
3031
import org.hl7.fhir.common.hapi.validation.support.UnknownCodeSystemWarningValidationSupport
3132
import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain
3233
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator
34+
import org.smartregister.fhircore.engine.util.DispatcherProvider
35+
import org.smartregister.fhircore.engine.util.validation.ResourceValidationRequestHandler
3336

3437
@Module
3538
@InstallIn(SingletonComponent::class)
@@ -52,4 +55,13 @@ class FhirValidatorModule {
5255
instanceValidator.invalidateCaches()
5356
return fhirContext.newValidator().apply { registerValidatorModule(instanceValidator) }
5457
}
58+
59+
@Provides
60+
@Singleton
61+
fun provideResourceValidationRequestHandler(
62+
fhirValidatorProvider: Lazy<FhirValidator>,
63+
dispatcherProvider: DispatcherProvider,
64+
): ResourceValidationRequestHandler {
65+
return ResourceValidationRequestHandler(fhirValidatorProvider.get(), dispatcherProvider)
66+
}
5567
}

android/engine/src/main/java/org/smartregister/fhircore/engine/ui/base/AlertDialogue.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ object AlertDialogue {
5555
@StringRes confirmButtonText: Int = R.string.questionnaire_alert_confirm_button_title,
5656
neutralButtonListener: ((d: DialogInterface) -> Unit)? = null,
5757
@StringRes neutralButtonText: Int = R.string.questionnaire_alert_neutral_button_title,
58+
negativeButtonListener: ((d: DialogInterface) -> Unit)? = null,
59+
@StringRes negativeButtonText: Int = R.string.questionnaire_alert_negative_button_title,
5860
cancellable: Boolean = false,
5961
options: Array<AlertDialogListItem>? = null,
6062
): AlertDialog {
@@ -71,6 +73,9 @@ object AlertDialogue {
7173
confirmButtonListener?.let {
7274
setPositiveButton(confirmButtonText) { d, _ -> confirmButtonListener.invoke(d) }
7375
}
76+
negativeButtonListener?.let {
77+
setNegativeButton(negativeButtonText) { d, _ -> negativeButtonListener.invoke(d) }
78+
}
7479
options?.run { setSingleChoiceItems(options.map { it.value }.toTypedArray(), -1, null) }
7580
}
7681
.show()
@@ -172,6 +177,8 @@ object AlertDialogue {
172177
@StringRes confirmButtonText: Int,
173178
neutralButtonListener: ((d: DialogInterface) -> Unit),
174179
@StringRes neutralButtonText: Int,
180+
negativeButtonListener: ((d: DialogInterface) -> Unit),
181+
@StringRes negativeButtonText: Int,
175182
cancellable: Boolean = true,
176183
options: List<AlertDialogListItem>? = null,
177184
): AlertDialog {
@@ -184,6 +191,8 @@ object AlertDialogue {
184191
confirmButtonText = confirmButtonText,
185192
neutralButtonListener = neutralButtonListener,
186193
neutralButtonText = neutralButtonText,
194+
negativeButtonListener = negativeButtonListener,
195+
negativeButtonText = negativeButtonText,
187196
cancellable = cancellable,
188197
options = options?.toTypedArray(),
189198
)

android/engine/src/main/java/org/smartregister/fhircore/engine/util/KnowledgeManagerUtil.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,26 @@ object KnowledgeManagerUtil {
2828
const val KNOWLEDGE_MANAGER_ASSETS_SUBFOLDER = "km"
2929
private val fhirContext = FhirContext.forR4Cached()
3030

31+
/**
32+
* Util method that creates a physical file and writes the Metadata FHIR resource content to it.
33+
* Note the filepath provided is appended to the apps private directory as returned by
34+
* Context.filesDir
35+
*
36+
* @param subFilePath the path of the file but within the apps private directory
37+
* {Context.filesDir}
38+
* @param metadataResource the actual FHIR Resource of type MetadataResource
39+
* @param configService the configuration service
40+
* @param context the application context
41+
* @return File the file object after creating and writing
42+
*/
3143
fun writeToFile(
32-
filePath: String,
44+
subFilePath: String,
3345
metadataResource: MetadataResource,
3446
configService: ConfigService,
3547
context: Context,
3648
): File =
3749
context
38-
.createFileInPrivateDirectory(filePath)
50+
.createFileInPrivateDirectory(subFilePath)
3951
.also { it.parentFile?.mkdirs() }
4052
.apply {
4153
writeText(

android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/FhirValidatorExtension.kt

Lines changed: 0 additions & 76 deletions
This file was deleted.

android/engine/src/main/java/org/smartregister/fhircore/engine/util/extension/QuestionnaireExtension.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.hl7.fhir.r4.model.Expression
2626
import org.hl7.fhir.r4.model.IdType
2727
import org.hl7.fhir.r4.model.Questionnaire
2828
import org.hl7.fhir.r4.model.QuestionnaireResponse
29+
import org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseStatus
2930
import org.hl7.fhir.r4.model.StringType
3031
import org.smartregister.fhircore.engine.configuration.LinkIdType
3132
import org.smartregister.fhircore.engine.configuration.QuestionnaireConfig
@@ -292,3 +293,19 @@ suspend fun Questionnaire.prepopulateUniqueIdAssignment(
292293
}
293294
}
294295
}
296+
297+
/**
298+
* Determines the [QuestionnaireResponse.Status] depending on the [saveDraft] and [isEditable]
299+
* values contained in the [QuestionnaireConfig]
300+
*
301+
* returns [COMPLETED] when [isEditable] is [true] returns [INPROGRESS] when [saveDraft] is [true]
302+
*/
303+
fun QuestionnaireConfig.questionnaireResponseStatus(): String? {
304+
return if (this.isEditable()) {
305+
QuestionnaireResponseStatus.COMPLETED.toCode()
306+
} else if (this.saveDraft) {
307+
QuestionnaireResponseStatus.INPROGRESS.toCode()
308+
} else {
309+
null
310+
}
311+
}

0 commit comments

Comments
 (0)