procedure refactoring

merge-requests/711/head
mosazaid 5 years ago
parent 9454e9d8af
commit bc48d915c6

@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]";
const ONLY_LETTERS = "[a-zA-Z &'\"]";
const ONLY_DATE = "[0-9/]";
const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/';
const BASE_URL = 'https://hmgwebservices.com/';
// const BASE_URL = 'https://uat.hmgwebservices.com/';
// const BASE_URL = 'https://hmgwebservices.com/';
const BASE_URL = 'https://uat.hmgwebservices.com/';
const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh";
const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList";
const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient";

@ -4,10 +4,10 @@ import 'package:doctor_app_flutter/core/model/labs/LabOrderResult.dart';
import 'package:doctor_app_flutter/core/model/labs/lab_result.dart';
import 'package:doctor_app_flutter/core/model/labs/patient_lab_orders.dart';
import 'package:doctor_app_flutter/core/model/labs/patient_lab_special_result.dart';
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/get_ordered_procedure_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_templateModel.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_template_details_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart';
@ -19,8 +19,12 @@ import 'package:doctor_app_flutter/core/service/patient_medical_file/radiology/r
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
import 'package:doctor_app_flutter/locator.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/procedures/ProcedureType.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:flutter/cupertino.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart'
as cpe;
class ProcedureViewModel extends BaseViewModel {
//TODO Hussam clean it
@ -84,11 +88,15 @@ class ProcedureViewModel extends BaseViewModel {
setState(ViewState.Idle);
}
Future getProcedureCategory({String categoryName, String categoryID, patientId}) async {
Future getProcedureCategory(
{String categoryName, String categoryID, patientId}) async {
if (categoryName == null) return;
hasError = false;
setState(ViewState.Busy);
await _procedureService.getProcedureCategory(
categoryName: categoryName, categoryID: categoryID,patientId: patientId);
categoryName: categoryName,
categoryID: categoryID,
patientId: patientId);
if (_procedureService.hasError) {
error = _procedureService.error;
setState(ViewState.ErrorLocal);
@ -137,8 +145,7 @@ class ProcedureViewModel extends BaseViewModel {
templateName: element.templateName,
templateId: element.templateID,
template: element);
if(!templateList.contains(template))
templateList.add(template);
if (!templateList.contains(template)) templateList.add(template);
}
});
print(templateList.length.toString());
@ -357,4 +364,70 @@ class ProcedureViewModel extends BaseViewModel {
} else
DrAppToastMsg.showSuccesToast(mes);
}
Future preparePostProcedure(
{String remarks,
String orderType,
PatiantInformtion patient,
List<cpe.EntityList> entityList,
ProcedureType procedureType}) async {
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.patientMRN;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = patient.appointmentNo;
postProcedureReqModel.episodeID = patient.episodeNo;
postProcedureReqModel.patientMRN = patient.patientMRN;
entityList.forEach((element) {
procedureValadteRequestModel.procedure = [element.procedureId];
List<Controls> controls = List();
controls.add(
Controls(
code: "remarks",
controlValue: element.remarks != null ? element.remarks : ""),
);
controls.add(
Controls(
code: "ordertype",
controlValue: procedureType == ProcedureType.PROCEDURE
? element.type ?? "1"
: "0"),
);
controlsProcedure.add(Procedures(
category: element.categoryID,
procedure: element.procedureId,
controls: controls));
});
postProcedureReqModel.procedures = controlsProcedure;
await valadteProcedure(procedureValadteRequestModel);
if (state == ViewState.Idle) {
if (valadteProcedureList[0].entityList.length == 0) {
await postProcedure(postProcedureReqModel, patient.patientMRN);
if (state == ViewState.ErrorLocal) {
Helpers.showErrorToast(error);
getProcedure(mrn: patient.patientMRN);
} else if (state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been added');
}
} else {
if (state == ViewState.ErrorLocal) {
Helpers.showErrorToast(error);
getProcedure(mrn: patient.patientMRN);
} else if (state == ViewState.Idle) {
Helpers.showErrorToast(
valadteProcedureList[0].entityList[0].warringMessages);
}
}
} else {
Helpers.showErrorToast(error);
}
}
}

