Пример #1
0
        public async Task <bool> addProgramEnrollmentRequest(string patientEncounterId, string careProgramId, string patientId)
        {
            bool programEnrollmentRequestCreated = false;

            string id = null;

            mzk_programenrollmentrequest programEnrollmentRequest = new mzk_programenrollmentrequest();

            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

            PatientDiagnosis patientDiagnosis = new PatientDiagnosis().getPatientDiagnosis(patientEncounterId, null, null, DateTime.MinValue, DateTime.MinValue, 0, "").Result.ToList().FirstOrDefault();

            if (patientDiagnosis != null)
            {
                if (!string.IsNullOrEmpty(patientDiagnosis.DiagnosisId))
                {
                    programEnrollmentRequest.mzk_PrincipalDiagnosis = new EntityReference(mzk_concept.EntityLogicalName, new Guid(patientDiagnosis.DiagnosisId));
                }
            }

            if (!string.IsNullOrEmpty(patientId))
            {
                programEnrollmentRequest.mzk_customerid = new EntityReference(Contact.EntityLogicalName, new Guid(patientId));
            }

            if (!string.IsNullOrEmpty(careProgramId))
            {
                programEnrollmentRequest.mzk_Program = new EntityReference(xrm.mzk_careprogram.EntityLogicalName, new Guid(careProgramId));
            }

            if (!string.IsNullOrEmpty(patientEncounterId))
            {
                programEnrollmentRequest.mzk_Encounter = new EntityReference(mzk_patientencounter.EntityLogicalName, new Guid(patientEncounterId));
            }

            //programEnrollmentRequest.mzk_Status = mzk_programenrollmentrequeststatus.Requested;

            id = Convert.ToString(entityRepository.CreateEntity(programEnrollmentRequest));

            if (!string.IsNullOrEmpty(id))
            {
                programEnrollmentRequestCreated = true;
            }
            else
            {
                programEnrollmentRequestCreated = false;
            }

            return(programEnrollmentRequestCreated);
        }
Пример #2
0
        public async Task <List <ProgramEnrollmentRequest> > getProgramEnrollmentRequest(string patientEncounterId)
        {
            List <ProgramEnrollmentRequest> programEnrollmentRequestList = new List <ProgramEnrollmentRequest>();

            SoapEntityRepository entityRepository = SoapEntityRepository.GetService();

            QueryExpression query = new QueryExpression(mzk_programenrollmentrequest.EntityLogicalName);

            query.ColumnSet = new ColumnSet(true);

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

            EntityCollection entitycollection = entityRepository.GetEntityCollection(query);

            if (entitycollection != null && entitycollection.Entities != null && entitycollection.Entities.Count > 0)
            {
                foreach (Entity entity in entitycollection.Entities)
                {
                    ProgramEnrollmentRequest programEnrollmentRequestModel = new ProgramEnrollmentRequest();

                    mzk_programenrollmentrequest programEnrollmentRequestRecord = (mzk_programenrollmentrequest)entity;

                    programEnrollmentRequestModel.id = programEnrollmentRequestRecord.Id.ToString();

                    if (programEnrollmentRequestRecord.Attributes.Contains("createdon"))
                    {
                        programEnrollmentRequestModel.createdOn = Convert.ToDateTime(programEnrollmentRequestRecord.CreatedOn);
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_customerid"))
                    {
                        programEnrollmentRequestModel.patientId   = (programEnrollmentRequestRecord.mzk_customerid).Id.ToString();
                        programEnrollmentRequestModel.patientName = (programEnrollmentRequestRecord.FormattedValues["mzk_customerid"]).ToString();
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_program"))
                    {
                        programEnrollmentRequestModel.programId   = (programEnrollmentRequestRecord.mzk_Program).Id.ToString();
                        programEnrollmentRequestModel.programName = (programEnrollmentRequestRecord.FormattedValues["mzk_program"]).ToString();
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_principaldiagnosis"))
                    {
                        programEnrollmentRequestModel.principalDiagnosisId   = (programEnrollmentRequestRecord.mzk_PrincipalDiagnosis).Id.ToString();
                        programEnrollmentRequestModel.principalDiagnosisName = (programEnrollmentRequestRecord.FormattedValues["mzk_principaldiagnosis"]).ToString();
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_encounter"))
                    {
                        programEnrollmentRequestModel.patientEncounterId = (programEnrollmentRequestRecord.mzk_Encounter).Id.ToString();
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_description"))
                    {
                        programEnrollmentRequestModel.programId = (programEnrollmentRequestRecord.mzk_Program).Id.ToString();
                    }

                    if (programEnrollmentRequestRecord.Attributes.Contains("mzk_status"))
                    {
                        programEnrollmentRequestModel.statusValue = (programEnrollmentRequestRecord.mzk_Status).Value.ToString();
                        programEnrollmentRequestModel.status      = (programEnrollmentRequestRecord.FormattedValues["mzk_status"]).ToString();
                    }

                    programEnrollmentRequestList.Add(programEnrollmentRequestModel);
                }
            }
            return(programEnrollmentRequestList);
        }