Search in sources :

Example 51 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteController method saveFieldNotes.

public void saveFieldNotes(String description, String detailedNotes, int entityId, String entityType, StudyBean sb, UserAccountBean ownerBean, UserAccountBean assignedUserBean, String resolutionStatus, String noteType, String entityName) {
    // Create a new thread each time
    DiscrepancyNoteBean parent = createDiscrepancyNoteBean(description, detailedNotes, entityId, entityType, sb, ownerBean, assignedUserBean, null, resolutionStatus, noteType, entityName);
    createDiscrepancyNoteBean(description, detailedNotes, entityId, entityType, sb, ownerBean, assignedUserBean, parent.getId(), resolutionStatus, noteType, entityName);
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 52 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteRow method compareColumn.

/*
     * (non-Javadoc)
     *
     * @see org.akaza.openclinica.core.EntityBeanRow#compareColumn(java.lang.Object,
     *      int)
     */
@Override
protected int compareColumn(Object row, int sortingColumn) {
    if (!row.getClass().equals(DiscrepancyNoteRow.class)) {
        return 0;
    }
    DiscrepancyNoteRow arg = (DiscrepancyNoteRow) row;
    DiscrepancyNoteBean thisNote = (DiscrepancyNoteBean) bean;
    DiscrepancyNoteBean argNote = (DiscrepancyNoteBean) arg.bean;
    int answer = 0;
    switch(sortingColumn) {
        case COL_SUBJECT:
            answer = thisNote.getSubjectName().toLowerCase().compareTo(argNote.getSubjectName().toLowerCase());
            break;
        case COL_EVENT:
            answer = thisNote.getEventName().toLowerCase().compareTo(argNote.getEventName().toLowerCase());
            break;
        case COL_EVENT_DATE:
            answer = compareDate(thisNote.getEventStart(), argNote.getEventStart());
            break;
        case COL_CRF:
            answer = thisNote.getCrfName().toLowerCase().compareTo(argNote.getCrfName().toLowerCase());
            break;
        case COL_DESCRIPTION:
            answer = thisNote.getDescription().toLowerCase().compareTo(argNote.getDescription().toLowerCase());
            break;
        case COL_DATE_CREATED:
            answer = compareDate(thisNote.getCreatedDate(), argNote.getCreatedDate());
            break;
        case COL_DATE_UPDATED:
            answer = compareDate(thisNote.getUpdatedDate(), argNote.getUpdatedDate());
            break;
        case COL_OWNER:
            answer = thisNote.getOwner().getName().toLowerCase().compareTo(argNote.getOwner().getName().toLowerCase());
            break;
        case COL_NUM_CHILDREN:
            answer = numChildren - arg.numChildren;
            break;
        case COL_TYPE:
            answer = thisNote.getDiscrepancyNoteTypeId() - argNote.getDiscrepancyNoteTypeId();
            break;
        case COL_RES_STATUS:
            answer = thisNote.getResolutionStatusId() - argNote.getResolutionStatusId();
            break;
        case COL_DETAILS:
            answer = thisNote.getDetailedNotes().toLowerCase().compareTo(argNote.getDetailedNotes().toLowerCase());
            break;
        case COL_ENTITY_TYPE:
            answer = thisNote.getEntityType().toLowerCase().compareTo(argNote.getEntityType().toLowerCase());
            break;
        case COL_ENTITY_NAME:
            answer = thisNote.getEntityName().toLowerCase().compareTo(argNote.getEntityName().toLowerCase());
            break;
        case COL_ENTITY_VALUE:
            answer = thisNote.getEntityValue().toLowerCase().compareTo(argNote.getEntityValue().toLowerCase());
            break;
    }
    return answer;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 53 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteRow method generateBeansFromRows.

public static ArrayList generateBeansFromRows(ArrayList rows) {
    ArrayList answer = new ArrayList();
    for (int i = 0; i < rows.size(); i++) {
        try {
            DiscrepancyNoteRow row = (DiscrepancyNoteRow) rows.get(i);
            DiscrepancyNoteBean bean = (DiscrepancyNoteBean) row.getBean();
            answer.add(bean);
        } catch (Exception e) {
        }
    }
    return answer;
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList)

Example 54 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteRow method setBean.

@Override
public void setBean(EntityBean bean) {
    super.setBean(bean);
    DiscrepancyNoteBean note = (DiscrepancyNoteBean) bean;
    type = DiscrepancyNoteType.get(note.getDiscrepancyNoteTypeId());
    status = ResolutionStatus.get(note.getResolutionStatusId());
}
Also used : DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)

Example 55 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DataImportService method submitData.

public ArrayList<String> submitData(ODMContainer odmContainer, DataSource dataSource, StudyBean studyBean, UserAccountBean userBean, List<DisplayItemBeanWrapper> displayItemBeanWrappers, Map<Integer, String> importedCRFStatuses) throws Exception {
    boolean discNotesGenerated = false;
    ItemDataDAO itemDataDao = new ItemDataDAO(dataSource);
    itemDataDao.setFormatDates(false);
    EventCRFDAO eventCrfDao = new EventCRFDAO(dataSource);
    StringBuffer auditMsg = new StringBuffer();
    int eventCrfBeanId = -1;
    EventCRFBean eventCrfBean = null;
    ArrayList<Integer> eventCrfInts;
    ItemDataBean itemDataBean;
    CrfBusinessLogicHelper crfBusinessLogicHelper = new CrfBusinessLogicHelper(dataSource);
    for (DisplayItemBeanWrapper wrapper : displayItemBeanWrappers) {
        boolean resetSDV = false;
        logger.debug("right before we check to make sure it is savable: " + wrapper.isSavable());
        if (wrapper.isSavable()) {
            eventCrfInts = new ArrayList<Integer>();
            logger.debug("wrapper problems found : " + wrapper.getValidationErrors().toString());
            if (wrapper.getDisplayItemBeans() != null && wrapper.getDisplayItemBeans().size() == 0) {
                return getReturnList("fail", "", "No items to submit. Please check your XML.");
            }
            for (DisplayItemBean displayItemBean : wrapper.getDisplayItemBeans()) {
                eventCrfBeanId = displayItemBean.getData().getEventCRFId();
                eventCrfBean = (EventCRFBean) eventCrfDao.findByPK(eventCrfBeanId);
                logger.debug("found value here: " + displayItemBean.getData().getValue());
                logger.debug("found status here: " + eventCrfBean.getStatus().getName());
                itemDataBean = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
                if (wrapper.isOverwrite() && itemDataBean.getStatus() != null) {
                    if (!itemDataBean.getValue().equals(displayItemBean.getData().getValue()))
                        resetSDV = true;
                    logger.debug("just tried to find item data bean on item name " + displayItemBean.getItem().getName());
                    itemDataBean.setUpdatedDate(new Date());
                    itemDataBean.setUpdater(userBean);
                    itemDataBean.setValue(displayItemBean.getData().getValue());
                    // set status?
                    itemDataDao.update(itemDataBean);
                    logger.debug("updated: " + itemDataBean.getItemId());
                    // need to set pk here in order to create dn
                    displayItemBean.getData().setId(itemDataBean.getId());
                } else {
                    resetSDV = true;
                    itemDataDao.create(displayItemBean.getData());
                    logger.debug("created: " + displayItemBean.getData().getItemId());
                    itemDataBean = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
                    // logger.debug("found: id " + itemDataBean2.getId() + " name " + itemDataBean2.getName());
                    displayItemBean.getData().setId(itemDataBean.getId());
                }
                ItemDAO idao = new ItemDAO(dataSource);
                ItemBean ibean = (ItemBean) idao.findByPK(displayItemBean.getData().getItemId());
                // logger.debug("*** checking for validation errors: " + ibean.getName());
                String itemOid = displayItemBean.getItem().getOid() + "_" + wrapper.getStudyEventRepeatKey() + "_" + displayItemBean.getData().getOrdinal() + "_" + wrapper.getStudySubjectOid();
                // wrapper.getValidationErrors().toString());
                if (wrapper.getValidationErrors().containsKey(itemOid)) {
                    ArrayList<String> messageList = (ArrayList<String>) wrapper.getValidationErrors().get(itemOid);
                    for (String message : messageList) {
                        DiscrepancyNoteBean parentDn = createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, null, userBean, dataSource, studyBean);
                        createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, parentDn.getId(), userBean, dataSource, studyBean);
                        discNotesGenerated = true;
                        logger.debug("*** created disc note with message: " + message);
                        auditMsg.append(wrapper.getStudySubjectOid() + ": " + ibean.getOid() + ": " + message + "---");
                    // split by this ? later, tbh
                    // displayItemBean);
                    }
                }
                if (!eventCrfInts.contains(new Integer(eventCrfBean.getId()))) {
                    String eventCRFStatus = importedCRFStatuses.get(new Integer(eventCrfBean.getId()));
                    if (eventCRFStatus != null && eventCRFStatus.equals(DataEntryStage.INITIAL_DATA_ENTRY.getName()) && eventCrfBean.getStatus().isAvailable()) {
                        crfBusinessLogicHelper.markCRFStarted(eventCrfBean, userBean, true);
                    } else {
                        crfBusinessLogicHelper.markCRFComplete(eventCrfBean, userBean, true);
                    }
                    eventCrfInts.add(new Integer(eventCrfBean.getId()));
                }
            }
            // Reset the SDV status if item data has been changed or added
            if (eventCrfBean != null && resetSDV)
                eventCrfDao.setSDVStatus(false, userBean.getId(), eventCrfBean.getId());
        }
    }
    if (!discNotesGenerated) {
        return getReturnList("success", "", auditMsg.toString());
    } else {
        return getReturnList("warn", "", auditMsg.toString());
    }
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) CrfBusinessLogicHelper(org.akaza.openclinica.web.job.CrfBusinessLogicHelper) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DisplayItemBeanWrapper(org.akaza.openclinica.bean.submit.DisplayItemBeanWrapper)

Aggregations

DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)122 ArrayList (java.util.ArrayList)81 HashMap (java.util.HashMap)62 Iterator (java.util.Iterator)44 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)34 Date (java.util.Date)20 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)20 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)20 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)20 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)18 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)18 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)13 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)11 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)11 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)11 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10