private static CaseNavigationItem CreateReportNavigationItem(Report report) { var item = new CaseNavigationItem() { ItemId = report.Id, ModuleType = report.ModuleType, Number = ReportInfoFormatter.FormatReportNumber(report), NavigationItemType = report.IsSupplement ? NavigationItemType.SupplementalReport : NavigationItemType.InitialReport, IsDraft = report.IsDraft }; var reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault(x => string.Compare(x.InvolvementType.Code, OfficerInvolvementTypes.Reporting.Code, StringComparison.InvariantCultureIgnoreCase) == 0); if (reportingOfficer == null) { reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault(); } if (reportingOfficer == null) { return(item); } item.ReportingDate = reportingOfficer.InvolvementDate; item.ReportingOfficer = reportingOfficer.OfficerName.Description; return(item); }
// Configure Mapper protected override void Configure() { #region Report => ReportQueueItem // This is the mapping for the common generic "report/workflow" queue data. CreateMap <Report, ReportQueueItem>() .ForMember(d => d.Number, o => o.MapFrom(s => ReportInfoFormatter.FormatReportNumber(s))) .ForMember(d => d.CaseNumber, o => o.MapFrom(s => string.IsNullOrWhiteSpace(s.CaseNumber) ? NoCaseAssigned : s.CaseNumber)) .ForMember(d => d.Agency, o => o.MapFrom(s => ReferenceDataHelper.GetOri(s.AgencyId))) .ForMember(d => d.Priority, o => o.MapFrom(s => s.Priority.GetDescription())) .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.Event.Description.Description)) .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description)) .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress)) .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description)) .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description)) .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description)) .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.Event == null ? string.Empty : CommonFormats.StandardDateTime(s.Event.StartDate))) .AfterMap((report, result) => { var reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault(x => string.Compare(x.InvolvementType.Code, OfficerInvolvementTypes.Reporting.Code, StringComparison.InvariantCultureIgnoreCase) == 0); if (reportingOfficer == null) { reportingOfficer = report.Officers.ReportingOfficers().FirstOrDefault(); } if (reportingOfficer != null) { result.ReportingOfficerId = reportingOfficer.OfficerName.Code; result.ReportingOfficerName = reportingOfficer.OfficerName.Description; } }); #endregion #region Case => CaseQueueItem // TODO DateTime Format CreateMap <Case, CaseQueueItem>() .ForMember(d => d.Location, o => o.MapFrom(s => s.Location.StreetAddress)) .ForMember(d => d.CrimeType, o => o.MapFrom(s => s.CrimeType.Description)) .AfterMap((@case, item) => { item.Agency = ReferenceDataHelper.GetOri(@case.AgencyId); // TODO Primary Offense...??? item.PrimaryOffense = string.Empty; //"TODO"; // TODO Related Cases??? item.RelatedCases = string.Empty; //"TODO"; }); #endregion #region ArrestSummary => ArrestSummaryQueueItem CreateMap <ArrestSummary, ArrestSummaryQueueItem>() .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number)) .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.ArrestEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.ArrestEvent.StartDate))) .ForMember(d => d.EventLocationBeat, o => o.MapFrom(s => s.Event.Address.Beat.Description)) .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description)) .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress)) .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description)) .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description)) .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description)) .AfterMap((summary, info) => { info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId); var arrestee = summary.Arrestee; if (arrestee != null) { info.Arrestee = arrestee.FullName; info.DateBorn = arrestee.DateOfBirth; info.Sex = arrestee.Sex.Description; info.Race = arrestee.Race.Description; } var charge = summary.ArrestCharges.FirstOrDefault(); if (charge != null) { //info.Charge = charge.Description;} info.Charge = charge.ViolationCodeReference.Description; } var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code); if (reportingOfficer != null) { info.ReportingOfficerId = reportingOfficer.OfficerName.Code; info.ReportingOfficerName = reportingOfficer.OfficerName.Description; info.EventDateReported = reportingOfficer.InvolvementDate; } var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code); if (supplementingOfficer != null) { info.SupplementingOfficerId = supplementingOfficer.OfficerName.Code; info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description; } }); #endregion #region IncidentSummary => IncidentSummaryQueueItem CreateMap <IncidentSummary, IncidentSummaryQueueItem>() .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.IncidentEvent == null ? null : s.IncidentEvent.StartDate)) .ForMember(d => d.Status, o => o.MapFrom(s => s.IncidentEvent.Status.Description)) .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.IncidentEvent.Description.Description)) .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.IncidentEvent.Address.CommonplaceName.Description)) .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.IncidentEvent.Address.StreetAddress)) .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.IncidentEvent.Address.City.Description)) .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.IncidentEvent.Address.State.Description)) .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.IncidentEvent.Address.ZipCode.Description)) .AfterMap((summary, info) => { info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId); var suspect = summary.Suspects.FirstOrDefault(); if (suspect != null) { info.Suspect = suspect.FullName; } var offense = summary.Offenses.FirstOrDefault(); if (offense != null) { //info.Offense = offense.Description;} info.Offense = offense.ViolationCodeReference.Description; } var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code); if (approvingOfficer != null) { info.ApprovingOfficerId = approvingOfficer.OfficerName.Code; info.ApprovingOfficerName = approvingOfficer.OfficerName.Description; } var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code); if (assistingOfficer != null) { info.AssistingOfficerId = assistingOfficer.OfficerName.Code; info.AssistingOfficerName = assistingOfficer.OfficerName.Description; } var investigatingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Investigating.Code); if (investigatingOfficer != null) { info.InvestigatingOfficerId = investigatingOfficer.OfficerName.Code; info.InvestigatingOfficerName = investigatingOfficer.OfficerName.Description; } var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code); if (reportingOfficer != null) { info.ReportingOfficerId = reportingOfficer.OfficerName.Code; info.ReportingOfficerName = reportingOfficer.OfficerName.Description; info.EventDateReported = reportingOfficer.InvolvementDate; } var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code); if (supplementingOfficer != null) { info.SupplementingOfficerId = supplementingOfficer.OfficerName.Code; info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description; } }); #endregion #region FieldInterviewSummary => FieldInterviewQueueItem CreateMap <FieldInterviewSummary, FieldInterviewSummaryQueueItem>() .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number)) .ForMember(d => d.IntelligenceConcerning, o => o.MapFrom(s => s.FieldInterviewEvent == null ? string.Empty : s.FieldInterviewEvent.IntelligenceConcerning)) .ForMember(d => d.ReasonForContact, o => o.MapFrom(s => s.FieldInterviewEvent == null ? string.Empty : (s.FieldInterviewEvent.ReasonsForContact.FirstOrDefault() == null ? string.Empty : s.FieldInterviewEvent.ReasonsForContact.First().Description))) .ForMember(d => d.DateTimeContact, o => o.MapFrom(s => s.FieldInterviewEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.FieldInterviewEvent.StartDate))) .ForMember(d => d.InfoEvaluation, o => o.MapFrom(s => s.FieldInterviewEvent.InfoEvaluation.Description)) .ForMember(d => d.LocationCommonplaceName, o => o.MapFrom(s => s.FieldInterviewEvent.Address.CommonplaceName.Description)) .ForMember(d => d.LocationCity, o => o.MapFrom(s => s.FieldInterviewEvent.Address.City.Description)) .ForMember(d => d.LocationState, o => o.MapFrom(s => s.FieldInterviewEvent.Address.State.Description)) .ForMember(d => d.LocationZipCode, o => o.MapFrom(s => s.FieldInterviewEvent.Address.ZipCode.Description)) .ForMember(d => d.LocationStreetAddress, o => o.MapFrom(s => s.FieldInterviewEvent.Address.StreetAddress)) .AfterMap((summary, result) => { // Find the first ReasonForContact. var reasonForContact = summary.FieldInterviewEvent != null ? summary.FieldInterviewEvent.ReasonsForContact.FirstOrDefault() : null; if (reasonForContact != null) { result.ReasonForContact = reasonForContact.Description; } // Find the first Source. var source = summary.FieldInterviewSources.FirstOrDefault(); if (source != null) { result.Sex = source.Sex.Description; result.Race = source.Race.Description; result.DateBorn = source.DateOfBirth; result.ContactName = CommonFormats.FullName(source.LastName, source.FirstName, source.MiddleName, source.Suffix); } var reportingOfficer = summary.Officers.ReportingOfficers().FirstOrDefault(); if (reportingOfficer != null) { result.ReportingOfficerId = reportingOfficer.OfficerName.Code; result.ReportingOfficerName = reportingOfficer.OfficerName.Description; } var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code); if (supplementingOfficer != null) { result.SupplementingOfficerId = supplementingOfficer.OfficerName.Code; result.SupplementingOfficerName = supplementingOfficer.OfficerName.Description; } }); #endregion #region CitationSummary => CitationSummaryQueueItem CreateMap <CitationSummary, CitationSummaryQueueItem>() .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number)) .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.Event == null ? string.Empty : CommonFormats.StandardDateTime(s.Event.StartDate))) .ForMember(d => d.EventLocationBeat, o => o.MapFrom(s => s.Event.Address.Beat.Description)) .ForMember(d => d.EventDescription, o => o.MapFrom(s => s.Event.Description.Description)) .ForMember(d => d.EventLocationCommonplaceName, o => o.MapFrom(s => s.Event.Address.CommonplaceName.Description)) .ForMember(d => d.EventLocationStreetAddress, o => o.MapFrom(s => s.Event.Address.StreetAddress)) .ForMember(d => d.EventLocationCity, o => o.MapFrom(s => s.Event.Address.City.Description)) .ForMember(d => d.EventLocationState, o => o.MapFrom(s => s.Event.Address.State.Description)) .ForMember(d => d.EventLocationZipCode, o => o.MapFrom(s => s.Event.Address.ZipCode.Description)) .ForMember(d => d.EventLocationCounty, o => o.MapFrom(s => s.Event.Address.County.Description)) .ForMember(d => d.IsVoided, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.IsVoided.Description)) .ForMember(d => d.ReadyForPublish, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.ReadyForPublish.Description)) .ForMember(d => d.ReadyForCourt, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.ReadyForCourt.Description)) .ForMember(d => d.CitationDescription, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.CitationDescription.Description)) .ForMember(d => d.CitationType, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : s.CitationEvent.CitationType.Description)) .ForMember(d => d.CourtDate, o => o.MapFrom(s => s.CitationEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.CitationEvent.CourtDate))) .AfterMap((summary, info) => { info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId); var subject = summary.Subject; if (subject != null) { info.Subject = subject.FullName; info.DateBorn = subject.DateOfBirth; info.Sex = subject.Sex.Description; info.Race = subject.Race.Description; } //put list of all charges and concat together /* * var charge = summary.CitationCharges.ToList(); * var dex = 1; * foreach (var citationCharge in charge) * { * info.Charge = info.Charge + "[Charge: " + dex + "] " + citationCharge.ViolationCodeReference.Description + " \n"; * dex++; * } */ var offense = summary.Offenses.FirstOrDefault(); if (offense != null) { info.Charge = offense.ViolationCodeReference.Description; } var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code); if (reportingOfficer != null) { info.ReportingOfficerId = reportingOfficer.OfficerName.Code; info.ReportingOfficerName = reportingOfficer.OfficerName.Description; info.EventDateReported = reportingOfficer.InvolvementDate; } var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code); if (approvingOfficer != null) { info.ApprovingOfficerId = approvingOfficer.OfficerName.Code; info.ApprovingOfficerName = approvingOfficer.OfficerName.Description; } var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code); if (assistingOfficer != null) { info.AssistingOfficerId = assistingOfficer.OfficerName.Code; info.AssistingOfficerName = assistingOfficer.OfficerName.Description; } var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code); if (supplementingOfficer != null) { info.SupplementingOfficerId = supplementingOfficer.OfficerName.Code; info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description; } }); #endregion #region CallForServiceSummary => CallForServiceSummaryQueueItem CreateMap <CallForServiceSummary, CallForServiceSummaryQueueItem>() .ForMember(d => d.Beat, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.Beat.Description)) .ForMember(d => d.CallStatus, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.WhichQueue.Description)) .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number)) // TODO: map derived field CasePendingTime .ForMember(d => d.City, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.City.Description)) .ForMember(d => d.CommonplaceName, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.CommonplaceName.Description)) // TODO: map derived field Disposition .ForMember(d => d.EnteredBy, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.CallTakingPerformedBy.Description)) .ForMember(d => d.EventDate, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : CommonFormats.StandardDateTime(s.CallForServiceEvent.StartDate))) .ForMember(d => d.CallPriority, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Priority.Description)) // TODO: map derived field ReportStatus .ForMember(d => d.SituationFound, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.SituationFound.Description)) .ForMember(d => d.SituationReported, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Problem.Description)) .ForMember(d => d.State, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.State.Description)) .ForMember(d => d.StreetAddress, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.StreetAddress)) .ForMember(d => d.ZipCode, o => o.MapFrom(s => s.CallForServiceEvent == null ? string.Empty : s.CallForServiceEvent.Address.ZipCode.Description)) .AfterMap((summary, info) => { info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId); // Map derived field Responders //string returnstring = string.Empty; string returnstring = string.Empty; if (summary.CallForServiceResponses != null) { foreach (CallForServiceResponse r in summary.CallForServiceResponses) { if (summary.CallForServiceResponses.Count > 1) { returnstring += " ["; } if (r.AssociatedResponders != null) { int responderCount = 1; foreach (AssociatedResponder ar in r.AssociatedResponders) { if (responderCount == 1) { returnstring += string.Format("{0}", ar.Name); } else { returnstring += " / " + string.Format("{0}", ar.Name); } responderCount++; } } if (summary.CallForServiceResponses.Count > 1) { returnstring += "] "; } } } info.Responders = returnstring.Trim(); }); #endregion #region OtherEventSummary => OtherEventSummaryQueueItem CreateMap <OtherEventSummary, OtherEventSummaryQueueItem>() .ForMember(d => d.CaseNumber, o => o.MapFrom(s => (s.CaseId == null || s.CaseId == Guid.Empty) ? NoCaseAssigned : s.Case.Number)) .ForMember(d => d.EventStartDate, o => o.MapFrom(s => s.OtherEventEvent == null ? null : s.OtherEventEvent.StartDate)) .ForMember(d => d.EventCategory, o => o.MapFrom(s => s.OtherEventEvent.EventCategory.Description)) .ForMember(d => d.EventStatus, o => o.MapFrom(s => s.OtherEventEvent.EventStatus.Description)) .ForMember(d => d.CommonplaceName, o => o.MapFrom(s => s.OtherEventEvent.Address.CommonplaceName.Description)) .ForMember(d => d.StreetAddress, o => o.MapFrom(s => s.OtherEventEvent.Address.StreetAddress)) .ForMember(d => d.City, o => o.MapFrom(s => s.OtherEventEvent.Address.City.Description)) .ForMember(d => d.State, o => o.MapFrom(s => s.OtherEventEvent.Address.State.Description)) .ForMember(d => d.ZipCode, o => o.MapFrom(s => s.OtherEventEvent.Address.ZipCode.Description)) .ForMember(d => d.County, o => o.MapFrom(s => s.OtherEventEvent.Address.County.Description)) .ForMember(d => d.Beat, o => o.MapFrom(s => s.OtherEventEvent.Address.Beat.Description)) .ForMember(d => d.Description, o => o.MapFrom(s => s.OtherEventEvent.Description.Description)) .AfterMap((summary, info) => { info.Agency = ReferenceDataHelper.GetOri(summary.AgencyId); var subject = summary.People.FirstOrDefault(); if (subject != null) { info.Subject = subject.FullName; } var offense = summary.Offenses.FirstOrDefault(); if (offense != null) { info.Charge = offense.ViolationCodeReference.Description; } var reportingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Reporting.Code); if (reportingOfficer != null) { info.ReportingOfficerId = reportingOfficer.OfficerName.Code; info.ReportingOfficerName = reportingOfficer.OfficerName.Description; } var supplementingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Supplementing.Code); if (supplementingOfficer != null) { info.SupplementingOfficerId = supplementingOfficer.OfficerName.Code; info.SupplementingOfficerName = supplementingOfficer.OfficerName.Description; } var assistingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Assisting.Code); if (assistingOfficer != null) { info.AssistingOfficerId = assistingOfficer.OfficerName.Code; info.AssistingOfficerName = assistingOfficer.OfficerName.Description; } var approvingOfficer = summary.Officers.FirstOrDefault(x => x.InvolvementType.Code == OfficerInvolvementTypes.Approving.Code); if (approvingOfficer != null) { info.ApprovingOfficerId = approvingOfficer.OfficerName.Code; info.ApprovingOfficerName = approvingOfficer.OfficerName.Description; } }); #endregion }