Search in sources :

Example 1 with CrossReport

use of gov.ca.cwds.rest.api.domain.CrossReport in project API by ca-cwds.

the class ScreeningToReferralService method processCrossReports.

/*
   * CMS Cross Report
   */
private Set<gov.ca.cwds.rest.api.domain.CrossReport> processCrossReports(ScreeningToReferral scr, String referralId, Set<ErrorMessage> messages) throws ServiceException {
    String crossReportId = "";
    Set<gov.ca.cwds.rest.api.domain.CrossReport> resultCrossReports = new HashSet<>();
    Set<CrossReport> crossReports;
    crossReports = scr.getCrossReports();
    if (crossReports != null) {
        for (CrossReport crossReport : crossReports) {
            Boolean lawEnforcementIndicator = false;
            if (crossReport.getAgencyType().contains("Law Enforcement")) {
                lawEnforcementIndicator = true;
            }
            if (crossReport.getLegacyId() == null || crossReport.getLegacyId().isEmpty()) {
                // create the cross report
                gov.ca.cwds.rest.api.domain.cms.CrossReport cmsCrossReport = gov.ca.cwds.rest.api.domain.cms.CrossReport.createWithDefaults(crossReportId, crossReport, referralId, DEFAULT_STAFF_PERSON_ID, DEFAULT_COUNTY_SPECIFIC_CODE, lawEnforcementIndicator);
                buildErrors(messages, validator.validate(cmsCrossReport));
                gov.ca.cwds.rest.api.domain.cms.CrossReport postedCrossReport = this.crossReportService.create(cmsCrossReport);
                crossReport.setLegacyId(postedCrossReport.getThirdId());
                crossReport.setLegacySourceTable(CROSS_REPORT_TABLE_NAME);
                resultCrossReports.add(crossReport);
            } else {
                gov.ca.cwds.rest.api.domain.cms.CrossReport foundCrossReport = this.crossReportService.find(crossReport.getLegacyId());
                if (foundCrossReport == null) {
                    String message = " Legacy Id on Cross Report does not correspond to an existing CMS/CWS Cross Report ";
                    ServiceException se = new ServiceException(message);
                    logError(message, se, messages);
                }
            }
        }
    }
    return resultCrossReports;
}
Also used : CrossReport(gov.ca.cwds.rest.api.domain.CrossReport) HashSet(java.util.HashSet)

Example 2 with CrossReport

use of gov.ca.cwds.rest.api.domain.CrossReport in project API by ca-cwds.

the class ScreeningToReferralService method create.

@UnitOfWork(value = "cms")
@Override
public Response create(Request request) {
    ScreeningToReferral screeningToReferral = (ScreeningToReferral) request;
    Set<ErrorMessage> messages = new HashSet<ErrorMessage>();
    verifyReferralHasValidParticipants(screeningToReferral, messages);
    String dateStarted = extractStartDate(screeningToReferral, messages);
    String timeStarted = extractStartTime(screeningToReferral, messages);
    String referralId = createCmsReferral(screeningToReferral, messages, dateStarted, timeStarted);
    createReferralAddress(screeningToReferral, messages);
    Set<Participant> resultParticipants = new HashSet<>();
    HashMap<Long, String> victimClient = new HashMap<>();
    HashMap<Long, String> perpatratorClient = new HashMap<>();
    processParticipants(screeningToReferral, messages, dateStarted, referralId, resultParticipants, victimClient, perpatratorClient);
    Set<CrossReport> resultCrossReports = createCrossReports(screeningToReferral, messages, referralId);
    Set<Allegation> resultAllegations = createAllegations(screeningToReferral, messages, referralId, victimClient, perpatratorClient);
    PostedScreeningToReferral pstr = PostedScreeningToReferral.createWithDefaults(referralId, screeningToReferral, resultParticipants, resultCrossReports, resultAllegations);
    pstr.setMessages(messages);
    return pstr;
}
Also used : HashMap(java.util.HashMap) Participant(gov.ca.cwds.rest.api.domain.Participant) CrossReport(gov.ca.cwds.rest.api.domain.CrossReport) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) ScreeningToReferral(gov.ca.cwds.rest.api.domain.ScreeningToReferral) Allegation(gov.ca.cwds.rest.api.domain.Allegation) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) ErrorMessage(gov.ca.cwds.rest.api.domain.error.ErrorMessage) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) HashSet(java.util.HashSet) UnitOfWork(io.dropwizard.hibernate.UnitOfWork)

Aggregations

CrossReport (gov.ca.cwds.rest.api.domain.CrossReport)2 HashSet (java.util.HashSet)2 Allegation (gov.ca.cwds.rest.api.domain.Allegation)1 Participant (gov.ca.cwds.rest.api.domain.Participant)1 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)1 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)1 PostedAllegation (gov.ca.cwds.rest.api.domain.cms.PostedAllegation)1 ErrorMessage (gov.ca.cwds.rest.api.domain.error.ErrorMessage)1 UnitOfWork (io.dropwizard.hibernate.UnitOfWork)1 HashMap (java.util.HashMap)1