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