Skip to content

Commit

Permalink
Merge pull request #832 from Intelehealth/nas_dev_sprint28_kaveri
Browse files Browse the repository at this point in the history
Nas dev sprint28 kaveri
  • Loading branch information
mithunvaghela committed Jun 12, 2024
2 parents 1927737 + bcf9c68 commit 98455b9
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.intelehealth.app.utilities.UuidDictionary.ENCOUNTER_ROLE;
import static org.intelehealth.app.utilities.UuidDictionary.ENCOUNTER_VISIT_NOTE;
import static org.intelehealth.app.utilities.UuidDictionary.FOLLOW_UP_VISIT;
import static org.intelehealth.app.utilities.UuidDictionary.VISIT_SPECIALITY;

import android.app.DatePickerDialog;
import android.app.Dialog;
Expand Down Expand Up @@ -384,7 +385,7 @@ public class VisitSummaryActivity extends AppCompatActivity /*implements Printer
private PrinterInterface curPrinterInterface = null;
IntelehealthApplication application;*/

private void collectChatConnectionInfoFromFirebase() {
private void collectChatConnectionInfoFromFirebase() {
FirebaseDatabase database = FirebaseDatabase.getInstance(AppConstants.getFirebaseRTDBUrl());
DatabaseReference chatDatabaseReference = database.getReference(AppConstants.getFirebaseRTDBRootRefForTextChatConnInfo() + "/" + visitUuid);
chatDatabaseReference.addValueEventListener(new ValueEventListener() {
Expand Down Expand Up @@ -469,7 +470,7 @@ public void registerBroadcastReceiverDynamically() {
public void registerDownloadPrescription() {
IntentFilter filter = new IntentFilter();
filter.addAction("downloadprescription");
ContextCompat.registerReceiver(this,downloadPrescriptionService, filter,ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(this, downloadPrescriptionService, filter, ContextCompat.RECEIVER_NOT_EXPORTED);
}


Expand Down Expand Up @@ -931,7 +932,7 @@ public void onClick(DialogInterface dialog, int which) {
List<String> items = providerAttributeLIstDAO.getAllValues();
items.remove("All");
Log.d("specc", "spec: " + visitUuid);
String special_value = visitAttributeListDAO.getVisitAttributesList_specificVisit(visitUuid);
String special_value = visitAttributeListDAO.getVisitAttributesList_specificVisit(visitUuid, VISIT_SPECIALITY);
//Hashmap to List<String> add all value
ArrayAdapter<String> stringArrayAdapter;

Expand All @@ -945,6 +946,7 @@ public void onClick(DialogInterface dialog, int which) {
speciality_spinner.setAdapter(stringArrayAdapter);
}

Log.d(TAG, "onCreate: special_value : " + special_value);
if (special_value != null) {
int spinner_position = stringArrayAdapter.getPosition(special_value);
speciality_spinner.setSelection(spinner_position);
Expand Down Expand Up @@ -1098,7 +1100,16 @@ public void onClick(View view) {
e.printStackTrace();
Log.d("Update_Special_Visit", "Update_Special_Visit: " + isUpdateVisitDone);
}

String uploadTime = AppConstants.dateAndTimeUtils.getVisitUploadDateTime();
VisitAttributeListDAO upload_time_attributes = new VisitAttributeListDAO();
boolean isUpdateUploadTimeDone = false;
try {
if (!isVisitSpecialityExists) {
isUpdateUploadTimeDone = upload_time_attributes.insertVisitAttributesUploadTime(visitUUID, uploadTime);
}
} catch (DAOException exception) {
exception.printStackTrace();
}

if (isVisitSpecialityExists) {
speciality_spinner.setEnabled(false);
Expand Down Expand Up @@ -2008,9 +2019,8 @@ public void onClick(View v) {
String remark = fuData.substring(fuData.indexOf(","));
showFollowupRescheduleDialog(remark);
Log.d(TAG, "reschedule btn: " + remark);
}
else { // ie. 08-08-2023
// followupDate = fuData;
} else { // ie. 08-08-2023
// followupDate = fuData;
showFollowupRescheduleDialog(null);
}
Log.d(TAG, "reschedule btn: " + followupDate);
Expand Down Expand Up @@ -2086,18 +2096,15 @@ else if (et_date.getText().toString().trim().isEmpty() && !et_reason.getText().t
else if (!et_date.getText().toString().trim().isEmpty() && et_reason.getText().toString().trim().isEmpty()) {
et_reason.requestFocus();
et_reason.setError(context.getString(R.string.error_field_required));
}


else { // ie. date is not empty ie. user has selected the date from the date picker.
} else { // ie. date is not empty ie. user has selected the date from the date picker.
et_date.setError(null);
et_reason.setError(null);

String followupValue = et_date.getText().toString().trim();
String reasonValue = et_reason.getText().toString().trim();

if (remark != null)
followupValue = followupValue + remark; // ie. 08-08-2023, Remark: abc
followupValue = followupValue + remark; // ie. 08-08-2023, Remark: abc

Log.d(TAG, "showFollowupRescheduleDialog: " + followupValue);
try {
Expand Down Expand Up @@ -2171,8 +2178,7 @@ private void update_insertIntoDb_PushFollowupValues(String followupValue, String
encounterTIME_MINUS_ONE_MINUTE = formatDateFromOnetoAnother
(visitendDate, "MMM dd, yyyy hh:mm:ss a", "yyyy-MM-dd'T'HH:mm:ss.SSSZ");
encounterTIME_MINUS_ONE_MINUTE = minus_MinutesAgo(encounterTIME_MINUS_ONE_MINUTE, 1); // ie. minus 1mins.
}
else {
} else {
encounterTIME_MINUS_ONE_MINUTE = AppConstants.dateAndTimeUtils.currentDateTime();
}

Expand Down Expand Up @@ -2325,6 +2331,7 @@ private boolean speciality_row_exist_check(String uuid) {

/**
* starting chat activity here
*
* @param view
*/
public void startTextChat(View view) {
Expand Down Expand Up @@ -4194,8 +4201,7 @@ private void parseData(String concept_id, String value) {
String fuData = followUpDateTextView.getText().toString().trim();
if (!fuData.isEmpty() && (fuData.contains(",") || !fuData.contains("Remark"))) { // ie. date is present and this can we changed too.
followupRescheduleBtn.setVisibility(View.VISIBLE);
}
else
} else
followupRescheduleBtn.setVisibility(View.GONE);

}
Expand Down Expand Up @@ -4297,7 +4303,7 @@ public void callBroadcastReceiver() {
if (!isReceiverRegistered) {
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
receiver = new NetworkChangeReceiver();
ContextCompat.registerReceiver(this,receiver, filter,ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(this, receiver, filter, ContextCompat.RECEIVER_NOT_EXPORTED);
isReceiverRegistered = true;
}
}
Expand Down Expand Up @@ -4788,7 +4794,7 @@ public void downloadPrescriptionDefault() {
protected void onStart() {
registerDownloadPrescription();
callBroadcastReceiver();
ContextCompat.registerReceiver(this,(mMessageReceiver), new IntentFilter(FILTER),ContextCompat.RECEIVER_NOT_EXPORTED);
ContextCompat.registerReceiver(this, (mMessageReceiver), new IntentFilter(FILTER), ContextCompat.RECEIVER_NOT_EXPORTED);
super.onStart();
}

Expand Down Expand Up @@ -5069,6 +5075,8 @@ public void onClick(DialogInterface dialogInterface, int i) {
CancelRequest request = new CancelRequest();
request.setVisitUuid(mAppointmentDetailsResponse.getData().getVisitUuid());
request.setId(mAppointmentDetailsResponse.getData().getId());
request.setHwUUID(mAppointmentDetailsResponse.getData().getUserUuid());
Log.d(TAG, "onClick: CancelRequest : " + new Gson().toJson(request));
String baseurl = "https://" + sessionManager.getServerUrl() + ":3004";
ApiClientAppointment.getInstance(baseurl).getApi().cancelAppointment(request).enqueue(new Callback<CancelResponse>() {
@Override
Expand All @@ -5092,6 +5100,8 @@ public void onResponse(Call<CancelResponse> call, Response<CancelResponse> respo

@Override
public void onFailure(Call<CancelResponse> call, Throwable t) {
t.printStackTrace();
Log.d(TAG, "onFailure: t :: " + t.getLocalizedMessage());
Log.v("onFailure", t.getMessage());
}
});
Expand Down Expand Up @@ -5335,11 +5345,10 @@ private String sms_prescription() {

if (advice_doctor__.indexOf("Start") != -1 || advice_doctor__.lastIndexOf(("Doctor_") + 9) != -1) {
String advice_split = new StringBuilder(advice_doctor__).delete(advice_doctor__.indexOf("Start"), advice_doctor__.lastIndexOf("Doctor_") + 9).toString();
advice_web = stringToWeb(advice_split.replace("\n\n", "\n")); //showing advice here...
advice_web = stringToWeb(advice_split.replace("\n\n", "\n")); //showing advice here...
advice_web = advice_web.replace(Node.big_bullet, "- ");
Log.d("Hyperlink", "hyper_print: " + advice_web); //gets called when clicked on button of print button
}
else {
} else {
advice_web = stringToWeb(advice_doctor__.replace("\n\n", "\n")); //showing advice here...
advice_web = advice_web.replace(Node.big_bullet, "- ");
Log.d("Hyperlink", "hyper_print: " + advice_web); //gets called when clicked on button of print button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.reactivex.plugins.RxJavaPlugins;
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;

import com.rt.printerlibrary.printer.RTPrinter;

//Extend Application class with MultiDexApplication for multidex support
Expand Down Expand Up @@ -65,9 +66,11 @@ public static String getAndroidId() {
private static IntelehealthApplication sIntelehealthApplication;
public String refreshedFCMTokenID = "";
public String webrtcTempCallId = "";

public static IntelehealthApplication getInstance() {
return sIntelehealthApplication;
}

private final SocketManager socketManager = SocketManager.getInstance();


Expand All @@ -88,7 +91,7 @@ public void onCreate() {
// keeping the base url in one singleton object for using in apprtc module

// Initialize
// EzdxBT.initialize(getApplicationContext());
// EzdxBT.initialize(getApplicationContext());
configureCrashReporting();

RxJavaPlugins.setErrorHandler(throwable -> {
Expand Down Expand Up @@ -122,6 +125,9 @@ public void onCreate() {
}
initSocketConnection();
registerActivityLifecycleCallbacks(this);
if (BuildConfig.DEBUG) {
Timber.plant(Timber.DebugTree());
}
}

private void configureCrashReporting() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@
import java.io.Serializable;

public class CancelRequest implements Serializable {
public int getId() {
return id;
}

public String getHwUUID() {
return hwUUID;
}

public void setHwUUID(String hwUUID) {
this.hwUUID = hwUUID;
}

@SerializedName("id")
private int id;

@SerializedName("visitUuid")
private String visitUuid;

@SerializedName("hwUUID")
private String hwUUID;


public String getVisitUuid() {
return visitUuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.intelehealth.app.app.AppConstants;
import org.intelehealth.app.models.dto.VisitAttributeDTO;
import org.intelehealth.app.utilities.UuidDictionary;
import org.intelehealth.app.utilities.exception.DAOException;

/**
Expand Down Expand Up @@ -81,15 +82,17 @@ private boolean createVisitAttributeList(VisitAttributeDTO visitDTO, SQLiteDatab
return isCreated;
}

public String getVisitAttributesList_specificVisit(String VISITUUID) {
public String getVisitAttributesList_specificVisit(String VISITUUID, String visit_attribute_type_uuid) {
String isValue = "";
Log.d("specc", "spec_fun: " + VISITUUID);
SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWritableDatabase();
db.beginTransaction();

Cursor cursor = db.rawQuery("SELECT value FROM tbl_visit_attribute WHERE visit_uuid = ?",
new String[]{VISITUUID});

/* Cursor cursor = db.rawQuery("SELECT value FROM tbl_visit_attribute WHERE visit_uuid = ?",
new String[]{VISITUUID});*/
Cursor cursor = db.rawQuery("SELECT value FROM tbl_visit_attribute WHERE visit_uuid = ? and " +
"visit_attribute_type_uuid = ? and voided = 0",
new String[]{VISITUUID, visit_attribute_type_uuid});
if (cursor.getCount() != 0) {
while (cursor.moveToNext()) {
isValue = cursor.getString(cursor.getColumnIndexOrThrow("value"));
Expand Down Expand Up @@ -158,4 +161,35 @@ public String getVisitID(String visitUUID) {
db.endTransaction();
return visit_id;
}

public boolean insertVisitAttributesUploadTime(String visitUuid, String uploadTime) throws DAOException {
boolean isInserted = false;

SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb();
db.beginTransaction();
ContentValues values = new ContentValues();
try {
values.put("uuid", UUID.randomUUID().toString()); //as per patient attributes uuid generation.
values.put("visit_uuid", visitUuid);
values.put("value", uploadTime);
values.put("visit_attribute_type_uuid", UuidDictionary.ATTRIBUTE_TIME_OF_UPLOAD_BUTTON_CLICK);
values.put("voided", "0");
values.put("sync", "0");

long count = db.insertWithOnConflict("tbl_visit_attribute", null, values, SQLiteDatabase.CONFLICT_REPLACE);
if (count != -1) {
isInserted = true;
}

db.setTransactionSuccessful();
} catch (SQLException e) {
isInserted = false;
throw new DAOException(e.getMessage(), e);
} finally {
db.endTransaction();
}

Log.d("isInserted", "isInserted: " + isInserted);
return isInserted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ public List<VisitDTO> unsyncedVisits() {

private List<VisitAttribute_Speciality> fetchVisitAttr_Speciality(String visit_uuid) {
List<VisitAttribute_Speciality> list = new ArrayList<>();
VisitAttribute_Speciality speciality = new VisitAttribute_Speciality();

SQLiteDatabase db = AppConstants.inteleHealthDatabaseHelper.getWriteDb();
db.beginTransaction();
Expand All @@ -288,7 +287,7 @@ private List<VisitAttribute_Speciality> fetchVisitAttr_Speciality(String visit_u

if (cursor.getCount() != 0) {
while (cursor.moveToNext()) {

VisitAttribute_Speciality speciality = new VisitAttribute_Speciality();
speciality.setUuid(cursor.getString(cursor.getColumnIndexOrThrow("uuid")));
speciality.setAttributeType(cursor.getString(cursor.getColumnIndexOrThrow("visit_attribute_type_uuid")));
speciality.setValue(cursor.getString(cursor.getColumnIndexOrThrow("value")));
Expand Down Expand Up @@ -324,7 +323,7 @@ public List<VisitDTO> getAllVisits() {
idCursor.close();
db.setTransactionSuccessful();
db.endTransaction();
// db.close(); // NAS-172: no need to close db instance this causes the issue of Sqlite object being closed - Prajwal.
// db.close(); // NAS-172: no need to close db instance this causes the issue of Sqlite object being closed - Prajwal.
return visitDTOList;
}

Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/org/intelehealth/app/shared/BaseActivity.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.intelehealth.app.shared;

import static org.intelehealth.app.utilities.NotificationUtils.saveChatInfoLog;

import android.os.Bundle;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -11,6 +14,7 @@
import org.intelehealth.app.database.dao.ProviderDAO;
import org.intelehealth.app.database.dao.RTCConnectionDAO;
import org.intelehealth.app.models.dto.RTCConnectionDTO;
import org.intelehealth.app.utilities.NotificationUtils;
import org.intelehealth.app.utilities.exception.DAOException;
import org.intelehealth.app.webrtc.activity.NASChatActivity;
import org.intelehealth.app.webrtc.notification.AppNotification;
Expand All @@ -36,7 +40,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

@Override
public void showNotification(@NonNull ChatMessage chatMessage) {
RtcArgs args = new RtcArgs();
NotificationUtils.sendChatNotification(this, chatMessage);
/* RtcArgs args = new RtcArgs();
args.setPatientName(chatMessage.getPatientName());
args.setPatientId(chatMessage.getPatientId());
args.setVisitId(chatMessage.getVisitId());
Expand All @@ -53,16 +58,16 @@ public void showNotification(@NonNull ChatMessage chatMessage) {
saveChatInfoLog(args.getVisitId(), args.getDoctorUuid());
} catch (DAOException e) {
throw new RuntimeException(e);
}
}*/
}

private void saveChatInfoLog(String visitId, String doctorId) throws DAOException {
/* private void saveChatInfoLog(String visitId, String doctorId) throws DAOException {
RTCConnectionDTO rtcDto = new RTCConnectionDTO();
rtcDto.setUuid(UUID.randomUUID().toString());
rtcDto.setVisitUUID(visitId);
rtcDto.setConnectionInfo(doctorId);
new RTCConnectionDAO().insert(rtcDto);
}
}*/

@Override
public void saveTheDoctor(@NonNull ChatMessage chatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ public static String minus_MinutesAgo(String timeStamp, int minute) throws Parse

return df.format(new Date(time - FIVE_MINS_IN_MILLIS));
}


public String getVisitUploadDateTime() {
DateFormat date = new SimpleDateFormat("dd MMM yyyy HH:mm:ss", Locale.ENGLISH);
return date.format(new Date());
}
}
Loading

0 comments on commit 98455b9

Please sign in to comment.