Tabnine Logo
ProgramWorkflowService.getPatientProgramByUuid
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: openmrs/openmrs-core

/**
 * @see ProgramWorkflowService#getPatientProgramByUuid(String)
 */
@Test
public void getPatientProgramByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() {
  Assert.assertNull(Context.getProgramWorkflowService().getPatientProgramByUuid("some invalid uuid"));
}

origin: openmrs/openmrs-core

/**
 * @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());
}

origin: openmrs/openmrs-module-webservices.rest

@Override
public PatientProgram getByUniqueId(String uniqueId) {
  return Context.getProgramWorkflowService().getPatientProgramByUuid(uniqueId);
}

origin: openmrs/openmrs-module-webservices.rest

@Override
public PatientProgram newObject() {
  return Context.getProgramWorkflowService().getPatientProgramByUuid(getUuidProperty());
}

origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldUpdateTheDatesOfAProgramEnrollment() throws Exception {
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  SimpleObject params = new SimpleObject();
  String date = dateFormat.format(new Date());
  params.add("dateEnrolled", date);
  
  MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), params);
  SimpleObject result = deserialize(handle(req));
  
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotNull(result);
  Assert.assertEquals(dateFormat.format(patientProgram.getDateEnrolled()), date);
}

origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldPurgeAPatientProgram() throws Exception {
  Assert.assertNotNull(service.getPatientProgramByUuid(getUuid()));
  handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", "true")));
  Assert.assertNull(service.getPatientProgramByUuid(getUuid()));
}

origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldUpdateExistingState() throws Exception {
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  String existingStartDate = "2008-08-08";
  String stateStartDate = "2015-08-04";
  
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Set<PatientState> existingStates = patientProgram.getStates();
  Assert.assertEquals(1, existingStates.size());
  PatientState existingPatientState = existingStates.iterator().next();
  Assert.assertEquals(existingStartDate, dateFormat.format(existingPatientState.getStartDate()));
  
  String json = "{ \"states\": [{ \"uuid\": \"" + existingPatientState.getUuid() + "\", \"startDate\": \""
      + stateStartDate + "\"}]}";
  MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), SimpleObject.parseJson(json));
  SimpleObject result = deserialize(handle(req));
  
  patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotNull(result);
  Set<PatientState> actualPatientStates = patientProgram.getStates();
  Assert.assertEquals(1, actualPatientStates.size());
  Assert.assertEquals(stateStartDate, dateFormat.format(actualPatientStates.iterator().next().getStartDate()));
}

origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldGetAPatientProgramByUuid() throws Exception {
  MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + getUuid());
  SimpleObject result = deserialize(handle(req));
  
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotNull(result);
  Assert.assertEquals(patientProgram.getUuid(), PropertyUtils.getProperty(result, "uuid"));
  Assert.assertEquals(patientProgram.getPatient().getUuid(),
    ((Map) PropertyUtils.getProperty(result, "patient")).get("uuid"));
  Assert.assertEquals(patientProgram.getProgram().getUuid(),
    ((Map) PropertyUtils.getProperty(result, "program")).get("uuid"));
}

origin: openmrs/openmrs-module-htmlformentry

@SuppressWarnings("deprecation")
@Override
public void testResults(SubmissionResults results) {
  // do all the basic assertions to make sure the program was processed correctly
  results.assertNoErrors();
  results.assertEncounterCreated();
  results.assertProvider(502);
  results.assertLocation(2);
  
  // confirm that that patient is no longer in the program
  Patient patient = Context.getPatientService().getPatient(2);
  Program program = Context.getProgramWorkflowService().getProgram(1);
  Assert.assertFalse("Patient should no longer be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
  
  // but confirm that the patient was in the program in the past
  Assert.assertTrue("Patient should still be in program in the past", Context.getProgramWorkflowService().isInProgram(patient, program, null, new Date()));	
  
  // confirm that the proper program has been closed
  PatientProgram pp = Context.getProgramWorkflowService().getPatientProgramByUuid("32296060-03aa-102d-b0e3-001ec94a0cc5");
  Assert.assertTrue("Program completion date should be current date", TestUtil.dateEquals(new Date(), pp.getDateCompleted()));
};
origin: openmrs/openmrs-module-htmlformentry

@SuppressWarnings("deprecation")
@Override
public void testResults(SubmissionResults results) {
  // do all the basic assertions to make sure the program was processed correctly
  results.assertNoErrors();
  results.assertEncounterCreated();
  results.assertProvider(502);
  results.assertLocation(2);
  // confirm that that patient is no longer in the program
  Patient patient = Context.getPatientService().getPatient(2);
  Program program = Context.getProgramWorkflowService().getProgram(1);
  Assert.assertFalse("Patient should no longer be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
  // but confirm that the patient was in the program in the past
  Assert.assertTrue("Patient should still be in program in the past", Context.getProgramWorkflowService().isInProgram(patient, program, null, new Date()));
  // confirm that the proper program has been closed
  PatientProgram pp = Context.getProgramWorkflowService().getPatientProgramByUuid("32296060-03aa-102d-b0e3-001ec94a0cc5");
  Assert.assertTrue("Program completion date should be current date", TestUtil.dateEquals(new Date(), pp.getDateCompleted()));
};
origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldTransitPatientState() throws Exception {
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
  String stateStartDate = "2015-08-04";
  String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_8.STATE_UUID
      + "\"}, \"startDate\": \"" + stateStartDate + "\"}]}";
  
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertEquals(1, patientProgram.getStates().size());
  
  MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), SimpleObject.parseJson(json));
  SimpleObject result = deserialize(handle(req));
  
  patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotNull(result);
  List<PatientState> states = new ArrayList<PatientState>(patientProgram.getStates());
  Assert.assertEquals(2, states.size());
  sortPatientStatesBasedOnStartDate(states);
  Assert.assertEquals(RestTestConstants1_8.STATE_UUID, states.get(1).getState().getUuid());
  String existingStateEndDate = dateFormat.format(states.get(0).getEndDate());
  Assert.assertEquals(stateStartDate, existingStateEndDate);
}

origin: openmrs/openmrs-module-htmlformentry

@SuppressWarnings("deprecation")
@Override
public void testEditedResults(SubmissionResults results) {
  // do all the basic assertions to make sure the program was processed correctly
  results.assertNoErrors();
  results.assertEncounterCreated();
  results.assertProvider(502);
  results.assertLocation(2);
  
  // confirm that that patient is no longer in the program
  Patient patient = Context.getPatientService().getPatient(2);
  Program program = Context.getProgramWorkflowService().getProgram(1);
  Assert.assertFalse("Patient should no longer be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
  
  // but confirm that the patient was in the program in the past
  Assert.assertTrue("Patient should still be in program in the past", Context.getProgramWorkflowService().isInProgram(patient, program, null, new Date()));	
  
  // confirm that the proper program has been closed
  PatientProgram pp = Context.getProgramWorkflowService().getPatientProgramByUuid("32296060-03aa-102d-b0e3-001ec94a0cc5");
  Assert.assertTrue("Program completion date should be current date", TestUtil.dateEquals(new Date(), pp.getDateCompleted()));
};
 
origin: openmrs/openmrs-module-htmlformentry

@SuppressWarnings("deprecation")
@Override
public void testResults(SubmissionResults results) {
  // do all the basic assertions to make sure the program was processed correctly
  results.assertNoErrors();
  results.assertEncounterCreated();
  results.assertProvider(502);
  results.assertLocation(2);
  // confirm that that patient is no longer in the program
  Patient patient = Context.getPatientService().getPatient(8);
  Program program = Context.getProgramWorkflowService().getProgram(10);
  Assert.assertFalse("Patient should no longer be in program", Context.getProgramWorkflowService().isInProgram(patient, program, new Date(), null));
  // but confirm that the patient was in the program in the past
  Assert.assertTrue("Patient should still be in program in the past", Context.getProgramWorkflowService().isInProgram(patient, program, null, new Date()));
  // confirm that the proper program has been closed
  PatientProgram pp = Context.getProgramWorkflowService().getPatientProgramByUuid("31396060-03aa-102d-b0e3-001ec94a0cc5");
  Assert.assertTrue("Program completion date should be current date", TestUtil.dateEquals(new Date(), pp.getDateCompleted()));
  // Confirm that the patient program has the right outcome
  Assert.assertEquals("Program should have recorded outcome", Context.getConceptService().getConcept(4202), pp.getOutcome());
};
origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldVoidAPatientProgram() throws Exception {
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertTrue(!patientProgram.isVoided());
  
  handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("!purge", "random reason")));
  
  patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertTrue(patientProgram.isVoided());
}

origin: openmrs/openmrs-module-webservices.rest

@Test
public void shouldUnenrollAPatientFromAProgram() throws Exception {
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
  SimpleObject params = new SimpleObject();
  String dateString = dateFormat.format(new Date());
  
  params.add("dateCompleted", dateString);
  
  MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), params);
  SimpleObject result = deserialize(handle(req));
  
  PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotNull(result);
  Assert.assertEquals(dateFormat.format(patientProgram.getDateCompleted()), dateString);
  
  params.add("dateEnrolled", dateString);
  MockHttpServletRequest req1 = newPostRequest(getURI() + "/" + getUuid(), params);
  SimpleObject result1 = deserialize(handle(req));
  
  PatientProgram patientProgram1 = service.getPatientProgramByUuid(getUuid());
  Assert.assertNotEquals(dateFormat.format(patientProgram.getDateEnrolled()), dateString);
}

origin: openmrs/openmrs-module-webservices.rest

DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid());
Assert.assertEquals(1, patientProgram.getStates().size());
SimpleObject result = deserialize(handle(req));
patientProgram = service.getPatientProgramByUuid(getUuid());
Assert.assertNotNull(result);
List<PatientState> states = new ArrayList<PatientState>(patientProgram.getStates());
handle(req);
patientProgram = service.getPatientProgramByUuid(getUuid());
org.openmrs.apiProgramWorkflowServicegetPatientProgramByUuid

Javadoc

Get a patient program by its uuid. There should be only one of these in the database. If multiple are found, an error is thrown.

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
  • getProgram
    Returns a program given that programs primary key programId A null value is returned if no program e
  • 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

  • Updating database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • getExternalFilesDir (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • Path (java.nio.file)
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now