Examples of HtmlFormEntryService


Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

                                      @RequestParam(value="reason", required=false) String reason,
                                      @RequestParam(value="returnUrl", required=false) String returnUrl,
                                      HttpServletRequest request) throws Exception {
        Encounter enc = Context.getEncounterService().getEncounter(encounterId);
        Integer ptId = enc.getPatientId();
        HtmlFormEntryService hfes = Context.getService(HtmlFormEntryService.class);
        HtmlForm form = hfes.getHtmlForm(htmlFormId);
        HtmlFormEntryUtil.voidEncounter(enc, form, reason);
        Context.getEncounterService().saveEncounter(enc);
        if (!StringUtils.hasText(returnUrl)) {
          returnUrl = request.getContextPath() + "/patientDashboard.form?patientId=" + ptId;
        }
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   */
  @RequestMapping(value="/module/htmlformentry/htmlForm", method=RequestMethod.POST)
  public String saveHtmlForm(Model model,
                             @ModelAttribute("htmlForm") HtmlForm htmlForm, BindingResult result,
                             WebRequest request) {
    HtmlFormEntryService service = HtmlFormEntryUtil.getService();
    if (htmlForm.getId() == null && StringUtils.isBlank(htmlForm.getXmlData())) {
      htmlForm.setXmlData(service.getStartingFormXml(htmlForm));
    }
    new HtmlFormValidator().validate(htmlForm, result);
    if (result.hasErrors()) {
      return null;
    } else {
          htmlForm = service.saveHtmlForm(htmlForm);
          request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "Saved " + htmlForm.getForm().getName() + " " + htmlForm.getForm().getVersion(), WebRequest.SCOPE_SESSION);
      return "redirect:htmlForm.form?id=" + htmlForm.getId();
    }
  }
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   * @param model
   * @return
   */
  @RequestMapping(method=RequestMethod.GET)
  public String showMigrationsNeeded(Model model) {
    HtmlFormEntryService service = HtmlFormEntryUtil.getService();   
    List<HtmlForm> allForms = service.getAllHtmlForms();
   
    // 1. figure out whether any htmlforms need splitting because they share a form
    {
      Map<Integer, List<HtmlForm>> duplicateForms = getDuplicateForms(allForms);
      if (duplicateForms.size() > 0) {
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   * @param request
   * @return
   */
  @RequestMapping(method=RequestMethod.POST, params="migration=duplicateForms")
  public String splitDuplicateForms(WebRequest request) {
    HtmlFormEntryService service = HtmlFormEntryUtil.getService();
    Map<Integer, List<HtmlForm>> duplicates = getDuplicateForms(service.getAllHtmlForms());
    for (Map.Entry<Integer, List<HtmlForm>> e : duplicates.entrySet()) {
      Integer id = e.getKey();
      List<HtmlForm> htmlForms = e.getValue();
      String choice = request.getParameter("group." + id);
      try {
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   * @return
   */
  @RequestMapping(method=RequestMethod.POST, params="migration=clearNamesAndDescriptions")
  public String clearNamesAndDescriptionsThatMatch(@RequestParam(value="clearName", required=false) List<Integer> clearNames,
                                                   @RequestParam(value="clearDescription", required=false) List<Integer> clearDescriptions) {
    HtmlFormEntryService service = HtmlFormEntryUtil.getService();
    for (HtmlForm form : service.getAllHtmlForms()) {
      boolean needToSave = false;
      if (clearNames != null && clearNames.contains(form.getId())) {
        form.setDeprecatedName(null);
        needToSave = true;
      }
      if (clearDescriptions != null && clearDescriptions.contains(form.getId())) {
        form.setDeprecatedDescription(null);
        needToSave = true;
      }
      if (needToSave)
        service.saveHtmlForm(form);
    }
      return "redirect:migrateNamesAndDescriptions.form";
  }
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   */
  private void splitUnderlyingForm(HtmlForm htmlForm) {
    Form oldForm = htmlForm.getForm();
      Form newForm = Context.getFormService().duplicateForm(oldForm);
      htmlForm.setForm(newForm);
      HtmlFormEntryService service = HtmlFormEntryUtil.getService();
      if (htmlForm.getDeprecatedName() != null) {
        newForm.setName(htmlForm.getDeprecatedName());
        htmlForm.setDeprecatedName(null);
      }
      service.saveHtmlForm(htmlForm);
    }
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

   * @param request
   * @return
   */
  @RequestMapping(method=RequestMethod.POST, params="migration=namesAndDescriptions")
  public String doNameAndDescriptionMigration(WebRequest request) {
    HtmlFormEntryService service = HtmlFormEntryUtil.getService();
   
    for (HtmlForm htmlForm : service.getAllHtmlForms()) {
      boolean modified = false;

      String nameChoice = request.getParameter("name." + htmlForm.getId());
      if (StringUtils.isNotBlank(nameChoice)) {
        if (nameChoice.equals("html")) {
          // use the old value
          htmlForm.getForm().setName(htmlForm.getDeprecatedName());
          htmlForm.setDeprecatedName(null);
        } else if (nameChoice.equals("form")) {
          // clear the old value, since we don't want it
          htmlForm.setDeprecatedName(null);
        }
        modified = true;
      }
     
      String descriptionChoice = request.getParameter("description." + htmlForm.getId());
      if (StringUtils.isNotBlank(descriptionChoice)) {
        if (descriptionChoice.equals("html")) {
          // use the old value
          htmlForm.getForm().setDescription(htmlForm.getDeprecatedDescription());
          htmlForm.setDeprecatedDescription(null);
        } else if (descriptionChoice.equals("form")) {
          // clear the old value, since we don't want it
          htmlForm.setDeprecatedDescription(null);
        }
        modified = true;
      }
     
      if (modified) {
        service.saveHtmlForm(htmlForm);
      }
    }
   
    return "redirect:migrateNamesAndDescriptions.form";
  }
View Full Code Here

Examples of org.openmrs.module.htmlformentry.HtmlFormEntryService

  public void started() {
    log.info("Drawing Module started");
  if (ModuleFactory.isModuleStarted("htmlformentry")) {
      try {
       
        HtmlFormEntryService hfes = Context.getService(HtmlFormEntryService.class);
       
        hfes.addHandler("drawing", new DrawingTagHandler());
       
        log.info("drawing : drawing tag registered");
      }
      catch (Exception ex) {
        log.error("failed to register drawing tag in drawing", ex);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.