コード例 #1
0
        public void OIDandUUIDUrls()
        {
            var oidUrl = "urn:oid:1.2.3";
            var illOidUrl = "urn:oid:datmagdusniet";
            var uuidUrl = "urn:uuid:a5afddf4-e880-459b-876e-e4591b0acc11";
            var illUuidUrl = "urn:uuid:ooknietgoed";
            var oidWithZero = "urn:oid:1.2.0.3.4";

            FhirUri uri = new FhirUri(oidUrl);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            uri = new FhirUri(illOidUrl);
            validateErrorOrFail(uri);

            uri = new FhirUri(uuidUrl);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            uri = new FhirUri(illUuidUrl);
            validateErrorOrFail(uri);

            uri = new FhirUri(oidWithZero);
            Validator.ValidateObject(uri, new ValidationContext(uri), true);

            Assert.IsTrue(Uri.Equals(new Uri("http://nu.nl"), new Uri("http://nu.nl")));
        }
        public OperationOutcome ValidateContent(List <DocumentReference.ContentComponent> contents)
        {
            //profile checker checks
            // - has at least one content
            // - has valid format
            // - has valid contentStability extension
            // - has 1 attachment
            //    - has valid creation date
            //    -
            foreach (var content in contents)
            {
                //attachment.contentType
                //TODO validate contenttype format
                var contentType = content.Attachment.ContentType;
                if (string.IsNullOrEmpty(contentType))
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("contenttype"));
                }

                //attachment.url
                var url = content.Attachment.Url;
                if (string.IsNullOrEmpty(url) || !FhirUri.IsValidValue(url))
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("url"));
                }
            }

            return(null);
        }
コード例 #3
0
        void InternalizeReferences(Resource resource)
        {
            Visitor action = (element, name) =>
            {
                if (element == null)
                {
                    return;
                }

                if (element is ResourceReference)
                {
                    ResourceReference reference = (ResourceReference)element;
                    if (reference.Url != null)
                    {
                        reference.Url = new Uri(InternalizeReference(reference.Url.ToString()), UriKind.RelativeOrAbsolute);
                    }
                }
                else if (element is FhirUri)
                {
                    FhirUri uri = (FhirUri)element;
                    uri.Value = InternalizeReference(uri.Value);
                    //((FhirUri)element).Value = LocalizeReference(new Uri(((FhirUri)element).Value, UriKind.RelativeOrAbsolute)).ToString();
                }
                else if (element is Narrative)
                {
                    Narrative n = (Narrative)element;
                    n.Div = FixXhtmlDiv(n.Div);
                }
            };

            Type[] types = { typeof(ResourceReference), typeof(FhirUri), typeof(Narrative) };

            Engine.Auxiliary.ResourceVisitor.VisitByType(resource, action, types);
        }
コード例 #4
0
        public static Parameters TranslateConcept(this FhirClient client, Code code, FhirUri system, FhirString version,
                                                  FhirUri valueSet, Coding coding, CodeableConcept codeableConcept, FhirUri target, IEnumerable <TranslateConceptDependency> dependencies)
        {
            Parameters par = createTranslateConceptParams(code, system, version, valueSet, coding, codeableConcept, target, dependencies);

            return(expect <Parameters>(client.TypeOperation <ConceptMap>(Operation.TRANSLATE, par)));
        }
コード例 #5
0
        public static Parameters TranslateConcept(this FhirClient client, string id, Code code, FhirUri system, FhirString version,
                                                  FhirUri valueSet, Coding coding, CodeableConcept codeableConcept, FhirUri target, IEnumerable <TranslateConceptDependency> dependencies)
        {
            Parameters par = createTranslateConceptParams(code, system, version, valueSet, coding, codeableConcept, target, dependencies);
            var        loc = ResourceIdentity.Build("ConceptMap", id);

            return(expect <Parameters>(client.InstanceOperation(loc, Operation.TRANSLATE, par)));
        }
