public static SerializableFormObject deserializeXml(String path) throws Exception { return deserializeXml(path,true); }
@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()); }
@Test @Verifies(value = "Should save archived form to the database", method = "reprocessArchivedForm") public void reprocessArchivedForm_shouldProcessForm() throws Exception { EncounterService encService = Context.getEncounterService(); String path = OpenmrsClassLoader.getInstance().getResource("archivedFormData.xml").getPath(); System.out.println("Path: "+path); //Get the SerializableFormObject SerializableFormObject formObject = SerializableFormObject.deserializeXml(path); Assert.assertEquals("da7f524f-27ce-4bb2-86d6-6d1d05312bd5",formObject.getPatientUuid()); Patient patient = Context.getPatientService().getPatientByUuid("da7f524f-27ce-4bb2-86d6-6d1d05312bd5"); int noEnc = encService.getEncountersByPatient(patient).size(); service.reprocessArchivedForm(path); int newNoEnc = encService.getEncountersByPatient(patient).size(); Assert.assertEquals(noEnc+1,newNoEnc); }