Search in sources :

Example 11 with Patient

use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.

the class VitalsDataSetManagerTest method setup.

@Before
@Override
public void setup() throws Exception {
    super.setup();
    Patient p = createPatient("X3XK71");
    Encounter e = createVitalsEncounter(p);
    visit = createVisit(e);
}
Also used : Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) Before(org.junit.Before)

Example 12 with Patient

use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.

the class PihPatientSearchAlgorithmTest method shouldExcludeVoidedPatients.

@Test
public void shouldExcludeVoidedPatients() {
    Patient patientToVoid = patientService.getPatient(13);
    patientService.voidPatient(patientToVoid, "test");
    Context.flushSession();
    Patient patient = new Patient();
    PersonName name = new PersonName();
    patient.addName(name);
    name.setGivenName("Jarusz");
    name.setFamilyName("Rapondee");
    patient.setBirthdate(new Date());
    patient.setGender("M");
    List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
    assertThat(results.size(), is(0));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 13 with Patient

use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.

the class PihPatientSearchAlgorithmTest method exactPersonAttributeFieldMatchShouldIncreaseScore.

@Test
public void exactPersonAttributeFieldMatchShouldIncreaseScore() {
    // first get the base score for this patient
    Patient patient = new Patient();
    PersonName name = new PersonName();
    patient.addName(name);
    name.setGivenName("Jarusz");
    name.setFamilyName("Rapondee");
    patient.setBirthdate(new Date());
    patient.setGender("M");
    List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
    double scoreWithoutAddress = results.get(0).getScore();
    // now add in address and recalculate
    PersonAttribute attribute = new PersonAttribute();
    attribute.setAttributeType(personService.getPersonAttributeTypeByName("Birthplace"));
    attribute.setValue("boston");
    patient.addAttribute(attribute);
    results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
    double scoreWithAddress = results.get(0).getScore();
    // in our test config we've weighed birthplace at 1 point
    assertThat(scoreWithAddress - scoreWithoutAddress, is(1.0));
    assertTrue(results.get(0).getMatchedFields().contains("attributes.Birthplace"));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) PersonAttribute(org.openmrs.PersonAttribute) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 14 with Patient

use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.

the class PihPatientSearchAlgorithmTest method shouldFindNamePhoneticsMatch.

@Test
public void shouldFindNamePhoneticsMatch() {
    Patient patient = new Patient();
    PersonName name = new PersonName();
    patient.addName(name);
    name.setGivenName("Jarusz");
    name.setFamilyName("Rapondee");
    patient.setBirthdate(new Date());
    patient.setGender("M");
    List<PatientAndMatchQuality> results = searchAlgorithm.findSimilarPatients(patient, null, null, 10);
    assertThat(results.size(), is(1));
    assertThat(results.get(0).getPatient().getPersonName().getGivenName(), is("Jarus"));
    assertThat(results.get(0).getPatient().getPersonName().getFamilyName(), is("Rapondi"));
}
Also used : PersonName(org.openmrs.PersonName) PatientAndMatchQuality(org.openmrs.module.registrationcore.api.search.PatientAndMatchQuality) Patient(org.openmrs.Patient) Date(java.util.Date) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

Example 15 with Patient

use of org.openmrs.Patient in project openmrs-module-pihcore by PIH.

the class PihCloseStaleVisitsTaskTest method test_shouldNotCloseVisitIfMostRecentDispositionKeepsVisitOpen.

@Test
public void test_shouldNotCloseVisitIfMostRecentDispositionKeepsVisitOpen() throws Exception {
    ContextSensitiveMetadataTestUtils.setupDispositionDescriptor(conceptService, dispositionService);
    ContextSensitiveMetadataTestUtils.setupAdmissionDecisionConcept(conceptService, emrApiProperties);
    ContextSensitiveMetadataTestUtils.setupSupportsVisitLocationTag(locationService);
    // patient already has one visit in test dataset
    Patient patient = patientService.getPatient(7);
    // need o tag the unknown location so we don't run into an error when testing against the existing visits in the test dataset
    Location unknownLocation = locationService.getLocation(1);
    unknownLocation.addTag(emrApiProperties.getSupportsVisitsLocationTag());
    locationService.saveLocation(unknownLocation);
    Location location = locationService.getLocation(2);
    location.addTag(emrApiProperties.getSupportsVisitsLocationTag());
    locationService.saveLocation(location);
    Visit visit = new Visit();
    visit.setStartDatetime(DateUtils.addHours(new Date(), -14));
    visit.setPatient(patient);
    visit.setLocation(location);
    visit.setVisitType(emrApiProperties.getAtFacilityVisitType());
    // create an encounter with a disposition obs
    Encounter encounter = new Encounter();
    encounter.setPatient(patient);
    encounter.setEncounterType(encounterService.getEncounterType(1));
    encounter.setEncounterDatetime(visit.getStartDatetime());
    Obs dispositionObsGroup = new Obs();
    dispositionObsGroup.setConcept(dispositionService.getDispositionDescriptor().getDispositionSetConcept());
    Obs dispositionObs = new Obs();
    dispositionObs.setConcept(dispositionService.getDispositionDescriptor().getDispositionConcept());
    // this fake code is set in ContextSensitiveMetadataTestUtils
    dispositionObs.setValueCoded(emrConceptService.getConcept(EmrApiConstants.EMR_CONCEPT_SOURCE_NAME + ":Admit to hospital"));
    dispositionObsGroup.addGroupMember(dispositionObs);
    encounter.addObs(dispositionObsGroup);
    encounterService.saveEncounter(encounter);
    visit.addEncounter(encounter);
    visitService.saveVisit(visit);
    VisitDomainWrapper activeVisit = adtService.getActiveVisit(patient, location);
    // sanity check
    assertNotNull(activeVisit);
    new PihCloseStaleVisitsTask().execute();
    activeVisit = adtService.getActiveVisit(patient, location);
    assertNotNull(activeVisit);
}
Also used : Obs(org.openmrs.Obs) Visit(org.openmrs.Visit) Patient(org.openmrs.Patient) Encounter(org.openmrs.Encounter) VisitDomainWrapper(org.openmrs.module.emrapi.visit.VisitDomainWrapper) Date(java.util.Date) Location(org.openmrs.Location) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.Test)

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