コード例 #6
0
        public static async Task <Parameters> TranslateConceptAsync(this FhirClient client, string id, Code code, FhirUri system, FhirString version,
                                                                    FhirUri valueSet, Coding coding, CodeableConcept codeableConcept, FhirUri target, IEnumerable <TranslateConceptDependency> dependencies)
        {
            Parameters par = createTranslateConceptParams(code, system, version, valueSet, coding, codeableConcept, target, dependencies);
            var        loc = ResourceIdentity.Build("ConceptMap", id);

            return(OperationResult <Parameters>(await client.InstanceOperationAsync(loc, RestOperation.TRANSLATE, par).ConfigureAwait(false)));
        }
コード例 #7
0
 public static Parameters TranslateConcept(this FhirClient client, string id, Code code, FhirUri system,
                                           FhirString version,
                                           FhirUri valueSet, Coding coding, CodeableConcept codeableConcept, FhirUri target,
                                           IEnumerable <TranslateConceptDependency> dependencies)
 {
     return(TranslateConceptAsync(client, id, code, system, version, valueSet, coding, codeableConcept, target,
                                  dependencies).WaitResult());
 }
コード例 #8
0
        public Hl7.Fhir.Model.Provenance WithProvenance(Provenance prov, Resource resource, string fullUrl)
        {
            // create the resource reference (with the full URL intact)
            ResourceReference resRef      = null;
            ResourceReference relativeRef = null;

            if (!string.IsNullOrEmpty(resource.Id))
            {
                resRef      = new ResourceReference(resource.ResourceIdentity(resource.ResourceBase).OriginalString);
                relativeRef = new ResourceReference(ResourceIdentity.Build(resource.TypeName, resource.Id, resource.Meta?.VersionId).OriginalString);

                // Append the display (like all good servers should)
                if (resource is Organization org)
                {
                    resRef.Display = org.Name;
                }
                if (resource is Location loc)
                {
                    resRef.Display = loc.Name;
                }
                if (resource is Endpoint ep)
                {
                    resRef.Display = ep.Name;
                }
                if (resource is HealthcareService hcs)
                {
                    resRef.Display = hcs.Name;
                }
                if (resource is Practitioner prac)
                {
                    resRef.Display = prac.Name.FirstOrDefault()?.Text;
                }
                if (resource is PractitionerRole pracRole)
                {
                    resRef.Display = pracRole.Practitioner.Display + " - " + string.Join(", ", pracRole.Code?.FirstOrDefault()?.Coding?.FirstOrDefault()?.Display);
                }
                relativeRef.Display = resRef.Display;
            }
            // include the resource in the provenance
            Element what = resRef;

            if (resRef != null)
            {
                prov.Target.Add(relativeRef);
            }
            else
            {
                what = new FhirUri(fullUrl);
            }
            prov.Entity.Add(new Provenance.EntityComponent()
            {
                Role = Provenance.ProvenanceEntityRole.Source,
                // this is the URL of the original source content
                What = what
            });
            return(prov);
        }
コード例 #9
0
 public static ValidateCodeResult ValidateCode(this IFhirClient client,
                                               FhirUri identifier    = null, FhirUri context                 = null, ValueSet valueSet  = null, Code code = null,
                                               FhirUri system        = null, FhirString version              = null, FhirString display = null,
                                               Coding coding         = null, CodeableConcept codeableConcept = null, FhirDateTime date  = null,
                                               FhirBoolean @abstract = null)
 {
     return(ValidateCodeAsync(client, identifier, context, valueSet, code, system, version, display,
                              coding, codeableConcept, date, @abstract).WaitResult());
 }
コード例 #10
0
        private List <Expression> ToExpressions(FhirUri element)
        {
            if (element == null || String.Empty.Equals(element.Value))
            {
                return(null);
            }

            return(ListOf(new StringValue(element.Value)));
        }
