public List <Visit> ExecuteGetByPersonId(long id)
 {
     return(_historicalDataGateway.GetVisitByPersonId(id).ToList());
 }
        private IEnumerable <BsonDocument> GetHistoricRecordsByPersonId(string personId, string?ncId)
        {
            var mosaicIdQuery  = _sccvDbContext.getCollection().AsQueryable();
            var mosaicIDFilter = Builders <BsonDocument> .Filter.Regex("mosaic_id", new BsonRegularExpression("^" + personId + "$", "i"));

            mosaicIdQuery = mosaicIdQuery.Where(db => mosaicIDFilter.Inject());

            var casesAndVisits = mosaicIdQuery.ToList();

            if (!string.IsNullOrWhiteSpace(ncId))
            {
                //add records that are still using nc ID to the results
                var ncIdQuery  = _sccvDbContext.getCollection().AsQueryable();
                var ncIdFilter = Builders <BsonDocument> .Filter.Regex("mosaic_id", new BsonRegularExpression("^" + ncId + "$", "i"));

                ncIdQuery = ncIdQuery.Where(db => ncIdFilter.Inject());

                casesAndVisits.AddRange(ncIdQuery.ToList());
            }

            long mosaicId;

            try
            {
                mosaicId = Convert.ToInt64(personId);
            }
            catch (Exception e) when(
                e is FormatException ||
                e is OverflowException
                )
            {
                throw new ProcessDataGatewayException($"PersonId conversion failure for id {personId}");
            }

            var historicVisits = new List <BsonDocument>();

            var visits = _historicalDataGateway
                         .GetVisitByPersonId(mosaicId)
                         .ToList();

            if (visits.Count > 0)
            {
                historicVisits = visits
                                 .Select(ResponseFactory.HistoricalVisitsToDomain)
                                 .ToList();
            }

            var historicCases = new List <BsonDocument>();

            var caseNotes = _historicalDataGateway
                            .GetCaseNotesByPersonId(mosaicId);

            if (caseNotes?.Count > 0)
            {
                historicCases = caseNotes
                                .Select(ResponseFactory.HistoricalCaseNotesToDomain)
                                .ToList();
            }

            if (historicVisits.Count > 0)
            {
                casesAndVisits.AddRange(historicVisits);
            }
            if (historicCases.Count > 0)
            {
                casesAndVisits.AddRange(historicCases);
            }

            return(casesAndVisits);
        }