Codota Logo
ProgramWorkflowService.getProgram
Code IndexAdd Codota to your IDE (free)

How to use
getProgram
method
in
org.openmrs.api.ProgramWorkflowService

Best Java code snippets using org.openmrs.api.ProgramWorkflowService.getProgram (Showing top 20 results out of 315)

  • Common ways to obtain ProgramWorkflowService
private void myMethod () {
ProgramWorkflowService p =
  • Codota IconContext.getProgramWorkflowService()
  • Smart code suggestions by Codota
}
origin: openmrs/openmrs-core

/**
 * @see org.openmrs.api.ProgramWorkflowService#getPossibleOutcomes(Integer)
 */
@Override
@Transactional(readOnly = true)
public List<Concept> getPossibleOutcomes(Integer programId) {
  List<Concept> possibleOutcomes = new ArrayList<>();
  Program program = Context.getProgramWorkflowService().getProgram(programId);
  if (program == null) {
    return possibleOutcomes;
  }
  Concept outcomesConcept = program.getOutcomesConcept();
  if (outcomesConcept == null) {
    return possibleOutcomes;
  }
  if (!outcomesConcept.getAnswers().isEmpty()) {
    for (ConceptAnswer conceptAnswer : outcomesConcept.getAnswers()) {
      possibleOutcomes.add(conceptAnswer.getAnswerConcept());
    }
    return possibleOutcomes;
  }
  if (!outcomesConcept.getSetMembers().isEmpty()) {
    return outcomesConcept.getSetMembers();
  }
  return possibleOutcomes;
}

origin: openmrs/openmrs-core

} else {
  Integer programId = Integer.valueOf(text);
  setValue(Context.getProgramWorkflowService().getProgram(programId));
origin: openmrs/openmrs-core

if (program == null) {
  program = pws.getProgram(Integer.valueOf(progIdStr));
origin: openmrs/openmrs-core

/**
 * @see WorkflowCollectionEditor#setAsText(String)
 */
@Test
public void setAsText_shouldUpdateWorkflowsInProgram() {
  Program program = Context.getProgramWorkflowService().getProgram(1);
  WorkflowCollectionEditor editor = new WorkflowCollectionEditor();
  
  Assert.assertEquals(2, program.getWorkflows().size());
  
  editor.setAsText("1:3");
  
  Assert.assertEquals(1, program.getWorkflows().size());
  Assert.assertEquals(3, program.getWorkflows().iterator().next().getConcept().getConceptId().intValue());
  Assert.assertEquals(3, program.getAllWorkflows().size());
}

origin: openmrs/openmrs-core

/**
 * @see ProgramValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassValidationAndSaveEditedProgram() {
  Program program = Context.getProgramWorkflowService().getProgram(3);
  program.setDescription("Edited description");
  
  Errors errors = new BindException(program, "program");
  programValidator.validate(program, errors);
  
  Assert.assertFalse(errors.hasErrors());
  
  Context.getProgramWorkflowService().saveProgram(program);
  program = Context.getProgramWorkflowService().getProgram(3);
  
  Assert.assertTrue(program.getDescription().equals("Edited description"));
}

origin: openmrs/openmrs-core

@Test
public void purgeProgram_shouldPurgeProgramWithPatientsEnrolled() {
  Program program = Context.getProgramWorkflowService().getProgram(2);
  
  // program has at least one patient enrolled
  List<PatientProgram> patientPrograms = Context.getProgramWorkflowService().getPatientPrograms(null, program, null,
    null, null, null, true);
  assertTrue(patientPrograms.size() > 0);
  
  Context.getProgramWorkflowService().purgeProgram(program);
  
  // should cascade to patient programs
  for (PatientProgram patientProgram : patientPrograms) {
    assertNull(Context.getProgramWorkflowService().getPatientProgram(patientProgram.getId()));
  }
  // make sure that the program was deleted properly
  assertNull(Context.getProgramWorkflowService().getProgram(2));
}
@Test
origin: openmrs/openmrs-core

/**
 * @see StateConversionValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfConceptIsNullOrEmptyOrWhitespace() {
  ConceptStateConversion csc = new ConceptStateConversion();
  ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
  csc.setProgramWorkflow(workflow);
  csc.setProgramWorkflowState(workflow.getState(1));
  
  Errors errors = new BindException(csc, "csc");
  new StateConversionValidator().validate(csc, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("concept"));
}

origin: openmrs/openmrs-core

/**
 * @see StateConversionValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfProgramWorkflowStateIsNullOrEmptyOrWhitespace() {
  ConceptStateConversion csc = new ConceptStateConversion();
  
  ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
  csc.setConcept(Context.getConceptService().getConcept(3));
  csc.setProgramWorkflow(workflow);
  csc.setProgramWorkflowState(null);
  
  Errors errors = new BindException(csc, "csc");
  new StateConversionValidator().validate(csc, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("programWorkflowState"));
}

origin: openmrs/openmrs-core

/**
 * @see StateConversionValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailValidationIfProgramWorkflowIsNullOrEmptyOrWhitespace() {
  ConceptStateConversion csc = new ConceptStateConversion();
  csc.setProgramWorkflow(null);
  
  ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
  csc.setConcept(Context.getConceptService().getConcept(3));
  csc.setProgramWorkflowState(workflow.getState(1));
  
  Errors errors = new BindException(csc, "csc");
  new StateConversionValidator().validate(csc, errors);
  
  Assert.assertTrue(errors.hasFieldErrors("programWorkflow"));
}

origin: openmrs/openmrs-core

  /**
   * @see StateConversionValidator#validate(Object,Errors)
   */
  @Test
  public void validate_shouldPassValidationIfAllRequiredFieldsHaveProperValues() {
    ConceptStateConversion csc = new ConceptStateConversion();
    ProgramWorkflow workflow = Context.getProgramWorkflowService().getProgram(1).getAllWorkflows().iterator().next();
    csc.setConcept(Context.getConceptService().getConcept(3));
    csc.setProgramWorkflow(workflow);
    csc.setProgramWorkflowState(workflow.getState(1));
    
    Errors errors = new BindException(csc, "csc");
    new StateConversionValidator().validate(csc, errors);
    
    Assert.assertFalse(errors.hasErrors());
  }
}
origin: openmrs/openmrs-core

/**
 * @see PatientProgramValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldPassValidationIfFieldLengthsAreCorrect() {
  ProgramWorkflowService pws = Context.getProgramWorkflowService();
  Patient patient = Context.getPatientService().getPatient(6);
  
  PatientProgram pp = new PatientProgram();
  pp.setPatient(patient);
  pp.setProgram(pws.getProgram(1));
  pp.setDateEnrolled(new Date());
  
  pp.setVoidReason("voidReason");
  
  BindException errors = new BindException(pp, "program");
  new PatientProgramValidator().validate(pp, errors);
  Assert.assertEquals(false, errors.hasErrors());
}

origin: openmrs/openmrs-core

  /**
   * @see PatientProgramValidator#validate(Object,Errors)
   */
  @Test
  public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() {
    ProgramWorkflowService pws = Context.getProgramWorkflowService();
    Patient patient = Context.getPatientService().getPatient(6);
    
    PatientProgram pp = new PatientProgram();
    pp.setPatient(patient);
    pp.setProgram(pws.getProgram(1));
    pp.setDateEnrolled(new Date());
    
    pp
        .setVoidReason("too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text");
    
    BindException errors = new BindException(pp, "program");
    new PatientProgramValidator().validate(pp, errors);
    Assert.assertEquals(true, errors.hasFieldErrors("voidReason"));
  }
}
origin: openmrs/openmrs-core