@ -1,5 +1,81 @@
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:flutter/material.dart';
enum ProcedureType {
PROCEDURE,
LAB_RESULT,
RADIOLOGY,
}
}
extension procedureType on ProcedureType {
String getFavouriteTabName(BuildContext context) {
return TranslationBase.of(context).favoriteTemplates;
}
String getAllLabelName(BuildContext context) {
switch (this) {
case ProcedureType.PROCEDURE:
return TranslationBase.of(context).allProcedures;
case ProcedureType.LAB_RESULT:
return TranslationBase.of(context).allLab;
case ProcedureType.RADIOLOGY:
return TranslationBase.of(context).allRadiology;
default:
return "";
}
}
String getToolbarLabel(BuildContext context) {
switch (this) {
case ProcedureType.PROCEDURE:
return TranslationBase.of(context).addProcedures;
case ProcedureType.LAB_RESULT:
return TranslationBase.of(context).addRadiologyOrder;
case ProcedureType.RADIOLOGY:
return TranslationBase.of(context).addLabOrder;
default:
return "";
}
}
String getAddButtonTitle(BuildContext context) {
switch (this) {
case ProcedureType.PROCEDURE:
return TranslationBase.of(context).addProcedures;
case ProcedureType.LAB_RESULT:
return TranslationBase.of(context).addRadiologyOrder;
case ProcedureType.RADIOLOGY:
return TranslationBase.of(context).addLabOrder;
default:
return "";
}
}
String getCategoryId() {
switch (this) {
case ProcedureType.PROCEDURE:
return null;
case ProcedureType.LAB_RESULT:
return "02";
case ProcedureType.RADIOLOGY:
return "03";
default:
return null;
}
}
String getCategoryName() {
switch (this) {
case ProcedureType.PROCEDURE:
return null;
case ProcedureType.LAB_RESULT:
return "Laboratory";
case ProcedureType.RADIOLOGY:
return "Radiology";
default:
return null;
}
}
}

