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 ***");
}
}
Aggregations