コード例 #1
0
        public object FindByExternalRecordId(string externalRecordId)
        {
            PatientNoteData data = null;

            try
            {
                using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.EQ(MEPatientNote.ExternalRecordIdProperty, externalRecordId));
                    queries.Add(Query.EQ(MEPatientNote.DeleteFlagProperty, false));
                    queries.Add(Query.EQ(MEPatientNote.TTLDateProperty, BsonNull.Value));
                    IMongoQuery   mQuery = Query.And(queries);
                    MEPatientNote mePN   = ctx.PatientNotes.Collection.Find(mQuery).FirstOrDefault();
                    if (mePN != null)
                    {
                        data = new PatientNoteData
                        {
                            Id = mePN.Id.ToString(),
                        };
                    }
                }
                return(data);
            }
            catch (Exception) { throw; }
        }
コード例 #2
0
        public object Insert(object newEntity)
        {
            InsertPatientNoteDataRequest request = (InsertPatientNoteDataRequest)newEntity;
            PatientNoteData noteData             = request.PatientNote;
            string          noteId = string.Empty;
            MEPatientNote   meN    = null;

            try
            {
                if (noteData != null)
                {
                    meN = new MEPatientNote(this.UserId, noteData.CreatedOn)
                    {
                        PatientId         = ObjectId.Parse(noteData.PatientId),
                        Text              = noteData.Text,
                        ProgramIds        = Helper.ConvertToObjectIdList(noteData.ProgramIds),
                        ValidatedIdentity = noteData.ValidatedIdentity,
                        ContactedOn       = noteData.ContactedOn,
                        Type              = ObjectId.Parse(noteData.TypeId),
                        DeleteFlag        = false,
                        DataSource        = Helper.TrimAndLimit(noteData.DataSource, 50),
                        LastUpdatedOn     = noteData.UpdatedOn,
                        ExternalRecordId  = noteData.ExternalRecordId,
                        Duration          = noteData.Duration,
                    };

                    if (!string.IsNullOrEmpty(noteData.MethodId))
                    {
                        meN.MethodId = ObjectId.Parse(noteData.MethodId);
                    }
                    if (!string.IsNullOrEmpty(noteData.OutcomeId))
                    {
                        meN.OutcomeId = ObjectId.Parse(noteData.OutcomeId);
                    }
                    if (!string.IsNullOrEmpty(noteData.WhoId))
                    {
                        meN.WhoId = ObjectId.Parse(noteData.WhoId);
                    }
                    if (!string.IsNullOrEmpty(noteData.SourceId))
                    {
                        meN.SourceId = ObjectId.Parse(noteData.SourceId);
                    }

                    using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName))
                    {
                        ctx.PatientNotes.Collection.Insert(meN);

                        AuditHelper.LogDataAudit(this.UserId,
                                                 MongoCollectionName.PatientNote.ToString(),
                                                 meN.Id.ToString(),
                                                 Common.DataAuditType.Insert,
                                                 request.ContractNumber);

                        noteId = meN.Id.ToString();
                    }
                }
                return(noteId);
            }
            catch (Exception) { throw; }
        }
コード例 #3
0
 public AdminController(IArticleData articleData,
                        IApiErrorHandler apiErrorHandler,
                        AssignedMedicineData assignedMedicineData,
                        AssignedPlanData assignedPlanData,
                        IFeedbackData feedbackData,
                        ILabTestData labTestData,
                        IMapper mapper,
                        LabTestRequestsData labTestRequestsData,
                        MedicineData medicineData,
                        PatientNoteData patientNoteData,
                        UserData userData,
                        UserManager <ApplicationUser> userManager,
                        RoleManager <ApplicationRole> roleManager,
                        UserRoleData userRoleData,
                        PatientData patientData,
                        PatientProgressData patientProgressData)
 {
     _articleData          = articleData;
     _apiErrorHandler      = apiErrorHandler;
     _assignedMedicineData = assignedMedicineData;
     _assignedPlanData     = assignedPlanData;
     _feedbackData         = feedbackData;
     _labTestData          = labTestData;
     _mapper = mapper;
     _labTestRequestsData = labTestRequestsData;
     _medicineData        = medicineData;
     _patientNoteData     = patientNoteData;
     _userData            = userData;
     _userManager         = userManager;
     _roleManager         = roleManager;
     _userRoleData        = userRoleData;
     _patientData         = patientData;
     _patientProgressData = patientProgressData;
 }
