List of usage examples for com.google.gwt.http.client RequestBuilder POST
Method POST
To view the source code for com.google.gwt.http.client RequestBuilder POST.
Click Source Link
From source file:org.freemedsoftware.gwt.client.screen.patient.PatientReportingScreen.java
License:Open Source License
/** * Get parameters for a specific report by uuid. * /*from w w w. j a va 2 s .c o m*/ * @param uuid */ public void getReportInformation(String uuid) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: handle stubbed } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { uuid }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util .getJsonRequest("org.freemedsoftware.module.PatientReporting.GetReportParameters", params))); try { 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) { populateReportParameters(result); } } else { } } }); } catch (RequestException e) { GWT.log("Exception", e); } } else { // TODO: Not done yet. } }
From source file:org.freemedsoftware.gwt.client.screen.patient.PrescriptionsScreen.java
License:Open Source License
public void savePrescription() { HashMap<String, String> data = new HashMap<String, String>(); data.put("rxphy", Integer.toString(wProvider.getValue())); data.put("rxpatient", Integer.toString(patientId)); data.put("rxdrug", wDrug.getStoredValue()); // rxform/*from w ww . j a v a 2s. c om*/ // rxdosage // rxquantity data.put("rxquantityqual", Integer.toString(wQuantity.getValue())); // rxsize // rxunit // rxinterval // rxsubstitute // rxrefills // rxrefillinterval // rxperrefill // rxorigrx // rxdx // rxcovstatus // rxsig // rxnote 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.Prescription.add", params))); try { builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("PrescriptionScreen", _("Failed to add prescription.")); } @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("PrescriptionScreen", _("Successfully added prescription.")); } } else { JsonUtil.debug("Received dummy response from JSON backend"); } } else { Util.showErrorMsg("PrescriptionScreen", _("Failed to add prescription")); } } }); } catch (RequestException e) { Util.showErrorMsg("PrescriptionScreen", _("Failed to add prescription")); } } else { // GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.patient.ProgressNoteEntry.java
License:Open Source License
public ProgressNoteEntry() { this.patientIdName = "pnotespat"; final VerticalPanel verticalPanel = new VerticalPanel(); initWidget(verticalPanel);//from w w w .j ava 2 s. c o m final TabPanel tabPanel = new TabPanel(); verticalPanel.add(tabPanel); final HorizontalPanel buttonBar = new HorizontalPanel(); buttonBar.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); final CustomButton wSubmit = new CustomButton(_("Submit"), AppConstants.ICON_ADD); buttonBar.add(wSubmit); wSubmit.addClickHandler(new ClickHandler() { public void onClick(ClickEvent evt) { submitForm(); } }); final CustomButton wReset = new CustomButton(_("Reset"), AppConstants.ICON_CLEAR); buttonBar.add(wReset); wReset.addClickHandler(new ClickHandler() { public void onClick(ClickEvent evt) { resetForm(); } }); verticalPanel.add(buttonBar); final SimplePanel simplePanel = new SimplePanel(); tabPanel.add(simplePanel, _("Summary")); final FlexTable flexTable = new FlexTable(); simplePanel.setWidget(flexTable); flexTable.setSize("100%", "100%"); final Label label = new Label(_("Import Previous Notes for") + " "); flexTable.setWidget(0, 0, label); final HorizontalPanel dateContainer = new HorizontalPanel(); final CustomDatePicker wImportDate = new CustomDatePicker(); // wImportDate.setWeekendSelectable(true); dateContainer.add(wImportDate); final CustomButton wImportPrevious = new CustomButton(_("Import"), AppConstants.ICON_IMPORT); dateContainer.add(wImportPrevious); flexTable.setWidget(0, 1, dateContainer); final Label dateLabel = new Label(_("Date") + " : "); flexTable.setWidget(1, 0, dateLabel); wDate = new CustomDatePicker(); wDate.setHashMapping("pnotesdt"); addEntryWidget("pnotesdt", wDate); flexTable.setWidget(1, 1, wDate); final Label providerLabel = new Label(_("Provider") + " : "); flexTable.setWidget(2, 0, providerLabel); wProvider = new SupportModuleWidget("ProviderModule"); wProvider.setHashMapping("pnotesphy"); addEntryWidget("pnotesphy", wProvider); flexTable.setWidget(2, 1, wProvider); final Label descriptionLabel = new Label(_("Description") + " : "); flexTable.setWidget(3, 0, descriptionLabel); wDescription = new CustomTextArea(); wDescription.setHashMapping("pnotesdescrip"); addEntryWidget("pnotesdescrip", wDescription); flexTable.setWidget(3, 1, wDescription); wDescription.setWidth("100%"); final Label templateLabel = new Label(_("Template") + " : "); flexTable.setWidget(4, 0, templateLabel); final HorizontalPanel templatePanel = new HorizontalPanel(); wTemplate = new SupportModuleWidget("ProgressNotesTemplates"); templatePanel.add(wTemplate); CustomButton importTemplate = new CustomButton(_("Import"), AppConstants.ICON_IMPORT); importTemplate.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (wTemplate.getValue() != null && wTemplate.getValue() != 0) { JsonUtil.debug("loading template " + wTemplate.getValue()); if (Util.getProgramMode() == ProgramMode.STUBBED) { Util.showInfoMsg("ProgressNotesTemplates", "Template loaded."); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { JsonUtil.jsonify(wTemplate.getValue()) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.module.ProgressNotesTemplates.GetTemplate", 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("ProgressNotesTemplates", _("Failed to load template.")); } public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { @SuppressWarnings("unchecked") HashMap<String, String> result = (HashMap<String, String>) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { loadTemplateData(result); Util.showInfoMsg("ProgressNotesTemplates", _("Loaded template.")); } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { GWT.log("Exception", e); Util.showErrorMsg("ProgressNotesTemplates", _("Failed to load template.")); } } else { // TODO: Make this work with GWT-RPC } } } }); templatePanel.add(importTemplate); flexTable.setWidget(4, 1, templatePanel); final SimplePanel containerS = new SimplePanel(); tabPanel.add(containerS, "S"); S = new CustomRichTextArea(); S.setHashMapping("pnotes_S"); addEntryWidget("pnotes_S", S); containerS.setWidget(S); S.setSize("100%", "100%"); final SimplePanel containerO = new SimplePanel(); tabPanel.add(containerO, "O"); O = new CustomRichTextArea(); O.setHashMapping("pnotes_O"); addEntryWidget("pnotes_O", O); containerO.setWidget(O); O.setSize("100%", "100%"); final SimplePanel containerA = new SimplePanel(); tabPanel.add(containerA, "A"); A = new CustomRichTextArea(); A.setHashMapping("pnotes_A"); addEntryWidget("pnotes_A", A); containerA.setWidget(A); A.setSize("100%", "100%"); final SimplePanel containerP = new SimplePanel(); tabPanel.add(containerP, "P"); P = new CustomRichTextArea(); P.setHashMapping("pnotes_P"); addEntryWidget("pnotes_P", P); containerP.setWidget(P); P.setSize("100%", "100%"); final SimplePanel containerI = new SimplePanel(); tabPanel.add(containerI, "I"); I = new CustomRichTextArea(); I.setHashMapping("pnotes_I"); addEntryWidget("pnotes_I", I); containerI.setWidget(I); I.setSize("100%", "100%"); final SimplePanel containerE = new SimplePanel(); tabPanel.add(containerE, "E"); E = new CustomRichTextArea(); E.setHashMapping("pnotes_E"); addEntryWidget("pnotes_E", E); containerE.setWidget(E); E.setSize("100%", "100%"); final VerticalPanel containerR = new VerticalPanel(); tabPanel.add(containerR, "R"); R = new CustomRichTextArea(); R.setHashMapping("pnotes_R"); addEntryWidget("pnotes_R", R); containerR.add(R); R.setSize("100%", "100%"); final RecentMedicationsList recentMedicationsList = new RecentMedicationsList(); recentMedicationsList.setPatientId(patientId); containerR.add(recentMedicationsList); tabPanel.selectTab(0); Util.setFocus(wProvider); }
From source file:org.freemedsoftware.gwt.client.screen.patient.ScannedDocumentsEntryScreen.java
License:Open Source License
public void deleteRecord(final String moduleName, Integer id) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: STUBBED } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // JSON-RPC String moduleURL = "org.freemedsoftware.module." + moduleName + ".Del"; String[] params = { JsonUtil.jsonify(id) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(moduleURL, params))); try {//from w w w.ja v a 2 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()) { Boolean b = (Boolean) JsonUtil.shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (b != null && b.booleanValue()) { retrieveAndFillListData(); resetForm(); wDelete.setVisible(false); tabPanel.selectTab(1); } } else { Util.showErrorMsg("ScannedDocuments", _("Failed to delete document.")); } } }); } catch (RequestException e) { } } else { // GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.patient.ScannedDocumentsEntryScreen.java
License:Open Source License
public void retrieveAndFillData(final String moduleName, String moduleURL, Integer id, final HashMap<String, Widget> containerFormFields) { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: STUBBED } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // JSON-RPC String[] params = { JsonUtil.jsonify(id) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest(moduleURL, params))); try {/*www. j a va2 s . c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { JsonUtil.debug("Error on retrieving document"); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { if (response.getText().compareToIgnoreCase("false") != 0) { HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); Util.populateForm(containerFormFields, result); } else { JsonUtil.debug("Received dummy response from JSON backend"); } } else { Util.showErrorMsg("ScannedDocuments", _("Failed to get document.")); } } }); } catch (RequestException e) { Util.showErrorMsg("ScannedDocuments", _("Failed to get document.")); } } else { // GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.patient.ScannedDocumentsEntryScreen.java
License:Open Source License
public void retrieveAndFillListData() { if (Util.getProgramMode() == ProgramMode.STUBBED) { // TODO: STUBBED } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { // JSON-RPC String[] params = { JsonUtil.jsonify(patientScreen.getPatient()) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode(Util.getJsonRequest( "org.freemedsoftware.module." + SCANNED_DOCUMENT + ".GetPatientAllRecords", params))); try {//from w w w .j a v a 2s .co m builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { JsonUtil.debug("Error on retrieving AppointmentTemplate"); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { if (response.getText().compareToIgnoreCase("false") != 0) { HashMap<String, String>[] result = (HashMap<String, String>[]) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "HashMap<String,String>[]"); if (result != null) { containerScannedDocumentsTable.loadData(result); } } else { JsonUtil.debug("Received dummy response from JSON backend"); } } else { Util.showErrorMsg("ScannedDocuments", _("Failed to get document.")); } } }); } catch (RequestException e) { Util.showErrorMsg("ScannedDocuments", _("Failed to get document.")); } } else { // GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.patient.ScannedDocumentsEntryScreen.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 www. j a v a 2s . c om*/ 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("ScannedDocuments", _("Entry successfully added.")); } else { Boolean b = (Boolean) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Boolean"); if (b != null) Util.showInfoMsg("ScannedDocuments", _("Entry successfully modified.")); } } else { Util.showErrorMsg("ScannedDocuments", _("Entry failed.")); } } }); } catch (RequestException e) { } } else { // GWT-RPC } }
From source file:org.freemedsoftware.gwt.client.screen.PatientForm.java
License:Open Source License
public void commitChanges() { if (validateForm()) { if (Util.getProgramMode() == ProgramMode.STUBBED) { submitButton.setEnabled(true); Util.showInfoMsg("PatientForm", _("Updated patient information.")); addressContainer.setOnCompletion(new Command() { public void execute() { closeScreen();// ww w.j a v a2 s . com } }); addressContainer.commitChanges(); } else if (Util.getProgramMode() == ProgramMode.NORMAL) { if (patientId == 0) { // Add getModuleProxy().ModuleAddMethod(moduleName, populateHashMap(), new AsyncCallback<Integer>() { public void onSuccess(Integer o) { CurrentState.getToaster().addItem("Patient", _("Updated patient information."), Toaster.TOASTER_INFO); addressContainer.setPatient(o); addressContainer.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); addressContainer.commitChanges(); if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.MODIFY)) { patientCoverages.setPatient(o); patientCoverages.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); patientCoverages.commitChanges(); } patientAuthorizations.setPatient(o); patientAuthorizations.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); patientAuthorizations.commitChanges(); } public void onFailure(Throwable t) { JsonUtil.debug("Exception"); submitButton.setEnabled(true); } }); } else { // Modify getModuleProxy().ModuleModifyMethod(moduleName, populateHashMap(), new AsyncCallback<Integer>() { public void onSuccess(Integer o) { CurrentState.getToaster().addItem("Patient", _("Updated patient information."), Toaster.TOASTER_INFO); addressContainer.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); addressContainer.commitChanges(); patientCoverages.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); patientCoverages.commitChanges(); patientAuthorizations.setOnCompletion(new Command() { public void execute() { closeScreen(); } }); patientAuthorizations.commitChanges(); } public void onFailure(Throwable t) { JsonUtil.debug("Exception"); submitButton.setEnabled(true); } }); } } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { if (patientId == 0) { // Add String[] params = { JsonUtil.jsonify(populateHashMap()) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientModule.add", 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()) { Integer r = (Integer) JsonUtil .shoehornJson(JSONParser.parseStrict(response.getText()), "Integer"); if (r != 0) { addressContainer.setPatient(r); addressContainer.commitChanges(); if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.WRITE)) { patientCoverages.setPatient(r); patientCoverages.commitChanges(); } if (CurrentState.isActionAllowed(AuthorizationsModuleName, AppConstants.WRITE)) { patientAuthorizations.setPatient(r); patientAuthorizations.commitChanges(); } spawnPatientScreen(r); CurrentState.getToaster().addItem("PatientForm", _("Patient successfully added.")); } } else { CurrentState.getToaster().addItem("PatientForm", _("Adding patient failed.")); } } }); } catch (RequestException e) { } } else { // Modify String[] params = { JsonUtil.jsonify(populateHashMap()) }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL .encode(Util.getJsonRequest("org.freemedsoftware.module.PatientModule.mod", 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) { // addressContainer.setPatient(patientId); //addressContainer.deleteAddress(); addressContainer.commitChanges(); if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.MODIFY)) patientCoverages.commitChanges(); if (CurrentState.isActionAllowed(AuthorizationsModuleName, AppConstants.MODIFY)) patientAuthorizations.commitChanges(); spawnPatientScreen(patientId); CurrentState.getToaster().addItem("PatientForm", _("Patient information successfully modified.")); } } else { CurrentState.getToaster().addItem("PatientForm", _("Adding patient failed.")); } } }); } catch (RequestException e) { } } } closeScreen(); } else { // Form validation failed, allow user to continue submitButton.setEnabled(true); Util.showErrorMsg("PatientForm", "Form validation failed."); } }
From source file:org.freemedsoftware.gwt.client.screen.PatientForm.java
License:Open Source License
protected void populateForm() { if (Util.getProgramMode() == Util.ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.PatientInterface.PatientInformation", params))); try {/*from w ww . j a v a2 s. c o m*/ builder.sendRequest(null, new RequestCallback() { public void onError(com.google.gwt.http.client.Request request, Throwable ex) { Window.alert(ex.toString()); } @SuppressWarnings("unchecked") public void onResponseReceived(com.google.gwt.http.client.Request request, com.google.gwt.http.client.Response response) { if (200 == response.getStatusCode()) { if (Util.checkValidSessionResponse(response.getText())) { HashMap<String, String> result = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (result != null) { addressContainer.setPatient(patientId); if (CurrentState.isActionAllowed(CoveragesModuleName, AppConstants.READ)) patientCoverages.setPatient(patientId); if (CurrentState.isActionAllowed(AuthorizationsModuleName, AppConstants.READ)) patientAuthorizations.setPatient(patientId); // Demographics screen // wTitle.setWidgetValue((String) result // .get((String) "ptsalut")); title.setWidgetValue((String) result.get((String) "ptsalut")); wLastName.setText((String) result.get((String) "ptlname")); wFirstName.setText((String) result.get((String) "ptfname")); wMiddleName.setText((String) result.get((String) "ptmname")); suffix.setWidgetValue((String) result.get((String) "ptsuffix")); gender.setWidgetValue((String) result.get((String) "ptsex")); wDob.setValue((String) result.get((String) "ptdob")); // Contact screen preferredContact.setWidgetValue((String) result.get((String) "ptprefcontact")); phoneHome.setText((String) result.get((String) "pthphone")); phoneWork.setText((String) result.get((String) "ptwphone")); phoneMobile.setText((String) result.get((String) "ptmphone")); phoneFax.setText((String) result.get((String) "ptfax")); emailAddress.setText((String) result.get((String) "ptemail")); // Personal screen martialStatus.setWidgetValue((String) result.get((String) "ptmarital")); employmentStatus.setWidgetValue((String) result.get((String) "ptempl")); socialSecurityNumber.setText((String) result.get((String) "ptssn")); race.setWidgetValue((String) result.get((String) "ptrace")); religion.setWidgetValue((String) result.get((String) "ptreligion")); languages.setWidgetValue((String) result.get((String) "ptprimarylanguage")); typeofBilling.setWidgetValue((String) result.get((String) "ptbilltype")); monthlyBudgetAmount.setText((String) result.get((String) "ptbudg")); patientPracticeID.setText((String) result.get((String) "ptid")); // Medical screen // bloodType.setWidgetValue((String) result.get((String) "ptblood")); if (result.get((String) "ptprimaryfacility") != null & result.get((String) "ptprimaryfacility").length() > 0) primaryFacility .setValue(new Integer(result.get((String) "ptprimaryfacility"))); if (result.get((String) "ptpharmacy") != null & result.get((String) "ptpharmacy").length() > 0) preferredPharmacy.setValue(new Integer(result.get((String) "ptpharmacy"))); if (result.get((String) "ptdoc") != null & result.get((String) "ptdoc").length() > 0) inHouseDoctor.setValue(new Integer(result.get((String) "ptdoc"))); if (result.get((String) "ptrefdoc") != null & result.get((String) "ptrefdoc").length() > 0) referringDoctor.setValue(new Integer(result.get((String) "ptrefdoc"))); if (result.get((String) "ptpcp") != null & result.get((String) "ptpcp").length() > 0) primaryCarePhysician.setValue(new Integer(result.get((String) "ptpcp"))); int tempCount = 0; if (result.get((String) "ptphy1") != null & result.get((String) "ptphy1").length() > 0) { otherPhysician1.setValue(new Integer(result.get((String) "ptphy1"))); tempCount++; } if (result.get((String) "ptphy2") != null & result.get((String) "ptphy2").length() > 0) { otherPhysician2.setValue(new Integer(result.get((String) "ptphy2"))); tempCount++; } if (result.get((String) "ptphy3") != null & result.get((String) "ptphy3").length() > 0) { otherPhysician3.setValue(new Integer(result.get((String) "ptphy3"))); tempCount++; } if (result.get((String) "ptphy4") != null & result.get((String) "ptphy4").length() > 0) { otherPhysician4.setValue(new Integer(result.get((String) "ptphy4"))); tempCount++; } updateOtherPhysiciansBoxes(tempCount); numberofOtherPhysicians.setWidgetValue(tempCount + ""); // Populate address container } } } else { Window.alert(response.toString()); } } }); } catch (RequestException e) { Window.alert(e.toString()); } } }
From source file:org.freemedsoftware.gwt.client.screen.PatientScreen.java
License:Open Source License
public void populate() { if (Util.getProgramMode() == ProgramMode.STUBBED) { HashMap<String, String> dummy = new HashMap<String, String>(); dummy.put("patient_name", "Hackenbush, Hugo Z"); dummy.put("id", patientId.toString()); dummy.put("patient_id", "HUGO01"); dummy.put("ptdob", "1979-08-10"); dummy.put("address_line_1", "101 Evergreen Terrace"); dummy.put("address_line_2", ""); dummy.put("csz", "N Kilt Town, IL 00000"); dummy.put("pthphone", "8005551212"); dummy.put("ptwphone", "860KL51212"); populatePatientInformation(dummy); } else if (Util.getProgramMode() == ProgramMode.JSONRPC) { String[] params = { patientId.toString() }; RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode( Util.getJsonRequest("org.freemedsoftware.api.PatientInterface.PatientInformation", params))); try {/*ww w .j ava2 s .com*/ builder.sendRequest(null, new RequestCallback() { public void onError(Request request, Throwable ex) { Util.showErrorMsg("PatientScreen", _("Failed to retrieve patient information.")); } @SuppressWarnings("unchecked") public void onResponseReceived(Request request, Response response) { if (200 == response.getStatusCode()) { HashMap<String, String> r = (HashMap<String, String>) JsonUtil.shoehornJson( JSONParser.parseStrict(response.getText()), "HashMap<String,String>"); if (r != null) { populatePatientInformation(r); } } else { Util.showErrorMsg("Patientscreen", _("Failed to retrieve patient information.")); } } }); } catch (RequestException e) { Util.showErrorMsg("Patientscreen", _("Failed to retrieve patient information.")); } } else { // Set off async method to get information PatientInterfaceAsync service = null; try { service = (PatientInterfaceAsync) Util .getProxy("org.freemedsoftware.gwt.client.Api.PatientInterface"); } catch (Exception e) { GWT.log("Exception caught: ", e); } service.PatientInformation(patientId, new AsyncCallback<HashMap<String, String>>() { public void onSuccess(HashMap<String, String> pInfo) { populatePatientInformation(pInfo); } public void onFailure(Throwable t) { GWT.log("FAILURE: ", t); Util.showErrorMsg("Patientscreen", _("Failed to retrieve patient information.")); } }); } }