One UI in flutter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
4.7 KiB

2 years ago
import 'package:dio/dio.dart';
import '../app/constants.dart';
import '../model/ac_company_response_model.dart';
2 years ago
import '../model/ac_doctor_model.dart';
2 years ago
import '../model/ac_mou_response_model.dart';
import '../model/mitra_response_model.dart';
import 'base_repository.dart';
class MitraRepository extends BaseRepository {
MitraRepository({required super.dio});
2 years ago
Future<bool> delete({
required String token,
required String mitraID,
CancelToken? cancelToken,
}) async {
final param = {
"token": token,
"mitraID": mitraID,
};
final service = "${Constants.baseUrl}md/delete";
await post(service: service, jsonParam: param, cancelToken: cancelToken);
return true;
}
Future<bool> add({
required String token,
required String companyID,
required List<String> mouID,
required String doctorID,
required String doctorAddressID,
required String login,
required String password,
CancelToken? cancelToken,
}) async {
final param = {
"token": token,
"companyID": companyID,
"mouID": mouID,
"doctorID": doctorID,
"doctorAddressID": doctorAddressID,
"login": login,
"password": password
};
final service = "${Constants.baseUrl}md/add";
await post(service: service, jsonParam: param, cancelToken: cancelToken);
return true;
}
2 years ago
Future<bool> edit({
required String mitraID,
required String token,
required String companyID,
required List<String> mouID,
required String doctorID,
required String doctorAddressID,
required String login,
required String password,
CancelToken? cancelToken,
}) async {
final param = {
"token": token,
"mitraID": mitraID,
"companyID": companyID,
"mouID": mouID,
"doctorID": doctorID,
"doctorAddressID": doctorAddressID,
"login": login,
"password": password
};
final service = "${Constants.baseUrl}md/edit";
await post(service: service, jsonParam: param, cancelToken: cancelToken);
return true;
}
2 years ago
Future<List<MitraResponseModel>> search({
required String query,
CancelToken? cancelToken,
}) async {
final param = {"query": query};
final service = "${Constants.baseUrl}md/search";
final resp = await post(
service: service, jsonParam: param, cancelToken: cancelToken);
final List<MitraResponseModel> result = List.empty(growable: true);
for (final el in resp["data"]) {
final model = MitraResponseModel.fromJson(el);
2 years ago
List<String> aggrementID = (el["aggrementID"].toString()).split(",");
model.aggrementID = aggrementID;
model.mDoctorName = el["M_DoctorName"];
2 years ago
result.add(model);
}
return result;
}
2 years ago
Future<List<AcDoctorResponseModel>> lookupDoctor({
required String query,
CancelToken? cancelToken,
}) async {
final param = {"query": query};
final service = "${Constants.baseUrl}md/lookup_doctor";
final resp = await post(
service: service, jsonParam: param, cancelToken: cancelToken);
final List<AcDoctorResponseModel> result = List.empty(growable: true);
for (final el in resp["data"]) {
final model = AcDoctorResponseModel.fromJson(el);
result.add(model);
}
return result;
}
Future<List<AcDoctorAddressResponseModel>> lookupDoctorAddress({
required String doctorID,
CancelToken? cancelToken,
}) async {
final service = "${Constants.baseUrl}md/lookup_doctoraddress/$doctorID";
final resp = await get(service: service, cancelToken: cancelToken);
final List<AcDoctorAddressResponseModel> result =
List.empty(growable: true);
for (final el in resp["data"]) {
final model = AcDoctorAddressResponseModel.fromJson(el);
result.add(model);
}
return result;
}
2 years ago
Future<List<AcCompanyModel>> lookupCompany({
required String query,
CancelToken? cancelToken,
}) async {
final param = {"query": query};
final service = "${Constants.baseUrl}md/lookup_company";
final resp = await post(
service: service, jsonParam: param, cancelToken: cancelToken);
final List<AcCompanyModel> result = List.empty(growable: true);
for (final el in resp["data"]) {
final model = AcCompanyModel.fromJson(el);
result.add(model);
}
return result;
}
Future<List<AcMouResponseModel>> lookupMou({
required String companyID,
CancelToken? cancelToken,
}) async {
final service = "${Constants.baseUrl}md/lookup_mou/$companyID";
final resp = await get(service: service, cancelToken: cancelToken);
final List<AcMouResponseModel> result = List.empty(growable: true);
for (final el in resp["data"]) {
final model = AcMouResponseModel.fromJson(el);
2 years ago
model.isCheck = false;
2 years ago
result.add(model);
}
return result;
}
}