// internal int createCorrectiveAction(EhriError ehriError, User submittedBy) private void createCorrectiveAction(User submittedBy) { //create corrective action CorrectiveAction correctiveAction = new CorrectiveAction(); correctiveAction.EmplId = entity.EmplId; correctiveAction.Employee = entity.Employee; correctiveAction.NOACode = "000"; correctiveAction.NatureOfAction = referenceService.RetrieveNatureOfAction("000"); correctiveAction.Details = entity.Details; correctiveAction.EffectiveDateOfPar = DateTime.Now; correctiveAction.ParEffectiveDate = null; correctiveAction.IsPaymentMismatch=false; correctiveAction.ErrorTypes = new System.Collections.Generic.List<ErrorType>(); correctiveAction.ActionId = 37; //37 Save As Draft correctiveAction.CreatedAtOrgId = submittedBy.OrgId.Value; correctiveAction.CreatedByUserId = submittedBy.UserId; correctiveAction.ActionRequestTypeId = 1; correctiveAction.RowVersion = 1; int caId = correctiveActionService.Save(correctiveAction,submittedBy); //create corrective action history item to denote it came from an EHRI error correctiveAction.Id = caId; string message = string.Format("Corrective Action Created from EHRI Error {0} by {1},<br/><br/>Details:<br/>{2}",entity.Id,submittedBy.DisplayName,entity.QmsErrorMessageText); correctiveActionService.addHistory(correctiveAction,submittedBy,message); //close out ehri error entity.CorrectiveActionId = caId; entity.ResolvedAt = DateTime.Now; }
internal int ExecuteUpdates(CorrectiveAction correctiveAction, User submittedBy, string history) { submitter = submittedBy; this.entity = correctiveAction; int retval = entity.Id; isNewTicket = retval == 0; routesToRBC = determineIfTicketRoutesToRBC(); // if submitted by PPRM this would need to be skipped StatusTransition action = referenceRepository.RetrieveOrgStatusTranstion(correctiveAction.ActionId); string actionToStatus = action.ToStatus.StatusCode; this.entity.StatusId = action.ToStatus.StatusId; if (isNewTicket) { this.entity.CreatedAt = DateTime.Now; this.entity.CreatedByUserId = submitter.UserId; this.entity.CreatedAtOrgId = submitter.OrgId.Value; this.entity.AssignedToOrgId = submitter.OrgId.Value; QmsCorrectiveactionrequest initialCar = correctiveAction.QmsCorrectiveActionRequest; correctiveActionRepository.context.Add(initialCar); correctiveActionRepository.context.SaveChanges(); retval = initialCar.Id; this.entity.Id = initialCar.Id; } else { this.entity.UpdatedAt = DateTime.Now; } if (actionToStatus == StatusType.UNASSIGNED) { ActionDescription = string.Format("{0} submitted Corrective Action for resolution<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Submitted; SubmitForResolution(); } else if (actionToStatus == StatusType.ASSIGNED) { ActionDescription = string.Format("{0} assigned Corrective Action<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Assigned; AssignToUser(entity); } else if (actionToStatus == StatusType.CLOSED) { ActionDescription = string.Format("{0} closed Corrective Action<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Closed; Close(entity); } else if (actionToStatus == StatusType.CLOSED_ACTION_COMPLETED) { ActionDescription = string.Format("{0} completed Corrective Action<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Closed; CloseActionCompleted(entity); } else if (actionToStatus == StatusType.DRAFT) { if (isNewTicket) { ActionDescription = string.Format("{0} created Corrective Action", submitter.DisplayName); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Created; SaveAsDraft(entity); } else { ActionDescription = string.Format("{0} withdrew Corrective Action<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Withdrawn; WithdrawItem(entity); } } else if (actionToStatus == StatusType.PENDING_REVIEW) { ActionDescription = string.Format("{0} submitted Corrective Action for review<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_PendingReview; SubmitForReview(entity); } else if (actionToStatus == StatusType.RETURNED) { ActionDescription = string.Format("{0} returned Corrective Action to originator<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Returned; Return(entity); } else if (actionToStatus == StatusType.REROUTED) { ActionDescription = string.Format("{0} rerouted Corrective Action<br/>{1}", submitter.DisplayName, history); correctiveActionService.addHistory(this.entity, submitter, ActionDescription); NotificationEventType = CorrectiveActionNotificationType.CA_Rerouted; Reroute(entity); } else { throw new InvalidStatusTypeException(actionToStatus + " is not a valid StatusType."); } QmsCorrectiveactionrequest car = this.entity.QmsCorrectiveActionRequest; correctiveActionRepository.Update(car); saveErrors(this.entity.ErrorTypes, retval, isNewTicket); correctiveActionRepository.context.SaveChanges(); return(retval); }