Skip to content

Commit

Permalink
Wrong device type may occur in CareLink, try to extract actual device…
Browse files Browse the repository at this point in the history
… type from data uploads for patient accounts.
  • Loading branch information
benceszasz committed May 26, 2023
1 parent ca91200 commit 7c2655f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.ActiveNotification;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.ClearedNotification;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.CountrySettings;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.DataUpload;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.Marker;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.MonitorData;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.Profile;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.Patient;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.M2MEnabled;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.RecentData;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.RecentUploads;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.SensorGlucose;
import com.eveningoutpost.dexdrip.cgm.carelinkfollow.message.User;
import com.eveningoutpost.dexdrip.models.JoH;
Expand Down Expand Up @@ -109,7 +111,14 @@ public Profile getSessionProfile() {
public CountrySettings getSessionCountrySettings() {
return sessionCountrySettings;
}

protected RecentUploads sessionRecentUploads;
public RecentUploads getSessionRecentUploads() {
return sessionRecentUploads;
}
protected Boolean sessionDeviceIsBle;
public Boolean getSessionDeviceIsBle() {
return sessionDeviceIsBle;
}
protected Boolean sessionM2MEnabled;
public boolean getSessionM2MEnabled(){
return sessionM2MEnabled;
Expand Down Expand Up @@ -171,7 +180,7 @@ public RecentData getRecentData(String patientUsername) {
return null;

// 7xxG
if (this.sessionMonitorData.isBle())
if (this.isBleDevice(patientUsername))
return this.getConnectDisplayMessage(this.sessionProfile.username, this.sessionUser.getUserRole(), patientUsername,
sessionCountrySettings.blePereodicDataEndpoint);
// Guardian + multi
Expand Down Expand Up @@ -203,6 +212,58 @@ else if (this.sessionProfile.username != null)
return null;
}

public boolean isBleDevice(String patientUsername){

Boolean recentUploadBle;

// Session device already determined
if(sessionDeviceIsBle != null)
return sessionDeviceIsBle;

// Force login to get basic info
if(getAuthorizationToken() == null)
return false;

// Patient: device from recent uploads if possible
if(!this.sessionUser.isCarePartner()){
recentUploadBle = this.isRecentUploadBle();
if(recentUploadBle != null){
this.sessionDeviceIsBle = recentUploadBle;
return sessionDeviceIsBle;
}
}

// Care partner (+M2M): device from patient list
if(this.sessionM2MEnabled && this.sessionUser.isCarePartner())
if(patientUsername == null || this.sessionPatients == null)
return false;
else {
for (int i = 0; i < this.sessionPatients.length; i++) {
if (sessionPatients[i].username.equals(patientUsername))
return sessionPatients[i].isBle();
}
return false;
}
// Other: classic method (session monitor data)
else
return this.sessionMonitorData.isBle();

}

public Boolean isRecentUploadBle(){

if(this.sessionRecentUploads == null)
return null;

for(DataUpload upload : this.sessionRecentUploads.recentUploads){
if(upload.device.toUpperCase().contains("MINIMED"))
return true;
else if(upload.device.toUpperCase().contains("GUARDIAN"))
return false;
}
return null;
}

//Authentication methods
protected boolean executeLoginProcedure() {

Expand Down Expand Up @@ -247,6 +308,9 @@ protected boolean executeLoginProcedure() {
this.sessionProfile = this.getMyProfile();
// Country settings
this.sessionCountrySettings = this.getMyCountrySettings();
// Recent uploads (only for patients)
if(!this.sessionUser.isCarePartner())
this.sessionRecentUploads = this.getRecentUploads(30);
// Multi follow enabled on server
this.sessionM2MEnabled = this.getM2MEnabled().value;
// Multi follow + Care Partner => patients
Expand Down Expand Up @@ -428,6 +492,17 @@ public Profile getMyProfile() {
return this.getData(this.careLinkServer(), "patient/users/me/profile", null, null, Profile.class);
}

// Recent uploads
public RecentUploads getRecentUploads(int numOfUploads) {

Map<String, String> queryParams = null;

queryParams = new HashMap<String, String>();
queryParams.put("numUploads", String.valueOf(numOfUploads));

return this.getData(this.careLinkServer(), "patient/dataUpload/recentUploads", queryParams, null, RecentUploads.class);
}

// Monitoring data
public MonitorData getMonitorData() {
return this.getData(this.careLinkServer(), "patient/monitor/data", null, null, MonitorData.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class DataUpload {

public long date;
public boolean mobileUploaded;
public String status;
public String device;
public String serialNumber;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eveningoutpost.dexdrip.cgm.carelinkfollow.message;

import java.util.List;

public class RecentUploads {

public List<DataUpload> recentUploads;

}

0 comments on commit 7c2655f

Please sign in to comment.