import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/core/model/medical_report/medical_file_model.dart';
import 'package:doctor_app_flutter/core/model/medical_report/medical_file_request_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';

class MedicalFileService extends BaseService {
  List<MedicalFileModel> _medicalFileList = [];

  List<MedicalFileModel> get medicalFileList => _medicalFileList;

  MedicalFileRequestModel _fileRequestModel = MedicalFileRequestModel(
 );

  Future getMedicalFile({int? mrn}) async {
    _fileRequestModel = MedicalFileRequestModel(patientMRN: mrn);
    _fileRequestModel.iPAdress = "9.9.9.9";
    hasError = false;
    _medicalFileList.clear();
    await baseAppClient.post(GET_MEDICAL_FILE,
        onSuccess: (dynamic response, int statusCode) {
      _medicalFileList
          .add(MedicalFileModel.fromJson(response['PatientFileList']));
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: _fileRequestModel.toJson());
  }
}
