|
|
|
|
@ -257,7 +257,7 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> getFamilyFiles({int? status, Function(dynamic)? onSuccess, Function(String)? onError}) async {
|
|
|
|
|
final result = await medicalFileRepo.getPatientFamilyFiles(status, _appState.superUserID != null ? _appState.superUserID! : _appState.getAuthenticatedUser()!.patientId!);
|
|
|
|
|
final result = await medicalFileRepo.getPatientFamilyFiles(status, _appState.getSuperUserID != null ? _appState.getSuperUserID! : _appState.getAuthenticatedUser()!.patientId!);
|
|
|
|
|
|
|
|
|
|
result.fold(
|
|
|
|
|
(failure) async => await errorHandlerService.handleError(
|
|
|
|
|
@ -288,61 +288,157 @@ class MedicalFileViewModel extends ChangeNotifier {
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// final List<FamilyFileResponseModelLists> activeFamilyFiles = [];
|
|
|
|
|
// final List<FamilyFileResponseModelLists> tempPendingFamilyFiles = [];
|
|
|
|
|
// for (var element in apiResponse.data!) {
|
|
|
|
|
// if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
|
|
|
|
|
// activeFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
// patientId: element.patientId,
|
|
|
|
|
// patientName: element.patientName!,
|
|
|
|
|
// isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
|
|
|
|
|
// gender: element.gender!,
|
|
|
|
|
// responseId: element.patientId,
|
|
|
|
|
// mobileNumber: element.mobileNumber,
|
|
|
|
|
// age: element.age,
|
|
|
|
|
// patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
// relationship: element.relationship,
|
|
|
|
|
// relationshipId: element.relationshipId,
|
|
|
|
|
// relationshipN: element.relationshipN,
|
|
|
|
|
// status: element.status,
|
|
|
|
|
// statusDescription: element.statusDescription,
|
|
|
|
|
// createdOn: element.createdOn,
|
|
|
|
|
// editedOn: element.editedOn,
|
|
|
|
|
// patientDataVerified: element.patientDataVerified,
|
|
|
|
|
// regionId: element.regionId,
|
|
|
|
|
// familyRegionId: element.familyRegionId,
|
|
|
|
|
// genderDescription: element.genderDescription,
|
|
|
|
|
// genderImage: element.genderImage,
|
|
|
|
|
// emaiLAddress: element.emaiLAddress));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
|
|
|
|
|
// tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
// patientId: element.patientId,
|
|
|
|
|
// patientName: element.patientName!,
|
|
|
|
|
// isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
|
|
|
|
|
// gender: element.gender!,
|
|
|
|
|
// responseId: element.patientId,
|
|
|
|
|
// mobileNumber: element.mobileNumber,
|
|
|
|
|
// age: element.age,
|
|
|
|
|
// patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
// relationship: element.relationship,
|
|
|
|
|
// relationshipId: element.relationshipId,
|
|
|
|
|
// relationshipN: element.relationshipN,
|
|
|
|
|
// status: element.status,
|
|
|
|
|
// statusDescription: element.statusDescription,
|
|
|
|
|
// createdOn: element.createdOn,
|
|
|
|
|
// editedOn: element.editedOn,
|
|
|
|
|
// patientDataVerified: element.patientDataVerified,
|
|
|
|
|
// regionId: element.regionId,
|
|
|
|
|
// familyRegionId: element.familyRegionId,
|
|
|
|
|
// genderDescription: element.genderDescription,
|
|
|
|
|
// genderImage: element.genderImage,
|
|
|
|
|
// emaiLAddress: element.emaiLAddress));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// patientFamilyFiles.addAll(activeFamilyFiles.where((element) => !patientFamilyFiles.any((e) => e.patientId == element.patientId)));
|
|
|
|
|
// pendingFamilyFiles.addAll(tempPendingFamilyFiles);
|
|
|
|
|
|
|
|
|
|
final List<FamilyFileResponseModelLists> activeFamilyFiles = [];
|
|
|
|
|
final List<FamilyFileResponseModelLists> tempPendingFamilyFiles = [];
|
|
|
|
|
for (var element in apiResponse.data!) {
|
|
|
|
|
if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
|
|
|
|
|
activeFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
patientId: element.patientId,
|
|
|
|
|
patientName: element.patientName!,
|
|
|
|
|
isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
|
|
|
|
|
gender: element.gender!,
|
|
|
|
|
responseId: element.patientId,
|
|
|
|
|
mobileNumber: element.mobileNumber,
|
|
|
|
|
age: element.age,
|
|
|
|
|
patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
relationship: element.relationship,
|
|
|
|
|
relationshipId: element.relationshipId,
|
|
|
|
|
relationshipN: element.relationshipN,
|
|
|
|
|
status: element.status,
|
|
|
|
|
statusDescription: element.statusDescription,
|
|
|
|
|
createdOn: element.createdOn,
|
|
|
|
|
editedOn: element.editedOn,
|
|
|
|
|
patientDataVerified: element.patientDataVerified,
|
|
|
|
|
regionId: element.regionId,
|
|
|
|
|
familyRegionId: element.familyRegionId,
|
|
|
|
|
genderDescription: element.genderDescription,
|
|
|
|
|
genderImage: element.genderImage,
|
|
|
|
|
emaiLAddress: element.emaiLAddress));
|
|
|
|
|
}
|
|
|
|
|
// final Set<dynamic> pendingIds = {};
|
|
|
|
|
|
|
|
|
|
// for (var element in apiResponse.data!) {
|
|
|
|
|
// if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
|
|
|
|
|
// tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
// patientId: element.patientId,
|
|
|
|
|
// patientName: element.patientName!,
|
|
|
|
|
// isActive: false,
|
|
|
|
|
// gender: element.gender!,
|
|
|
|
|
// responseId: element.patientId,
|
|
|
|
|
// mobileNumber: element.mobileNumber,
|
|
|
|
|
// age: element.age,
|
|
|
|
|
// patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
// relationship: element.relationship,
|
|
|
|
|
// relationshipId: element.relationshipId,
|
|
|
|
|
// relationshipN: element.relationshipN,
|
|
|
|
|
// status: element.status,
|
|
|
|
|
// statusDescription: element.statusDescription,
|
|
|
|
|
// createdOn: element.createdOn,
|
|
|
|
|
// editedOn: element.editedOn,
|
|
|
|
|
// patientDataVerified: element.patientDataVerified,
|
|
|
|
|
// regionId: element.regionId,
|
|
|
|
|
// familyRegionId: element.familyRegionId,
|
|
|
|
|
// genderDescription: element.genderDescription,
|
|
|
|
|
// genderImage: element.genderImage,
|
|
|
|
|
// emaiLAddress: element.emaiLAddress));
|
|
|
|
|
// } else if (element.status != null && element.status == FamilyFileEnum.active.toInt) {
|
|
|
|
|
// activeFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
// patientId: element.patientId,
|
|
|
|
|
// patientName: element.patientName!,
|
|
|
|
|
// isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
|
|
|
|
|
// gender: element.gender!,
|
|
|
|
|
// responseId: element.patientId,
|
|
|
|
|
// mobileNumber: element.mobileNumber,
|
|
|
|
|
// age: element.age,
|
|
|
|
|
// patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
// relationship: element.relationship,
|
|
|
|
|
// relationshipId: element.relationshipId,
|
|
|
|
|
// relationshipN: element.relationshipN,
|
|
|
|
|
// status: element.status,
|
|
|
|
|
// statusDescription: element.statusDescription,
|
|
|
|
|
// createdOn: element.createdOn,
|
|
|
|
|
// editedOn: element.editedOn,
|
|
|
|
|
// patientDataVerified: element.patientDataVerified,
|
|
|
|
|
// regionId: element.regionId,
|
|
|
|
|
// familyRegionId: element.familyRegionId,
|
|
|
|
|
// genderDescription: element.genderDescription,
|
|
|
|
|
// genderImage: element.genderImage,
|
|
|
|
|
// emaiLAddress: element.emaiLAddress));
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
if (element.status != null && element.status == FamilyFileEnum.pending.toInt) {
|
|
|
|
|
tempPendingFamilyFiles.add(FamilyFileResponseModelLists(
|
|
|
|
|
patientId: element.patientId,
|
|
|
|
|
patientName: element.patientName!,
|
|
|
|
|
isActive: element.status == FamilyFileEnum.active.toInt ? true : false,
|
|
|
|
|
gender: element.gender!,
|
|
|
|
|
responseId: element.patientId,
|
|
|
|
|
mobileNumber: element.mobileNumber,
|
|
|
|
|
age: element.age,
|
|
|
|
|
patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
relationship: element.relationship,
|
|
|
|
|
relationshipId: element.relationshipId,
|
|
|
|
|
relationshipN: element.relationshipN,
|
|
|
|
|
status: element.status,
|
|
|
|
|
statusDescription: element.statusDescription,
|
|
|
|
|
createdOn: element.createdOn,
|
|
|
|
|
editedOn: element.editedOn,
|
|
|
|
|
patientDataVerified: element.patientDataVerified,
|
|
|
|
|
regionId: element.regionId,
|
|
|
|
|
familyRegionId: element.familyRegionId,
|
|
|
|
|
genderDescription: element.genderDescription,
|
|
|
|
|
genderImage: element.genderImage,
|
|
|
|
|
emaiLAddress: element.emaiLAddress));
|
|
|
|
|
for (var element in apiResponse.data!) {
|
|
|
|
|
if (element.status == null) continue;
|
|
|
|
|
|
|
|
|
|
final isPending = element.status == FamilyFileEnum.pending.toInt;
|
|
|
|
|
final isActive = element.status == FamilyFileEnum.active.toInt;
|
|
|
|
|
|
|
|
|
|
if (!isPending && !isActive) continue;
|
|
|
|
|
|
|
|
|
|
final familyFile = FamilyFileResponseModelLists(
|
|
|
|
|
patientId: element.patientId,
|
|
|
|
|
patientName: element.patientName!,
|
|
|
|
|
isActive: isActive,
|
|
|
|
|
gender: element.gender!,
|
|
|
|
|
responseId: element.patientId,
|
|
|
|
|
mobileNumber: element.mobileNumber,
|
|
|
|
|
age: element.age,
|
|
|
|
|
patientIdenficationNumber: element.patientIdenficationNumber,
|
|
|
|
|
relationship: element.relationship,
|
|
|
|
|
relationshipId: element.relationshipId,
|
|
|
|
|
relationshipN: element.relationshipN,
|
|
|
|
|
status: element.status,
|
|
|
|
|
statusDescription: element.statusDescription,
|
|
|
|
|
createdOn: element.createdOn,
|
|
|
|
|
editedOn: element.editedOn,
|
|
|
|
|
patientDataVerified: element.patientDataVerified,
|
|
|
|
|
regionId: element.regionId,
|
|
|
|
|
familyRegionId: element.familyRegionId,
|
|
|
|
|
genderDescription: element.genderDescription,
|
|
|
|
|
genderImage: element.genderImage,
|
|
|
|
|
emaiLAddress: element.emaiLAddress,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (isPending) {
|
|
|
|
|
tempPendingFamilyFiles.add(familyFile);
|
|
|
|
|
} else if (isActive) {
|
|
|
|
|
activeFamilyFiles.add(familyFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
patientFamilyFiles.addAll(activeFamilyFiles.where((element) => !patientFamilyFiles.any((e) => e.patientId == element.patientId)));
|
|
|
|
|
pendingFamilyFiles.addAll(tempPendingFamilyFiles);
|
|
|
|
|
|
|
|
|
|
patientFamilyFiles.addAll(activeFamilyFiles.where((element) => patientFamilyFiles.every((e) => e.patientId != element.patientId || e.status != FamilyFileEnum.active.toInt)));
|
|
|
|
|
pendingFamilyFiles.addAll(tempPendingFamilyFiles.where((element) => pendingFamilyFiles.every((e) => e.patientId != element.patientId)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
notifyListeners();
|
|
|
|
|
|