@ -1,349 +0,0 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
import 'ProcedureType.dart';
import 'entity_list_checkbox_search_widget.dart';
void addSelectedProcedure(
context, ProcedureViewModel model, PatiantInformtion patient) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return AddSelectedProcedure(
model: model,
patient: patient,
);
});
}
class AddSelectedProcedure extends StatefulWidget {
final ProcedureViewModel model;
final PatiantInformtion patient;
final ProcedureType procedureType;
const AddSelectedProcedure({Key key, this.model, this.patient, this.procedureType})
: super(key: key);
@override
_AddSelectedProcedureState createState() =>
_AddSelectedProcedureState(patient: patient, model: model);
}
class _AddSelectedProcedureState extends State<AddSelectedProcedure> {
int selectedType;
ProcedureViewModel model;
PatiantInformtion patient;
_AddSelectedProcedureState({this.patient, this.model});
TextEditingController procedureController = TextEditingController();
TextEditingController remarksController = TextEditingController();
List<EntityList> entityList = List();
List<EntityList> entityListProcedure = List();
TextEditingController procedureName = TextEditingController();
dynamic selectedCategory;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
@override
Widget build(BuildContext context) {
return BaseView<ProcedureViewModel>(
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: false,
body: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.070,
),
Expanded(
child: NetworkBaseView(
baseViewModel: model,
child: DraggableScrollableSheet(
minChildSize: 0.90,
initialChildSize: 0.95,
maxChildSize: 1.0,
builder: (BuildContext context,
ScrollController scrollController) {
return SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * 1.20,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
AppText(
TranslationBase.of(context)
.pleaseEnterProcedure,
fontWeight: FontWeight.w700,
fontSize: 20,
),
]),
SizedBox(
height:
MediaQuery.of(context).size.height * 0.04,
),
Row(
children: [
Container(
width: MediaQuery.of(context).size.width *
0.79,
child: AppTextFieldCustom(
hintText: TranslationBase.of(context)
.searchProcedureHere,
isTextFieldHasSuffix: false,
maxLines: 1,
minLines: 1,
hasBorder: true,
controller: procedureName,
// onSubmitted: (_) {
// model.getProcedureCategory(
// categoryName: procedureName.text);
// },
onClick: () {
if (procedureName.text.isNotEmpty &&
procedureName.text.length >= 3)
model.getProcedureCategory(
patientId: patient.patientId,
categoryName:
procedureName.text);
else
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.atLeastThreeCharacters,
);
},
),
),
SizedBox(
width: MediaQuery.of(context).size.width *
0.02,
),
Expanded(
child: InkWell(
onTap: () {
if (procedureName.text.isNotEmpty &&
procedureName.text.length >= 3)
model.getProcedureCategory(
patientId: patient.patientId,
categoryName: procedureName.text);
else
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.atLeastThreeCharacters,
);
},
child: Icon(
Icons.search,
size: 25.0,
),
),
),
],
),
if (procedureName.text.isNotEmpty &&
model.procedureList.length != 0)
NetworkBaseView(
baseViewModel: model,
child: EntityListCheckboxSearchWidget(
model: widget.model,
masterList: widget
.model.categoriesList[0].entityList,
removeHistory: (item) {
setState(() {
entityList.remove(item);
});
},
addHistory: (history) {
setState(() {
entityList.add(history);
});
},
addSelectedHistories: () {
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected: (master) =>
isEntityListSelected(master),
)),
SizedBox(
height: 115.0,
),
],
),
),
),
);
}),
),
),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: TranslationBase.of(context).addSelectedProcedures,
color: Color(0xff359846),
fontWeight: FontWeight.w700,
onPressed: () {
if (entityList.isEmpty == true) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.fillTheMandatoryProcedureDetails,
);
return;
}
Navigator.pop(context);
postProcedure(
orderType: selectedType.toString(),
entityList: entityList,
patient: patient,
model: widget.model,
remarks: remarksController.text);
},
),
],
),
),
],
),
),
);
}
bool isEntityListSelected(EntityList masterKey) {
Iterable<EntityList> history = entityList
.where((element) => masterKey.procedureId == element.procedureId);
if (history.length > 0) {
return true;
}
return false;
}
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown
? suffixIcon != null
? suffixIcon
: Icon(
Icons.arrow_drop_down,
color: Colors.black,
)
: null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
postProcedure(
{ProcedureViewModel model,
String remarks,
String orderType,
PatiantInformtion patient,
List<EntityList> entityList,
ProcedureType procedureType}) async {
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.patientMRN;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = patient.appointmentNo;
postProcedureReqModel.episodeID = patient.episodeNo;
postProcedureReqModel.patientMRN = patient.patientMRN;
entityList.forEach((element) {
procedureValadteRequestModel.procedure = [element.procedureId];
List<Controls> controls = List();
controls.add(
Controls(
code: "remarks",
controlValue: element.remarks != null ? element.remarks : ""),
);
controls.add(
Controls(code: "ordertype", controlValue: procedureType ==
ProcedureType.PROCEDURE ? element.type ?? "1" : "0"),
);
controlsProcedure.add(Procedures(
category: element.categoryID,
procedure: element.procedureId,
controls: controls));
});
postProcedureReqModel.procedures = controlsProcedure;
await model.valadteProcedure(procedureValadteRequestModel);
if (model.state == ViewState.Idle) {
if (model.valadteProcedureList[0].entityList.length == 0) {
await model.postProcedure(postProcedureReqModel, patient.patientMRN);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getProcedure(mrn: patient.patientMRN);
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been added');
}
} else {
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getProcedure(mrn: patient.patientMRN);
} else if (model.state == ViewState.Idle) {
Helpers.showErrorToast(
model.valadteProcedureList[0].entityList[0].warringMessages);
}
}
} else {
Helpers.showErrorToast(model.error);
}
}
}

