Skip to content

Commit

Permalink
Update SimpleDetailsViewModel.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenreup committed Mar 11, 2024
1 parent 30f78c3 commit f96a9ba
Showing 1 changed file with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,38 +55,38 @@ class SimpleDetailsViewModel @Inject constructor(val patientRepository: PatientR
}

fun loadData(encounterId: String) {
viewModelScope.launch {
val encounter = patientRepository.loadEncounter(encounterId)
val config =
patientRepository.configurationRegistry.retrieveConfiguration<DetailViewConfiguration>(
configClassification = QuestConfigClassification.TEST_RESULT_DETAIL_VIEW,
)

val dataItem = DetailsViewItem()
dataItem.label = config.label

val dataMap = getDataMap(encounter)

config.rows.forEach {
val row = DetailsViewItemRow()

it.filters.forEach { f ->
// get the required property from pre-loaded resources e.g. CONDITION
val value =
dataMap[f.resourceType]
?.find { doesSatisfyFilter(it, f) == true }
?.getPathValue(f.displayableProperty)

row.cells.add(DetailsViewItemCell(value, f))
}

dataItem.rows.add(row)
}

Timber.i(dataItem.rows.toString())

_detailsViewItem.postValue(dataItem)
}
// viewModelScope.launch {
// val encounter = patientRepository.loadEncounter(encounterId)
// val config =
// patientRepository.configurationRegistry.retrieveConfiguration<DetailViewConfiguration>(
// configClassification = QuestConfigClassification.TEST_RESULT_DETAIL_VIEW,
// )
//
// val dataItem = DetailsViewItem()
// dataItem.label = config.label
//
// val dataMap = getDataMap(encounter)
//
// config.rows.forEach {
// val row = DetailsViewItemRow()
//
// it.filters.forEach { f ->
// // get the required property from pre-loaded resources e.g. CONDITION
// val value =
// dataMap[f.resourceType]
// ?.find { doesSatisfyFilter(it, f) == true }
// ?.getPathValue(f.displayableProperty)
//
// row.cells.add(DetailsViewItemCell(value, f))
// }
//
// dataItem.rows.add(row)
// }
//
// Timber.i(dataItem.rows.toString())
//
// _detailsViewItem.postValue(dataItem)
// }
}

/**
Expand Down

0 comments on commit f96a9ba

Please sign in to comment.