Search in sources :

Example 1 with ChildNoteBean

use of org.akaza.openclinica.bean.odmbeans.ChildNoteBean in project OpenClinica by OpenClinica.

the class ClinicalDataReportBean method addOneDN.

protected void addOneDN(DiscrepancyNoteBean dn, String currentIndent) {
    StringBuffer xml = this.getXmlOutput();
    String indent = this.getIndent();
    String nls = System.getProperty("line.separator");
    // Boolean p = s.length()>0||i.length()>0||d.toString().length()>0||n>0 ? true : false;
    xml.append(currentIndent + "<OpenClinica:DiscrepancyNote ");
    if (dn.getOid() != null) {
        String i = dn.getOid();
        if (i.length() > 0) {
            xml.append("ID=\"" + StringEscapeUtils.escapeXml(i) + "\" ");
        }
    }
    if (dn.getStatus() != null) {
        String s = dn.getStatus();
        if (s.length() > 0) {
            xml.append("Status=\"" + s + "\" ");
        }
    }
    if (dn.getNoteType() != null) {
        String s = dn.getNoteType();
        if (s.length() > 0) {
            xml.append("NoteType=\"" + s + "\" ");
        }
    }
    if (dn.getDateUpdated() != null) {
        Date d = dn.getDateUpdated();
        if (d.toString().length() > 0) {
            xml.append("DateUpdated=\"" + new SimpleDateFormat("yyyy-MM-dd").format(d) + "\" ");
        }
    }
    if (dn.getEntityName() != null) {
        String s = dn.getEntityName();
        if (s.length() > 0) {
            xml.append("EntityName=\"" + s + "\" ");
        }
    }
    int n = dn.getNumberOfChildNotes();
    if (n > 0) {
        xml.append("NumberOfChildNotes=\"" + dn.getNumberOfChildNotes() + "\"");
    }
    xml.append(">");
    xml.append(nls);
    if (dn.getChildNotes() != null && dn.getChildNotes().size() > 0) {
        for (ChildNoteBean cn : dn.getChildNotes()) {
            xml.append(currentIndent + indent + "<OpenClinica:ChildNote ");
            if (cn.getOid() != null) {
                String s = cn.getOid();
                if (s.length() > 0) {
                    xml.append("ID=\"" + s + "\" ");
                }
            }
            if (cn.getStatus() != null) {
                String s = cn.getStatus();
                if (s.length() > 0) {
                    xml.append("Status=\"" + s + "\" ");
                }
            }
            if (cn.getDateCreated() != null) {
                Date d = cn.getDateCreated();
                if (d.toString().length() > 0) {
                    xml.append("DateCreated=\"" + new SimpleDateFormat("yyyy-MM-dd").format(d) + "\" ");
                }
            }
            if (cn.getOwnerUserName() != "") {
                String ownerUserName = cn.getOwnerUserName();
                if (ownerUserName.length() > 0) {
                    xml.append("UserName=\"" + ownerUserName + "\" ");
                }
            }
            if (cn.getOwnerFirstName() != "" || cn.getOwnerLastName() != "") {
                String ownerLastName = cn.getOwnerLastName();
                String ownerFirstName = cn.getOwnerFirstName();
                if (ownerLastName.length() > 0 || ownerFirstName.length() > 0) {
                    xml.append("Name=\"" + ownerFirstName + " " + ownerLastName + "\"");
                }
            }
            xml.append(">");
            xml.append(nls);
            if (cn.getDescription() != null) {
                String dc = cn.getDescription();
                if (dc.length() > 0) {
                    xml.append(currentIndent + indent + indent + "<OpenClinica:Description>" + StringEscapeUtils.escapeXml(dc) + "</OpenClinica:Description>");
                    xml.append(nls);
                }
            }
            if (cn.getDetailedNote() != null) {
                String nt = cn.getDetailedNote();
                if (nt.length() > 0) {
                    xml.append(currentIndent + indent + indent + "<OpenClinica:DetailedNote>" + StringEscapeUtils.escapeXml(nt) + "</OpenClinica:DetailedNote>");
                    xml.append(nls);
                }
            }
            if (cn.getUserRef() != null) {
                String uid = cn.getUserRef().getElementDefOID();
                String userName = cn.getUserRef().getUserName();
                String fullName = cn.getUserRef().getFullName();
                String temp = "";
                if (userName.length() > 0) {
                    temp += " OpenClinica:UserName=\"" + StringEscapeUtils.escapeXml(userName) + "\"";
                }
                if (fullName.length() > 0) {
                    temp += " OpenClinica:FullName=\"" + StringEscapeUtils.escapeXml(fullName) + "\"";
                }
                if (uid.length() > 0) {
                    xml.append(currentIndent + indent + indent + "<UserRef UserOID=\"" + StringEscapeUtils.escapeXml(uid) + " \"" + temp + "/>");
                    xml.append(nls);
                }
            }
            xml.append(currentIndent + indent + "</OpenClinica:ChildNote>");
            xml.append(nls);
        }
    }
    xml.append(currentIndent + "</OpenClinica:DiscrepancyNote>");
    xml.append(nls);
}
Also used : ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 2 with ChildNoteBean

