HtmlForm form = Context.getService(HtmlFormEntryService.class).getHtmlForm(id); xml = form.getXmlData();
htmlForm = HtmlFormEntryUtil.getService().getHtmlForm(htmlFormId); } else if (formId != null) { form = Context.getFormService().getForm(formId);
@ModelAttribute("htmlForm") HtmlForm formBackingObject(@RequestParam(value="id", required=false) Integer id) { if (id != null) { HtmlForm hf = HtmlFormEntryUtil.getService().getHtmlForm(id); // avoid LazyInitializationException hf.getForm().getFormFields().size(); return hf; } else { HtmlForm hf = new HtmlForm(); hf.setForm(new Form()); return hf; } }
@RequestMapping(method=RequestMethod.POST, value="/module/htmlformentry/deleteEncounter") public ModelAndView handleRequest(@RequestParam("encounterId") Integer encounterId, @RequestParam("htmlFormId") Integer htmlFormId, @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.getPatient().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; } return new ModelAndView(new RedirectView(returnUrl)); }
/** * This method returns a FormEntrySession object using data in the instance object * @return FormEntrySession object * @throws Exception */ private void createSession() throws Exception { //TODO: Check for null patientUuid and try to parse the xml to obtain the patient ID instead. Patient patient = Context.getPatientService().getPatientByUuid(getPatientUuid()); session = new FormEntrySession(patient,getXmlDefinition(),null); HtmlForm htmlForm = HtmlFormEntryUtil.getService().getHtmlForm(htmlFormId); htmlForm.setXmlData(xmlDefinition); session.setHtmlForm(htmlForm); //getHtmlToDisplay() is called to generate necessary tag handlers and cache the form session.getHtmlToDisplay(); //PrepareForSubmit is called to set patient and encounter if specified in tags session.prepareForSubmit(); }