public async Task DocumentOperationCanIncludeCustomResources() { var composition = CreateTestCompositionInclCustomResource(); var compositionSearchResult = new SearchResult(new List <IResource>() { composition }, 1, 1); var customResourceTest = SourceNode.Resource("CustomBasic", "CustomBasic"); customResourceTest.Add(SourceNode.Valued("id", Guid.NewGuid().ToString())); var customResourceSearchResults = new SearchResult(new List <IResource> { customResourceTest.ToIResource(VonkConstants.Model.FhirR3) }, 1, 1); _searchMock.Setup(repo => repo.Search(It.Is <IArgumentCollection>(arg => arg.GetArgument("_type").ArgumentValue.Equals("Composition")), It.IsAny <SearchOptions>())).ReturnsAsync(compositionSearchResult); _searchMock.Setup(repo => repo.Search(It.Is <IArgumentCollection>(arg => arg.GetArgument("_type").ArgumentValue.Equals("CustomBasic")), It.IsAny <SearchOptions>())).ReturnsAsync(customResourceSearchResults); var testContext = new VonkTestContext(VonkInteraction.instance_custom); testContext.Arguments.AddArguments(new[] { new Argument(ArgumentSource.Path, ArgumentNames.resourceType, "Composition"), new Argument(ArgumentSource.Path, ArgumentNames.resourceId, "test") }); testContext.TestRequest.CustomOperation = "document"; testContext.TestRequest.Method = "GET"; await _documentService.DocumentInstanceGET(testContext); testContext.Response.HttpResult.Should().Be(StatusCodes.Status200OK, "$document should return HTTP 200 - OK when all references in the composition (incl. recursive references) can be resolved"); testContext.Response.Payload.SelectNodes("entry.resource").Count().Should().Be(2, "Expected Composition and CustomBasic to be in the document"); }
public ElementNodeTests() { var annotatedNode = SourceNode.Valued("id", "myId1"); (annotatedNode as IAnnotatable).AddAnnotation("a string annotation"); patient = SourceNode.Node("Patient", SourceNode.Resource("contained", "Observation", SourceNode.Valued("valueBoolean", "true")), SourceNode.Valued("active", "true", annotatedNode, SourceNode.Valued("id", "myId2"), SourceNode.Node("extension", SourceNode.Valued("value", "4")), SourceNode.Node("extension", SourceNode.Valued("value", "world!")))); }
private GenericBundle CreateEmptyBundle() { var bundleResourceNode = SourceNode.Resource("Bundle", "Bundle", SourceNode.Valued("type", "searchset")); var identifier = SourceNode.Node("identifier"); identifier.Add(SourceNode.Valued("system", "urn:ietf:rfc:3986")); identifier.Add(SourceNode.Valued("value", Guid.NewGuid().ToString())); bundleResourceNode.Add(identifier); var documentBundle = GenericBundle.FromBundle(bundleResourceNode); documentBundle = documentBundle.Meta(Guid.NewGuid().ToString(), DateTimeOffset.Now); return(documentBundle); }
public void IgnoreElements() { var patient = SourceNode.Resource("Patient", "Patient", SourceNode.Valued("id", "pat1")); var jsonBare = patient.ToTypedElement(new PocoStructureDefinitionSummaryProvider()).ToJson(new FhirJsonSerializationSettings { IgnoreUnknownElements = false }); Assert.IsTrue(jsonBare.Contains("pat1")); patient.Add(SourceNode.Valued("unknownElement", "someValue")); var jsonUnknown = patient.ToTypedElement(new PocoStructureDefinitionSummaryProvider(), settings: new TypedElementSettings { ErrorMode = TypedElementSettings.TypeErrorMode.Ignore }).ToJson(new FhirJsonSerializationSettings { IgnoreUnknownElements = true }); Assert.IsFalse(jsonUnknown.Contains("unknownElement")); }