/**
 * @see PatientProgramValidator#validate(Object,Errors)
 */
@Test
public void validate_shouldFailIfThereIsMoreThanOneStateWithANullStartDateInTheSameWorkflow() {
  ProgramWorkflowService pws = Context.getProgramWorkflowService();
  Patient patient = Context.getPatientService().getPatient(6);
  PatientProgram pp = new PatientProgram();
  pp.setPatient(patient);
  pp.setProgram(pws.getProgram(1));
  ProgramWorkflow testWorkflow = pp.getProgram().getWorkflow(1);
  
  //Add 2 other patient states with null start date		
  PatientState newPatientState1 = new PatientState();
  newPatientState1.setState(testWorkflow.getState(1));
  pp.getStates().add(newPatientState1);
  
  PatientState newPatientState2 = new PatientState();
  newPatientState2.setState(testWorkflow.getState(2));
  pp.getStates().add(newPatientState2);
  
  BindException errors = new BindException(pp, "");
  new PatientProgramValidator().validate(pp, errors);
  Assert.assertEquals(true, errors.hasFieldErrors("states"));
}

origin: openmrs/openmrs-core

/**
 * @see PatientProgramValidator#validate(Object,Errors)
 * this test is to specifically validate fix for https://tickets.openmrs.org/browse/TRUNK-3670
 */
@Test
public void validate_shouldNotFailIfPatientStateIsInRetiredWorkflow() {
  ProgramWorkflowService pws = Context.getProgramWorkflowService();
  Patient patient = Context.getPatientService().getPatient(6);
  
  // create a patient program
  PatientProgram pp = new PatientProgram();
  pp.setPatient(patient);
  pp.setProgram(pws.getProgram(1));
  
  // add a test workflow, and put the patient in a state in that workflow
  ProgramWorkflow testWorkflow = pp.getProgram().getWorkflow(1);
  PatientState newPatientState = new PatientState();
  newPatientState.setState(testWorkflow.getState(1));
  pp.getStates().add(newPatientState);
  
  // now retire the workflow
  testWorkflow.setRetired(true);
  testWorkflow.setRetiredBy(Context.getAuthenticatedUser());
  testWorkflow.setRetireReason("test");
  
  BindException errors = new BindException(pp, "");
  new PatientProgramValidator().validate(pp, errors);
  Assert.assertEquals(false, errors.hasFieldErrors("states"));
}

origin: openmrs/openmrs-module-htmlformentry

