Skip to content

Commit

Permalink
Fix for the family removal issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleem92 authored and ellykits committed May 14, 2024
1 parent b2adf6e commit 9e3ffc3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ constructor(
* This function triggers removal of [Resource] s as per the [QuestionnaireConfig.groupResource]
* or [QuestionnaireConfig.removeResource] config properties.
*/
fun softDeleteResources(questionnaireConfig: QuestionnaireConfig) {
suspend fun softDeleteResources(questionnaireConfig: QuestionnaireConfig) {
if (questionnaireConfig.groupResource != null) {
removeGroup(
groupId = questionnaireConfig.groupResource!!.groupIdentifier,
Expand Down Expand Up @@ -860,40 +860,40 @@ constructor(
}
}

private fun removeGroup(groupId: String, removeGroup: Boolean, deactivateMembers: Boolean) {
private suspend fun removeGroup(
groupId: String,
removeGroup: Boolean,
deactivateMembers: Boolean,
) {
if (removeGroup) {
viewModelScope.launch(dispatcherProvider.io()) {
try {
defaultRepository.removeGroup(
groupId = groupId,
isDeactivateMembers = deactivateMembers,
configComputedRuleValues = emptyMap(),
)
} catch (exception: Exception) {
Timber.e(exception)
}
try {
defaultRepository.removeGroup(
groupId = groupId,
isDeactivateMembers = deactivateMembers,
configComputedRuleValues = emptyMap(),
)
} catch (exception: Exception) {
Timber.e(exception)
}
}
}

private fun removeGroupMember(
private suspend fun removeGroupMember(
memberId: String?,
groupIdentifier: String?,
memberResourceType: ResourceType?,
removeMember: Boolean,
) {
if (removeMember && !memberId.isNullOrEmpty()) {
viewModelScope.launch(dispatcherProvider.io()) {
try {
defaultRepository.removeGroupMember(
memberId = memberId,
groupId = groupIdentifier,
groupMemberResourceType = memberResourceType,
configComputedRuleValues = emptyMap(),
)
} catch (exception: Exception) {
Timber.e(exception)
}
try {
defaultRepository.removeGroupMember(
memberId = memberId,
groupId = groupIdentifier,
groupMemberResourceType = memberResourceType,
configComputedRuleValues = emptyMap(),
)
} catch (exception: Exception) {
Timber.e(exception)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ class QuestionnaireViewModelTest : RobolectricTest() {
}

@Test
fun testSoftDeleteShouldTriggerDefaultRepositoryRemoveGroupFunction() {
fun testSoftDeleteShouldTriggerDefaultRepositoryRemoveGroupFunction() = runTest {
val theQuestionnaireConfig =
QuestionnaireConfig(
id = samplePatientRegisterQuestionnaire.id,
Expand All @@ -836,7 +836,7 @@ class QuestionnaireViewModelTest : RobolectricTest() {
}

@Test
fun testSoftDeleteShouldTriggerDefaultRepositoryRemoveGroupMemberFunction() {
fun testSoftDeleteShouldTriggerDefaultRepositoryRemoveGroupMemberFunction() = runTest {
val theQuestionnaireConfig =
QuestionnaireConfig(
id = samplePatientRegisterQuestionnaire.id,
Expand All @@ -863,7 +863,7 @@ class QuestionnaireViewModelTest : RobolectricTest() {
}

@Test
fun testSoftDeleteShouldTriggerDefaultRepositoryUpdateResourceFunction() {
fun testSoftDeleteShouldTriggerDefaultRepositoryUpdateResourceFunction() = runTest {
val patient = Faker.buildPatient()
val theQuestionnaireConfig =
QuestionnaireConfig(
Expand Down

0 comments on commit 9e3ffc3

Please sign in to comment.