Ejemplo n.º 1
0
        public PostRepeatActionResponse RepeatAction(PostRepeatActionRequest request)
        {
            try
            {
                RelatedChanges.Clear();
                ProcessedElements.Clear();
                var response = new PostRepeatActionResponse();
                response.PlanElems = new PlanElements();

                var p = EndPointUtils.RequestPatientProgramDetail(request);

                // get module reference
                Module mod = PEUtils.FindElementById(p.Modules, request.Action.ModuleId);
                IPlanElementStrategy strategy = new StatePlanElementStrategy(new SetModulePropertiesForRepeat(mod));

                // clone and insert new action
                var cAction = PEUtils.CloneRepeatAction(request.Action, mod.AssignToId);
                cAction.CompletedBy = "CM";
                AddUniquePlanElementToProcessedList(cAction);

                // insert action update
                var action = NGUtils.UpdateProgramAction(request.Action, p);
                AddUniquePlanElementToProcessedList(request.Action);

                // insert action into module and update references
                ReplaceActionReferenceInModule(request.Action.Id, cAction, mod);
                strategy.Evoke();
                AddUniquePlanElementToProcessedList(mod);

                // save
                var pdetail = EndPointUtils.SaveAction(request, cAction.Id, p, true);

                // create element changed lists
                PEUtils.HydratePlanElementLists(ProcessedElements, response.PlanElems);

                response.PlanElems.Attributes = PEUtils.GetAttributes(pdetail.Attributes);
                response.RelatedChanges       = RelatedChanges;
                response.PatientId            = request.PatientId;
                response.Version = request.Version;

                return(response);
            }
            catch (Exception ex)
            {
                throw new Exception("AD:InterviewManager:ProcessActionResults()::" + ex.Message, ex.InnerException);
            }
        }