@ -0,0 +1,265 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.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/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:doctor_app_flutter/widgets/shared/text_fields/app-textfield-custom.dart';
import 'package:flutter/material.dart';
import 'ProcedureType.dart';
import 'entity_list_checkbox_search_widget.dart';
class AddProcedurePage extends StatefulWidget {
final ProcedureViewModel model;
final PatiantInformtion patient;
final ProcedureType procedureType;
const AddProcedurePage(
{Key key, this.model, this.patient, this.procedureType})
: super(key: key);
@override
_AddProcedurePageState createState() => _AddProcedurePageState(
patient: patient, model: model, procedureType: this.procedureType);
}
class _AddProcedurePageState extends State<AddProcedurePage> {
int selectedType;
ProcedureViewModel model;
PatiantInformtion patient;
ProcedureType procedureType;
_AddProcedurePageState({this.patient, this.model, this.procedureType});
TextEditingController procedureController = TextEditingController();
TextEditingController remarksController = TextEditingController();
List<EntityList> entityList = List();
List<EntityList> entityListProcedure = List();
TextEditingController procedureName = TextEditingController();
dynamic selectedCategory;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
@override
Widget build(BuildContext context) {
return BaseView<ProcedureViewModel>(
onModelReady: (model) {
model.getProcedureCategory(
categoryName: procedureType.getCategoryName(),
categoryID: procedureType.getCategoryId(),
patientId: patient.patientId);
},
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: false,
body: Column(
children: [
Container(
height: MediaQuery.of(context).size.height * 0.070,
),
Expanded(
child: NetworkBaseView(
baseViewModel: model,
child: SingleChildScrollView(
child: Container(
// height: MediaQuery.of(context).size.height * 1.2,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (procedureType == ProcedureType.PROCEDURE)
Column(
children: [
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
AppText(
TranslationBase.of(context)
.pleaseEnterProcedure,
fontWeight: FontWeight.w700,
fontSize: 20,
),
],
),
SizedBox(
height:
MediaQuery.of(context).size.height * 0.02,
),
Row(
children: [
Container(
width: MediaQuery.of(context).size.width *
0.79,
child: AppTextFieldCustom(
hintText: TranslationBase.of(context)
.searchProcedureHere,
isTextFieldHasSuffix: false,
maxLines: 1,
minLines: 1,
hasBorder: true,
controller: procedureName,
// onClick: () {
// if (procedureName.text.isNotEmpty &&
// procedureName.text.length >= 3)
// model.getProcedureCategory(
// patientId: patient.patientId,
// categoryName:
// procedureName.text);
// else
// DrAppToastMsg.showErrorToast(
// TranslationBase.of(context)
// .atLeastThreeCharacters,
// );
// },
),
),
SizedBox(
width: MediaQuery.of(context).size.width *
0.02,
),
Expanded(
child: InkWell(
onTap: () {
if (procedureName.text.isNotEmpty &&
procedureName.text.length >= 3)
model.getProcedureCategory(
patientId: patient.patientId,
categoryName:
procedureName.text);
else
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.atLeastThreeCharacters,
);
},
child: Icon(
Icons.search,
size: 25.0,
),
),
),
],
),
],
),
if (procedureName.text.isNotEmpty &&
model.categoriesList.length != 0)
NetworkBaseView(
baseViewModel: model,
child: EntityListCheckboxSearchWidget(
model: widget.model,
masterList:
model.categoriesList[0].entityList,
removeHistory: (item) {
setState(() {
entityList.remove(item);
});
},
addHistory: (history) {
setState(() {
entityList.add(history);
});
},
addSelectedHistories: () {
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected: (master) =>
isEntityListSelected(master),
)),
],
),
),
),
),
),
),
Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: procedureType.getAddButtonTitle(context),
fontWeight: FontWeight.w700,
color: Color(0xff359846),
onPressed: () async {
if (entityList.isEmpty == true) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.fillTheMandatoryProcedureDetails,
);
return;
}
Navigator.pop(context);
await model.preparePostProcedure(
orderType: selectedType.toString(),
entityList: entityList,
patient: patient,
remarks: remarksController.text);
},
),
],
),
),
],
),
),
);
}
bool isEntityListSelected(EntityList masterKey) {
Iterable<EntityList> history = entityList
.where((element) => masterKey.procedureId == element.procedureId);
if (history.length > 0) {
return true;
}
return false;
}
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown
? suffixIcon != null
? suffixIcon
: Icon(
Icons.arrow_drop_down,
color: Colors.black,
)
: null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
}

