List of usage examples for com.google.gwt.http.client URL encode
public static String encode(String decodedURL)
From source file:org.freemedsoftware.gwt.client.widget.PatientAuthorizations.java
License:Open Source License
public void commitChanges() { // Form map/* w ww . 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 {// w w w . j av a2s . 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 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 w w w .j ava2 s . 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.PatientCoverages.java
License:Open Source License
public void commitChanges() { // Form map// w ww. ja 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 ww . j a v a 2 s . com 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 {// ww w . ja 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.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 {/*from w w w.j a v a 2 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 ww .jav a2 s .c om 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); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.PatientTagsWidget.java
License:Open Source License
/** * Update database to set new tag./*from w ww. j a v a2s . c om*/ * * @param tag */ public void addTag(final String tag) { if (Util.getProgramMode() == ProgramMode.STUBBED) { wEntry.clear(); addTagToDisplay(tag); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(patientId), tag }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest("org.freemedsoftware.module.PatientTag.CreateTag", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showInfoMsg("PatientTags", _("Failed to add tags.")); } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Boolean r = (Boolean) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (r != null) { wEntry.clear(); addTagToDisplay(tag); Util.showInfoMsg("PatientTags", _("Tag added.")); } } else { Util.showErrorMsg("PatientTags", _("Failed to add tags.")); } } }); } catch (RequestException e) { Util.showErrorMsg("PatientTags", _("Failed to add tags.")); } } else { getProxy().CreateTag(patientId, tag, new AsyncCallback<Boolean>() { public void onSuccess(Boolean o) { wEntry.clear(); addTagToDisplay(tag); Util.showInfoMsg("PatientTags", _("Tag added.")); } public void onFailure(Throwable t) { GWT.log("Exception", t); Util.showErrorMsg("PatientTags", _("Failed to add tags.")); } }); } }
From source file:org.freemedsoftware.gwt.client.widget.PatientTagsWidget.java
License:Open Source License
/** * Actual addition of tag to display./* w w w . jav a 2 s.c o m*/ * * @param tag */ protected void addTagToDisplay(String tag) { JsonUtil.debug("addTagToDisplay(" + tag + ")"); HorizontalPanel p = new HorizontalPanel(); p.setTitle(tag); final String oldTagName = tag.trim(); final HTML r = new HTML("<sup>X</sup>"); final Anchor tagLabel = new Anchor(tag); tagLabel.setStylePrimaryName("freemed-PatientTag"); JsonUtil.debug("addclicklistener"); tagLabel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent evt) { final Widget w = (Widget) evt.getSource(); final PopupPanel p = new PopupPanel(true); final FlexTable fT = new FlexTable(); fT.setWidget(0, 0, new HTML("<b>" + oldTagName + "</b>")); fT.setWidget(1, 0, new Label(_("Rename Tag"))); final TextBox newTagName = new TextBox(); fT.setWidget(2, 0, newTagName); final CustomButton changeTagButton = new CustomButton(_("Change"), AppConstants.ICON_MODIFY); fT.setWidget(2, 1, changeTagButton); changeTagButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent bEvt) { if (newTagName.getText().trim().length() > 0) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // Stubbed mode p.hide(); p.removeFromParent(); ((HorizontalPanel) w.getParent()).removeFromParent(); addTagToDisplay(newTagName.getText().trim()); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { oldTagName, newTagName.getText().trim() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.module.PatientTag.ChangeTag", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { } public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { Boolean r = (Boolean) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "Boolean"); if (r != null) { p.hide(); p.removeFromParent(); ((HorizontalPanel) w.getParent()).removeFromParent(); addTagToDisplay(newTagName.getText().trim()); } } else { } } }); } catch (RequestException e) { } } else { getProxy().ChangeTag(oldTagName, newTagName.getText().trim(), new AsyncCallback<Boolean>() { public void onSuccess(Boolean o) { p.hide(); p.removeFromParent(); ((HorizontalPanel) w.getParent()).removeFromParent(); addTagToDisplay(newTagName.getText().trim()); } public void onFailure(Throwable t) { GWT.log("Exception", t); } }); } } } }); final CustomButton searchButton = new CustomButton(_("Search"), AppConstants.ICON_SEARCH); fT.setWidget(2, 2, searchButton); searchButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent evt) { PatientTagSearchScreen searchScreen = new PatientTagSearchScreen(); searchScreen.setTagValue(oldTagName); Util.spawnTab(_("Tag Search"), searchScreen); p.hide(); } }); p.add(fT); p.setPopupPosition(tagLabel.getAbsoluteLeft() + 5, tagLabel.getAbsoluteTop() - 10); p.setStyleName("freemed-PatientTagPopup"); p.show(); } }); p.add(tagLabel); p.add(r); p.setStyleName("freemed-PatientTag"); r.addStyleName("freemed-PatientTagRemove"); r.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent evt) { if (Window.confirm("Are you sure you want to remove this tag?")) { HorizontalPanel container = (HorizontalPanel) ((Widget) evt.getSource()).getParent(); removeTag(container.getTitle(), container); } } }); flowPanel.add(p); }