Search in sources :

Example 1 with DiscrepancyNote

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

the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.

private DiscrepancyNotesBean fetchDiscrepancyNotes(StudySubject studySubj) {
    List<DnStudySubjectMap> dnMaps = studySubj.getDnStudySubjectMaps();
    DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
    dnNotesBean.setEntityID(studySubj.getOcOid());
    DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
    DiscrepancyNoteBean dnSubjBean = new DiscrepancyNoteBean();
    ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
    boolean addDN = true;
    for (DnStudySubjectMap dnMap : dnMaps) {
        DiscrepancyNote dn = dnMap.getDiscrepancyNote();
        addDN = true;
        fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnMap.getDnStudySubjectMapId().getColumnName());
    }
    dnNotesBean.setDiscrepancyNotes(dnNotes);
    List<DnSubjectMap> dnSubjMaps = studySubj.getSubject().getDnSubjectMaps();
    ArrayList<DiscrepancyNoteBean> dnSubjs = new ArrayList<DiscrepancyNoteBean>();
    for (DnSubjectMap dnMap : dnSubjMaps) {
        DiscrepancyNote dn = dnMap.getDiscrepancyNote();
        addDN = true;
        fillDNObject(dnSubjBean, dnSubjs, addDN, dn, dnMap.getDnSubjectMapId().getColumnName());
    }
    for (DiscrepancyNoteBean dnSubjMap : dnSubjs) dnNotesBean.getDiscrepancyNotes().add(dnSubjMap);
    return dnNotesBean;
}
Also used : DnStudySubjectMap(org.akaza.openclinica.domain.datamap.DnStudySubjectMap) 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) DnSubjectMap(org.akaza.openclinica.domain.datamap.DnSubjectMap)

Example 2 with DiscrepancyNote

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

the class GenerateClinicalDataServiceImpl method fetchDiscrepancyNotes.

private DiscrepancyNotesBean fetchDiscrepancyNotes(EventCrf eventCrf) {
    LOGGER.info("Fetching the discrepancy notes..");
    List<DnEventCrfMap> dnEventCrfMaps = eventCrf.getDnEventCrfMaps();
    DiscrepancyNotesBean dnNotesBean = new DiscrepancyNotesBean();
    dnNotesBean.setEntityID(eventCrf.getCrfVersion().getCrf().getOcOid());
    DiscrepancyNoteBean dnNoteBean = new DiscrepancyNoteBean();
    ArrayList<DiscrepancyNoteBean> dnNotes = new ArrayList<DiscrepancyNoteBean>();
    boolean addDN = true;
    for (DnEventCrfMap dnItemDataMap : dnEventCrfMaps) {
        DiscrepancyNote dn = dnItemDataMap.getDiscrepancyNote();
        addDN = true;
        fillDNObject(dnNoteBean, dnNotes, addDN, dn, dnItemDataMap.getDnEventCrfMapId().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) DnEventCrfMap(org.akaza.openclinica.domain.datamap.DnEventCrfMap)

Example 3 with DiscrepancyNote

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

the class QueryServiceImpl method updateParentQuery.

private void updateParentQuery(QueryServiceHelperBean helperBean) {
    if (helperBean.getDn().getParentDiscrepancyNote() == null)
        return;
    DiscrepancyNote itemParentNote = discrepancyNoteDao.findByDiscrepancyNoteId(helperBean.getDn().getParentDiscrepancyNote().getDiscrepancyNoteId());
    itemParentNote.setResolutionStatus(helperBean.getResStatus());
    discrepancyNoteDao.saveOrUpdate(itemParentNote);
}
Also used : DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote)

Example 4 with DiscrepancyNote

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

the class QueryServiceImpl method createQuery.

private DiscrepancyNote createQuery(QueryServiceHelperBean helperBean, QueryBean queryBean) throws Exception {
    DiscrepancyNote dn = new DiscrepancyNote();
    dn.setStudy(helperBean.getContainer().getStudy());
    dn.setEntityType("itemData");
    dn.setDescription("description");
    dn.setDetailedNotes(queryBean.getComment());
    dn.setDiscrepancyNoteType(new DiscrepancyNoteType(3));
    String user = queryBean.getUser();
    if (user == null) {
        dn.setUserAccountByOwnerId(helperBean.getContainer().getUser());
    } else {
        UserAccount userAccountByOwnerId = userAccountDao.findByUserName(user);
        dn.setUserAccountByOwnerId(userAccountByOwnerId);
    }
    setResolutionStatus(queryBean, dn);
    String assignedTo = "";
    if (queryBean.getComment().startsWith("Automatic query for:")) {
        assignedTo = helperBean.getContainer().getUser().getUserName();
    } else {
        assignedTo = queryBean.getAssigned_to();
    }
    if (!StringUtils.isEmpty(assignedTo)) {
        UserAccount userAccount = userAccountDao.findByUserName(assignedTo);
        helperBean.setUserAccount(userAccount);
        dn.setUserAccount(userAccount);
    }
    // create itemData when a query is created without an autosaved itemdata
    if (helperBean.getItemData() == null) {
        helperBean.setItemData(createBlankItemData(helperBean));
    }
    dn.setDateCreated(new Date());
    return dn;
}
Also used : DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) DiscrepancyNoteType(org.akaza.openclinica.domain.datamap.DiscrepancyNoteType) UserAccount(org.akaza.openclinica.domain.user.UserAccount) Date(java.util.Date)

