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

EA-1014 Updates for 0.15.0 #35

Merged
merged 3 commits into from
Feb 2, 2024
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 bwell-kotlin-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.1")

implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -84,7 +84,7 @@ class NavigationActivity : AppCompatActivity() {
}

override fun onDestroy() {
unregisterDeviceToken(deviceId)
//unregisterDeviceToken(deviceId)
super.onDestroy()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -91,11 +90,6 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
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)
Expand Down Expand Up @@ -165,11 +159,11 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
}
}
is EncounterGroup ->{
val encountersRequest = EncountersRequest.Builder()
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
Expand All @@ -188,9 +182,6 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
//printProperties(allergyIntolerances.data?.get(position))
}
}
is Communication ->{
// do nothing
}
is ConditionGroup ->{
val conditionsRequest = ConditionRequest.Builder()
//.ids(listOf(id))
Expand All @@ -215,7 +206,6 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
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 -> ""
}
Expand Down Expand Up @@ -253,7 +243,7 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
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 -> ""
Expand All @@ -266,7 +256,7 @@ class HealthSummaryCategoriesDataAdapter<T>(private val launches: List<T>?) :
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 -> ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -85,39 +84,36 @@ class LabsFragment : Fragment(), View.OnClickListener {
}
}

private fun setLabsAdapter(dataList: List<Observation>?) {
private fun setLabsAdapter(dataList: List<LabGroup>?) {
val adapter = LabsListAdapter(dataList)
adapter.onItemClicked = { selectedLabType ->
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
}

@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) {
Expand All @@ -128,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 -> {}
}
Expand All @@ -158,9 +155,7 @@ class LabsFragment : Fragment(), View.OnClickListener {
binding.includeLabsDetail.labDataLl.addView(textView)
}

private fun showLabKnowledgeView(selectedLabType: Observation?) {
val labId = selectedLabType?.id

private fun showLabKnowledgeView(labId: String?) {
val request = LabKnowledgeRequest.Builder()
.labId(labId.toString())
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ 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

/*
*Display the Labs List in RecyclerView
* */
class LabsListAdapter(private val launches: List<Observation>?) :
class LabsListAdapter(private val launches: List<LabGroup>?) :
RecyclerView.Adapter<LabsListAdapter.ViewHolder>() {

class ViewHolder(val binding: LabsItemsViewBinding) : RecyclerView.ViewHolder(binding.root)
Expand All @@ -25,11 +26,11 @@ class LabsListAdapter(private val launches: List<Observation>?) :
}

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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
Loading