Search in sources :

Example 66 with GlobalProperty

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

the class PatientServiceTest method getPatients_shouldAllowSearchStringToBeOneAccordingToMinsearchcharactersGlobalProperty.

/**
 * @see PatientService#getPatients(String)
 */
@Test
public void getPatients_shouldAllowSearchStringToBeOneAccordingToMinsearchcharactersGlobalProperty() throws Exception {
    initializeInMemoryDatabase();
    executeDataSet(FIND_PATIENTS_XML);
    updateSearchIndex();
    // make sure the default of "2" kicks in and blocks any results
    assertEquals(0, Context.getPatientService().getPatients("J").size());
    Context.clearSession();
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "1"));
    // there is a patient will middle name "F", so this should generate a hit.
    assertEquals(1, Context.getPatientService().getPatients("F").size());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 67 with GlobalProperty

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

the class PatientServiceTest method getPatients_shouldForceSearchStringToBeGreaterThanMinsearchcharactersGlobalProperty.

/**
 * @see PatientService#getPatients(String)
 */
@Test
public void getPatients_shouldForceSearchStringToBeGreaterThanMinsearchcharactersGlobalProperty() throws Exception {
    // make sure we can get patients with the default of 3
    assertEquals(1, Context.getPatientService().getPatients("Colle").size());
    Context.clearSession();
    Context.getAdministrationService().saveGlobalProperty(new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_MIN_SEARCH_CHARACTERS, "4"));
    assertEquals(0, Context.getPatientService().getPatients("Col").size());
}
Also used : GlobalProperty(org.openmrs.GlobalProperty) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) PatientServiceImplTest(org.openmrs.api.impl.PatientServiceImplTest) Test(org.junit.Test)

Example 68 with GlobalProperty

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

the class ProviderServiceTest method getUnknownProvider_shouldGetTheUnknownProviderAccount.

/**
 * @see ProviderService#getUnknownProvider()
 */
@Test
public void getUnknownProvider_shouldGetTheUnknownProviderAccount() {
    Provider provider = new Provider();
    provider.setPerson(newPerson("Unknown Provider"));
    provider.setIdentifier("Test Unknown Provider");
    provider = service.saveProvider(provider);
    GlobalProperty gp = new GlobalProperty(OpenmrsConstants.GP_UNKNOWN_PROVIDER_UUID, provider.getUuid(), null);
    Context.getAdministrationService().saveGlobalProperty(gp);
    assertEquals(provider, service.getUnknownProvider());
}
Also used : Provider(org.openmrs.Provider) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 69 with GlobalProperty

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

the class ORUR01HandlerTest method processMessage_shouldFailIfQuestionDatatypeIsCodedAndABooleanIsNotAValidAnswer.

/**
 * @see ORUR01Handler#processMessage(Message)
 */
@Test(expected = ApplicationException.class)
public void processMessage_shouldFailIfQuestionDatatypeIsCodedAndABooleanIsNotAValidAnswer() throws Exception {
    GlobalProperty trueConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_TRUE_CONCEPT, "7", "Concept id of the concept defining the TRUE boolean concept");
    GlobalProperty falseConceptGlobalProperty = new GlobalProperty(OpenmrsConstants.GLOBAL_PROPERTY_FALSE_CONCEPT, "8", "Concept id of the concept defining the TRUE boolean concept");
    Context.getAdministrationService().saveGlobalProperty(trueConceptGlobalProperty);
    Context.getAdministrationService().saveGlobalProperty(falseConceptGlobalProperty);
    String hl7string = "MSH|^~\\&|FORMENTRY|AMRS.ELD|HL7LISTENER|AMRS.ELD|20080226102656||ORU^R01|JqnfhKKtouEz8kzTk6Zo|P|2.5|1||||||||16^AMRS.ELD.FORMID\r" + "PID|||7^^^^||Collet^Test^Chebaskwony||\r" + "PV1||O|1^Unknown Location||||1^Super User (1-8)|||||||||||||||||||||||||||||||||||||20080212|||||||V\r" + "ORC|RE||||||||20080226102537|1^Super User\r" + "OBR|1|||1238^MEDICAL RECORD OBSERVATIONS^99DCT\r" + "OBX|2|NM|4^CIVIL STATUS^99DCT||1|||||||||20080206";
    Assert.assertEquals("Coded", Context.getConceptService().getConcept(4).getDatatype().getName());
    Message hl7message = parser.parse(hl7string);
    router.processMessage(hl7message);
}
Also used : Message(ca.uhn.hl7v2.model.Message) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Example 70 with GlobalProperty

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