コード例 #11
0
        private static Parameters createTranslateConceptParams(Code code, FhirUri system, FhirString version, FhirUri valueSet, Coding coding, CodeableConcept codeableConcept,
                                                               FhirUri target, IEnumerable <TranslateConceptDependency> dependencies)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            var par = new Parameters().Add("target", target);

            if (code != null)
            {
                par.Add("code", code);
            }
            if (system != null)
            {
                par.Add("system", system);
            }
            if (version != null)
            {
                par.Add("version", version);
            }
            if (valueSet != null)
            {
                par.Add("valueSet", valueSet);
            }
            if (coding != null)
            {
                par.Add("coding", coding);
            }
            if (codeableConcept != null)
            {
                par.Add("codeableConcept", codeableConcept);
            }

            if (dependencies != null && dependencies.Any())
            {
                foreach (var dependency in dependencies)
                {
                    var dependencyPar = new List <Tuple <string, Base> >();

                    if (dependency.Element != null)
                    {
                        dependencyPar.Add(Tuple.Create("element", (Base)dependency.Element));
                    }
                    if (dependency.Concept != null)
                    {
                        dependencyPar.Add(Tuple.Create("concept", (Base)dependency.Concept));
                    }

                    par.Add("dependency", dependencyPar);
                }
            }

            return(par);
        }
コード例 #12
0
        public void Can_ConvertElement_R3_FhirUri_To_R4_FhirUri()
        {
            var value          = "https://helsenorge.no";
            var r3TypeInstance = new FhirUri(value);
            var r4TypeInstance = new FhirConverter(FhirVersion.R4, FhirVersion.R3)
                                 .Convert <FhirUri, FhirUri>(r3TypeInstance);

            Assert.NotNull(r4TypeInstance);
            Assert.Equal(value, r4TypeInstance.Value);
        }
コード例 #13
0
 public string Cast(FhirUri uri)
 {
     if (uri != null)
     {
         return(uri.ToString());
     }
     else
     {
         return(null);
     }
 }
コード例 #14
0
 private void SetUpResource()
 {
     eventCode            = null;
     receiverPractioner   = null;
     receiverOrganization = null;
     senderPractioner     = null;
     senderOrganization   = null;
     focus  = null;
     source = null;
     handlingSpecification = new ITKHandlingKeys();
 }
コード例 #15
0
        public void Test_FhirUri_Referance_IndexSetter_GoodFormat_NoMatchOnServiceRootUrl()
        {
            //Arrange
            string   ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient";
            string   ReferanceUrlString   = "http://SomeWhereElse.net.au/FhirApi/Encounter/10";
            IFhirUri ReferanceFhirUri     = Pyro.Common.CommonFactory.GetFhirUri(new Uri(ReferanceUrlString));

            var FhirUri = new FhirUri();

            FhirUri.Value = ReferanceUrlString;

            //Mok the inbound Request Url, this contains the service root url from the db.
            Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>();

            var      ServiceRootUrl = new Uri(ServiceRootUrlString);
            IFhirUri RequestFhirUri = Pyro.Common.CommonFactory.GetFhirUri(ServiceRootUrl);

            MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri);

            var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore();

            ServiceDtoRootUrlStore.Id = 1;
            ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true;
            ServiceDtoRootUrlStore.Url = ServiceRootUrlString;
            MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore);

            //Mok the response from the db from the Common repository, this if request Url does not match service root url
            Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>();

            var ReferanceRootUrlStore = new Pyro.DataModel.DatabaseModel.ServiceRootURL_Store();

            ReferanceRootUrlStore.ServiceRootURL_StoreID  = 0;
            ReferanceRootUrlStore.IsServersPrimaryUrlRoot = false;
            ReferanceRootUrlStore.RootUrl = ReferanceFhirUri.ServiceRootUrlForComparison;
            MockICommonRepository.Setup(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison)).Returns(ReferanceRootUrlStore);

            ReferenceIndex Index = new ReferenceIndex();

            //Act
            Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(FhirUri, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex;

            //Assert
            Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id);
            Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType);
            Assert.IsNotNull(Index.Url);
            Assert.AreEqual(Index.Url.ServiceRootURL_StoreID, 0);
            Assert.IsFalse(Index.Url.IsServersPrimaryUrlRoot);
            Assert.AreEqual(Index.Url.RootUrl, ReferanceFhirUri.ServiceRootUrlForComparison);
            Assert.IsNull(Index.VersionId);
            Assert.IsNull(Index.ServiceRootURL_StoreID);
            //Test GetAndOrAddPyro_RootUrlStore called once to add or get the Url from / to the db
            Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Once));
        }
