/** * @see * org.openmrs.module.patientflags.api.FlagService#savePatientFlagsProperties(PatientFlagsProperties) */ public void savePatientFlagsProperties(PatientFlagsProperties properties) { // save updated property values back to global_properties if (properties != null) { try { GlobalProperty patientHeaderDisplay = Context.getAdministrationService() .getGlobalPropertyObject("patientflags.patientHeaderDisplay"); patientHeaderDisplay.setPropertyValue(properties.getPatientHeaderDisplay().toString()); Context.getAdministrationService().saveGlobalProperty(patientHeaderDisplay); GlobalProperty patientOverviewDisplay = Context.getAdministrationService() .getGlobalPropertyObject("patientflags.patientOverviewDisplay"); patientOverviewDisplay.setPropertyValue(properties.getPatientOverviewDisplay().toString()); Context.getAdministrationService().saveGlobalProperty(patientOverviewDisplay); GlobalProperty username = Context.getAdministrationService().getGlobalPropertyObject("patientflags.username"); username.setPropertyValue(properties.getUsername()); Context.getAdministrationService().saveGlobalProperty(username); // refresh the cache so the privileges are updated if username changed refreshCache(); } catch (Throwable t) { throw new APIException( "Unable to update Patient Flags global properties. Try restarting Patient Flags module.", t); } } else { log.error("Cannot save Patient Flags properties - invalid PatientFlagsProperties object"); } }
/** @see org.openmrs.module.patientflags.api.FlagService#getPatientFlagsProperties() */ public PatientFlagsProperties getPatientFlagsProperties() { PatientFlagsProperties properties = new PatientFlagsProperties(); // initialize Patient Flags Properties based on values in global_properties String patientHeaderDisplay = Context.getAdministrationService().getGlobalProperty("patientflags.patientHeaderDisplay"); if (patientHeaderDisplay == null) { properties.setPatientHeaderDisplay(null); log.error( "Unable to initialize patientHeaderDisplay parameter, invalid or missing value in global_properties table."); } else if (patientHeaderDisplay.equals("true")) { properties.setPatientHeaderDisplay(true); } else if (patientHeaderDisplay.equals("false")) { properties.setPatientHeaderDisplay(false); } else { properties.setPatientHeaderDisplay(null); log.error( "Unable to initialize patientHeaderDisplay parameter, invalid or missing value in global_properties table."); } String patientOverviewDisplay = Context.getAdministrationService().getGlobalProperty("patientflags.patientOverviewDisplay"); if (patientOverviewDisplay == null) { properties.setPatientOverviewDisplay(null); log.error( "Unable to initialize patientOverviewDisplay parameter, invalid or missing value in global_properties table."); } else if (patientOverviewDisplay.equals("true")) { properties.setPatientOverviewDisplay(true); } else if (patientOverviewDisplay.equals("false")) { properties.setPatientOverviewDisplay(false); } else { properties.setPatientOverviewDisplay(null); log.error( "Unable to initialize patientOverviewDisplay parameter, invalid or missing value in global_properties table."); } String username = Context.getAdministrationService().getGlobalProperty("patientflags.username"); if (username == null) { properties.setUsername(null); log.error( "Unable to initialize username parameter, invalid or missing value in global_properties table."); } else { properties.setUsername(username); } return properties; }