@Override
public void testResults(SubmissionResults results) {
  results.assertNoErrors();
  results.assertEncounterCreated();
  List<PatientProgram> pps = pws.getPatientPrograms(ps.getPatient(patientId), pws.getProgram(programId), null,
    null, null, null, false);
  Assert.assertEquals(1, pps.size());
  
  // make sure the state has been set
  Set<PatientState> states = pps.get(0).getStates();
  Assert.assertEquals(1, states.size());
  Assert.assertTrue(((PatientState) states.toArray()[0]).getState().equals(Context.getProgramWorkflowService().getStateByUuid("6de7ed10-53ad-11e1-8cb6-00248140a5eb")));
};
 
origin: openmrs/openmrs-module-htmlformentry

@SuppressWarnings("deprecation")
@Override
public Patient getPatient()  {
  Patient patient = Context.getPatientService().getPatient(2);
  Program program = Context.getProgramWorkflowService().getProgram(1);
  
  // as a sanity check, make sure the patient is currently enrolled in the program before we run the test
  Assert.assertTrue("Patient should be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
  
  return patient;
};
   
origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldPurgeARetiredProgram() throws Exception {
  
  Program program = service.getProgram(3);
  MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + program.getUuid());
  req.addParameter("purge", "true");
  handle(req);
  
  Assert.assertNull(service.getProgram(3));
}

origin: openmrs/openmrs-module-htmlformentry

/**
 * @see {@link HtmlFormEntryUtil#getState(String,Program)}
 */
@Test
@Verifies(value = "should return the state with the matching uuid", method = "getState(String,Program)")
public void getStateProgram_shouldReturnTheStateWithTheMatchingUuid() throws Exception {
  Assert.assertEquals("1",HtmlFormEntryUtil.getState("92584cdc-6a20-4c84-a659-e035e45d36b0", Context.getProgramWorkflowService().getProgram(1)).getId().toString());
}
 
origin: openmrs/openmrs-module-htmlformentry

/**
 * @see {@link HtmlFormEntryUtil#isEnrolledInProgramOnDate(Patient, Program, Date)}
 */
@Test
@Verifies(value = "should return false if the patient is not enrolled in the program", method = "isEnrolledInProgram(Patient,Program,Date)")
public void isEnrolledInProgram_shouldReturnFalseIfThePatientIsNotEnrolledInTheProgram() throws Exception {
  Patient patient = Context.getPatientService().getPatient(6);
  Program program = Context.getProgramWorkflowService().getProgram(1);
  Assert.assertFalse(HtmlFormEntryUtil.isEnrolledInProgramOnDate(patient, program, new Date()));
}
 
origin: openmrs/openmrs-module-htmlformentry

  public void testEditedResults(SubmissionResults results) {
    results.assertNoErrors();
    Assert.assertEquals(1, Context.getProgramWorkflowService().getPatientPrograms(patient, Context.getProgramWorkflowService().getProgram(10), null, null, null, null, false).size());
    // double check that state has been set
    ProgramWorkflowState state = Context.getProgramWorkflowService().getStateByUuid(START_STATE);
    PatientProgram patientProgram = getPatientProgramByState(results.getPatient(), state, DATE);
    PatientState patientState = getPatientState(patientProgram, state, DATE);
    Assert.assertNotNull(patientProgram);
    Assert.assertEquals(dateAsString(DATE), dateAsString(patientState.getStartDate()));
    Assert.assertEquals(dateAsString(PAST_DATE), dateAsString(patientProgram.getDateEnrolled()));
  }
}.run();
org.openmrs.apiProgramWorkflowServicegetProgram

Javadoc

Returns a program given that programs primary key programId A null value is returned if no program exists with this programId.

Popular methods of ProgramWorkflowService

  • getProgramByUuid
    Get a program by its uuid. There should be only one of these in the database. If multiple are found,
  • getPatientPrograms
    Returns PatientPrograms that match the input parameters. If an input parameter is set to null, the p
  • getStateByUuid
    Get a state by its uuid. There should be only one of these in the database. If multiple are found, a
  • getAllPrograms
    Returns all programs
  • getPatientProgramByUuid
    Get a patient program by its uuid. There should be only one of these in the database. If multiple ar
  • getProgramByName
    Returns a program given the program's exact name A null value is returned if there is no program wit
  • getWorkflowByUuid
    Get ProgramWorkflow by its UUID
  • savePatientProgram
    Save patientProgram to database (create if new or update if changed)
  • getPatientStateByUuid
    Get a program state by its uuid. There should be only one of these in the database. If multiple are
  • getProgramAttributeTypeByUuid
  • getWorkflow
    Get ProgramWorkflow by internal identifier.
  • purgePatientProgram
    Completely remove a patientProgram from the database (not reversible)
  • getWorkflow,
  • purgePatientProgram,
  • purgeProgram,
  • getAllProgramAttributeTypes,
  • getPatientProgram,
  • getPatientProgramAttributeByUuid,
  • getState,
  • purgeProgramAttributeType,
  • saveProgram

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSystemService (Context)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now