@Override public HtmlForm saveHtmlForm(HtmlForm htmlForm) { if (htmlForm.getCreator() == null) htmlForm.setCreator(Context.getAuthenticatedUser()); if (htmlForm.getDateCreated() == null) htmlForm.setDateCreated(new Date()); if (htmlForm.getId() != null) { htmlForm.setChangedBy(Context.getAuthenticatedUser()); htmlForm.setDateChanged(new Date()); } Context.getFormService().saveForm(htmlForm.getForm()); return dao.saveHtmlForm(htmlForm); }
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml")); List<String> extraCols = new ArrayList<String>();
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "obsGroupDataExportTest.xml")); List<String> extraCols = new ArrayList<String>();
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "obsGroupSchemaTest.xml")); FormEntrySession session = new FormEntrySession(HtmlFormEntryUtil.getFakePerson(), htmlform, null);
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "obsGroupDataExportTest.xml")); List<String> extraCols = new ArrayList<String>();
@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()){ st += "|" + e.getKey() + " : " + e.getValue(); } //System.out.println(st); TestUtil.assertFuzzyContains("Section One", st); TestUtil.assertFuzzyContains("Section One Inner One", st); TestUtil.assertFuzzyContains("Section One Inner Two", st); TestUtil.assertFuzzyContains("no name specified", st); }
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "datatypeRenderingTest.xml")); List<String> extraCols = new ArrayList<String>();
/** * @return a new VelocityFunctions instance for the given patientId */ private VelocityFunctions setupFunctionsForPatient(Integer patientId) throws Exception { HtmlForm htmlform = new HtmlForm(); Form form = new Form(); form.setEncounterType(new EncounterType(1)); htmlform.setForm(form); htmlform.setDateChanged(new Date()); htmlform.setXmlData("<htmlform></htmlform>"); Patient p = new Patient(patientId); String[] datePattern = {"yyyy.MM.dd"}; p.setBirthdate(DateUtils.parseDate("1970.01.01",datePattern )); measureAgeInDaysAndMonths(new Date(), p.getBirthdate()); FormEntrySession session = new FormEntrySession(p, htmlform, null); return new VelocityFunctions(session); }
/** * calls session.createForm on a form that has both conceptIds with labels, and conceptIds without labels in obs tags. * Verifies that the dropdown options for selecting a concept are correctly labeled. * @throws Exception */ @Test @Verifies(value = "should test labels generation for concept selects on dropdown options", method = "") public void getSectionNodes_shouldReturnDropdownForConceptSelects() 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 + "obsGroupDataExportTest.xml")); FormEntrySession session = new FormEntrySession(HtmlFormEntryUtil.getFakePerson(), htmlform, null); String xml = session.createForm(htmlform.getXmlData()); // System.out.println(xml); Assert.assertTrue(xml.contains("<option value=\"\" selected=\"true\"></option><option value=\"2474\">Susc</option><option value=\"3017\">Interm</option>")); Assert.assertTrue(xml.contains("<option value=\"\" selected=\"true\"></option><option value=\"2474\">Susceptible</option><option value=\"3017\">Intermediate</option><option value=\"1441\">Resistant</option>")); }
@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); FormEntrySession session = new FormEntrySession(HtmlFormEntryUtil.getFakePerson(), htmlform, null); String html = session.getHtmlToDisplay(); System.out.println(html); TestUtil.assertFuzzyContains("<span class=\"sectionHeader\">Section One Inner One</span>", html); TestUtil.assertFuzzyContains("ISONIAZID <select id=\"w2\" name=\"w2\" size=\"1\"><option value=\"\" selected=\"true\"></option><option value=\"2474\">Susceptible</option><option value=\"3017\">Intermediate</option><option value=\"1441\">Resistant</option></select>", html); }
private HtmlForm copyOf(HtmlForm form) { HtmlForm copy = new HtmlForm(); copy.setChangedBy(form.getChangedBy()); copy.setCreator(form.getCreator()); copy.setDateChanged(form.getDateChanged()); copy.setDateCreated(form.getDateCreated()); copy.setDateRetired(form.getDateRetired()); copy.setForm(form.getForm()); copy.setId(form.getId()); copy.setRetired(form.getRetired()); copy.setRetiredBy(form.getRetiredBy()); copy.setRetireReason(form.getRetireReason()); copy.setUuid(form.getUuid()); copy.setXmlData(form.getXmlData()); return copy; }
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.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));
@Test @Verifies(value = "should return encounter with all child objects voided according to schema", method = "voidEncounterByHtmlFormSchema") public void testVoidEncounterByHtmlFormSchema_shouldReturnEncounterVoided() throws Exception { executeDataSet(XML_DATASET_PATH + new TestUtil().getTestDatasetFilename(XML_REGRESSION_TEST_DATASET)); Encounter e = new Encounter(); e.setPatient(Context.getPatientService().getPatient(2)); Date date = Context.getDateFormat().parse("01/02/2003"); e.setDateCreated(new Date()); e.setEncounterDatetime(date); e.setLocation(Context.getLocationService().getLocation(2)); e.setProvider(Context.getPersonService().getPerson(502)); //add a bunch of obs... TestUtil.addObs(e, 2474, Context.getConceptService().getConcept(656), date); //matches 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")); HtmlFormEntryUtil.voidEncounterByHtmlFormSchema(e, htmlform, null); //this is going to test out the voided state of the obs in the encounter after processing: Assert.assertTrue(e.isVoided()); }
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));
htmlform.setForm(form); form.setEncounterType(new EncounterType()); htmlform.setDateChanged(new Date()); htmlform.setXmlData(new TestUtil().loadXmlFromFile(XML_DATASET_PATH + "returnSectionsAndConceptsInSectionsTestFormWithGroups.xml"));