Search in sources :

Example 81 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getDNotesForStudy.

/**
     * Acquire the DiscrepancyNoteBeans for a specific study.
     *
     * @param currentStudy
     *            A StudyBean object.
     * @param resolutionStatus
     *            An int resolution status; only DiscrepancyNoteBeans will be
     *            returned if they have this resolutionStatus id.
     * @param dataSource
     *            A DataSource used for various DAO methods.
     * @param discNoteType
     *            An int discrepancy note type id; only DiscrepancyNoteBeans
     *            will be returned if they have this discrepancyNoteTypeId.
     * @return A List of DiscrepancyNoteBeans.
     */
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, int resolutionStatus, DataSource dataSource, int discNoteType) {
    List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    if (currentStudy == null)
        return allDiscNotes;
    // Do the returned DN's have to be filtered? A valid resolution status
    // has to be between 1 and 5; 0 is "invalid";
    // -1 means that no resolutionStatus parameter was passed into the
    // servlet
    boolean filterDiscNotes = resolutionStatus >= 1 && resolutionStatus <= 5;
    boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    // what is the purpose of this data member?
    discrepancyNoteDAO.setFetchMapping(true);
    EventCRFDAO ecdao = new EventCRFDAO(dataSource);
    ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
    ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
    ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
    ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
    ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
    allDiscNotes.addAll(itemDataNotes);
    allDiscNotes.addAll(subjectNotes);
    allDiscNotes.addAll(studySubjectNotes);
    allDiscNotes.addAll(studyEventNotes);
    allDiscNotes.addAll(eventCRFNotes);
    if (filterDiscNotes) {
        // filter for the resolution status
        allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatus);
    }
    if (filterforDiscNoteType) {
        // filter for the ddiscrepancyNoteTypeId
        allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
    }
    return allDiscNotes;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 82 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DiscrepancyNoteUtil method getDNotesForStudy.

/**
     * An overloaded version of the prior method, the difference being a HashSet
     * of resolution status ids, instead of a single id.
     *
     * @param currentStudy
     *            A StudyBean object.
     * @param resolutionStatusIds
     *            A HashSet object consisting of resolution status ids (i.e.,
     *            1,2,3).
     * @param dataSource
     *            A DataSource used for various DAO methods.
     * @param discNoteType
     *            An int discrepancy note type id; only DiscrepancyNoteBeans
     *            will be returned if they have this discrepancyNoteTypeId.
     * @return A List of DiscrepancyNoteBeans.
     */
public List<DiscrepancyNoteBean> getDNotesForStudy(StudyBean currentStudy, Set<Integer> resolutionStatusIds, DataSource dataSource, int discNoteType) {
    List<DiscrepancyNoteBean> allDiscNotes = new ArrayList<DiscrepancyNoteBean>();
    if (currentStudy == null)
        return allDiscNotes;
    // Do the returned DN's have to be filtered? A valid resolution status
    // has to be between 1 and 5; 0 is "invalid";
    // -1 means that no resolutionStatus parameter was passed into the
    // servlet
    boolean filterDiscNotes = checkResolutionStatus(resolutionStatusIds);
    boolean filterforDiscNoteType = discNoteType >= 1 && discNoteType <= 4;
    DiscrepancyNoteDAO discrepancyNoteDAO = new DiscrepancyNoteDAO(dataSource);
    // what is the purpose of this data member?
    discrepancyNoteDAO.setFetchMapping(true);
    EventCRFDAO ecdao = new EventCRFDAO(dataSource);
    ArrayList itemDataNotes = discrepancyNoteDAO.findAllItemDataByStudy(currentStudy);
    ArrayList subjectNotes = discrepancyNoteDAO.findAllSubjectByStudy(currentStudy);
    ArrayList studySubjectNotes = discrepancyNoteDAO.findAllStudySubjectByStudy(currentStudy);
    ArrayList studyEventNotes = discrepancyNoteDAO.findAllStudyEventByStudy(currentStudy);
    ArrayList eventCRFNotes = discrepancyNoteDAO.findAllEventCRFByStudy(currentStudy);
    allDiscNotes.addAll(itemDataNotes);
    allDiscNotes.addAll(subjectNotes);
    allDiscNotes.addAll(studySubjectNotes);
    allDiscNotes.addAll(studyEventNotes);
    allDiscNotes.addAll(eventCRFNotes);
    if (filterDiscNotes) {
        // filter for the resolution status
        allDiscNotes = filterDiscNotes(allDiscNotes, resolutionStatusIds);
    }
    if (filterforDiscNoteType) {
        // filter for the ddiscrepancyNoteTypeId
        allDiscNotes = filterforDiscNoteType(allDiscNotes, discNoteType);
    }
    return allDiscNotes;
}
Also used : DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) ArrayList(java.util.ArrayList) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 83 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method downLoadDiscBeans.

