From 13bc728ee52899b9d512db2e8688affb6bfa009d Mon Sep 17 00:00:00 2001 From: Kate Kolchier Date: Thu, 1 Feb 2024 14:50:25 -0600 Subject: [PATCH 1/3] EA-1014 Updates for 0.15.0 --- bwell-kotlin-android/app/build.gradle.kts | 2 +- .../HealthSummaryCategoriesDataAdapter.kt | 14 +---- .../activities/ui/labs/LabsFragment.kt | 43 ++++++------- .../activities/ui/labs/LabsListAdapter.kt | 7 ++- .../ui/medicines/MedicineDetailFragment.kt | 61 ++++++------------- .../ui/medicines/MedicinesFragment.kt | 1 - .../sampleapp/repository/LabsRepository.kt | 16 ++--- .../repository/MedicineRepository.kt | 19 ++---- .../sampleapp/viewmodel/LabsViewModel.kt | 28 +++++---- .../sampleapp/viewmodel/MedicinesViewModel.kt | 33 +++------- 10 files changed, 82 insertions(+), 142 deletions(-) diff --git a/bwell-kotlin-android/app/build.gradle.kts b/bwell-kotlin-android/app/build.gradle.kts index 412fc0f..894b10e 100644 --- a/bwell-kotlin-android/app/build.gradle.kts +++ b/bwell-kotlin-android/app/build.gradle.kts @@ -66,7 +66,7 @@ android { dependencies { // BWell SDK Usage - implementation("com.bwell:bwell-sdk-kotlin:0.14.0") + implementation("com.bwell:bwell-sdk-kotlin:0.15.0") implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt index 1dc4352..f227bcd 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt @@ -8,7 +8,6 @@ import com.bwell.BWellSdk import com.bwell.common.models.domain.common.Coding import com.bwell.common.models.domain.healthdata.healthsummary.allergyintolerance.AllergyIntoleranceGroup import com.bwell.common.models.domain.healthdata.healthsummary.careplan.CarePlanGroup -import com.bwell.common.models.domain.healthdata.healthsummary.communication.Communication import com.bwell.common.models.domain.healthdata.healthsummary.condition.ConditionGroup import com.bwell.common.models.domain.healthdata.healthsummary.encounter.EncounterGroup import com.bwell.common.models.domain.healthdata.healthsummary.immunization.ImmunizationGroup @@ -18,7 +17,7 @@ import com.bwell.common.models.responses.BWellResult import com.bwell.healthdata.healthsummary.requests.allergyintolerance.AllergyIntoleranceRequest import com.bwell.healthdata.healthsummary.requests.careplan.CarePlanRequest import com.bwell.healthdata.healthsummary.requests.condition.ConditionRequest -import com.bwell.healthdata.healthsummary.requests.encounter.EncountersRequest +import com.bwell.healthdata.healthsummary.requests.encounter.EncounterRequest import com.bwell.healthdata.healthsummary.requests.immunization.ImmunizationRequest import com.bwell.healthdata.healthsummary.requests.procedure.ProcedureRequest import com.bwell.healthdata.healthsummary.requests.vitalsign.VitalSignsRequest @@ -91,11 +90,6 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : holder.binding.textViewDate.text =launch.criticality.toString() holder.binding.organizationName.text = "from "+ launch.source?.joinToString(", ") } - is Communication ->{ - holder.binding.header.text = getTitle(launch) - holder.binding.textViewDate.text = launch.status.toString() - holder.binding.organizationName.text = "from "+ launch.meta?.source - } is ConditionGroup ->{ holder.binding.header.text = getTitle(launch) val startDate = getDate(launch) @@ -165,7 +159,7 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : } } is EncounterGroup ->{ - val encountersRequest = EncountersRequest.Builder() + val encountersRequest = EncounterRequest.Builder() //.ids(listOf(id)) //.groupCode(listOf(GroupCoding(code = groupCodeCode, system = groupCodeSystem))) //.page(0) @@ -188,9 +182,6 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : //printProperties(allergyIntolerances.data?.get(position)) } } - is Communication ->{ - // do nothing - } is ConditionGroup ->{ val conditionsRequest = ConditionRequest.Builder() //.ids(listOf(id)) @@ -215,7 +206,6 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : is VitalSignGroup -> item.name ?: "" is EncounterGroup -> item.name ?: "" is AllergyIntoleranceGroup -> item.name ?: "" - is Communication -> item.category?.get(0)?.coding?.get(0)?.code ?: "" is ConditionGroup -> item.name ?: "" else -> "" } diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt index 48fddc9..7cc78cd 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt @@ -14,11 +14,13 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager +import com.bwell.common.models.domain.common.Coding import com.bwell.common.models.domain.common.Period +import com.bwell.common.models.domain.healthdata.lab.LabGroup import com.bwell.common.models.domain.healthdata.observation.Observation import com.bwell.common.models.domain.healthdata.observation.performer.ObservationOrganizationPerformer import com.bwell.common.models.responses.BWellResult -import com.bwell.healthdata.lab.requests.LabDetailsRequest +import com.bwell.healthdata.healthsummary.requests.procedure.LabGroupsRequest import com.bwell.healthdata.lab.requests.LabKnowledgeRequest import com.bwell.healthdata.lab.requests.LabsRequest import com.bwell.sampleapp.BWellSampleApplication @@ -50,26 +52,23 @@ class LabsFragment : Fragment(), View.OnClickListener { labsViewModel = ViewModelProvider(this, LabsViewModelFactory(repository))[LabsViewModel::class.java] - getLabsList() + getLabGroups() binding.includeLabsDetail.leftArrowImageView.setOnClickListener(this) return root } - private fun getLabsList() { - val date = Period.Builder().start( - parseDateStringToDate("2023-01-01", "yyyy-MM-dd")).build() - val page = "0" + private fun getLabGroups() { + val page = 0 val pageSize = 30 - val request = LabsRequest.Builder() - .date(date) + val request = LabGroupsRequest.Builder() .page(page) .pageSize(pageSize) .build() - labsViewModel.getLabsList(request) + labsViewModel.getLabGroups(request) viewLifecycleOwner.lifecycleScope.launch { - labsViewModel.labsResults.take(1).collect { result -> + labsViewModel.labGroupsResults.take(1).collect { result -> if (result != null) { Log.e("result", "result-$result") when (result) { @@ -85,7 +84,7 @@ class LabsFragment : Fragment(), View.OnClickListener { } } - private fun setLabsAdapter(dataList: List?) { + private fun setLabsAdapter(dataList: List?) { val adapter = LabsListAdapter(dataList) adapter.onItemClicked = { selectedLabType -> binding.includelabsData.labsFragment.visibility = View.GONE @@ -98,26 +97,24 @@ class LabsFragment : Fragment(), View.OnClickListener { } @SuppressLint("SetTextI18n") - private fun showLabDetailedView(selectedLabType: Observation?) { + private fun showLabDetailedView(selectedLabType: LabGroup?) { binding.includeLabsDetail.labDataLl.removeAllViews() val id = selectedLabType?.id - val code = selectedLabType?.code?.coding?.get(0)?.code - val date = Period.Builder().start( - parseDateStringToDate("2023-01-01", "yyyy-MM-dd")).build() - val page = "0" + val groupCodeCode = selectedLabType?.coding?.code + val groupCodeSystem = selectedLabType?.coding?.system + + val page = 0 val pageSize = 30 - val request = LabDetailsRequest.Builder() - .id(id) - .code(code) - .date(date) + val request = LabsRequest.Builder() + .groupCode(listOf(Coding(code = groupCodeCode, system = groupCodeSystem))) .page(page) .pageSize(pageSize) .build() - labsViewModel.getLabsDetails(request) + labsViewModel.getLabs(request) viewLifecycleOwner.lifecycleScope.launch { - labsViewModel.labsDetailResults.take(1).collect { result -> + labsViewModel.labsResults.take(1).collect { result -> if (result != null) { Log.d("result", "result$result") when (result) { @@ -158,7 +155,7 @@ class LabsFragment : Fragment(), View.OnClickListener { binding.includeLabsDetail.labDataLl.addView(textView) } - private fun showLabKnowledgeView(selectedLabType: Observation?) { + private fun showLabKnowledgeView(selectedLabType: LabGroup?) { val labId = selectedLabType?.id val request = LabKnowledgeRequest.Builder() diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsListAdapter.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsListAdapter.kt index 7bbd056..a16c5bb 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsListAdapter.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsListAdapter.kt @@ -3,6 +3,7 @@ package com.bwell.sampleapp.activities.ui.labs import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView +import com.bwell.common.models.domain.healthdata.lab.LabGroup import com.bwell.common.models.domain.healthdata.observation.Observation import com.bwell.sampleapp.databinding.LabsItemsViewBinding import com.bwell.sampleapp.utils.formatDate @@ -10,7 +11,7 @@ import com.bwell.sampleapp.utils.formatDate /* *Display the Labs List in RecyclerView * */ -class LabsListAdapter(private val launches: List?) : +class LabsListAdapter(private val launches: List?) : RecyclerView.Adapter() { class ViewHolder(val binding: LabsItemsViewBinding) : RecyclerView.ViewHolder(binding.root) @@ -25,11 +26,11 @@ class LabsListAdapter(private val launches: List?) : } var onEndOfListReached: (() -> Unit)? = null - var onItemClicked: ((Observation?) -> Unit)? = null + var onItemClicked: ((LabGroup?) -> Unit)? = null override fun onBindViewHolder(holder: ViewHolder, position: Int) { val launch = launches?.get(position) - holder.binding.header.text = launch?.code?.text + holder.binding.header.text = launch?.name.toString() holder.binding.textViewDate.text = launch?.effectiveDateTime?.toString()?.let { formatDate(it) } ?: "---" holder.binding.textViewStatus.text = launch?.interpretation?.get(0)?.text ?: "---" if (position == (launches?.size ?: 0) - 1) { diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt index f69589b..8076e2c 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt @@ -1,7 +1,6 @@ package com.bwell.sampleapp.activities.ui.medicines import android.os.Bundle -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -11,14 +10,13 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope -import com.bwell.common.models.domain.healthdata.medication.MedicationComposition +import com.bwell.common.models.domain.healthdata.medication.MedicationStatement import com.bwell.common.models.responses.BWellResult import com.bwell.healthdata.medication.requests.MedicationKnowledgeRequest -import com.bwell.healthdata.medication.requests.MedicationPricingRequest +import com.bwell.healthdata.medication.requests.MedicationStatementsRequest import com.bwell.sampleapp.BWellSampleApplication import com.bwell.sampleapp.R import com.bwell.sampleapp.databinding.MedicineDetailViewBinding -import com.bwell.sampleapp.utils.formatDate import com.bwell.sampleapp.viewmodel.MedicineViewModelFactory import com.bwell.sampleapp.viewmodel.MedicinesViewModel import kotlinx.coroutines.flow.take @@ -90,31 +88,6 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { binding.whatIsItTextView.setOnClickListener(this) binding.medicineKnowledgeView.containerLayout.removeAllViews() binding.medicinePriceView.priceContainerLayout.removeAllViews() - val request = MedicationPricingRequest.Builder() - .compositionId(medicationId) - .build() - medicinesViewModel.getMedicationPricing(request) - viewLifecycleOwner.lifecycleScope.launch { - medicinesViewModel.medicationPricingResults.take(1).collect { result -> - if (result != null) { - when (result) { - is BWellResult.ResourceCollection -> { - val dataList = result.data - for (i in 0 until (dataList?.size ?: 0)) { - val item = dataList?.get(i) - val priceValue = item?.price?.value - val currency = item?.price?.currency - val pharmacy = item?.pharmacy - val textView = TextView(requireContext()) - textView.text = "$pharmacy price is $${String.format("%.2f", priceValue)} $currency" - binding.medicinePriceView.priceContainerLayout.addView(textView) - } - } - else -> {} - } - } - } - } } private fun showOverView() { @@ -132,20 +105,26 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { binding.pricingTextView.setOnClickListener(this) binding.medicineKnowledgeView.containerLayout.removeAllViews() binding.medicinePriceView.priceContainerLayout.removeAllViews() - medicinesViewModel.getMedicationOverview(medicationId) + + val medicationStatementsRequest = MedicationStatementsRequest.Builder() + .page(0) + .pageSize(10) + .build() + + medicinesViewModel.getMedicationStatements(medicationStatementsRequest) viewLifecycleOwner.lifecycleScope.launch { - medicinesViewModel.medicationOverviewResults.take(1).collect { result -> + medicinesViewModel.medicationStatementsResults.take(1).collect { result -> if (result != null) { - if (result is BWellResult.SingleResource){ - val medicationOverview = result.data - binding.medicineOverviewView.medicineTitleTextView.text = medicationOverview?.name - binding.medicineOverviewView.rxValueTextView.text = medicationOverview?.prescriptionNumber - binding.medicineOverviewView.quantityValueTextView.text = medicationOverview?.quantity.toString() - binding.medicineOverviewView.lastRefilledValueTextView.text = formatDate(medicationOverview?.refills?.get(0)?.refillDate.toString()) - binding.medicineOverviewView.refillsRemainingValueTextView.text = medicationOverview?.refillsRemaining.toString() - binding.medicineOverviewView.startDateValueTextView.text = formatDate(medicationOverview?.startDate.toString()) - binding.medicineOverviewView.datePrescribedValueTextView.text = formatDate(medicationOverview?.datePrescribed.toString()) - binding.medicineOverviewView.organizationName.text = "from "+medicationOverview?.source + if (result is BWellResult.SingleResource){ + val medicationStatement = result.data + //binding.medicineOverviewView.medicineTitleTextView.text = medicationOverview?.name + //binding.medicineOverviewView.rxValueTextView.text = medicationOverview?.prescriptionNumber + //binding.medicineOverviewView.quantityValueTextView.text = medicationOverview?.quantity.toString() + //binding.medicineOverviewView.lastRefilledValueTextView.text = formatDate(medicationOverview?.refills?.get(0)?.refillDate.toString()) + //binding.medicineOverviewView.refillsRemainingValueTextView.text = medicationOverview?.refillsRemaining.toString() + //binding.medicineOverviewView.startDateValueTextView.text = formatDate(medicationOverview?.startDate.toString()) + //binding.medicineOverviewView.datePrescribedValueTextView.text = formatDate(medicationOverview?.datePrescribed.toString()) + binding.medicineOverviewView.organizationName.text = "from "+medicationStatement?.requester?.toString() } } } diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt index 0b47d11..3be6ec2 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt @@ -15,7 +15,6 @@ import com.bwell.common.models.domain.healthdata.medication.MedicationGroup import com.bwell.common.models.responses.BWellResult import com.bwell.common.models.domain.healthdata.medication.enums.MedicationStatus import com.bwell.healthdata.medication.requests.MedicationGroupsRequest -import com.bwell.healthdata.medication.requests.MedicationListRequest import com.bwell.sampleapp.BWellSampleApplication import com.bwell.sampleapp.R import com.bwell.sampleapp.databinding.FragmentMedicinesBinding diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/LabsRepository.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/LabsRepository.kt index b1bbdd0..f61da64 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/LabsRepository.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/LabsRepository.kt @@ -2,9 +2,11 @@ package com.bwell.sampleapp.repository import android.content.Context import com.bwell.BWellSdk +import com.bwell.common.models.domain.healthdata.lab.LabGroup +import com.bwell.common.models.domain.healthdata.lab.LabKnowledge import com.bwell.common.models.domain.healthdata.observation.Observation import com.bwell.common.models.responses.BWellResult -import com.bwell.healthdata.lab.requests.LabDetailsRequest +import com.bwell.healthdata.healthsummary.requests.procedure.LabGroupsRequest import com.bwell.healthdata.lab.requests.LabKnowledgeRequest import com.bwell.healthdata.lab.requests.LabsRequest import kotlinx.coroutines.flow.Flow @@ -12,25 +14,25 @@ import kotlinx.coroutines.flow.flow class LabsRepository(private val applicationContext: Context) { - suspend fun getLabsList(labsRequest: LabsRequest): Flow?> = flow { + suspend fun getLabGroups(labGroupsRequest: LabGroupsRequest): Flow?> = flow { try { - val labsResult = BWellSdk.health?.getLabs(labsRequest) - emit(labsResult) + val labGroupsResult = BWellSdk.health?.getLabGroups(labGroupsRequest) + emit(labGroupsResult) } catch (e: Exception) { emit(null) } } - suspend fun getLabDetails(labsDetailRequest: LabDetailsRequest): Flow?> = flow { + suspend fun getLabs(labsRequest: LabsRequest): Flow?> = flow { try { - val labsResult = BWellSdk.health?.getLabDetails(labsDetailRequest) + val labsResult = BWellSdk.health?.getLabs(labsRequest) emit(labsResult) } catch (e: Exception) { emit(null) } } - suspend fun getLabKnowledge(labKnowledgeRequest: LabKnowledgeRequest): Flow?> = flow { + suspend fun getLabKnowledge(labKnowledgeRequest: LabKnowledgeRequest): Flow?> = flow { try { val labKnowledgeResults = BWellSdk.health?.getLabKnowledge(labKnowledgeRequest) emit(labKnowledgeResults) diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/MedicineRepository.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/MedicineRepository.kt index 9233a28..cee4155 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/MedicineRepository.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/repository/MedicineRepository.kt @@ -2,14 +2,13 @@ package com.bwell.sampleapp.repository import android.content.Context import com.bwell.BWellSdk -import com.bwell.common.models.domain.healthdata.medication.MedicationComposition import com.bwell.common.models.domain.healthdata.medication.MedicationGroup import com.bwell.common.models.domain.healthdata.medication.MedicationKnowledge -import com.bwell.common.models.domain.healthdata.medication.MedicationPricing +import com.bwell.common.models.domain.healthdata.medication.MedicationStatement import com.bwell.common.models.responses.BWellResult import com.bwell.healthdata.medication.requests.MedicationGroupsRequest import com.bwell.healthdata.medication.requests.MedicationKnowledgeRequest -import com.bwell.healthdata.medication.requests.MedicationPricingRequest +import com.bwell.healthdata.medication.requests.MedicationStatementsRequest import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow @@ -24,9 +23,9 @@ class MedicineRepository(private val applicationContext: Context) { } } - suspend fun getMedicationOverview(medicationId: String): Flow?> = flow { + suspend fun getMedicationStatements(medicationStatementsRequest: MedicationStatementsRequest): Flow?> = flow { try { - val carePlanResult = BWellSdk.health?.getMedication(medicationId) + val carePlanResult = BWellSdk.health?.getMedicationStatements(medicationStatementsRequest) emit(carePlanResult) } catch (e: Exception) { emit(null) @@ -41,14 +40,4 @@ class MedicineRepository(private val applicationContext: Context) { emit(null) } } - - suspend fun getMedicationPricing(medicationPricingRequest: MedicationPricingRequest): Flow?> = flow { - try { - val medicationPricingResult = BWellSdk.health?.getMedicationPricing(medicationPricingRequest) - emit(medicationPricingResult) - } catch (e: Exception) { - emit(null) - } - } - } \ No newline at end of file diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/LabsViewModel.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/LabsViewModel.kt index b2bd8a5..0b5eff6 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/LabsViewModel.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/LabsViewModel.kt @@ -2,9 +2,11 @@ package com.bwell.sampleapp.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.bwell.common.models.domain.healthdata.lab.LabGroup +import com.bwell.common.models.domain.healthdata.lab.LabKnowledge import com.bwell.common.models.domain.healthdata.observation.Observation import com.bwell.common.models.responses.BWellResult -import com.bwell.healthdata.lab.requests.LabDetailsRequest +import com.bwell.healthdata.healthsummary.requests.procedure.LabGroupsRequest import com.bwell.healthdata.lab.requests.LabKnowledgeRequest import com.bwell.healthdata.lab.requests.LabsRequest import com.bwell.sampleapp.repository.LabsRepository @@ -14,14 +16,14 @@ import kotlinx.coroutines.launch class LabsViewModel (private val repository: LabsRepository?) : ViewModel() { - private val _labsResults = MutableStateFlow?>(null) - val labsResults: StateFlow?> = _labsResults + private val _labGroupsResults = MutableStateFlow?>(null) + val labGroupsResults: StateFlow?> = _labGroupsResults - fun getLabsList(labsRequest: LabsRequest) { + fun getLabGroups(labGroupsRequest: LabGroupsRequest) { viewModelScope.launch { try { - repository?.getLabsList(labsRequest)?.collect { result -> - _labsResults.emit(result) + repository?.getLabGroups(labGroupsRequest)?.collect { result -> + _labGroupsResults.emit(result) } } catch (e: Exception) { // Handle exceptions, if any @@ -29,14 +31,14 @@ class LabsViewModel (private val repository: LabsRepository?) : ViewModel() { } } - private val _labsDetailResults = MutableStateFlow?>(null) - val labsDetailResults: StateFlow?> = _labsDetailResults + private val _labsResults = MutableStateFlow?>(null) + val labsResults: StateFlow?> = _labsResults - fun getLabsDetails(labsDetailRequest: LabDetailsRequest) { + fun getLabs(labsRequest: LabsRequest) { viewModelScope.launch { try { - repository?.getLabDetails(labsDetailRequest)?.collect { result -> - _labsDetailResults.emit(result) + repository?.getLabs(labsRequest)?.collect { result -> + _labsResults.emit(result) } } catch (e: Exception) { // Handle exceptions, if any @@ -44,8 +46,8 @@ class LabsViewModel (private val repository: LabsRepository?) : ViewModel() { } } - private val _labsKnowledgeResults = MutableStateFlow?>(null) - val labsKnowledgeResults: StateFlow?> = _labsKnowledgeResults + private val _labsKnowledgeResults = MutableStateFlow?>(null) + val labsKnowledgeResults: StateFlow?> = _labsKnowledgeResults fun getLabKnowledge(labKnowledgeRequest: LabKnowledgeRequest) { viewModelScope.launch { diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/MedicinesViewModel.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/MedicinesViewModel.kt index 1d94436..720b203 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/MedicinesViewModel.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/viewmodel/MedicinesViewModel.kt @@ -2,15 +2,13 @@ package com.bwell.sampleapp.viewmodel import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope -import com.bwell.common.models.domain.healthdata.medication.MedicationComposition import com.bwell.common.models.domain.healthdata.medication.MedicationGroup import com.bwell.common.models.domain.healthdata.medication.MedicationKnowledge -import com.bwell.common.models.domain.healthdata.medication.MedicationPricing +import com.bwell.common.models.domain.healthdata.medication.MedicationStatement import com.bwell.common.models.responses.BWellResult import com.bwell.healthdata.medication.requests.MedicationGroupsRequest import com.bwell.healthdata.medication.requests.MedicationKnowledgeRequest -import com.bwell.healthdata.medication.requests.MedicationListRequest -import com.bwell.healthdata.medication.requests.MedicationPricingRequest +import com.bwell.healthdata.medication.requests.MedicationStatementsRequest import com.bwell.sampleapp.repository.MedicineRepository import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -77,14 +75,14 @@ class MedicinesViewModel(private val repository: MedicineRepository?) : ViewMode } } - private val _medicationOverviewResults = MutableStateFlow?>(null) - val medicationOverviewResults: StateFlow?> = _medicationOverviewResults + private val _medicationStatementsResults = MutableStateFlow?>(null) + val medicationStatementsResults: StateFlow?> = _medicationStatementsResults - fun getMedicationOverview(medicationId: String) { + fun getMedicationStatements(medicationStatementsRequest: MedicationStatementsRequest) { viewModelScope.launch { try { - repository?.getMedicationOverview(medicationId)?.collect { result -> - _medicationOverviewResults.emit(result) + repository?.getMedicationStatements(medicationStatementsRequest)?.collect { result -> + _medicationStatementsResults.emit(result) } } catch (e: Exception) { // Handle exceptions, if any @@ -106,21 +104,4 @@ class MedicinesViewModel(private val repository: MedicineRepository?) : ViewMode } } } - - private val _medicationPricingResults = MutableStateFlow?>(null) - val medicationPricingResults: StateFlow?> = _medicationPricingResults - - fun getMedicationPricing(medicationPricingRequest: MedicationPricingRequest) { - viewModelScope.launch { - try { - repository?.getMedicationPricing(medicationPricingRequest)?.collect { result -> - _medicationPricingResults.emit(result) - } - } catch (e: Exception) { - // Handle exceptions, if any - } - } - } - - } \ No newline at end of file From ee7a5a957a49d325fcfc4c6a039010e3bd4e6dc6 Mon Sep 17 00:00:00 2001 From: Kate Kolchier Date: Thu, 1 Feb 2024 16:21:07 -0600 Subject: [PATCH 2/3] EA-1014 Fix for LabKnowledge and Encounters --- bwell-kotlin-android/app/build.gradle.kts | 2 +- .../healthsummary/HealthSummaryCategoriesDataAdapter.kt | 8 ++++---- .../bwell/sampleapp/activities/ui/labs/LabsFragment.kt | 8 +++----- bwell-kotlin-android/settings.gradle.kts | 8 ++++---- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/bwell-kotlin-android/app/build.gradle.kts b/bwell-kotlin-android/app/build.gradle.kts index 894b10e..9eac265 100644 --- a/bwell-kotlin-android/app/build.gradle.kts +++ b/bwell-kotlin-android/app/build.gradle.kts @@ -66,7 +66,7 @@ android { dependencies { // BWell SDK Usage - implementation("com.bwell:bwell-sdk-kotlin:0.15.0") + implementation("com.bwell:bwell-sdk-kotlin:1.0.0-SNAPSHOT") implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt index f227bcd..b7e9edf 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/healthsummary/HealthSummaryCategoriesDataAdapter.kt @@ -161,9 +161,9 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : is EncounterGroup ->{ val encountersRequest = EncounterRequest.Builder() //.ids(listOf(id)) - //.groupCode(listOf(GroupCoding(code = groupCodeCode, system = groupCodeSystem))) + .groupCode(listOf(Coding(code = groupCodeCode, system = groupCodeSystem))) //.page(0) - .pageSize(1) + .pageSize(10) .build() GlobalScope.launch { val encounters = BWellSdk.health.getEncounters(encountersRequest) as BWellResult.ResourceCollection @@ -243,7 +243,7 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : is ImmunizationGroup -> item.coding?.system.toString() is ProcedureGroup -> item.coding?.system.toString() is VitalSignGroup -> item.coding?.system.toString() - //is EncounterGroup -> item.coding?.system.toString() + is EncounterGroup -> item.coding?.system.toString() is ConditionGroup -> item.coding?.system.toString() is AllergyIntoleranceGroup -> item.coding?.system.toString() else -> "" @@ -256,7 +256,7 @@ class HealthSummaryCategoriesDataAdapter(private val launches: List?) : is ImmunizationGroup -> item.coding?.code.toString() is ProcedureGroup -> item.coding?.code.toString() is VitalSignGroup -> item.coding?.code.toString() - //is EncounterGroup -> item.coding?.code.toString() + is EncounterGroup -> item.coding?.code.toString() is ConditionGroup -> item.coding?.code.toString() is AllergyIntoleranceGroup -> item.coding?.code.toString() else -> "" diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt index 7cc78cd..89119ee 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/labs/LabsFragment.kt @@ -90,7 +90,6 @@ class LabsFragment : Fragment(), View.OnClickListener { binding.includelabsData.labsFragment.visibility = View.GONE binding.includeLabsDetail.labDetailFragment.visibility = View.VISIBLE showLabDetailedView(selectedLabType) - showLabKnowledgeView(selectedLabType) } binding.includelabsData.rvLabs.layoutManager = LinearLayoutManager(requireContext()) binding.includelabsData.rvLabs.adapter = adapter @@ -125,11 +124,12 @@ class LabsFragment : Fragment(), View.OnClickListener { binding.includeLabsDetail.typeText.text = details?.code?.text binding.includeLabsDetail.dateText.text = ("as of " + details?.effectiveDateTime?.toString().let { formatDate(it) }) - binding.includeLabsDetail.organizationName.text = "from "+(details?.performer?.get(1) as ObservationOrganizationPerformer).organizationName + //binding.includeLabsDetail.organizationName.text = "from "+(details?.performer?.get(1) as ObservationOrganizationPerformer).organizationName addTextField(details?.effectiveDateTime?.toString()?.let { formatDate(it) } ?: "---",false) addTextField(details?.interpretation?.get(0)?.text.toString(),false) addTextField(resources.getString(R.string.healthy_range),true) addTextField(details?.referenceRange?.get(0)?.text.toString(),false) + showLabKnowledgeView(details?.id) } else -> {} } @@ -155,9 +155,7 @@ class LabsFragment : Fragment(), View.OnClickListener { binding.includeLabsDetail.labDataLl.addView(textView) } - private fun showLabKnowledgeView(selectedLabType: LabGroup?) { - val labId = selectedLabType?.id - + private fun showLabKnowledgeView(labId: String?) { val request = LabKnowledgeRequest.Builder() .labId(labId.toString()) .build() diff --git a/bwell-kotlin-android/settings.gradle.kts b/bwell-kotlin-android/settings.gradle.kts index 9ef7d4d..436ee1d 100644 --- a/bwell-kotlin-android/settings.gradle.kts +++ b/bwell-kotlin-android/settings.gradle.kts @@ -11,10 +11,10 @@ dependencyResolutionManagement { google() mavenCentral() // BWell SDK Usage - //mavenLocal() //uncomment after running `./gradlew publishToMavenLocal` in the SDK for testing - maven { - url = uri("https://artifacts.icanbwell.com/repository/bwell-public/") - } + mavenLocal() //uncomment after running `./gradlew publishToMavenLocal` in the SDK for testing + //maven { + // url = uri("https://artifacts.icanbwell.com/repository/bwell-public/") + //} } } From 91c61f8267d788463aa2423fc68523e63b5f6cc3 Mon Sep 17 00:00:00 2001 From: Kate Kolchier Date: Thu, 1 Feb 2024 20:51:52 -0600 Subject: [PATCH 3/3] EA-1014 0.15.1: Updates for searching by groups for Medication Statements. Also updated device application name --- bwell-kotlin-android/app/build.gradle.kts | 2 +- .../com/bwell/sampleapp/activities/NavigationActivity.kt | 4 ++-- .../bwell/sampleapp/activities/ui/login/LoginFragment.kt | 4 ++-- .../activities/ui/medicines/MedicineDetailFragment.kt | 8 +++++++- .../activities/ui/medicines/MedicinesFragment.kt | 2 ++ bwell-kotlin-android/settings.gradle.kts | 8 ++++---- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/bwell-kotlin-android/app/build.gradle.kts b/bwell-kotlin-android/app/build.gradle.kts index 9eac265..449b66a 100644 --- a/bwell-kotlin-android/app/build.gradle.kts +++ b/bwell-kotlin-android/app/build.gradle.kts @@ -66,7 +66,7 @@ android { dependencies { // BWell SDK Usage - implementation("com.bwell:bwell-sdk-kotlin:1.0.0-SNAPSHOT") + implementation("com.bwell:bwell-sdk-kotlin:0.15.1") implementation("androidx.core:core-ktx:1.12.0") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/NavigationActivity.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/NavigationActivity.kt index b1f4be7..27b40b0 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/NavigationActivity.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/NavigationActivity.kt @@ -57,7 +57,7 @@ class NavigationActivity : AppCompatActivity() { deviceId = tempDeviceId val registerDeviceTokenRequest: RegisterDeviceTokenRequest = RegisterDeviceTokenRequest.Builder() .deviceToken(deviceId) - .applicationName("Samsung Health PHR") + .applicationName("com.sec.android.app.shealth") .platform(DevicePlatform.ANDROID) .build() registerDeviceToken(registerDeviceTokenRequest) @@ -84,7 +84,7 @@ class NavigationActivity : AppCompatActivity() { } override fun onDestroy() { - unregisterDeviceToken(deviceId) + //unregisterDeviceToken(deviceId) super.onDestroy() } diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/login/LoginFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/login/LoginFragment.kt index 0dc0bd3..48bb75e 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/login/LoginFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/login/LoginFragment.kt @@ -153,12 +153,12 @@ class LoginFragment : Fragment() { val registerDeviceTokenRequest: RegisterDeviceTokenRequest = RegisterDeviceTokenRequest.Builder() .deviceToken(deviceKey) - .applicationName("com.icanbwell.bwelldemo.staging") + .applicationName("com.sec.android.app.shealth") .platform(DevicePlatform.ANDROID) .build() registerDeviceToken(registerDeviceTokenRequest) - deregisterDeviceToken(deviceKey) + //deregisterDeviceToken(deviceKey) Log.i(TAG, "Finished initializing SDK") } diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt index 8076e2c..f807501 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicineDetailFragment.kt @@ -10,6 +10,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope +import com.bwell.common.models.domain.common.Coding import com.bwell.common.models.domain.healthdata.medication.MedicationStatement import com.bwell.common.models.responses.BWellResult import com.bwell.healthdata.medication.requests.MedicationKnowledgeRequest @@ -27,6 +28,8 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { private var _binding: MedicineDetailViewBinding? = null private lateinit var medicinesViewModel: MedicinesViewModel private lateinit var medicationId: String + private lateinit var groupCode: String + private lateinit var groupSystem: String private val binding get() = _binding!! @@ -43,6 +46,8 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { binding.whatIsItTextView.setOnClickListener(this) binding.pricingTextView.setOnClickListener(this) medicationId = arguments?.getString("id").toString() + groupCode = arguments?.getString("groupCode").toString() + groupSystem = arguments?.getString("groupSystem").toString() showOverView() @@ -107,6 +112,7 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { binding.medicinePriceView.priceContainerLayout.removeAllViews() val medicationStatementsRequest = MedicationStatementsRequest.Builder() + .groupCode(listOf(Coding(code = groupCode, system = groupSystem))) .page(0) .pageSize(10) .build() @@ -117,7 +123,7 @@ class MedicineDetailFragment : Fragment(),View.OnClickListener { if (result != null) { if (result is BWellResult.SingleResource){ val medicationStatement = result.data - //binding.medicineOverviewView.medicineTitleTextView.text = medicationOverview?.name + binding.medicineOverviewView.medicineTitleTextView.text = medicationStatement?.medication?.text.toString() //binding.medicineOverviewView.rxValueTextView.text = medicationOverview?.prescriptionNumber //binding.medicineOverviewView.quantityValueTextView.text = medicationOverview?.quantity.toString() //binding.medicineOverviewView.lastRefilledValueTextView.text = formatDate(medicationOverview?.refills?.get(0)?.refillDate.toString()) diff --git a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt index 3be6ec2..e3dc095 100644 --- a/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt +++ b/bwell-kotlin-android/app/src/main/java/com/bwell/sampleapp/activities/ui/medicines/MedicinesFragment.kt @@ -72,6 +72,8 @@ class MedicinesFragment : Fragment() { val medicineDetailFragment = MedicineDetailFragment() val bundle = Bundle() bundle.putString("id", selectedMedicine?.id) + bundle.putString("groupCode", selectedMedicine?.coding?.code.toString()) + bundle.putString("groupSystem", selectedMedicine?.coding?.system.toString()) medicineDetailFragment.arguments = bundle val transaction = childFragmentManager.beginTransaction() binding.containerLayout.visibility = View.VISIBLE; diff --git a/bwell-kotlin-android/settings.gradle.kts b/bwell-kotlin-android/settings.gradle.kts index 436ee1d..9ef7d4d 100644 --- a/bwell-kotlin-android/settings.gradle.kts +++ b/bwell-kotlin-android/settings.gradle.kts @@ -11,10 +11,10 @@ dependencyResolutionManagement { google() mavenCentral() // BWell SDK Usage - mavenLocal() //uncomment after running `./gradlew publishToMavenLocal` in the SDK for testing - //maven { - // url = uri("https://artifacts.icanbwell.com/repository/bwell-public/") - //} + //mavenLocal() //uncomment after running `./gradlew publishToMavenLocal` in the SDK for testing + maven { + url = uri("https://artifacts.icanbwell.com/repository/bwell-public/") + } } }