コード例 #16
0
        public void Test_FhirUri_StringIndexSetter_FhirUri_IsNull()
        {
            //Arrange
            FhirUri FhirUri = null;

            UriIndex Index = new UriIndex();

            //Act
            ActualValueDelegate <UriIndex> testDelegate = () => IndexSetterFactory.Create(typeof(UriIndex)).Set(FhirUri, Index) as UriIndex;

            //Assert
            Assert.That(testDelegate, Throws.TypeOf <ArgumentNullException>());
        }
コード例 #17
0
        public void Test_FhirUri_UriIndexSetter_FhirUri_Value_IsNull()
        {
            //Arrange
            var FhirUri = new FhirUri();

            FhirUri.Value = null;
            UriIndex Index = new UriIndex();

            //Act
            Index = IndexSetterFactory.Create(typeof(UriIndex)).Set(FhirUri, Index) as UriIndex;

            //Assert
            Assert.IsNull(Index);
        }
コード例 #18
0
        /// <summary>
        /// Convert to assigning authority
        /// </summary>
        /// <param name="fhirSystem">The FHIR system.</param>
        /// <returns>AssigningAuthority.</returns>
        /// <exception cref="System.InvalidOperationException">Unable to locate service</exception>
        public static AssigningAuthority ToAssigningAuthority(FhirUri fhirSystem)
        {
            if (fhirSystem == null)
            {
                return(null);
            }

            traceSource.TraceEvent(EventLevel.Verbose, "Mapping assigning authority");

            var oidRegistrar = ApplicationServiceContext.Current.GetService <IAssigningAuthorityRepositoryService>();
            var oid          = oidRegistrar.Get(fhirSystem.Value);

            return(oid);
        }
コード例 #19
0
        public SubsumesParameters WithCoding(Coding codingA, Coding codingB, string system = null, string version = null)
        {
            CodingA = codingA;
            CodingB = codingB;
            if (!string.IsNullOrWhiteSpace(system))
            {
                System = new FhirUri(system);
            }
            if (!string.IsNullOrWhiteSpace(version))
            {
                Version = new FhirString(version);
            }

            return(this);
        }
コード例 #20
0
        /// <summary>
        /// Convert to assigning authority
        /// </summary>
        /// <param name="fhirSystem">The FHIR system.</param>
        /// <returns>AssigningAuthority.</returns>
        /// <exception cref="System.InvalidOperationException">Unable to locate service</exception>
        public static AssigningAuthority ToAssigningAuthority(FhirUri fhirSystem)
        {
            if (fhirSystem == null)
            {
                return(null);
            }
            IOidRegistrarService d;

            traceSource.TraceEvent(TraceEventType.Verbose, 0, "Mapping assigning authority");

            var oidRegistrar = ApplicationContext.Current.GetService <IOidRegistrarService>();
            var oid          = oidRegistrar.FindData(fhirSystem.Value);

            return(new AssigningAuthority(oid.Mnemonic, oid.Name, oid.Oid));
        }
コード例 #21
0
        /// <summary>
        /// Parse uri
        /// </summary>
        public static Hl7.Fhir.Model.FhirUri ParseFhirUri(IFhirReader reader, ErrorList errors, Hl7.Fhir.Model.FhirUri existingInstance = null)
        {
            Hl7.Fhir.Model.FhirUri result = existingInstance != null ? existingInstance : new Hl7.Fhir.Model.FhirUri();
            string currentElementName     = reader.CurrentElementName;

            reader.EnterElement();

            while (reader.HasMoreElements())
            {
                var atName = reader.CurrentElementName;
                // Parse element extension
                if (atName == "extension")
                {
                    result.Extension = new List <Hl7.Fhir.Model.Extension>();
                    reader.EnterArray();

                    while (ParserUtils.IsAtArrayElement(reader, "extension"))
                    {
                        result.Extension.Add(ExtensionParser.ParseExtension(reader, errors));
                    }

                    reader.LeaveArray();
                }

                // Parse element _id
                else if (atName == "_id")
                {
                    result.LocalIdElement = Id.Parse(reader.ReadPrimitiveContents(typeof(Id)));
                }

                // Parse element value
                else if (atName == "value")
                {
                    result.Value = FhirUri.Parse(reader.ReadPrimitiveContents(typeof(FhirUri))).Value;
                }

                else
                {
                    errors.Add(String.Format("Encountered unknown element {0} while parsing {1}", reader.CurrentElementName, currentElementName), reader);
                    reader.SkipSubElementsFor(currentElementName);
                    result = null;
                }
            }

            reader.LeaveElement();
            return(result);
        }
