コード例 #1
0
        public async Task <string> AddNotes(Notes notes)
        {
            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

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

            if (!string.IsNullOrEmpty(notes.NoteText))
            {
                annotationNotes.NoteText = notes.NoteText;
            }

            if (!string.IsNullOrEmpty(notes.Subject))
            {
                annotationNotes.Subject = notes.Subject;
            }

            if (!string.IsNullOrEmpty(notes.ObjectId))
            {
                annotationNotes.ObjectId = new Microsoft.Xrm.Sdk.EntityReference(notes.EntityType, new Guid(notes.ObjectId));
            }

            if (!string.IsNullOrEmpty(notes.fileName))
            {
                annotationNotes.FileName = notes.fileName;
            }

            if (!string.IsNullOrEmpty(notes.mimeType))
            {
                annotationNotes.MimeType = notes.mimeType;
            }

            if (!string.IsNullOrEmpty(notes.file))
            {
                annotationNotes.DocumentBody = notes.file;
            }


            Id = Convert.ToString(entityRepository.CreateEntity(annotationNotes));

            return(Id.ToString());
        }
コード例 #2
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);
        }
コード例 #3
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);
        }