Skip to content

Commit cb14a25

Browse files
authored
added visit number to profile view (#91)
* added visit number to profile view * Update PersonalData.kt
1 parent 60b4f1f commit cb14a25

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ fun CarePlan.CarePlanActivityComponent.shouldShowOnProfile(): Boolean {
8282
.not()
8383
}
8484

85+
fun CarePlan.extractVisitNumber(): String? {
86+
val visitNumberCoding =
87+
this.category.firstOrNull {
88+
(it.coding.firstOrNull()?.system ?: "") == "https://d-tree.org/fhir/care-plan-visit-number"
89+
}
90+
return visitNumberCoding?.coding?.firstOrNull()?.code
91+
}
92+
8593
fun CarePlan.CarePlanStatus.toCoding() = Coding(this.system, this.toCode(), this.display)
8694

8795
fun CarePlan.isLastTask(task: Task) =

android/engine/src/main/res/values/strings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@
168168
<string name="upload_strategy">Upload Strategy</string>
169169
<string name="ok">Ok</string>
170170
<string name="opening_form">Opening form...</string>
171+
<string name="visit">Visit</string>
171172
</resources>

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/patient/profile/components/PersonalData.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.smartregister.fhircore.quest.ui.patient.profile.components
1818

19-
import android.graphics.Color
2019
import androidx.compose.foundation.background
2120
import androidx.compose.foundation.layout.Arrangement
2221
import androidx.compose.foundation.layout.Column
@@ -100,6 +99,9 @@ fun PersonalData(
10099
) {
101100
OtherDetailsItem(title = stringResource(R.string.sex), value = patientProfileViewData.sex)
102101
OtherDetailsItem(title = stringResource(R.string.age), value = patientProfileViewData.age)
102+
patientProfileViewData.visitNumber?.let {
103+
OtherDetailsItem(title = stringResource(R.string.visit), value = it)
104+
}
103105
}
104106
}
105107
}
@@ -124,6 +126,7 @@ fun PersonalDataPreview() {
124126
sex = "Female",
125127
age = "48y",
126128
dob = "08 Dec",
129+
visitNumber = "1",
127130
identifier = "123455",
128131
)
129132
PersonalData(patientProfileViewData = patientProfileData)

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/shared/models/ProfileViewData.kt

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ sealed class ProfileViewData(
6363
val addressTracingCatchment: String = "",
6464
val addressPhysicalLocator: String = "",
6565
val currentCarePlan: CarePlan? = null,
66+
val visitNumber: String? = null,
6667
val phoneContacts: List<String> = emptyList(),
6768
val observations: List<Observation> = emptyList(),
6869
val practitioners: List<Practitioner> = emptyList(),

android/quest/src/main/java/org/smartregister/fhircore/quest/util/mappers/ProfileViewDataMapper.kt

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import org.smartregister.fhircore.engine.ui.theme.SuccessColor
3939
import org.smartregister.fhircore.engine.util.extension.asDdMmYyyy
4040
import org.smartregister.fhircore.engine.util.extension.canBeCompleted
4141
import org.smartregister.fhircore.engine.util.extension.extractId
42+
import org.smartregister.fhircore.engine.util.extension.extractVisitNumber
4243
import org.smartregister.fhircore.engine.util.extension.getQuestionnaire
4344
import org.smartregister.fhircore.engine.util.extension.getQuestionnaireName
4445
import org.smartregister.fhircore.engine.util.extension.makeItReadable
@@ -92,6 +93,7 @@ class ProfileViewDataMapper @Inject constructor(@ApplicationContext val context:
9293
observations = inputModel.observations,
9394
guardians = inputModel.guardians,
9495
currentCarePlan = inputModel.currentCarePlan,
96+
visitNumber = inputModel.currentCarePlan?.extractVisitNumber(),
9597
tasks =
9698
inputModel.tasks.map {
9799
PatientProfileRowItem(

0 commit comments

Comments
 (0)