Example 5 with DiscrepancyNote

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

the class QueryServiceImpl method process.

@Override
public void process(QueryServiceHelperBean helperBean, SubmissionContainer container, Node itemNode, int itemOrdinal) throws Exception {
    String node = itemNode.getTextContent();
    if (StringUtils.isEmpty(node))
        return;
    helperBean.setContainer(container);
    helperBean.setItemOrdinal(itemOrdinal);
    helperBean.setItemNode(itemNode);
    ItemData id = getItemData(helperBean);
    if (id == null) {
        helperBean.setItemData(createBlankItemData(helperBean));
    } else {
        helperBean.setItemData(id);
    }
    QueriesBean queries = null;
    try {
        ObjectMapper objectMapper = new ObjectMapper();
        queries = objectMapper.readValue(node, QueriesBean.class);
    } catch (IOException e) {
        logger.error(e.getMessage());
        throw e;
    }
    List<Integer> idList = new ArrayList();
    List<QueryBean> qBeans = queries.getQueries();
    QueryBean queryBean = null;
    DiscrepancyNote childDN = null;
    DiscrepancyNote parentDN = null;
    List<DiscrepancyNote> childDns = null;
    if (qBeans.size() > 0) {
        for (QueryBean qBean : qBeans) {
            idList.add(Integer.valueOf(qBean.getId()));
        }
        Collections.reverse(idList);
        queryBean = qBeans.get(0);
        parentDN = findQueryParent(helperBean);
        if (parentDN == null) {
            parentDN = createQuery(helperBean, queryBean);
            parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
            helperBean.setDn(parentDN);
            saveQueryItemDatamap(helperBean);
        }
        childDns = findChildQueries(helperBean);
        if (childDns.size() < qBeans.size()) {
            // Enketo passes JSON "id" attribute for unsubmitted queries only
            // if (StringUtils.isEmpty(queryBean.getId())){
            childDN = createQuery(helperBean, queryBean);
            childDN.setParentDiscrepancyNote(parentDN);
            childDN = discrepancyNoteDao.saveOrUpdate(childDN);
            parentDN.setUserAccount(childDN.getUserAccount());
            setResolutionStatus(queryBean, parentDN);
            parentDN.setUserAccountByOwnerId(helperBean.getContainer().getUser());
            parentDN.setDetailedNotes(childDN.getDetailedNotes());
            parentDN.setDiscrepancyNoteType(childDN.getDiscrepancyNoteType());
            parentDN = discrepancyNoteDao.saveOrUpdate(parentDN);
            helperBean.setDn(childDN);
            saveQueryItemDatamap(helperBean);
            handleEmailNotification(helperBean, queryBean);
        }
    }
}
Also used : DiscrepancyNote(org.akaza.openclinica.domain.datamap.DiscrepancyNote) QueriesBean(org.akaza.openclinica.core.form.xform.QueriesBean) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) ItemData(org.akaza.openclinica.domain.datamap.ItemData) QueryBean(org.akaza.openclinica.core.form.xform.QueryBean)

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