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.
 
 
 
 
 
 

160 lines
4.7 KiB

import 'package:dio/dio.dart';
import '../app/constants.dart';
import '../model/ac_company_response_model.dart';
import '../model/ac_doctor_model.dart';
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});
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;
}
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;
}
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);
List<String> aggrementID = (el["aggrementID"].toString()).split(",");
model.aggrementID = aggrementID;
model.mDoctorName = el["M_DoctorName"];
result.add(model);
}
return result;
}
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;
}
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);
model.isCheck = false;
result.add(model);
}
return result;
}
}