private void ShouldHavePoorScore()
        {
            var patient = new HipLibrary.Patient.Model.Patient {
                Name = "Jackie"
            };
            var patientWithRank = new NameRanker().Rank(patient, "Zackey");

            patientWithRank.Meta.Should().BeEquivalentTo(FullMatchMeta(Match.Empty));
            patientWithRank.Rank.Score.Should().Be(0);
        }
        private void ShouldHaveHighScore()
        {
            var patient = new HipLibrary.Patient.Model.Patient {
                Name = "Jack"
            };
            var patientWithRank = new NameRanker().Rank(patient, "Zack");

            patientWithRank.Meta.Should().BeEquivalentTo(FullMatchMeta(Match.Name));
            patientWithRank.Rank.Score.Should().Be(8);
        }
Exemplo n.º 3
0
        private static IEnumerable <CareContextRepresentation> GetUnlinkedCareContexts(
            IEnumerable <LinkedAccounts> linkedAccounts,
            HipLibrary.Patient.Model.Patient patient)
        {
            var allLinkedCareContexts = linkedAccounts
                                        .SelectMany(account => account.CareContexts)
                                        .ToList();

            return(patient.CareContexts
                   .Where(careContext =>
                          allLinkedCareContexts.Find(linkedCareContext =>
                                                     linkedCareContext == careContext.ReferenceNumber) == null));
        }
Exemplo n.º 4
0
        private async void ShouldReturnPatientForAlreadyLinkedPatient()
        {
            var patientDiscovery = new PatientDiscovery(
                matchingRepository.Object,
                discoveryRequestRepository.Object,
                linkPatientRepository.Object,
                patientRepository.Object,
                logger.Object);
            var phoneNumber           = Faker().Phone.PhoneNumber();
            var verifiedIdentifiers   = new[] { new Identifier(IdentifierType.MOBILE, phoneNumber) };
            var unverifiedIdentifiers = new[] { new Identifier(IdentifierType.MR, Faker().Random.String()) };
            var patientId             = Faker().Random.String();
            var name          = Faker().Name.FullName();
            var alreadyLinked =
                new CareContextRepresentation(Faker().Random.Uuid().ToString(), Faker().Random.String());
            var unlinkedCareContext =
                new CareContextRepresentation(Faker().Random.Uuid().ToString(), Faker().Random.String());
            var expectedPatient = new PatientEnquiryRepresentation(
                patientId,
                name,
                new[] { unlinkedCareContext },
                new[] { Match.ConsentManagerUserId.ToString() });
            var transactionId  = Faker().Random.String();
            var patientRequest = new PatientEnquiry(patientId,
                                                    verifiedIdentifiers,
                                                    unverifiedIdentifiers,
                                                    name,
                                                    HipLibrary.Patient.Model.Gender.M,
                                                    2019);
            var discoveryRequest  = new DiscoveryRequest(patientRequest, RandomString(), transactionId, DateTime.Now);
            var sessionId         = Faker().Random.Hash();
            var linkedCareContext = new[] { alreadyLinked.ReferenceNumber };
            var testLinkAccounts  = new LinkedAccounts(patientId,
                                                       sessionId,
                                                       Faker().Random.Hash(),
                                                       It.IsAny <string>(),
                                                       linkedCareContext.ToList());
            var testPatient =
                new HipLibrary.Patient.Model.Patient
            {
                PhoneNumber  = phoneNumber,
                Identifier   = patientId,
                Gender       = Faker().PickRandom <HipLibrary.Patient.Model.Gender>(),
                Name         = name,
                CareContexts = new[]
                {
                    alreadyLinked,
                    unlinkedCareContext
                }
            };

            linkPatientRepository.Setup(e => e.GetLinkedCareContexts(patientId))
            .ReturnsAsync(new Tuple <IEnumerable <LinkedAccounts>, Exception>(
                              new List <LinkedAccounts> {
                testLinkAccounts
            },
                              null));
            patientRepository.Setup(x => x.PatientWith(testPatient.Identifier))
            .Returns(Option.Some(testPatient));

            var(discoveryResponse, error) = await patientDiscovery.PatientFor(discoveryRequest);

            discoveryResponse.Patient.Should().BeEquivalentTo(expectedPatient);
            discoveryRequestRepository.Verify(
                x => x.Add(It.Is <HipService.Discovery.Model.DiscoveryRequest>(
                               r => r.TransactionId == transactionId && r.ConsentManagerUserId == patientId)),
                Times.Once);
            error.Should().BeNull();
        }