Skip to main content

Consultation Type And Related Types

Dealing With ConsultationType​

In order to deal with the Consultations and the functionality related to consultations, we use the Class Consultation

import com.google.gson.annotations.SerializedName

data class Consultation(
val id: Int?,
@SerializedName("user_id") val userId: Int?,
val question: String?,
val medium: String?,
val status: String?,
@SerializedName("is_fulfilled") val isFulfilled: Int?,
@SerializedName("parent_consultation_id") val parentConsultationId: Int?,
@SerializedName("scheduled_to") val scheduledTo: String?,
@SerializedName("consultation_category_id") val consultationCategoryId: Int?,
@SerializedName("created_at") val createdAt: String?,
@SerializedName("updated_at") val updatedAt: String?,
val parentConsultation: Consultation?,
val media: List<Media>?,
val user: User?,
val consultations: List<Consultation>?,
@SerializedName("pusherChannel") val socketChannel: String?,
@SerializedName("pusherAppKey") val appKey: String?,
val chatConfig: ChatConfig?,
val voipConfig: VoipConfig?,
val videoConfig: VoipConfig?,
val chatHistory: ChatHistory?,
val recommendation: Recommendation?,
@SerializedName("doctor_name") val doctorName: String?,
@SerializedName("doctor_avatar") val doctorAvatar: String?,
@SerializedName("doctor_average_rating") val doctorAverageRating: Double?
) {
companion object {
fun fromJson(json: Map<String, Any>): Consultation {
return Consultation(
id = json["id"] as? Int,
userId = json["user_id"] as? Int,
question = json["question"] as? String,
medium = json["medium"] as? String,
status = json["status"] as? String,
isFulfilled = json["is_fulfilled"] as? Int,
parentConsultationId = json["parent_consultation_id"] as? Int,
scheduledTo = json["scheduled_to"] as? String,
consultationCategoryId = json["consultation_category_id"] as? Int,
createdAt = json["created_at"] as? String,
updatedAt = json["updated_at"] as? String,
parentConsultation = json["parentConsultation"]?.let { Consultation.fromJson(it as Map<String, Any>) },
media = (json["media"] as? List<*>)?.map { it as? Map<String, Any> }
?.map { Media.fromJson(it!!) },
user = json["user"]?.let { User.fromJson(it as Map<String, Any>) },
consultations = (json["consultations"] as? List<*>)?.map { it as? Map<String, Any> }
?.map { Consultation.fromJson(it!!) },
socketChannel = json["pusherChannel"] as? String,
appKey = json["pusherAppKey"] as? String,
chatConfig = json["chatConfig"]?.let { ChatConfig.fromJson(it as Map<String, Any>) },
voipConfig = json["voipConfig"]?.let { VoipConfig.fromJson(it as Map<String, Any>) },
videoConfig = json["videoConfig"]?.let { VoipConfig.fromJson(it as Map<String, Any>) },
chatHistory = json["chatHistory"]?.let { ChatHistory.fromJson(it as Map<String, Any>) },
recommendation = json["recommendation"]?.let { Recommendation.fromJson(it as Map<String, Any>) },
doctorName = json["doctor_name"] as? String,
doctorAvatar = json["doctor_avatar"] as? String,
doctorAverageRating = json["doctor_average_rating"] as? Double,
)
}
}
}

Also, there are some pre-defined types included in the ConsultationType classes

MediaType​

The consultation data might include some media files related to the consultation represented as MediaType array and here is the Media Class

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
)
}
}
}

ChatConfig​

The ChatConfig object contains the data related to chat consultations, here is the ChatConfig Class

data class ChatConfig(
val id: Int?,
@SerializedName("consultation_id") val consultationId: Int?,
@SerializedName("group_id") val groupId: String?,
@SerializedName("app_id") val appId: String?,
@SerializedName("chat_user_id") val chatUserId: String?,
@SerializedName("chat_user_token") val chatUserToken: String?
) {
companion object {
fun fromJson(json: Map<String, Any?>): ChatConfig {
return ChatConfig(
id = json["id"] as? Int,
consultationId = json["consultation_id"] as? Int,
groupId = json["group_id"] as? String,
appId = json["app_id"] as? String,
chatUserId = json["chat_user_id"] as? String,
chatUserToken = json["chat_user_token"] as? String
)
}
}
}

