/** * Gets the context's data access object * * @return ContextDAO */ static ContextDAO getContextDAO() { if (contextDAO == null) { throw new APIException("error.context.null", (Object[]) null); } return contextDAO; }
/** * @see org.openmrs.hl7.HL7Service#retireHL7Source(org.openmrs.hl7.HL7Source) */ @Override public HL7Source retireHL7Source(HL7Source hl7Source) throws APIException { throw new APIException("general.not.yet.implemented", (Object[]) null); }
public void confirmNoKnownAllergies(){ if (!allergies.isEmpty()) { throw new APIException("Cannot confirm no known allergies if allergy list is not empty"); } allergyStatus = NO_KNOWN_ALLERGIES; }
/** * @param errorDetails The errorDetails to set. */ public void setErrorDetails(String errorDetails) { if (errorDetails != null && errorDetails.length() > MAX_ERROR_DETAILS_LENGTH) { throw new APIException("Hl7inError.error.details.length", new Object[] { errorDetails.length(), MAX_ERROR_DETAILS_LENGTH }); } this.errorDetails = errorDetails; }
/** * @see org.openmrs.api.AdministrationService#validate(java.lang.Object, Errors) */ @Override @Transactional(readOnly = true) public void validate(Object object, Errors errors) throws APIException { if (object == null) { throw new APIException("error.null", (Object[]) null); } dao.validate(object, errors); }
/** * Throws an exception if the given allergies collection has * an allergen similar to that of the given allergy * * @param allergy the given allergy * @param allergies the given allergies collection */ private void throwExceptionIfHasAllergen(Allergy allergy, Collection<? extends Allergy> allergies) { if (containsAllergen(allergy, allergies)) { throw new APIException("Duplicate allergens not allowed"); } }
/** * @see org.openmrs.api.UserService#purgeUser(org.openmrs.User, boolean) */ @Override public void purgeUser(User user, boolean cascade) throws APIException { if (cascade) { throw new APIException("cascade.do.not.think", (Object[]) null); } dao.deleteUser(user); }
/** * @see org.openmrs.api.PatientService#getDuplicatePatientsByAttributes(java.util.List) */ @Override @Transactional(readOnly = true) public List<Patient> getDuplicatePatientsByAttributes(List<String> attributes) throws APIException { if (attributes == null || attributes.isEmpty()) { throw new APIException("Patient.no.attribute", (Object[]) null); } return dao.getDuplicatePatientsByAttributes(attributes); }
/** * @see org.openmrs.hl7.HL7Service#getHL7InArchiveByUuid(java.lang.String) */ @Override @Transactional(readOnly = true) public HL7InArchive getHL7InArchiveByUuid(String uuid) throws APIException { if (Hl7InArchivesMigrateThread.isActive()) { throw new APIException("Hl7Service.cannot.fetch.archives", (Object[]) null); } return dao.getHL7InArchiveByUuid(uuid); }
/** * @see org.openmrs.api.PatientService#voidPatientIdentifier(org.openmrs.PatientIdentifier, * java.lang.String) */ @Override public PatientIdentifier voidPatientIdentifier(PatientIdentifier patientIdentifier, String reason) throws APIException { if (patientIdentifier == null || StringUtils.isBlank(reason)) { throw new APIException("Patient.identifier.cannot.be.null", (Object[]) null); } return Context.getPatientService().savePatientIdentifier(patientIdentifier); }
/** * @see org.openmrs.api.ProgramWorkflowService#purgePatientProgram(org.openmrs.PatientProgram, * boolean) */ @Override public void purgePatientProgram(PatientProgram patientProgram, boolean cascade) throws APIException { if (cascade && !patientProgram.getStates().isEmpty()) { throw new APIException("PatientProgram.cascade.purging.not.implemented", (Object[]) null); } dao.deletePatientProgram(patientProgram); }
/** * @see org.openmrs.api.UserService#purgePrivilege(org.openmrs.Privilege) */ @Override public void purgePrivilege(Privilege privilege) throws APIException { if (OpenmrsUtil.getCorePrivileges().keySet().contains(privilege.getPrivilege())) { throw new APIException("Privilege.cannot.delete.core", (Object[]) null); } dao.deletePrivilege(privilege); }
/** * @see org.openmrs.api.ConceptService#purgeConceptReferenceTerm(org.openmrs.ConceptReferenceTerm) */ @Override public void purgeConceptReferenceTerm(ConceptReferenceTerm conceptReferenceTerm) throws APIException { if (dao.isConceptReferenceTermInUse(conceptReferenceTerm)) { throw new APIException("ConceptRefereceTerm.inUse", (Object[]) null); } dao.deleteConceptReferenceTerm(conceptReferenceTerm); }
@Override public User saveUserProperties(Map<String, String> properties) { User user = Context.getAuthenticatedUser(); if (user == null) { throw new APIException("no.authenticated.user.found", (Object[]) null); } user.getUserProperties().clear(); for (Map.Entry<String, String> entry : properties.entrySet()) { user.setUserProperty(entry.getKey(), entry.getValue()); } return dao.saveUser(user, null); }
/** * @see org.openmrs.api.ConceptService#purgeConceptMapType(org.openmrs.ConceptMapType) */ @Override public void purgeConceptMapType(ConceptMapType conceptMapType) throws APIException { if (dao.isConceptMapTypeInUse(conceptMapType)) { throw new APIException("ConceptMapType.inUse", (Object[]) null); } dao.deleteConceptMapType(conceptMapType); }
@Override public User saveUserProperty(String key, String value) { User user = Context.getAuthenticatedUser(); if (user == null) { throw new APIException("no.authenticated.user.found", (Object[]) null); } user.setUserProperty(key, value); return dao.saveUser(user, null); }
@Override public void changePasswordUsingSecretAnswer(String secretAnswer, String pw) throws APIException { User user = Context.getAuthenticatedUser(); if(!isSecretAnswer(user, secretAnswer)) { throw new APIException("secret.answer.not.correct", (Object[]) null); } updatePassword(user, pw); }
/** * This method safely checks if authenticated user is not supposed to edit encounter of certain type * * @param encounter encounter which is to be edited * @throws APIException if not allowed to edit encounter */ private void failIfDeniedToEdit(Encounter encounter) throws APIException { if (!canEditEncounter(encounter, null)) { throw new APIException("Encounter.error.privilege.required.edit", new Object[] { encounter.getEncounterType() .getEditPrivilege() }); } }
private void ensureProgramIsSet(ProgramWorkflow workflow, Program program) { if (workflow.getProgram() == null) { workflow.setProgram(program); } else if (!workflow.getProgram().equals(program)) { throw new APIException("Program.error.contains.ProgramWorkflow", new Object[] { workflow.getProgram() }); } }
private void ensureProgramWorkflowIsSet(ProgramWorkflowState state, ProgramWorkflow workflow) { if (state.getProgramWorkflow() == null) { state.setProgramWorkflow(workflow); } else if (!state.getProgramWorkflow().equals(workflow)) { throw new APIException("ProgramWorkflow.error.contains.state", new Object[] { workflow.getProgram() }); } }