コード例 #4
0
        public void InsertPatientNote_Test()
        {
            List <string> prog = new List <string>();

            prog.Add("558c756184ac0707d02f72c8");

            PatientNoteData data = new PatientNoteData
            {
                PatientId         = "5429d29984ac050c788bd34f",
                Text              = "GGGG",
                ProgramIds        = prog,
                TypeId            = "54909997d43323251c0a1dfe",
                MethodId          = "540f1da7d4332319883f3e8c",
                ValidatedIdentity = false,
                ContactedOn       = DateTime.Now.AddDays(4)
            };

            InsertPatientNoteDataRequest request = new InsertPatientNoteDataRequest
            {
                Context        = context,
                ContractNumber = contractNumber,
                UserId         = userId,
                Version        = version,
                PatientNote    = data,
                PatientId      = "5429d29984ac050c788bd34f",
            };

            string requestURL = string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Note", url, context, version, contractNumber, data.PatientId);
            //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note", "POST")]
            InsertPatientNoteDataResponse response = client.Post <InsertPatientNoteDataResponse>(requestURL, request);

            Assert.IsNotNull(response);
        }
コード例 #5
0
ファイル: PatientNoteTest.cs プロジェクト: rotovibe/engage
        public void GetPatientNote_Test_Passes()
        {
            GetPatientNoteDataRequest request = new GetPatientNoteDataRequest {
                Id = "530fb4d9d433230ea4e8bdfa"
            };

            PatientNoteData response = m.GetPatientNote(request);

            Assert.IsNotNull(response);
        }
コード例 #6
0
ファイル: PatientNoteTest.cs プロジェクト: rotovibe/engage
        public void GetPatientNote_Test_Fails()
        {
            GetPatientNoteDataRequest request = new GetPatientNoteDataRequest {
                Id = "52f5589c072ef709f84e7798"
            };

            PatientNoteData response = m.GetPatientNote(request);

            Assert.IsNull(response);
        }
コード例 #7
0
        public PatientNoteData MapPatientNote(string patientMongoId, PatientNote n)
        {
            var pnote = new PatientNoteData
            {
                ExternalRecordId = n.NoteId.ToString(),
                Text             = n.Note,
                PatientId        = n.PatientId.ToString(), // look into this.
                DataSource       = _dataSource,
                CreatedOn        = n.CreatedDate.GetValueOrDefault(),
                CreatedById      = Constants.SystemContactId,
                TypeId           = GetNoteType(Convert.ToInt32(n.ActionID), n.CategoryId)// get note type
            };

            if (!pnote.TypeId.Equals("54909997d43323251c0a1dfe"))
            {
                return(pnote);
            }

            if (pnote.TypeId.Equals("54909997d43323251c0a1dfe"))
            {
                pnote.SourceId = "540f2091d4332319883f3e9c";//outbound
                //pnote.DurationId = "540f216cd4332319883f3e9e"; //not applicable
                pnote.ContactedOn = n.CreatedDate.GetValueOrDefault();
            }

            switch (n.ActionID)
            {
            case 1:
                pnote.MethodId  = "540f1da4d4332319883f3e8b";     //mail
                pnote.OutcomeId = "540f1f10d4332319883f3e92";     // successful
                pnote.WhoId     = "540f1fbcd4332319883f3e95";
                break;

            case 2:
                pnote.MethodId  = "540f1d9dd4332319883f3e89";     //phone
                pnote.OutcomeId = "540f1f14d4332319883f3e93";     // unsuccessful
                pnote.WhoId     = "540f1fbcd4332319883f3e95";
                break;

            case 3:
                pnote.MethodId  = "540f1d9dd4332319883f3e89";     //phone
                pnote.OutcomeId = "540f1f10d4332319883f3e92";     // successful
                pnote.WhoId     = "540f1fbcd4332319883f3e95";
                break;

            case 4:
                pnote.MethodId  = "540f1d9dd4332319883f3e89"; //phone
                pnote.OutcomeId = "540f1f10d4332319883f3e92"; // successful
                pnote.WhoId     = "540f1fc0d4332319883f3e96"; //caremanager
                break;
            }
            return(pnote);
        }
