/** * Adds a {@see RepeatControllerAction} to the list of submission actions. * * @param repeat the repeat controller action to add */ public void startRepeat(RepeatControllerAction repeat) { if (this.repeat != null) throw new IllegalArgumentException("Nested Repeating elements are not yet implemented"); addAction(repeat); this.repeat = repeat; }
/** * Creates a new HTML Form Entry session (in "Enter" mode) for the specified Patient, using the * specified xml string to create the HTML Form object * * @param patient * @param xml * @param httpSession * @throws Exception */ public FormEntrySession(Patient patient, String xml, HttpSession httpSession) throws Exception { this(patient, Mode.ENTER, null, httpSession); submissionController = new FormSubmissionController(); this.xmlDefinition = xml; }
@Override public void doEndTag(FormEntrySession session, PrintWriter out, Node parent, Node node) { session.getSubmissionController().endRepeat(); }
Model model) throws Exception { try { List<FormSubmissionError> validationErrors = session.getSubmissionController().validateSubmission(session.getContext(), request); if (validationErrors != null && validationErrors.size() > 0) { errors.reject("Fix errors"); session.getSubmissionController().handleFormSubmission(session, request); HtmlFormEntryUtil.getService().applyActions(session); String successView = session.getAfterSaveUrlTemplate();
public void handleSubmission() throws Exception{ //Get the FormEntrySession & HttpServletRequest if(session==null)createSession(); HttpServletRequest request = createHttpServletRequest(); Map<Widget,String> fields = session.getContext().getFieldNames(); //handle submission & save data session.getSubmissionController().handleFormSubmission(session, request); }
session.getHtmlToDisplay(); FormSubmissionController fsa = session.getSubmissionController(); List<FormSubmissionControllerAction> actions = fsa.getActions(); for (FormSubmissionControllerAction fsca : actions){ if (fsca instanceof ObsSubmissionElement){
/** * Returns a fragment of javascript that will display any error widgets that had errors on the * last submission. */ public String getLastSubmissionErrorJavascript() { if (context.getMode() == Mode.VIEW) { // in VIEW mode there are no error widgets return ""; } StringBuilder sb = new StringBuilder(); List<FormSubmissionError> errs = submissionController.getLastSubmissionErrors(); if (errs != null && errs.size() > 0) { for (FormSubmissionError error : errs) { if (error.getSourceWidget() != null) sb.append("showError('" + context.getErrorFieldId(error.getSourceWidget()) + "', '" + error.getError() + "');\n"); else sb.append("showError('" + error.getId() + "', '" + error.getError() + "');\n"); } } return sb.toString(); }
HttpServletRequest lastSubmission = submissionController.getLastSubmission(); if (lastSubmission == null) { return "";
private SubmissionResults doSubmission(FormEntrySession session, HttpServletRequest request) throws Exception { SubmissionResults results = new SubmissionResults(); session.prepareForSubmit(); List<FormSubmissionError> validationErrors = session.getSubmissionController().validateSubmission( session.getContext(), request); if (validationErrors != null && validationErrors.size() > 0) { results.setValidationErrors(validationErrors); return results; } session.getSubmissionController().handleFormSubmission(session, request); if (session.getContext().getMode() == Mode.ENTER && session.hasEncouterTag() && (session.getSubmissionActions().getEncountersToCreate() == null || session.getSubmissionActions() .getEncountersToCreate().size() == 0)) throw new IllegalArgumentException("This form is not going to create an encounter"); Context.getService(HtmlFormEntryService.class).applyActions(session); results.setPatient(session.getPatient()); results.setEncounterCreated(session.getEncounter()); results.setFormEntrySession(session); return results; }
FormEntrySession session = new FormEntrySession(eTmp.getPatient(), eTmp, Mode.VIEW, htmlform, null); // session gets a null HttpSession session.getHtmlToDisplay(); List<FormSubmissionControllerAction> actions = session.getSubmissionController().getActions(); Set<Obs> matchedObs = new HashSet<Obs>(); Set<Order> matchedOrders = new HashSet<Order>();
@Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) throws BadFormDesignException { String className = parameters.get("class"); if (StringUtils.isEmpty(className)) { throw new BadFormDesignException("<postSubmissionAction/> tag requires a 'class' attribute"); } session.getSubmissionController().addAction(new Action(className)); return ""; }
/** * Creates a new HTML Form Entry session (in "Enter" mode) for the specified patient and using * the HTML Form associated with the specified Form * * @param patient * @param form * @param httpSession * @throws Exception */ public FormEntrySession(Patient patient, Form form, HttpSession httpSession) throws Exception { this(patient, Mode.ENTER, null, httpSession); this.form = form; velocityContext.put("form", form); submissionController = new FormSubmissionController(); HtmlForm temp = HtmlFormEntryUtil.getService().getHtmlFormByForm(form); this.formModifiedTimestamp = (temp.getDateChanged() == null ? temp.getDateCreated() : temp.getDateChanged()) .getTime(); xmlDefinition = temp.getXmlData(); }
@Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) { Map<String, Object> temp = new HashMap<String, Object>(); temp.putAll(parameters); temp.put("location", true); EncounterDetailSubmissionElement element = new EncounterDetailSubmissionElement(session.getContext(), temp); session.getSubmissionController().addAction(element); return element.generateHtml(session.getContext()); }
public FormEntrySession(Patient patient, HtmlForm htmlForm, Mode mode, Location defaultLocation, HttpSession httpSession, boolean automaticClientSideValidation, boolean clientSideValidationHints) throws Exception { this(patient, mode, defaultLocation, httpSession); this.context.setAutomaticClientSideValidation(automaticClientSideValidation); this.context.setClientSideValidationHints(clientSideValidationHints); this.htmlForm = htmlForm; this.formModifiedTimestamp = (htmlForm.getDateChanged() == null ? htmlForm.getDateCreated() : htmlForm .getDateChanged()).getTime(); form = htmlForm.getForm(); velocityContext.put("form", form); submissionController = new FormSubmissionController(); // avoid lazy initialization exceptions later if (form.getEncounterType() != null) form.getEncounterType().getName(); xmlDefinition = htmlForm.getXmlData(); }
@Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) { Map<String, Object> temp = new HashMap<String, Object>(); temp.putAll(parameters); temp.put("provider", true); EncounterDetailSubmissionElement element = new EncounterDetailSubmissionElement(session.getContext(), temp); session.getSubmissionController().addAction(element); return element.generateHtml(session.getContext()); }
submissionController = new FormSubmissionController(); context.setupExistingData(encounter); this.xmlDefinition = htmlForm.getXmlData();
@Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) { Map<String, Object> temp = new HashMap<String, Object>(); temp.putAll(parameters); temp.put("showVoidEncounter", true); EncounterDetailSubmissionElement element = new EncounterDetailSubmissionElement(session.getContext(), temp); session.getSubmissionController().addAction(element); return element.generateHtml(session.getContext()); }
@Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) { Date date = null; if (parameters.get("default") != null) { date = HtmlFormEntryUtil.translateDatetimeParam(parameters.get("default"), "yyyy-MM-dd"); } Map<String, Object> temp = new HashMap<String, Object>(); temp.putAll(parameters); temp.put("date", true); temp.put("defaultDate", date); EncounterDetailSubmissionElement element = new EncounterDetailSubmissionElement(session.getContext(), temp); session.getSubmissionController().addAction(element); return element.generateHtml(session.getContext()); }
/** * @see org.openmrs.module.htmlformentry.handler.SubstitutionTagHandler#getSubstitution(org.openmrs.module.htmlformentry.FormEntrySession, * org.openmrs.module.htmlformentry.FormSubmissionController, java.util.Map) */ @Override protected String getSubstitution(FormEntrySession session, FormSubmissionController controllerActions, Map<String, String> parameters) { Map<String, Object> temp = new HashMap<String, Object>(); temp.putAll(parameters); temp.put("encounterType", true); EncounterDetailSubmissionElement element = new EncounterDetailSubmissionElement(session.getContext(), temp); session.getSubmissionController().addAction(element); return element.generateHtml(session.getContext()); }