use of org.akaza.openclinica.domain.datamap.StudyEvent in project OpenClinica by OpenClinica.
the class RuleSetListenerService method onApplicationEvent.
@Override
public void onApplicationEvent(final OnStudyEventUpdated event) {
LOGGER.debug("listening");
if (event.getContainer().getChangeDetails().getStartDateChanged() || event.getContainer().getChangeDetails().getStatusChanged()) {
StudyEvent studyEvent = event.getContainer().getEvent();
Integer studyEventDefId = studyEvent.getStudyEventDefinition().getStudyEventDefinitionId();
Integer studyEventOrdinal = studyEvent.getSampleOrdinal();
Integer userId = studyEvent.getUpdateId();
if (userId == null && studyEvent.getUserAccount() != null)
userId = studyEvent.getUserAccount().getUserId();
StudyEventBean studyEventBean = new StudyEventBean();
studyEventBean.setId(studyEvent.getStudyEventId());
ArrayList<RuleSetBean> ruleSets = (ArrayList<RuleSetBean>) createRuleSet(studyEventDefId);
for (RuleSetBean ruleSet : ruleSets) {
ArrayList<RuleSetBean> ruleSetBeans = new ArrayList();
ExpressionBean eBean = new ExpressionBean();
eBean.setValue(ruleSet.getTarget().getValue() + ".A.B");
ruleSet.setTarget(eBean);
ruleSet.addExpression(getRuleSetService().replaceSEDOrdinal(ruleSet.getTarget(), studyEventBean));
ruleSetBeans.add(ruleSet);
getRuleSetService().runIndividualRulesInBeanProperty(ruleSetBeans, userId, event.getContainer().getChangeDetails(), studyEventOrdinal);
}
}
}
use of org.akaza.openclinica.domain.datamap.StudyEvent 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.StudyEvent in project OpenClinica by OpenClinica.
the class GenerateClinicalDataServiceImpl method setExportStudyEventDataBean.
private ArrayList<ExportStudyEventDataBean> setExportStudyEventDataBean(StudySubject ss, List<StudyEvent> sEvents, String formVersionOID) {
ArrayList<ExportStudyEventDataBean> al = new ArrayList<ExportStudyEventDataBean>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (StudyEvent se : sEvents) {
if (se != null) {
ExportStudyEventDataBean expSEBean = new ExportStudyEventDataBean();
expSEBean.setLocation(se.getLocation());
if (se.getDateEnd() != null)
if (se.getEndTimeFlag())
expSEBean.setEndDate(se.getDateEnd() + "");
else {
String temp = sdf.format(se.getDateEnd());
expSEBean.setEndDate(temp);
}
if (se.getStartTimeFlag())
expSEBean.setStartDate(se.getDateStart() + "");
else {
String temp = sdf.format(se.getDateStart());
expSEBean.setStartDate(temp);
}
expSEBean.setStudyEventOID(se.getStudyEventDefinition().getOc_oid());
expSEBean.setStudyEventRepeatKey(se.getSampleOrdinal().toString());
if (se.getStudySubject().getSubject().getDateOfBirth() != null && se.getDateStart() != null)
expSEBean.setAgeAtEvent(Utils.getAge(se.getStudySubject().getSubject().getDateOfBirth(), se.getDateStart()));
expSEBean.setStatus(fetchStudyEventStatus(se.getSubjectEventStatusId()));
if (collectAudits)
expSEBean.setAuditLogs(fetchAuditLogs(se.getStudyEventId(), "study_event", se.getStudyEventDefinition().getOc_oid(), null));
if (collectDns)
expSEBean.setDiscrepancyNotes(fetchDiscrepancyNotes(se));
expSEBean.setExportFormData(getFormDataForClinicalStudy(ss, se, formVersionOID));
expSEBean.setStudyEventDefinition(se.getStudyEventDefinition());
al.add(expSEBean);
}
}
return al;
}
use of org.akaza.openclinica.domain.datamap.StudyEvent 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.StudyEvent in project OpenClinica by OpenClinica.
the class ExpressionBeanService method evaluateExpression.
public String evaluateExpression(String test) {
String value = "";
String temp = null;
String oid = null;
int index = 0;
// TODO fix this
System.out.println("TEST :: " + test);
if (checkIfForScheduling(test)) {
//TODO: get the format from data format properties.??
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
index = test.indexOf(".");
oid = test.substring(0, index);
temp = test.substring(index, test.length());
StudyEvent studyEvent = getStudyEventFromOID(oid);
if (ExpressionService.STARTDATE.endsWith(temp)) {
if (studyEvent != null) {
value = sdf.format(DateUtils.truncate((java.util.Date) studyEvent.getDateStart(), Calendar.DATE));
value = value.replace(("00:00:00.0"), "");
value = value.trim();
}
}
}
return value;
}
Aggregations