@ -1,269 +0,0 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:flutter/material.dart';
import 'entity_list_checkbox_search_widget.dart';
valdateProcedure(ProcedureViewModel model, PatiantInformtion patient,
List<EntityList> entityList) async {
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.appointmentNo;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
}
postProcedure(
{ProcedureViewModel model,
String remarks,
String orderType,
PatiantInformtion patient,
List<EntityList> entityList}) async {
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.patientMRN;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = patient.appointmentNo;
postProcedureReqModel.episodeID = patient.episodeNo;
postProcedureReqModel.patientMRN = patient.patientMRN;
entityList.forEach((element) {
procedureValadteRequestModel.procedure = [element.procedureId];
List<Controls> controls = List();
controls.add(
Controls(
code: "remarks",
controlValue: element.remarks != null ? element.remarks : ""),
);
controls.add(
Controls(code: "ordertype", controlValue: "0"),
);
controlsProcedure.add(Procedures(
category: element.categoryID,
procedure: element.procedureId,
controls: controls));
});
postProcedureReqModel.procedures = controlsProcedure;
await model.valadteProcedure(procedureValadteRequestModel);
if (model.state == ViewState.Idle) {
if (model.valadteProcedureList[0].entityList.length == 0) {
await model.postProcedure(postProcedureReqModel, patient.patientMRN);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getLabs(patient);
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been added');
}
} else {
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getLabs(patient);
} else if (model.state == ViewState.Idle) {
Helpers.showErrorToast(
model.valadteProcedureList[0].entityList[0].warringMessages);
}
}
} else {
Helpers.showErrorToast(model.error);
}
}
void addSelectedLabOrder(
context, ProcedureViewModel model, PatiantInformtion patient) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return AddSelectedLabOrder(
model: model,
patient: patient,
);
});
}
class AddSelectedLabOrder extends StatefulWidget {
final ProcedureViewModel model;
final PatiantInformtion patient;
const AddSelectedLabOrder({Key key, this.model, this.patient})
: super(key: key);
@override
_AddSelectedLabOrderState createState() =>
_AddSelectedLabOrderState(patient: patient, model: model);
}
class _AddSelectedLabOrderState extends State<AddSelectedLabOrder> {
int selectedType;
ProcedureViewModel model;
PatiantInformtion patient;
_AddSelectedLabOrderState({this.patient, this.model});
TextEditingController procedureController = TextEditingController();
TextEditingController remarksController = TextEditingController();
List<EntityList> entityList = List();
List<EntityList> entityListProcedure = List();
dynamic selectedCategory;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
return BaseView<ProcedureViewModel>(
onModelReady: (model) => model.getProcedureCategory(
categoryName: "Laboratory", categoryID: "02",patientId: patient.patientId),
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: false,
body: NetworkBaseView(
baseViewModel: model,
child: DraggableScrollableSheet(
minChildSize: 0.90,
initialChildSize: 0.95,
maxChildSize: 1.0,
builder:
(BuildContext context, ScrollController scrollController) {
return SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * .90,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 10.0,
),
if (widget.model.categoriesList.length != 0)
NetworkBaseView(
baseViewModel: model,
child: EntityListCheckboxSearchWidget(
model: widget.model,
masterList:
widget.model.categoriesList[0].entityList,
removeHistory: (item) {
setState(() {
entityList.remove(item);
});
},
addHistory: (history) {
setState(() {
entityList.add(history);
});
},
addSelectedHistories: () {
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected: (master) =>
isEntityListSelected(master),
)),
],
),
),
),
);
}),
),
bottomSheet: Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: TranslationBase.of(context).addLabOrder,
fontWeight: FontWeight.w700,
color: Color(0xff359846),
onPressed: () {
if (entityList.isEmpty == true) {
DrAppToastMsg.showErrorToast(
TranslationBase.of(context)
.fillTheMandatoryProcedureDetails,
);
return;
}
Navigator.pop(context);
postProcedure(
orderType: selectedType.toString(),
entityList: entityList,
patient: patient,
model: widget.model,
remarks: remarksController.text);
},
),
],
),
),
),
);
}
bool isEntityListSelected(EntityList masterKey) {
Iterable<EntityList> history = entityList
.where((element) => masterKey.procedureId == element.procedureId);
if (history.length > 0) {
return true;
}
return false;
}
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown
? suffixIcon != null
? suffixIcon
: Icon(
Icons.arrow_drop_down,
color: Colors.black,
)
: null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
}

