From bd9199d8e706bf923cb1ac511c9040159f060f2f Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 14:29:09 +0530 Subject: [PATCH 01/10] Patient Exit Survey issue fixed. --- .idea/misc.xml | 2 +- .../app/intelehealth/client/database/dao/EncounterDAO.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 8a8f75bfe2..703e5d4b89 100755 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ - + diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index 189047da15..4106ba89e7 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -119,8 +119,9 @@ public List unsyncedEncounters() { List encounterDTOList = new ArrayList<>(); SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb(); db.beginTransaction(); - Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR a.sync=?) and a.uuid = b.encounteruuid and b.sync='false' AND b.voided='0' ", new String[]{"false", "0"}); + Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR b.sync=?) and a.uuid = b.encounteruuid and b.sync='FALSE' AND b.voided='0' ", new String[]{"false", "0"}); EncounterDTO encounterDTO = new EncounterDTO(); + Log.d("RAINBOW: ","RAINBOW: "+idCursor.getCount()); if (idCursor.getCount() != 0) { while (idCursor.moveToNext()) { encounterDTO = new EncounterDTO(); @@ -193,8 +194,6 @@ public boolean updateEncounterSync(String synced, String uuid) throws DAOExcepti throw new DAOException(sql.getMessage()); } finally { db.endTransaction(); - - } return isUpdated; From 595d496826a3d603d772a3466e9af4f24a1c2fb8 Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 14:37:43 +0530 Subject: [PATCH 02/10] query modified as it was corrupt and wrongly written. --- .../java/app/intelehealth/client/database/dao/EncounterDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index 4106ba89e7..796ffdc858 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -119,7 +119,7 @@ public List unsyncedEncounters() { List encounterDTOList = new ArrayList<>(); SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb(); db.beginTransaction(); - Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR b.sync=?) and a.uuid = b.encounteruuid and b.sync='FALSE' AND b.voided='0' ", new String[]{"false", "0"}); + Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR a.sync=?) and a.uuid = b.encounteruuid and b.sync='FALSE' AND b.voided='0' ", new String[]{"false", "0"}); EncounterDTO encounterDTO = new EncounterDTO(); Log.d("RAINBOW: ","RAINBOW: "+idCursor.getCount()); if (idCursor.getCount() != 0) { From a96bb3878a5dffe9834881ece7608833798d8b6f Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 16:43:28 +0530 Subject: [PATCH 03/10] b.sync = 'FALSE' doesn't creates webapp data. --- .../java/app/intelehealth/client/database/dao/EncounterDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index 796ffdc858..d66b14c63d 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -119,7 +119,7 @@ public List unsyncedEncounters() { List encounterDTOList = new ArrayList<>(); SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb(); db.beginTransaction(); - Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR a.sync=?) and a.uuid = b.encounteruuid and b.sync='FALSE' AND b.voided='0' ", new String[]{"false", "0"}); + Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR a.sync=?) and a.uuid = b.encounteruuid and b.sync='false' AND b.voided='0' ", new String[]{"false", "0"}); EncounterDTO encounterDTO = new EncounterDTO(); Log.d("RAINBOW: ","RAINBOW: "+idCursor.getCount()); if (idCursor.getCount() != 0) { From c9749d411976bfbb30f8b558464edf05c85bd36b Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 16:53:12 +0530 Subject: [PATCH 04/10] sqlite query keywords all caps set. --- .../java/app/intelehealth/client/database/dao/EncounterDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index d66b14c63d..bbd10649fc 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -119,7 +119,7 @@ public List unsyncedEncounters() { List encounterDTOList = new ArrayList<>(); SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb(); db.beginTransaction(); - Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b where (a.sync = ? OR a.sync=?) and a.uuid = b.encounteruuid and b.sync='false' AND b.voided='0' ", new String[]{"false", "0"}); + Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b WHERE (a.sync = ? OR a.sync=?) AND a.uuid = b.encounteruuid AND b.sync='false' AND b.voided='0' ", new String[]{"false", "0"}); EncounterDTO encounterDTO = new EncounterDTO(); Log.d("RAINBOW: ","RAINBOW: "+idCursor.getCount()); if (idCursor.getCount() != 0) { From bd638cbaeb96bde54c88af6079a0bab54636bbd9 Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 20:40:23 +0530 Subject: [PATCH 05/10] Patient Exit Survey issue is FIXED. --- .../main/java/app/intelehealth/client/database/dao/ObsDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/ObsDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/ObsDAO.java index a4f5558f88..dff7fa136c 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/ObsDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/ObsDAO.java @@ -166,7 +166,7 @@ public boolean insertObsToDb(List obsDTO) throws DAOException { values.put("value", ob.getValue()); values.put("modified_date", AppConstants.dateAndTimeUtils.currentDateTime()); values.put("voided", "0"); - values.put("sync", "FALSE"); + values.put("sync", "false"); //Earlier was set to FALSE which caused the issue. insertedCount = db.insert("tbl_obs", null, values); } db.setTransactionSuccessful(); From 066fdcc6c2d1ebbeb83e4fd67132fba000195018 Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Wed, 11 Mar 2020 20:40:45 +0530 Subject: [PATCH 06/10] Comment is added. --- .../java/app/intelehealth/client/database/dao/EncounterDAO.java | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index bbd10649fc..cc857519ba 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -119,6 +119,7 @@ public List unsyncedEncounters() { List encounterDTOList = new ArrayList<>(); SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb(); db.beginTransaction(); + //Distinct keyword is used to remove all duplicate records. Cursor idCursor = db.rawQuery("SELECT distinct a.uuid,a.visituuid,a.encounter_type_uuid,a.provider_uuid,a.encounter_time,a.voided,a.privacynotice_value FROM tbl_encounter a,tbl_obs b WHERE (a.sync = ? OR a.sync=?) AND a.uuid = b.encounteruuid AND b.sync='false' AND b.voided='0' ", new String[]{"false", "0"}); EncounterDTO encounterDTO = new EncounterDTO(); Log.d("RAINBOW: ","RAINBOW: "+idCursor.getCount()); From a155adeeda7aa96bac9e0e866b17684386a19ad8 Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Thu, 12 Mar 2020 13:35:59 +0530 Subject: [PATCH 07/10] ProviderUUID is manually added for check and sync = false --- .../app/intelehealth/client/database/dao/EncounterDAO.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index cc857519ba..9dd7689ace 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -7,6 +7,7 @@ import android.util.Log; import com.crashlytics.android.Crashlytics; +import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; @@ -129,7 +130,7 @@ public List unsyncedEncounters() { encounterDTO.setUuid(idCursor.getString(idCursor.getColumnIndexOrThrow("uuid"))); encounterDTO.setVisituuid(idCursor.getString(idCursor.getColumnIndexOrThrow("visituuid"))); encounterDTO.setEncounterTypeUuid(idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_type_uuid"))); - encounterDTO.setProvideruuid(idCursor.getString(idCursor.getColumnIndexOrThrow("provider_uuid"))); + encounterDTO.setProvideruuid("28cea4ab-3188-434a-82f0-055133090a38"); Log.d("ENCO","ENCO_PROV: "+idCursor.getString(idCursor.getColumnIndexOrThrow("provider_uuid"))); encounterDTO.setEncounterTime(idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_time"))); Log.d("ENCO","ENCO_TIME: "+idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_time"))); @@ -142,7 +143,8 @@ public List unsyncedEncounters() { db.setTransactionSuccessful(); db.endTransaction(); - + Gson gson = new Gson(); + Log.d("ENC_GSON: ","ENC_GSON: "+gson.toJson(encounterDTOList)); return encounterDTOList; } From 234bfaf46a43a550bf751e02a4246bb4c637a52e Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Thu, 12 Mar 2020 16:54:22 +0530 Subject: [PATCH 08/10] FALSE -> false in ObsDAO was the issue. --- .../app/intelehealth/client/utilities/PatientsFrameJson.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/app/intelehealth/client/utilities/PatientsFrameJson.java b/app/src/main/java/app/intelehealth/client/utilities/PatientsFrameJson.java index 7e9fc77929..1a36d1ac9b 100644 --- a/app/src/main/java/app/intelehealth/client/utilities/PatientsFrameJson.java +++ b/app/src/main/java/app/intelehealth/client/utilities/PatientsFrameJson.java @@ -3,6 +3,7 @@ import android.util.Log; import com.crashlytics.android.Crashlytics; +import com.google.gson.Gson; import java.util.ArrayList; import java.util.List; @@ -171,6 +172,8 @@ public PushRequestApiCall frameJson() { pushRequestApiCall.setPersons(personList); pushRequestApiCall.setVisits(visitList); pushRequestApiCall.setEncounters(encounterList); + Gson gson = new Gson(); + Log.d("OBS: ","OBS: "+gson.toJson(encounterList)); return pushRequestApiCall; From 06f27403593a708178f898699693b407115b0eeb Mon Sep 17 00:00:00 2001 From: prajwalmw Date: Thu, 12 Mar 2020 16:55:40 +0530 Subject: [PATCH 09/10] Manual providrUUId code is removed. --- .../java/app/intelehealth/client/database/dao/EncounterDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java index 9dd7689ace..cb8289d7d4 100644 --- a/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java +++ b/app/src/main/java/app/intelehealth/client/database/dao/EncounterDAO.java @@ -130,7 +130,7 @@ public List unsyncedEncounters() { encounterDTO.setUuid(idCursor.getString(idCursor.getColumnIndexOrThrow("uuid"))); encounterDTO.setVisituuid(idCursor.getString(idCursor.getColumnIndexOrThrow("visituuid"))); encounterDTO.setEncounterTypeUuid(idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_type_uuid"))); - encounterDTO.setProvideruuid("28cea4ab-3188-434a-82f0-055133090a38"); + encounterDTO.setProvideruuid(idCursor.getString(idCursor.getColumnIndexOrThrow("provider_uuid"))); Log.d("ENCO","ENCO_PROV: "+idCursor.getString(idCursor.getColumnIndexOrThrow("provider_uuid"))); encounterDTO.setEncounterTime(idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_time"))); Log.d("ENCO","ENCO_TIME: "+idCursor.getString(idCursor.getColumnIndexOrThrow("encounter_time"))); From 821c66904d93e0d7ed283770d6c59a9622d920bd Mon Sep 17 00:00:00 2001 From: Sagar S Date: Fri, 13 Mar 2020 19:45:39 +0530 Subject: [PATCH 10/10] Issue is fixed Added Patient UUID from session & changed current time stamp by 5 min ago in Exit Survey Encounter. --- .../PatientSurveyActivity.java | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/app/intelehealth/client/activities/patientSurveyActivity/PatientSurveyActivity.java b/app/src/main/java/app/intelehealth/client/activities/patientSurveyActivity/PatientSurveyActivity.java index d38103e862..90467dc80f 100644 --- a/app/src/main/java/app/intelehealth/client/activities/patientSurveyActivity/PatientSurveyActivity.java +++ b/app/src/main/java/app/intelehealth/client/activities/patientSurveyActivity/PatientSurveyActivity.java @@ -15,7 +15,11 @@ import com.crashlytics.android.Crashlytics; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.List; import java.util.UUID; @@ -58,6 +62,7 @@ public class PatientSurveyActivity extends AppCompatActivity { String comments; SessionManager sessionManager = null; + @Override public void onBackPressed() { //do nothing @@ -115,13 +120,11 @@ public void onClick(View v) { public void onClick(View v) { if (rating != null && !TextUtils.isEmpty(rating)) { - Log.d(TAG, "Rating is "+rating); + Log.d(TAG, "Rating is " + rating); uploadSurvey(); endVisit(); - } - else - { - Toast.makeText(getApplicationContext(),getString(R.string.exit_survey_toast),Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getApplicationContext(), getString(R.string.exit_survey_toast), Toast.LENGTH_LONG).show(); } } @@ -158,9 +161,17 @@ private void uploadSurvey() { encounterDTO = new EncounterDTO(); encounterDTO.setUuid(uuid); encounterDTO.setEncounterTypeUuid(encounterDAO.getEncounterTypeUuid("ENCOUNTER_PATIENT_EXIT_SURVEY")); - encounterDTO.setEncounterTime(AppConstants.dateAndTimeUtils.currentDateTime()); + + //As per issue #785 - we fixed it by subtracting 1 minute from Encounter Time + try { + encounterDTO.setEncounterTime(fiveMinutesAgo(AppConstants.dateAndTimeUtils.currentDateTime())); + } catch (ParseException e) { + e.printStackTrace(); + } + encounterDTO.setVisituuid(visitUuid); - encounterDTO.setProvideruuid(encounterDTO.getProvideruuid()); //handles correct provideruuid for every patient +// encounterDTO.setProvideruuid(encounterDTO.getProvideruuid()); //handles correct provideruuid for every patient + encounterDTO.setProvideruuid(sessionManager.getProviderID()); //handles correct provideruuid for every patient encounterDTO.setSyncd(false); encounterDTO.setVoided(0); try { @@ -190,10 +201,17 @@ private void uploadSurvey() { Crashlytics.getInstance().core.logException(e); } +// AppConstants.notificationUtils.DownloadDone("Upload survey", "Survey uploaded", 3, PatientSurveyActivity.this); + + } -// AppConstants.notificationUtils.DownloadDone("Upload survey", "Survey uploaded", 3, PatientSurveyActivity.this); + public String fiveMinutesAgo(String timeStamp) throws ParseException { + long FIVE_MINS_IN_MILLIS = 5 * 60 * 1000; + DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); + long time = df.parse(timeStamp).getTime(); + return df.format(new Date(time - FIVE_MINS_IN_MILLIS)); } private void endVisit() { @@ -202,7 +220,6 @@ private void endVisit() { visitsDAO.updateVisitEnddate(visitUuid, AppConstants.dateAndTimeUtils.currentDateTime()); } catch (DAOException e) { Crashlytics.getInstance().core.logException(e); - } //SyncDAO syncDAO = new SyncDAO();