public void downLoadDiscBeans(List<DiscrepancyNoteBean> listOfBeans, String format, OutputStream stream, String studyIdentifier) {
    if (listOfBeans == null) {
        return;
    }
    StringBuilder allContent = new StringBuilder();
    String singleBeanContent = "";
    int counter = 0;
    if (CSV.equalsIgnoreCase(format)) {
        for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
            ++counter;
            singleBeanContent = counter == 1 ? serializeToString(discNoteBean, true, 0) : serializeToString(discNoteBean, false, 0);
            allContent.append(singleBeanContent);
            allContent.append("\n");
        }
    }
    //This must be a ServletOutputStream for our purposes
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    try {
        if (CSV.equalsIgnoreCase(format)) {
            servletStream.print(allContent.toString());
        } else {
            //Create PDF version
            this.serializeListToPDF(listOfBeans, servletStream, studyIdentifier);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (servletStream != null) {
            try {
                servletStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) IOException(java.io.IOException)

Example 84 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method serializeListToPDF.

public void serializeListToPDF(List<DiscrepancyNoteBean> listOfBeans, OutputStream stream, String studyIdentifier) {
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    Document pdfDoc = new Document();
    try {
        PdfWriter.getInstance(pdfDoc, servletStream);
        pdfDoc.open();
        //Create header for the study identifier or name
        if (studyIdentifier != null) {
            HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
            header.setAlignment(Element.ALIGN_CENTER);
            Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
            para.setAlignment(Element.ALIGN_CENTER);
            pdfDoc.setHeader(header);
            pdfDoc.add(para);
        }
        for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
            pdfDoc.add(this.createTableFromBean(discNoteBean));
            pdfDoc.add(new Paragraph("\n"));
        }
    //pdfDoc.add(new Paragraph(content));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDoc.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) Color(java.awt.Color) DocumentException(com.lowagie.text.DocumentException) HeaderFooter(com.lowagie.text.HeaderFooter) Phrase(com.lowagie.text.Phrase) Document(com.lowagie.text.Document) Font(com.lowagie.text.Font) Paragraph(com.lowagie.text.Paragraph)

Example 85 with DiscrepancyNoteBean

use of org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean in project OpenClinica by OpenClinica.

the class DownloadDiscrepancyNote method serializeToPDF.

private void serializeToPDF(EntityBean bean, OutputStream stream) {
    ServletOutputStream servletStream = (ServletOutputStream) stream;
    DiscrepancyNoteBean discNBean = (DiscrepancyNoteBean) bean;
    StringBuilder writer = new StringBuilder();
    writer.append(serializeToString(discNBean, false, 0));
    Document pdfDoc = new Document();
    try {
        PdfWriter.getInstance(pdfDoc, servletStream);
        pdfDoc.open();
        pdfDoc.add(new Paragraph(writer.toString()));
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    pdfDoc.close();
}
Also used : ServletOutputStream(javax.servlet.ServletOutputStream) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DocumentException(com.lowagie.text.DocumentException) Document(com.lowagie.text.Document) Paragraph(com.lowagie.text.Paragraph)

Aggregations

DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)122 ArrayList (java.util.ArrayList)81 HashMap (java.util.HashMap)62 Iterator (java.util.Iterator)44 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)34 Date (java.util.Date)20 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)20 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)20 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)20 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)18 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)18 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)15 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)14 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)13 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)11 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)11 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)11 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10