Example usage for com.google.gwt.http.client RequestBuilder POST

List of usage examples for com.google.gwt.http.client RequestBuilder POST

Introduction

In this page you can find the example usage for com.google.gwt.http.client RequestBuilder POST.

Prototype

Method POST

To view the source code for com.google.gwt.http.client RequestBuilder POST.

Click Source Link

Document

Specifies that the HTTP POST method should be used.

Usage

From source file:org.freemedsoftware.gwt.client.screen.ModuleFieldCheckerTypeEntryScreen.java

License:Open Source License

public void saveFormData(final String moduleName, HashMap<String, String> data, boolean isModify) {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: STUBBED
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // JSON-RPC
        String moduleURL = "org.freemedsoftware.module." + moduleName + (isModify ? ".Mod" : ".Add");
        String[] params = { JsonUtil.jsonify(data) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest(moduleURL, params)));
        try {//from ww  w.j a  v a  2s  .  com
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        Integer r = (Integer) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()),
                                "Integer");
                        if (r != null) {
                            populateAvailableData();
                            Util.showInfoMsg(moduleName, _("Entry successfully added."));
                        } else {
                            Boolean b = (Boolean) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean");
                            if (b != null)
                                Util.showInfoMsg(moduleName, _("Entry successfully modified."));
                        }
                    } else {
                        Util.showErrorMsg(moduleName, _("Failed to save data!"));
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        // GWT-RPC
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.AllergyEntryScreen.java

License:Open Source License

public void saveForm() {
    data.put("patient", patientScreen.getPatient().toString());

    data.put("allergy", allergyTextBox.getText());
    data.put("reaction", reactionTextBox.getText());
    data.put("severity", severityTextBox.getText());

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        Util.showInfoMsg(className, _("Allergy added."));
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(data) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Allergies.add", params)));
        try {/* w w w.jav  a2s  .  c o  m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg(className, _("Failed to add allergy."));
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        Integer r = (Integer) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()),
                                "Integer");
                        if (r != null) {
                            Util.showInfoMsg(className, _("Allergy added."));
                            patientScreen.getSummaryScreen().populateClinicalInformation();
                        }
                    } else {
                        Util.showErrorMsg(className, _("Failed to add allergy."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg(className, _("Failed to add allergy."));
        }
    } else {
        // TODO: GWT-RPC Stuff
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.AllergyEntryScreen.java

License:Open Source License

public void populate() {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(patientId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Allergies.GetMostRecent", params)));
        try {/*  w ww  .  j  a  v  a2 s . com*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        @SuppressWarnings("unchecked")
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            allergyTextBox.setText(r[0].get("allergy"));
                            reactionTextBox.setText(r[0].get("reaction"));
                            severityTextBox.setText(r[0].get("severity"));
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.ClinicalOrdersEntry.java

License:Open Source License

public void save() {
    HashMap<String, String> data = new HashMap<String, String>();
    data.put("patient", Integer.toString(patientId));

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: STUBBED
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        // JSON-RPC
        String[] params = { JsonUtil.jsonify(data) };

        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.ClinicalOrders.add", params)));
        try {/* w ww.j  a  v  a 2 s.  c o  m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add order."));
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode()) {
                        if (response.getText().compareToIgnoreCase("false") != 0) {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) { // Successful
                                Util.showInfoMsg("ClinicalOrdersEntry", _("Successfully added order."));
                            }
                        } else {
                            JsonUtil.debug("Received dummy response from JSON backend");
                        }
                    } else {
                        Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add orders."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("ClinicalOrdersEntry", _("Failed to add orders."));
        }

    } else {
        // GWT-RPC
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void loadEncountersList() {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {

        String[] params = { patientId.toString() };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.getEncountersList", params)));

        try {/*from ww w . jav a 2 s  . c om*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                            if (r != null) {
                                enotesCustomTable.loadData(r);
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void laodEncounterNoteInfo(String id) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { id };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.getEncounterNoteInfo", params)));

        try {/*from  www.  j  ava2s  .  c  o m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) {
                                moddata = r;
                                if (r.get("pnotestemplate") == null || r.get("pnotestemplate").equals("")
                                        || r.get("pnotestemplate").equals("0")) {

                                    entryVerticalPanel.clear();
                                    createEncounterNotesAdditionTab();

                                } else {
                                    getTemplateValues(moddata.get("pnotestemplate"));
                                }
                            } else {
                            }
                        } catch (Exception e) {
                        }

                    } else {
                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void getTemplateValues(String templateId) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { templateId };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util
                .getJsonRequest("org.freemedsoftware.module.EncounterNotesTemplate.getTemplateInfo", params)));

        try {/*w  ww .j a v a  2  s.  c  om*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (r != null) {
                                String secStr = r.get("pnotestsections");
                                sections = (HashMap<String, List<String>>) JsonUtil
                                        .shoehornJson(JSONParser.parseStrict(secStr), "HashMap<String,List>");
                                entryVerticalPanel.clear();
                                createEncounterNotesAdditionTab();
                            } else {

                            }
                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.EncounterScreen.java

License:Open Source License

public void deleteNote(String id) {
    if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { id };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.EncounterNotes.del", params)));

        try {/*from   w  w w  .  j  a va2  s .c o  m*/
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                public void onResponseReceived(Request request, Response response) {

                    if (200 == response.getStatusCode()) {
                        try {
                            Boolean r = (Boolean) JsonUtil
                                    .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean");
                            if (r) {
                                Util.showInfoMsg("EncounterNotes", _("Encounter Note successfully deleted."));
                                loadEncountersList();
                            }

                        } catch (Exception e) {

                        }

                    } else {

                    }
                }
            });
        } catch (RequestException e) {
        }
    }
}

From source file:org.freemedsoftware.gwt.client.screen.patient.GrowthChartScreen.java

License:Open Source License

public void populateStockData(boolean height, final GrowthChart chart) {
    Boolean infant = false;/* w  w w  .jav a  2s .com*/
    if (getMonthsAge(birthDate) < 36) {
        infant = true;
    } else {
        infant = false;
    }

    if (Util.getProgramMode() == ProgramMode.STUBBED) {
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { gender, JsonUtil.jsonify(height), JsonUtil.jsonify(infant) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(
                Util.getJsonRequest("org.freemedsoftware.module.GrowthCharts.GetGrowthChartValues", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                    Util.showErrorMsg("GrowthCharts", "Failed to retrieve stock growth chart data.");
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (200 == response.getStatusCode() || response.getText() == "false") {
                        HashMap<String, String>[] r = (HashMap<String, String>[]) JsonUtil.shoehornJson(
                                JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]");
                        if (r != null) {
                            chart.setStockData(r);
                            chart.drawStockCurves();
                        }
                    } else {
                        Util.showErrorMsg("GrowthCharts", _("Failed to retrieve stock growth chart data."));
                    }
                }
            });
        } catch (RequestException e) {
            Util.showErrorMsg("GrowthCharts", _("Failed to retrieve stock growth chart data."));
        }
    } else {
        JsonUtil.debug("Unimplemented GrowthCharts RPC");
    }

}

From source file:org.freemedsoftware.gwt.client.screen.patient.PatientReportingScreen.java

License:Open Source License

public void populate() {
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO: handle stubbed
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { locale };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL
                .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientReporting.GetReports", params)));
        try {/*from ww w  . j av  a  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) {
                            reportTable.loadData(result);
                        } else {
                        }
                    } else {
                    }
                }
            });
        } catch (RequestException e) {
            GWT.log("Exception", e);
        }
    } else {
        // TODO: Not done yet
    }
}