use of org.akaza.openclinica.bean.managestudy.SubjectTransferBean in project OpenClinica by OpenClinica.
the class CctsSubjectEndpoint method rollBackSubject.
/**
* if NAMESPACE_URI_V1:commitRequest execute this method
* @param gridId
* @param subject
* @param studyOid
* @return
* @throws Exception
*/
@PayloadRoot(localPart = "rollbackRequest", namespace = NAMESPACE_URI_V1)
public Source rollBackSubject(@XPathParam("//s:gridId") String gridId, @XPathParam("//s:subject") NodeList subject, @XPathParam("//s:study/@oid") String studyOid) throws Exception {
Element subjectElement = (Element) (subject.item(0));
SubjectTransferBean subjectTranferBean = unMarshallToSubjectTransfer(gridId, subjectElement, studyOid);
// TODO: Add Logic
return new DOMSource(mapConfirmation(SUCCESS_MESSAGE));
}
use of org.akaza.openclinica.bean.managestudy.SubjectTransferBean in project OpenClinica by OpenClinica.
the class CctsSubjectEndpoint method createSubject.
/**
* if NAMESPACE_URI_V1:commitRequest execute this method
* @param gridId
* @param subject
* @param studyOid
* @return
* @throws Exception
*/
@PayloadRoot(localPart = "commitRequest", namespace = NAMESPACE_URI_V1)
public Source createSubject(@XPathParam("//s:gridId") String gridId, @XPathParam("//s:subject") NodeList subject, @XPathParam("//s:study/@oid") String studyOid) throws Exception {
Element subjectElement = (Element) (subject.item(0));
SubjectTransferBean subjectTranferBean = unMarshallToSubjectTransfer(gridId, subjectElement, studyOid);
// TODO: Add Logic
logger.debug("In CreateSubject");
return new DOMSource(mapConfirmation(SUCCESS_MESSAGE));
}
use of org.akaza.openclinica.bean.managestudy.SubjectTransferBean in project OpenClinica by OpenClinica.
the class SubjectTransferDAO method getEntityFromHashMap.
public Object getEntityFromHashMap(HashMap hm) {
SubjectTransferBean subjectTransferBean = new SubjectTransferBean();
subjectTransferBean.setId((Integer) hm.get("subject_transfer_id"));
subjectTransferBean.setPersonId((String) hm.get("person_id"));
subjectTransferBean.setStudySubjectId((String) hm.get("study_subject_id"));
subjectTransferBean.setDateOfBirth((Date) hm.get("date_of_birth"));
try {
String gender = (String) hm.get("gender");
char[] genderarr = gender.toCharArray();
subjectTransferBean.setGender(genderarr[0]);
} catch (ClassCastException ce) {
subjectTransferBean.setGender(' ');
}
subjectTransferBean.setEnrollmentDate((Date) hm.get("enrollment_date"));
subjectTransferBean.setOwner((UserAccountBean) getUserAccountDao().findByPK((Integer) hm.get("owner_id")));
return subjectTransferBean;
}
use of org.akaza.openclinica.bean.managestudy.SubjectTransferBean in project OpenClinica by OpenClinica.
the class SubjectTransferValidator method validate.
public void validate(Object obj, Errors e) {
SubjectTransferBean subjectTransferBean = (SubjectTransferBean) obj;
StudyBean study = getStudyDAO().findByUniqueIdentifier(subjectTransferBean.getStudyOid());
if (study == null) {
e.reject("subjectTransferValidator.study_does_not_exist", new Object[] { subjectTransferBean.getStudyOid() }, "Study identifier you specified " + subjectTransferBean.getStudyOid() + " does not correspond to a valid study.");
return;
}
UserAccountBean ua = subjectTransferBean.getOwner();
StudyUserRoleBean role = ua.getRoleByStudy(study);
if (role.getId() == 0 || role.getRole().equals(Role.MONITOR)) {
e.reject("subjectTransferValidator.insufficient_permissions", "You do not have sufficient privileges to proceed with this operation.");
return;
}
if (subjectTransferBean.getSiteIdentifier() != null) {
study = getStudyDAO().findSiteByUniqueIdentifier(subjectTransferBean.getStudyOid(), subjectTransferBean.getSiteIdentifier());
}
subjectTransferBean.setStudy(study);
if (study == null) {
e.reject("subjectTransferValidator.site_does_not_exist", new Object[] { subjectTransferBean.getSiteIdentifier() }, "Site identifier you specified does not correspond to a valid site.");
return;
}
int handleStudyId = study.getParentStudyId() > 0 ? study.getParentStudyId() : study.getId();
StudyParameterValueBean studyParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectPersonIdRequired");
String personId = subjectTransferBean.getPersonId();
if ("required".equals(studyParameter.getValue()) && (personId == null || personId.length() < 1)) {
e.reject("subjectTransferValidator.personId_required", new Object[] { study.getName() }, "personId is required for the study: " + study.getName());
return;
}
if (personId != null && personId.length() > 255) {
e.reject("subjectTransferValidator.personId_invalid_length", new Object[] { personId }, "personId: " + personId + " cannot be longer than 255 characters.");
return;
}
String idSetting = "";
StudyParameterValueBean subjectIdGenerationParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "subjectIdGeneration");
idSetting = subjectIdGenerationParameter.getValue();
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
int nextLabel = getStudySubjectDAO().findTheGreatestLabel() + 1;
subjectTransferBean.setStudySubjectId(new Integer(nextLabel).toString());
}
String studySubjectId = subjectTransferBean.getStudySubjectId();
if (studySubjectId == null || studySubjectId.length() < 1) {
e.reject("subjectTransferValidator.studySubjectId_required");
return;
} else if (studySubjectId.length() > 30) {
e.reject("subjectTransferValidator.studySubjectId_invalid_length", new Object[] { studySubjectId }, "studySubjectId: " + studySubjectId + " cannot be longer than 30 characters.");
return;
}
String secondaryId = subjectTransferBean.getSecondaryId();
if (secondaryId != null && secondaryId.length() > 30) {
e.reject("subjectTransferValidator.secondaryId_invalid_length", new Object[] { secondaryId }, "secondaryId: " + secondaryId + " cannot be longer than 30 characters.");
return;
}
String gender = subjectTransferBean.getGender() + "";
studyParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "genderRequired");
if ("true".equals(studyParameter.getValue()) && (gender == null || gender.length() < 1)) {
e.reject("subjectTransferValidator.gender_required", new Object[] { study.getName() }, "Gender is required for the study: " + study.getName());
return;
}
if (!"m".equals(gender) && !"f".equals(gender)) {
e.reject("subjectTransferValidator.gender_is_m_or_f");
// e.reject("subjectTransferValidator.gender_required", new Object[] { study.getName() }, "Gender is required to be 'm' or 'f'");
return;
}
Date dateOfBirth = subjectTransferBean.getDateOfBirth();
String yearOfBirth = subjectTransferBean.getYearOfBirth();
studyParameter = getStudyParameterValueDAO().findByHandleAndStudy(handleStudyId, "collectDob");
if ("1".equals(studyParameter.getValue()) && (dateOfBirth == null)) {
e.reject("subjectTransferValidator.dateOfBirth_required", new Object[] { study.getName() }, "Date of birth is required for the study " + study.getName());
return;
} else if ("2".equals(studyParameter.getValue()) && (yearOfBirth == null)) {
e.reject("subjectTransferValidator.yearOfBirth_required", new Object[] { study.getName() }, "Year of birth is required for the study " + study.getName());
return;
} else if ("2".equals(studyParameter.getValue()) && (yearOfBirth != null)) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
subjectTransferBean.setDateOfBirth(sdf.parse(subjectTransferBean.getYearOfBirth()));
} catch (ParseException xe) {
e.reject("subjectTransferValidator.yearOfBirth_invalid", new Object[] { yearOfBirth }, "Year of birth: " + yearOfBirth + " is not valid");
return;
}
}
Date enrollmentDate = subjectTransferBean.getEnrollmentDate();
if (enrollmentDate == null) {
e.reject("subjectTransferValidator.enrollmentDate_required");
return;
} else {
if ((new Date()).compareTo(enrollmentDate) < 0) {
e.reject("subjectTransferValidator.enrollmentDate_should_be_in_past");
return;
}
}
}
use of org.akaza.openclinica.bean.managestudy.SubjectTransferBean in project OpenClinica by OpenClinica.
the class SubjectTransferDAO method create.
public EntityBean create(EntityBean eb, UserAccountBean ub) {
// INSERT INTO subject_transfer (subject_transfer_id,date_of_birth,gender,person_id,study_subject_id, status_id,updater_id,date_updated) VALUES
// (?,?,?,?,?)
SubjectTransferBean subjectTransferBean = (SubjectTransferBean) eb;
RuleSetAuditBean ruleSetAudit = new RuleSetAuditBean();
HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
HashMap<Integer, Object> nullVars = new HashMap<Integer, Object>();
if (subjectTransferBean.getDateOfBirth() == null) {
nullVars.put(new Integer(1), new Integer(Types.DATE));
variables.put(new Integer(1), null);
} else {
variables.put(new Integer(1), subjectTransferBean.getDateOfBirth());
}
if (subjectTransferBean.getGender() != 'm' && subjectTransferBean.getGender() != 'f') {
nullVars.put(new Integer(2), new Integer(Types.CHAR));
variables.put(new Integer(2), null);
} else {
char[] ch = { subjectTransferBean.getGender() };
variables.put(new Integer(2), new String(ch));
}
variables.put(3, subjectTransferBean.getPersonId());
variables.put(4, subjectTransferBean.getStudySubjectId());
variables.put(5, subjectTransferBean.getStudyOid());
variables.put(6, subjectTransferBean.getDateReceived());
variables.put(7, subjectTransferBean.getEnrollmentDate());
variables.put(8, subjectTransferBean.getOwner().getId());
executeWithPK(digester.getQuery("create"), variables, nullVars);
if (isQuerySuccessful()) {
subjectTransferBean.setId(getLatestPK());
}
return subjectTransferBean;
}
Aggregations