コード例 #22
0
        public void Test_FhirUri_UriIndexSetter_GoodFormat()
        {
            //Arrange
            Uri TheUri = new Uri("http://acme.org/fhir/ValueSet/123");

            var FhirUri = new FhirUri();

            FhirUri.Value = TheUri.OriginalString;

            UriIndex Index = new UriIndex();

            //Act
            Index = IndexSetterFactory.Create(typeof(UriIndex)).Set(FhirUri, Index) as UriIndex;

            //Assert
            Assert.AreEqual(Index.Uri, TheUri.OriginalString);
        }
コード例 #23
0
        public void Test_FhirUri_Referance_IndexSetter_Uri_Is_RelativeUri()
        {
            //Info: This is a Uri that is not a Fhir resource reference, it is actually a GUID expressed as a Uri.
            //In this case as it is not a FhirUriReferance we want to return null as it is not searchable as a
            //Search parameter type of Reference.
            //Arrange
            string   ServiceRootUrlString = "http://SomeWhere.net.au/FhirApi/Patient";
            string   ReferanceUrlString   = "Encounter/10";
            IFhirUri ReferanceFhirUri     = Common.CommonFactory.GetFhirUri(ReferanceUrlString);
            //IFhirUri ReferanceFhirUri = new Pyro.Common.BusinessEntities.UriSupport.DtoFhirUri(ReferanceUrlString);

            FhirUri FhirUri = new FhirUri();

            FhirUri.Value = ReferanceUrlString;

            //Mok the inbound Request Url, this contains the service root url from the db.
            Mock <IDtoFhirRequestUri> MockIDtoFhirRequestUri = new Mock <IDtoFhirRequestUri>();

            var      ServiceRootUrl = new Uri(ServiceRootUrlString);
            IFhirUri RequestFhirUri = Pyro.Common.CommonFactory.GetFhirUri(ServiceRootUrl);

            MockIDtoFhirRequestUri.Setup(x => x.FhirUri).Returns(RequestFhirUri);

            var ServiceDtoRootUrlStore = new Pyro.Common.BusinessEntities.Dto.DtoRootUrlStore();

            ServiceDtoRootUrlStore.Id = 1;
            ServiceDtoRootUrlStore.IsServersPrimaryUrlRoot = true;
            ServiceDtoRootUrlStore.Url = ServiceRootUrlString;
            MockIDtoFhirRequestUri.Setup(x => x.PrimaryRootUrlStore).Returns(ServiceDtoRootUrlStore);

            //Mok the response from the db from the Common repository, this if request Url does not match service root url
            Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository> MockICommonRepository = new Mock <Pyro.DataModel.Repository.Interfaces.ICommonRepository>();

            ReferenceIndex Index = new ReferenceIndex();

            //Act
            Index = IndexSetterFactory.Create(typeof(ReferenceIndex)).Set(FhirUri, Index, MockIDtoFhirRequestUri.Object, MockICommonRepository.Object) as ReferenceIndex;

            //Assert
            Assert.AreEqual(Index.FhirId, ReferanceFhirUri.Id);
            Assert.AreEqual(Index.Type, ReferanceFhirUri.ResourseType);
            Assert.IsNull(Index.Url);
            Assert.IsNull(Index.VersionId);
            Assert.AreEqual(Index.ServiceRootURL_StoreID, 1);
            Assert.DoesNotThrow(() => MockICommonRepository.Verify(x => x.GetAndOrAddService_RootUrlStore(ReferanceFhirUri.ServiceRootUrlForComparison), Times.Never));
        }
