Medication Knowledge

Retrieving Medication Knowledge

Overview

The getMedicationKnowledge method in the b.well SDK retrieves extensive information about medications, including indications, contraindications, dosages, administration guidelines, and more, typically found in medication inserts.

Method Signature

suspend fun getMedicationKnowledge(request: MedicationKnowledgeRequest): BWellResult<MedicationKnowledge>
  • request: A MedicationKnowledgeRequest object, which must include the medication statement ID.
  • BWellResult<MedicationKnowledge>: Represents the detailed medication knowledge data retrieved.

Example Usage

val request = MedicationKnowledgeRequest.Builder()
    .medicationStatementId("medicationId") // Replace with the ID of the MedicationGroup
    .build()

medicinesViewModel.getMedicationKnowledge(request)

fun getMedicationKnowledge(medicationKnowledgeRequest: MedicationKnowledgeRequest) {
    viewModelScope.launch {
        repository?.getMedicationKnowledge(medicationKnowledgeRequest)?.collect { result ->
            _medicationKnowledgeResults.emit(result)
        }
    }
}

This example demonstrates how to build a MedicationKnowledgeRequest and fetch detailed medication information.

Best Practices

  • Ensure the medication statement ID is correctly included in the request.
  • Handle exceptions like BadRequestException if the statement ID is null.