Exemple #1
0
        public void SavePatientMedSupp_Test()
        {
            PatientMedSupp pms = new PatientMedSupp
            {
                //FamilyId = "54dd28e784ac0714f0cef2cb",
                CategoryId = 1,
                DeleteFlag = false,
                // Dosage = "Two",
                //EndDate = DateTime.UtcNow,
                //FreqHowOftenId = "545be059d43323224896663a",
                //FreqQuantity = "4",
                //   FreqWhenId = "545be126d433232248966643",
                Id       = "54dd2d63d43328283844e107",
                Name     = "ARMES",//"NICOTINE",
                Form     = "TABLET",
                Route    = "ORAL",
                Strength = "56 l",
                //NDCs = ,
                // Notes = "note for Acetomophine 2",
                PatientId = "54dd289384ac0511987c998e",
                //PharmClasses = ,
                //  PrescribedBy = "Dr Basu",
                // Reason = "Reason for Acetomophine 2",
                //SigCode = ,
                SourceId  = "544e9976d433231d9c0330ae",
                StartDate = DateTime.UtcNow,
                StatusId  = 1,
                //  SystemName = "Engage",
                TypeId = "545bdfa1d433232248966638"
            };

            PostPatientMedSuppRequest request = new PostPatientMedSuppRequest
            {
                ContractNumber = contractNumber,
                PatientMedSupp = pms,
                RecalculateNDC = false,
                Insert         = false,
                UserId         = userId,
                Version        = version
            };

            JsonServiceClient.HttpWebRequestFilter = x => x.Headers.Add(string.Format("{0}: {1}", "Token", token));
            //[Route("/{Version}/{ContractNumber}/PatientMedSupp/Save", "POST")]
            PostPatientMedSuppResponse response = client.Post <PostPatientMedSuppResponse>(
                string.Format("{0}/{1}/{2}/PatientMedSupp/Save", url, version, contractNumber), request);

            Assert.IsNotNull(response);
        }
Exemple #2
0
        public void CalculateMedicationSigCode_Test()
        {
            var manager = new MedicationManager();

            manager.EndpointUtil = new MedicationEndpointUtil();
            PostPatientMedSuppRequest request = new PostPatientMedSuppRequest();

            request.ContractNumber = contractNumber;
            request.UserId         = userId;
            request.Version        = version;
            //request.Token = token;
            PatientMedSupp patientMedication = new PatientMedSupp {
                Id         = "55dce59e84ac092884e0960a",
                PatientId  = "5325d9f2d6a4850adcbba4ca",
                Name       = "YOUGREEN F",
                CategoryId = 1,
                DeleteFlag = false,
                NDCs       = new List <string>()
                {
                    "42361-043"
                },
                Notes      = "bla bla",
                Reason     = "the reason",
                SourceId   = "544e9976d433231d9c0330ae",
                StatusId   = 1,
                SystemName = "Engage",
                TypeId     = "545bdfa6d433232248966639",

                StartDate    = DateTime.Parse("2016-03-01T06:00:00.000Z"), //DateTime.Now,
                EndDate      = DateTime.Parse("2016-03-14T05:00:00.000Z"), //DateTime.Now.AddDays(10),
                Route        = "TOPICAL",
                Form         = "OINTMENT",
                Strength     = "7.5 g/30g",
                FreqQuantity = "12 bunches",
                FrequencyId  = "54fa11abd433230404046e6b", //Q4H (every 4 hours)
            };

            request.PatientMedSupp = patientMedication;
            string sigCode = manager.CalculateSigCode(request);

            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode = " + sigCode);

            patientMedication.FrequencyId = "56ddd57f84ac070fc8287596";  //a custom freq -
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode with custom frequency = " + sigCode);

            patientMedication.Route    = null;
            patientMedication.Form     = "";
            patientMedication.Strength = null;
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sigCode with some empty values = " + sigCode);

            //daylight saving time tests:
            patientMedication.StartDate    = DateTime.Parse("2016-03-01T06:00:00.000Z");
            patientMedication.EndDate      = DateTime.Parse("2016-03-14T05:00:00.000Z");
            patientMedication.FreqQuantity = null;
            patientMedication.FrequencyId  = null;
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code for dst w /specific dates: ");
            Console.WriteLine("sig code should be 13 days: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-03-13T06:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2016-03-14T05:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 1 day: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-03-15T05:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2016-03-17T05:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 2 days: " + sigCode);

            patientMedication.StartDate = DateTime.Parse("2016-04-01T05:00:00.0000000Z");
            patientMedication.EndDate   = DateTime.Parse("2017-01-01T06:00:00.0000000Z");
            sigCode = manager.CalculateSigCode(request);
            Assert.IsNotNull(sigCode);
            Assert.IsTrue(sigCode.Length > 0);
            Console.WriteLine("sig code should be 275 days: " + sigCode);
        }