use of org.akaza.openclinica.bean.odmbeans.ChildNoteBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCSubjectDataDNs.

protected void setOCSubjectDataDNs(OdmClinicalDataBean data, String studySubjectOids, HashMap<String, String> subOidPoses) {
    this.setOCSubjectDataDNsTypesExpected();
    HashMap<String, ArrayList<ChildNoteBean>> pDNs = new HashMap<String, ArrayList<ChildNoteBean>>();
    // HashMap<String, ArrayList<DiscrepancyNoteBean>> sDNs = new HashMap<String, ArrayList<DiscrepancyNoteBean>>();
    logger.debug("Begin to execute GetOCSubjectDataDNsSql");
    logger.debug("getOCSubjectDataDNsSql= " + this.getOCSubjectDataDNsSql(studySubjectOids));
    ArrayList rows = select(this.getOCSubjectDataDNsSql(studySubjectOids));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        String studySubjectLabel = (String) row.get("study_subject_oid");
        Integer pdnId = (Integer) row.get("parent_dn_id");
        Integer dnId = (Integer) row.get("dn_id");
        String description = (String) row.get("description");
        String detailedNote = (String) row.get("detailed_notes");
        Integer ownerId = (Integer) row.get("owner_id");
        Date dateCreated = (Date) row.get("date_created");
        String status = (String) row.get("status");
        String noteType = (String) row.get("name");
        if (pdnId != null && pdnId > 0) {
            String key = studySubjectLabel + "-" + pdnId;
            ChildNoteBean cn = new ChildNoteBean();
            cn.setDateCreated(dateCreated);
            cn.setDescription(description);
            cn.setDetailedNote(detailedNote);
            cn.setStatus(status);
            cn.setOid("CDN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            cn.setUserRef(userRef);
            ArrayList<ChildNoteBean> cns = pDNs.containsKey(key) ? pDNs.get(key) : new ArrayList<ChildNoteBean>();
            cns.add(cn);
            pDNs.put(key, cns);
        } else {
            DiscrepancyNoteBean dn = new DiscrepancyNoteBean();
            String k = studySubjectLabel + "-" + dnId;
            if (pDNs != null && pDNs.containsKey(k)) {
                dn.setChildNotes(pDNs.get(k));
                dn.setNumberOfChildNotes(dn.getChildNotes().size());
            }
            dn.setDateUpdated(dateCreated);
            dn.setNoteType(noteType);
            dn.setStatus(status);
            dn.setOid("DN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            if (subOidPoses.containsKey(studySubjectLabel)) {
                int i = Integer.parseInt(subOidPoses.get(studySubjectLabel));
                String entityID = data.getExportSubjectData().get(i).getSubjectOID();
                data.getExportSubjectData().get(i).getDiscrepancyNotes().setEntityID(entityID);
                data.getExportSubjectData().get(i).getDiscrepancyNotes().getDiscrepancyNotes().add(dn);
            }
        }
    }
}
Also used : ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Date(java.util.Date)

Example 3 with ChildNoteBean

use of org.akaza.openclinica.bean.odmbeans.ChildNoteBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCEventDataDNs.

protected void setOCEventDataDNs(OdmClinicalDataBean data, String definitionOids, String studySubjectOids, HashMap<String, String> evnOidPoses) {
    this.setOCEventDataDNsTypesExpected();
    HashMap<String, ArrayList<ChildNoteBean>> pDNs = new HashMap<String, ArrayList<ChildNoteBean>>();
    // HashMap<String, ArrayList<DiscrepancyNoteBean>> sDNs = new HashMap<String, ArrayList<DiscrepancyNoteBean>>();
    logger.debug("Begin to execute GetOCEventDataDNsSql");
    logger.debug("getOCEventDataDNsSql= " + this.getOCEventDataDNsSql(definitionOids, studySubjectOids));
    ArrayList rows = select(this.getOCEventDataDNsSql(definitionOids, studySubjectOids));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        String studySubjectLabel = (String) row.get("study_subject_oid");
        String defOid = (String) row.get("definition_oid");
        Integer pdnId = (Integer) row.get("parent_dn_id");
        Integer dnId = (Integer) row.get("dn_id");
        String description = (String) row.get("description");
        String detailedNote = (String) row.get("detailed_notes");
        Integer ownerId = (Integer) row.get("owner_id");
        Date dateCreated = (Date) row.get("date_created");
        String status = (String) row.get("status");
        String noteType = (String) row.get("name");
        String oidKey = studySubjectLabel + defOid;
        if (pdnId != null && pdnId > 0) {
            String key = oidKey + pdnId;
            ChildNoteBean cn = new ChildNoteBean();
            cn.setDateCreated(dateCreated);
            cn.setDescription(description);
            cn.setDetailedNote(detailedNote);
            cn.setStatus(status);
            cn.setOid("CDN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            cn.setUserRef(userRef);
            ArrayList<ChildNoteBean> cns = pDNs.containsKey(key) ? pDNs.get(key) : new ArrayList<ChildNoteBean>();
            cns.add(cn);
            pDNs.put(key, cns);
        } else {
            DiscrepancyNoteBean dn = new DiscrepancyNoteBean();
            String k = oidKey + dnId;
            if (pDNs != null && pDNs.containsKey(k)) {
                dn.setChildNotes(pDNs.get(k));
                dn.setNumberOfChildNotes(dn.getChildNotes().size());
            }
            dn.setDateUpdated(dateCreated);
            dn.setNoteType(noteType);
            dn.setStatus(status);
            dn.setOid("DN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            if (evnOidPoses.containsKey(oidKey)) {
                String[] poses = evnOidPoses.get(oidKey).split("---");
                int p0 = Integer.parseInt(poses[0]);
                int p1 = Integer.parseInt(poses[1]);
                String entityID = data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getStudyEventOID();
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getDiscrepancyNotes().setEntityID(entityID);
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getDiscrepancyNotes().getDiscrepancyNotes().add(dn);
            }
        }
    }
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) Iterator(java.util.Iterator)

