use of org.akaza.openclinica.domain.datamap.StudySubject in project OpenClinica by OpenClinica.
the class BeanPropertyService method executeAction.
/**
* The Event action runs based on the values set in the rules.
* @param result
* @param propertyBean
* @param eow
* @param eventAction
*/
private void executeAction(Object result, PropertyBean propertyBean, ExpressionBeanObjectWrapper eow, EventActionBean eventAction, Integer userId, boolean isTransaction) {
String oid = eventAction.getOc_oid_reference();
String eventOID = null;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
int ordinal = 1;
if (oid.startsWith(ExpressionService.STUDY_EVENT_OID_START_KEY)) {
StudyEvent studyEvent = null;
if (oid.contains("[")) {
int leftBracketIndex = oid.indexOf("[");
int rightBracketIndex = oid.indexOf("]");
ordinal = Integer.valueOf(oid.substring(leftBracketIndex + 1, rightBracketIndex));
eventOID = oid.substring(0, leftBracketIndex);
studyEvent = getStudyEventDAO().fetchByStudyEventDefOIDAndOrdinal(eventOID, ordinal, eow.getStudySubjectBeanId());
} else {
eventOID = oid;
studyEvent = getStudyEventDAO().fetchByStudyEventDefOIDAndOrdinal(oid, ordinal, eow.getStudySubjectBeanId());
}
StudyEventChangeDetails changeDetails = new StudyEventChangeDetails();
if (studyEvent == null) {
//the studyevent may not have been created.
studyEvent = new StudyEvent();
StudySubject ss = getStudySubjectDao().findById(eow.getStudySubjectBeanId());
StudyEventDefinition sed = getStudyEventDefinitionDao().findByColumnName(eventOID, "oc_oid");
studyEvent.setStudyEventDefinition(sed);
studyEvent.setStudySubject(ss);
studyEvent.setStatusId(1);
studyEvent.setSampleOrdinal(getNewEventOrdinal(eventOID, eow.getStudySubjectBeanId(), sed));
//The status is changed to started when it doesnt exist. In other cases, the status remains the same. The case of Signed and locked are prevented from validator and are not again checked here.
studyEvent.setSubjectEventStatusId(new Integer(1));
studyEvent.setStartTimeFlag(false);
studyEvent.setEndTimeFlag(false);
studyEvent.setDateCreated(new Date());
studyEvent.setUserAccount(getUserAccountDao().findById(userId));
changeDetails.setStartDateChanged(true);
changeDetails.setStatusChanged(true);
} else {
studyEvent.setUpdateId(userId);
studyEvent.setDateUpdated(new Date());
changeDetails.setStatusChanged(false);
}
try {
if (studyEvent.getDateStart() == null || studyEvent.getDateStart().compareTo(df.parse((String) result)) != 0)
changeDetails.setStartDateChanged(true);
studyEvent.setDateStart(df.parse((String) result));
} catch (ParseException e) {
e.printStackTrace();
LOGGER.info(e.getMessage());
}
changeDetails.setRunningInTransaction(isTransaction);
StudyEventContainer container = new StudyEventContainer(studyEvent, changeDetails);
if (isTransaction)
getStudyEventDAO().saveOrUpdateTransactional(container);
else
getStudyEventDAO().saveOrUpdate(container);
}
}
use of org.akaza.openclinica.domain.datamap.StudySubject in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method constructClinicalDataStudy.
private OdmClinicalDataBean constructClinicalDataStudy(List<StudySubject> studySubjs, Study study, List<StudyEvent> studyEvents, String formVersionOID) {
OdmClinicalDataBean odmClinicalDataBean = new OdmClinicalDataBean();
ExportSubjectDataBean expSubjectBean;
List<ExportSubjectDataBean> exportSubjDataBeanList = new ArrayList<ExportSubjectDataBean>();
for (StudySubject studySubj : studySubjs) {
studyEvents = (ArrayList<StudyEvent>) getStudySubjectDao().fetchListSEs(studySubj.getOcOid());
if (studyEvents != null) {
expSubjectBean = setExportSubjectDataBean(studySubj, study, studyEvents, formVersionOID);
exportSubjDataBeanList.add(expSubjectBean);
odmClinicalDataBean.setExportSubjectData(exportSubjDataBeanList);
odmClinicalDataBean.setStudyOID(study.getOc_oid());
}
}
return odmClinicalDataBean;
// return null;
}
use of org.akaza.openclinica.domain.datamap.StudySubject in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method getClinicalData.
public LinkedHashMap<String, OdmClinicalDataBean> getClinicalData(String studyOID) {
LinkedHashMap<String, OdmClinicalDataBean> hm = new LinkedHashMap<String, OdmClinicalDataBean>();
Study study = new Study();
study.setOc_oid(studyOID);
study = getStudyDao().findByColumnName(studyOID, "oc_oid");
List<StudySubject> studySubjs = study.getStudySubjects();
if (study.getStudies().size() < 1) {
hm.put(studyOID, constructClinicalData(study, studySubjs));
} else // return odmClinicalDataBean;
{
// at study level
hm.put(studyOID, constructClinicalData(study, studySubjs));
for (Study s : study.getStudies()) {
// all the sites
hm.put(s.getOc_oid(), constructClinicalData(s, s.getStudySubjects()));
}
}
return hm;
// return constructClinicalData(study, studySubjs);
}
use of org.akaza.openclinica.domain.datamap.StudySubject in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method getClinicalDatas.
private OdmClinicalDataBean getClinicalDatas(String studyOID, String studySubjectOID, String studyEventOID, String formVersionOID) {
int seOrdinal = 0;
String temp = studyEventOID;
List<StudyEvent> studyEvents = new ArrayList<StudyEvent>();
StudyEventDefinition sed = null;
Study study = getStudyDao().findByColumnName(studyOID, "oc_oid");
List<StudySubject> ss = listStudySubjects(studySubjectOID);
int idx = studyEventOID.indexOf(OPEN_ORDINAL_DELIMITER);
LOGGER.info("study event oridinal is.." + idx);
if (idx > 0) {
studyEventOID = studyEventOID.substring(0, idx);
seOrdinal = new Integer(temp.substring(idx + 1, temp.indexOf(CLOSE_ORDINAL_DELIMITER))).intValue();
}
sed = getStudyEventDefDao().findByColumnName(studyEventOID, "oc_oid");
LOGGER.info("study event ordinal.." + seOrdinal);
if (seOrdinal > 0) {
studyEvents = fetchSE(seOrdinal, sed.getStudyEvents(), studySubjectOID);
} else {
studyEvents = fetchSE(sed.getStudyEvents(), studySubjectOID);
}
return constructClinicalDataStudy(ss, study, studyEvents, formVersionOID);
}
use of org.akaza.openclinica.domain.datamap.StudySubject in project OpenClinica by OpenClinica.
the class BatchCRFMigrationController method executeMigrationAction.
public void executeMigrationAction(HelperObject helperObject, EventCRFBean eventCRFBean) {
Session session = helperObject.getSession();
EventCrf eventCrf = helperObject.getEventCrfDao().findById(eventCRFBean.getId());
StudyEvent studyEvent = helperObject.getStudyEventDao().findById(eventCRFBean.getStudyEventId());
FormLayout formLayout = helperObject.getFormLayoutDao().findById(helperObject.getTargetCrfVersionBean().getId());
StudySubject studySubject = helperObject.getStudySubjectDao().findById(eventCRFBean.getStudySubjectId());
eventCrf.setSdvStatus(false);
eventCrf.setDateUpdated(new Date());
eventCrf.setSdvUpdateId(helperObject.getUserAccountBean().getId());
eventCrf.setUpdateId(helperObject.getUserAccountBean().getId());
eventCrf.setFormLayout(formLayout);
session.saveOrUpdate(eventCrf);
String status_before_update = null;
SubjectEventStatus eventStatus = null;
if (studySubject.getStatus() == Status.SIGNED) {
status_before_update = auditDao().findLastStatus("study_subject", studySubject.getStudySubjectId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int subject_status = Integer.parseInt(status_before_update);
Status status = Status.getByCode(subject_status);
studySubject.setStatus(status);
}
studySubject.setUpdateId(helperObject.getUserAccountBean().getId());
session.saveOrUpdate(studySubject);
}
studyEvent.setUpdateId(helperObject.getUserAccountBean().getId());
studyEvent.setDateUpdated(new Date());
status_before_update = auditDao().findLastStatus("study_event", studyEvent.getStudyEventId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int status = Integer.parseInt(status_before_update);
eventStatus = SubjectEventStatus.get(status);
studyEvent.setSubjectEventStatusId(eventStatus.getId());
}
session.saveOrUpdate(studyEvent);
}
Aggregations