use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class EventCRFDAO method findByEventFormLayout.
public EventCRFBean findByEventFormLayout(StudyEventBean studyEvent, FormLayoutBean formLayout) {
EventCRFBean eventCrfBean = null;
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(new Integer(1), new Integer(studyEvent.getId()));
variables.put(new Integer(2), new Integer(formLayout.getId()));
ArrayList<EventCRFBean> eventCrfs = executeFindAllQuery("findByEventFormLayout", variables);
if (!eventCrfs.isEmpty() && eventCrfs.size() == 1) {
eventCrfBean = eventCrfs.get(0);
}
return eventCrfBean;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class EventCRFDAO method getEntityFromHashMap.
public Object getEntityFromHashMap(HashMap hm) {
EventCRFBean eb = new EventCRFBean();
this.setEntityAuditInformation(eb, hm);
eb.setId(((Integer) hm.get("event_crf_id")).intValue());
eb.setStudyEventId(((Integer) hm.get("study_event_id")).intValue());
eb.setCRFVersionId(((Integer) hm.get("crf_version_id")).intValue());
eb.setDateInterviewed((Date) hm.get("date_interviewed"));
eb.setInterviewerName((String) hm.get("interviewer_name"));
eb.setCompletionStatusId(((Integer) hm.get("completion_status_id")).intValue());
eb.setAnnotations((String) hm.get("annotations"));
eb.setDateCompleted((Date) hm.get("date_completed"));
eb.setValidatorId(((Integer) hm.get("validator_id")).intValue());
eb.setDateValidate((Date) hm.get("date_validate"));
eb.setDateValidateCompleted((Date) hm.get("date_validate_completed"));
eb.setValidatorAnnotations((String) hm.get("validator_annotations"));
eb.setValidateString((String) hm.get("validate_string"));
eb.setStudySubjectId(((Integer) hm.get("study_subject_id")).intValue());
eb.setSdvStatus((Boolean) hm.get("sdv_status"));
eb.setSdvUpdateId((Integer) hm.get("sdv_update_id"));
eb.setFormLayoutId(((Integer) hm.get("form_layout_id")).intValue());
Integer oldStatusId = (Integer) hm.get("old_status_id");
eb.setOldStatus(Status.get(oldStatusId));
// eb.setStatus(Status.get((Integer) hm.get("status_id"))
return eb;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class EventCRFDAO method update.
public EntityBean update(EntityBean eb) {
EventCRFBean ecb = (EventCRFBean) eb;
ecb.setActive(false);
HashMap variables = new HashMap();
HashMap nullVars = new HashMap();
variables.put(new Integer(1), new Integer(ecb.getStudyEventId()));
variables.put(new Integer(2), new Integer(ecb.getCRFVersionId()));
if (ecb.getDateInterviewed() == null) {
nullVars.put(new Integer(3), new Integer(Types.DATE));
variables.put(new Integer(3), null);
} else {
variables.put(new Integer(3), ecb.getDateInterviewed());
}
variables.put(new Integer(4), ecb.getInterviewerName());
variables.put(new Integer(5), new Integer(ecb.getCompletionStatusId()));
variables.put(new Integer(6), new Integer(ecb.getStatus().getId()));
variables.put(new Integer(7), ecb.getAnnotations());
if (ecb.getDateCompleted() == null) {
nullVars.put(new Integer(8), new Integer(Types.TIMESTAMP));
variables.put(new Integer(8), null);
} else {
variables.put(new Integer(8), new java.sql.Timestamp(ecb.getDateCompleted().getTime()));
}
// variables.put(new Integer(8),ecb.getDateCompleted());
variables.put(new Integer(9), new Integer(ecb.getValidatorId()));
if (ecb.getDateValidate() == null) {
nullVars.put(new Integer(10), new Integer(Types.DATE));
variables.put(new Integer(10), null);
} else {
variables.put(new Integer(10), ecb.getDateValidate());
}
if (ecb.getDateValidateCompleted() == null) {
nullVars.put(new Integer(11), new Integer(Types.TIMESTAMP));
variables.put(new Integer(11), null);
} else {
variables.put(new Integer(11), new Timestamp(ecb.getDateValidateCompleted().getTime()));
}
// variables.put(new Integer(11),ecb.getDateValidateCompleted());
variables.put(new Integer(12), ecb.getValidatorAnnotations());
variables.put(new Integer(13), ecb.getValidateString());
variables.put(new Integer(14), new Integer(ecb.getStudySubjectId()));
variables.put(new Integer(15), new Integer(ecb.getUpdaterId()));
variables.put(new Integer(16), new Boolean(ecb.isElectronicSignatureStatus()));
variables.put(new Integer(17), new Boolean(ecb.isSdvStatus()));
if (ecb.getOldStatus() != null && ecb.getOldStatus().getId() > 0) {
variables.put(new Integer(18), new Integer(ecb.getOldStatus().getId()));
} else {
variables.put(new Integer(18), new Integer(0));
}
// @pgawade 22-May-2011 added the sdv updater id variable
variables.put(new Integer(19), ecb.getSdvUpdateId());
// variables.put(new Integer(19), new Integer(ecb.getId()));
variables.put(new Integer(21), new Integer(ecb.getId()));
variables.put(new Integer(20), new Integer(ecb.getFormLayoutId()));
this.execute(digester.getQuery("update"), variables, nullVars);
if (isQuerySuccessful()) {
ecb.setActive(true);
}
return ecb;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ImportDataHelper method createEventCRF.
public EventCRFBean createEventCRF(HashMap<String, String> importedObject) {
EventCRFBean eventCrfBean = null;
int studyEventId = importedObject.get("study_event_id") == null ? -1 : Integer.parseInt(importedObject.get("study_event_id"));
String crfVersionName = importedObject.get("crf_version_name") == null ? "" : importedObject.get("crf_version_name").toString();
String crfName = importedObject.get("crf_name") == null ? "" : importedObject.get("crf_name").toString();
String eventDefinitionCRFName = importedObject.get("event_definition_crf_name") == null ? "" : importedObject.get("event_definition_crf_name").toString();
String subjectName = importedObject.get("subject_name") == null ? "" : importedObject.get("subject_name").toString();
String studyName = importedObject.get("study_name") == null ? "" : importedObject.get("study_name").toString();
logger.info("found the following: study event id " + studyEventId + ", crf version name " + crfVersionName + ", crf name " + crfName + ", event def crf name " + eventDefinitionCRFName + ", subject name " + subjectName + ", study name " + studyName);
// << tbh
int eventCRFId = 0;
EventCRFDAO eventCrfDao = new EventCRFDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
StudySubjectDAO studySubjectDao = new StudySubjectDAO(sm.getDataSource());
StudyEventDefinitionDAO studyEventDefinistionDao = new StudyEventDefinitionDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
SubjectDAO subjectDao = new SubjectDAO(sm.getDataSource());
StudyBean studyBean = (StudyBean) studyDao.findByName(studyName);
// .findByPK(studyId);
// generate the subject bean first, so that we can have the subject id
// below...
SubjectBean subjectBean = // .findByUniqueIdentifierAndStudy(subjectName,
subjectDao.findByUniqueIdentifier(subjectName);
StudySubjectBean studySubjectBean = studySubjectDao.findBySubjectIdAndStudy(subjectBean.getId(), studyBean);
// .findByLabelAndStudy(subjectName, studyBean);
logger.info("::: found study subject id here: " + studySubjectBean.getId() + " with the following: subject ID " + subjectBean.getId() + " study bean name " + studyBean.getName());
StudyEventBean studyEventBean = (StudyEventBean) studyEventDao.findByPK(studyEventId);
// TODO need to replace, can't really replace
logger.info("found study event status: " + studyEventBean.getStatus().getName());
// [study] event should be scheduled, event crf should be not started
CRFVersionBean crfVersion = (CRFVersionBean) crfVersionDao.findByFullName(crfVersionName, crfName);
// .findByPK(crfVersionId);
// replaced by findByName(name, version)
logger.info("found crf version name here: " + crfVersion.getName());
EntityBean crf = crfdao.findByPK(crfVersion.getCrfId());
logger.info("found crf name here: " + crf.getName());
// trying it again up here since down there doesn't seem to work, tbh
StudyEventDefinitionBean studyEventDefinitionBean = (StudyEventDefinitionBean) studyEventDefinistionDao.findByName(eventDefinitionCRFName);
if (studySubjectBean.getId() <= 0 && studyEventBean.getId() <= 0 && crfVersion.getId() <= 0 && studyBean.getId() <= 0 && studyEventDefinitionBean.getId() <= 0) {
logger.info("Throw an Exception, One of the provided ids is not valid");
}
// >> tbh repeating items:
ArrayList eventCrfBeans = eventCrfDao.findByEventSubjectVersion(studyEventBean, studySubjectBean, crfVersion);
// TODO repeating items here? not yet
if (eventCrfBeans.size() > 1) {
logger.info("found more than one");
}
if (!eventCrfBeans.isEmpty() && eventCrfBeans.size() == 1) {
eventCrfBean = (EventCRFBean) eventCrfBeans.get(0);
logger.info("This EventCrfBean was found");
}
if (!eventCrfBeans.isEmpty() && eventCrfBeans.size() > 1) {
logger.info("Throw a System exception , result should either be 0 or 1");
}
if (eventCrfBean == null) {
StudyBean studyWithSED = studyBean;
if (studyBean.getParentStudyId() > 0) {
studyWithSED = new StudyBean();
studyWithSED.setId(studyBean.getParentStudyId());
}
AuditableEntityBean studyEvent = studyEventDao.findByPKAndStudy(studyEventId, studyWithSED);
if (studyEvent.getId() <= 0) {
logger.info("Hello Exception");
}
eventCrfBean = new EventCRFBean();
// eventCrfBean.setCrfVersion(crfVersion);
if (eventCRFId == 0) {
// ???
if (studyBean.getStudyParameterConfig().getInterviewerNameDefault().equals("blank")) {
eventCrfBean.setInterviewerName("");
} else {
// default will be event's owner name
eventCrfBean.setInterviewerName(studyEventBean.getOwner().getName());
}
if (!studyBean.getStudyParameterConfig().getInterviewDateDefault().equals("blank")) {
if (studyEventBean.getDateStarted() != null) {
// default
eventCrfBean.setDateInterviewed(studyEventBean.getDateStarted());
// date
} else {
// logger.info("evnet start date is null, so date
// interviewed is null");
eventCrfBean.setDateInterviewed(null);
}
} else {
eventCrfBean.setDateInterviewed(null);
}
eventCrfBean.setAnnotations("");
eventCrfBean.setCreatedDate(new Date());
eventCrfBean.setCRFVersionId(crfVersion.getId());
// eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
eventCrfBean.setOwner(ub);
// eventCrfBean.setCrf((CRFBean)crf);
eventCrfBean.setStatus(Status.AVAILABLE);
eventCrfBean.setCompletionStatusId(1);
// problem with the line below
eventCrfBean.setStudySubjectId(studySubjectBean.getId());
eventCrfBean.setStudyEventId(studyEventId);
eventCrfBean.setValidateString("");
eventCrfBean.setValidatorAnnotations("");
try {
eventCrfBean = (EventCRFBean) eventCrfDao.create(eventCrfBean);
// TODO review
// eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
// eventCrfBean.setCrf((CRFBean)crf);
} catch (Exception ee) {
logger.info(ee.getMessage());
logger.info("throws with crf version id " + crfVersion.getId() + " and study event id " + studyEventId + " study subject id " + studySubjectBean.getId());
}
// note that you need to catch an exception if the numbers are
// bogus, ie you can throw an error here
// however, putting the try catch allows you to pass which is
// also bad
// logger.info("CREATED EVENT CRF");
} else {
// there is an event CRF already, only need to update
// is the status not started???
logger.info("*** already-started event CRF with msg: " + eventCrfBean.getStatus().getName());
if (eventCrfBean.getStatus().equals(Status.PENDING)) {
logger.info("Not Started???");
}
eventCrfBean = (EventCRFBean) eventCrfDao.findByPK(eventCRFId);
eventCrfBean.setCRFVersionId(crfVersion.getId());
eventCrfBean.setUpdatedDate(new Date());
eventCrfBean.setUpdater(ub);
eventCrfBean = (EventCRFBean) eventCrfDao.update(eventCrfBean);
// eventCrfBean.setCrfVersion((CRFVersionBean)crfVersion);
// eventCrfBean.setCrf((CRFBean)crf);
}
if (eventCrfBean.getId() <= 0) {
logger.info("error");
} else {
// TODO change status here, tbh
// 2/08 this part seems to work, tbh
studyEventBean.setSubjectEventStatus(SubjectEventStatus.DATA_ENTRY_STARTED);
studyEventBean.setUpdater(ub);
studyEventBean.setUpdatedDate(new Date());
studyEventDao.update(studyEventBean);
}
}
eventCrfBean.setCrfVersion(crfVersion);
eventCrfBean.setCrf((CRFBean) crf);
// repeating?
return eventCrfBean;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class Key method populateForCrfBasedRulesView.
/**
* Organize objects in a certain way so that we can show to Users on UI.
* step1 : Get StudyEvent , eventCrf , crfVersion from studyEventId.
*
* @param crfViewSpecificOrderedObjects
* @param ruleSet
* @param rule
* @return
*/
private HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> populateForCrfBasedRulesView(HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> crfViewSpecificOrderedObjects, RuleSetBean ruleSet, RuleBean rule, String result, StudyBean currentStudy, List<RuleActionBean> actions) {
// step1
StudyEventBean studyEvent = (StudyEventBean) getStudyEventDao().findByPK(Integer.valueOf(getExpressionService().getStudyEventDefenitionOrdninalCurated(ruleSet.getTarget().getValue())));
EventCRFBean eventCrf = (EventCRFBean) getEventCrfDao().findAllByStudyEventAndCrfOrCrfVersionOid(studyEvent, getExpressionService().getCrfOid(ruleSet.getTarget().getValue())).get(0);
CRFVersionBean crfVersion = (CRFVersionBean) getCrfVersionDao().findByPK(eventCrf.getCRFVersionId());
RuleBulkExecuteContainer key = new RuleBulkExecuteContainer(crfVersion.getName(), rule, result, actions);
String key2String = getExpressionService().getCustomExpressionUsedToCreateView(ruleSet.getTarget().getValue(), studyEvent.getSampleOrdinal());
String studyEventDefinitionName = getExpressionService().getStudyEventDefinitionFromExpression(ruleSet.getTarget().getValue(), currentStudy).getName();
studyEventDefinitionName += " [" + studyEvent.getSampleOrdinal() + "]";
// String itemGroupName = getExpressionService().getItemGroupNameAndOrdinal(ruleSet.getTarget().getValue());
// String itemName = getExpressionService().getItemGroupExpression(ruleSet.getTarget().getValue()).getName();
String itemGroupName = getExpressionService().getItemGroupNameAndOrdinal(ruleSet.getTarget().getValue());
ItemGroupBean itemGroupBean = getExpressionService().getItemGroupExpression(ruleSet.getTarget().getValue());
ItemBean itemBean = getExpressionService().getItemExpression(ruleSet.getTarget().getValue(), itemGroupBean);
String itemName = itemBean.getName();
RuleBulkExecuteContainerTwo key2 = new RuleBulkExecuteContainerTwo(key2String, studyEvent, studyEventDefinitionName, itemGroupName, itemName);
StudySubjectBean studySubject = (StudySubjectBean) getStudySubjectDao().findByPK(studyEvent.getStudySubjectId());
if (crfViewSpecificOrderedObjects.containsKey(key)) {
HashMap<RuleBulkExecuteContainerTwo, Set<String>> k = crfViewSpecificOrderedObjects.get(key);
if (k.containsKey(key2)) {
k.get(key2).add(String.valueOf(studySubject.getLabel()));
} else {
HashSet<String> values = new HashSet<String>();
values.add(String.valueOf(studySubject.getLabel()));
k.put(key2, values);
}
} else {
HashMap<RuleBulkExecuteContainerTwo, Set<String>> k = new HashMap<RuleBulkExecuteContainerTwo, Set<String>>();
HashSet<String> values = new HashSet<String>();
values.add(String.valueOf(studySubject.getLabel()));
k.put(key2, values);
crfViewSpecificOrderedObjects.put(key, k);
}
return crfViewSpecificOrderedObjects;
}
Aggregations