VoipConfig​

The VoipConfig object contains the data related to Video or Voip consultations, here is the VoipConfig Class

data class VoipConfig(
val id: Int?,
@SerializedName("consultation_id") val consultationId: Int?,
@SerializedName("api_key") val apiKey: String?,
@SerializedName("call_id") val callId: String?,
@SerializedName("token") val token: String?,
) {
companion object {
fun fromJson(json: Map<String, Any>): VoipConfig {
return VoipConfig(
json["id"] as? Int,
json["consultation_id"] as? Int,
json["api_key"] as? String,
json["call_id"] as? String,
json["token"] as? String
)
}
}
}

ChatHistory​

The ChatHistory object contains the data related to chat history of chat consultations, here is the ChatHistory Class

data class ChatHistory(
val id: Int?,
@SerializedName("consultation_id") val consultationId: Int?,
val data: List<Data>?,
@SerializedName("created_at") val createdAt: String?,
@SerializedName("updated_at") val updatedAt: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): ChatHistory {
return ChatHistory(
json["id"] as? Int,
json["consultation_id"] as? Int,
(json["data"] as? List<*>)?.map { it as? Map<String, Any> }
?.map { Data.fromJson(it!!) },
json["created_at"] as? String,
json["updated_at"] as? String,
)
}
}
}

The data array of ChatHistory object is an array of ChatData type, and here is the Data Class

data class Data(
val id: String?,
val message: String?,
@SerializedName("sent_at") val sentAt: String?,
@SerializedName("chat_user_id") val chatUserId: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): Data {
return Data(
json["id"] as? String,
json["message"] as? String,
json["sent_at"] as? String,
json["chat_user_id"] as? String
)
}
}
}

Recommendation​

The Recommendation object contains the recommendation data filled by the doctor, here is the Recommendation Class

data class Recommendation(
val id: Int?,
@SerializedName("consultation_id") val consultationId: Int?,
val data: RecommendationData?,
@SerializedName("created_at") val createdAt: String?,
@SerializedName("updated_at") val updatedAt: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): Recommendation {
return Recommendation(
json["id"] as? Int,
json["consultation_id"] as? Int,
json["data"]?.let { RecommendationData.fromJson(it as Map<String, Any>) },
json["created_at"] as? String,
json["updated_at"] as? String
)
}
}
}

The data of the Recommendation object is an object of RecommendationData type and here is the RecommendationData Class

data class RecommendationData(
val lab: RecommendationLab?,
val drug: RecommendationDrug?,
val icd10: RecommendationICD10?,
val followUp: List<RecommendationFollowUp>?,
val doctorReferral: RecommendationDoctorReferral?,
val postCallAnswer: List<RecommendationPostCallAnswer>?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationData {
return RecommendationData(
json["lab"]?.let { RecommendationLab.fromJson(it as Map<String, Any>) },
json["drug"]?.let { RecommendationDrug.fromJson(it as Map<String, Any>) },
json["icd10"]?.let { RecommendationICD10.fromJson(it as Map<String, Any>) },
json["followUp"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationFollowUp.fromJson(item)
}
},
json["doctorReferral"]?.let { RecommendationDoctorReferral.fromJson(it as Map<String, Any>) },
json["postCallAnswer"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationPostCallAnswer.fromJson(item)
}
}
)
}
}
}

Each field of the RecommendationData object is a pre-defined type and here are all the class related to RecommendationData object

RecommendationLab The RecommendationLab field contains an array of labs prescribed after the consultation

data class RecommendationLab(
val lab: List<RecommendationLabItem>?,
val panel: List<RecommendationLabItem>?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationLab {
return RecommendationLab(
json["lab"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationLabItem.fromJson(item)
}
},
json["panel"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationLabItem.fromJson(item)
}
}
)
}
}
}

And here is the RecommendationLabItem class related to RecommendationLab

data class RecommendationLabItem(
val name: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationLabItem {
return RecommendationLabItem(
json["name"] as? String
)
}
}
}

