/** * Show a single HTML Form */ @RequestMapping(value="/module/htmlformentry/htmlForm", method=RequestMethod.GET) public void showHtmlForm(Model model, HttpSession httpSession, @ModelAttribute("htmlForm") HtmlForm htmlForm) { HtmlForm hf = (HtmlForm) model.asMap().get("htmlForm"); if (hf.getId() == null) { model.addAttribute("previewHtml", ""); } else { try { Patient demo = HtmlFormEntryUtil.getFakePerson(); FormEntrySession fes = new FormEntrySession(demo, hf.getXmlData(), httpSession); String html = fes.getHtmlToDisplay(); if (fes.getFieldAccessorJavascript() != null) { html += "<script>" + fes.getFieldAccessorJavascript() + "</script>"; } model.addAttribute("previewHtml", html); } catch (Exception ex) { log.warn("Error rendering html form", ex); model.addAttribute("previewHtml", "Error! " + ex); } } }
FormEntrySession fes = new FormEntrySession(p, null, Mode.ENTER, fakeForm, request.getSession()); String html = fes.getHtmlToDisplay(); if (fes.getFieldAccessorJavascript() != null) { html += "<script>" + fes.getFieldAccessorJavascript() + "</script>";
@Test public void shouldDisplayEncounterTypeValue() throws Exception { String htmlform = "<htmlform><encounterType/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterType.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterType.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayEncounterTypeValuePropertyAccessorUsingCustomName() throws Exception { String htmlform = "<htmlform><encounterType id=\"myEncounter\"/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayLocationValuePropertyAccessor() throws Exception { String htmlform = "<htmlform><encounterLocation/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterLocation.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterLocation.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayDatePropertyAccessorUsingCustomName() throws Exception { String htmlform = "<htmlform><encounterDate id=\"myEncounter\"/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayDatePropertyAccessor() throws Exception { String htmlform = "<htmlform><encounterDate/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterDate.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterDate.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayProviderValuePropertyAccessor() throws Exception { String htmlform = "<htmlform><encounterProvider/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterProvider.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['encounterProvider.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayProviderValuePropertyAccessorUsingCustomName() throws Exception { String htmlform = "<htmlform><encounterProvider id=\"myEncounter\"/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.error'\\]", session.getFieldAccessorJavascript()); }
@Test public void shouldDisplayLocationValuePropertyAccessorUsingCustomName() throws Exception { String htmlform = "<htmlform><encounterLocation id=\"myEncounter\"/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); session.getHtmlToDisplay(); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.value'\\]", session.getFieldAccessorJavascript()); TestUtil.assertFuzzyContains("propertyAccessorInfo\\['myEncounter.error'\\]", session.getFieldAccessorJavascript()); }