Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MedicationId,MedicationName,MedStrength,MedDosage,MedFrequency,ConditionBeingTreated,DrugStatus,DateStarted,DateStopped,MedProviderId,PharmacyUsed,PharmacyNumber,PrescriptionNumber,Refills,OtcDrugs,VitaminsAndSupplements,CommentsDirections")] MedicationHistory medicationHistory)
        {
            if (id != medicationHistory.MedicationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(medicationHistory);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MedicationHistoryExists(medicationHistory.MedicationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MedProviderId"] = new SelectList(_context.MedicalProvider, "MedProviderId", "ActiveOrInactive", medicationHistory.MedProviderId);
            return(View(medicationHistory));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("MedicationId,MedicationName,MedStrength,MedDosage,MedFrequency,ConditionBeingTreated,DrugStatus,DateStarted,DateStopped,MedProviderId,PharmacyUsed,PharmacyNumber,PrescriptionNumber,Refills,OtcDrugs,VitaminsAndSupplements,CommentsDirections")] MedicationHistory medicationHistory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(medicationHistory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MedProviderId"] = new SelectList(_context.MedicalProvider, "MedProviderId", "ActiveOrInactive", medicationHistory.MedProviderId);
            return(View(medicationHistory));
        }
        public void ValidateGetMedicationStatement()
        {
            string          PHN   = "9735361219";
            string          HDID  = "EXTRIOYFPNX35TWEBUAJ3DNFDFXSYTBC6J4M76GYE3HC5ER2NKWQ";
            string          IP    = "10.0.0.1";
            ODRHistoryQuery query = new ODRHistoryQuery()
            {
                StartDate = System.DateTime.Parse("1990/01/01"),
                EndDate   = System.DateTime.Now,
                PHN       = PHN,
            };
            ProtectiveWord protectiveWord = new ProtectiveWord()
            {
                Id            = Guid.Parse("ed428f08-1c07-4439-b2a3-acbb16b8fb65"),
                RequestorHDID = HDID,
                RequestorIP   = IP,
                QueryResponse = new ProtectiveWordQueryResponse()
                {
                    PHN      = PHN,
                    Operator = Constants.ProtectiveWordOperator.Get,
                    Value    = string.Empty,
                }
            };
            string            protectiveWordjson = JsonSerializer.Serialize(protectiveWord);
            MedicationHistory medicationHistory  = new MedicationHistory()
            {
                Id            = Guid.Parse("ee37267e-cb2c-48e1-a3c9-16c36ce7466b"),
                RequestorHDID = HDID,
                RequestorIP   = IP,
                Query         = query,
                Response      = new MedicationHistoryResponse()
                {
                    Id           = Guid.Parse("ee37267e-cb2c-48e1-a3c9-16c36ce7466b"),
                    Pages        = 1,
                    TotalRecords = 1,
                    Results      = new List <Models.ODR.MedicationResult>()
                    {
                        new Models.ODR.MedicationResult()
                        {
                            DIN                = "00000000",
                            Directions         = "Directions",
                            DispenseDate       = DateTime.Now,
                            DispensingPharmacy = new Pharmacy()
                            {
                                Address = new Address()
                                {
                                    City       = "City",
                                    Country    = "Country",
                                    Line1      = "Line 1",
                                    Line2      = "Line 2",
                                    PostalCode = "A1A 1A1",
                                    Province   = "PR",
                                },
                                FaxNumber   = "1111111111",
                                Name        = "Name",
                                PharmacyId  = "ID",
                                PhoneNumber = "2222222222",
                            },
                            GenericName = "Generic Name",
                            Id          = 0,
                            Practioner  = new Name()
                            {
                                GivenName     = "Given",
                                MiddleInitial = "I",
                                Surname       = "Surname",
                            },
                            PrescriptionNumber = "Number",
                            PrescriptionStatus = "F",
                            Quantity           = 1,
                            Refills            = 1,
                        },
                    },
                }
            };
            string meedicationHistoryjson = JsonSerializer.Serialize(medicationHistory);

            var       handlerMock         = new Mock <HttpMessageHandler>();
            ODRConfig odrConfig           = new ODRConfig();
            string    ODRConfigSectionKey = "ODR";

            this.configuration.Bind(ODRConfigSectionKey, odrConfig);
            Uri baseURI = new Uri(odrConfig.BaseEndpoint);
            Uri patientProfileEndpoint = new Uri(baseURI, odrConfig.PatientProfileEndpoint);
            Uri protectiveWordEndpoint = new Uri(baseURI, odrConfig.ProtectiveWordEndpoint);

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.Is <HttpRequestMessage>(c => c.RequestUri == patientProfileEndpoint),
                ItExpr.IsAny <CancellationToken>()
                )
            .ReturnsAsync(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(meedicationHistoryjson),
            })
            .Verifiable();

            handlerMock
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.Is <HttpRequestMessage>(c => c.RequestUri == protectiveWordEndpoint),
                ItExpr.IsAny <CancellationToken>()
                )
            .ReturnsAsync(new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(protectiveWordjson),
            })
            .Verifiable();
            using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
            Mock <IGenericCacheDelegate> mockCacheDelegate = new Mock <IGenericCacheDelegate>();
            Mock <IHashDelegate>         mockHashDelegate  = new Mock <IHashDelegate>();
            IHash hash = new HMACHash()
            {
                Hash = "",
            };

            mockHashDelegate.Setup(s => s.Hash(It.IsAny <string>())).Returns(hash);
            mockHashDelegate.Setup(s => s.Compare(It.IsAny <string>(), It.IsAny <IHash>())).Returns(true);
            Mock <IHttpClientService> mockHttpClientService = new Mock <IHttpClientService>();

            mockHttpClientService.Setup(s => s.CreateDefaultHttpClient()).Returns(() => new HttpClient(handlerMock.Object));
            IMedStatementDelegate medStatementDelegate = new RestMedStatementDelegate(loggerFactory.CreateLogger <RestMedStatementDelegate>(),
                                                                                      mockHttpClientService.Object,
                                                                                      this.configuration,
                                                                                      mockCacheDelegate.Object,
                                                                                      mockHashDelegate.Object);

            RequestResult <MedicationHistoryResponse> response = Task.Run(async() =>
                                                                          await medStatementDelegate.GetMedicationStatementsAsync(
                                                                              query,
                                                                              string.Empty,
                                                                              string.Empty,
                                                                              string.Empty).ConfigureAwait(true)).Result;

            Assert.True(response.ResultStatus == Common.Constants.ResultType.Success &&
                        medicationHistory.Response.IsDeepEqual(response.ResourcePayload));
        }