Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> getNotes(MazikCareService.Core.Models.Notes notes)
        {
            List <MazikCareService.Core.Models.Notes> data = new List <MazikCareService.Core.Models.Notes>();
            int CurrentPage = 1;

            if (CurrentPage < 0)
            {
                return(Response.Error("App", "current page is not valid"));
            }

            try
            {
                ApiResponseModel <List <MazikCareService.Core.Models.Notes> > model = new ApiResponseModel <List <MazikCareService.Core.Models.Notes> >()
                {
                };
                var client = ServiceFactory.GetService(typeof(MazikCareService.Core.Models.Notes));
                data = await client.getNotes(notes);

                if (data != null)
                {
                    model.data.pagination.currentPage = CurrentPage.ToString();
                    model.data.pagination.totalCount  = data.Count().ToString();
                    int pageSize = Convert.ToInt32(AppSettings.GetByKey("PageSize"));
                    model.data.records = data.Take <MazikCareService.Core.Models.Notes>(Convert.ToInt32(CurrentPage * pageSize)).Skip((CurrentPage - 1) * pageSize).ToList();
                }
                return(Response.Success <List <MazikCareService.Core.Models.Notes> >(model));
            }
            catch (Exception ex)
            {
                return(Response.Exception(ex));
            }
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> getNotesFile(ApiModel inputmodel)
        {
            MazikCareService.Core.Models.Notes data = new MazikCareService.Core.Models.Notes();
            try
            {
                ApiResponseModel <MazikCareService.Core.Models.Notes> model = new ApiResponseModel <MazikCareService.Core.Models.Notes>();

                var client = ServiceFactory.GetService(typeof(MazikCareService.Core.Models.Notes));
                data = await client.getFile(inputmodel.notesAnnotationId);

                model.data.records = data;

                return(Response.Success <MazikCareService.Core.Models.Notes>(model));
            }
            catch (Exception ex)
            {
                return(Response.Exception(ex));
            }
        }
Ejemplo n.º 3
0
        public async Task <HttpResponseMessage> AddNotes(MazikCareService.Core.Models.Notes notes)
        {
            string data = string.Empty;

            notes.EntityType = "mzk_patientencounter";
            notes.Subject    = "Progress Notes";
            try
            {
                ApiResponseModel <string> model = new ApiResponseModel <string>();
                var client = ServiceFactory.GetService(typeof(MazikCareService.Core.Models.Notes));
                data = await client.AddNotes(notes);

                model.data.records = data;
                return(Response.Success <string>(model));
            }
            catch (Exception ex)
            {
                return(Response.Exception(ex));
            }
        }
Ejemplo n.º 4
0
        public async Task <HttpResponseMessage> updateNotes(MazikCareService.Core.Models.Notes notes)
        {
            bool data = false;

            try
            {
                ApiResponseModel <bool> model = new ApiResponseModel <bool>()
                {
                };
                var client = ServiceFactory.GetService(typeof(MazikCareService.Core.Models.Notes));
                data = await client.updateNotes(notes);

                model.data.records = data;

                return(Response.Success <bool>(model));
            }
            catch (Exception ex)
            {
                return(Response.Exception(ex));
            }
        }
Ejemplo n.º 5
0
        public async Task <List <Notes> > getNotes(Notes notes)
        {
            List <Notes> PatientNotes = new List <Notes>();

            xrm.Annotation patientOrderEntity = new xrm.Annotation();

            QueryExpression  query       = new QueryExpression(Annotation.EntityLogicalName);
            FilterExpression childFilter = query.Criteria.AddFilter(LogicalOperator.And);
            //check if it is case
            PatientCase pcase = new PatientCase();

            if (!string.IsNullOrEmpty(notes.ObjectId))
            {
                if (pcase.getCaseDetails(notes.ObjectId).Result.CaseNumber != null)
                {
                    #region Case
                    PatientEncounter encounter = new PatientEncounter();
                    encounter.CaseId = notes.ObjectId;
                    List <PatientEncounter> listEncounterId = encounter.getEncounterDetails(encounter).Result;
                    if (listEncounterId.Count > 0)
                    {
                        for (int entityCount = 0; entityCount < listEncounterId.Count; entityCount++)
                        {
                            #region Notes
                            QueryExpression  querycase       = new QueryExpression(Annotation.EntityLogicalName);
                            FilterExpression childFiltercase = querycase.Criteria.AddFilter(LogicalOperator.And);
                            childFiltercase.AddCondition("objectid", ConditionOperator.Equal, new Guid(listEncounterId[entityCount].EncounterId));
                            //Entity :: Notes
                            querycase.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("objectid",
                                                                                        "subject",
                                                                                        "notetext",
                                                                                        "createdby", "createdon", "modifiedon", "modifiedby");
                            OrderExpression orderby = new OrderExpression();
                            orderby.AttributeName = "createdon";
                            orderby.OrderType     = OrderType.Descending;
                            querycase.Orders.Add(orderby);

                            #endregion
                            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();
                            EntityCollection     entitycollection = entityRepository.GetEntityCollection(querycase);

                            foreach (Entity entity in entitycollection.Entities)
                            {
                                Notes model = new Notes();

                                if (entity.Attributes.Contains("objectid"))
                                {
                                    model.ObjectId = ((EntityReference)entity.Attributes["objectid"]).Id.ToString();
                                }

                                if (entity.Attributes.Contains("subject"))
                                {
                                    model.Subject = entity.Attributes["subject"].ToString();
                                }

                                if (entity.Attributes.Contains("notetext"))
                                {
                                    model.NoteText = entity.Attributes["notetext"].ToString();
                                }

                                if (entity.Attributes.Contains("createdon"))
                                {
                                    model.CreatedOn = Convert.ToDateTime(entity.Attributes["createdon"]);
                                }

                                if (entity.Attributes.Contains("createdby"))
                                {
                                    model.CreatedBy = ((EntityReference)entity.Attributes["createdby"]).Name;
                                }

                                model.Id = entity.Id.ToString();

                                PatientNotes.Add(model);
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region Encounter
                    if (!string.IsNullOrEmpty(notes.Id))
                    {
                        childFilter.AddCondition("annotationid", ConditionOperator.Equal, new Guid(notes.Id));
                    }

                    if (!string.IsNullOrEmpty(notes.ObjectId))
                    {
                        childFilter.AddCondition("objectid", ConditionOperator.Equal, new Guid(notes.ObjectId));
                    }

                    //Entity :: Notes
                    query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("objectid",
                                                                            "subject",
                                                                            "notetext",
                                                                            "createdby", "createdon", "modifiedon", "modifiedby");

                    OrderExpression orderby = new OrderExpression();
                    orderby.AttributeName = "createdon";
                    orderby.OrderType     = OrderType.Descending;

                    query.Orders.Add(orderby);

                    if (string.IsNullOrEmpty(notes.ObjectId) && string.IsNullOrEmpty(notes.Id))
                    {
                        throw new ValidationException("Parameter missing");
                    }


                    SoapEntityRepository entityRepository = SoapEntityRepository.GetService();
                    EntityCollection     entitycollection = entityRepository.GetEntityCollection(query);

                    foreach (Entity entity in entitycollection.Entities)
                    {
                        Notes model = new Notes();

                        if (entity.Attributes.Contains("objectid"))
                        {
                            model.ObjectId = ((EntityReference)entity.Attributes["objectid"]).Id.ToString();
                        }

                        if (entity.Attributes.Contains("subject"))
                        {
                            model.Subject = entity.Attributes["subject"].ToString();
                        }

                        if (entity.Attributes.Contains("notetext"))
                        {
                            model.NoteText = entity.Attributes["notetext"].ToString();
                        }

                        if (entity.Attributes.Contains("createdon"))
                        {
                            model.CreatedOn = Convert.ToDateTime(entity.Attributes["createdon"]);
                        }

                        if (entity.Attributes.Contains("createdby"))
                        {
                            model.CreatedBy = ((EntityReference)entity.Attributes["createdby"]).Name;
                        }

                        model.Id = entity.Id.ToString();

                        PatientNotes.Add(model);
                    }
                    #endregion
                }
            }



            return(PatientNotes);
        }
Ejemplo n.º 6
0
        public async Task <List <Notes> > getCaseNotes(string caseId)
        {
            List <Notes> PatientNotes = new List <Notes>();

            xrm.Annotation patientOrderEntity = new xrm.Annotation();

            QueryExpression query = new QueryExpression(Annotation.EntityLogicalName);

            query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("objectid",
                                                                    "subject",
                                                                    "notetext",
                                                                    "createdby", "createdon", "modifiedon", "modifiedby");
            OrderExpression orderby = new OrderExpression();

            orderby.AttributeName = "createdon";
            orderby.OrderType     = OrderType.Descending;
            query.Orders.Add(orderby);

            LinkEntity ptEnc = new LinkEntity(Annotation.EntityLogicalName, mzk_patientencounter.EntityLogicalName, "objectid", "mzk_patientencounterid", JoinOperator.Inner);

            ptEnc.LinkCriteria.AddCondition("mzk_caseid", ConditionOperator.Equal, new Guid(caseId));

            query.LinkEntities.Add(ptEnc);

            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();
            EntityCollection     entitycollection = entityRepository.GetEntityCollection(query);

            foreach (Entity entity in entitycollection.Entities)
            {
                Notes model = new Notes();

                if (entity.Attributes.Contains("objectid"))
                {
                    model.ObjectId = ((EntityReference)entity.Attributes["objectid"]).Id.ToString();
                }

                if (entity.Attributes.Contains("subject"))
                {
                    model.Subject = entity.Attributes["subject"].ToString();
                }

                if (entity.Attributes.Contains("notetext"))
                {
                    model.NoteText = entity.Attributes["notetext"].ToString();
                }

                if (entity.Attributes.Contains("createdon"))
                {
                    model.CreatedOn = Convert.ToDateTime(entity.Attributes["createdon"]);
                }

                if (entity.Attributes.Contains("createdby"))
                {
                    model.CreatedBy = ((EntityReference)entity.Attributes["createdby"]).Name;
                }

                model.Id = entity.Id.ToString();

                PatientNotes.Add(model);
            }

            return(PatientNotes);
        }