use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ViewCRFServlet method populate.
private Collection<TableColumnHolder> populate(CRFBean crf, ArrayList<FormLayoutBean> versions) {
HashMap<FormLayoutBean, ArrayList<TableColumnHolder>> hm = new HashMap<FormLayoutBean, ArrayList<TableColumnHolder>>();
List<TableColumnHolder> tableColumnHolders = new ArrayList<TableColumnHolder>();
for (FormLayoutBean versionBean : versions) {
hm.put(versionBean, new ArrayList<TableColumnHolder>());
}
List<RuleSetBean> ruleSets = getRuleSetService().getRuleSetsByCrfAndStudy(crf, currentStudy);
ruleSets = getRuleSetService().filterByStatusEqualsAvailable(ruleSets);
for (RuleSetBean ruleSetBean : ruleSets) {
if (ruleSetBean.getCrfVersion() == null) {
for (FormLayoutBean version : versions) {
hm.get(version).addAll(createFromRuleSet(ruleSetBean, version));
}
}
if (ruleSetBean.getCrfVersion() != null) {
hm.get(ruleSetBean.getCrfVersion()).addAll(createFromRuleSet(ruleSetBean, ruleSetBean.getFormLayout()));
}
}
for (ArrayList<TableColumnHolder> list : hm.values()) {
tableColumnHolders.addAll(list);
}
return tableColumnHolders;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ImportDataRuleRunnerContainer method initRuleSetsAndTargets.
/**
* Populate importDataTrueRuleSets and variableAndValue.
* Precondition: import data file passed validation which means all OIDs are not empty.
* @param ds
* @param studyBean
* @param subjectDataBean
* @param ruleSetService
*/
@Transactional
public void initRuleSetsAndTargets(DataSource ds, StudyBean studyBean, SubjectDataBean subjectDataBean, RuleSetServiceInterface ruleSetService) {
this.shouldRunRules = this.shouldRunRules == null ? Boolean.FALSE : this.shouldRunRules;
this.importDataTrueRuleSets = this.importDataTrueRuleSets == null ? new ArrayList<RuleSetBean>() : this.importDataTrueRuleSets;
this.variableAndValue = this.variableAndValue == null ? new HashMap<String, String>() : this.variableAndValue;
studyOid = studyBean.getOid();
studySubjectOid = subjectDataBean.getSubjectOID();
StudySubjectBean studySubject = new StudySubjectDAO<String, ArrayList>(ds).findByOid(studySubjectOid);
HashMap<String, StudyEventDefinitionBean> seds = new HashMap<String, StudyEventDefinitionBean>();
HashMap<String, CRFVersionBean> cvs = new HashMap<String, CRFVersionBean>();
ArrayList<StudyEventDataBean> studyEventDataBeans = subjectDataBean.getStudyEventData();
for (StudyEventDataBean studyEventDataBean : studyEventDataBeans) {
String sedOid = studyEventDataBean.getStudyEventOID();
StudyEventDefinitionBean sed;
if (seds.containsKey(sedOid))
sed = seds.get(sedOid);
else {
sed = new StudyEventDefinitionDAO<String, ArrayList>(ds).findByOid(sedOid);
seds.put(sedOid, sed);
}
ArrayList<FormDataBean> formDataBeans = studyEventDataBean.getFormData();
for (FormDataBean formDataBean : formDataBeans) {
String cvOid = formDataBean.getFormOID();
CRFVersionBean crfVersion;
if (cvs.containsKey(cvOid))
crfVersion = cvs.get(cvOid);
else {
crfVersion = new CRFVersionDAO<String, ArrayList>(ds).findByOid(cvOid);
cvs.put(cvOid, crfVersion);
}
String sedOrd = studyEventDataBean.getStudyEventRepeatKey();
Integer sedOrdinal = sedOrd != null && !sedOrd.isEmpty() ? Integer.valueOf(sedOrd) : 1;
StudyEventBean studyEvent = (StudyEventBean) new StudyEventDAO(ds).findByStudySubjectIdAndDefinitionIdAndOrdinal(studySubject.getId(), sed.getId(), sedOrdinal);
List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByCrfStudyAndStudyEventDefinition(studyBean, sed, crfVersion);
// Set<String> targetItemOids = new HashSet<String>();
if (ruleSets != null && !ruleSets.isEmpty()) {
ruleSets = filterByImportDataEntryTrue(ruleSets);
if (ruleSets != null && !ruleSets.isEmpty()) {
ruleSets = ruleSetService.filterByStatusEqualsAvailable(ruleSets);
ruleSets = ruleSetService.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEvent, crfVersion, sed);
// ruleSets = ruleSetService.filterRuleSetsByHiddenItems(ruleSets, eventCrfBean, crfVersion, new ArrayList<ItemBean>());
shouldRunRules = ruleSetService.shouldRunRulesForRuleSets(ruleSets, Phase.IMPORT);
if (shouldRunRules != null && shouldRunRules == Boolean.TRUE) {
// targetItemOids = collectTargetItemOids(ruleSets);
HashMap<String, Integer> grouped = new HashMap<String, Integer>();
ArrayList<ImportItemGroupDataBean> itemGroupDataBeans = formDataBean.getItemGroupData();
for (ImportItemGroupDataBean itemGroupDataBean : itemGroupDataBeans) {
ArrayList<ImportItemDataBean> itemDataBeans = itemGroupDataBean.getItemData();
for (ImportItemDataBean importItemDataBean : itemDataBeans) {
// if(targetItemOids.contains(importItemDataBean.getItemOID())) {
ItemBean item = new ItemDAO<String, ArrayList>(ds).findByOid(importItemDataBean.getItemOID()).get(0);
String igOid = itemGroupDataBean.getItemGroupOID();
String igOrd = itemGroupDataBean.getItemGroupRepeatKey();
Integer igOrdinal = igOrd != null && !igOrd.isEmpty() ? Integer.valueOf(igOrd) : 1;
// logic from DataEntryServlet method: populateRuleSpecificHashMaps()
if (isRepeatIGForSure(ds, crfVersion.getId(), igOid, igOrdinal, item.getId())) {
String key1 = igOid + "[" + igOrdinal + "]." + importItemDataBean.getItemOID();
String key = igOid + "." + importItemDataBean.getItemOID();
variableAndValue.put(key1, importItemDataBean.getValue());
if (grouped.containsKey(key)) {
grouped.put(key, grouped.get(key) + 1);
} else {
grouped.put(key, 1);
}
} else {
variableAndValue.put(importItemDataBean.getItemOID(), importItemDataBean.getValue());
grouped.put(importItemDataBean.getItemOID(), 1);
}
//
// }
}
}
ruleSets = ruleSetService.solidifyGroupOrdinalsUsingFormProperties(ruleSets, grouped);
importDataTrueRuleSets.addAll(ruleSets);
}
}
}
}
}
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetAuditDaoTest method testFindAllByRuleSet.
public void testFindAllByRuleSet() {
// RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
// RuleSetAuditDao ruleSetAuditDao = (RuleSetAuditDao) getContext().getBean("ruleSetAuditDao");
RuleSetBean ruleSet = ruleSetDao.findById(-1);
List<RuleSetAuditBean> ruleSetAudits = ruleSetAuditDao.findAllByRuleSet(ruleSet);
assertNotNull("ruleSetAudits is null", ruleSetAudits);
assertEquals("The size of the ruleSetAudits is not 2", new Integer(2), Integer.valueOf(ruleSetAudits.size()));
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetRuleAuditDaoTest method testFindAllByRuleSet.
public void testFindAllByRuleSet() {
// RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
// RuleSetRuleAuditDao ruleSetRuleAuditDao = (RuleSetRuleAuditDao) getContext().getBean("ruleSetRuleAuditDao");
RuleSetBean ruleSet = ruleSetDao.findById(-1);
List<RuleSetRuleAuditBean> ruleSetRuleAudits = ruleSetRuleAuditDao.findAllByRuleSet(ruleSet);
assertNotNull("ruleSetAudits is null", ruleSetRuleAudits);
assertEquals("The size of the ruleSetRuleAudits is not 2", new Integer(2), Integer.valueOf(ruleSetRuleAudits.size()));
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetDaoTest method createStubRuleSetBean.
private RuleSetBean createStubRuleSetBean(RuleBean ruleBean) {
RuleSetBean ruleSet = new RuleSetBean();
ruleSet.setTarget(createExpression(Context.OC_RULES_V1, "SE_ED2REPEA.F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_N"));
RuleSetRuleBean ruleSetRule = createRuleSetRule(ruleSet, ruleBean);
ruleSet.addRuleSetRule(ruleSetRule);
return ruleSet;
}
Aggregations