-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear text to re-generate it from SDK (#3008)
* Clear text to re-generate the text with HTML from SDK * spotlessApply * spotlessApply * Update android/quest/src/main/java/org/smartregister/fhircore/quest/ui/questionnaire/QuestionnaireActivity.kt --------- Co-authored-by: Peter Lubell-Doughtie <[email protected]>
- Loading branch information
1 parent
d35bd17
commit d7cabeb
Showing
3 changed files
with
91 additions
and
1 deletion.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...n/java/org/smartregister/fhircore/engine/util/extension/QuestionnaireResponseExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.util.extension | ||
|
||
import org.hl7.fhir.r4.model.QuestionnaireResponse | ||
import org.hl7.fhir.r4.model.QuestionnaireResponse.QuestionnaireResponseItemComponent | ||
|
||
/** Clears the item text in the [QuestionnaireResponse]. */ | ||
fun QuestionnaireResponse.clearText() { | ||
this.item.clearText() | ||
} | ||
|
||
/** Clears the text of items in the current list. */ | ||
private fun List<QuestionnaireResponseItemComponent>.clearText() { | ||
this.forEach { itemToClear -> | ||
itemToClear.text = null | ||
if (itemToClear.hasItem()) { | ||
itemToClear.item.clearText() | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...va/org/smartregister/fhircore/engine/util/extension/QuestionnaireResponseExtensionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2021-2024 Ona Systems, Inc | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.smartregister.fhircore.engine.util.extension | ||
|
||
import org.hl7.fhir.r4.model.QuestionnaireResponse | ||
import org.junit.Assert | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class QuestionnaireResponseExtensionTest { | ||
private lateinit var questionnaireResponse: QuestionnaireResponse | ||
|
||
@Before | ||
fun setup() { | ||
questionnaireResponse = | ||
QuestionnaireResponse().apply { | ||
addItem().apply { | ||
linkId = "1" | ||
text = "Text 1" | ||
addItem().apply { | ||
linkId = "2" | ||
text = "Text 2" | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testClearText() { | ||
questionnaireResponse.clearText() | ||
val item1 = questionnaireResponse.itemFirstRep | ||
Assert.assertNull(item1.text) | ||
val item2 = item1.itemFirstRep | ||
Assert.assertNull(item2.text) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters