done the referral service

merge-requests/547/head
Mohammad Aljammal 5 years ago
parent 650a949c6a
commit b37c607813

@ -100,7 +100,7 @@ class BaseAppClient {
});
final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400) {
onFailure('Error While Fetching data', statusCode);
onFailure(Helpers.generateContactAdminMsg(), statusCode);
} else {
var parsed = json.decode(response.body.toString());

@ -0,0 +1,108 @@
class ReferralRequest {
String roomID;
String referralClinic;
String referralDoctor;
int createdBy;
int editedBy;
int patientID;
int patientTypeID;
int referringClinic;
int referringDoctor;
int projectID;
int admissionNo;
String referringDoctorRemarks;
String priority;
String frequency;
String extension;
int languageID;
String stamp;
String iPAdress;
double versionID;
int channel;
String tokenID;
String sessionID;
bool isLoginForDoctorApp;
bool patientOutSA;
ReferralRequest(
{this.roomID,
this.referralClinic,
this.referralDoctor,
this.createdBy,
this.editedBy,
this.patientID,
this.patientTypeID,
this.referringClinic,
this.referringDoctor,
this.projectID,
this.admissionNo,
this.referringDoctorRemarks,
this.priority,
this.frequency,
this.extension,
this.languageID,
this.stamp,
this.iPAdress,
this.versionID,
this.channel,
this.tokenID,
this.sessionID,
this.isLoginForDoctorApp,
this.patientOutSA});
ReferralRequest.fromJson(Map<String, dynamic> json) {
roomID = json['RoomID'];
referralClinic = json['ReferralClinic'];
referralDoctor = json['ReferralDoctor'];
createdBy = json['CreatedBy'];
editedBy = json['EditedBy'];
patientID = json['PatientID'];
patientTypeID = json['PatientTypeID'];
referringClinic = json['ReferringClinic'];
referringDoctor = json['ReferringDoctor'];
projectID = json['ProjectID'];
admissionNo = json['AdmissionNo'];
referringDoctorRemarks = json['ReferringDoctorRemarks'];
priority = json['Priority'];
frequency = json['Frequency'];
extension = json['Extension'];
languageID = json['LanguageID'];
stamp = json['stamp'];
iPAdress = json['IPAdress'];
versionID = json['VersionID'];
channel = json['Channel'];
tokenID = json['TokenID'];
sessionID = json['SessionID'];
isLoginForDoctorApp = json['IsLoginForDoctorApp'];
patientOutSA = json['PatientOutSA'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['RoomID'] = this.roomID;
data['ReferralClinic'] = this.referralClinic;
data['ReferralDoctor'] = this.referralDoctor;
data['CreatedBy'] = this.createdBy;
data['EditedBy'] = this.editedBy;
data['PatientID'] = this.patientID;
data['PatientTypeID'] = this.patientTypeID;
data['ReferringClinic'] = this.referringClinic;
data['ReferringDoctor'] = this.referringDoctor;
data['ProjectID'] = this.projectID;
data['AdmissionNo'] = this.admissionNo;
data['ReferringDoctorRemarks'] = this.referringDoctorRemarks;
data['Priority'] = this.priority;
data['Frequency'] = this.frequency;
data['Extension'] = this.extension;
data['LanguageID'] = this.languageID;
data['stamp'] = this.stamp;
data['IPAdress'] = this.iPAdress;
data['VersionID'] = this.versionID;
data['Channel'] = this.channel;
data['TokenID'] = this.tokenID;
data['SessionID'] = this.sessionID;
data['IsLoginForDoctorApp'] = this.isLoginForDoctorApp;
data['PatientOutSA'] = this.patientOutSA;
return data;
}
}

@ -1,48 +1,46 @@
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 {
//TODO Jammal
Future referralPatient(
{String admissionNo,
{int admissionNo,
String roomID,
String referralClinic,
String referralDoctor,
String patientID,
String patientTypeID,
String referringClinic,
int referralClinic,
int referralDoctor,
int patientID,
int patientTypeID,
int priority,
int frequency,
String referringDoctorRemarks,
String priority,String frequency,String extension}) async {
String extension}) async {
await getDoctorProfile();
hasError = false;
Map<String, dynamic> body = Map();
body['ProjectID'] = doctorProfile.projectID;
body['AdmissionNo'] = admissionNo;
body['RoomID'] = roomID;
body['ReferralClinic'] = referralClinic;
body['ReferralDoctor'] = referralDoctor;
body['CreatedBy'] = doctorProfile.doctorID;
body['EditedBy'] = doctorProfile.doctorID;
body['PatientID'] = patientID;
body['PatientTypeID'] = patientTypeID;
body['ReferringClinic'] = referringClinic;
body['ReferringDoctor'] = doctorProfile.doctorID;
body['ReferringDoctorRemarks'] = referringDoctorRemarks;
body['Priority'] = priority;
body['Frequency'] = frequency;
body['Extension'] = extension;
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) {
},
onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
},
body: body,
body: referralRequest.toJson(),
);
}
}

