|
|
|
|
@ -899,7 +899,9 @@ class HmgServicesViewModel extends ChangeNotifier {
|
|
|
|
|
int? projectID,
|
|
|
|
|
bool forceRefresh = false,
|
|
|
|
|
}) async {
|
|
|
|
|
if (hasVitalSignDataLoaded && transNo == null && projectID == null && !forceRefresh) {
|
|
|
|
|
final bool isSpecificQuery = (transNo != null || projectID != null);
|
|
|
|
|
|
|
|
|
|
if (!isSpecificQuery && hasVitalSignDataLoaded && !forceRefresh) {
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
|
onSuccess(GenericApiModel<List<VitalSignResModel>>(
|
|
|
|
|
messageStatus: 1,
|
|
|
|
|
@ -908,37 +910,44 @@ class HmgServicesViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
isVitalSignLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|
|
|
|
|
if (!isSpecificQuery) {
|
|
|
|
|
isVitalSignLoading = true;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final result = await hmgServicesRepo.getPatientVitalSign(transNo, projectID);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async {
|
|
|
|
|
isVitalSignLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (!isSpecificQuery) {
|
|
|
|
|
isVitalSignLoading = false;
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
await errorHandlerService.handleError(failure: failure);
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(failure.message);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
(apiResponse) {
|
|
|
|
|
isVitalSignLoading = false;
|
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
|
vitalSignList = apiResponse.data ?? [];
|
|
|
|
|
if (transNo == null && projectID == null) {
|
|
|
|
|
if (!isSpecificQuery) {
|
|
|
|
|
isVitalSignLoading = false;
|
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
|
vitalSignList = apiResponse.data ?? [];
|
|
|
|
|
hasVitalSignDataLoaded = true;
|
|
|
|
|
}
|
|
|
|
|
if (vitalSignList.isNotEmpty) {
|
|
|
|
|
getIt.get<SymptomsCheckerViewModel>().setSelectedHeight(vitalSignList.first.heightCm);
|
|
|
|
|
getIt.get<SymptomsCheckerViewModel>().setSelectedWeight(vitalSignList.first.weightKg);
|
|
|
|
|
if (vitalSignList.isNotEmpty) {
|
|
|
|
|
getIt.get<SymptomsCheckerViewModel>().setSelectedHeight(vitalSignList.first.heightCm);
|
|
|
|
|
getIt.get<SymptomsCheckerViewModel>().setSelectedWeight(vitalSignList.first.weightKg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (apiResponse.messageStatus == 1) {
|
|
|
|
|
if (onSuccess != null) {
|
|
|
|
|
onSuccess(apiResponse);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
notifyListeners();
|
|
|
|
|
if (onError != null) {
|
|
|
|
|
onError(apiResponse.errorMessage ?? 'Unknown error');
|
|
|
|
|
}
|
|
|
|
|
|