Search in sources :

Example 6 with ChildNoteBean

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

the class OdmExtractDAO method setOCItemDataDNs.

protected void setOCItemDataDNs(OdmClinicalDataBean data, String idataIds, HashMap<Integer, String> idataOidPoses) {
    this.setOCItemDataDNsTypesExpected();
    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 GetOCItemDataDNsSql");
    logger.debug("getOCItemDataDNsSql= " + this.getOCItemDataDNsSql(idataIds));
    ArrayList rows = select(this.getOCItemDataDNsSql(idataIds));
    Iterator iter = rows.iterator();
    while (iter.hasNext()) {
        HashMap row = (HashMap) iter.next();
        Integer idataId = (Integer) row.get("item_data_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 = idataId + "-" + 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 = idataId + "-" + 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 (idataOidPoses.containsKey(idataId)) {
                String[] poses = idataOidPoses.get(idataId).split("---");
                int p0 = Integer.parseInt(poses[0]);
                int p1 = Integer.parseInt(poses[1]);
                int p2 = Integer.parseInt(poses[2]);
                int p3 = Integer.parseInt(poses[3]);
                int p4 = Integer.parseInt(poses[4]);
                String entityID = data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getItemGroupData().get(p3).getItemData().get(p4).getItemOID();
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getItemGroupData().get(p3).getItemData().get(p4).getDiscrepancyNotes().setEntityID(entityID);
                data.getExportSubjectData().get(p0).getExportStudyEventData().get(p1).getExportFormData().get(p2).getItemGroupData().get(p3).getItemData().get(p4).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)

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