コード例 #24
0
        /// <summary>
        /// Get structure definition
        /// </summary>
        public static StructureDefinition GetStructureDefinition(this Type me, bool isProfile = false)
        {
            // Base structure definition
            Assembly entryAssembly     = Assembly.GetEntryAssembly();
            FhirUri  baseStructureDefn = null;

            if (isProfile)
            {
                baseStructureDefn = new Uri(Reference.CreateResourceReference <StructureDefinition>(me.GetStructureDefinition(false), RestOperationContext.Current.IncomingRequest.Url).ReferenceUrl, UriKind.Relative);
            }
            else if (typeof(ResourceBase).IsAssignableFrom(me.BaseType))
            {
                baseStructureDefn = new Uri($"http://hl7.org/fhir/StructureDefinition/{me.BaseType.GetCustomAttribute<XmlTypeAttribute>().TypeName}", UriKind.Absolute);
            }

            // Create the structure definition
            var retVal = new StructureDefinition()
            {
                Abstract = me.IsAbstract,
                Base     = baseStructureDefn,
                Contact  = new List <Backbone.ContactDetail>()
                {
                    new Backbone.ContactDetail()
                    {
                        Name = me.Assembly.GetCustomAttribute <AssemblyCompanyAttribute>().Company
                    }
                },
                Name           = me.GetCustomAttribute <DescriptionAttribute>()?.Description ?? me.Name,
                Description    = me.GetCustomAttribute <DescriptionAttribute>()?.Description ?? me.Name,
                FhirVersion    = "4.0.0",
                Date           = DateTime.Now,
                Kind           = StructureDefinitionKind.Resource,
                Type           = me.GetCustomAttribute <XmlTypeAttribute>()?.TypeName ?? me.Name,
                DerivationType = isProfile ? TypeDerivationRule.Constraint : TypeDerivationRule.Specialization,
                Id             = me.GetCustomAttribute <XmlTypeAttribute>()?.TypeName ?? me.Name,
                Version        = entryAssembly.GetName().Version.ToString(),
                VersionId      = me.Assembly.GetName().Version.ToString(),
                Copyright      = me.Assembly.GetCustomAttribute <AssemblyCopyrightAttribute>()?.Copyright,
                Experimental   = true,
                Publisher      = me.Assembly.GetCustomAttribute <AssemblyCompanyAttribute>()?.Company,
                Status         = PublicationStatus.Active
            };

            // Structure definitions
            return(retVal);
        }
        public async Task DocumentOperationPOSTReturn200OnSuccess()
        {
            // Setup Composition resource
            var composition   = CreateTestCompositionNoReferences();
            var compositionId = "test";
            var searchResult  = new SearchResult(new List <IResource>()
            {
                composition
            }, 1, 1);

            _searchMock.Setup(repo => repo.Search(
                                  It.Is <IArgumentCollection>(args => args.GetArgument(ArgumentNames.resourceId).ArgumentValue == compositionId),
                                  It.IsAny <SearchOptions>())).ReturnsAsync(searchResult);

            // Create VonkContext for $document (POST / Type level)
            var testContext = new VonkTestContext(VonkInteraction.instance_custom);

            testContext.Arguments.AddArguments(new[]
            {
                new Argument(ArgumentSource.Path, ArgumentNames.resourceType, "Composition")
            });
            testContext.TestRequest.CustomOperation = "document";
            testContext.TestRequest.Method          = "POST";

            var parameters         = new Parameters();
            var idValue            = new FhirUri(compositionId);
            var parameterComponent = new Parameters.ParameterComponent {
                Name = "id"
            };

            parameterComponent.Value = idValue;
            parameters.Parameter.Add(parameterComponent);

            testContext.TestRequest.Payload = new RequestPayload(true, parameters.ToIResource());

            // Execute $document
            await _documentService.DocumentTypePOST(testContext);

            // Check response status
            testContext.Response.HttpResult.Should().Be(StatusCodes.Status200OK, "$document should succeed with HTTP 200 - OK on test composition");
            testContext.Response.Payload.Should().NotBeNull();
            var bundleType = testContext.Response.Payload.SelectText("type");

            bundleType.Should().Be("document", "Bundle.type should be set to 'document'");
        }
