Search in sources :

Example 81 with Patient

use of org.openmrs.Patient in project openmrs-core by openmrs.

the class DiagnosisServiceImplTest method getDiagnoses_shouldGetDiagnosesOfPatientWithDate.

/**
 * @see DiagnosisService#getDiagnoses(Patient, Date)
 */
@Test
public void getDiagnoses_shouldGetDiagnosesOfPatientWithDate() {
    Calendar calendar = new GregorianCalendar(2015, 12, 1, 0, 0, 0);
    Patient patient = patientService.getPatient(2);
    List<Diagnosis> diagnoses = diagnosisService.getDiagnoses(patient, calendar.getTime());
    Assert.assertEquals(2, diagnoses.size());
    Assert.assertEquals("68802cce-6880-17e4-6880-a68804d22fb7", diagnoses.get(0).getUuid());
    Assert.assertEquals("688804ce-6880-8804-6880-a68804d88047", diagnoses.get(1).getUuid());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Patient(org.openmrs.Patient) Diagnosis(org.openmrs.Diagnosis) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 82 with Patient

use of org.openmrs.Patient in project openmrs-core by openmrs.

the class PatientServiceImplTest method checkPatientIdentifiers_shouldNotThrowMissingRequiredIdentifierGivenRequiredIdentifierTypesArePresent.

@Test
public void checkPatientIdentifiers_shouldNotThrowMissingRequiredIdentifierGivenRequiredIdentifierTypesArePresent() throws Exception {
    // given
    final String typeUuid = "equal type uuid";
    final PatientIdentifierType requiredIdentifierType = new PatientIdentifierType(12345);
    requiredIdentifierType.setUuid(typeUuid);
    final PatientIdentifierType patientIdentifierType = new PatientIdentifierType(12345);
    patientIdentifierType.setUuid(typeUuid);
    final List<PatientIdentifierType> requiredTypes = new ArrayList<>();
    requiredTypes.add(requiredIdentifierType);
    when(patientDaoMock.getPatientIdentifierTypes(any(), any(), any(), any())).thenReturn(requiredTypes);
    final Patient patientWithIdentifiers = new Patient();
    patientWithIdentifiers.addIdentifier(new PatientIdentifier("some identifier", patientIdentifierType, mock(Location.class)));
    final PatientIdentifierType anotherPatientIdentifier = new PatientIdentifierType(2345);
    anotherPatientIdentifier.setUuid("another type uuid");
    patientWithIdentifiers.addIdentifier(new PatientIdentifier("some identifier", anotherPatientIdentifier, mock(Location.class)));
    // when
    patientService.checkPatientIdentifiers(patientWithIdentifiers);
// then no exception
}
Also used : ArrayList(java.util.ArrayList) Patient(org.openmrs.Patient) Matchers.anyString(org.mockito.Matchers.anyString) PatientIdentifierType(org.openmrs.PatientIdentifierType) PatientIdentifier(org.openmrs.PatientIdentifier) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) PatientServiceTest(org.openmrs.api.PatientServiceTest)

Example 83 with Patient

use of org.openmrs.Patient in project openmrs-core by openmrs.

the class ConceptServiceTest method purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs.

/**
 * @see ConceptService#purgeConcept(Concept)
 */
@Test(expected = ConceptNameInUseException.class)
public void purgeConcept_shouldFailIfAnyOfTheConceptNamesOfTheConceptIsBeingUsedByAnObs() {
    Obs o = new Obs();
    o.setConcept(Context.getConceptService().getConcept(3));
    o.setPerson(new Patient(2));
    o.setEncounter(new Encounter(3));
    o.setObsDatetime(new Date());
    o.setLocation(new Location(1));
    ConceptName conceptName = new ConceptName(1847);
    o.setValueCodedName(conceptName);
    Context.getObsService().saveObs(o, null);
    // ensure that the association between the conceptName and the obs has been established
    Assert.assertEquals(true, conceptService.hasAnyObservation(conceptName));
    Concept concept = conceptService.getConceptByName("cd4 count");
    // make sure the name concept name exists
    Assert.assertNotNull(concept);
    conceptService.purgeConcept(concept);
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) Obs(org.openmrs.Obs) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) ConceptName(org.openmrs.ConceptName) Date(java.util.Date) Location(org.openmrs.Location) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 84 with Patient

use of org.openmrs.Patient in project openmrs-core by openmrs.

the class EncounterServiceTest method voidEncounter_shouldNotVoidProviders.

/**
 * @see EncounterService#voidEncounter(Encounter, String)
 */
@Test
public void voidEncounter_shouldNotVoidProviders() {
    EncounterService encounterService = Context.getEncounterService();
    Encounter encounter = new Encounter();
    encounter.setLocation(new Location(1));
    encounter.setEncounterType(new EncounterType(1));
    encounter.setEncounterDatetime(new Date());
    encounter.setPatient(new Patient(3));
    EncounterRole role = new EncounterRole();
    role.setName("role");
    role = encounterService.saveEncounterRole(role);
    Provider provider = new Provider();
    provider.setIdentifier("id1");
    provider.setPerson(newPerson("name"));
    provider = Context.getProviderService().saveProvider(provider);
    encounter.addProvider(role, provider);
    encounterService.saveEncounter(encounter);
    assertEquals(1, encounter.getProvidersByRoles().size());
    encounterService.voidEncounter(encounter, "reason");
    encounter = encounterService.getEncounter(encounter.getEncounterId());
    assertEquals(1, encounter.getProvidersByRoles().size());
}
Also used : Encounter(org.openmrs.Encounter) Patient(org.openmrs.Patient) EncounterRole(org.openmrs.EncounterRole) EncounterType(org.openmrs.EncounterType) Date(java.util.Date) Location(org.openmrs.Location) Provider(org.openmrs.Provider) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 85 with Patient

use of org.openmrs.Patient in project openmrs-core by openmrs.

the class HibernateDiagnosisDAOTest method shouldGetActiveDiagnosesWithFromDate.

@Test
public void shouldGetActiveDiagnosesWithFromDate() {
    Calendar calendar = new GregorianCalendar(2014, 1, 1, 13, 24, 56);
    assertEquals(1, diagnosisDAO.getActiveDiagnoses(new Patient(2), calendar.getTime()).size());
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) Patient(org.openmrs.Patient) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

Patient (org.openmrs.Patient)389 Test (org.junit.Test)345 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)284 Date (java.util.Date)106 PatientServiceImplTest (org.openmrs.api.impl.PatientServiceImplTest)91 Encounter (org.openmrs.Encounter)76 PatientIdentifier (org.openmrs.PatientIdentifier)60 Location (org.openmrs.Location)57 OrderUtilTest (org.openmrs.order.OrderUtilTest)47 PersonName (org.openmrs.PersonName)43 DrugOrder (org.openmrs.DrugOrder)42 BindException (org.springframework.validation.BindException)38 Concept (org.openmrs.Concept)37 Order (org.openmrs.Order)36 PatientIdentifierType (org.openmrs.PatientIdentifierType)33 Errors (org.springframework.validation.Errors)33 Visit (org.openmrs.Visit)29 ArrayList (java.util.ArrayList)28 Obs (org.openmrs.Obs)28 TestOrder (org.openmrs.TestOrder)28