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());
}
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
}
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);
}
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());
}
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());
}
Aggregations