Skip to content

Commit

Permalink
Fixed multiple specialty issue & minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SagarS committed Jan 12, 2021
1 parent 531eb0b commit 399e064
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,18 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
uploadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

isVisitSpecialityExists = speciality_row_exist_check(visitUUID);
if (speciality_spinner.getSelectedItemPosition() != 0) {
// VisitsDAO visitsDAO_speciality = new VisitsDAO();
VisitAttributeListDAO speciality_attributes = new VisitAttributeListDAO();
boolean isUpdateVisitDone = false;
try {
// isUpdateVisitDone = visitsDAO_speciality.update_visitTbl_speciality
// (speciality_selected, visitUuid);
isUpdateVisitDone = speciality_attributes
.insertVisitAttributes(visitUuid, speciality_selected);
if (!isVisitSpecialityExists) {
isUpdateVisitDone = speciality_attributes
.insertVisitAttributes(visitUuid, speciality_selected);
}

Log.d("Update_Special_Visit", "Update_Special_Visit: " + isUpdateVisitDone);
} catch (DAOException e) {
Expand All @@ -782,7 +784,7 @@ public void onClick(View view) {
}

Log.d("visitUUID", "upload_click: " + visitUUID);
isVisitSpecialityExists = speciality_row_exist_check(visitUUID);

if (isVisitSpecialityExists)
speciality_spinner.setEnabled(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,7 @@ public void syncBackground() {
SyncDAO syncDAO = new SyncDAO();
ImagesPushDAO imagesPushDAO = new ImagesPushDAO();

// Checking if Specialty is added or not in visit
PushRequestApiCall pushRequestApiCall;
PatientsFrameJson patientsFrameJson = new PatientsFrameJson();
pushRequestApiCall = patientsFrameJson.frameJson();

for (int i = 0; i < pushRequestApiCall.getVisits().size(); i++) {
if (pushRequestApiCall.getVisits().get(i).getAttributes().size() > 0) {
syncDAO.pushDataApi();
}
}

syncDAO.pushDataApi();
syncDAO.pullData_Background(IntelehealthApplication.getAppContext()); //only this new function duplicate

imagesPushDAO.patientProfileImagesPush();
Expand Down Expand Up @@ -80,21 +70,9 @@ public boolean syncForeground(String fromActivity) {
ImagesPushDAO imagesPushDAO = new ImagesPushDAO();
Logger.logD(TAG, "Push Started");

// Checking if Specialty is added or not in visit
PushRequestApiCall pushRequestApiCall;
PatientsFrameJson patientsFrameJson = new PatientsFrameJson();
pushRequestApiCall = patientsFrameJson.frameJson();

for (int i = 0; i < pushRequestApiCall.getVisits().size(); i++) {
if (pushRequestApiCall.getVisits().get(i).getAttributes().size() > 0) {
isSynced = syncDAO.pushDataApi();
}
}

// isSynced = syncDAO.pushDataApi();
isSynced = syncDAO.pushDataApi();
Logger.logD(TAG, "Push ended");


// need to add delay for pulling the obs correctly
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package app.intelehealth.client.utilities;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;


Expand All @@ -9,6 +11,7 @@
import java.util.ArrayList;
import java.util.List;

import app.intelehealth.client.app.AppConstants;
import app.intelehealth.client.app.IntelehealthApplication;
import app.intelehealth.client.database.dao.EncounterDAO;
import app.intelehealth.client.database.dao.ObsDAO;
Expand Down Expand Up @@ -121,7 +124,11 @@ public PushRequestApiCall frameJson() {
visit.setVisitType(visitDTO.getVisitTypeUuid());
visit.setStopDatetime(visitDTO.getEnddate());
visit.setAttributes(visitDTO.getAttributes());
visitList.add(visit);
// visitList.add(visit);

if (visitDTO.getAttributes().size() > 0) {
visitList.add(visit);
}

}

Expand Down Expand Up @@ -168,7 +175,12 @@ public PushRequestApiCall frameJson() {

encounter.setLocation(session.getLocationUuid());

encounterList.add(encounter);
// encounterList.add(encounter);

if (speciality_row_exist_check(encounter.getVisit())){
encounterList.add(encounter);
}

}


Expand All @@ -182,4 +194,27 @@ public PushRequestApiCall frameJson() {

return pushRequestApiCall;
}

/**
* @param uuid the visit uuid of the patient visit records is passed to the function.
* @return boolean value will be returned depending upon if the row exists in the tbl_visit_attribute tbl
*/
private boolean speciality_row_exist_check(String uuid) {
boolean isExists = false;
SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getReadableDatabase();
db.beginTransaction();
Cursor cursor = db.rawQuery("SELECT * FROM tbl_visit_attribute WHERE visit_uuid=?",
new String[]{uuid});

if (cursor.getCount() != 0) {
while (cursor.moveToNext()) {
isExists = true;
}
}
cursor.close();
db.setTransactionSuccessful();
db.endTransaction();

return isExists;
}
}

0 comments on commit 399e064

Please sign in to comment.