import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/ReferralRequest.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';

class ReferralService extends BaseService {

  Future referralPatient(
      {int admissionNo,
      String roomID,
      int referralClinic,
      int referralDoctor,
      int patientID,
      int patientTypeID,
      int priority,
      int frequency,
      String referringDoctorRemarks,
      String extension}) async {
    await getDoctorProfile();
    ReferralRequest referralRequest = ReferralRequest();
    referralRequest.admissionNo = admissionNo;
    referralRequest.roomID = roomID;
    referralRequest.referralClinic = referralClinic.toString();
    referralRequest.referralDoctor = referralDoctor.toString();
    referralRequest.patientID = patientID;
    referralRequest.patientTypeID = patientTypeID;
    referralRequest.priority = priority.toString();
    referralRequest.frequency = frequency.toString();
    referralRequest.referringDoctorRemarks = referringDoctorRemarks;
    referralRequest.referringClinic = doctorProfile.clinicID;
    referralRequest.referringDoctor = doctorProfile.doctorID;
    referralRequest.extension = extension;
    referralRequest.editedBy = doctorProfile.doctorID;
    referralRequest.createdBy = doctorProfile.doctorID;
    referralRequest.patientOutSA = false;

    await baseAppClient.post(
      REFER_TO_DOCTOR,
      onSuccess: (dynamic response, int statusCode) {},
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: referralRequest.toJson(),
    );
  }
}
