Skip to content

Commit

Permalink
add API to get Audiogram based on clinic, patient, and image
Browse files Browse the repository at this point in the history
  • Loading branch information
slogan621 committed Apr 13, 2020
1 parent 53cfae1 commit 0c09093
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ public void onResponse(JSONObject response) {
}
}

private class GetAudiogramArraySingleResponseListener implements Response.Listener<JSONArray> {

@Override
public void onResponse(JSONArray response) {
synchronized (m_lock) {
if (response.length() != 1) {
setStatus(500);
onFail(500, "Request for single audiogram returned multiple items");
} else {
setStatus(200);
CommonSessionSingleton sess = CommonSessionSingleton.getInstance();
try {
sess.setPatientAudiogram(response.getJSONObject(0));
} catch (Exception e) {
}
onSuccess(200, "", response);
}
m_lock.notify();
}
}
}

private class GetAudiogramArrayResponseListener implements Response.Listener<JSONArray> {

@Override
Expand Down Expand Up @@ -159,6 +181,24 @@ public Object getAudiogram(int clinicId, int patientId) {
return m_lock;
}

public Object getAudiogram(int clinicId, int patientId, int imageId) {

VolleySingleton volley = VolleySingleton.getInstance();

volley.initQueueIf(getContext());

RequestQueue queue = volley.getQueue();

String url = String.format("%s://%s:%s/tscharts/v1/audiogram/?patient=%d&clinic=%d&image=%d", getProtocol(), getIP(), getPort(), patientId, clinicId, imageId);

AudiogramREST.AuthJSONArrayRequest request = new AuthJSONArrayRequest(url, null, new GetAudiogramArraySingleResponseListener(), new ErrorListener());
request.setRetryPolicy(new DefaultRetryPolicy(getTimeoutInMillis(), getRetries(), DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));

queue.add((JsonArrayRequest) request);

return m_lock;
}

public Object getAudiogram(int id) {

VolleySingleton volley = VolleySingleton.getInstance();
Expand Down

0 comments on commit 0c09093

Please sign in to comment.