コード例 #1
0
        public string getScheduleType(string appointmentGuid = null)
        {
            string appointmentTypeId = "";

            SoapEntityRepository repo = SoapEntityRepository.GetService();

            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

            QueryExpression query = new QueryExpression(mzk_patientappointment.EntityLogicalName);

            query.Criteria.AddCondition("mzk_patientappointmentid", ConditionOperator.Equal, new Guid(appointmentGuid));

            query.ColumnSet = new ColumnSet("mzk_appointmenttype");

            EntityCollection entitycollection = entityRepository.GetEntityCollection(query);

            if (entitycollection != null && entitycollection.Entities != null && entitycollection.Entities.Count > 0)
            {
                mzk_patientappointment appointment = (mzk_patientappointment)entitycollection.Entities[0];

                if (appointment.Attributes.Contains("mzk_appointmenttype"))
                {
                    appointmentTypeId = ((EntityReference)(appointment.Attributes["mzk_appointmenttype"])).Id.ToString();
                }
            }

            return(appointmentTypeId);
        }
コード例 #2
0
        public static List <Appointment> getUserAppointments(string resourceId, string clinicId, DateTime startDate, DateTime endDate, bool onlyTriaged, string searchOrder, string appointmentId, string patientId = null, bool activitiesIncluded = true)
        {
            List <Appointment> appointments = new List <Appointment>();

            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

            QueryExpression query = new QueryExpression(mzk_patientappointment.EntityLogicalName);

            query.ColumnSet = new ColumnSet(true);

            if (!string.IsNullOrEmpty(appointmentId))
            {
                query.Criteria.AddCondition("mzk_patientappointmentid", ConditionOperator.Equal, new Guid(appointmentId));
            }

            LinkEntity bookingstatus = new LinkEntity(mzk_patientappointment.EntityLogicalName, BookingStatus.EntityLogicalName, "mzk_appointmentstatus", "bookingstatusid", JoinOperator.Inner);

            bookingstatus.Columns     = new ColumnSet(true);
            bookingstatus.EntityAlias = "bookingstatus";

            LinkEntity bookableresource = new LinkEntity(mzk_patientappointment.EntityLogicalName, BookableResource.EntityLogicalName, "mzk_resource", "bookableresourceid", JoinOperator.Inner);

            bookableresource.Columns     = new ColumnSet(true);
            bookableresource.EntityAlias = "bookableresource";
            if (!string.IsNullOrEmpty(resourceId))
            {
                bookableresource.LinkCriteria.AddCondition("bookableresourceid", ConditionOperator.Equal, new Guid(resourceId));
            }

            LinkEntity user = new LinkEntity(BookableResource.EntityLogicalName, SystemUser.EntityLogicalName, "userid", "systemuserid", JoinOperator.Inner);

            user.Columns     = new ColumnSet(true);
            user.EntityAlias = "user";
            bookableresource.LinkEntities.Add(user);

            LinkEntity contact = new LinkEntity(mzk_patientappointment.EntityLogicalName, Contact.EntityLogicalName, "mzk_customerid", "contactid", JoinOperator.Inner);

            if (!string.IsNullOrEmpty(patientId))
            {
                contact.LinkCriteria.AddCondition("contactid", ConditionOperator.Equal, new Guid(patientId));
            }

            contact.Columns = new ColumnSet("contactid", "entityimage", "gendercode", "birthdate",
                                            "fullname",
                                            "telephone1",
                                            "fax",
                                            "emailaddress1",
                                            "address1_name",
                                            "address1_city",
                                            "address1_stateorprovince",
                                            "address1_line1",
                                            "address1_line2",
                                            "address1_line3",
                                            "address1_country",
                                            "address1_postalcode",
                                            "mzk_patientlanguage",
                                            "familystatuscode",
                                            "mzk_salutation",
                                            "mzk_nationality",
                                            "mzk_nationalidexpirydate",
                                            "mzk_nationalidtype",
                                            "preferredcontactmethodcode",
                                            "mzk_vippatient",
                                            "firstname",
                                            "lastname",
                                            "mzk_age",
                                            "telephone2");
            contact.EntityAlias = "contact";
            query.LinkEntities.Add(contact);

            LinkEntity account = new LinkEntity(Contact.EntityLogicalName, Account.EntityLogicalName, "contactid", "primarycontactid", JoinOperator.LeftOuter);

            account.Columns     = new ColumnSet(true);
            account.EntityAlias = "account";
            contact.LinkEntities.Add(account);

            LinkEntity patientCase = new LinkEntity(mzk_patientappointment.EntityLogicalName, Incident.EntityLogicalName, "mzk_caseid", "incidentid", JoinOperator.Inner);

            patientCase.Columns     = new ColumnSet(true);
            patientCase.EntityAlias = "case";

            if (!string.IsNullOrEmpty(clinicId))
            {
                LinkEntity clinic = new LinkEntity(mzk_patientappointment.EntityLogicalName, msdyn_organizationalunit.EntityLogicalName, "mzk_organizationunit", "msdyn_organizationalunitid", JoinOperator.Inner);
                clinic.Columns     = new ColumnSet(true);
                clinic.EntityAlias = "clinic";
                clinic.LinkCriteria.AddCondition("msdyn_organizationalunitid", ConditionOperator.Equal, new Guid(clinicId));

                query.LinkEntities.Add(clinic);
            }

            if (startDate != null && startDate != DateTime.MinValue)
            {
                query.Criteria.AddCondition("mzk_starttime", ConditionOperator.GreaterEqual, startDate);
            }

            if (endDate != null && endDate != DateTime.MaxValue)
            {
                query.Criteria.AddCondition("mzk_endtime", ConditionOperator.LessEqual, endDate);
            }

            query.LinkEntities.Add(bookableresource);
            query.LinkEntities.Add(bookingstatus);
            query.LinkEntities.Add(patientCase);

            EntityCollection entitycollection = entityRepository.GetEntityCollection(query);

            if (entitycollection != null && entitycollection.Entities != null && entitycollection.Entities.Count > 0)
            {
                List <mzk_patientappointment> bookableResourceBookings = new List <mzk_patientappointment>();

                foreach (Entity entity in entitycollection.Entities)
                {
                    mzk_patientappointment patientAppointment = (mzk_patientappointment)entity;
                    Appointment            model = new Appointment();

                    model = getAppointmentModelFilledByAppointment(patientAppointment, model);

                    if (patientAppointment.Attributes.Contains("contact.contactid"))
                    {
                        model.patient = Patient.getPatientModelFilled(patientAppointment, new Patient(), contact.EntityAlias, account.EntityAlias);
                    }

                    if (patientAppointment.Attributes.Contains("bookingstatus.msdyn_fieldservicestatus"))
                    {
                        model.statusValue = ((OptionSetValue)(patientAppointment.Attributes["bookingstatus.msdyn_fieldservicestatus"] as AliasedValue).Value).Value;
                        model.status      = (patientAppointment.FormattedValues["bookingstatus.msdyn_fieldservicestatus"]).ToString();
                    }

                    if (patientAppointment.Attributes.Contains("case.incidentid"))
                    {
                        model.caseId = ((patientAppointment.Attributes["case.incidentid"] as AliasedValue).Value).ToString();
                    }

                    appointments.Add(model);
                }
            }

            return(appointments);
        }