the class ModuleFileParserTest method parse_shouldParseGlobalProperty.

@Test
public void parse_shouldParseGlobalProperty() throws IOException {
    GlobalProperty gp1 = new GlobalProperty("report.deleteReportsAgeInHours", "72", "delete reports after hours");
    GlobalProperty gp2 = new GlobalProperty("report.validateInput", "2", "to validate input", RegexValidatedTextDatatype.class, "^\\d+$");
    Document config = buildOnValidConfigXml().withGlobalProperty(gp1.getProperty(), gp1.getPropertyValue(), gp1.getDescription(), null, null).withGlobalProperty(gp2.getProperty(), gp2.getPropertyValue(), gp2.getDescription(), gp2.getDatatypeClassname(), gp2.getDatatypeConfig()).build();
    ModuleFileParser parser = new ModuleFileParser(writeConfigXmlToFile(config));
    Module module = parser.parse();
    assertThat(module.getGlobalProperties().size(), is(2));
    assertThat(module.getGlobalProperties().get(0).getProperty(), is(gp1.getProperty()));
    assertThat(module.getGlobalProperties().get(0).getPropertyValue(), is(gp1.getPropertyValue()));
    assertThat(module.getGlobalProperties().get(0).getDescription(), is(gp1.getDescription()));
    assertThat(module.getGlobalProperties().get(0).getDatatypeClassname(), is(gp1.getDatatypeClassname()));
    assertThat(module.getGlobalProperties().get(0).getDatatypeConfig(), is(gp1.getDatatypeConfig()));
    assertThat(module.getGlobalProperties().get(1).getProperty(), is(gp2.getProperty()));
    assertThat(module.getGlobalProperties().get(1).getPropertyValue(), is(gp2.getPropertyValue()));
    assertThat(module.getGlobalProperties().get(1).getDescription(), is(gp2.getDescription()));
    assertThat(module.getGlobalProperties().get(1).getDatatypeClassname(), is(gp2.getDatatypeClassname()));
    assertThat(module.getGlobalProperties().get(1).getDatatypeConfig(), is(gp2.getDatatypeConfig()));
}
Also used : Document(org.w3c.dom.Document) GlobalProperty(org.openmrs.GlobalProperty) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

GlobalProperty (org.openmrs.GlobalProperty)110 Test (org.junit.Test)80 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)77 Locale (java.util.Locale)14 OrderUtilTest (org.openmrs.order.OrderUtilTest)14 Encounter (org.openmrs.Encounter)12 ArrayList (java.util.ArrayList)11 User (org.openmrs.User)11 Patient (org.openmrs.Patient)10 AdministrationService (org.openmrs.api.AdministrationService)10 BindException (org.springframework.validation.BindException)10 DrugOrder (org.openmrs.DrugOrder)9 Errors (org.springframework.validation.Errors)9 CareSetting (org.openmrs.CareSetting)7 OrderType (org.openmrs.OrderType)7 Date (java.util.Date)6 EncounterType (org.openmrs.EncounterType)5 APIException (org.openmrs.api.APIException)5 MutableMessageSource (org.openmrs.messagesource.MutableMessageSource)4 MutableResourceBundleMessageSource (org.openmrs.messagesource.impl.MutableResourceBundleMessageSource)4