コード例 #8
0
ファイル: PatientNoteTest.cs プロジェクト: rotovibe/engage
        public void InsertPatientNote_Test()
        {
            PatientNoteData n = new PatientNoteData {
                Text = "Note D data domain", PatientId = "531f2dcf072ef727c4d2a150", CreatedById = "531f2df5072ef727c4d2a3bc"
            };
            InsertPatientNoteDataRequest request = new InsertPatientNoteDataRequest {
                Version     = 1,
                PatientNote = n
            };
            string id = m.InsertPatientNote(request);

            Assert.IsNotNull(id);
        }
コード例 #9
0
 public PatientNoteData GetPatientNote(GetPatientNoteDataRequest request)
 {
     try
     {
         PatientNoteData             response = null;
         IMongoPatientNoteRepository repo     = Factory.GetRepository(RepositoryType.PatientNote);
         response = repo.FindByID(request.Id) as PatientNoteData;
         return(response);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #10
0
 public PatientController(LabTestRequestsData labTestRequestsData,
                          ApiErrorHandler apiErrorHandler,
                          IMapper mapper,
                          PatientNoteData patientNoteData,
                          PatientData patientData,
                          UserData userData,
                          PatientProgressData patientProgressData)
 {
     _labTestRequestsData = labTestRequestsData;
     _apiErrorHandler     = apiErrorHandler;
     _mapper              = mapper;
     _patientNoteData     = patientNoteData;
     _patientData         = patientData;
     _userData            = userData;
     _patientProgressData = patientProgressData;
 }
コード例 #11
0
        public PatientNote GetPatientNote(GetPatientNoteRequest request)
        {
            try
            {
                PatientNote result = null;
                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note/{Id}", "GET")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Note/{5}",
                                                                          DDPatientNoteUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber,
                                                                          request.PatientId,
                                                                          request.Id), request.UserId);

                GetPatientNoteDataResponse ddResponse = client.Get <GetPatientNoteDataResponse>(url);

                if (ddResponse != null && ddResponse.PatientNote != null)
                {
                    PatientNoteData n = ddResponse.PatientNote;
                    result = new PatientNote
                    {
                        Id                = n.Id,
                        PatientId         = n.PatientId,
                        Text              = n.Text,
                        ProgramIds        = n.ProgramIds,
                        CreatedOn         = n.CreatedOn,
                        CreatedById       = n.CreatedById,
                        TypeId            = n.TypeId,
                        MethodId          = n.MethodId,
                        OutcomeId         = n.OutcomeId,
                        WhoId             = n.WhoId,
                        SourceId          = n.SourceId,
                        Duration          = n.Duration,
                        ValidatedIdentity = n.ValidatedIdentity,
                        ContactedOn       = n.ContactedOn,
                        UpdatedById       = n.UpdatedById,
                        UpdatedOn         = n.UpdatedOn,
                        DataSource        = n.DataSource
                    };
                }
                return(result);
            }
            catch (WebServiceException ex) { throw ex; }
        }
