Skip to main content

Create Consultation

Create Consultation Example

Creates a new consultation with the provided [question], [medium], [userID], and optional [mediaIDs, followUpId, forceWhiteLabelingPartnerName].

Consider that the required fields are question, medium and userID

The accepted values for medium are: chat, gsm, voip, video

The followUpId field is not required and used in case the consultation being created is related to a previous consultation, then you have to add the previous consultation id

forceWhiteLabelingPartnerName is used to notify doctors to use specific partner name in communication with patients

In some cases the consultation might include some media files (Images or PDFs) so there is a flow of uploading these files and add attach their IDs to the createConsultation method

We have the uploadMedia method that could be used to upload the files, here is a quick view for this method

ApiService.uploadMedia(imageFile, object : ApiCallback<Media> {
override fun onSuccess(response: Media) {
}
override fun onFailure(error: String?) {
}
override fun onRequestError(error: String?) {
}
})

We have the Class Media to decode the response of the uploadMedia method

data class Media(
val id: String?,
val type: String?,
val name: String?,
val path: String?,
val extension: String?,
val size: Int?,
val url: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): Media {
return Media(
json["id"] as? String,
json["type"] as? String,
json["name"] as? String,
json["path"] as? String,
json["extension"] as? String,
json["size"] as? Int,
json["url"] as? String
)
}
}
}

Creating the consultation

Check the example

import com.altibbi.telehealth.ApiService

ApiService.createConsultation(
question = "YOUR QUESTION",
medium = Medium.chat, // chat, voip, video, gsm
userID = Int,
mediaIDs = null ,
//followUpId = String,
//forceWhiteLabelingPartnerName = String,
object : ApiCallback<Consultation> {
override fun onSuccess(response: Consultation) {
}

override fun onFailure(error: String?) {
}

override fun onRequestError(error: String?) {
}
}
)

Responses

Status 201

Success

{
"id": 123,
"user_id": 999999999,
"question": "I want to consult a doctor on ...",
"medium": "chat",
"parent_consultation_id": null,
"status": "new"
}

Status 401

UnauthorizedHttpException represents an Unauthorized HTTP exception with status code 401

{
"name": "Unauthorized",
"message": "Your request was made with invalid credentials",
"code": "0",
"status": "401",
"type": "yii\\\\web\\\\UnauthorizedHttpException"
}

Status 403

Duplicate request

{
"name": "Forbidden",
"message": "duplicate request OR Current user cant access this page",
"code": "0",
"status": "403",
"type": "yii\\\\web\\\\ForbiddenHttpException"
}

Status 422

Data Validation Failed

[
{
"field": "string",
"message": "string"
}
]