private void SucceedsPartialDateTime(Parser <PartialDateTime> parser, string s) { AssertParser.SucceedsMatch(parser, s, PartialDateTime.Parse(s.Substring(1))); }
public void GivenAnEmptyStringOrWhiteSpaces_WhenParsing_ThenArgumentExceptionShouldBeThrown(string inputString) { Assert.Throws <ArgumentException>(() => PartialDateTime.Parse(inputString)); }
public async Task <Bundle> SearchHistoryAsync( string resourceType, string resourceId, PartialDateTime at, PartialDateTime since, int?count, string continuationToken, CancellationToken cancellationToken) { var queryParameters = new List <Tuple <string, string> >(); if (at != null && since != null) { // _at and _since cannot be both specified. throw new InvalidSearchOperationException( string.Format( CultureInfo.InvariantCulture, Core.Resources.AtAndSinceCannotBeBothSpecified, KnownQueryParameterNames.At, KnownQueryParameterNames.Since)); } bool searchByResourceId = !string.IsNullOrEmpty(resourceId); if (searchByResourceId) { queryParameters.Add(Tuple.Create(SearchParameterNames.Id, resourceId)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParameters.Add(Tuple.Create(KnownQueryParameterNames.ContinuationToken, continuationToken)); } if (at != null) { queryParameters.Add(Tuple.Create(SearchParameterNames.LastUpdated, at.ToString())); } else if (since != null) { queryParameters.Add(Tuple.Create(SearchParameterNames.LastUpdated, $"ge{since}")); } if (count.HasValue && count > 0) { queryParameters.Add(Tuple.Create(KnownQueryParameterNames.Count, count.ToString())); } SearchOptions searchOptions = !string.IsNullOrEmpty(resourceType) ? _searchOptionsFactory.Create(resourceType, queryParameters) : _searchOptionsFactory.Create(queryParameters); SearchResult searchResult = await SearchHistoryInternalAsync(searchOptions, cancellationToken); // If no results are returned from the _history search // determine if the resource actually exists or if the results were just filtered out. // The 'deleted' state has no effect because history will return deleted resources if (searchByResourceId && searchResult.Results.Any() == false) { var resource = await _dataStore.GetAsync(new ResourceKey(resourceType, resourceId), cancellationToken); if (resource == null) { throw new ResourceNotFoundException(string.Format(Core.Resources.ResourceNotFoundById, resourceType, resourceId)); } } return(_bundleFactory.CreateHistoryBundle( unsupportedSearchParams: null, result: searchResult)); }
public async Task GivenThereIsNoMatchingJob_WhenCreatingAnExportJob_ThenNewJobShouldBeCreated(Uri requestUrl, PartialDateTime since) { var request = new CreateExportRequest(requestUrl, ExportJobType.All, since: since); CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); Assert.NotNull(response); Assert.False(string.IsNullOrWhiteSpace(response.JobId)); }
public CreateExportRequest(Uri requestUri, ExportJobType requestType, string resourceType = null, PartialDateTime since = null, string groupId = null, string anonymizationConfigurationLocation = null, string anonymizationConfigurationFileETag = null) { EnsureArg.IsNotNull(requestUri, nameof(requestUri)); RequestUri = requestUri; RequestType = requestType; ResourceType = resourceType; Since = since; AnonymizationConfigurationLocation = anonymizationConfigurationLocation; AnonymizationConfigurationFileETag = anonymizationConfigurationFileETag; GroupId = groupId; }
public void GivenAnInvalidString_WhenParsing_ThenExceptionShouldBeThrown(string s) { Assert.Throws <ArgumentException>(ParamNameS, () => PartialDateTime.Parse(s)); }
public async Task GivenThereIsAMatchingJob_WhenCreatingAnExportJob_ThenExistingJobShouldBeReturned(Uri requestUri, PartialDateTime since) { var request = new CreateExportRequest(requestUri, ExportJobType.All, since: since); CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); var newRequest = new CreateExportRequest(requestUri, ExportJobType.All, since: since); CreateExportResponse newResponse = await _createExportRequestHandler.Handle(request, _cancellationToken); Assert.NotNull(newResponse); Assert.Equal(response.JobId, newResponse.JobId); }
private static object convertXmlStringToPrimitive(Type to, string value) { if (typeof(Boolean) == to) { return(XmlConvert.ToBoolean(value)); } if (typeof(Byte) == to) { return(XmlConvert.ToByte(value)); // Not used in FHIR serialization } if (typeof(Char) == to) { return(XmlConvert.ToChar(value)); // Not used in FHIR serialization } if (typeof(DateTime) == to) { return(ConvertToDatetimeOffset(value).UtcDateTime); // Obsolete: use DateTimeOffset instead!! } if (typeof(Decimal) == to) { if (FORBIDDEN_DECIMAL_PREFIXES.Any(prefix => value.StartsWith(prefix)) || value.EndsWith(".")) { // decimal cannot start with '+', '-' or '00' and cannot end with '.' throw new FormatException("Input string was not in a correct format."); } return(decimal.Parse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture)); } if (typeof(Double) == to) { return(XmlConvert.ToDouble(value)); // Could lead to loss in precision } if (typeof(Int16) == to) { return(XmlConvert.ToInt16(value)); // Could lead to loss in precision } if (typeof(Int32) == to) { return(XmlConvert.ToInt32(value)); } if (typeof(Int64) == to) { return(XmlConvert.ToInt64(value)); // Not used in FHIR serialization } if (typeof(SByte) == to) { return(XmlConvert.ToSByte(value)); // Not used in FHIR serialization } if (typeof(Single) == to) { return(XmlConvert.ToSingle(value)); // Not used in FHIR serialization } if (typeof(UInt16) == to) { return(XmlConvert.ToUInt16(value)); // Not used in FHIR serialization } if (typeof(UInt32) == to) { return(XmlConvert.ToUInt32(value)); // Not used in FHIR serialization } if (typeof(UInt64) == to) { return(XmlConvert.ToUInt64(value)); // Not used in FHIR serialization } if (typeof(byte[]) == to) { return(System.Convert.FromBase64String(value)); } if (typeof(DateTimeOffset) == to) { return(ConvertToDatetimeOffset(value)); } if (typeof(System.Uri) == to) { return(new Uri(value, UriKind.RelativeOrAbsolute)); } if (typeof(PartialDateTime) == to) { return(PartialDateTime.Parse(value)); } if (typeof(PartialTime) == to) { return(PartialTime.Parse(value)); } if (typeof(BigInteger) == to) { return(BigInteger.Parse(value)); } if (to.IsEnum()) { var result = EnumUtility.ParseLiteral(value, to); if (result == null) { throw Error.NotSupported($"String value '{value}' is not a known literal in enum '{to.Name}'"); } return(result); } throw Error.NotSupported($"Cannot convert string value '{value}' to a {to.Name}"); }
public static async Task <ResourceElement> SearchResourceHistoryAsync(this IMediator mediator, string resourceType, string resourceId, PartialDateTime since = null, PartialDateTime before = null, PartialDateTime at = null, int?count = null, string continuationToken = null, CancellationToken cancellationToken = default) { EnsureArg.IsNotNull(mediator, nameof(mediator)); var result = await mediator.Send(new SearchResourceHistoryRequest(resourceType, resourceId, since, before, at, count, continuationToken), cancellationToken); return(result.Bundle); }
public void FhirPath_Gramm_Literal() { var parser = Grammar.Literal.End(); AssertParser.SucceedsMatch(parser, "'hi there'", new ConstantExpression("hi there")); AssertParser.SucceedsMatch(parser, "3", new ConstantExpression(3L)); AssertParser.SucceedsMatch(parser, "3.14", new ConstantExpression(3.14m)); AssertParser.SucceedsMatch(parser, "@2013-12", new ConstantExpression(PartialDateTime.Parse("2013-12"))); AssertParser.SucceedsMatch(parser, "@T12:23:34Z", new ConstantExpression(PartialTime.Parse("12:23:34Z"))); AssertParser.SucceedsMatch(parser, "true", new ConstantExpression(true)); AssertParser.SucceedsMatch(parser, "@2014-12-13T12:00:00+02:00", new ConstantExpression(PartialDateTime.Parse("2014-12-13T12:00:00+02:00"))); AssertParser.FailsMatch(parser, "%constant"); AssertParser.FailsMatch(parser, "\"quotedstring\""); AssertParser.FailsMatch(parser, "A23identifier"); }
public void FhirPath_Gramm_Term() { var parser = Grammar.Term.End(); AssertParser.SucceedsMatch(parser, "childname", new ChildExpression(AxisExpression.This, "childname")); AssertParser.SucceedsMatch(parser, "$this", AxisExpression.This); AssertParser.SucceedsMatch(parser, "doSomething()", new FunctionCallExpression(AxisExpression.This, "doSomething", TypeInfo.Any)); AssertParser.SucceedsMatch(parser, "doSomething('hi', 3.14)", new FunctionCallExpression(AxisExpression.This, "doSomething", TypeInfo.Any, new ConstantExpression("hi"), new ConstantExpression(3.14m))); AssertParser.SucceedsMatch(parser, "%external", new VariableRefExpression("external")); AssertParser.SucceedsMatch(parser, "@2013-12", new ConstantExpression(PartialDateTime.Parse("2013-12"))); AssertParser.SucceedsMatch(parser, "3", new ConstantExpression(3L)); AssertParser.SucceedsMatch(parser, "true", new ConstantExpression(true)); AssertParser.SucceedsMatch(parser, "(3)", new ConstantExpression(3L)); AssertParser.SucceedsMatch(parser, "{}", NewNodeListInitExpression.Empty); AssertParser.SucceedsMatch(parser, "@2014-12-13T12:00:00+02:00", new ConstantExpression(PartialDateTime.Parse("2014-12-13T12:00:00+02:00"))); }
public void TestCompare() { Assert.Equal(0, MinMaxValidationExtensions.Compare(PartialDateTime.Parse("1972-11-30"), new Model.FhirDateTime(1972, 11, 30))); Assert.Equal(1, MinMaxValidationExtensions.Compare(PartialDateTime.Parse("1972-12-01"), new Model.Date(1972, 11, 30))); Assert.Equal(-1, MinMaxValidationExtensions.Compare(PartialDateTime.Parse("1972-12-01T13:00:00Z"), new Model.Instant(new DateTimeOffset(1972, 12, 01, 14, 00, 00, TimeSpan.Zero)))); Assert.Equal(0, MinMaxValidationExtensions.Compare(Hl7.FhirPath.Time.Parse("12:00:00Z"), new Model.Time("12:00:00Z"))); Assert.Equal(1, MinMaxValidationExtensions.Compare(3.14m, new Model.FhirDecimal(2.14m))); Assert.Equal(-1, MinMaxValidationExtensions.Compare(-3L, new Model.Integer(3))); Assert.Equal(-1, MinMaxValidationExtensions.Compare("aaa", new Model.FhirString("bbb"))); Assert.Equal(1, MinMaxValidationExtensions.Compare(new Hl7.FhirPath.Quantity(5.0m, "kg"), new Model.Quantity(4.0m, "kg"))); Assert.Throws <NotSupportedException>(() => MinMaxValidationExtensions.Compare(PartialDateTime.Parse("1972-11-30"), new Model.Quantity(4.0m, "kg"))); }
public void TestGetComparable() { var navQ = new PocoNavigator(new Model.FhirDateTime(1972, 11, 30)); Assert.Equal(0, navQ.GetComparableValue(typeof(Model.FhirDateTime)).CompareTo(PartialDateTime.Parse("1972-11-30"))); navQ = new PocoNavigator(new Model.Quantity(3.14m, "kg")); Assert.Equal(-1, navQ.GetComparableValue(typeof(Model.Quantity)).CompareTo(new Hl7.FhirPath.Quantity(5.0m, "kg"))); navQ = new PocoNavigator(new Model.HumanName()); Assert.Null(navQ.GetComparableValue(typeof(Model.HumanName))); var navQ2 = new PocoNavigator(new Model.Quantity(3.14m, "kg") { Comparator = Model.Quantity.QuantityComparator.GreaterOrEqual }); Assert.Throws <NotSupportedException>(() => navQ2.GetComparableValue(typeof(Model.Quantity))); var navQ3 = new PocoNavigator(new Model.Quantity()); Assert.Throws <NotSupportedException>(() => navQ3.GetComparableValue(typeof(Model.Quantity))); }
public async Task GivenResourceId_WhenSearchingHistoryWithSinceButNoResults_ThenBundleIsReturned() { const string resourceType = "Observation"; const string resourceId = "abc"; var observation = new Observation { Id = resourceId }.ToResourceElement(); var resourceWrapper = new ResourceWrapper(observation, _rawResourceFactory.Create(observation, keepMeta: true), _resourceRequest, false, null, null, null); _searchService.SearchImplementation = options => SearchResult.Empty(_unsupportedQueryParameters); _fhirDataStore.GetAsync(Arg.Any <ResourceKey>(), Arg.Any <CancellationToken>()).Returns(resourceWrapper); SearchResult searchResult = await _searchService.SearchHistoryAsync(resourceType, resourceId, PartialDateTime.Parse("2018"), null, null, null, null, CancellationToken.None); Assert.Empty(searchResult.Results); }
private async Task <IActionResult> SendExportRequest(ExportJobType exportType, PartialDateTime since, string resourceType = null, string groupId = null, string containerName = null, string anonymizationConfigLocation = null, string anonymizationConfigFileETag = null) { CreateExportResponse response = await _mediator.ExportAsync(_fhirRequestContextAccessor.FhirRequestContext.Uri, exportType, resourceType, since, groupId, containerName, anonymizationConfigLocation, anonymizationConfigFileETag, HttpContext.RequestAborted); var exportResult = ExportResult.Accepted(); exportResult.SetContentLocationHeader(_urlResolver, OperationsConstants.Export, response.JobId); return(exportResult); }
public async Task <IActionResult> Export([FromQuery(Name = KnownQueryParameterNames.Since)] PartialDateTime since, [FromQuery(Name = KnownQueryParameterNames.Type)] string resourceType) { CheckIfExportIsEnabled(); return(await SendExportRequest(ExportJobType.All, since, resourceType)); }
public void GivenANullString_WhenParsing_ThenExceptionShouldBeThrown() { Assert.Throws <ArgumentNullException>(ParamNameS, () => PartialDateTime.Parse(null)); }
public async Task <SearchResult> SearchHistoryAsync( string resourceType, string resourceId, PartialDateTime at, PartialDateTime since, PartialDateTime before, int?count, string continuationToken, CancellationToken cancellationToken) { var queryParameters = new List <Tuple <string, string> >(); if (at != null) { if (since != null) { // _at and _since cannot be both specified. throw new InvalidSearchOperationException( string.Format( CultureInfo.InvariantCulture, Core.Resources.AtCannotBeSpecifiedWithBeforeOrSince, KnownQueryParameterNames.At, KnownQueryParameterNames.Since)); } if (before != null) { // _at and _since cannot be both specified. throw new InvalidSearchOperationException( string.Format( CultureInfo.InvariantCulture, Core.Resources.AtCannotBeSpecifiedWithBeforeOrSince, KnownQueryParameterNames.At, KnownQueryParameterNames.Before)); } } if (before != null) { var beforeOffset = before.ToDateTimeOffset( defaultMonth: 1, defaultDaySelector: (year, month) => 1, defaultHour: 0, defaultMinute: 0, defaultSecond: 0, defaultFraction: 0.0000000m, defaultUtcOffset: TimeSpan.Zero).ToUniversalTime(); if (beforeOffset.CompareTo(Clock.UtcNow) > 0) { // you cannot specify a value for _before in the future throw new InvalidSearchOperationException( string.Format( CultureInfo.InvariantCulture, Core.Resources.HistoryParameterBeforeCannotBeFuture, KnownQueryParameterNames.Before)); } } bool searchByResourceId = !string.IsNullOrEmpty(resourceId); if (searchByResourceId) { queryParameters.Add(Tuple.Create(SearchParameterNames.Id, resourceId)); } if (!string.IsNullOrEmpty(continuationToken)) { queryParameters.Add(Tuple.Create(KnownQueryParameterNames.ContinuationToken, continuationToken)); } if (at != null) { queryParameters.Add(Tuple.Create(SearchParameterNames.LastUpdated, at.ToString())); } else { if (since != null) { queryParameters.Add(Tuple.Create(SearchParameterNames.LastUpdated, $"ge{since}")); } if (before != null) { queryParameters.Add(Tuple.Create(SearchParameterNames.LastUpdated, $"lt{before}")); } } if (count.HasValue && count > 0) { queryParameters.Add(Tuple.Create(KnownQueryParameterNames.Count, count.ToString())); } SearchOptions searchOptions = _searchOptionsFactory.Create(resourceType, queryParameters); SearchResult searchResult = await SearchHistoryInternalAsync(searchOptions, cancellationToken); // If no results are returned from the _history search // determine if the resource actually exists or if the results were just filtered out. // The 'deleted' state has no effect because history will return deleted resources if (searchByResourceId && searchResult.Results.Any() == false) { var resource = await _fhirDataStore.GetAsync(new ResourceKey(resourceType, resourceId), cancellationToken); if (resource == null) { throw new ResourceNotFoundException(string.Format(Core.Resources.ResourceNotFoundById, resourceType, resourceId)); } } return(searchResult); }
public void GivenAnInvalidFormatString_WhenParsing_ThenExceptionShouldBeThrown() { Assert.Throws <FormatException>(() => PartialDateTime.Parse("abc")); }
private Expression <Predicate <IReadOnlyList <Tuple <string, string> > > > CreateQueryParametersExpressionWithContinuationToken(string continuationToken, PartialDateTime since) { return(arg => arg != null && Tuple.Create("_count", "1").Equals(arg[0]) && Tuple.Create("_lastUpdated", $"le{_exportJobRecord.QueuedTime.ToString("o")}").Equals(arg[1]) && Tuple.Create("_lastUpdated", $"ge{since}").Equals(arg[2]) && Tuple.Create("ct", continuationToken).Equals(arg[3])); }
public async Task GivenDifferentRequestUrl_WhenCreatingAnExportJob_ThenNewJobShouldBeCreated(Uri requestUri, PartialDateTime since, Uri newRequestUri, PartialDateTime newSince) { var request = new CreateExportRequest(requestUri, ExportJobType.All, since: since); CreateExportResponse response = await _createExportRequestHandler.Handle(request, _cancellationToken); var newRequest = new CreateExportRequest(newRequestUri, ExportJobType.All, since: newSince); CreateExportResponse newResponse = await _createExportRequestHandler.Handle(newRequest, _cancellationToken); Assert.NotNull(newResponse); Assert.NotEqual(response.JobId, newResponse.JobId); }
public static SymbolTable AddStandardFP(this SymbolTable t) { // Functions that operate on the focus, without null propagation t.Add("empty", (IEnumerable <object> f) => !f.Any()); t.Add("exists", (IEnumerable <object> f) => f.Any()); t.Add("count", (IEnumerable <object> f) => f.Count()); t.Add("trace", (IEnumerable <IElementNavigator> f, string name) => f.Trace(name)); // t.Add("binary.|", (object f, IEnumerable<IValueProvider> l, IEnumerable<IValueProvider> r) => l.ConcatUnion(r)); t.Add("binary.|", (object f, IEnumerable <IElementNavigator> l, IEnumerable <IElementNavigator> r) => l.DistinctUnion(r)); t.Add("binary.contains", (object f, IEnumerable <IElementNavigator> a, IElementNavigator b) => a.Contains(b)); t.Add("binary.in", (object f, IElementNavigator a, IEnumerable <IElementNavigator> b) => b.Contains(a)); t.Add("distinct", (IEnumerable <IElementNavigator> f) => f.Distinct()); t.Add("isDistinct", (IEnumerable <IElementNavigator> f) => f.IsDistinct()); t.Add("subsetOf", (IEnumerable <IElementNavigator> f, IEnumerable <IElementNavigator> a) => f.SubsetOf(a)); t.Add("supersetOf", (IEnumerable <IElementNavigator> f, IEnumerable <IElementNavigator> a) => a.SubsetOf(f)); t.Add("today", (object f) => PartialDateTime.Today()); t.Add("now", (object f) => PartialDateTime.Now()); t.Add("binary.&", (object f, string a, string b) => (a ?? "") + (b ?? "")); t.Add("iif", (IEnumerable <IElementNavigator> f, bool?condition, IEnumerable <IElementNavigator> result) => f.IIf(condition, result)); t.Add("iif", (IEnumerable <IElementNavigator> f, bool?condition, IEnumerable <IElementNavigator> result, IEnumerable <IElementNavigator> otherwise) => f.IIf(condition, result, otherwise)); // Functions that use normal null propagation and work with the focus (buy may ignore it) t.Add("not", (IEnumerable <IElementNavigator> f) => f.Not(), doNullProp: true); t.Add("builtin.children", (IEnumerable <IElementNavigator> f, string a) => f.Navigate(a), doNullProp: true); t.Add("children", (IEnumerable <IElementNavigator> f) => f.Children(), doNullProp: true); t.Add("descendants", (IEnumerable <IElementNavigator> f) => f.Descendants(), doNullProp: true); t.Add("binary.=", (object f, IEnumerable <IElementNavigator> a, IEnumerable <IElementNavigator> b) => a.IsEqualTo(b), doNullProp: true); t.Add("binary.!=", (object f, IEnumerable <IElementNavigator> a, IEnumerable <IElementNavigator> b) => !a.IsEqualTo(b), doNullProp: true); t.Add("binary.~", (object f, IEnumerable <IElementNavigator> a, IEnumerable <IElementNavigator> b) => a.IsEquivalentTo(b), doNullProp: true); t.Add("binary.!~", (object f, IEnumerable <IElementNavigator> a, IEnumerable <IElementNavigator> b) => !a.IsEquivalentTo(b), doNullProp: true); t.Add("unary.-", (object f, long a) => - a, doNullProp: true); t.Add("unary.-", (object f, decimal a) => - a, doNullProp: true); t.Add("unary.+", (object f, long a) => a, doNullProp: true); t.Add("unary.+", (object f, decimal a) => a, doNullProp: true); t.Add("binary.*", (object f, long a, long b) => a * b, doNullProp: true); t.Add("binary.*", (object f, decimal a, decimal b) => a * b, doNullProp: true); t.Add("binary./", (object f, decimal a, decimal b) => a / b, doNullProp: true); //.Add((object f, decimal a, decimal b) => a / b, doNullProp: true); t.Add("binary.+", (object f, long a, long b) => a + b, doNullProp: true); t.Add("binary.+", (object f, decimal a, decimal b) => a + b, doNullProp: true); t.Add("binary.+", (object f, string a, string b) => a + b, doNullProp: true); t.Add("binary.-", (object f, long a, long b) => a - b, doNullProp: true); t.Add("binary.-", (object f, decimal a, decimal b) => a - b, doNullProp: true); t.Add("binary.div", (object f, long a, long b) => a / b, doNullProp: true); t.Add("binary.div", (object f, decimal a, decimal b) => (long)Math.Truncate(a / b), doNullProp: true); t.Add("binary.mod", (object f, long a, long b) => a % b, doNullProp: true); t.Add("binary.mod", (object f, decimal a, decimal b) => a % b, doNullProp: true); t.Add("binary.>", (object f, long a, long b) => a > b, doNullProp: true); t.Add("binary.>", (object f, decimal a, decimal b) => a > b, doNullProp: true); t.Add("binary.>", (object f, string a, string b) => String.CompareOrdinal(a, b) > 0, doNullProp: true); t.Add("binary.>", (object f, PartialDateTime a, PartialDateTime b) => a > b, doNullProp: true); t.Add("binary.>", (object f, PartialTime a, PartialTime b) => a > b, doNullProp: true); t.Add("binary.<", (object f, long a, long b) => a < b, doNullProp: true); t.Add("binary.<", (object f, decimal a, decimal b) => a < b, doNullProp: true); t.Add("binary.<", (object f, string a, string b) => String.CompareOrdinal(a, b) < 0, doNullProp: true); t.Add("binary.<", (object f, PartialDateTime a, PartialDateTime b) => a < b, doNullProp: true); t.Add("binary.<", (object f, PartialTime a, PartialTime b) => a < b, doNullProp: true); t.Add("binary.<=", (object f, long a, long b) => a <= b, doNullProp: true); t.Add("binary.<=", (object f, decimal a, decimal b) => a <= b, doNullProp: true); t.Add("binary.<=", (object f, string a, string b) => String.CompareOrdinal(a, b) <= 0, doNullProp: true); t.Add("binary.<=", (object f, PartialDateTime a, PartialDateTime b) => a <= b, doNullProp: true); t.Add("binary.<=", (object f, PartialTime a, PartialTime b) => a <= b, doNullProp: true); t.Add("binary.>=", (object f, long a, long b) => a >= b, doNullProp: true); t.Add("binary.>=", (object f, decimal a, decimal b) => a >= b, doNullProp: true); t.Add("binary.>=", (object f, string a, string b) => String.CompareOrdinal(a, b) >= 0, doNullProp: true); t.Add("binary.>=", (object f, PartialDateTime a, PartialDateTime b) => a >= b, doNullProp: true); t.Add("binary.>=", (object f, PartialTime a, PartialTime b) => a >= b, doNullProp: true); t.Add("single", (IEnumerable <IElementNavigator> f) => f.Single(), doNullProp: true); t.Add("skip", (IEnumerable <IElementNavigator> f, long a) => f.Skip((int)a), doNullProp: true); t.Add("first", (IEnumerable <IElementNavigator> f) => f.First(), doNullProp: true); t.Add("last", (IEnumerable <IElementNavigator> f) => f.Last(), doNullProp: true); t.Add("tail", (IEnumerable <IElementNavigator> f) => f.Tail(), doNullProp: true); t.Add("take", (IEnumerable <IElementNavigator> f, long a) => f.Take((int)a), doNullProp: true); t.Add("builtin.item", (IEnumerable <IElementNavigator> f, long a) => f.Item((int)a), doNullProp: true); t.Add("toInteger", (IElementNavigator f) => f.ToInteger(), doNullProp: true); t.Add("toDecimal", (IElementNavigator f) => f.ToDecimal(), doNullProp: true); t.Add("toString", (IElementNavigator f) => f.ToStringRepresentation(), doNullProp: true); t.Add("substring", (string f, long a) => f.FpSubstring((int)a), doNullProp: true); t.Add("substring", (string f, long a, long b) => f.FpSubstring((int)a, (int)b), doNullProp: true); t.Add("startsWith", (string f, string fragment) => f.StartsWith(fragment), doNullProp: true); t.Add("endsWith", (string f, string fragment) => f.EndsWith(fragment), doNullProp: true); t.Add("matches", (string f, string regex) => Regex.IsMatch(f, regex), doNullProp: true); t.Add("indexOf", (string f, string fragment) => f.FpIndexOf(fragment), doNullProp: true); t.Add("contains", (string f, string fragment) => f.Contains(fragment), doNullProp: true); t.Add("replaceMatches", (string f, string regex, string subst) => Regex.Replace(f, regex, subst), doNullProp: true); t.Add("replace", (string f, string regex, string subst) => f.FpReplace(regex, subst), doNullProp: true); t.Add("length", (string f) => f.Length, doNullProp: true); t.Add("is", (IElementNavigator f, string name) => f.Is(name), doNullProp: true); t.Add("as", (IEnumerable <IElementNavigator> f, string name) => f.FilterType(name), doNullProp: true); t.Add("binary.is", (object f, IElementNavigator left, string name) => left.Is(name), doNullProp: true); t.Add("binary.as", (object f, IElementNavigator left, string name) => left.CastAs(name), doNullProp: true); t.Add("extension", (IEnumerable <IElementNavigator> f, string url) => f.Extension(url), doNullProp: true); // Logic operators do not use null propagation and may do short-cut eval t.AddLogic("binary.and", (a, b) => a.And(b)); t.AddLogic("binary.or", (a, b) => a.Or(b)); t.AddLogic("binary.xor", (a, b) => a.XOr(b)); t.AddLogic("binary.implies", (a, b) => a.Implies(b)); // Special late-bound functions t.Add(new CallSignature("where", typeof(IEnumerable <IElementNavigator>), typeof(object), typeof(Invokee)), runWhere); t.Add(new CallSignature("select", typeof(IEnumerable <IElementNavigator>), typeof(object), typeof(Invokee)), runSelect); t.Add(new CallSignature("all", typeof(bool), typeof(object), typeof(Invokee)), runAll); t.Add(new CallSignature("any", typeof(bool), typeof(object), typeof(Invokee)), runAny); t.Add(new CallSignature("repeat", typeof(IEnumerable <IElementNavigator>), typeof(object), typeof(Invokee)), runRepeat); t.AddVar("sct", "http://snomed.info/sct"); t.AddVar("loinc", "http://loinc.org"); t.AddVar("ucum", "http://unitsofmeasure.org"); t.Add("builtin.coreexturl", (object f, string id) => getCoreExtensionUrl(id)); t.Add("builtin.corevsurl", (object f, string id) => getCoreValueSetUrl(id)); return(t); }
public async Task GivenResourceId_WhenSearchingHistoryWithSinceButNoResults_ThenBundleIsReturned() { const string resourceType = "Observation"; const string resourceId = "abc"; var observation = new Observation { Id = resourceId }; var resourceWrapper = new ResourceWrapper(observation, _rawResourceFactory.Create(observation), _resourceRequest, false, null, null); _searchService.SearchImplementation = options => new SearchResult(new ResourceWrapper[0], null); _urlResolver.ResolveRouteUrl(Arg.Any <string>(), Arg.Any <IEnumerable <Tuple <string, string> > >()).Returns(new Uri("http://narwhal")); _dataStore.GetAsync(Arg.Any <ResourceKey>(), Arg.Any <CancellationToken>()).Returns(resourceWrapper); var bundle = await _searchService.SearchHistoryAsync(resourceType, resourceId, PartialDateTime.Parse("2018"), null, null, null, CancellationToken.None); Assert.Empty(bundle.Entry); }
public CreateExportRequest(Uri requestUri, ExportJobType requestType, string resourceType = null, PartialDateTime since = null, string groupId = null, string containerName = null) { EnsureArg.IsNotNull(requestUri, nameof(requestUri)); RequestUri = requestUri; RequestType = requestType; ResourceType = resourceType; Since = since; GroupId = groupId; ContainerName = containerName; }