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.
89 lines
2.9 KiB
89 lines
2.9 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<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); |
|
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; |
|
} |
|
}
|
|
|