List of usage examples for com.google.gwt.http.client RequestBuilder sendRequest
public Request sendRequest(String requestData, RequestCallback callback) throws RequestException
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
public void deleteAddress() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientModule.DeleteAddresses", params))); try {//ww w . j a v a2s . c o m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAddresses.java
License:Open Source License
public void deleteAddress(Address a) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { a.getAddressId().toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientModule.DeleteAddressById", params))); try {/*from w w w . j a v a 2s . c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
public void commitChanges() { // Form map/*ww w .j a v a 2 s .c om*/ // HashMap<String, String>[] map; Iterator<Integer> iter = authorizations.keySet().iterator(); while (iter.hasNext()) { HashMap<String, String> mmp = authorizations.get(iter.next()).getMap(); mmp.put("authpatient", patientId.toString()); String url = "org.freemedsoftware.module.Authorizations.Add"; if (mmp.get("id") != null) url = "org.freemedsoftware.module.Authorizations.Mod"; if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("PatientAuthorization", _("Updated patient authorizations.")); if (onCompletion != null) { onCompletion.execute(); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(mmp) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(url, params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); Util.showErrorMsg("PatientAuthorization", _("Failed to update patient authorizations.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { Util.showInfoMsg("PatientAuthorization", _("Updated patient authorizations.")); if (onCompletion != null) { onCompletion.execute(); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("PatientAuthorization", _("Failed to update patient authorizations.")); } } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
private void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: Stubbed stuff } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.Authorizations.GetAllAuthorizations", params))); try {//from w w w .j ava 2 s.co m builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { for (int iter = 0; iter < result.length; iter++) { // Create new Authorization object Authorization x = new Authorization(); /* * x.setAuthorizationId(Integer.parseInt(result * [iter].get("id"))); * x.setStartingDate(result * [iter].get("authdtbegin")); * x.setEndingDate * (result[iter].get("authdtend")); * x.setAuthorizationNumber * (result[iter].get("authnum")); * x.setAuthorizationType * (result[iter].get("authtype")); * if(result[iter].get("authprov")!=null) * x.setAuthorizingProvider * (Integer.parseInt( * result[iter].get("authprov"))); * x.setProviderIdentifier * (result[iter].get("authprovid")); * if(result[iter].get("authinsco")!=null) * x.setAuthorizingInsuranceCompany(Integer. * parseInt(result[iter].get("authinsco"))); * x.setNumberofVisits(result[iter].get( * "authvisits")); * x.setUsedVisits(result[iter * ].get("authvisitsused")); * x.setComment(result * [iter].get("authcomment")); */ x.loadData(result[iter]); // builder addAuthorization(new Integer(iter + 1), x); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
public void deleteAuthorization(Integer cid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { cid.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Authorizations.del", params))); try {//from ww w. ja v a2 s. com builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
public void commitChanges() { // Form map/*from w ww . j a v a 2 s . c o m*/ // HashMap<String, String>[] map; Iterator<Integer> iter = coverages.keySet().iterator(); while (iter.hasNext()) { HashMap<String, String> mmp = coverages.get(iter.next()).getMap(); Iterator<String> innerItr = mmp.keySet().iterator(); while (innerItr.hasNext()) { String key = innerItr.next(); if (mmp.get(key) == null) mmp.remove(key); } mmp.put("covpatient", patientId.toString()); String url = "org.freemedsoftware.module.PatientCoverages.Add"; if (mmp.get("id") != null) url = "org.freemedsoftware.module.PatientCoverages.Mod"; if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("PatientCoverages", "Updated patient Coverages."); if (onCompletion != null) { onCompletion.execute(); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(mmp) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(url, params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); Util.showErrorMsg("PatientCoverages", _("Failed to update patient coverages.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { Boolean result = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (result != null) { Util.showInfoMsg("PatientCoverages", _("Updated patient coverages.")); if (onCompletion != null) { onCompletion.execute(); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("PatientCoverages", _("Failed to update patient coverages.")); } } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
private void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: Stubbed stuff } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.module.PatientCoverages.GetAllCoverages", params))); try {//from w w w .j a va 2 s . c o m builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { GWT.log("Exception", ex); } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { for (int iter = 0; iter < result.length; iter++) { // Create new Coverage object Coverage x = new Coverage(); x.loadData(result[iter]); // builder addCoverage(new Integer(iter + 1), x); } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); } } }
From source file:org.freemedsoftware.gwt.client.widget.PatientCoverages.java
License:Open Source License
public void deleteCoverage(Integer cid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO stubbed mode goes here } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { cid.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.PatientCoverages.del", params))); try {/*from w w w . j a va 2 s .c om*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { } } }); } catch (RequestException e) { Window.alert(e.getMessage()); } } else { // TODO normal mode code goes here } }
From source file:org.freemedsoftware.gwt.client.widget.PatientProblemList.java
License:Open Source License
public void deleteItem(Integer item, HashMap<String, String> data) { final String module = data.get("module"); final Integer internalId = Integer.parseInt(data.get("oid")); if (Util.getProgramMode() == ProgramMode.STUBBED) { } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { module, JsonUtil.jsonify(internalId) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.ModuleInterface.ModuleDeleteMethod", params))); try {// w w w . jav a2 s .c om builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { JsonUtil.debug(ex.toString()); CurrentState.getToaster().addItem(module, _("Unable to remove entry."), Toaster.TOASTER_ERROR); } public void onResponseReceived(Request request, Response response) { JsonUtil.debug("onResponseReceived"); if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { JsonUtil.debug(response.getText()); Boolean r = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (r) { loadData(); CurrentState.getToaster().addItem(module, _("Removed item."), Toaster.TOASTER_INFO); } else { CurrentState.getToaster().addItem(module, _("Unable to remove entry."), Toaster.TOASTER_ERROR); } } else { JsonUtil.debug(response.toString()); CurrentState.getToaster().addItem(module, _("Unable to remove entry."), Toaster.TOASTER_ERROR); } } } }); } catch (RequestException e) { JsonUtil.debug(e.toString()); CurrentState.getToaster().addItem(module, _("Unable to remove entry."), Toaster.TOASTER_ERROR); } } else { ModuleInterfaceAsync service = null; try { service = (ModuleInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.ModuleInterface"); } catch (Exception e) { GWT.log("Failed to get proxy for ModuleInterface", e); } service.ModuleDeleteMethod(module, internalId, new AsyncCallback<Integer>() { @Override public void onFailure(Throwable caught) { JsonUtil.debug(caught.toString()); CurrentState.getToaster().addItem(module, _("Unable to remove entry."), Toaster.TOASTER_ERROR); } @Override public void onSuccess(Integer result) { loadData(); CurrentState.getToaster().addItem(module, _("Removed item."), Toaster.TOASTER_INFO); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.PatientProblemList.java
License:Open Source License
@SuppressWarnings("unchecked") public void loadData() { // Clear mappings during populate selected.clear();//from w w w .j a v a2s. c o m actionBarMap.clear(); if (patientId.intValue() == 0) { JsonUtil.debug("ERROR: patientId not defined when loadData called for PatientProblemList"); } if (Util.getProgramMode() == ProgramMode.STUBBED) { List<HashMap<String, String>> a = new ArrayList<HashMap<String, String>>(); { HashMap<String, String> item = new HashMap<String, String>(); item.put("stamp", "2008-01-01"); item.put("type", "test"); item.put("summary", "Test item 1"); item.put("module", "ProgressNotes"); a.add(item); } { HashMap<String, String> item = new HashMap<String, String>(); item.put("stamp", "2008-01-02"); item.put("type", "test"); item.put("summary", "Test item 2"); item.put("module", "ProgressNotes"); a.add(item); } { HashMap<String, String> item = new HashMap<String, String>(); item.put("stamp", "2008-01-02"); item.put("type", "test"); item.put("summary", "Test item 3"); item.put("module", "Letters"); a.add(item); } { HashMap<String, String> item = new HashMap<String, String>(); item.put("stamp", "2008-01-03"); item.put("type", "test"); item.put("summary", "Test item 4"); item.put("module", "Letters"); a.add(item); } dataStore = (HashMap<String, String>[]) a.toArray(new HashMap<?, ?>[0]); populateData(dataStore); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util .getJsonRequest("org.freemedsoftware.api.PatientInterface.EmrAttachmentsByPatient", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Window.alert(ex.toString()); } public void onResponseReceived(Request request, Response response) { JsonUtil.debug("onResponseReceived"); if (Util.checkValidSessionResponse(response.getText())) { if (200 == response.getStatusCode()) { JsonUtil.debug(response.getText()); HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (r != null) { JsonUtil.debug( "PatientProblemList... r.length = " + new Integer(r.length).toString()); dataStore = r; populateData(dataStore); } } else { Window.alert(response.toString()); } } } }); } catch (RequestException e) { Window.alert(e.toString()); } } else { PatientInterfaceAsync service = null; try { service = (PatientInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.PatientInterface"); } catch (Exception e) { GWT.log("Failed to get proxy for PatientInterface", e); } service.EmrAttachmentsByPatient(patientId, new AsyncCallback<HashMap<String, String>[]>() { public void onSuccess(HashMap<String, String>[] r) { dataStore = r; populateData(dataStore); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } }