Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If items inside token is distinct of 2 show display name #28

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
2 changes: 1 addition & 1 deletion app/src/main/assets/paperwork.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildTime":"2020-08-13 13:58","gitSha":"c8d8a7e9a"}
{"buildTime":"2020-08-17 11:17","gitSha":"bcc96daab"}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package org.dhis2.usecases.eventsWithoutRegistration.eventCapture

import org.dhis2.Bindings.valueByPropName
import org.hisp.dhis.android.core.D2
import timber.log.Timber
import java.util.HashMap

class TitlePatternFormatException(message: String?) : Exception(message) {}

fun getProgramStageName(d2: D2, eventUid: String): String {
val event = d2.eventModule().events().uid(eventUid).blockingGet()
val programStage = d2.programModule().programStages().uid(event.programStage()).blockingGet()
Expand Down Expand Up @@ -78,15 +75,12 @@ fun getProgramStageNameByAttributeValue(
if (!dataElementsMap.containsKey(tokenWithBrackets)) {
val tokenItems = tokenWithBrackets.substring(2, it.value.length - 2).split(".")

if (tokenItems.size == 1) {
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], "displayName")
} else if (tokenItems.size == 2) {
if (tokenItems.size == 2) {
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], tokenItems[1])
} else {
Timber.w("Invalid TitlePattern ")
throw TitlePatternFormatException("Invalid TitlePattern")
dataElementsMap[tokenWithBrackets] =
getDataElementValue(tokenItems[0], "displayName")
}
}
}
Expand Down