Search in sources :

Example 1 with ResolutionStatus

use of org.akaza.openclinica.domain.datamap.ResolutionStatus 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)

Aggregations

Date (java.util.Date)1 ResourceBundle (java.util.ResourceBundle)1 DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)1 DnItemDataMap (org.akaza.openclinica.domain.datamap.DnItemDataMap)1 DnItemDataMapId (org.akaza.openclinica.domain.datamap.DnItemDataMapId)1 ResolutionStatus (org.akaza.openclinica.domain.datamap.ResolutionStatus)1