public object FindByPatientId(object request)
        {
            List <PatientMedFrequencyData>      list        = null;
            GetPatientMedFrequenciesDataRequest dataRequest = (GetPatientMedFrequenciesDataRequest)request;

            try
            {
                using (MedicationMongoContext ctx = new MedicationMongoContext(ContractDBName))
                {
                    List <IMongoQuery> queries = new List <IMongoQuery>();
                    queries.Add(Query.EQ(MEPatientMedFrequency.PatientIdProperty, ObjectId.Parse(dataRequest.PatientId)));
                    queries.Add(Query.EQ(MEPatientMedFrequency.DeleteFlagProperty, false));
                    queries.Add(Query.EQ(MEPatientMedFrequency.TTLDateProperty, BsonNull.Value));
                    IMongoQuery mQuery = Query.And(queries);
                    List <MEPatientMedFrequency> meFreqs = ctx.PatientMedFrequencies.Collection.Find(mQuery).ToList();
                    if (meFreqs != null && meFreqs.Count > 0)
                    {
                        list = new List <PatientMedFrequencyData>();
                        meFreqs.ForEach(p =>
                        {
                            PatientMedFrequencyData data = AutoMapper.Mapper.Map <PatientMedFrequencyData>(p);
                            list.Add(data);
                        });
                    }
                }
                return(list);
            }
            catch (Exception) { throw; }
        }
        public void InsertPatientMedFrequency_Test()
        {
            PatientMedFrequencyData data = new PatientMedFrequencyData
            {
                Name      = "abc",
                PatientId = "5325da88d6a4850adcbba68a",
            };

            PostPatientMedFrequencyDataRequest request = new PostPatientMedFrequencyDataRequest
            {
                Context                 = context,
                ContractNumber          = contractNumber,
                PatientMedFrequencyData = data,
                UserId  = userId,
                Version = version
            };

            //[Route("/{Context}/{Version}/{ContractNumber}/PatientMedSupp/Frequency/Insert", "POST")]
            PostPatientMedFrequencyDataResponse response = client.Post <PostPatientMedFrequencyDataResponse>(
                string.Format("{0}/{1}/{2}/{3}/PatientMedSupp/Frequency/Insert", url, context, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
Example #3
0
        public string InsertPatientMedFrequency(PostPatientMedFrequencyRequest request)
        {
            try
            {
                string      id     = null;
                IRestClient client = new JsonServiceClient();
                //[Route("/{Context}/{Version}/{ContractNumber}/PatientMedSupp/Frequency/Insert", "POST")]
                var url = Common.Helper.BuildURL(string.Format("{0}/{1}/{2}/{3}/PatientMedSupp/Frequency/Insert",
                                                               DDMedicationUrl,
                                                               "NG",
                                                               request.Version,
                                                               request.ContractNumber), request.UserId);
                if (request.PatientMedFrequency != null)
                {
                    PatientMedFrequencyData data = new PatientMedFrequencyData
                    {
                        Name      = request.PatientMedFrequency.Name,
                        PatientId = request.PatientMedFrequency.PatientId
                    };
                    PostPatientMedFrequencyDataResponse dataDomainResponse = client.Post <PostPatientMedFrequencyDataResponse>(url, new PostPatientMedFrequencyDataRequest
                    {
                        Context                 = "NG",
                        ContractNumber          = request.ContractNumber,
                        UserId                  = request.UserId,
                        Version                 = request.Version,
                        PatientMedFrequencyData = data,
                    } as object);

                    if (dataDomainResponse != null)
                    {
                        id = dataDomainResponse.Id;
                    }
                }
                return(id);
            }
            catch (Exception ex) { throw ex; }
        }