Skip to content

Commit

Permalink
Done minor change for triggering prescription notifications as change…
Browse files Browse the repository at this point in the history
… into Sync functionality
  • Loading branch information
nehav39 committed Nov 13, 2019
1 parent 555fc43 commit 65adf0d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
42 changes: 32 additions & 10 deletions app/src/main/java/io/intelehealth/client/database/dao/SyncDAO.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.crashlytics.android.Crashlytics;
import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import io.intelehealth.client.R;
import io.intelehealth.client.app.AppConstants;
Expand All @@ -22,6 +24,8 @@
import io.intelehealth.client.models.pushResponseApiCall.PushResponseApiCall;
import io.intelehealth.client.services.LastSyncIntentService;
import io.intelehealth.client.utilities.Logger;
import io.intelehealth.client.utilities.NotificationID;
import io.intelehealth.client.utilities.NotificationUtils;
import io.intelehealth.client.utilities.PatientsFrameJson;
import io.intelehealth.client.utilities.SessionManager;
import io.intelehealth.client.utilities.exception.DAOException;
Expand Down Expand Up @@ -107,9 +111,28 @@ public void onResponse(Call<ResponseDTO> call, Response<ResponseDTO> response) {
AppConstants.notificationUtils.DownloadDone("sync", "failed synced,You can try again", 1, IntelehealthApplication.getAppContext());

if (response.body().getData() != null) {
triggerVisitNotification(response.body().getData().getVisitDTO());
}
ArrayList<String> listPatientUUID = new ArrayList<String>();
List<VisitDTO> listVisitDTO = new ArrayList<>();
ArrayList<String> encounterVisitUUID = new ArrayList<String>();
for (int i = 0; i < response.body().getData().getEncounterDTO().size(); i++) {
if (response.body().getData().getEncounterDTO().get(i)
.getEncounterTypeUuid().equalsIgnoreCase("d7151f82-c1f3-4152-a605-2f9ea7414a79")) {
encounterVisitUUID.add(response.body().getData().getEncounterDTO().get(i).getVisituuid());
}
}
listVisitDTO.addAll(response.body().getData().getVisitDTO());
for (int i = 0; i < encounterVisitUUID.size() ; i++) {
for (int j = 0; j < listVisitDTO.size(); j++) {
if (encounterVisitUUID.get(i).equalsIgnoreCase(listVisitDTO.get(j).getUuid())){
listPatientUUID.add(listVisitDTO.get(j).getPatientuuid());
}
}
}

if (listPatientUUID.size() > 0) {
triggerVisitNotification(listPatientUUID);
}
}
}

Logger.logD("End Pull request", "Ended");
Expand All @@ -128,19 +151,18 @@ public void onFailure(Call<ResponseDTO> call, Throwable t) {
return true;
}

private void triggerVisitNotification(List<VisitDTO> listVisitDTO) {
private void triggerVisitNotification(ArrayList<String> listPatientUUID) {

List<ActivePatientModel> activePatientList = new ArrayList<>();
getPatients(activePatientList);

List<VisitDTO> visitDTO = new ArrayList<>();
visitDTO.addAll(listVisitDTO);

if (visitDTO != null) {
for (int i = 0; i < visitDTO.size(); i++) {
if (listPatientUUID != null) {
for (int i = 0; i < listPatientUUID.size(); i++) {
for (int j = 0; j < activePatientList.size(); j++) {
if (visitDTO.get(i).getPatientuuid().equalsIgnoreCase(activePatientList.get(j).getPatientuuid())) {
AppConstants.notificationUtils.DownloadDone(IntelehealthApplication.getAppContext().getResources().getString(R.string.patient) + " " + activePatientList.get(j).getFirst_name() + " " + activePatientList.get(j).getLast_name(), IntelehealthApplication.getAppContext().getResources().getString(R.string.has_a_new_prescription), 2, IntelehealthApplication.getAppContext());
if (listPatientUUID.get(i).equalsIgnoreCase(activePatientList.get(j).getPatientuuid())) {
Log.e("GET-ID", "" + NotificationID.getID());
AppConstants.notificationUtils.DownloadDone(IntelehealthApplication.getAppContext().getResources().getString(R.string.patient) + " " + activePatientList.get(j).getFirst_name() + " " + activePatientList.get(j).getLast_name(),
IntelehealthApplication.getAppContext().getResources().getString(R.string.has_a_new_prescription), NotificationID.getID(), IntelehealthApplication.getAppContext());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.intelehealth.client.utilities;

import java.util.concurrent.atomic.AtomicInteger;

/**
* Created by Sagar Shimpi
* Github - sagarS23
*/
public class NotificationID {
private final static AtomicInteger c = new AtomicInteger(5);

public static int getID() {
return c.incrementAndGet();
}
}

0 comments on commit 65adf0d

Please sign in to comment.