Merge branch 'master' into haroon_dev

pull/368/head
haroon amjad 1 month ago
commit 6819c59db5

@ -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');
}

@ -692,7 +692,7 @@ class _AppointmentDetailsPageState extends State<AppointmentDetailsPage> {
? (apiResponse.data ?? [])
: (apiResponse.data is List<VitalSignResModel>
? (apiResponse.data as List<VitalSignResModel>)
: hmgServicesVM.vitalSignList);
: <VitalSignResModel>[]);
VitalSignResModel? matchedVitalSign;
if (vitalList.isNotEmpty) {

Loading…
Cancel
Save