Exemple #3
0
        public PatientMedSupp SavePatientMedSupp(PostPatientMedSuppRequest request)
        {
            PatientMedSupp patientMedSupp = null;

            try
            {
                if (request.PatientMedSupp != null)
                {
                    string name     = string.IsNullOrEmpty(request.PatientMedSupp.Name) ? string.Empty : request.PatientMedSupp.Name.ToUpper();
                    string form     = string.IsNullOrEmpty(request.PatientMedSupp.Form) ? string.Empty : request.PatientMedSupp.Form.ToUpper();
                    string route    = string.IsNullOrEmpty(request.PatientMedSupp.Route) ? string.Empty : request.PatientMedSupp.Route.ToUpper();
                    string strength = string.IsNullOrEmpty(request.PatientMedSupp.Strength) ? string.Empty : request.PatientMedSupp.Strength;

                    #region Search MedicationMap
                    // Search if any record exists with the given combination of name, strength, route and form.
                    GetMedicationMapsRequest mmRequest = new GetMedicationMapsRequest
                    {
                        Name           = name,
                        Route          = route,
                        Form           = form,
                        Strength       = strength,
                        ContractNumber = request.ContractNumber,
                        UserId         = request.UserId,
                        Version        = request.Version
                    };
                    List <MedicationMapData> list = EndpointUtil.SearchMedicationMap(mmRequest);
                    #endregion
                    if (list == null)
                    {
                        MedicationMapData medData = null;
                        if (string.IsNullOrEmpty(request.PatientMedSupp.FamilyId))
                        {
                            #region Insert MedicationMap
                            PostMedicationMapRequest insertReq = new PostMedicationMapRequest
                            {
                                MedicationMap = new DTO.MedicationMap
                                {
                                    FullName      = name,
                                    SubstanceName = string.Empty,
                                    Strength      = strength,
                                    Route         = route,
                                    Form          = form,
                                    Custom        = true,
                                    Verified      = false
                                },
                                ContractNumber = request.ContractNumber,
                                UserId         = request.UserId,
                                Version        = request.Version
                            };
                            medData = EndpointUtil.InsertMedicationMap(insertReq);
                            #endregion
                        }
                        else
                        {
                            #region Update MedicationMap
                            // This saves the initialized medicine map
                            PutMedicationMapRequest req = new PutMedicationMapRequest
                            {
                                MedicationMap = new DTO.MedicationMap
                                {
                                    Id            = request.PatientMedSupp.FamilyId,
                                    FullName      = name,
                                    SubstanceName = string.Empty,
                                    Strength      = strength,
                                    Route         = route,
                                    Form          = form,
                                    Custom        = true,
                                    Verified      = false
                                },
                                ContractNumber = request.ContractNumber,
                                UserId         = request.UserId,
                                Version        = request.Version
                            };
                            medData = EndpointUtil.UpdateMedicationMap(req);
                            #endregion
                        }
                        RegisterMedication(request, medData);
                    }
                    #region Calculate NDC codes.
                    bool calculateNDC = false;
                    if (request.Insert)
                    {
                        calculateNDC = true;
                        request.PatientMedSupp.SystemName = Constants.SystemName;
                    }
                    else
                    {
                        // On update, check for ReCalculateNDC flag.
                        if (request.RecalculateNDC)
                        {
                            calculateNDC = true;
                        }
                    }
                    if (calculateNDC)
                    {
                        request.PatientMedSupp.NDCs = EndpointUtil.GetMedicationNDCs(request);
                    }
                    #endregion

                    string sigCode = CalculateSigCode(request);
                    if (!string.IsNullOrEmpty(sigCode))
                    {
                        request.PatientMedSupp.SigCode = sigCode;
                    }
                    PatientMedSuppData data = EndpointUtil.SavePatientMedSupp(request);
                    if (data != null)
                    {
                        patientMedSupp = Mapper.Map <PatientMedSupp>(data);
                    }
                }
                return(patientMedSupp);
            }
            catch (Exception ex) { throw ex; }
        }