コード例 #12
0
        public object FindByID(string entityID)
        {
            PatientNoteData noteData = null;

            try
            {
                using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.EQ(MEPatientNote.IdProperty, ObjectId.Parse(entityID)));
                    queries.Add(Query.EQ(MEPatientNote.DeleteFlagProperty, false));
                    IMongoQuery   mQuery = Query.And(queries);
                    MEPatientNote meN    = ctx.PatientNotes.Collection.Find(mQuery).FirstOrDefault();
                    if (meN != null)
                    {
                        noteData = new PatientNoteData
                        {
                            Id                = meN.Id.ToString(),
                            PatientId         = meN.PatientId.ToString(),
                            Text              = meN.Text,
                            ProgramIds        = Helper.ConvertToStringList(meN.ProgramIds),
                            CreatedOn         = meN.RecordCreatedOn,
                            CreatedById       = meN.RecordCreatedBy.ToString(),
                            TypeId            = meN.Type.ToString(),
                            MethodId          = (meN.MethodId == null) ? null :  meN.MethodId.ToString(),
                            OutcomeId         = (meN.OutcomeId == null) ? null : meN.OutcomeId.ToString(),
                            WhoId             = (meN.WhoId == null) ? null : meN.WhoId.ToString(),
                            SourceId          = (meN.SourceId == null) ? null : meN.SourceId.ToString(),
                            Duration          = meN.Duration,
                            ValidatedIdentity = meN.ValidatedIdentity,
                            ContactedOn       = meN.ContactedOn,
                            UpdatedById       = (meN.UpdatedBy == null) ? null : meN.UpdatedBy.ToString(),
                            UpdatedOn         = meN.LastUpdatedOn,
                            DataSource        = meN.DataSource,
                            ExternalRecordId  = meN.ExternalRecordId
                        };
                    }
                }
                return(noteData);
            }
            catch (Exception) { throw; }
        }
