Search in sources :

Example 16 with EventCrf

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

the class EventProcessor method processParticipant.

private void processParticipant(SubmissionContainer container, Errors errors, StudySubject studySubject, StudyEventDefinition studyEventDefinition) throws Exception {
    Integer ordinal = Integer.valueOf(container.getSubjectContext().get("studyEventOrdinal"));
    StudyEvent existingEvent = studyEventDao.fetchByStudyEventDefOIDAndOrdinal(studyEventDefinition.getOc_oid(), ordinal, studySubject.getStudySubjectId());
    if (existingEvent == null) {
        container.setStudyEvent(createStudyEvent(studySubject, studyEventDefinition, ordinal, container.getUser()));
    } else
        container.setStudyEvent(existingEvent);
    // Create event crf if it doesn't exist
    if (studyEventDefinition.getStatus() != Status.AVAILABLE) {
        logger.info("This Crf Version has a Status Not available in this Study Event Defn");
        errors.reject("This Crf Version has a Status Not available in this Study Event Defn");
        throw new Exception("This Crf Version has a Status Not available in this Study Event Defn");
    }
    CrfVersion crfVersion = crfVersionDao.findByOcOID(container.getSubjectContext().get("crfVersionOID"));
    EventCrf existingEventCrf = eventCrfDao.findByStudyEventIdStudySubjectIdCrfId(container.getStudyEvent().getStudyEventId(), container.getSubject().getStudySubjectId(), crfVersion.getCrf().getCrfId());
    if (existingEventCrf == null) {
        logger.info("***New EventCrf is created***");
        // create event crf
        container.setEventCrf(createEventCrf(crfVersion, container.getStudyEvent(), container.getSubject(), container.getUser()));
    } else if (existingEventCrf.getCrfVersion().getOcOid().equals(crfVersion.getOcOid())) {
        logger.info("***  Existing EventCrf with same CRF Version  ***");
        // use existing event crf
        container.setEventCrf(existingEventCrf);
    } else {
        // different version already exists. log error and abort submission
        errors.reject("Existing EventCrf with other CRF version");
        logger.info("***  Existing EventCrf with other CRF version  ***");
        throw new Exception("***  Existing EventCrf with other CRF version  ***");
    }
}
Also used : EventCrf(org.akaza.openclinica.domain.datamap.EventCrf) CrfVersion(org.akaza.openclinica.domain.datamap.CrfVersion) StudyEvent(org.akaza.openclinica.domain.datamap.StudyEvent)

Aggregations

EventCrf (org.akaza.openclinica.domain.datamap.EventCrf)16 CrfVersion (org.akaza.openclinica.domain.datamap.CrfVersion)9 Date (java.util.Date)6 StudyEvent (org.akaza.openclinica.domain.datamap.StudyEvent)6 StudySubject (org.akaza.openclinica.domain.datamap.StudySubject)5 EventDefinitionCrf (org.akaza.openclinica.domain.datamap.EventDefinitionCrf)4 Study (org.akaza.openclinica.domain.datamap.Study)4 StudyEventDefinition (org.akaza.openclinica.domain.datamap.StudyEventDefinition)4 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Item (org.akaza.openclinica.domain.datamap.Item)2 PFormCache (org.akaza.openclinica.web.pform.PFormCache)2 ResponseEntity (org.springframework.http.ResponseEntity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 StringReader (java.io.StringReader)1 List (java.util.List)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1