use of org.openmrs.GlobalProperty in project openmrs-module-mirebalais by PIH.
the class HibernateMirebalaisHospitalDAO method getNextRadiologyOrderNumberSeedSequenceValue.
/**
* @see org.openmrs.api.db.OrderDAO#getNextRadiologyOrderNumberSeedSequenceValue()
*/
@Override
public Long getNextRadiologyOrderNumberSeedSequenceValue() {
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(GlobalProperty.class);
searchCriteria.add(Restrictions.eq("property", MirebalaisConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED));
GlobalProperty globalProperty = (GlobalProperty) sessionFactory.getCurrentSession().get(GlobalProperty.class, MirebalaisConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED, LockOptions.UPGRADE);
if (globalProperty == null) {
throw new APIException("Missing global property named: " + MirebalaisConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED);
}
String gpTextValue = globalProperty.getPropertyValue();
if (StringUtils.isBlank(gpTextValue)) {
throw new APIException("Invalid value for global property named: " + MirebalaisConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED);
}
Long gpNumericValue = null;
try {
gpNumericValue = Long.parseLong(gpTextValue);
} catch (NumberFormatException ex) {
throw new APIException("Invalid value for global property named: " + MirebalaisConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED);
}
globalProperty.setPropertyValue(String.valueOf(gpNumericValue + 1));
sessionFactory.getCurrentSession().save(globalProperty);
return gpNumericValue;
}
use of org.openmrs.GlobalProperty in project openmrs-module-pihcore by PIH.
the class ConfigurationSetup method updateGlobalProperty.
private void updateGlobalProperty(String name, Object value) {
AdministrationService administrationService = Context.getAdministrationService();
GlobalProperty gp = administrationService.getGlobalPropertyObject(name);
if (gp == null) {
throw new RuntimeException("Failed to get global property object '" + name + "'. Cannot set it to " + value);
} else {
gp.setPropertyValue(value == null ? "" : value.toString());
administrationService.saveGlobalProperty(gp);
}
}
use of org.openmrs.GlobalProperty in project openmrs-module-pihcore by PIH.
the class CauseOfDeathListTagHandlerComponentTest method setUp.
@Before
public void setUp() throws Exception {
ConceptSource ciel = conceptSource("CIEL", "Columbia International eHealth Laboratory concept ID", null, CoreConceptMetadataBundle.ConceptSources.CIEL);
conceptService.saveConceptSource(ciel);
// for some reason, one of the other tests leaves the context dirty, and the locale set to "fr", which causes the tests to fail when matching obs
Context.setLocale(new Locale("en"));
unknownConcept = testData.concept().datatype("N/A").conceptClass("Misc").name("Unknown Concept").save();
administrationService.saveGlobalProperty(new GlobalProperty(HtmlFormEntryConstants.GP_UNKNOWN_CONCEPT, unknownConcept.getUuid()));
codedCauseConcept = testData.concept().datatype("Coded").conceptClass("Misc").name("CAUSE OF DEATH FROM DEATH CERTIFICATE").mapping("SAME-AS", "CIEL:1814").save();
nonCodedCauseConcept = testData.concept().datatype("Text").conceptClass("Misc").name("Probable cause of death (text)").mapping("SAME-AS", "CIEL:160218").save();
sequenceConcept = testData.conceptNumeric().datatype("Numeric").conceptClass("Misc").name("DIAGNOSIS SEQUENCE NUMBER").mapping("SAME-AS", "CIEL:1815").save();
groupingConcept = testData.concept().datatype("N/A").conceptClass("Misc").name("CAUSES OF DEATH FROM DEATH CERTIFICATE").mapping("SAME-AS", "CIEL:1816").setMembers(codedCauseConcept, nonCodedCauseConcept, sequenceConcept).save();
HtmlFormSetup.setupHtmlFormEntryTagHandlers();
}
use of org.openmrs.GlobalProperty in project openmrs-module-pihcore by PIH.
the class PihCoreDAO method getNextRadiologyOrderNumberSeedSequenceValue.
/**
* @see OrderDAO#getNextOrderNumberSeedSequenceValue() ()
*/
public Long getNextRadiologyOrderNumberSeedSequenceValue() {
String gp = PihCoreConstants.GP_NEXT_RADIOLOGY_ORDER_NUMBER_SEED;
Criteria searchCriteria = sessionFactory.getCurrentSession().createCriteria(GlobalProperty.class);
searchCriteria.add(Restrictions.eq("property", gp));
GlobalProperty globalProperty = (GlobalProperty) sessionFactory.getCurrentSession().get(GlobalProperty.class, gp, LockOptions.UPGRADE);
if (globalProperty == null) {
throw new APIException("Missing global property named: " + gp);
}
String gpTextValue = globalProperty.getPropertyValue();
if (StringUtils.isBlank(gpTextValue)) {
throw new APIException("Invalid value for global property named: " + gp);
}
Long gpNumericValue;
try {
gpNumericValue = Long.parseLong(gpTextValue);
} catch (NumberFormatException ex) {
throw new APIException("Invalid value for global property named: " + gp);
}
globalProperty.setPropertyValue(String.valueOf(gpNumericValue + 1));
sessionFactory.getCurrentSession().save(globalProperty);
return gpNumericValue;
}
use of org.openmrs.GlobalProperty in project openmrs-module-mirebalais by PIH.
the class MirebalaisHospitalActivator method updateGlobalProperty.
private void updateGlobalProperty(String name, Object value) {
AdministrationService administrationService = Context.getAdministrationService();
GlobalProperty gp = administrationService.getGlobalPropertyObject(name);
gp.setPropertyValue(value == null ? "" : value.toString());
administrationService.saveGlobalProperty(gp);
}
Aggregations