コード例 #13
0
        public PatientNoteData UpdatePatientNote(UpdatePatientNoteDataRequest request)
        {
            PatientNoteData result = null;

            try
            {
                IMongoPatientNoteRepository repo = Factory.GetRepository(RepositoryType.PatientNote);
                if (request.PatientNoteData != null)
                {
                    bool status = (bool)repo.Update(request);
                    if (status)
                    {
                        result = (PatientNoteData)repo.FindByID(request.PatientNoteData.Id);
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        public PatientNoteData MapPatientNote(string patientMongoId, PatientNote n)
        {
            const string touchPoint = "54909997d43323251c0a1dfe";

            var pnote = new PatientNoteData
            {
                ExternalRecordId = n.NoteId.ToString(),
                Text             = n.Note,
                PatientId        = n.PatientId.ToString(), // look into this.
                DataSource       = _dataSource,
                CreatedOn        = n.CreatedDate.GetValueOrDefault(),
                CreatedById      = Constants.SystemContactId,
                TypeId           = GetNoteType(Convert.ToInt32(n.ActionID), n.CategoryId) // get note type
            };

            if (pnote.TypeId.Equals(touchPoint))
            {
                SetTouchPointNoteTypeProperties(n, pnote, touchPoint);
            }

            return(pnote);
        }
コード例 #15
0
        public void UpdatePatientNote_Test()
        {
            List <string> prog = new List <string>();

            prog.Add("558c756184ac0707d02f72c8");

            PatientNoteData data = new PatientNoteData {
                Id                = "558c757284ac05114837dc38",
                PatientId         = "5429d29984ac050c788bd34f",
                Text              = "ABCABC",
                ProgramIds        = prog,
                TypeId            = "54909997d43323251c0a1dfe",
                MethodId          = "540f1da7d4332319883f3e8c",
                WhoId             = "540f1fc3d4332319883f3e97",
                OutcomeId         = "540f1f14d4332319883f3e93",
                SourceId          = "540f2091d4332319883f3e9c",
                Duration          = 10,
                ValidatedIdentity = false,
                ContactedOn       = DateTime.Now.AddDays(4)
            };

            UpdatePatientNoteDataRequest request = new UpdatePatientNoteDataRequest
            {
                Context         = context,
                ContractNumber  = contractNumber,
                UserId          = userId,
                Version         = version,
                PatientNoteData = data,
                Id        = data.Id,
                PatientId = data.PatientId
            };

            string requestURL = string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Note/{5}", url, context, version, contractNumber, data.PatientId, data.Id);
            //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note/{Id}", "PUT")]
            UpdatePatientNoteDataResponse response = client.Put <UpdatePatientNoteDataResponse>(requestURL, request);

            Assert.IsNotNull(response);
        }
コード例 #16
0
ファイル: PatientNote_Test.cs プロジェクト: rotovibe/engage
        public void InsertPatientNote_Test()
        {
            string          url  = "http://localhost:8888/PatientNote";
            PatientNoteData note = new PatientNoteData {
                Text = "DD_Service test note 2", CreatedById = "53043e53d433231f48de8a7a", PatientId = "52f55877072ef709f84e69b0"
            };
            string      contractNumber = "InHealth001";
            string      context        = "NG";
            double      version        = 1.0;
            IRestClient client         = new JsonServiceClient();

            JsonServiceClient.HttpWebRequestFilter = x =>
                                                     x.Headers.Add(string.Format("{0}: {1}", "x-Phytel-UserID", "531f2df9072ef727c4d2a3df"));

            //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note/Insert", "PUT")]
            PutPatientNoteDataResponse response = client.Put <PutPatientNoteDataResponse>(
                string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Note/Insert", url, context, version, contractNumber, note.PatientId),
                new PutPatientNoteDataRequest {
                Context = context, ContractNumber = contractNumber, PatientId = "52f55877072ef709f84e69b0", PatientNote = note, UserId = "53043e53d433231f48de8a7a", Version = version
            } as object);

            Assert.IsNotNull(response.Id);
        }
コード例 #17
0
        public IEnumerable <object> FindNotesWithAProgramId(string entityId)
        {
            List <PatientNoteData> noteDataList = null;

            try
            {
                using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(MB.Query.In(MEPatientNote.ProgramProperty, new List <BsonValue> {
                        BsonValue.Create(ObjectId.Parse(entityId))
                    }));
                    queries.Add(MB.Query.EQ(MEPatientNote.DeleteFlagProperty, false));
                    IMongoQuery          mQuery  = MB.Query.And(queries);
                    List <MEPatientNote> meNotes = ctx.PatientNotes.Collection.Find(mQuery).ToList();
                    if (meNotes != null && meNotes.Count > 0)
                    {
                        noteDataList = new List <PatientNoteData>();
                        foreach (MEPatientNote meN in meNotes)
                        {
                            PatientNoteData data = new PatientNoteData
                            {
                                Id          = meN.Id.ToString(),
                                PatientId   = meN.PatientId.ToString(),
                                Text        = meN.Text,
                                ProgramIds  = Helper.ConvertToStringList(meN.ProgramIds),
                                CreatedOn   = meN.RecordCreatedOn,
                                CreatedById = meN.RecordCreatedBy.ToString()
                            };
                            noteDataList.Add(data);
                        }
                    }
                }
                return(noteDataList);
            }
            catch (Exception ex) { throw ex; }
        }
コード例 #18
0
        public UpdatePatientNoteResponse UpdatePatientNote(UpdatePatientNoteRequest request)
        {
            try
            {
                if (request.PatientNote == null)
                {
                    throw new Exception("The Note property is null in the request.");
                }
                else if (string.IsNullOrEmpty(request.PatientNote.Text))
                {
                    throw new Exception("Note text is a required field.");
                }

                UpdatePatientNoteResponse response = new UpdatePatientNoteResponse();
                if (request.PatientNote != null)
                {
                    PatientNote pn = request.PatientNote;
                    //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note/{Id}", "PUT")]
                    IRestClient client = new JsonServiceClient();
                    string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/Patient/{4}/Note/{5}",
                                                                              DDPatientNoteUrl,
                                                                              "NG",
                                                                              request.Version,
                                                                              request.ContractNumber,
                                                                              pn.PatientId,
                                                                              pn.Id), request.UserId);

                    PatientNoteData pnData = new PatientNoteData
                    {
                        Id                = pn.Id,
                        Text              = pn.Text,
                        ProgramIds        = pn.ProgramIds,
                        CreatedById       = request.UserId,
                        CreatedOn         = pn.CreatedOn,
                        PatientId         = pn.PatientId,
                        TypeId            = pn.TypeId,
                        MethodId          = pn.MethodId,
                        OutcomeId         = pn.OutcomeId,
                        WhoId             = pn.WhoId,
                        SourceId          = pn.SourceId,
                        Duration          = pn.Duration,
                        ContactedOn       = pn.ContactedOn,
                        ValidatedIdentity = pn.ValidatedIdentity,
                        DataSource        = pn.DataSource
                    };
                    UpdatePatientNoteDataResponse dataDomainResponse =
                        client.Put <UpdatePatientNoteDataResponse>(url, new UpdatePatientNoteDataRequest
                    {
                        Context         = "NG",
                        ContractNumber  = request.ContractNumber,
                        Version         = request.Version,
                        UserId          = request.UserId,
                        PatientNoteData = pnData
                    } as object);
                    if (dataDomainResponse != null & dataDomainResponse.PatientNoteData != null)
                    {
                        response.PatientNote = Mapper.Map <PatientNote>(dataDomainResponse.PatientNoteData);;
                    }
                }
                return(response);
            }
            catch (WebServiceException ex) { throw ex; }
        }
コード例 #19
0
        public void SetTouchPointNoteTypeProperties(PatientNote n, PatientNoteData pnote, string touchPoint)
        {
            const string mail            = "540f1da4d4332319883f3e8b";
            const string successful      = "540f1f10d4332319883f3e92";
            const string unsuccessful    = "540f1f14d4332319883f3e93";
            const string phone           = "540f1d9dd4332319883f3e89";
            const string facetofaceother = "540f1da9d4332319883f3e8d";
            const string careManager     = "540f1fc0d4332319883f3e96";
            const string individual      = "540f1fbcd4332319883f3e95";

            if (pnote.TypeId.Equals(touchPoint))
            {
                pnote.SourceId = "540f2091d4332319883f3e9c"; //outbound
                //pnote.DurationId = "540f216cd4332319883f3e9e"; //not applicable
                pnote.ContactedOn = n.CreatedDate.GetValueOrDefault();
            }

            switch (n.ActionID)
            {
            //5	Other
            //6	PreVIsit Planning
            //7	Care Plan Management
            //8	Campaign
            //11	Medication Management
            //12	Escalations managed in NextGen

            case 1:                           //1	Campaign Follow-up
                pnote.MethodId  = mail;       //mail
                pnote.OutcomeId = successful; // successful
                pnote.WhoId     = individual;
                break;

            case 2:                             //2	Left Message
                pnote.MethodId  = phone;        //phone
                pnote.OutcomeId = unsuccessful; // unsuccessful
                pnote.WhoId     = individual;
                break;

            case 3:                           //3	Spoke to Patient
                pnote.MethodId  = phone;      //phone
                pnote.OutcomeId = successful; // successful
                pnote.WhoId     = individual;
                break;

            case 4:                            //4	Spoke with Care Giver
                pnote.MethodId  = phone;       //phone
                pnote.OutcomeId = successful;  // successful
                pnote.WhoId     = careManager; //caremanager
                break;

            case 9:                                //9	Face-to-Face
                pnote.MethodId  = facetofaceother; //face to face other
                pnote.OutcomeId = successful;      // successful
                pnote.WhoId     = careManager;     //caremanager
                break;

            case 10:                            //10	Left Message
                pnote.MethodId  = phone;        //phone
                pnote.OutcomeId = unsuccessful; // unsuccessful
                pnote.WhoId     = individual;   //individual
                break;
            }
        }
コード例 #20
0
        public object Update(object entity)
        {
            bool result = false;
            UpdatePatientNoteDataRequest request = (UpdatePatientNoteDataRequest)entity;
            PatientNoteData pn = request.PatientNoteData;

            try
            {
                using (PatientNoteMongoContext ctx = new PatientNoteMongoContext(ContractDBName))
                {
                    var q = MB.Query <MEPatientNote> .EQ(b => b.Id, ObjectId.Parse(pn.Id));

                    var uv = new List <MB.UpdateBuilder>();
                    uv.Add(MB.Update.Set(MEPatientNote.UpdatedByProperty, ObjectId.Parse(this.UserId)));
                    uv.Add(MB.Update.Set(MEPatientNote.VersionProperty, request.Version));
                    uv.Add(MB.Update.Set(MEPatientNote.LastUpdatedOnProperty, System.DateTime.UtcNow));
                    if (pn.PatientId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.PatientIdProperty, ObjectId.Parse(pn.PatientId)));
                    }
                    if (pn.Text != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.TextProperty, pn.Text));
                    }
                    if (pn.TypeId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.NoteTypeProperty, ObjectId.Parse(pn.TypeId)));
                    }
                    if (pn.ProgramIds != null && pn.ProgramIds.Count > 0)
                    {
                        uv.Add(MB.Update.SetWrapped <List <ObjectId> >(MEPatientNote.ProgramProperty, Helper.ConvertToObjectIdList(pn.ProgramIds)));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.ProgramProperty, BsonNull.Value));
                    }
                    if (pn.MethodId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.MethodIdProperty, ObjectId.Parse(pn.MethodId)));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.MethodIdProperty, BsonNull.Value));
                    }
                    if (pn.WhoId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.WhoIdProperty, pn.WhoId));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.WhoIdProperty, BsonNull.Value));
                    }
                    if (pn.SourceId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.SourceIdProperty, pn.SourceId));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.SourceIdProperty, BsonNull.Value));
                    }
                    if (pn.OutcomeId != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.OutcomeIdProperty, pn.OutcomeId));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.OutcomeIdProperty, BsonNull.Value));
                    }
                    if (pn.Duration != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.DurationProperty, pn.Duration));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.DurationProperty, BsonNull.Value));
                    }
                    uv.Add(MB.Update.Set(MEPatientNote.ValidatedIdentityProperty, pn.ValidatedIdentity));
                    if (pn.ContactedOn != null && !pn.ContactedOn.Equals(new DateTime()))
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.ContactedOnProperty, pn.ContactedOn));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.ContactedOnProperty, BsonNull.Value));
                    }

                    if (pn.DataSource != null)
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.DataSourceProperty, Helper.TrimAndLimit(pn.DataSource, 50)));
                    }
                    else
                    {
                        uv.Add(MB.Update.Set(MEPatientNote.DataSourceProperty, BsonNull.Value));
                    }

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

                    AuditHelper.LogDataAudit(this.UserId,
                                             MongoCollectionName.PatientNote.ToString(),
                                             pn.Id,
                                             DataAuditType.Update,
                                             request.ContractNumber);

                    result = true;
                }
                return(result as object);
            }
            catch (Exception) { throw; }
        }
