complete refer patient

merge-requests/111/head
ibrahim albitar 4 years ago
parent 4a8b97b189
commit 480c64d25a

@ -1,3 +1,5 @@
import 'package:flutter/cupertino.dart';
class ReferToDoctorRequest { class ReferToDoctorRequest {
/* /*
@ -64,27 +66,27 @@ class ReferToDoctorRequest {
*/ */
ReferToDoctorRequest( ReferToDoctorRequest(
{this.projectID, {@required this.projectID,
this.admissionNo, @required this.admissionNo,
this.roomID = "ISO-6", @required this.roomID ,
this.referralClinic, @required this.referralClinic,
this.referralDoctor , @required this.referralDoctor ,
this.createdBy, @required this.createdBy,
this.editedBy , @required this.editedBy ,
this.patientID, @required this.patientID,
this.patientTypeID = 1, @required this.patientTypeID,
this.referringClinic, @required this.referringClinic,
this.referringDoctor, @required this.referringDoctor,
this.referringDoctorRemarks, @required this.referringDoctorRemarks,
this.priority , @required this.priority ,
this.frequency, @required this.frequency,
this.extension, @required this.extension,
this.languageID = 2, this.languageID = 2,
this.stamp = "2020-06-03T11:26:42.358Z", this.stamp = "2020-06-03T11:26:42.358Z",
this.iPAdress = "11.11.11.11", this.iPAdress = "11.11.11.11",
this.versionID = 1.2, this.versionID = 1.2,
this.channel = 9, this.channel = 9,
this.tokenID, @required this.tokenID,
this.sessionID = "JBXRsDl37L", this.sessionID = "JBXRsDl37L",
this.isLoginForDoctorApp = true, this.isLoginForDoctorApp = true,
this.patientOutSA = false}); this.patientOutSA = false});

@ -68,7 +68,7 @@ class PatientsProvider with ChangeNotifier {
ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest(); ReferToDoctorRequest _referToDoctorRequest = ReferToDoctorRequest();
Client client = Client client =
HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]); HttpClientWithInterceptor.build(interceptors: [HttpInterceptor()]);
PatiantInformtion _selectedPatient; PatiantInformtion _selectedPatient;
@ -239,7 +239,7 @@ class PatientsProvider with ChangeNotifier {
try { try {
if (await Helpers.checkConnection()) { if (await Helpers.checkConnection()) {
final response = final response =
await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient)); await AppClient.post(GET_PRESCRIPTION, body: json.encode(patient));
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
isLoading = false; isLoading = false;
@ -302,22 +302,20 @@ class PatientsProvider with ChangeNotifier {
} }
} }
getPrescriptionReport(prescriptionReqModel) async{ getPrescriptionReport(prescriptionReqModel) async {
prescriptionReport = []; prescriptionReport = [];
isLoading = true; isLoading = true;
isError = false; isError = false;
error = ""; error = "";
notifyListeners(); notifyListeners();
await BaseAppClient.post( await BaseAppClient.post('Patients.svc/REST/GetPrescriptionReport',
'Patients.svc/REST/GetPrescriptionReport',
onSuccess: (dynamic response, int statusCode) { onSuccess: (dynamic response, int statusCode) {
response['ListPRM'].forEach((v) { response['ListPRM'].forEach((v) {
prescriptionReport prescriptionReport.add(PrescriptionReport.fromJson(v));
.add(PrescriptionReport.fromJson(v)); });
}); isError = false;
isError = false; isLoading = false;
isLoading = false; }, onFailure: (String error, int statusCode) {
}, onFailure: (String error, int statusCode) {
isError = true; isError = true;
isLoading = false; isLoading = false;
this.error = error; this.error = error;
@ -626,66 +624,70 @@ class PatientsProvider with ChangeNotifier {
*@desc: referToDoctor *@desc: referToDoctor
*/ */
referToDoctor( referToDoctor(
int selectedDoctorID, {String selectedDoctorID,
int selectedClinicID, String selectedClinicID,
String selectedReferralFrequancyID,
int admissionNo, int admissionNo,
String extension, String extension,
String doctorRemark) async { String priority,
String token = await sharedPref.getString(TOKEN); String frequency,
int projectID = await sharedPref.getInt(PROJECT_ID); String referringDoctorRemarks,
Map profile = await sharedPref.getObj(DOCTOR_PROFILE); int patientID,
DoctorProfileModel doctorProfile = new DoctorProfileModel.fromJson(profile); int patientTypeID,
int doctorID = doctorProfile.doctorID; String roomID,
int clinicId = doctorProfile.clinicID; int projectID}) async {
setBasicData(); setBasicData();
try { try {
if (await Helpers.checkConnection()) { if (await Helpers.checkConnection()) {
// _referToDoctorRequest.tokenID = token; String token = await sharedPref.getString(TOKEN);
// _referToDoctorRequest.admissionNo = admissionNo; Map profile = await sharedPref.getObj(DOCTOR_PROFILE);
// _referToDoctorRequest.projectID = projectID; DoctorProfileModel doctorProfile =
// _referToDoctorRequest.tokenID = token; new DoctorProfileModel.fromJson(profile);
// _referToDoctorRequest.extension = extension; int doctorID = doctorProfile.doctorID;
// _referToDoctorRequest.frequency = selectedReferralFrequancyID; int clinicId = doctorProfile.clinicID;
// _referToDoctorRequest.patientID = _referToDoctorRequest = ReferToDoctorRequest(
// _referToDoctorRequest.priority = projectID: projectID,
// _referToDoctorRequest.referralClinic = admissionNo: admissionNo,
// _referToDoctorRequest.referralDoctor = roomID: roomID,
// _referToDoctorRequest.referringDoctorRemarks = referralClinic: selectedClinicID.toString(),
// _referToDoctorRequest.roomID = referralDoctor: selectedDoctorID.toString(),
// _referToDoctorRequest.referringClinic = createdBy: doctorID,
// _referToDoctorRequest.referringDoctor = editedBy: doctorID,
patientID: patientID,
patientTypeID: patientTypeID,
referringClinic: clinicId,
referringDoctor: doctorID,
referringDoctorRemarks: referringDoctorRemarks,
priority: priority,
frequency: frequency,
extension: extension,
tokenID: token);
final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL, final response = await AppClient.post(PATIENT_REFER_TO_DOCTOR_URL,
body: json.encode(_referralFrequencyRequest)); body: json.encode(_referToDoctorRequest));
final int statusCode = response.statusCode; final int statusCode = response.statusCode;
isLoading = false; isLoading = false;
if (statusCode < 200 || statusCode >= 400 || json == null) { if (statusCode < 200 || statusCode >= 400 || json == null) {
isError = true; isError = true;
error = 'Error While Fetching data'; error = 'Error While Fetching data';
} else {
var res = json.decode(response.body);
print('$res');
if (res['MessageStatus'] == 1) {
print('Done : /n $res');
} else { } else {
var res = json.decode(response.body); isError = true;
print('$res'); error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
if (res['MessageStatus'] == 1) {
patientProgressNoteList = res['List_GetPregressNoteForInPatient'];
} else {
isError = true;
error = res['ErrorMessage'] ?? res['ErrorEndUserMessage'];
}
} }
} else {
isLoading = false;
isError = true;
error = 'Please Check The Internet Connection';
} }
notifyListeners(); } else {
} catch (err) { isLoading = false;
handelCatchErrorCase(err); isError = true;
error = 'Please Check The Internet Connection';
} }
notifyListeners();
} catch (err) {
handelCatchErrorCase(err);
} }
}
} }

@ -1,6 +1,13 @@
import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/widgets/shared/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_text_form_field.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart'; import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/rounded_container_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../../../config/size_config.dart'; import '../../../config/size_config.dart';
import '../../../providers/patients_provider.dart'; import '../../../providers/patients_provider.dart';
@ -29,13 +36,22 @@ class _ReferPatientState extends State<ReferPatientScreen> {
var doctorsList; var doctorsList;
var clinicsList; var clinicsList;
var referralFrequancyList; var referralFrequancyList;
final _controller = TextEditingController(); final _remarksController = TextEditingController();
final _extController = TextEditingController();
var _isInit = true; var _isInit = true;
var clinicId;
var doctorId;
var freqId;
String _selectedClinic; String _selectedClinic;
String _selectedDoctor; String _selectedDoctor;
String _selectedReferralFrequancy; String _selectedReferralFrequancy;
List<String> _priorities = ['Very Urgent', 'Urgent', 'Routine'];
int _activePriority = 2;
String _priorityTime;
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
@ -54,214 +70,410 @@ class _ReferPatientState extends State<ReferPatientScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AppScaffold( return AppScaffold(
appBarTitle: "Progress Note", appBarTitle: "Refer Patient",
body: patientsProv.isLoading body: patientsProv.isLoading
? DrAppCircularProgressIndeicator() ? DrAppCircularProgressIndeicator()
: patientsProv.isError : patientsProv.isError
? DrAppEmbeddedError(error: patientsProv.error) ? DrAppEmbeddedError(error: patientsProv.error)
: clinicsList == null : clinicsList == null
? DrAppEmbeddedError( ? DrAppEmbeddedError(
error: 'You don\'t have any Progress Note') error: 'Something Wrong!')
: Column( : SingleChildScrollView(
children: <Widget>[ child: Column(
RoundedContainer( mainAxisAlignment: MainAxisAlignment.start,
margin: 0, crossAxisAlignment: CrossAxisAlignment.start,
showBorder: true, children: <Widget>[
raduis: 30, AppText(
borderColor: Color(0xff707070), "Clinic",
width: double.infinity, fontSize: 18,
child: Padding( fontWeight: FontWeight.bold,
padding: EdgeInsets.only( marginLeft: 15,
top: SizeConfig.widthMultiplier * 0.9, marginTop: 15,
bottom: SizeConfig.widthMultiplier * 0.9, ),
right: SizeConfig.widthMultiplier * 3, RoundedContainer(
left: SizeConfig.widthMultiplier * 3), margin: 10,
child: Row( showBorder: true,
mainAxisSize: MainAxisSize.max, raduis: 30,
children: <Widget>[ borderColor: Color(0xff707070),
Expanded( width: double.infinity,
// add Expanded to have your dropdown button fill remaining space child: Padding(
child: DropdownButton( padding: EdgeInsets.only(
isExpanded: true, top: SizeConfig.widthMultiplier * 0.9,
value: _selectedClinic, bottom: SizeConfig.widthMultiplier * 0.9,
iconSize: 40, right: SizeConfig.widthMultiplier * 3,
elevation: 16, left: SizeConfig.widthMultiplier * 3),
selectedItemBuilder: child: Row(
(BuildContext context) { mainAxisSize: MainAxisSize.max,
return patientsProv children: <Widget>[
Expanded(
// add Expanded to have your dropdown button fill remaining space
child: DropdownButton(
isExpanded: true,
value: _selectedClinic,
iconSize: 40,
elevation: 16,
selectedItemBuilder:
(BuildContext context) {
return patientsProv
.getClinicNameList()
.map((item) {
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
AppText(
item,
fontSize:
SizeConfig.textMultiplier *
2.1,
),
],
);
}).toList();
},
onChanged: (newValue) => {
setState(() {
_selectedDoctor = null;
_selectedClinic = newValue;
var clinicInfo =
clinicsList.singleWhere((i) =>
i['ClinicDescription']
.toString()
.contains(_selectedClinic));
clinicId =
clinicInfo['ClinicID'].toString();
patientsProv.getDoctorsList(clinicId);
})
},
items: patientsProv
.getClinicNameList() .getClinicNameList()
.map((item) { .map((item) {
return Row( return DropdownMenuItem(
mainAxisSize: MainAxisSize.max, value: item.toString(),
children: <Widget>[ child: Text(
AppText( item,
item, textAlign: TextAlign.end,
fontSize: ),
SizeConfig.textMultiplier *
2.1,
),
],
); );
}).toList(); }).toList(),
}, ),
onChanged: (newValue) => {
setState(() {
_selectedDoctor = null;
_selectedClinic = newValue;
var clinicInfo =
clinicsList.singleWhere((i) =>
i['ClinicDescription']
.toString()
.contains(_selectedClinic));
var clinicId =
clinicInfo['ClinicID'].toString();
patientsProv.getDoctorsList(clinicId);
})
},
items: patientsProv
.getClinicNameList()
.map((item) {
return DropdownMenuItem(
value: item.toString(),
child: Text(
item,
textAlign: TextAlign.end,
),
);
}).toList(),
), ),
), ],
], ),
), ),
), ),
), //--------------------------------------------------------------------//
//--------------------------------------------------------------------// AppText(
RoundedContainer( "Doctor",
margin: 0, fontSize: 18,
showBorder: true, fontWeight: FontWeight.bold,
raduis: 30, marginLeft: 15,
borderColor: Color(0xff707070), marginTop: 15,
width: double.infinity, ),
child: Padding(
padding: EdgeInsets.only( RoundedContainer(
top: SizeConfig.widthMultiplier * 0.9, margin: 10,
bottom: SizeConfig.widthMultiplier * 0.9, showBorder: true,
right: SizeConfig.widthMultiplier * 3, raduis: 30,
left: SizeConfig.widthMultiplier * 3), borderColor: Color(0xff707070),
child: Row( width: double.infinity,
mainAxisSize: MainAxisSize.max, child: Padding(
children: <Widget>[ padding: EdgeInsets.only(
Expanded( top: SizeConfig.widthMultiplier * 0.9,
// add Expanded to have your dropdown button fill remaining space bottom: SizeConfig.widthMultiplier * 0.9,
child: DropdownButton( right: SizeConfig.widthMultiplier * 3,
isExpanded: true, left: SizeConfig.widthMultiplier * 3),
value: _selectedDoctor, child: Row(
iconSize: 40, mainAxisSize: MainAxisSize.max,
elevation: 16, children: <Widget>[
selectedItemBuilder: Expanded(
(BuildContext context) { // add Expanded to have your dropdown button fill remaining space
return patientsProv child: DropdownButton(
isExpanded: true,
value: _selectedDoctor,
iconSize: 40,
elevation: 16,
selectedItemBuilder:
(BuildContext context) {
return patientsProv
.getDoctorNameList()
.map((item) {
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
AppText(
item,
fontSize:
SizeConfig.textMultiplier *
2.1,
),
],
);
}).toList();
},
onChanged: (newValue) => {
setState(() {
_selectedDoctor = newValue;
var doctorInfo =
doctorsList.singleWhere((i) =>
i['DoctorName']
.toString()
.contains(_selectedDoctor));
doctorId =
doctorInfo['DoctorID'].toString();
})
},
items: patientsProv
.getDoctorNameList() .getDoctorNameList()
.map((item) { .map((item) {
return Row( return DropdownMenuItem(
mainAxisSize: MainAxisSize.max, value: item.toString(),
children: <Widget>[ child: Text(
AppText( item,
item, textAlign: TextAlign.end,
fontSize: ),
SizeConfig.textMultiplier *
2.1,
),
],
); );
}).toList(); }).toList(),
}, ),
onChanged: (newValue) => {
setState(() {
_selectedDoctor = newValue;
})
},
items: patientsProv
.getDoctorNameList()
.map((item) {
return DropdownMenuItem(
value: item.toString(),
child: Text(
item,
textAlign: TextAlign.end,
),
);
}).toList(),
), ),
), ],
], ),
),
), //-----------------------------///
AppText(
"Ext#",
fontSize: 18,
fontWeight: FontWeight.bold,
marginLeft: 15,
marginTop: 15,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: AppTextFormField(
hintText: "Ext#",
controller: _extController,
inputFormatter: ONLY_NUMBERS,
textInputType: TextInputType.number,
onChanged: (value) => {},
), ),
), ),
), //-----------------------------/// AppText(
RoundedContainer( "Priority",
margin: 0, fontSize: 18,
showBorder: true, fontWeight: FontWeight.bold,
raduis: 30, marginLeft: 15,
borderColor: Color(0xff707070), marginTop: 15,
width: double.infinity, ),
child: Padding(
padding: EdgeInsets.only( priorityBar(context),
top: SizeConfig.widthMultiplier * 0.9,
bottom: SizeConfig.widthMultiplier * 0.9, AppText(
right: SizeConfig.widthMultiplier * 3, "Replay Before: " + getPriority(),
left: SizeConfig.widthMultiplier * 3), fontWeight: FontWeight.bold,
child: Row( marginLeft: 15,
mainAxisSize: MainAxisSize.max, marginTop: 15,
children: <Widget>[ ),
Expanded(
// add Expanded to have your dropdown button fill remaining space AppText(
child: DropdownButton( "Referral Frequency",
isExpanded: true, fontSize: 18,
value: _selectedReferralFrequancy, fontWeight: FontWeight.bold,
iconSize: 40, marginLeft: 15,
elevation: 16, marginTop: 15,
selectedItemBuilder: ),
(BuildContext context) { RoundedContainer(
return patientsProv margin: 10,
showBorder: true,
raduis: 30,
borderColor: Color(0xff707070),
width: double.infinity,
child: Padding(
padding: EdgeInsets.only(
top: SizeConfig.widthMultiplier * 0.9,
bottom: SizeConfig.widthMultiplier * 0.9,
right: SizeConfig.widthMultiplier * 3,
left: SizeConfig.widthMultiplier * 3),
child: Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Expanded(
// add Expanded to have your dropdown button fill remaining space
child: DropdownButton(
isExpanded: true,
value: _selectedReferralFrequancy,
iconSize: 40,
elevation: 16,
selectedItemBuilder:
(BuildContext context) {
return patientsProv
.getReferralNamesList()
.map((item) {
return Row(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
AppText(
item,
fontSize:
SizeConfig.textMultiplier *
2.1,
),
],
);
}).toList();
},
onChanged: (newValue) => {
setState(() {
_selectedReferralFrequancy = newValue;
var freqInfo =
referralFrequancyList.singleWhere((i) =>
i['Description']
.toString()
.contains(_selectedReferralFrequancy));
freqId =
freqInfo['ParameterCode'].toString();
})
},
items: patientsProv
.getReferralNamesList() .getReferralNamesList()
.map((item) { .map((item) {
return Row( return DropdownMenuItem(
mainAxisSize: MainAxisSize.max, value: item.toString(),
children: <Widget>[ child: Text(
AppText( item,
item, textAlign: TextAlign.end,
fontSize: ),
SizeConfig.textMultiplier *
2.1,
),
],
); );
}).toList(); }).toList(),
}, ),
onChanged: (newValue) => {
setState(() {
_selectedReferralFrequancy = newValue;
})
},
items: patientsProv
.getReferralNamesList()
.map((item) {
return DropdownMenuItem(
value: item.toString(),
child: Text(
item,
textAlign: TextAlign.end,
),
);
}).toList(),
), ),
), ],
], ),
), ),
), ),
AppText(
"Clinical Details and Remarks",
fontSize: 18,
fontWeight: FontWeight.bold,
marginLeft: 15,
marginTop: 15,
),
Padding(
padding: const EdgeInsets.all(10.0),
child: AppTextFormField(
hintText: "Remarks",
controller: _remarksController,
inputFormatter: ONLY_LETTERS,
textInputType: TextInputType.text,
onChanged: (value) => {},
),
),
Padding(
padding: const EdgeInsets.all(20.0),
child: AppButton(title: "Send", color: Color(PRIMARY_COLOR),onPressed: ()=>{
referToDoctor()
},),
)
],
),
),
);
}
Widget priorityBar(BuildContext _context) {
return Container(
height: MediaQuery.of(context).size.height * 0.065,
width: SizeConfig.screenWidth * 0.9,
margin: EdgeInsets.only(top: 10),
decoration: BoxDecoration(
color: Color(0Xffffffff), borderRadius: BorderRadius.circular(20)),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: CrossAxisAlignment.center,
children: _priorities.map((item) {
bool _isActive = _priorities[_activePriority] == item ? true : false;
return Column(mainAxisSize: MainAxisSize.min, children: <Widget>[
InkWell(
child: Center(
child: Container(
height: 40,
width: 90,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
color: _isActive ? Hexcolor("#B8382B") : Colors.white,
),
child: Center(
child: Text(
item,
style: TextStyle(
fontSize: 12,
color: _isActive
? Colors.white
: Colors.black, //Colors.black,
// backgroundColor:_isActive
// ? Hexcolor("#B8382B")
// : Colors.white,//sideColor,
fontWeight: FontWeight.bold,
),
), ),
], )),
), ),
onTap: () {
print(_priorities.indexOf(item));
setState(() {
_activePriority = _priorities.indexOf(item);
});
}),
_isActive
? Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white),
alignment: Alignment.center,
height: 3,
width: 90,
)
: Container()
]);
}).toList(),
),
); );
} }
String getPriority() {
DateTime date = DateTime.now();
switch (_activePriority) {
case 0:
date = date.add(new Duration(hours: 3));
break;
case 1:
date = date.add(new Duration(hours: 6));
break;
case 2:
date = date.add(new Duration(days: 1));
break;
}
var format = DateFormat('yyyy/mm/dd HH:mm a');
var time = format.format(date);
print(time);
return time;
}
void referToDoctor(){
final routeArgs = ModalRoute.of(context).settings.arguments as Map;
PatiantInformtion patient = routeArgs['patient'];
patientsProv.referToDoctor(
extension: _extController.value.text,
admissionNo:int.parse( patient.admissionNo),
referringDoctorRemarks: _remarksController.value.text,
frequency: freqId,
patientID: patient.patientId,
patientTypeID: patient.patientType,
priority: (_activePriority + 1).toString(),
roomID: patient.roomId,
selectedClinicID: clinicId.toString(),
selectedDoctorID: doctorId.toString(),
projectID: patient.projectId
);
}
} }

Loading…
Cancel
Save