Context.getHL7Service().processHL7InQueue(hl7InQueue);
/** * @throws HL7Exception * @see HL7Service#processHL7InQueue(HL7InQueue) */ @Test(expected = HL7Exception.class) public void processHL7InQueue_shouldFailIfGivenInQueueIsAlreadyMarkedAsProcessing() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); HL7Service hl7service = Context.getHL7Service(); HL7InQueue queueItem = hl7service.getHL7InQueue(1); queueItem.setMessageState(HL7Constants.HL7_STATUS_PROCESSING); // set this to processing hl7service.processHL7InQueue(queueItem); }
/** * @throws HL7Exception * @see HL7Service#processHL7InQueue(HL7InQueue) */ @Test public void processHL7InQueue_shouldCreateHL7InErrorAfterFailedParsing() throws HL7Exception { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); // sanity check, make sure there aren't any error items HL7Service hl7service = Context.getHL7Service(); Assert.assertEquals(0, hl7service.getAllHL7InErrors().size()); HL7InQueue queueItem = hl7service.getHL7InQueue(2); hl7service.processHL7InQueue(queueItem); Assert.assertEquals(1, hl7service.getAllHL7InErrors().size()); }
/** * @throws HL7Exception * @throws IOException * @see HL7Service#processHL7InQueue(HL7InQueue) */ @Test public void processHL7InQueue_shouldCreateHL7InArchiveAfterSuccessfulParsing() throws HL7Exception, IOException { executeDataSet("org/openmrs/hl7/include/ORUTest-initialData.xml"); File tempDir = new File(System.getProperty("java.io.tmpdir"), HL7Constants.HL7_ARCHIVE_DIRECTORY_NAME); if (tempDir.exists() && tempDir.isDirectory()) Assert.assertEquals(true, OpenmrsUtil.deleteDirectory(tempDir)); //set a global property for the archives directory as a temporary folder GlobalProperty gp = new GlobalProperty(); gp.setProperty(OpenmrsConstants.GLOBAL_PROPERTY_HL7_ARCHIVE_DIRECTORY); gp.setPropertyValue(tempDir.getAbsolutePath()); gp.setDescription("temp test dir"); Context.getAdministrationService().saveGlobalProperty(gp); HL7Service hl7service = Context.getHL7Service(); Assert.assertEquals(0, hl7service.getAllHL7InArchives().size()); HL7InQueue queueItem = hl7service.getHL7InQueue(1); hl7service.processHL7InQueue(queueItem); Assert.assertEquals(1, hl7service.getAllHL7InArchives().size()); }
hl7service.processHL7InQueue(queueItem);
Assert.assertEquals(0, service.getAllHL7InArchives().size()); service.processHL7InQueue(service.getAllHL7InQueues().get(0));