Example 4 with ChildNoteBean

use of org.akaza.openclinica.bean.odmbeans.ChildNoteBean in project OpenClinica by OpenClinica.

the class OdmExtractDAO method setOCFormDataDNs.

protected void setOCFormDataDNs(OdmClinicalDataBean data, String ecIds, HashMap<Integer, String> formOidPoses) {
    this.setOCFormDataDNsTypesExpected();
    HashMap<String, ArrayList<ChildNoteBean>> pDNs = new HashMap<String, ArrayList<ChildNoteBean>>();
    // HashMap<String, ArrayList<DiscrepancyNoteBean>> sDNs = new HashMap<String, ArrayList<DiscrepancyNoteBean>>();
    logger.debug("Begin to execute GetOCEventDataDNsSql");
    logger.debug("getOCFormDataDNsSql= " + this.getOCFormDataDNsSql(ecIds));
    ArrayList rows = select(this.getOCFormDataDNsSql(ecIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer ecId = (Integer) row.get("event_crf_id");
        Integer pdnId = (Integer) row.get("parent_dn_id");
        Integer dnId = (Integer) row.get("dn_id");
        String description = (String) row.get("description");
        String detailedNote = (String) row.get("detailed_notes");
        Integer ownerId = (Integer) row.get("owner_id");
        Date dateCreated = (Date) row.get("date_created");
        String status = (String) row.get("status");
        String noteType = (String) row.get("name");
        if (pdnId != null && pdnId > 0) {
            String key = ecId + "-" + pdnId;
            ChildNoteBean cn = new ChildNoteBean();
            cn.setDateCreated(dateCreated);
            cn.setDescription(description);
            cn.setDetailedNote(detailedNote);
            cn.setStatus(status);
            cn.setOid("CDN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            cn.setUserRef(userRef);
            ArrayList<ChildNoteBean> cns = pDNs.containsKey(key) ? pDNs.get(key) : new ArrayList<ChildNoteBean>();
            cns.add(cn);
            pDNs.put(key, cns);
        } else {
            DiscrepancyNoteBean dn = new DiscrepancyNoteBean();
            String k = ecId + "-" + dnId;
            if (pDNs != null && pDNs.containsKey(k)) {
                dn.setChildNotes(pDNs.get(k));
                dn.setNumberOfChildNotes(dn.getChildNotes().size());
            }
            dn.setDateUpdated(dateCreated);
            dn.setNoteType(noteType);
            dn.setStatus(status);
            dn.setOid("DN_" + dnId);
            ElementRefBean userRef = new ElementRefBean();
            userRef.setElementDefOID("USR_" + ownerId);
            if (formOidPoses.containsKey(ecId)) {
                String[] poses = formOidPoses.get(ecId).split("---");
                int p0 = Integer.parseInt(poses[0]);
                int p1 = Integer.parseInt(poses[1]);
                int p2 = Integer.parseInt(poses[2]);
                String entityID = data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getFormOID();
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getDiscrepancyNotes().setEntityID(entityID);
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getDiscrepancyNotes().getDiscrepancyNotes().add(dn);
            }
        }
    }
}
Also used : ElementRefBean(org.akaza.openclinica.bean.odmbeans.ElementRefBean) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) ChildNoteBean(org.akaza.openclinica.bean.odmbeans.ChildNoteBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean) Iterator(java.util.Iterator)

Example 5 with ChildNoteBean

use of org.akaza.openclinica.bean.odmbeans.ChildNoteBean 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)

Aggregations

ChildNoteBean (org.akaza.openclinica.bean.odmbeans.ChildNoteBean)6 Date (java.util.Date)5 DiscrepancyNoteBean (org.akaza.openclinica.bean.odmbeans.DiscrepancyNoteBean)5 ElementRefBean (org.akaza.openclinica.bean.odmbeans.ElementRefBean)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Iterator (java.util.Iterator)4 LinkedHashMap (java.util.LinkedHashMap)4 SimpleDateFormat (java.text.SimpleDateFormat)1 DiscrepancyNote (org.akaza.openclinica.domain.datamap.DiscrepancyNote)1