Package org.openmrs

Examples of org.openmrs.Form


   
    for(Encounter enc: encounters)
    {
      if(enc.getForm() != null)
      {
        Form encForm = enc.getForm();
        HtmlForm htmlForm = HtmlFormEntryUtil.getService().getHtmlFormByForm(encForm);
        if(htmlForm != null && htmlForm.getId().equals(formId) && dateToCheck.compareTo(enc.getEncounterDatetime()) == 0)
        {
          duplicate = true;
        }
View Full Code Here


            mode = Mode.EDIT;           
    }

        Patient patient = null;
      Encounter encounter = null;
      Form form = null;
      HtmlForm htmlForm = null;

      if (StringUtils.hasText(request.getParameter("encounterId"))) {
       
        Integer encounterId = Integer.valueOf(request.getParameter("encounterId"));
View Full Code Here

            // avoid LazyInitializationException
            hf.getForm().getFormFields().size();
            return hf;
        } else {
          HtmlForm hf = new HtmlForm();
          hf.setForm(new Form());
          return hf;
        }
    }
View Full Code Here

 
 
  private Map<Integer, List<HtmlForm>> getDuplicateForms(List<HtmlForm> allForms) {
    Map<Integer, List<HtmlForm>> ret = new LinkedHashMap<Integer, List<HtmlForm>>();
    for (HtmlForm htmlForm : allForms) {
      Form form = htmlForm.getForm();
      List<HtmlForm> holder = (List<HtmlForm>) ret.get(form.getId());
      if (holder == null) {
        holder = new ArrayList<HtmlForm>();
        ret.put(form.getId(), holder);
      }
      holder.add(htmlForm);
    }
    // remove anything that doesn't appear multiple times
    for (Iterator<Map.Entry<Integer, List<HtmlForm>>> i = ret.entrySet().iterator(); i.hasNext(); ) {
View Full Code Here

  /**
   * Duplicates the Form that this HtmlForm points to, and points this HtmlForm to the new form.
   * @param htmlForm
   */
  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

  @Verifies(value = "should allow xml containing encounter type tag for a form with no encounter type", method = "validate(Object,Errors)")
  public void validate_shouldAllowXmlContainingEncounterTypeTagForAFormWithNoEncounterType() throws Exception {
    String xml = "<htmlform>Date: <encounterDate/>Location: <encounterLocation/>Provider: <encounterProvider role=\"Provider\"/>Encounter Type: <encounterType /><submit/></htmlform>";
    HtmlForm htmlForm = new HtmlForm();
    htmlForm.setName("testForm");
    Form form = Context.getFormService().getForm(1);
    Assert.assertNull(form.getEncounterType());
    htmlForm.setForm(form);
    htmlForm.setXmlData(xml);
    Errors errors = new BindException(htmlForm, "htmlForm");
    new HtmlFormValidator().validate(htmlForm, errors);
    Assert.assertFalse(errors.hasErrors());
View Full Code Here

    String xml = "<htmlform>Date: <encounterDate/>Location: <encounterLocation/>Provider: <encounterProvider role=\"Provider\"/>Encounter Type: <encounterType /><submit/></htmlform>";
    HtmlForm htmlForm = new HtmlForm();
    htmlForm.setName("testForm");
    htmlForm.setXmlData(xml);
   
    Form form = Context.getFormService().getForm(1);
    //set the encounter type on the form for testing purposes
    EncounterType encType = Context.getEncounterService().getEncounterType(1);
    Assert.assertNotNull(encType);
    form.setEncounterType(encType);
    htmlForm.setForm(form);
   
    Errors errors = new BindException(htmlForm, "htmlForm");
    new HtmlFormValidator().validate(htmlForm, errors);
    Assert.assertTrue(errors.hasFieldErrors("xmlData"));
View Full Code Here

    }
   
    @Test
    @Verifies(value = "should recognize and return section tags in xml", method = "getSectionNodes(HtmlForm)")
    public void getSectionNodes_shouldReturnSectionNodesCorrectly() throws Exception {     
        Form form = new Form();
        HtmlForm htmlform = new HtmlForm();
        htmlform.setForm(form);
        form.setEncounterType(new EncounterType());
        htmlform.setDateChanged(new Date());
        htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestForm.xml"));
        Map<Integer, String> map = HtmlFormEntryExportUtil.getSectionIndex(htmlform);
        String st = "";
        for (Map.Entry<Integer, String> e : map.entrySet()){
View Full Code Here


    @Test
    @Verifies(value = "should return section as a new htmlform", method = "getSectionAsForm(HtmlForm)")
    public void getSectionAsForm_shouldReturnStringCorrectly() throws Exception
        Form form = new Form();
        HtmlForm htmlform = new HtmlForm();
        htmlform.setForm(form);
        form.setEncounterType(new EncounterType());
        htmlform.setDateChanged(new Date());
        htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestForm.xml"));
        String newXml = HtmlFormEntryExportUtil.getSectionAsFormXml(htmlform, 1);
        //System.out.println(newXML);
        htmlform.setXmlData(newXml);
View Full Code Here

   

    @Test
    @Verifies(value = "should return trimmed encounter", method = "trimEncounterToMatchForm(Encounter e, HtmlForm htmlform)")
    public void trimEncounterToMatchForm_shouldReturnEncounterCorrectly() throws Exception {
        Form form = new Form();
        HtmlForm htmlform = new HtmlForm();
        htmlform.setForm(form);
        form.setEncounterType(new EncounterType());
        htmlform.setDateChanged(new Date());
        htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));
        String newXml = HtmlFormEntryExportUtil.getSectionAsFormXml(htmlform, 0);
        htmlform.setXmlData(newXml);
       
View Full Code Here

TOP

Related Classes of org.openmrs.Form

Copyright © 2018 www.massapicom. 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.