add vital-sign files
parent
765c546c28
commit
94093e775e
@ -1,8 +1,10 @@
|
|||||||
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
import 'package:doctor_app_flutter/client/base_app_client.dart';
|
||||||
|
import 'package:doctor_app_flutter/util/dr_app_shared_pref.dart';
|
||||||
|
|
||||||
class BaseService {
|
class BaseService {
|
||||||
String error;
|
String error;
|
||||||
bool hasError = false;
|
bool hasError = false;
|
||||||
BaseAppClient baseAppClient = BaseAppClient();
|
BaseAppClient baseAppClient = BaseAppClient();
|
||||||
|
DrAppSharedPreferances sharedPref = new DrAppSharedPreferances();
|
||||||
//TODO add the user login model when we need it
|
//TODO add the user login model when we need it
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
import 'package:doctor_app_flutter/config/config.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
||||||
|
import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart';
|
||||||
|
|
||||||
|
class VitalSignsService extends BaseService{
|
||||||
|
|
||||||
|
List<VitalSignResModel> patientVitalSignList = [];
|
||||||
|
List<VitalSignResModel> patientVitalSignOrderdSubList = [];
|
||||||
|
|
||||||
|
Future getPatientVitalSign(patient) async {
|
||||||
|
hasError = false;
|
||||||
|
await baseAppClient.post(
|
||||||
|
GET_PATIENT_VITAL_SIGN,
|
||||||
|
onSuccess: (dynamic response, int statusCode) {
|
||||||
|
patientVitalSignList = [];
|
||||||
|
response['List_DoctorPatientVitalSign'].forEach((v) {
|
||||||
|
patientVitalSignList.add(new VitalSignResModel.fromJson(v));
|
||||||
|
});
|
||||||
|
|
||||||
|
if (patientVitalSignList.length > 0) {
|
||||||
|
List<VitalSignResModel> patientVitalSignOrderdSubListTemp = [];
|
||||||
|
patientVitalSignOrderdSubListTemp = patientVitalSignList;
|
||||||
|
patientVitalSignOrderdSubListTemp
|
||||||
|
.sort((VitalSignResModel a, VitalSignResModel b) {
|
||||||
|
return b.vitalSignDate.microsecondsSinceEpoch -
|
||||||
|
a.vitalSignDate.microsecondsSinceEpoch;
|
||||||
|
});
|
||||||
|
patientVitalSignOrderdSubList.clear();
|
||||||
|
int length = patientVitalSignOrderdSubListTemp.length >= 20
|
||||||
|
? 20
|
||||||
|
: patientVitalSignOrderdSubListTemp.length;
|
||||||
|
for (int x = 0; x < length; x++) {
|
||||||
|
patientVitalSignOrderdSubList
|
||||||
|
.add(patientVitalSignOrderdSubListTemp[x]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onFailure: (String error, int statusCode) {
|
||||||
|
hasError = true;
|
||||||
|
super.error = error;
|
||||||
|
},
|
||||||
|
body: patient,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import 'package:doctor_app_flutter/core/enum/viewstate.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/service/patient-vital-signs-service.dart';
|
||||||
|
import 'package:doctor_app_flutter/core/viewModel/base_view_model.dart';
|
||||||
|
import 'package:doctor_app_flutter/models/patient/vital_sign/vital_sign_res_model.dart';
|
||||||
|
|
||||||
|
import '../../locator.dart';
|
||||||
|
|
||||||
|
class VitalSignsViewModel extends BaseViewModel{
|
||||||
|
VitalSignsService _vitalSignService = locator<VitalSignsService>();
|
||||||
|
|
||||||
|
List<VitalSignResModel> get patientVitalSignList =>
|
||||||
|
_vitalSignService.patientVitalSignList;
|
||||||
|
|
||||||
|
List<VitalSignResModel> get patientVitalSignOrderdSubList =>
|
||||||
|
_vitalSignService.patientVitalSignOrderdSubList;
|
||||||
|
|
||||||
|
Future getPatientVitalSign(patient) async {
|
||||||
|
setState(ViewState.Busy);
|
||||||
|
await _vitalSignService.getPatientVitalSign(patient);
|
||||||
|
if (_vitalSignService.hasError) {
|
||||||
|
error = _vitalSignService.error;
|
||||||
|
setState(ViewState.Error);
|
||||||
|
} else
|
||||||
|
setState(ViewState.Idle);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue