working on Referral feature

merge-requests/249/head
mosazaid 4 years ago
parent 2f17167e2f
commit 8726653ffb

@ -71,6 +71,12 @@ const CREATE_REFERRAL_PATIENT =
const RESPONSE_PENDING_REFERRAL_PATIENT = const RESPONSE_PENDING_REFERRAL_PATIENT =
'Services/DoctorApplication.svc/REST/CreateReferral'; 'Services/DoctorApplication.svc/REST/CreateReferral';
const GET_PATIENT_REFERRAL =
'Services/DoctorApplication.svc/REST/GetRefferal';
const POST_UCAF =
'Services/DoctorApplication.svc/REST/PostUCAF';
const GET_DOCTOR_WORKING_HOURS_TABLE = const GET_DOCTOR_WORKING_HOURS_TABLE =
'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable'; 'Services/Doctors.svc/REST/GetDoctorWorkingHoursTable';

@ -18,6 +18,7 @@ class PatientReferralService extends LookupService {
List<dynamic> doctorsList = []; List<dynamic> doctorsList = [];
List<MyReferredPatientModel> listMyReferredPatientModel = []; List<MyReferredPatientModel> listMyReferredPatientModel = [];
List<PendingReferral> pendingReferralList = []; List<PendingReferral> pendingReferralList = [];
List<PendingReferral> patientReferralList = [];
String setupID = "0"; String setupID = "0";
Future getProjectsList() async { Future getProjectsList() async {
@ -163,6 +164,33 @@ class PatientReferralService extends LookupService {
); );
} }
Future getPatientReferral(PatiantInformtion patient) async {
hasError = false;
Map<String, dynamic> body = Map();
body['PatientMRN'] = patient.patientMRN;
body['AppointmentNo'] = patient.appointmentNo;
await baseAppClient.post(
GET_PATIENT_REFERRAL,
onSuccess: (dynamic response, int statusCode) {
patientReferralList.clear();
response['ReferralList']['entityList'].forEach((v) {
PendingReferral item = PendingReferral.fromJson(v);
item.isReferralDoctorSameBranch =
item.targetProjectId == item.sourceProjectId;
patientReferralList.add(item);
});
},
onFailure: (String error, int statusCode) {
patientReferralList.clear();
hasError = true;
super.error = error;
},
body: body,
);
}
Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async { Future responseReferral(PendingReferral pendingReferral, bool isAccepted) async {
hasError = false; hasError = false;
DoctorProfileModel doctorProfile = await getDoctorProfile(); DoctorProfileModel doctorProfile = await getDoctorProfile();
@ -221,6 +249,7 @@ class PatientReferralService extends LookupService {
CREATE_REFERRAL_PATIENT, CREATE_REFERRAL_PATIENT,
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
print(response.toString()); print(response.toString());
print("create referral status code = ${statusCode}");
}, },
onFailure: (String error, int statusCode) { onFailure: (String error, int statusCode) {
hasError = true; hasError = true;

@ -27,9 +27,27 @@ class PatientReferralViewModel extends BaseViewModel {
List<PendingReferral> get pendingReferral => List<PendingReferral> get pendingReferral =>
_referralPatientService.pendingReferralList; _referralPatientService.pendingReferralList;
List<PendingReferral> get patientReferral =>
_referralPatientService.patientReferralList;
List<PatiantInformtion> get patientArrivalList => List<PatiantInformtion> get patientArrivalList =>
_referralPatientService.patientArrivalList; _referralPatientService.patientArrivalList;
Future getPatientReferral(PatiantInformtion patient) async {
setState(ViewState.Busy);
await _referralPatientService.getPatientReferral(patient);
if (_referralPatientService.hasError) {
error = _referralPatientService.error;
setState(ViewState.Error);
} else {
if(patientReferral.length == 0){
await getMasterLookup(MasterKeysService.physiotherapyGoals);
} else {
setState(ViewState.Idle);
}
}
}
Future getMasterLookup(MasterKeysService masterKeys) async { Future getMasterLookup(MasterKeysService masterKeys) async {
setState(ViewState.Busy); setState(ViewState.Busy);
await _referralPatientService.getMasterLookup(masterKeys); await _referralPatientService.getMasterLookup(masterKeys);

@ -8,6 +8,7 @@ import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart'; import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart'; import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart'; import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/patient-referral-item-widget.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart'; import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart';
@ -50,16 +51,21 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
patient = routeArgs['patient']; patient = routeArgs['patient'];
referToList = List(); referToList = List();
dynamic sameBranch = {"id": 1, "name": TranslationBase.of(context).sameBranch}; dynamic sameBranch = {
dynamic otherBranch = {"id": 2, "name": TranslationBase.of(context).otherBranch}; "id": 1,
"name": TranslationBase.of(context).sameBranch
};
dynamic otherBranch = {
"id": 2,
"name": TranslationBase.of(context).otherBranch
};
referToList.add(sameBranch); referToList.add(sameBranch);
referToList.add(otherBranch); referToList.add(otherBranch);
final screenSize = MediaQuery.of(context).size; final screenSize = MediaQuery.of(context).size;
return BaseView<PatientReferralViewModel>( return BaseView<PatientReferralViewModel>(
onModelReady: (model) => onModelReady: (model) => model.getPatientReferral(patient),
model.getMasterLookup(MasterKeysService.physiotherapyGoals),
builder: (_, model, w) => AppScaffold( builder: (_, model, w) => AppScaffold(
baseViewModel: model, baseViewModel: model,
appBarTitle: TranslationBase.of(context).referPatient, appBarTitle: TranslationBase.of(context).referPatient,
@ -86,9 +92,61 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
indent: 0, indent: 0,
endIndent: 0, endIndent: 0,
), ),
model.patientReferral.length == 0
? ReferralForm(model, screenSize)
: PatientReferralItemWidget(
patientName: model.patientReferral[0].patientName,
referralStatus: "${model.patientReferral[0].referralStatus}",
isReferredTo: true,
isSameBranch: model.patientReferral[0]
.isReferralDoctorSameBranch,
referralDoctorName:
model.patientReferral[0].referredByDoctorInfo,
clinicDescription: null,
remark:
model.patientReferral[0].remarksFromSource
),
],
),
if (model.patientReferral.length == 0)
Container( Container(
margin: margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
EdgeInsets.symmetric(vertical: 16, horizontal: 16), child: AppButton(
title: TranslationBase.of(context).refer,
color: HexColor("#B8382B"),
onPressed: () {
if (appointmentDate == null ||
_selectedBranch == null ||
_selectedClinic == null ||
_selectedDoctor == null ||
_remarksController.text == null) return;
model
.makeReferral(
patient,
appointmentDate.toIso8601String(),
_selectedBranch['ID'],
_selectedClinic['ClinicID'],
_selectedDoctor['DoctorID'],
_remarksController.text)
.then((_) {
DrAppToastMsg.showSuccesToast(
TranslationBase.of(context).referralSuccessMsg);
Navigator.pop(context);
});
},
),
)
],
),
),
),
),
);
}
Widget ReferralForm(PatientReferralViewModel model, Size screenSize) {
return Container(
margin: EdgeInsets.symmetric(vertical: 16, horizontal: 16),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -108,8 +166,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
child: InkWell( child: InkWell(
onTap: referToList != null onTap: referToList != null
? () { ? () {
ListSelectDialog dialog = ListSelectDialog dialog = ListSelectDialog(
ListSelectDialog(
list: referToList, list: referToList,
attributeName: 'name', attributeName: 'name',
attributeValueId: 'id', attributeValueId: 'id',
@ -120,13 +177,10 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
_selectedBranch = null; _selectedBranch = null;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
model model.getDoctorBranch().then((value) {
.getDoctorBranch()
.then((value) {
_selectedBranch = value; _selectedBranch = value;
if (_referTo['id'] == 1) { if (_referTo['id'] == 1) {
model.getClinics( model.getClinics(_selectedBranch['ID']);
_selectedBranch['ID']);
} }
}); });
}); });
@ -161,8 +215,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
_referTo != null && _referTo != null &&
_referTo['id'] == 2 _referTo['id'] == 2
? () { ? () {
ListSelectDialog dialog = ListSelectDialog dialog = ListSelectDialog(
ListSelectDialog(
list: model.branchesList, list: model.branchesList,
attributeName: 'Desciption', attributeName: 'Desciption',
attributeValueId: 'ID', attributeValueId: 'ID',
@ -172,8 +225,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
_selectedBranch = selectedValue; _selectedBranch = selectedValue;
_selectedClinic = null; _selectedClinic = null;
_selectedDoctor = null; _selectedDoctor = null;
model.getClinics( model.getClinics(_selectedBranch['ID']);
_selectedBranch['ID']);
}); });
}, },
); );
@ -207,8 +259,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
model.clinicsList != null && model.clinicsList != null &&
model.clinicsList.length > 0 model.clinicsList.length > 0
? () { ? () {
ListSelectDialog dialog = ListSelectDialog dialog = ListSelectDialog(
ListSelectDialog(
list: model.clinicsList, list: model.clinicsList,
attributeName: 'ClinicDescription', attributeName: 'ClinicDescription',
attributeValueId: 'ClinicID', attributeValueId: 'ClinicID',
@ -218,8 +269,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
_selectedDoctor = null; _selectedDoctor = null;
_selectedClinic = selectedValue; _selectedClinic = selectedValue;
model.getClinicDoctors( model.getClinicDoctors(
_selectedClinic['ClinicID'] _selectedClinic['ClinicID'].toString());
.toString());
}); });
}, },
); );
@ -253,8 +303,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
model.doctorsList != null && model.doctorsList != null &&
model.doctorsList.length > 0 model.doctorsList.length > 0
? () { ? () {
ListSelectDialog dialog = ListSelectDialog dialog = ListSelectDialog(
ListSelectDialog(
list: model.doctorsList, list: model.doctorsList,
attributeName: 'DoctorName', attributeName: 'DoctorName',
attributeValueId: 'DoctorID', attributeValueId: 'DoctorID',
@ -294,8 +343,7 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
onTap: () => _selectDate(context, model), onTap: () => _selectDate(context, model),
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: textFieldSelectorDecoration(
TranslationBase.of(context) TranslationBase.of(context).chooseAppointment,
.chooseAppointment,
appointmentDate != null appointmentDate != null
? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}" ? "${DateUtils.convertDateToFormat(appointmentDate, "yyyy-MM-dd")}"
: null, : null,
@ -314,14 +362,11 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
Container( Container(
child: TextField( child: TextField(
decoration: textFieldSelectorDecoration( decoration: textFieldSelectorDecoration(
TranslationBase.of(context).remarks, TranslationBase.of(context).remarks, null, false),
null,
false),
enabled: true, enabled: true,
controller: _remarksController, controller: _remarksController,
inputFormatters: [ inputFormatters: [
FilteringTextInputFormatter.allow( FilteringTextInputFormatter.allow(RegExp(ONLY_LETTERS))
RegExp(ONLY_LETTERS))
], ],
keyboardType: TextInputType.text, keyboardType: TextInputType.text,
minLines: 4, minLines: 4,
@ -329,41 +374,6 @@ class _PatientMakeReferralScreenState extends State<PatientMakeReferralScreen> {
)), )),
], ],
), ),
),
],
),
Container(
margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: AppButton(
title: TranslationBase.of(context).refer,
color: HexColor("#B8382B"),
onPressed: () {
if (appointmentDate == null ||
_selectedBranch == null ||
_selectedClinic == null ||
_selectedDoctor == null ||
_remarksController.text == null) return;
model
.makeReferral(
patient,
appointmentDate.toIso8601String(),
_selectedBranch['ID'],
_selectedClinic['ClinicID'],
_selectedDoctor['DoctorID'],
_remarksController.text)
.then((_) {
DrAppToastMsg.showSuccesToast(
TranslationBase.of(context).referralSuccessMsg);
Navigator.pop(context);
});
},
),
)
],
),
),
),
),
); );
} }

@ -37,7 +37,7 @@ class PatientReferralItemWidget extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Center( Center(
child: AppText( child: AppText(
patientName, "${patientName}",
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 16, fontSize: 16,
@ -48,9 +48,10 @@ class PatientReferralItemWidget extends StatelessWidget {
color: Color(0xFF4BA821), color: Color(0xFF4BA821),
padding: EdgeInsets.all(4), padding: EdgeInsets.all(4),
child: AppText( child: AppText(
referralStatus == "46" referralStatus
/*referralStatus == "46"
? TranslationBase.of(context).approved ? TranslationBase.of(context).approved
: TranslationBase.of(context).rejected, : TranslationBase.of(context).rejected*/,
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 12, fontSize: 12,

Loading…
Cancel
Save