Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
### Changes

- Hide next button when registration is going
- Remove hypertension and diabetes questions from medical history screen

## 2025.09.09

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,4 @@ sealed class NewMedicalHistoryViewEffect : NewMedicalHistoryEffect()

data class OpenPatientSummaryScreen(val patientUuid: UUID) : NewMedicalHistoryViewEffect()

data object ShowOngoingHypertensionTreatmentError : NewMedicalHistoryViewEffect()

data object ShowDiagnosisRequiredError : NewMedicalHistoryViewEffect()

data object ShowHypertensionDiagnosisRequiredError : NewMedicalHistoryViewEffect()

data object ShowChangeDiagnosisErrorDialog : NewMedicalHistoryViewEffect()

data object ShowOngoingDiabetesTreatmentErrorDialog : NewMedicalHistoryViewEffect()

data object GoBack : NewMedicalHistoryViewEffect()
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ data class CurrentFacilityLoaded(val facility: Facility) : NewMedicalHistoryEven

data class SyncTriggered(val registeredPatientUuid: UUID) : NewMedicalHistoryEvent()

data object ChangeDiagnosisNotNowClicked : NewMedicalHistoryEvent() {
override val analyticsName = "New Medical History:Change Diagnosis:Not Now Clicked"
}

data object BackClicked : NewMedicalHistoryEvent() {
override val analyticsName: String = "New Medical History:Back Clicked"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ data class NewMedicalHistoryModel(
val ongoingMedicalHistoryEntry: OngoingMedicalHistoryEntry,
val currentFacility: Facility?,
val nextButtonState: ButtonState?,
val hasShownChangeDiagnosisError: Boolean,
val showIsSmokingQuestion: Boolean,
val showSmokelessTobaccoQuestion: Boolean,
) : Parcelable {
Expand All @@ -36,12 +35,6 @@ data class NewMedicalHistoryModel(
val facilityDiabetesManagementEnabled: Boolean
get() = currentFacility!!.config.diabetesManagementEnabled

val hasAnsweredBothDiagnosisQuestions: Boolean
get() = !(ongoingMedicalHistoryEntry.diagnosedWithHypertension == Unanswered || ongoingMedicalHistoryEntry.hasDiabetes == Unanswered)

val hasAnsweredHypertensionDiagnosis: Boolean
get() = ongoingMedicalHistoryEntry.diagnosedWithHypertension != Unanswered

val registeringPatient: Boolean
get() = nextButtonState == ButtonState.SAVING

Expand All @@ -51,27 +44,12 @@ data class NewMedicalHistoryModel(
val diagnosedWithDiabetes: Boolean
get() = ongoingMedicalHistoryEntry.hasDiabetes == Yes

val answeredIsOnHypertensionTreatment: Boolean
get() = ongoingMedicalHistoryEntry.isOnHypertensionTreatment != Unanswered

val answeredIsOnDiabetesTreatment: Boolean
get() = ongoingMedicalHistoryEntry.isOnDiabetesTreatment != Unanswered

val showOngoingHypertensionTreatment: Boolean
get() = diagnosedWithHypertension && (country.isoCountryCode == Country.INDIA || country.isoCountryCode == Country.SRI_LANKA)

val showOngoingDiabetesTreatment: Boolean
get() = facilityDiabetesManagementEnabled && diagnosedWithDiabetes && country.isoCountryCode == Country.INDIA

private val hasNoHypertension: Boolean
get() = ongoingMedicalHistoryEntry.diagnosedWithHypertension == No

private val hasNoDiabetes: Boolean
get() = ongoingMedicalHistoryEntry.hasDiabetes == No

val showChangeDiagnosisError: Boolean
get() = facilityDiabetesManagementEnabled && !hasShownChangeDiagnosisError && hasNoHypertension && hasNoDiabetes

companion object {
fun default(
country: Country,
Expand All @@ -83,7 +61,6 @@ data class NewMedicalHistoryModel(
ongoingMedicalHistoryEntry = OngoingMedicalHistoryEntry(),
currentFacility = null,
nextButtonState = null,
hasShownChangeDiagnosisError = false,
showIsSmokingQuestion = showIsSmokingQuestion,
showSmokelessTobaccoQuestion = showSmokelessTobaccoQuestion
)
Expand All @@ -108,8 +85,4 @@ data class NewMedicalHistoryModel(
fun patientRegistered(): NewMedicalHistoryModel {
return copy(nextButtonState = ButtonState.SAVED)
}

fun changeDiagnosisErrorShown(): NewMedicalHistoryModel {
return copy(hasShownChangeDiagnosisError = true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,41 +100,10 @@ class NewMedicalHistoryScreen : Fragment(), NewMedicalHistoryUiActions, HandlesB
router.push(PatientSummaryScreenKey(patientUuid, OpenIntention.ViewNewPatient, Instant.now(utcClock)))
}

override fun showOngoingHypertensionTreatmentErrorDialog() {
SelectOngoingHypertensionTreatmentErrorDialog.show(fragmentManager = activity.supportFragmentManager)
}

override fun showOngoingDiabetesTreatmentErrorDialog() {
SelectOngoingDiabetesTreatmentErrorDialog.show(fragmentManager = activity.supportFragmentManager)
}

override fun goBack() {
router.pop()
}

override fun showDiagnosisRequiredErrorDialog() {
SelectDiagnosisErrorDialog.show(activity.supportFragmentManager)
}

override fun showHypertensionDiagnosisRequiredErrorDialog() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.select_diagnosis_error_diagnosis_required))
.setMessage(getString(R.string.select_diagnosis_error_enter_diagnosis_hypertension))
.setPositiveButton(getString(R.string.select_diagnosis_error_ok), null)
.show()
}

override fun showChangeDiagnosisErrorDialog() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.change_diagnosis_title))
.setMessage(getString(R.string.change_diagnosis_message))
.setPositiveButton(getString(R.string.change_diagnosis_positive), null)
.setNegativeButton(getString(R.string.change_diagnosis_negative)) { _, _ ->
viewModel.dispatch(ChangeDiagnosisNotNowClicked)
}
.show()
}

override fun onBackPressed(): Boolean {
viewModel.dispatch(BackClicked)
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@ import java.util.UUID

interface NewMedicalHistoryUiActions {
fun openPatientSummaryScreen(patientUuid: UUID)
fun showOngoingHypertensionTreatmentErrorDialog()
fun showDiagnosisRequiredErrorDialog()
fun showHypertensionDiagnosisRequiredErrorDialog()
fun showChangeDiagnosisErrorDialog()
fun showOngoingDiabetesTreatmentErrorDialog()

fun goBack()
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,15 @@ class NewMedicalHistoryUpdate : Update<NewMedicalHistoryModel, NewMedicalHistory
): Next<NewMedicalHistoryModel, NewMedicalHistoryEffect> {
return when (event) {
is NewMedicalHistoryAnswerToggled -> answerToggled(model, event.question, event.answer)
is SaveMedicalHistoryClicked -> saveClicked(model)
is SaveMedicalHistoryClicked -> registerPatient(model)
is PatientRegistered -> next(model.patientRegistered(), TriggerSync(event.patientUuid))
is OngoingPatientEntryLoaded -> next(model.ongoingPatientEntryLoaded(event.ongoingNewPatientEntry))
is CurrentFacilityLoaded -> currentFacilityLoaded(event, model)
is SyncTriggered -> dispatch(OpenPatientSummaryScreen(event.registeredPatientUuid))
is ChangeDiagnosisNotNowClicked -> registerPatient(model)
is BackClicked -> dispatch(GoBack)
}
}

private fun saveClicked(model: NewMedicalHistoryModel): Next<NewMedicalHistoryModel, NewMedicalHistoryEffect> {
return when {
model.showChangeDiagnosisError -> {
next(model.changeDiagnosisErrorShown(), ShowChangeDiagnosisErrorDialog)
}
model.facilityDiabetesManagementEnabled && !model.hasAnsweredBothDiagnosisQuestions -> {
dispatch(ShowDiagnosisRequiredError)
}
!model.facilityDiabetesManagementEnabled && !model.hasAnsweredHypertensionDiagnosis -> {
dispatch(ShowHypertensionDiagnosisRequiredError)
}
model.showOngoingHypertensionTreatment && !model.answeredIsOnHypertensionTreatment -> {
dispatch(ShowOngoingHypertensionTreatmentError)
}
model.showOngoingDiabetesTreatment && !model.answeredIsOnDiabetesTreatment -> {
dispatch(ShowOngoingDiabetesTreatmentErrorDialog)
}
else -> registerPatient(model)
}
}

private fun registerPatient(model: NewMedicalHistoryModel): Next<NewMedicalHistoryModel, NewMedicalHistoryEffect> {
return if (model.registeringPatient) {
noChange()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ class NewMedicalHistoryViewEffectHandler(
override fun handle(viewEffect: NewMedicalHistoryViewEffect) {
when (viewEffect) {
is OpenPatientSummaryScreen -> uiActions.openPatientSummaryScreen(viewEffect.patientUuid)
ShowOngoingHypertensionTreatmentError -> uiActions.showOngoingHypertensionTreatmentErrorDialog()
ShowDiagnosisRequiredError -> uiActions.showDiagnosisRequiredErrorDialog()
ShowHypertensionDiagnosisRequiredError -> uiActions.showHypertensionDiagnosisRequiredErrorDialog()
ShowChangeDiagnosisErrorDialog -> uiActions.showChangeDiagnosisErrorDialog()
ShowOngoingDiabetesTreatmentErrorDialog -> uiActions.showOngoingDiabetesTreatmentErrorDialog()
GoBack -> uiActions.goBack()
}.exhaustive()
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ import org.simple.clinic.common.ui.components.TopAppBar
import org.simple.clinic.common.ui.theme.SimpleTheme
import org.simple.clinic.medicalhistory.Answer
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.DiagnosedWithDiabetes
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.DiagnosedWithHypertension
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.IsOnDiabetesTreatment
import org.simple.clinic.medicalhistory.MedicalHistoryQuestion.IsOnHypertensionTreatment
import org.simple.clinic.medicalhistory.OngoingMedicalHistoryEntry
import org.simple.clinic.medicalhistory.newentry.NewMedicalHistoryModel

Expand Down Expand Up @@ -80,33 +76,13 @@ fun NewMedicalHistoryUi(
val scrollState = rememberScrollState()
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(scrollState)
.padding(paddingValues)
.padding(dimensionResource(R.dimen.spacing_8)),
.fillMaxWidth()
.verticalScroll(scrollState)
.padding(paddingValues)
.padding(dimensionResource(R.dimen.spacing_8)),
verticalArrangement = Arrangement.spacedBy(dimensionResource(R.dimen.spacing_8))
) {
val showDiabetesDiagnosis = model.hasLoadedCurrentFacility && model.facilityDiabetesManagementEnabled
MedicalHistoryDiagnosisWithTreatment(
diagnosisLabel = stringResource(R.string.medicalhistory_diagnosis_hypertension_required),
diagnosisQuestion = DiagnosedWithHypertension,
diagnosisAnswer = model.ongoingMedicalHistoryEntry.diagnosedWithHypertension,
treatmentQuestion = IsOnHypertensionTreatment(model.country.isoCountryCode),
treatmentAnswer = model.ongoingMedicalHistoryEntry.isOnHypertensionTreatment,
showTreatmentQuestion = model.showOngoingHypertensionTreatment,
onSelectionChange = onSelectionChange
)
if (showDiabetesDiagnosis) {
MedicalHistoryDiagnosisWithTreatment(
diagnosisLabel = stringResource(R.string.medicalhistory_diagnosis_diabetes_required),
diagnosisQuestion = DiagnosedWithDiabetes,
diagnosisAnswer = model.ongoingMedicalHistoryEntry.hasDiabetes,
treatmentQuestion = IsOnDiabetesTreatment,
treatmentAnswer = model.ongoingMedicalHistoryEntry.isOnDiabetesTreatment,
showTreatmentQuestion = model.showOngoingDiabetesTreatment,
onSelectionChange = onSelectionChange
)
}
HistoryContainer(
heartAttackAnswer = model.ongoingMedicalHistoryEntry.hasHadHeartAttack,
strokeAnswer = model.ongoingMedicalHistoryEntry.hasHadStroke,
Expand Down Expand Up @@ -139,7 +115,6 @@ private val previewMedicalHistoryModel = NewMedicalHistoryModel(
ongoingMedicalHistoryEntry = OngoingMedicalHistoryEntry(),
currentFacility = null,
nextButtonState = null,
hasShownChangeDiagnosisError = true,
showIsSmokingQuestion = true,
showSmokelessTobaccoQuestion = true
)
Expand All @@ -151,7 +126,7 @@ private fun NewMedicalHistoryUiPreview() {
model = previewMedicalHistoryModel,
navigationIconClick = {},
onNextClick = {}
) { question, answer ->
) { _, _ ->
//do nothing
}
}
Loading