@ -1,5 +1,6 @@
import 'package:doctor_app_flutter/core/enum/master_lookup_key.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/service/ReferralService.dart';
import 'package:doctor_app_flutter/core/service/patient-doctor-referral-service.dart';
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/models/doctor/doctor_profile_model.dart';
@ -16,6 +17,9 @@ class PatientReferralViewModel extends BaseViewModel {
PatientReferralService _referralPatientService =
locator<PatientReferralService>();
ReferralService _referralService =
locator<ReferralService>();
List<dynamic> get branchesList => _referralPatientService.projectsList;
List<dynamic> get clinicsList => _referralPatientService.clinicsList;
@ -173,7 +177,25 @@ class PatientReferralViewModel extends BaseViewModel {
String referralDate,
String remarks,
String ext}) async {
setState(ViewState.Busy);
await _referralService.referralPatient(
patientID: patient.patientId,
roomID: patient.roomId,
referralClinic: clinicID,
admissionNo: patient.appointmentNo,
referralDoctor: doctorID,
patientTypeID: patient.patientType,
referringDoctorRemarks:remarks,
priority: priority,
frequency: frequencyCode,
extension: ext,
);
if (_referralService.hasError) {
error = _referralService.error;
setState(ViewState.ErrorLocal);
} else {
setState(ViewState.Idle);
}
}
Future getPatientDetails(

@ -16,6 +16,7 @@ import 'package:get_it/get_it.dart';
import 'core/service/InsuranceCardService.dart';
import 'core/service/PatientMuseService.dart';
import 'core/service/ReferralService.dart';
import 'core/service/SOAP_service.dart';
import 'core/service/labs_service.dart';
import 'core/service/patient-admission-request-service.dart';
@ -72,6 +73,7 @@ void setupLocator() {
locator.registerLazySingleton(() => InsuranceCardService());
locator.registerLazySingleton(() => RadiologyService());
locator.registerLazySingleton(() => PrescriptionsService());
locator.registerLazySingleton(() => ReferralService());
/// View Model
locator.registerFactory(() => DoctorReplayViewModel());

@ -383,11 +383,7 @@ class _PatientMakeInPatientReferralScreenState
AppTextFieldCustom(
hintText: TranslationBase.of(context).ext,
controller: _extController,
inputType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.allow(
RegExp(ONLY_NUMBERS))
],
inputType: TextInputType.text,
),
SizedBox(
height: 10,
@ -411,7 +407,7 @@ class _PatientMakeInPatientReferralScreenState
title: TranslationBase.of(context).refer,
fontWeight: FontWeight.w700,
color: Color(0XFF359846),
onPressed: () {
onPressed: () async{
setState(() {
if (_referTo == null) {
branchError =
@ -449,9 +445,9 @@ class _PatientMakeInPatientReferralScreenState
_selectedClinic == null ||
_selectedDoctor == null ||
_remarksController.text == null ||
_extController.text == null) return;
model
.makeInPatientReferral(
_extController.text == null) return;{
await model.makeInPatientReferral(
patient: patient,
projectID: _selectedBranch['facilityId'],
clinicID: _selectedClinic['ClinicID'],
@ -461,12 +457,15 @@ class _PatientMakeInPatientReferralScreenState
remarks: _remarksController.text,
priority: _activePriority,
referralDate: appointmentDate
)
.then((_) {
DrAppToastMsg.showSuccesToast(
TranslationBase.of(context).referralSuccessMsg);
Navigator.pop(context);
});
);
if(model.state == ViewState.ErrorLocal)
DrAppToastMsg.showErrorToast(model.error);
else{
DrAppToastMsg.showSuccesToast(TranslationBase.of(context).referralSuccessMsg);
Navigator.pop(context);
}
}
},
),
)

Loading…
Cancel
Save