コード例 #21
0
        public PostPatientNoteResponse InsertPatientNote(PostPatientNoteRequest request)
        {
            try
            {
                if (request.Note == null)
                {
                    throw new Exception("The Note property is null in the request.");
                }
                else if (string.IsNullOrEmpty(request.Note.Text))
                {
                    throw new Exception("Note text is a required field.");
                }

                PostPatientNoteResponse response = new PostPatientNoteResponse();
                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note/Insert", "PUT")]
                //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Note", "POST")]
                IRestClient client = new JsonServiceClient();
                string      url    = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/patient/{4}/note",
                                                                          DDPatientNoteUrl,
                                                                          "NG",
                                                                          request.Version,
                                                                          request.ContractNumber,
                                                                          request.PatientId), request.UserId);

                PatientNoteData noteData = new PatientNoteData {
                    Text              = request.Note.Text,
                    ProgramIds        = request.Note.ProgramIds,
                    CreatedById       = request.UserId,
                    CreatedOn         = request.Note.CreatedOn,
                    PatientId         = request.Note.PatientId,
                    TypeId            = request.Note.TypeId,
                    MethodId          = request.Note.MethodId,
                    OutcomeId         = request.Note.OutcomeId,
                    WhoId             = request.Note.WhoId,
                    SourceId          = request.Note.SourceId,
                    Duration          = request.Note.Duration,
                    ContactedOn       = request.Note.ContactedOn,
                    ValidatedIdentity = request.Note.ValidatedIdentity,
                    DataSource        = request.Note.DataSource
                };

                InsertPatientNoteDataResponse dataDomainResponse =
                    client.Post <InsertPatientNoteDataResponse>(url, new InsertPatientNoteDataRequest
                {
                    PatientNote    = noteData,
                    Context        = "NG",
                    ContractNumber = request.ContractNumber,
                    Version        = request.Version,
                    UserId         = request.UserId,
                    PatientId      = request.PatientId
                } as object);

                if (dataDomainResponse != null && !(string.IsNullOrEmpty(dataDomainResponse.Id)))
                {
                    response.Id      = dataDomainResponse.Id;
                    response.Version = dataDomainResponse.Version;
                }

                return(response);
            }
            catch (WebServiceException ex) { throw ex; }
        }