/** * @see org.openmrs.api.ProgramWorkflowService#purgeConceptStateConversion(org.openmrs.ConceptStateConversion) */ @Override public void purgeConceptStateConversion(ConceptStateConversion conceptStateConversion) throws APIException { Context.getProgramWorkflowService().purgeConceptStateConversion(conceptStateConversion, false); }
/** * @see org.openmrs.api.ProgramWorkflowService#getAllPrograms() */ @Override @Transactional(readOnly = true) public List<Program> getAllPrograms() throws APIException { return Context.getProgramWorkflowService().getAllPrograms(true); }
@Override protected ProgramWorkflow getObjectByUuid(String uuid) { return Context.getProgramWorkflowService().getWorkflowByUuid(uuid); } }
/** * @see org.openmrs.api.ProgramWorkflowService#voidPatientProgram(org.openmrs.PatientProgram, * java.lang.String) */ @Override public PatientProgram voidPatientProgram(PatientProgram patientProgram, String reason) { patientProgram.setVoided(true); patientProgram.setVoidReason(reason); return Context.getProgramWorkflowService().savePatientProgram(patientProgram); // The savePatientProgram method handles all of the voiding defaults and cascades }
/** * @see ProgramWorkflowService#getPatientStateByUuid(String) */ @Test public void getPatientStateByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getProgramWorkflowService().getPatientStateByUuid("some invalid uuid")); }
/** * @see ProgramWorkflowService#getProgramByUuid(String) */ @Test public void getProgramByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getProgramWorkflowService().getProgramByUuid("some invalid uuid")); }
@Test public void getPossibleOutcomes_shouldGetOutcomesForASet() { executeDataSet(PROGRAM_WITH_OUTCOMES_XML); List<Concept> possibleOutcomes = Context.getProgramWorkflowService().getPossibleOutcomes(4); assertEquals(4, possibleOutcomes.size()); }
/** * @see ProgramWorkflowService#getStateByUuid(String) */ @Test public void getStateByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { Assert.assertNull(Context.getProgramWorkflowService().getStateByUuid("some invalid uuid")); }
@Test public void getPossibleOutcomes_shouldGetOutcomesForAQuestion() { executeDataSet(PROGRAM_WITH_OUTCOMES_XML); List<Concept> possibleOutcomes = Context.getProgramWorkflowService().getPossibleOutcomes(5); assertEquals(2, possibleOutcomes.size()); }
@Test public void getPossibleOutcomes_shouldReturnEmptyListWhenProgramHasNoOutcome() { executeDataSet(PROGRAM_WITH_OUTCOMES_XML); List<Concept> possibleOutcomes = Context.getProgramWorkflowService().getPossibleOutcomes(1); assertTrue(possibleOutcomes.isEmpty()); }
/** * @see ProgramWorkflowService#getStateByUuid(String) */ @Test public void getStateByUuid_shouldFindObjectGivenValidUuid() { String uuid = "92584cdc-6a20-4c84-a659-e035e45d36b0"; ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(uuid); Assert.assertEquals(1, (int) state.getProgramWorkflowStateId()); }
/** * @see ProgramWorkflowService#getProgramByUuid(String) */ @Test public void getProgramByUuid_shouldFindObjectGivenValidUuid() { String uuid = "eae98b4c-e195-403b-b34a-82d94103b2c0"; Program program = Context.getProgramWorkflowService().getProgramByUuid(uuid); Assert.assertEquals(1, (int) program.getProgramId()); }
/** * @see ProgramWorkflowService#getPatientProgramByUuid(String) */ @Test public void getPatientProgramByUuid_shouldFindObjectGivenValidUuid() { String uuid = "2edf272c-bf05-4208-9f93-2fa213ed0415"; PatientProgram patientProgram = Context.getProgramWorkflowService().getPatientProgramByUuid(uuid); Assert.assertEquals(2, (int) patientProgram.getPatientProgramId()); }
/** * @see ProgramWorkflowService#getPatientStateByUuid(String) */ @Test public void getPatientStateByUuid_shouldFindObjectGivenValidUuid() { String uuid = "ea89deaa-23cc-4840-92fe-63d199c37e4c"; PatientState patientState = Context.getProgramWorkflowService().getPatientStateByUuid(uuid); Assert.assertEquals(1, (int) patientState.getPatientStateId()); }
/** * @see ProgramWorkflowService#getConceptStateConversionByUuid(String) */ @Test public void getConceptStateConversionByUuid_shouldFindObjectGivenValidUuid() { String uuid = "6c72b064-506d-11de-80cb-001e378eb67e"; ConceptStateConversion conceptStateConversion = Context.getProgramWorkflowService().getConceptStateConversionByUuid( uuid); Assert.assertEquals(1, (int) conceptStateConversion.getConceptStateConversionId()); }
/** * @see ProgramWorkflowService#getWorkflowByUuid(String) */ @Test public void getWorkflowByUuid_shouldFindObjectGivenValidUuid() { String uuid = "84f0effa-dd73-46cb-b931-7cd6be6c5f81"; ProgramWorkflow programWorkflow = Context.getProgramWorkflowService().getWorkflowByUuid(uuid); Assert.assertEquals(1, (int) programWorkflow.getProgramWorkflowId()); }
/** * @see PatientProgramValidator#validate(Object,Errors) */ @Test public void validate_shouldFailIfPatientProgramEnrolledDateIsInFuture() { PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1); Date date10DaysAfterSystemCurrentDate = new Date(System.currentTimeMillis() + 10 * 24 * 60 * 60 * 1000); program.setDateEnrolled(date10DaysAfterSystemCurrentDate); BindException errors = new BindException(program, ""); new PatientProgramValidator().validate(program, errors); Assert.assertTrue(errors.hasFieldErrors("dateEnrolled")); }
/** * @see PatientProgramValidator#validate(Object,Errors) */ @Test public void validate_shouldFailIfPatientProgramEndDateIsInFuture() { PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1); Date date10DaysAfterSystemCurrentDate = new Date(System.currentTimeMillis() + 10 * 24 * 60 * 60 * 1000); program.setDateCompleted(date10DaysAfterSystemCurrentDate); BindException errors = new BindException(program, ""); new PatientProgramValidator().validate(program, errors); Assert.assertTrue(errors.hasFieldErrors("dateCompleted")); }
/** * @see PatientProgramValidator#validate(Object,Errors) */ @Test public void validate_shouldFailIfAnyPatientStateHasANullWorkFlowState() { PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1); PatientState patientState = program.getStates().iterator().next(); patientState.setState(null); BindException errors = new BindException(program, ""); new PatientProgramValidator().validate(program, errors); Assert.assertTrue(errors.hasFieldErrors("states")); }
/** * @see PatientProgramValidator#validate(Object,Errors) */ @Test public void validate_shouldFailIfPatientProgramEnrollDateIsEmpty() { PatientProgram program = Context.getProgramWorkflowService().getPatientProgram(1); program.setDateEnrolled(null); BindException errors = new BindException(program, ""); new PatientProgramValidator().validate(program, errors); Assert.assertTrue(errors.hasFieldErrors("dateEnrolled")); }