Search in sources :

Example 6 with DiscrepancyNote

use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.

the class AbstractItemProcessor method closeItemDiscrepancyNotes.

protected void closeItemDiscrepancyNotes(SubmissionContainer container, ItemData itemData) {
    ResourceBundleProvider.updateLocale(container.getLocale());
    ResourceBundle resword = ResourceBundleProvider.getWordsBundle(container.getLocale());
    // Notes & Discrepancies must be set to "closed" when event CRF is deleted
    // parentDiscrepancyNoteList is the list of the parent DNs records only
    List<DiscrepancyNote> parentDiscrepancyNoteList = discrepancyNoteDao.findParentNotesByItemData(itemData.getItemDataId());
    for (DiscrepancyNote parentDiscrepancyNote : parentDiscrepancyNoteList) {
        if (parentDiscrepancyNote.getResolutionStatus().getResolutionStatusId() != 4) {
            // if the DN's resolution
            // status is not set to
            // Closed
            String description = resword.getString("dn_auto-closed_description");
            String detailedNotes = resword.getString("dn_auto_closed_item_detailed_notes");
            // create new DN record , new DN Map record , also update the parent record
            DiscrepancyNote dn = new DiscrepancyNote();
            ResolutionStatus resStatus = resolutionStatusDao.findByResolutionStatusId(4);
            dn.setStudy(container.getStudy());
            dn.setEntityType("itemData");
            dn.setDescription(description);
            dn.setDetailedNotes(detailedNotes);
            // set to parent DN Type Id
            dn.setDiscrepancyNoteType(parentDiscrepancyNote.getDiscrepancyNoteType());
            // set to closed
            dn.setResolutionStatus(resStatus);
            dn.setUserAccount(container.getUser());
            dn.setUserAccountByOwnerId(container.getUser());
            dn.setParentDiscrepancyNote(parentDiscrepancyNote);
            dn.setDateCreated(new Date());
            dn = discrepancyNoteDao.saveOrUpdate(dn);
            // Create Mapping for new Discrepancy Note
            DnItemDataMapId dnItemDataMapId = new DnItemDataMapId();
            dnItemDataMapId.setDiscrepancyNoteId(dn.getDiscrepancyNoteId());
            dnItemDataMapId.setItemDataId(itemData.getItemDataId());
            dnItemDataMapId.setStudySubjectId(container.getSubject().getStudySubjectId());
            dnItemDataMapId.setColumnName("value");
            DnItemDataMap mapping = new DnItemDataMap();
            mapping.setDnItemDataMapId(dnItemDataMapId);
            mapping.setItemData(itemData);
            mapping.setStudySubject(container.getSubject());
            mapping.setActivated(false);
            mapping.setDiscrepancyNote(dn);
            dnItemDataMapDao.saveOrUpdate(mapping);
            DiscrepancyNote itemParentNote = discrepancyNoteDao.findByDiscrepancyNoteId(dn.getParentDiscrepancyNote().getDiscrepancyNoteId());
            itemParentNote.setResolutionStatus(resStatus);
            itemParentNote.setUserAccount(container.getUser());
            discrepancyNoteDao.saveOrUpdate(itemParentNote);
        }
    }
    // Deactivate existing mappings for this ItemData
    List<DnItemDataMap> existingMappings = dnItemDataMapDao.findByItemData(itemData.getItemDataId());
    for (DnItemDataMap mapping : existingMappings) {
        mapping.setActivated(false);
        dnItemDataMapDao.saveOrUpdate(mapping);
    }
}
Also used : ResolutionStatus(org.akaza.openclinica.domain.datamap.ResolutionStatus) DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) DnItemDataMapId(org.akaza.openclinica.domain.datamap.DnItemDataMapId) ResourceBundle(java.util.ResourceBundle) DnItemDataMap(org.akaza.openclinica.domain.datamap.DnItemDataMap) Date(java.util.Date)

Example 7 with DiscrepancyNote

use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.

private DiscrepancyNotesBean fetchDiscrepancyNotes(StudyEvent studyEvent) {
    List<DnStudyEventMap> dnMaps = studyEvent.getDnStudyEventMaps();
    DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
    dnNotesBean.setEntityID(studyEvent.getStudyEventDefinition().getOc_oid());
    DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
    ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
    boolean addDN = true;
    for (DnStudyEventMap dnMap : dnMaps) {
        DiscrepancyNote dn = dnMap.getDiscrepancyNote();
        addDN = true;
        fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnMap.getDnStudyEventMapId().getColumnName());
    }
    dnNotesBean.setDiscrepancyNotes(dnNotes);
    return dnNotesBean;
}
Also used : DiscrepancyNotesBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNotesBean) DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) DnStudyEventMap(org.akaza.openclinica.domain.datamap.DnStudyEventMap)

Example 8 with DiscrepancyNote

use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.