コード例 #26
0
ファイル: ModelTests.cs プロジェクト: evrimulgen/fhir-net-api
        public void TestStringValueInterface()
        {
            IStringValue sv = new FhirString("test");

            Assert.IsNotNull(sv);
            sv.Value = "string";
            Assert.AreEqual(sv.Value, "string");

            sv = new FhirUri("test");
            Assert.IsNotNull(sv);
            sv.Value = "http://example.org";
            Assert.AreEqual(sv.Value, "http://example.org");

            sv = new Uuid("test");
            Assert.IsNotNull(sv);
            sv.Value = "550e8400-e29b-41d4-a716-446655440000";
            Assert.AreEqual(sv.Value, "550e8400-e29b-41d4-a716-446655440000");

            sv = new Oid("test");
            Assert.IsNotNull(sv);
            sv.Value = "2.16.840.1.113883";
            Assert.AreEqual(sv.Value, "2.16.840.1.113883");

            sv = new Markdown("test");
            Assert.IsNotNull(sv);
            sv.Value = "Hello World!";
            Assert.AreEqual(sv.Value, "Hello World!");

            sv = new Date();
            Assert.IsNotNull(sv);
            sv.Value = "20161201";
            Assert.AreEqual(sv.Value, "20161201");

            sv = new Time();
            Assert.IsNotNull(sv);
            sv.Value = "23:59:00";
            Assert.AreEqual(sv.Value, "23:59:00");

            sv = new FhirDateTime(DateTime.Now);
            Assert.IsNotNull(sv);
            sv.Value = "20161201 23:59:00";
            Assert.AreEqual(sv.Value, "20161201 23:59:00");
        }
コード例 #27
0
 public LookupParameters WithCode(string code = null, string system = null, string version = null, string displayLanguage = null)
 {
     if (!string.IsNullOrWhiteSpace(code))
     {
         Code = new Code(code);
     }
     if (!string.IsNullOrWhiteSpace(system))
     {
         System = new FhirUri(system);
     }
     if (!string.IsNullOrWhiteSpace(version))
     {
         Version = new FhirString(version);
     }
     if (!string.IsNullOrWhiteSpace(displayLanguage))
     {
         DisplayLanguage = new Code(displayLanguage);
     }
     return(this);
 }
コード例 #28
0
        public static Parameters Validate(this FhirClient client, String valueSetId, FhirUri system, Code code, FhirString display = null)
        {
            if (code == null)
            {
                throw new ArgumentNullException("code");
            }
            if (system == null)
            {
                throw new ArgumentNullException("system");
            }

            var par = new Parameters().Add("code", code).Add("system", system);

            if (display != null)
            {
                par.Add("display", display);
            }

            return(validateCodeForValueSetId(client, valueSetId, par));
        }
コード例 #29
0
        public OperationOutcome ValidateContent(List <DocumentReference.ContentComponent> contents)
        {
            if (contents == null || contents.Count == 0)
            {
                return(OperationOutcomeFactory.CreateInvalidResource("content"));
            }

            foreach (var content in contents)
            {
                //attachment
                if (content.Attachment == null)
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("attachment"));
                }

                //attachment.contentType
                //TODO validate content type format
                var contentType = content.Attachment.ContentType;
                if (string.IsNullOrEmpty(contentType))
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("contenttype"));
                }

                //attachment.url
                var url = content.Attachment.Url;
                if (string.IsNullOrEmpty(url) || !FhirUri.IsValidValue(url))
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("url"));
                }

                //attachment.creation can be empty
                var      creation = content.Attachment.Creation;
                DateTime validCreation;
                if (!string.IsNullOrEmpty(creation) && (!FhirDateTime.IsValidValue(creation) || !DateTime.TryParse(creation, out validCreation)))
                {
                    return(OperationOutcomeFactory.CreateInvalidResource("creation", $"The attachment creation date value is not a valid dateTime type: {creation}."));
                }
            }

            return(null);
        }
コード例 #30
0
        public SubsumesParameters WithCode(string codeA, string codeB, string system = null, string version = null)
        {
            if (!string.IsNullOrWhiteSpace(codeA))
            {
                CodeA = new Code(codeA);
            }
            if (!string.IsNullOrWhiteSpace(codeB))
            {
                CodeB = new Code(codeB);
            }
            if (!string.IsNullOrWhiteSpace(system))
            {
                System = new FhirUri(system);
            }
            if (!string.IsNullOrWhiteSpace(version))
            {
                Version = new FhirString(version);
            }

            return(this);
        }