Skip to content

Commit

Permalink
Rename to toCoding from toCodingUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
magomannen committed Feb 26, 2024
1 parent a8ff9e8 commit fbbb4ee
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.hl7.fhir.r4.model.Enumeration
* client, we have to call the desired api on the GenericType passed to the [Enumeration] and get
* the desired value by calling the api's as described above.
*/
internal fun Enumeration<*>.toCodingUnit(): Coding {
internal fun Enumeration<*>.toCoding(): Coding {
val enumeration = this
return Coding().apply {
display =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ internal val Questionnaire.QuestionnaireItemComponent.unitOption: List<Coding>
.plus(
// https://build.fhir.org/ig/HL7/sdc/behavior.html#initial
// quantity given as initial without value is for default unit reference purpose
this.initial.map { it.valueQuantity.toCodingUnit() },
this.initial.map { it.valueQuantity.toCoding() },
)
.distinctBy { it.code }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal fun Coding.toCodeType(): CodeType {
* Converts Quantity to Coding type. The resulting Coding properties are equivalent of Coding.system
* = Quantity.system Coding.code = Quantity.code Coding.display = Quantity.unit
*/
internal fun Quantity.toCodingUnit(): Coding {
internal fun Quantity.toCoding(): Coding {
return Coding(this.system, this.code, this.unit)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.google.android.fhir.datacapture.extensions.logicalId
import com.google.android.fhir.datacapture.extensions.questionnaireLaunchContexts
import com.google.android.fhir.datacapture.extensions.targetStructureMap
import com.google.android.fhir.datacapture.extensions.toCodeType
import com.google.android.fhir.datacapture.extensions.toCodingUnit
import com.google.android.fhir.datacapture.extensions.toCoding
import com.google.android.fhir.datacapture.extensions.toIdType
import com.google.android.fhir.datacapture.extensions.toUriType
import com.google.android.fhir.datacapture.extensions.validateLaunchContextExtensions
Expand Down Expand Up @@ -743,7 +743,7 @@ private fun Base.asExpectedType(
return when {
questionnaireItemType == Questionnaire.QuestionnaireItemType.REFERENCE ->
asExpectedReferenceType()
this is Enumeration<*> -> toCodingUnit()
this is Enumeration<*> -> toCoding()
this is IdType -> StringType(idPart)
else -> this as Type
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import androidx.core.widget.doAfterTextChanged
import com.google.android.fhir.datacapture.R
import com.google.android.fhir.datacapture.extensions.getRequiredOrOptionalText
import com.google.android.fhir.datacapture.extensions.localizedFlyoverSpanned
import com.google.android.fhir.datacapture.extensions.toCodingUnit
import com.google.android.fhir.datacapture.extensions.toCoding
import com.google.android.fhir.datacapture.extensions.unitOption
import com.google.android.fhir.datacapture.validation.Invalid
import com.google.android.fhir.datacapture.validation.NotValidated
Expand Down Expand Up @@ -187,12 +187,12 @@ internal object QuantityViewHolderFactory :
}

val unit =
questionnaireViewItem.answers.singleOrNull()?.valueQuantity?.toCodingUnit()
questionnaireViewItem.answers.singleOrNull()?.valueQuantity?.toCoding()
?: questionnaireViewItem.draftAnswer?.let { if (it is Coding) it else null }
?: questionnaireViewItem.questionnaireItem.initial
?.firstOrNull()
?.valueQuantity
?.toCodingUnit()
?.toCoding()
unitAutoCompleteTextView.setText(unit?.display ?: "")

val unitAdapter =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MoreEnumerationsTest {
@Test
fun enumeration_should_return_coding() {
val maleEnumerationCoding =
Enumeration(Enumerations.AdministrativeGenderEnumFactory(), "male").toCodingUnit()
Enumeration(Enumerations.AdministrativeGenderEnumFactory(), "male").toCoding()
val coding =
Coding().apply {
display = "Male"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class MoreTypesTest {
this.unit = "years"
this.system = "http://unit.org"
}
val result = quantity.toCodingUnit()
val result = quantity.toCoding()
assertThat(result.equalsDeep(Coding("http://unit.org", "yr", "years")))
}

Expand Down

0 comments on commit fbbb4ee

Please sign in to comment.