@ -1,270 +0,0 @@
import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
import 'package:doctor_app_flutter/core/model/procedure/ControlsModel.dart';
import 'package:doctor_app_flutter/core/model/procedure/categories_procedure.dart';
import 'package:doctor_app_flutter/core/model/procedure/post_procedure_req_model.dart';
import 'package:doctor_app_flutter/core/model/procedure/procedure_valadate_request_model.dart';
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/dr_app_toast_msg.dart';
import 'package:doctor_app_flutter/util/helpers.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/buttons/app_buttons_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/network_base_view.dart';
import 'package:flutter/material.dart';
import 'entity_list_checkbox_search_widget.dart';
valdateProcedure(ProcedureViewModel model, PatiantInformtion patient,
List<EntityList> entityList) async {
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.appointmentNo;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
}
postProcedure(
{ProcedureViewModel model,
String remarks,
String orderType,
PatiantInformtion patient,
List<EntityList> entityList}) async {
PostProcedureReqModel postProcedureReqModel = new PostProcedureReqModel();
ProcedureValadteRequestModel procedureValadteRequestModel =
new ProcedureValadteRequestModel();
procedureValadteRequestModel.patientMRN = patient.patientMRN;
procedureValadteRequestModel.episodeID = patient.episodeNo;
procedureValadteRequestModel.appointmentNo = patient.appointmentNo;
List<Procedures> controlsProcedure = List();
postProcedureReqModel.appointmentNo = patient.appointmentNo;
postProcedureReqModel.episodeID = patient.episodeNo;
postProcedureReqModel.patientMRN = patient.patientMRN;
entityList.forEach((element) {
procedureValadteRequestModel.procedure = [element.procedureId];
List<Controls> controls = List();
controls.add(
Controls(
code: "remarks",
controlValue: element.remarks != null ? element.remarks : ""),
);
controls.add(
Controls(code: "ordertype", controlValue: "0"),
);
controlsProcedure.add(Procedures(
category: element.categoryID,
procedure: element.procedureId,
controls: controls));
});
postProcedureReqModel.procedures = controlsProcedure;
await model.valadteProcedure(procedureValadteRequestModel);
if (model.state == ViewState.Idle) {
if (model.valadteProcedureList[0].entityList.length == 0) {
await model.postProcedure(postProcedureReqModel, patient.patientMRN);
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getPatientRadOrders(patient);
} else if (model.state == ViewState.Idle) {
DrAppToastMsg.showSuccesToast('procedure has been added');
}
} else {
if (model.state == ViewState.ErrorLocal) {
Helpers.showErrorToast(model.error);
model.getPatientRadOrders(patient);
} else if (model.state == ViewState.Idle) {
Helpers.showErrorToast(
model.valadteProcedureList[0].entityList[0].warringMessages);
}
}
} else {
Helpers.showErrorToast(model.error);
}
}
void addSelectedRadiologyOrder(
context, ProcedureViewModel model, PatiantInformtion patient) {
showModalBottomSheet(
context: context,
isScrollControlled: true,
builder: (BuildContext bc) {
return AddSelectedRadiologyOrder(
model: model,
patient: patient,
);
});
}
class AddSelectedRadiologyOrder extends StatefulWidget {
final ProcedureViewModel model;
final PatiantInformtion patient;
const AddSelectedRadiologyOrder({Key key, this.model, this.patient})
: super(key: key);
@override
_AddSelectedRadiologyOrderState createState() =>
_AddSelectedRadiologyOrderState(patient: patient, model: model);
}
class _AddSelectedRadiologyOrderState extends State<AddSelectedRadiologyOrder> {
int selectedType;
ProcedureViewModel model;
PatiantInformtion patient;
_AddSelectedRadiologyOrderState({this.patient, this.model});
TextEditingController procedureController = TextEditingController();
TextEditingController remarksController = TextEditingController();
List<EntityList> entityList = List();
List<EntityList> entityListProcedure = List();
dynamic selectedCategory;
setSelectedType(int val) {
setState(() {
selectedType = val;
});
}
@override
Widget build(BuildContext context) {
final screenSize = MediaQuery.of(context).size;
return BaseView<ProcedureViewModel>(
onModelReady: (model) => model.getProcedureCategory(
categoryName: "Radiology", categoryID: "03",patientId: patient.patientId),
builder: (BuildContext context, ProcedureViewModel model, Widget child) =>
AppScaffold(
isShowAppBar: false,
body: NetworkBaseView(
baseViewModel: model,
child: DraggableScrollableSheet(
minChildSize: 0.90,
initialChildSize: 0.95,
maxChildSize: 1.0,
builder:
(BuildContext context, ScrollController scrollController) {
return SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height * 1.0,
child: Padding(
padding: EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 10.0,
),
if (widget.model.categoriesList.length != 0)
NetworkBaseView(
baseViewModel: model,
child: EntityListCheckboxSearchWidget(
model: widget.model,
masterList:
widget.model.categoriesList[0].entityList,
removeHistory: (item) {
setState(() {
entityList.remove(item);
});
},
addHistory: (history) {
setState(() {
entityList.add(history);
});
},
addSelectedHistories: () {
//TODO build your fun herr
// widget.addSelectedHistories();
},
isEntityListSelected: (master) =>
isEntityListSelected(master),
)),
],
),
),
),
);
}),
),
bottomSheet: Container(
margin: EdgeInsets.all(SizeConfig.widthMultiplier * 5),
child: Wrap(
alignment: WrapAlignment.center,
children: <Widget>[
AppButton(
title: TranslationBase.of(context).addRadiologyOrder,
color: Color(0xff359846),
fontWeight: FontWeight.w700,
onPressed: () {
if (entityList.isEmpty == true) {
DrAppToastMsg.showErrorToast(TranslationBase.of(context)
.fillTheMandatoryProcedureDetails);
return;
}
Navigator.pop(context);
postProcedure(
orderType: selectedType.toString(),
entityList: entityList,
patient: patient,
model: widget.model,
remarks: remarksController.text);
},
),
],
),
),
),
);
}
bool isEntityListSelected(EntityList masterKey) {
Iterable<EntityList> history = entityList
.where((element) => masterKey.procedureId == element.procedureId);
if (history.length > 0) {
return true;
}
return false;
}
InputDecoration textFieldSelectorDecoration(
String hintText, String selectedText, bool isDropDown,
{Icon suffixIcon}) {
return InputDecoration(
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
disabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xFFCCCCCC), width: 2.0),
borderRadius: BorderRadius.circular(8),
),
hintText: selectedText != null ? selectedText : hintText,
suffixIcon: isDropDown
? suffixIcon != null
? suffixIcon
: Icon(
Icons.arrow_drop_down,
color: Colors.black,
)
: null,
hintStyle: TextStyle(
fontSize: 14,
color: Colors.grey.shade600,
),
);
}
}