RecommendationDrug The RecommendationDrug field contains an array of fdaDrugs prescribed after the consultation

data class RecommendationDrug(
val fdaDrug: List<RecommendationFdaDrug>?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationDrug {
return RecommendationDrug(
json["fdaDrug"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationFdaDrug.fromJson(item)
}
}
)
}
}
}

And here is the RecommendationFdaDrug class related to RecommendationDrug

data class RecommendationFdaDrug(
val name: String?,
val dosage: String?,
val duration: Int?,
val howToUse: String?,
val frequency: String?,
val tradeName: String?,
val dosageForm: String?,
val dosageUnit: String?,
val packageSize: String?,
val packageType: String?,
val strengthValue: String?,
val relationWithFood: String?,
val specialInstructions: String?,
val routeOfAdministration: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationFdaDrug {
return RecommendationFdaDrug(
json["name"] as? String,
json["dosage"] as? String,
json["duration"] as? Int,
json["howToUse"] as? String,
json["frequency"] as? String,
json["tradeName"] as? String,
json["dosageForm"] as? String,
json["dosageUnit"] as? String,
json["packageSize"] as? String,
json["packageType"] as? String,
json["strengthValue"] as? String,
json["relationWithFood"] as? String,
json["specialInstructions"] as? String,
json["routeOfAdministration"] as? String
)
}
}
}

RecommendationICD10 The RecommendationICD10 field contains an array of symptoms and array of diagnosis defined after the consultation

data class RecommendationICD10(
val symptom: List<RecommendationSymptom>?,
val diagnosis: List<RecommendationDiagnosis>?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationICD10 {
return RecommendationICD10(
json["symptom"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationSymptom.fromJson(item)
}
},
json["diagnosis"]?.let {
(it as List<Map<String, Any>>).map { item ->
RecommendationDiagnosis.fromJson(item)
}
}
)
}
}
}

And here are the RecommendationSymptom and RecommendationDiagnosis class related to RecommendationICD10

data class RecommendationSymptom(
val code: String?,
val name: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationSymptom {
return RecommendationSymptom(
json["code"] as? String,
json["name"] as? String
)
}
}
}
data class RecommendationDiagnosis(
val code: String?,
val name: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationDiagnosis {
return RecommendationDiagnosis(
json["code"] as? String,
json["name"] as? String
)
}
}
}

RecommendationFollowUp The RecommendationFollowUp field is an array of follow-ups related to the consultation

data class RecommendationFollowUp(
val name: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationFollowUp {
return RecommendationFollowUp(
json["name"] as? String
)
}
}
}

RecommendationDoctorReferral The RecommendationDoctorReferral field is an object contains the referral speciality recommended in the consultation

data class RecommendationDoctorReferral(
val name: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationDoctorReferral {
return RecommendationDoctorReferral(
json["name"] as? String
)
}
}
}

RecommendationPostCallAnswer The RecommendationPostCallAnswer field is an array of predefined questions answered in the recommendation

data class RecommendationPostCallAnswer(
val answer: String?,
val question: String?
) {
companion object {
fun fromJson(json: Map<String, Any>): RecommendationPostCallAnswer {
return RecommendationPostCallAnswer(
json["answer"] as? String,
json["question"] as? String
)
}
}
}

Consultation Functionalities​

The following are the functionalities relate to consultations

APIParams
createConsultationquestion: String,
medium: Medium,
userID: Int,
callback: ApiCallback<Consultation>,
mediaIDs: List<String>? = null,
followUpId: String? = null,
scheduledTo: String? = null,
forceWhiteLabelingPartnerName: String? = null,
consultationCategoryId: Int? = null
getConsultationInfoconsultationId: String, callback: ApiCallback<Consultation>
getLastConsultationcallback: ApiCallback<Consultation>
getConsultationListuserId: Int?,
page: Int?,
perPage: Int?,
sort: String?,
callback: ApiCallback<List<Consultation>>
deleteConsultationconsultationId: String, callback: ApiCallback<Boolean>
cancelConsultationconsultationId: String, callback: ApiCallback<Boolean>
uploadConsultationAttachmentsconsultationId: String,
mediaIDs: List<String>,
callback: ApiCallback<Boolean>