public void Delete(object entity)
        {
            DeleteInterventionDataRequest request = (DeleteInterventionDataRequest)entity;

            try
            {
                using (PatientGoalMongoContext ctx = new PatientGoalMongoContext(_dbName))
                {
                    var q = MB.Query <MEPatientIntervention> .EQ(b => b.Id, ObjectId.Parse(request.InterventionId));

                    var uv = new List <MB.UpdateBuilder>();
                    uv.Add(MB.Update.Set(MEPatientIntervention.TTLDateProperty, System.DateTime.UtcNow.AddDays(_expireDays)));
                    uv.Add(MB.Update.Set(MEPatientIntervention.DeleteFlagProperty, true));
                    uv.Add(MB.Update.Set(MEPatientIntervention.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                    uv.Add(MB.Update.Set(MEPatientIntervention.LastUpdatedOnProperty, DateTime.UtcNow));

                    IMongoUpdate update = MB.Update.Combine(uv);
                    ctx.PatientInterventions.Collection.Update(q, update);

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientIntervention.ToString(),
                                             request.InterventionId.ToString(),
                                             Common.DataAuditType.Delete,
                                             request.ContractNumber);
                }
            }
            catch (Exception) { throw; }
        }
Exemplo n.º 2
0
        public DeleteInterventionDataResponse DeleteIntervention(DeleteInterventionDataRequest request)
        {
            try
            {
                DeleteInterventionDataResponse result = new DeleteInterventionDataResponse();

                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientIntervention);

                List <PatientInterventionData> pid = (List <PatientInterventionData>)repo.Find(request.PatientGoalId);
                List <string> deletedIds           = null;
                if (pid != null && pid.Count > 0)
                {
                    deletedIds = new List <string>();
                    pid.ForEach(i =>
                    {
                        request.InterventionId = i.Id;
                        repo.Delete(request);
                        deletedIds.Add(request.InterventionId);
                    });
                }
                result.DeletedIds = deletedIds;
                result.Success    = true;
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 3
0
        public PutUpdateInterventionResponse UpdatePatientIntervention(PutUpdateInterventionRequest request)
        {
            try
            {
                PutUpdateInterventionResponse result = new PutUpdateInterventionResponse();

                IGoalRepository repo = Factory.GetRepository(request, RepositoryType.PatientIntervention);

                if (request.InterventionIdsList != null && request.InterventionIdsList.Count > 0)
                {
                    List <PatientInterventionData> pid = (List <PatientInterventionData>)repo.Find(request.PatientGoalId);
                    List <string> dbTaskIdList         = GetInterventionIds(pid);

                    // update existing intervention entries with a delete
                    List <string> excludes = dbTaskIdList.Except(request.InterventionIdsList).ToList <string>();
                    excludes.ForEach(ex =>
                    {
                        // create delete intervention request to insert
                        DeleteInterventionDataRequest dtr = new DeleteInterventionDataRequest {
                            InterventionId = ex, UserId = request.UserId
                        };
                        repo.Delete(dtr);
                    });
                }
                if (request.Intervention != null && request.Intervention.Id != "0")
                {
                    bool status = (bool)repo.Update(request);
                    if (status)
                    {
                        PatientInterventionData data = repo.FindByID(request.Intervention.Id) as PatientInterventionData;
                        result.InterventionData = data;
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 4
0
        public DeleteInterventionDataResponse Delete(DeleteInterventionDataRequest request)
        {
            DeleteInterventionDataResponse response = new DeleteInterventionDataResponse();

            try
            {
                if (string.IsNullOrEmpty(request.UserId))
                {
                    throw new UnauthorizedAccessException("PatientGoalDD:Get()::Unauthorized Access");
                }

                response         = Manager.DeleteIntervention(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                CommonFormatter.FormatExceptionResponse(response, base.Response, ex);

                string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0";
                Common.Helper.LogException(int.Parse(aseProcessID), ex);
            }
            return(response);
        }