Search in sources :

Example 1 with PostedScreeningToReferral

use of gov.ca.cwds.rest.api.domain.PostedScreeningToReferral 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

Allegation (gov.ca.cwds.rest.api.domain.Allegation)1 CrossReport (gov.ca.cwds.rest.api.domain.CrossReport)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 HashSet (java.util.HashSet)1