private DiscrepancyNotesBean fetchDiscrepancyNotes(ItemData itemData) {
    List<DnItemDataMap> dnItemDataMaps = itemData.getDnItemDataMaps();
    DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
    dnNotesBean.setEntityID(itemData.getItem().getOcOid());
    if (isCollectDns()) {
        DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
        ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
        boolean addDN = true;
        for (DnItemDataMap dnItemDataMap : dnItemDataMaps) {
            DiscrepancyNote dn = dnItemDataMap.getDiscrepancyNote();
            addDN = true;
            fillDNObject(dnNoteBean, dnNotes, addDN, dn, null);
        }
        dnNotesBean.setDiscrepancyNotes(dnNotes);
    }
    return dnNotesBean;
}
Also used : DiscrepancyNotesBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNotesBean) DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) DnItemDataMap(org.akaza.openclinica.domain.datamap.DnItemDataMap)

Example 9 with DiscrepancyNote

use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.

the class GenerateClinicalDataServiceImpl method fillDNObject.

private void fillDNObject(DiscrepancyNoteBean dnNoteBean, ArrayList<DiscrepancyNoteBean> dnNotes, boolean addDN, DiscrepancyNote dn, String columnName) {
    if (dn.getParentDiscrepancyNote() != null) {
    } else {
        dnNoteBean = new DiscrepancyNoteBean();
        dnNoteBean.setStatus(dn.getResolutionStatus().getName());
        dnNoteBean.setNoteType(dn.getEntityType());
        dnNoteBean.setOid("DN_" + dn.getDiscrepancyNoteId());
        dnNoteBean.setNoteType(dn.getDiscrepancyNoteType().getName());
        dnNoteBean.setDateUpdated(dn.getDateCreated());
        dnNoteBean.setEntityName(columnName);
        for (DiscrepancyNote childDN : dn.getChildDiscrepancyNotes()) {
            ChildNoteBean childNoteBean = new ChildNoteBean();
            childNoteBean.setOid("CDN_" + childDN.getDiscrepancyNoteId());
            ElementRefBean userRef = new ElementRefBean();
            childNoteBean.setDescription(childDN.getDescription());
            childNoteBean.setStatus(childDN.getResolutionStatus().getName());
            childNoteBean.setDetailedNote(childDN.getDetailedNotes());
            childNoteBean.setDateCreated(childDN.getDateCreated());
            if (childDN.getUserAccountByOwnerId() != null) {
                childNoteBean.setOwnerUserName(childDN.getUserAccountByOwnerId().getUserName());
                childNoteBean.setOwnerFirstName(childDN.getUserAccountByOwnerId().getFirstName());
                childNoteBean.setOwnerLastName(childDN.getUserAccountByOwnerId().getLastName());
            }
            if (childDN.getUserAccount() != null) {
                userRef.setElementDefOID("USR_" + childDN.getUserAccount().getUserId());
                userRef.setUserName(childDN.getUserAccount().getUserName());
                userRef.setFullName(childDN.getUserAccount().getFirstName() + " " + childDN.getUserAccount().getLastName());
            } else {
                userRef.setElementDefOID("");
                userRef.setUserName("");
                userRef.setFullName("");
            }
            childNoteBean.setUserRef(userRef);
            dnNoteBean.getChildNotes().add(childNoteBean);
        }
        dnNoteBean.setNumberOfChildNotes(dnNoteBean.getChildNotes().size());
        if (!dnNotes.contains(dnNoteBean)) {
            dnNotes.add(dnNoteBean);
        }
    }
}
Also used : DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean)

Example 10 with DiscrepancyNote

use of org.akaza.openclinica.domain.datamap.DiscrepancyNote in project OpenClinica by OpenClinica.

the class DiscrepancyNoteDao method findParentQueryByItemData.

public DiscrepancyNote findParentQueryByItemData(Integer itemDataId) {
    Query q = getCurrentSession().createQuery(findParentQueryByItemDataQuery);
    q.setParameter("itemDataId", itemDataId);
    return (DiscrepancyNote) q.uniqueResult();
}
Also used : DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) Query(org.hibernate.query.Query)

Aggregations

DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)12 ArrayList (java.util.ArrayList)6 DiscrepancyNoteBean (org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean)5 DiscrepancyNotesBean (org.akaza.openclinica.bean.odmbeans.DiscrepancyNotesBean)4 Date (java.util.Date)2 QueriesBean (org.akaza.openclinica.core.form.xform.QueriesBean)2 QueryBean (org.akaza.openclinica.core.form.xform.QueryBean)2 DnItemDataMap (org.akaza.openclinica.domain.datamap.DnItemDataMap)2 UserAccount (org.akaza.openclinica.domain.user.UserAccount)2 Query (org.hibernate.query.Query)2 IOException (java.io.IOException)1 ResourceBundle (java.util.ResourceBundle)1 ChildNoteBean (org.akaza.openclinica.bean.odmbeans.ChildNoteBean)1 ElementRefBean (org.akaza.openclinica.bean.odmbeans.ElementRefBean)1 LogBean (org.akaza.openclinica.core.form.xform.LogBean)1 AuditLogEvent (org.akaza.openclinica.domain.datamap.AuditLogEvent)1 DiscrepancyNoteType (org.akaza.openclinica.domain.datamap.DiscrepancyNoteType)1 DnEventCrfMap (org.akaza.openclinica.domain.datamap.DnEventCrfMap)1 DnItemDataMapId (org.akaza.openclinica.domain.datamap.DnItemDataMapId)1 DnStudyEventMap (org.akaza.openclinica.domain.datamap.DnStudyEventMap)1