@ -11,9 +11,7 @@ import 'package:flutter/material.dart';
import 'ProcedureType.dart';
import 'add-favourite-procedure.dart';
import 'add-procedure-form.dart';
import 'add_lab_orders.dart';
import 'add_radiology_order.dart';
import 'add-procedure-page.dart';
class BaseAddProcedureTabPage extends StatefulWidget {
final ProcedureViewModel model;
@ -25,8 +23,8 @@ class BaseAddProcedureTabPage extends StatefulWidget {
: super(key: key);
@override
_BaseAddProcedureTabPageState createState() =>
_BaseAddProcedureTabPageState(patient: patient, model: model, procedureType: procedureType);
_BaseAddProcedureTabPageState createState() => _BaseAddProcedureTabPageState(
patient: patient, model: model, procedureType: procedureType);
}
class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
@ -86,13 +84,7 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
AppText(
procedureType == ProcedureType.PROCEDURE
? TranslationBase.of(context).addProcedures
: procedureType == ProcedureType.RADIOLOGY
? TranslationBase.of(context)
.addRadiologyOrder
: TranslationBase.of(context)
.addLabOrder,
procedureType.getToolbarLabel(context),
fontWeight: FontWeight.w700,
fontSize: 20,
),
@ -140,21 +132,13 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
tabWidget(
screenSize,
_activeTab == 0,
TranslationBase.of(context)
.favoriteTemplates,
procedureType
.getFavouriteTabName(context),
),
tabWidget(
screenSize,
_activeTab == 1,
procedureType == ProcedureType.PROCEDURE
? TranslationBase.of(context)
.allProcedures
: procedureType ==
ProcedureType.RADIOLOGY
? TranslationBase.of(context)
.allRadiology
: TranslationBase.of(context)
.allLab,
procedureType.getAllLabelName(context),
),
],
),
@ -171,49 +155,18 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
AddFavouriteProcedure(
patient: patient,
model: model,
addButtonTitle: procedureType ==
ProcedureType.PROCEDURE
? TranslationBase.of(context)
.addProcedures
: procedureType ==
ProcedureType.RADIOLOGY
? TranslationBase.of(context)
.addRadiologyOrder
: TranslationBase.of(context)
.addLabOrder,
toolbarTitle: procedureType ==
ProcedureType.PROCEDURE
? TranslationBase.of(context)
.addProcedures
: procedureType ==
ProcedureType.RADIOLOGY
? TranslationBase.of(context)
.addRadiologyOrder
: TranslationBase.of(context)
.addLabOrder,
categoryID: procedureType ==
ProcedureType.PROCEDURE
? null
: procedureType ==
ProcedureType.RADIOLOGY
? "03"
: "02",
addButtonTitle: procedureType
.getAddButtonTitle(context),
toolbarTitle: procedureType
.getToolbarLabel(context),
categoryID:
procedureType.getCategoryId(),
),
AddProcedurePage(
model: model,
patient: patient,
procedureType: procedureType,
),
procedureType == ProcedureType.PROCEDURE
? AddSelectedProcedure(
model: model,
patient: patient,
)
: procedureType ==
ProcedureType.RADIOLOGY
? AddSelectedRadiologyOrder(
model: model,
patient: patient,
)
: AddSelectedLabOrder(
model: model,
patient: patient,
),
],
),
),
@ -276,5 +229,3 @@ class _BaseAddProcedureTabPageState extends State<BaseAddProcedureTabPage>
);
}
}

@ -4,7 +4,7 @@ import 'package:doctor_app_flutter/core/model/procedure/procedure_template_detai
import 'package:doctor_app_flutter/core/viewModel/procedure_View_model.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/procedures/add-procedure-form.dart';
import 'package:doctor_app_flutter/screens/procedures/add-procedure-page.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/TextFields.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
@ -223,10 +223,9 @@ class _ProcedureCheckOutScreenState extends State<ProcedureCheckOutScreen> {
);
});
Navigator.pop(context);
await postProcedure(
await model.preparePostProcedure(
entityList: entityList,
patient: widget.patient,
model: widget.model,
remarks: remarksController.text);
Navigator.pop(context);
Navigator.pop(context);

Loading…
Cancel
Save