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); }
private HtmlFormSchema generateSchema(String xml, HttpSession httpSession) throws Exception { Patient p = HtmlFormEntryUtil.getFakePerson(); HtmlForm fakeForm = new HtmlForm(); fakeForm.setXmlData(xml); FormEntrySession fes = new FormEntrySession(p, null, FormEntryContext.Mode.ENTER, fakeForm, httpSession); fes.getHtmlToDisplay(); return fes.getContext().getSchema(); } }
@Override public void reprocessArchivedForm(String argument,boolean isPath) throws Exception { SerializableFormObject formObject; if(isPath) { formObject = SerializableFormObject.deserializeXml(argument); } else { formObject = SerializableFormObject.deserializeXml(argument,false); } formObject.handleSubmission(); //Save data to database HtmlFormEntryUtil.getService().applyActions(formObject.getSession()); }
/** * @see org.openmrs.module.htmlformentry.action.FormSubmissionControllerAction#handleSubmission(org.openmrs.module.htmlformentry.FormEntrySession, javax.servlet.http.HttpServletRequest) */ @Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { if (session.getContext().getMode() == Mode.ENTER) { session.getSubmissionActions().completeProgram(program); } }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertProvider(502); results.assertLocation(2); results.assertObsCreatedCount(0); }
@Override public void doEndTag(FormEntrySession session, PrintWriter out, Node parent, Node node) { // Concept question = null; // if (parent != null){ // NamedNodeMap attrs = parent.getAttributes(); // try { // question = HtmlFormEntryUtil.getConcept(attrs.getNamedItem("groupingConceptId").getNodeValue()); // } catch (Exception ex){} // } session.getContext().endObsGroup(); session.getSubmissionController().addAction(ObsGroupAction.end()); }
@Override public boolean shouldIncludeContent(FormEntrySession session, Node parent, Node node) { String mode = HtmlFormEntryUtil.getNodeAttribute(node, "mode", null); String include = HtmlFormEntryUtil.getNodeAttribute(node, "include", "true"); if (mode == null) { throw new RuntimeException("ifMode tag requires the mode attribute"); } boolean modeIsCurrent = mode.equalsIgnoreCase(session.getContext().getMode().toString()); return include.equals("true") ? modeIsCurrent : !modeIsCurrent; } }
private Obs findObsGroup(FormEntrySession session, Node node, String parentGroupingConceptId) { String path = ObsGroupComponent.getObsGroupPath(node); if (session.getContext().isUnmatchedMode()) { return session.getContext().getNextUnmatchedObsGroup(path); } else { List<ObsGroupComponent> questionsAndAnswers = ObsGroupComponent.findQuestionsAndAnswersForGroup(parentGroupingConceptId, node); return session.getContext().findBestMatchingObsGroup(questionsAndAnswers, parentGroupingConceptId, path); } }
@Test public void shouldDisplayStateSpecifiedByMapping() throws Exception { executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_TEST_DATASET)); String htmlform = "<htmlform><workflowState workflowId=\"108\" stateId=\"SNOMED CT:Test Code\"/></htmlform>"; FormEntrySession session = new FormEntrySession(patient, htmlform, null); assertPresent(session, MAPPED_STATE); }
@Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { session.getSubmissionActions().addCustomFormSubmissionAction(this); }
@Override public void doEndTag(FormEntrySession session, PrintWriter out, Node parent, Node node) { session.getSubmissionController().endRepeat(); }
@Override protected Object formBackingObject(HttpServletRequest request) throws Exception { return HtmlFormEntryUtil.getService().getAllHtmlForms(); }
private static <T extends OpenmrsMetadata> T getMetadataByMapping(Class<T> type, String identifier){ MetadataMappingResolver metadataMappingResolver = getMetadaMappingResolver(); if (metadataMappingResolver != null) { return metadataMappingResolver.getMetadataItem(type, identifier); } return null; }
/** * @return the all the encounters of the specified type * @should return all the encounters of the specified type * @should return all encounters if no type specified */ public List<Encounter> allEncounters(String encounterTypeId){ EncounterType encounterType = HtmlFormEntryUtil.getEncounterType(encounterTypeId); return getAllEncounters(encounterType); }
/** * This method doesn't support "SessionAttribute:", but is otherwise like the similarly-named method. * @see #getLocation(String, FormEntryContext) */ public static Location getLocation(String id) { return getLocation(id, null); }
private HtmlFormSchema generateSchema(String xml, HttpSession httpSession, Encounter encounter) throws Exception { HtmlForm fakeForm = new HtmlForm(); fakeForm.setXmlData(xml); FormEntrySession fes = new FormEntrySession(encounter.getPatient(), encounter, FormEntryContext.Mode.VIEW, fakeForm, httpSession); fes.getHtmlToDisplay(); return fes.getContext().getSchema(); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertProvider(502); results.assertLocation(2); results.assertObsCreatedCount(1); results.assertObsCreated(1, "8.0"); }
@Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { session.getSubmissionActions().addCustomFormSubmissionAction(this); }
@Override public void testResults(SubmissionResults results) { results.assertNoErrors(); results.assertEncounterCreated(); results.assertProvider(502); results.assertLocation(2); results.assertObsCreatedCount(1); results.assertObsCreated(1,"8.0"); }
@Override public void handleSubmission(FormEntrySession session, HttpServletRequest submission) { session.getSubmissionActions().addCustomFormSubmissionAction(this); }