use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method hideNew.
public void hideNew(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet) {
ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
ItemGroupMetadataBean itemGroupMetadataBeanA = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(), eventCrfBeanA.getCRFVersionId());
Boolean isGroupARepeating = isGroupRepeating(itemGroupMetadataBeanA);
String itemGroupAOrdinal = getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
for (PropertyBean propertyBean : properties) {
String oid = propertyBean.getOid();
ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
// OID is an item
if (itemOrItemGroup.getItemBean() != null) {
String expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
EventCRFBean eventCrfBeanB = eventCrfBeanA;
ItemGroupMetadataBean itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
Boolean isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
String itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
List<ItemDataBean> itemDataBeans = new ArrayList<ItemDataBean>();
// If A and B are both non repeating groups
if (!isGroupARepeating && !isGroupBRepeating) {
ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
itemDataBeans.add(oidBasedItemData);
}
// If A is not repeating group & B is a repeating group with no index selected
if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
List<ItemDataBean> oidBasedItemDatas = oneToMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
itemDataBeans.addAll(oidBasedItemDatas);
}
// If A is not repeating group & B is a repeating group with index selected
if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
itemDataBeans.add(oidBasedItemData);
}
// If A is repeating group with index & B is a repeating group with index selected
if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
itemDataBeans.add(oidBasedItemData);
}
// If A is repeating group with index & B is a repeating group with no index selected
if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupAOrdinal));
itemDataBeans.add(oidBasedItemData);
}
for (ItemDataBean oidBasedItemData : itemDataBeans) {
ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(), eventCrfBeanA.getCRFVersionId());
DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("")) {
hideNewItem(itemFormMetadataBean, eventCrfBeanA, oidBasedItemData);
} else if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("")) {
// tbh #5287: add an additional check here to see if it should be hidden
dynamicsMetadataBean.setShowItem(false);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
}
}
} else // OID is a group
{
// ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
// below taken from showNew and reversed, tbh 07/2010
logger.debug("found item group id 1 " + oid);
ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
ArrayList sectionBeans = getSectionDAO().findAllByCRFVersionId(eventCrfBeanA.getCRFVersionId());
for (int i = 0; i < sectionBeans.size(); i++) {
SectionBean sectionBean = (SectionBean) sectionBeans.get(i);
// System.out.println("found section " + sectionBean.getId());
List<ItemGroupMetadataBean> itemGroupMetadataBeans = getItemGroupMetadataDAO().findMetaByGroupAndSection(itemGroupBean.getId(), eventCrfBeanA.getCRFVersionId(), sectionBean.getId());
for (ItemGroupMetadataBean itemGroupMetadataBean : itemGroupMetadataBeans) {
if (itemGroupMetadataBean.getItemGroupId() == itemGroupBean.getId()) {
// System.out.println("found item group id 2 " + oid);
DynamicsItemGroupMetadataBean dynamicsGroupBean = getDynamicsItemGroupMetadataBean(itemGroupMetadataBean, eventCrfBeanA);
if (dynamicsGroupBean == null) {
hideGroup(itemGroupMetadataBean, eventCrfBeanA);
} else if (dynamicsGroupBean != null && !dynamicsGroupBean.isShowGroup()) {
dynamicsGroupBean.setShowGroup(false);
getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
// TODO is below required in hide?
} else if (eventCrfBeanA.getStage().equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
//setVersion(1); // version 1 = passed DDE
dynamicsGroupBean.setPassedDde(1);
getDynamicsItemGroupMetadataDao().saveOrUpdate(dynamicsGroupBean);
}
}
}
}
}
}
// tbh #5287: reset the check to make sure items that have been shown are not re-hidden
// resetItemCounter();
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method insert.
private void insert(Integer itemDataId, List<PropertyBean> properties, UserAccountBean ub, RuleSetBean ruleSet, Status itemDataStatus, List<StratificationFactorBean> stratificationFactorBeans) {
ItemDataBean itemDataBeanA = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
EventCRFBean eventCrfBeanA = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBeanA.getEventCRFId());
StudyEventBean studyEventBeanA = (StudyEventBean) getStudyEventDAO().findByPK(eventCrfBeanA.getStudyEventId());
ItemGroupMetadataBean itemGroupMetadataBeanA = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemDataBeanA.getItemId(), eventCrfBeanA.getCRFVersionId());
Boolean isGroupARepeating = isGroupRepeating(itemGroupMetadataBeanA);
String itemGroupAOrdinal = getExpressionService().getGroupOrdninalCurated(ruleSet.getTarget().getValue());
for (PropertyBean propertyBean : properties) {
String expression = getExpressionService().constructFullExpressionIfPartialProvided(propertyBean.getOid(), ruleSet.getTarget().getValue());
ItemBean itemBeanB = getExpressionService().getItemBeanFromExpression(expression);
ItemGroupBean itemGroupBeanB = getExpressionService().getItemGroupExpression(expression);
ItemGroupMetadataBean itemGroupMetadataBeanB = null;
Boolean isGroupBRepeating = null;
String itemGroupBOrdinal = null;
EventCRFBean eventCrfBeanB = null;
Boolean isItemInSameForm = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemBeanB.getId(), eventCrfBeanA.getCRFVersionId()).getId() != 0 ? true : false;
// Item Does not below to same form
if (!isItemInSameForm) {
List<EventCRFBean> eventCrfs = getEventCRFDAO().findAllByStudyEventAndCrfOrCrfVersionOid(studyEventBeanA, getExpressionService().getCrfOid(expression));
if (eventCrfs.size() == 0) {
CRFVersionBean crfVersion = getExpressionService().getCRFVersionFromExpression(expression);
CRFBean crf = getExpressionService().getCRFFromExpression(expression);
int crfVersionId = 0;
EventDefinitionCRFBean eventDefinitionCRFBean = getEventDefinitionCRfDAO().findByStudyEventDefinitionIdAndCRFId(studyEventBeanA.getStudyEventDefinitionId(), crf.getId());
if (eventDefinitionCRFBean.getId() != 0) {
crfVersionId = crfVersion != null ? crfVersion.getId() : eventDefinitionCRFBean.getDefaultVersionId();
}
// Create new event crf
eventCrfBeanB = eventCrfBeanA.copy();
eventCrfBeanB.setStatus(Status.AVAILABLE);
eventCrfBeanB.setId(0);
eventCrfBeanB.setCRFVersionId(crfVersionId);
eventCrfBeanB = (EventCRFBean) getEventCRFDAO().create(eventCrfBeanB);
} else {
eventCrfBeanB = eventCrfs.get(0);
}
}
if (isItemInSameForm) {
eventCrfBeanB = eventCrfBeanA;
}
itemGroupMetadataBeanB = (ItemGroupMetadataBean) getItemGroupMetadataDAO().findByItemAndCrfVersion(itemBeanB.getId(), eventCrfBeanB.getCRFVersionId());
isGroupBRepeating = isGroupRepeating(itemGroupMetadataBeanB);
itemGroupBOrdinal = getExpressionService().getGroupOrdninalCurated(expression);
// If A and B are both non repeating groups
if (!isGroupARepeating && !isGroupBRepeating) {
ItemDataBean oidBasedItemData = oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is not repeating group & B is a repeating group with no index selected
if (!isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
List<ItemDataBean> oidBasedItemDatas = oneToMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
for (ItemDataBean oidBasedItemData : oidBasedItemDatas) {
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
}
// If A is not repeating group & B is a repeating group with index selected
if (!isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating/ non repeating group & B is a repeating group with index selected as END
if (isGroupBRepeating && itemGroupBOrdinal.equals("END")) {
ItemDataBean oidBasedItemData = oneToEndMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub);
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating group with index & B is a repeating group with index selected
if (isGroupARepeating && isGroupBRepeating && !itemGroupBOrdinal.equals("") && !itemGroupBOrdinal.equals("END")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupBOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// If A is repeating group with index & B is a repeating group with no index selected
if (isGroupARepeating && isGroupBRepeating && itemGroupBOrdinal.equals("")) {
ItemDataBean oidBasedItemData = oneToIndexedMany(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, Integer.valueOf(itemGroupAOrdinal));
oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA, stratificationFactorBeans));
if (itemDataStatus != null)
oidBasedItemData.setStatus(itemDataStatus);
getItemDataDAO().updateValue(oidBasedItemData, getDateFormat(propertyBean));
}
// // If A is repeating group with index & B is none-repeating group
// if (isGroupARepeating && !isGroupBRepeating ) {
// ItemDataBean oidBasedItemData =
// oneToOne(itemDataBeanA, eventCrfBeanA, itemGroupMetadataBeanA, itemBeanB, itemGroupMetadataBeanB, eventCrfBeanB, ub, 1);
//
// oidBasedItemData.setValue(getValue(propertyBean, ruleSet, eventCrfBeanA));
// getItemDataDAO().updateValue(oidBasedItemData, "yyyy-MM-dd");
// }
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class DynamicsMetadataService method hide.
public void hide(Integer itemDataId, List<PropertyBean> properties) {
ItemDataBean itemDataBean = (ItemDataBean) getItemDataDAO().findByPK(itemDataId);
EventCRFBean eventCrfBean = (EventCRFBean) getEventCRFDAO().findByPK(itemDataBean.getEventCRFId());
for (PropertyBean propertyBean : properties) {
String oid = propertyBean.getOid();
ItemOrItemGroupHolder itemOrItemGroup = getItemOrItemGroup(oid);
// OID is an item
if (itemOrItemGroup.getItemBean() != null) {
ItemDataBean oidBasedItemData = getItemData(itemOrItemGroup.getItemBean(), eventCrfBean, itemDataBean.getOrdinal());
ItemFormMetadataBean itemFormMetadataBean = getItemFormMetadataDAO().findByItemIdAndCRFVersionId(itemOrItemGroup.getItemBean().getId(), eventCrfBean.getCRFVersionId());
DynamicsItemFormMetadataBean dynamicsMetadataBean = getDynamicsItemFormMetadataBean(itemFormMetadataBean, eventCrfBean, oidBasedItemData);
if (dynamicsMetadataBean == null && oidBasedItemData.getValue().equals("")) {
showItem(itemFormMetadataBean, eventCrfBean, oidBasedItemData);
} else if (dynamicsMetadataBean != null && dynamicsMetadataBean.isShowItem() && oidBasedItemData.getValue().equals("")) {
dynamicsMetadataBean.setShowItem(false);
getDynamicsItemFormMetadataDao().saveOrUpdate(dynamicsMetadataBean);
}
} else // OID is a group
{
// ItemGroupBean itemGroupBean = itemOrItemGroup.getItemGroupBean();
}
}
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class StudySubjectServiceImpl method getUncompletedCRFs.
private ArrayList<DisplayEventDefinitionCRFBean> getUncompletedCRFs(List eventDefinitionCRFs, List eventCRFs, SubjectEventStatus status, Set<Integer> nonEmptyEventCrf, Map<Integer, FormLayoutBean> formLayoutById, Map<Integer, CRFBean> crfById) {
int i;
HashMap<Integer, Boolean> completed = new HashMap<Integer, Boolean>();
HashMap<Integer, EventCRFBean> startedButIncompleted = new HashMap<Integer, EventCRFBean>();
ArrayList<DisplayEventDefinitionCRFBean> answer = new ArrayList<DisplayEventDefinitionCRFBean>();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = formLayoutById.get(ecrf.getFormLayoutId()).getCrfId();
if (nonEmptyEventCrf.contains(ecrf.getId())) {
// this crf has data
// already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// available (i.e., not removed)
if (edcrf.getStatus().equals(Status.AVAILABLE)) {
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
}
return answer;
}
use of org.akaza.openclinica.bean.submit.EventCRFBean in project OpenClinica by OpenClinica.
the class ExpressionService method fixGroupOrdinal.
private String fixGroupOrdinal(String ruleExpression, String targetExpression, List<ItemDataBean> itemData, EventCRFBean eventCrf) {
String returnedRuleExpression = ruleExpression;
if (getItemGroupOid(ruleExpression).equals(getItemGroupOid(targetExpression))) {
if (getGroupOrdninalCurated(ruleExpression).equals("") && !getGroupOrdninalCurated(targetExpression).equals("")) {
returnedRuleExpression = replaceGroupOidOrdinalInExpression(ruleExpression, Integer.valueOf(getGroupOrdninalCurated(targetExpression)));
}
} else {
EventCRFBean theEventCrfBean = null;
if (eventCrf != null) {
theEventCrfBean = eventCrf;
} else if (!itemData.isEmpty()) {
theEventCrfBean = (EventCRFBean) getEventCRFDao().findByPK(itemData.get(0).getEventCRFId());
} else {
return returnedRuleExpression;
}
Integer itemId = itemData.isEmpty() ? ((EntityBean) getItemDao().findByOid(getItemOid(ruleExpression)).get(0)).getId() : itemData.get(0).getItemId();
ItemGroupMetadataBean itemGroupMetadataBean = (ItemGroupMetadataBean) getItemGroupMetadataDao().findByItemAndCrfVersion(itemId, theEventCrfBean.getCRFVersionId());
if (isGroupRepeating(itemGroupMetadataBean) && getGroupOrdninalCurated(ruleExpression).equals("")) {
returnedRuleExpression = replaceGroupOidOrdinalInExpression(ruleExpression, Integer.valueOf(getGroupOrdninalCurated(targetExpression)));
}
}
return returnedRuleExpression;
}
Aggregations