Search in sources :

Example 36 with PersonAttributeType

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

the class PersonServiceTest method purgePersonAttributeType_shouldThrowAnErrorWhileTryingToDeletePersonAttributeTypeWhenPersonAttributeTypesAreLocked.

/**
 * @see PersonService#purgePersonAttributeType(PersonAttributeType)
 * @throws PersonAttributeTypeLockedException
 */
@Test(expected = PersonAttributeTypeLockedException.class)
public void purgePersonAttributeType_shouldThrowAnErrorWhileTryingToDeletePersonAttributeTypeWhenPersonAttributeTypesAreLocked() throws Exception {
    PersonService ps = Context.getPersonService();
    createPersonAttributeTypeLockedGPAndSetValue("true");
    PersonAttributeType pat = ps.getPersonAttributeType(1);
    ps.purgePersonAttributeType(pat);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 37 with PersonAttributeType

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

the class PersonServiceTest method shouldUnretirePersonAttributeType.

@Test
public void shouldUnretirePersonAttributeType() {
    PersonAttributeType pat = personService.getPersonAttributeType(RETIRED_PERSON_ATTRIBUTE_TYPE);
    personService.unretirePersonAttributeType(pat);
    PersonAttributeType unretiredPat = personService.getPersonAttributeType(UNRETIRED_PERSON_ATTRIBUTE_TYPE);
    assertFalse(unretiredPat.getRetired());
    assertNull(unretiredPat.getRetiredBy());
    assertNull(unretiredPat.getRetireReason());
    assertNull(unretiredPat.getDateRetired());
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 38 with PersonAttributeType

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

the class PersonServiceTest method getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesExcludingRetiredWhenIncludeRetiredIsFalse.

/**
 * @see PersonService#getAllPersonAttributeTypes(null)
 */
@Test
public void getAllPersonAttributeTypes_shouldReturnAllPersonAttributeTypesExcludingRetiredWhenIncludeRetiredIsFalse() throws Exception {
    executeDataSet("org/openmrs/api/include/PersonServiceTest-createRetiredPersonAttributeType.xml");
    List<PersonAttributeType> attributeTypes = Context.getPersonService().getAllPersonAttributeTypes(false);
    assertTrue("At least one element, otherwise no checking for retired will take place", attributeTypes.size() > 0);
    boolean foundRetired = false;
    for (PersonAttributeType personAttributeType : attributeTypes) {
        if (personAttributeType.getRetired()) {
            foundRetired = true;
            break;
        }
    }
    Assert.assertFalse("There should be no retired person attribute type found in the list", foundRetired);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 39 with PersonAttributeType

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

the class PersonDAOTest method getSavedPersonAttributeTypeName_shouldGetSavedPersonAttributeTypeNameFromDatabase.

/**
 * @see PersonDAO#getSavedPersonAttributeTypeName(org.openmrs.PersonAttributeType)
 */
@Test
public void getSavedPersonAttributeTypeName_shouldGetSavedPersonAttributeTypeNameFromDatabase() {
    PersonAttributeType pat = Context.getPersonService().getPersonAttributeType(1);
    // save the name from the db for later checks
    String origName = pat.getName();
    String newName = "Race Updated";
    assertFalse(newName.equals(origName));
    // change the name on the java pojo (NOT in the database)
    pat.setName(newName);
    // the value from the database should match the original name from the
    // pat right after /it/ was fetched from the database
    String nameFromDatabase = dao.getSavedPersonAttributeTypeName(pat);
    assertEquals(origName, nameFromDatabase);
}
Also used : PersonAttributeType(org.openmrs.PersonAttributeType) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 40 with PersonAttributeType

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

the class LegacyMasterPatientIndexSetup method setupConnectionToMasterPatientIndex.

public static void setupConnectionToMasterPatientIndex(RuntimeProperties customProperties) {
    String url = customProperties.getLacollineServerUrl();
    String username = customProperties.getLacollineUsername();
    String password = customProperties.getLacollinePassword();
    if (url == null || username == null || password == null) {
        log.warn("Not configuring link to Lacolline server (url, username, and password are required)");
        return;
    }
    Map<String, PatientIdentifierType> identifierTypeMap = new HashMap<String, PatientIdentifierType>();
    identifierTypeMap.put("a541af1e-105c-40bf-b345-ba1fd6a59b85", Context.getPatientService().getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_ZLEMRID_UUID));
    // TODO create PatientIdentifierType for Lacolline KE dossier number
    identifierTypeMap.put("e66645eb-03a8-4991-b4ce-e87318e37566", Context.getPatientService().getPatientIdentifierTypeByUuid(ZlConfigConstants.PATIENTIDENTIFIERTYPE_EXTERNALDOSSIERNUMBER_UUID));
    // TODO create PatientIdentifierType for Lacolline dental dossier number
    Map<String, Location> locationMap = new HashMap<String, Location>();
    locationMap.put("23e7bb0d-51f9-4d5f-b34b-2fbbfeea1960", Context.getLocationService().getLocationByUuid(LACOLLINE_LOCATION_UUID));
    Map<String, PersonAttributeType> attributeTypeMap = new HashMap<String, PersonAttributeType>();
    attributeTypeMap.put("340d04c4-0370-102d-b0e3-001ec94a0cc1", Metadata.getPhoneNumberAttributeType());
    RemoteServerConfiguration config = new RemoteServerConfiguration();
    config.setUrl(url);
    config.setUsername(username);
    config.setPassword(password);
    config.setIdentifierTypeMap(identifierTypeMap);
    config.setLocationMap(locationMap);
    config.setAttributeTypeMap(attributeTypeMap);
    Context.getService(ImportPatientFromWebService.class).registerRemoteServer("lacolline", config);
}
Also used : RemoteServerConfiguration(org.openmrs.module.importpatientfromws.api.RemoteServerConfiguration) HashMap(java.util.HashMap) PersonAttributeType(org.openmrs.PersonAttributeType) PatientIdentifierType(org.openmrs.PatientIdentifierType) Location(org.openmrs.Location) ImportPatientFromWebService(org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService)

Aggregations

PersonAttributeType (org.openmrs.PersonAttributeType)40 Test (org.junit.Test)33 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)33 BindException (org.springframework.validation.BindException)7 Errors (org.springframework.validation.Errors)7 PersonAttribute (org.openmrs.PersonAttribute)4 Location (org.openmrs.Location)3 PatientIdentifierType (org.openmrs.PatientIdentifierType)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Patient (org.openmrs.Patient)2 ImportPatientFromWebService (org.openmrs.module.importpatientfromws.api.ImportPatientFromWebService)2 RemoteServerConfiguration (org.openmrs.module.importpatientfromws.api.RemoteServerConfiguration)2 DLD (ca.uhn.hl7v2.model.v25.datatype.DLD)1 IS (ca.uhn.hl7v2.model.v25.datatype.IS)1 File (java.io.File)1 URL (java.net.URL)1 Random (java.util.Random)1 Ignore (org.junit.Ignore)1 GlobalProperty (org.openmrs.GlobalProperty)1