bookTeleconsultationAppointment method
dynamic
bookTeleconsultationAppointment({
- dynamic department_id,
- dynamic symptom_id,
- dynamic patient_name,
- dynamic age,
- dynamic gender,
- dynamic contact,
- dynamic email,
- dynamic appointment_date,
- dynamic appointment_time,
- dynamic remark,
- dynamic package_id,
- dynamic context,
Implementation
bookTeleconsultationAppointment({
department_id,
symptom_id,
patient_name,
age,
gender,
contact,
email,
appointment_date,
appointment_time,
remark,
package_id,
context,
}) async {
var decodedResponse;
try {
var request = http.MultipartRequest(
'POST',
Uri.parse(
'${medicine_API}api/teleconsultation/post-consultation-details'),
);
request.headers.addAll({"Authorization": currentUserToken});
request.fields['department_id'] = "${department_id}";
request.fields['symptom_id'] = '$symptom_id';
request.fields['patient_name'] = '$patient_name';
request.fields['age'] = '$age';
request.fields['gender'] = '$gender';
request.fields['contact'] = '$contact';
request.fields['email'] = '$email';
request.fields['appointment_date'] = '$appointment_date';
request.fields['appointment_time'] = '$appointment_time';
request.fields['remark'] = '$remark';
request.fields['package_id'] = packageId.value == '' ? '' : '$packageId';
if (uploadedReportsList.isNotEmpty) {
for (int i = 0; i < uploadedReportsList.length; i++) {
request.files.add(await http.MultipartFile.fromPath(
"upload_reports[$i]",
uploadedReportsList[i]['image_file'].toString(),
));
}
}
var response = await request.send();
var responsed = await http.Response.fromStream(response);
decodedResponse = json.decode(responsed.body);
if (decodedResponse['success'] == true) {
Get.back();
bookAppointmentData = decodedResponse;
teleconsultationOrderDetailsId =
await decodedResponse['data']['consultation']['id'];
await Get.to(TeleConsultationPlaceOrder(
teleconsultationOrderId: decodedResponse['data']['consultation']
['id'],
));
} else {
Get.back();
Validator().errorMessage(
context: context,
message: decodedResponse['message'] ?? "Something went wrong",
);
}
} catch (e) {
Validator().errorMessage(
context: context,
message: "${decodedResponse['message']}",
);
}
}