bookTeleconsultationAppointment method

dynamic bookTeleconsultationAppointment({
  1. dynamic department_id,
  2. dynamic symptom_id,
  3. dynamic patient_name,
  4. dynamic age,
  5. dynamic gender,
  6. dynamic contact,
  7. dynamic email,
  8. dynamic appointment_date,
  9. dynamic appointment_time,
  10. dynamic remark,
  11. dynamic package_id,
  12. 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']}",
    );
  }
}