Beispiel #1
0
        public async Task DOITest()
        {
            string bib = await IdentifierUtility.SearchBibliographyEntry("10.5555/12345678");

            Assert.IsNotNull(bib);
            Assert.IsTrue(bib.Contains("Toward a Unified Theory of High-Energy Metaphysics: Silly String Theory"));
        }
Beispiel #2
0
        public async Task ISBNDirectTest()
        {
            string bib = await IdentifierUtility.SearchIsbn("9781780648903");

            Assert.IsNotNull(bib);
            Assert.IsTrue(bib.Contains("Climate change and cotton production in modern farming systems"));
        }
Beispiel #3
0
        public override bool MatchIdentifier(QsiIdentifier x, QsiIdentifier y)
        {
            string nX = x.IsEscaped ? IdentifierUtility.Unescape(x.Value) : x.Value;
            string nY = y.IsEscaped ? IdentifierUtility.Unescape(y.Value) : y.Value;

            return(string.Equals(nX, nY, StringComparison.OrdinalIgnoreCase));
        }
        public async Task <IEnumerable <FhirTransactionRequestEntry> > BuildAsync(FhirTransactionContext context, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNull(context.ChangeFeedEntry, nameof(context.ChangeFeedEntry));

            Identifier         identifier           = IdentifierUtility.CreateIdentifier(context.ChangeFeedEntry.StudyInstanceUid);
            List <Observation> matchingObservations = (await _fhirService.RetrieveObservationsAsync(identifier, cancellationToken)).ToList();

            // terminate early if no observation found
            if (matchingObservations.Count == 0)
            {
                return(null);
            }

            var requests = new List <FhirTransactionRequestEntry>();

            foreach (Observation observation in matchingObservations)
            {
                Bundle.RequestComponent request = new Bundle.RequestComponent()
                {
                    Method = Bundle.HTTPVerb.DELETE,
                    Url    = $"{ResourceType.Observation.GetLiteral()}/{observation.Id}"
                };

                requests.Add(new FhirTransactionRequestEntry(
                                 FhirTransactionRequestMode.Delete,
                                 request,
                                 observation.ToServerResourceId(),
                                 observation));
            }

            return(requests);
        }
Beispiel #5
0
        /// <summary>
        ///		Resets internal states for new type.
        /// </summary>
        /// <param name="targetType">Type of the target.</param>
        protected override void ResetCore(Type targetType)
        {
            var declaringType = new CodeTypeDeclaration(IdentifierUtility.EscapeTypeName(targetType) + "Serializer");

            declaringType.BaseTypes.Add(
                targetType.GetIsEnum()
                                ? typeof(EnumMessagePackSerializer <>).MakeGenericType(targetType)
                                : typeof(MessagePackSerializer <>).MakeGenericType(targetType));
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(
                    new CodeTypeReference(typeof(GeneratedCodeAttribute)),
                    new CodeAttributeArgument(new CodePrimitiveExpression("MsgPack.Serialization.CodeDomSerializers.CodeDomSerializerBuilder")),
                    new CodeAttributeArgument(new CodePrimitiveExpression(this.GetType().Assembly.GetName().Version.ToString()))
                    )
                );
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerNonUserCodeAttribute)))
                );

            this._declaringTypes.Add(targetType, declaringType);
            this._dependentSerializers.Clear();
            this._cachedFieldInfos.Clear();
            this._cachedMethodBases.Clear();
            this._buildingType = declaringType;

            this.Packer         = CodeDomConstruct.Parameter(typeof(Packer), "packer");
            this.PackToTarget   = CodeDomConstruct.Parameter(targetType, "objectTree");
            this.Unpacker       = CodeDomConstruct.Parameter(typeof(Unpacker), "unpacker");
            this.UnpackToTarget = CodeDomConstruct.Parameter(targetType, "collection");
        }
Beispiel #6
0
        public static IColumn VisitSelectElement(SelectElementContext context)
        {
            switch (context)
            {
            case SelectColumnElementContext selectColumnElementContext:
                return(new PropertyColumn
                {
                    Name = IdentifierUtility.Parse(selectColumnElementContext.fullColumnName().GetText()),
                    Alias = IdentifierUtility.Unescape(selectColumnElementContext.alias?.GetText()),
                });

            case SelectFunctionElementContext selectFunctionElementContext:
            {
                if (selectFunctionElementContext.builtInFunctionCall() is CountFunctionCallContext)
                {
                    return new CountFunctionColumn
                           {
                               Alias = IdentifierUtility.Unescape(selectFunctionElementContext.alias?.GetText()),
                           }
                }
                ;

                return(VisitorHelper.ThrowNotSupportedFeature <IColumn>("Select Element Function"));
            }

            case SelectExpressionElementContext _:
                return(VisitorHelper.ThrowNotSupportedFeature <IColumn>("Select Element Expression"));
            }

            return(VisitorHelper.ThrowNotSupportedContext <IColumn>(context));
        }
Beispiel #7
0
        private Identifier getSenderID(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string senderID = DocumentXPathResolver.GetElementValueByXPathNavigator(
                message.MessageXml,
                docTypeConfig.EndpointType.SenderKey.XPath,
                docTypeConfig.Namespaces);
            var        senderKeyType = Utilities.GetSenderKeyTypeCode(message.MessageXml, docTypeConfig);
            Identifier id            = IdentifierUtility.GetIdentifierFromKeyType(senderID, senderKeyType);

            if (!id.IsAllowedInPublic)
            {
                string cvrNumberString;
                string endpointType;
                if (Credentials.ClientCertificate.TryGetCvrNumberString(out endpointType, out cvrNumberString))
                {
                    id = new Identifier(endpointType, cvrNumberString);
                }
                else
                {
                    throw new Exception("Sender ID is not allowed to be added to header. It was not possible to retrieve ID from certificate");
                }
            }

            return(id);
        }
Beispiel #8
0
        /// <summary>
        ///		Resets internal states for new type.
        /// </summary>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="baseClass">Type of base class of the target.</param>
        protected override void ResetCore(Type targetType, Type baseClass)
        {
            var declaringType = new CodeTypeDeclaration(IdentifierUtility.EscapeTypeName(targetType) + "Serializer");

            declaringType.BaseTypes.Add(baseClass);
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(
                    new CodeTypeReference(typeof(GeneratedCodeAttribute)),
                    new CodeAttributeArgument(new CodePrimitiveExpression("MsgPack.Serialization.CodeDomSerializers.CodeDomSerializerBuilder")),
                    new CodeAttributeArgument(new CodePrimitiveExpression(this.GetType().Assembly.GetName().Version.ToString()))
                    )
                );
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerNonUserCodeAttribute)))
                );

            this._declaringTypes.Add(targetType, declaringType);
            this._dependentSerializers.Clear();
            this._cachedFieldInfos.Clear();
            this._cachedMethodBases.Clear();
            this._buildingType = declaringType;

            this.Packer         = CodeDomConstruct.Parameter(typeof(Packer), "packer");
            this.PackToTarget   = CodeDomConstruct.Parameter(targetType, "objectTree");
            this.Unpacker       = CodeDomConstruct.Parameter(typeof(Unpacker), "unpacker");
            this.UnpackToTarget = CodeDomConstruct.Parameter(targetType, "collection");
            var traits = targetType.GetCollectionTraits();

            if (traits.ElementType != null)
            {
                this.CollectionToBeAdded = CodeDomConstruct.Parameter(targetType, "collection");
                this.ItemToAdd           = CodeDomConstruct.Parameter(traits.ElementType, "item");
                this.InitialCapacity     = CodeDomConstruct.Parameter(typeof(int), "initialCapacity");
            }
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FieldBasedSerializerEmitter"/> class.
        /// </summary>
        /// <param name="host">The host <see cref="ModuleBuilder"/>.</param>
        /// <param name="sequence">The sequence number to name new type.</param>
        /// <param name="targetType">Type of the serialization target.</param>
        /// <param name="isDebuggable">Set to <c>true</c> when <paramref name="host"/> is debuggable.</param>
        public FieldBasedSerializerEmitter(ModuleBuilder host, int?sequence, Type targetType, bool isDebuggable)
            : base()
        {
            Contract.Requires(host != null);
            Contract.Requires(targetType != null);

            string typeName =
#if !NETFX_35
                String.Join(
                    Type.Delimiter.ToString(),
                    typeof(SerializerEmitter).Namespace,
                    "Generated",
                    IdentifierUtility.EscapeTypeName(targetType) + "Serializer" + sequence
                    );
#else
                String.Join(
                    Type.Delimiter.ToString(),
                    new string[]
            {
                typeof(SerializerEmitter).Namespace,
                "Generated",
                IdentifierUtility.EscapeTypeName(targetType) + "Serializer" + sequence
            }
                    );
#endif
            Tracer.Emit.TraceEvent(Tracer.EventType.DefineType, Tracer.EventId.DefineType, "Create {0}", typeName);
            this._typeBuilder =
                host.DefineType(
                    typeName,
                    TypeAttributes.Sealed | TypeAttributes.Public | TypeAttributes.UnicodeClass | TypeAttributes.AutoLayout | TypeAttributes.BeforeFieldInit,
                    typeof(MessagePackSerializer <>).MakeGenericType(targetType)
                    );

            this._defaultConstructorBuilder = this._typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
            this._contextConstructorBuilder = this._typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, _constructorParameterTypes);

            this._packMethodBuilder =
                this._typeBuilder.DefineMethod(
                    "PackToCore",
                    MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig,
                    CallingConventions.HasThis,
                    typeof(void),
                    new Type[] { typeof(Packer), targetType }
                    );

            this._unpackFromMethodBuilder =
                this._typeBuilder.DefineMethod(
                    "UnpackFromCore",
                    MethodAttributes.Family | MethodAttributes.Virtual | MethodAttributes.Final | MethodAttributes.HideBySig,
                    CallingConventions.HasThis,
                    targetType,
                    UnpackFromCoreParameterTypes
                    );

            this._typeBuilder.DefineMethodOverride(this._packMethodBuilder, this._typeBuilder.BaseType.GetMethod(this._packMethodBuilder.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
            this._typeBuilder.DefineMethodOverride(this._unpackFromMethodBuilder, this._typeBuilder.BaseType.GetMethod(this._unpackFromMethodBuilder.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
            this._serializers  = new Dictionary <RuntimeTypeHandle, FieldBuilder>();
            this._isDebuggable = isDebuggable;
        }
        public void GivenStudyInstanceUid_WhenCreated_ThenCorrectIdentifierShouldBeCreated()
        {
            var identifier = IdentifierUtility.CreateIdentifier("123");

            Assert.NotNull(identifier);
            Assert.Equal("urn:dicom:uid", identifier.System);
            Assert.Equal("urn:oid:123", identifier.Value);
        }
 protected void AddColumns(QsiTableStructure table, params string[] names)
 {
     foreach (var name in names)
     {
         var c = table.NewColumn();
         c.Name = new QsiIdentifier(name, IdentifierUtility.IsEscaped(name));
     }
 }
Beispiel #12
0
        public override async Task <DbDataReader> ExecuteAsync(CancellationToken cancellationToken = default)
        {
            _deletedCount = 0;
            var selectQueryInfo = new SelectQueryInfo
            {
                WhereExpression = QueryInfo.WhereExpression,
                Limit           = QueryInfo.Limit,
                TableSource     = new AtomTableSource(QueryInfo.TableName, string.Empty),
                Columns         = await GetColumnsAsync(cancellationToken),
            };

            // TODO: Performance issue, need to performance enhancement.
            if (QueryInfo.WhereExpression == null)
            {
                throw new InvalidOperationException("Update not support without where expression.");
            }

            var planner = new SelectPlanner
            {
                QueryInfo = selectQueryInfo,
                Context   = Context
            };

            var reader = await planner.ExecuteAsync(cancellationToken);

            bool hasSortKey = selectQueryInfo.Columns.Length == 2;

            while (await reader.ReadAsync(cancellationToken))
            {
                var request = new DeleteItemRequest
                {
                    TableName = QueryInfo.TableName,
                    ExpressionAttributeNames  = ExpressionAttributeNames,
                    ExpressionAttributeValues = ExpressionAttributeValues
                };

                request.Key.Add(IdentifierUtility.Unescape(reader.GetName(0)), reader[0].ToAttributeValue());

                if (hasSortKey)
                {
                    request.Key.Add(IdentifierUtility.Unescape(reader.GetName(1)), reader[1].ToAttributeValue());
                }

                try
                {
                    await Context.Client.DeleteItemAsync(request, cancellationToken);
                }
                catch (AggregateException e)
                {
                    var innerException = e.InnerExceptions[0];
                    throw new Exception($"Error while delete Item (Key: {reader.GetName(0)}){Environment.NewLine}{innerException.Message}");
                }

                _deletedCount++;
            }

            return(new PrimarSqlDataReader(new EmptyDataProvider(_deletedCount)));
        }
Beispiel #13
0
        static LookupParameters GetUddiParameters(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            // Use an OIOSI utility to find the endpoint type in the XML document to be sent
            string endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(message, docTypeConfig);

            // Use the XPath expression from the UBL type configuration (found in the RaspConfiguration.xml file)
            // to find the endpoint identifier in the XML document to be sent
            Identifier endpointKey = Utilities.GetEndpointKeyByXpath(
                message.MessageXml,
                docTypeConfig.EndpointType.Key.XPath,
                docTypeConfig.Namespaces,
                endpointKeyTypeCode
                );

            // create the profile tModel
            UddiId profileTModelId = GetProfileTModelId(message, docTypeConfig);

            // Find the UDDI identifier for the service contract used by the remote endpoint
            UddiId serviceContractTModel;

            try {
                serviceContractTModel = IdentifierUtility.GetUddiIDFromString(docTypeConfig.ServiceContractTModel);
            }
            catch (Exception) {
                throw new Exception("Could not find the service contract TModel for the UDDI lookup");
            }

            LookupParameters uddiLookupParameters;

            if (profileTModelId != null)
            {
                // lookup including profile
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <UddiId> {
                    profileTModelId
                },
                    new List <EndpointAddressTypeCode> {
                    EndpointAddressTypeCode.http
                });
            }
            else
            {
                // lookup without profile
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }

            return(uddiLookupParameters);
        }
Beispiel #14
0
        public EndpointAddress GetEndpointAddress()
        {
            accessPoint accessPointItem = template.Item as accessPoint;

            if (accessPointItem == null)
            {
                throw new Exception("accessPoint type expected");
            }
            return(IdentifierUtility.GetEndpointAddressFromString(accessPointItem.Value));
        }
Beispiel #15
0
        public static ITableSource VisitTableSourceBase(TableSourceItemContext context)
        {
            IPart[] identifiers = IdentifierUtility.Parse(context.tableName().GetText());
            ValidateTableWithIndexName(identifiers);

            return(new AtomTableSource(
                       identifiers[0].ToString(),
                       identifiers.Length == 2 ? identifiers[1].ToString() : string.Empty
                       ));
        }
Beispiel #16
0
        /// <summary>
        ///		Resets internal states for new type.
        /// </summary>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="baseClass">Type of base class of the target.</param>
        protected override void ResetCore(Type targetType, Type baseClass)
        {
            var declaringType = new CodeTypeDeclaration(IdentifierUtility.EscapeTypeName(targetType) + "Serializer");

            declaringType.BaseTypes.Add(baseClass);
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(
                    new CodeTypeReference(typeof(GeneratedCodeAttribute)),
                    new CodeAttributeArgument(new CodePrimitiveExpression("MsgPack.Serialization.CodeDomSerializers.CodeDomSerializerBuilder")),
                    new CodeAttributeArgument(new CodePrimitiveExpression(this.GetType().Assembly.GetName().Version.ToString()))
                    )
                );
            declaringType.CustomAttributes.Add(
                new CodeAttributeDeclaration(new CodeTypeReference(typeof(DebuggerNonUserCodeAttribute)))
                );

            this._targetType = targetType;
            this._declaringTypes.Add(targetType, declaringType);
            this._dependentSerializers.Clear();
            this._cachedTargetFields.Clear();
            this._cachedPropertyAccessors.Clear();
            this._buildingType = declaringType;

            var targetTypeDefinition = TypeDefinition.Object(targetType);

            this.Packer          = CodeDomConstruct.Parameter(TypeDefinition.PackerType, "packer");
            this.PackToTarget    = CodeDomConstruct.Parameter(targetTypeDefinition, "objectTree");
            this.NullCheckTarget = CodeDomConstruct.Parameter(targetTypeDefinition, "objectTree");
            this.Unpacker        = CodeDomConstruct.Parameter(TypeDefinition.UnpackerType, "unpacker");
            this.IndexOfItem     = CodeDomConstruct.Parameter(TypeDefinition.Int32Type, "indexOfItem");
            this.ItemsCount      = CodeDomConstruct.Parameter(TypeDefinition.Int32Type, "itemsCount");
            this.UnpackToTarget  = CodeDomConstruct.Parameter(targetTypeDefinition, "collection");
            var traits = targetType.GetCollectionTraits(CollectionTraitOptions.Full, this.SerializationContext.CompatibilityOptions.AllowNonCollectionEnumerableTypes);

            if (traits.ElementType != null)
            {
                this.CollectionToBeAdded = CodeDomConstruct.Parameter(targetTypeDefinition, "collection");
                this.ItemToAdd           = CodeDomConstruct.Parameter(traits.ElementType, "item");
                if (traits.DetailedCollectionType == CollectionDetailedKind.GenericDictionary
#if !NET35 && !NET40
                    || traits.DetailedCollectionType == CollectionDetailedKind.GenericReadOnlyDictionary
#endif // !NET35 && !NET40
                    )
                {
                    this.KeyToAdd   = CodeDomConstruct.Parameter(traits.ElementType.GetGenericArguments()[0], "key");
                    this.ValueToAdd = CodeDomConstruct.Parameter(traits.ElementType.GetGenericArguments()[1], "value");
                }
                else
                {
                    this.KeyToAdd   = null;
                    this.ValueToAdd = null;
                }
                this.InitialCapacity = CodeDomConstruct.Parameter(TypeDefinition.Int32Type, "initialCapacity");
            }
        }
Beispiel #17
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FieldBasedSerializerEmitter"/> class.
        /// </summary>
        /// <param name="host">The host <see cref="ModuleBuilder"/>.</param>
        /// <param name="sequence">The sequence number to name new type.</param>
        /// <param name="targetType">Type of the serialization target.</param>
        /// <param name="baseClass">Type of the base class of the serializer.</param>
        /// <param name="isDebuggable">Set to <c>true</c> when <paramref name="host"/> is debuggable.</param>
        public FieldBasedSerializerEmitter(ModuleBuilder host, int?sequence, Type targetType, Type baseClass, bool isDebuggable)
        {
            Contract.Requires(host != null);
            Contract.Requires(targetType != null);
            Contract.Requires(baseClass != null);

            string typeName =
#if !NETFX_35
                String.Join(
                    Type.Delimiter.ToString(CultureInfo.InvariantCulture),
                    typeof(SerializerEmitter).Namespace,
                    "Generated",
                    IdentifierUtility.EscapeTypeName(targetType) + "Serializer" + sequence
                    );
#else
                String.Join(
                    Type.Delimiter.ToString(),
                    new string[]
            {
                typeof(SerializerEmitter).Namespace,
                "Generated",
                IdentifierUtility.EscapeTypeName(targetType) + "Serializer" + sequence
            }
                    );
#endif
            Tracer.Emit.TraceEvent(Tracer.EventType.DefineType, Tracer.EventId.DefineType, "Create {0}", typeName);
            this._typeBuilder =
                host.DefineType(
                    typeName,
                    TypeAttributes.Sealed | TypeAttributes.Public | TypeAttributes.UnicodeClass | TypeAttributes.AutoLayout | TypeAttributes.BeforeFieldInit,
                    baseClass
                    );

            this._defaultConstructorBuilder = this._typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, Type.EmptyTypes);
            this._contextConstructorBuilder = this._typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ConstructorParameterTypes);

            this._targetType = targetType;
            this._traits     = targetType.GetCollectionTraits();
            var baseType = this._typeBuilder.BaseType;
#if DEBUG
            Contract.Assert(baseType != null, "baseType != null");
#endif
            this._serializers  = new Dictionary <SerializerFieldKey, SerializerFieldInfo>();
            this._fieldInfos   = new Dictionary <RuntimeFieldHandle, FieldBuilder>();
            this._methodBases  = new Dictionary <RuntimeMethodHandle, FieldBuilder>();
            this._isDebuggable = isDebuggable;

#if !SILVERLIGHT && !NETFX_35
            if (isDebuggable && SerializerDebugging.DumpEnabled)
            {
                SerializerDebugging.PrepareDump(host.Assembly as AssemblyBuilder);
            }
#endif
        }
        /// <inheritdoc/>
        public async Task <FhirTransactionRequestEntry> BuildAsync(FhirTransactionContext context, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(context, nameof(context));
            EnsureArg.IsNotNull(context.ChangeFeedEntry, nameof(context.ChangeFeedEntry));

            ChangeFeedEntry changeFeedEntry = context.ChangeFeedEntry;

            Identifier   imagingStudyIdentifier = IdentifierUtility.CreateIdentifier(changeFeedEntry.StudyInstanceUid);
            ImagingStudy imagingStudy           = await _fhirService.RetrieveImagingStudyAsync(imagingStudyIdentifier, cancellationToken);

            // Returns null if imagingStudy does not exists for given studyInstanceUid
            if (imagingStudy == null)
            {
                return(null);
            }

            string imagingStudySource = imagingStudy.Meta.Source;

            ImagingStudy.SeriesComponent   series   = ImagingStudyPipelineHelper.GetSeriesWithinAStudy(changeFeedEntry.SeriesInstanceUid, imagingStudy.Series);
            ImagingStudy.InstanceComponent instance = ImagingStudyPipelineHelper.GetInstanceWithinASeries(changeFeedEntry.SopInstanceUid, series);

            // Return null if the given instance is not present in ImagingStudy
            if (instance == null)
            {
                return(null);
            }

            // Removes instance from series collection
            series.Instance.Remove(instance);

            // Removes series from ImagingStudy if its instance collection is empty
            if (series.Instance.Count == 0)
            {
                imagingStudy.Series.Remove(series);
            }

            if (imagingStudy.Series.Count == 0 && _dicomWebEndpoint.Equals(imagingStudySource, System.StringComparison.Ordinal))
            {
                return(new FhirTransactionRequestEntry(
                           FhirTransactionRequestMode.Delete,
                           ImagingStudyPipelineHelper.GenerateDeleteRequest(imagingStudy),
                           imagingStudy.ToServerResourceId(),
                           imagingStudy));
            }

            return(new FhirTransactionRequestEntry(
                       FhirTransactionRequestMode.Update,
                       ImagingStudyPipelineHelper.GenerateUpdateRequest(imagingStudy),
                       imagingStudy.ToServerResourceId(),
                       imagingStudy));
        }
Beispiel #19
0
        public UddiId GetNewerVersion()
        {
            keyedReference newVersKeyref;

            if (!this.categoryBag.TryGetKeyedReference(newerVersionId, out newVersKeyref))
            {
                return(null);
            }
            if (String.IsNullOrEmpty(newVersKeyref.keyValue))
            {
                return(null);
            }
            return(IdentifierUtility.GetUddiIDFromString(newVersKeyref.keyValue));
        }
Beispiel #20
0
        public List <ProcessRoleDefinition> GetProcessRoleDefinitions()
        {
            List <UddiTModel> processesRoleTModels = GetProcessRoleTModels();
            Converter <UddiTModel, ProcessRoleDefinition> converter = delegate(UddiTModel tmodel)
            {
                string name        = tmodel.Name;
                string description = tmodel.Description;
                string role        = tmodel.GetProfileRoleId();
                string roleType    = tmodel.GetProfileRoleTypeId();
                UddiId processDefinitionReferenceId = IdentifierUtility.GetUddiIDFromString(tmodel.GetProcessDefinitionReferenceId());
                return(new ProcessRoleDefinition(name, description, role, roleType, processDefinitionReferenceId));
            };

            return(processesRoleTModels.ConvertAll <ProcessRoleDefinition>(converter));
        }
Beispiel #21
0
        protected LookupParameters GetMessageParameters(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            string endpointKeyTypeCode = Utilities.GetEndpointKeyTypeCode(message, docTypeConfig);

            Identifier endpointKey = Utilities.GetEndpointKeyByXpath(
                message.MessageXml,
                docTypeConfig.EndpointType.Key.XPath,
                docTypeConfig.Namespaces,
                endpointKeyTypeCode
                );

            UddiId profileTModelId = GetProfileTModelId(message, docTypeConfig);

            // 2. Build MessageParameters class:
            UddiId serviceContractTModel;

            serviceContractTModel = IdentifierUtility.GetUddiIDFromString(docTypeConfig.ServiceContractTModel);

            LookupParameters uddiLookupParameters;

            if (profileTModelId == null)
            {
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }
            else
            {
                uddiLookupParameters = new LookupParameters(
                    endpointKey,
                    serviceContractTModel,
                    new List <UddiId>()
                {
                    profileTModelId
                },
                    new List <EndpointAddressTypeCode>()
                {
                    EndpointAddressTypeCode.http
                });
            }

            return(uddiLookupParameters);
        }
        public bool Equals(QsiIdentifier x, QsiIdentifier y)
        {
            if (x == null && y == null)
            {
                return(true);
            }

            if (x == null || y == null)
            {
                return(false);
            }

            string nX = x.IsEscaped ? IdentifierUtility.Unescape(x.Value) : x.Value;
            string nY = y.IsEscaped ? IdentifierUtility.Unescape(y.Value) : y.Value;

            return(string.Equals(nX, nY, _comparison));
        }
Beispiel #23
0
        public static QsiLiteralExpressionNode VisitLiteral(ParserRuleContext context)
        {
            QsiDataType literalType;
            object      value;

            switch (context)
            {
            case NullLiteralContext _:
                literalType = QsiDataType.Null;
                value       = null;
                break;

            case StringLiteralContext stringLiteral:
            {
                value = string.Join("",
                                    stringLiteral.STRING_LITERAL()
                                    .Select(l => IdentifierUtility.Unescape(l.GetText())));

                literalType = QsiDataType.String;
                break;
            }

            case DecimalLiteralContext _:
                literalType = QsiDataType.Decimal;
                value       = decimal.Parse(context.GetText());
                break;

            case BooleanLiteralContext _:
                literalType = QsiDataType.Boolean;
                value       = bool.Parse(context.GetText());
                break;

            default:
                throw TreeHelper.NotSupportedTree(context);
            }

            var node = new QsiLiteralExpressionNode
            {
                Value = value,
                Type  = literalType
            };

            PrimarSqlTree.PutContextSpan(node, context);

            return(node);
        }
        public void RadiationEventWithAllSupportedAttributes()
        {
            const string  randomIrradiationEventUid          = "1.2.3.4.5.6.123123";
            const decimal randomDecimalNumber                = (decimal)0.10;
            var           randomRadiationMeasurementCodeItem = new DicomCodeItem("mGy", "UCUM", "mGy");
            var           report = new DicomStructuredReport(
                ObservationConstants.IrradiationEventXRayData,
                new DicomContentItem(
                    ObservationConstants.IrradiationEventUid,
                    DicomRelationship.Contains,
                    new DicomUID(randomIrradiationEventUid, "", DicomUidType.Unknown)),
                new DicomContentItem(
                    ObservationConstants.MeanCtdIvol,
                    DicomRelationship.Contains,
                    new DicomMeasuredValue(randomDecimalNumber,
                                           randomRadiationMeasurementCodeItem)),
                new DicomContentItem(
                    ObservationConstants.Dlp,
                    DicomRelationship.Contains,
                    new DicomMeasuredValue(randomDecimalNumber,
                                           randomRadiationMeasurementCodeItem)),
                new DicomContentItem(
                    ObservationConstants.CtdIwPhantomType,
                    DicomRelationship.Contains,
                    new DicomCodeItem("113691", "DCM", "IEC Body Dosimetry Phantom")));

            var observations = _observationParser.Parse(
                report.Dataset,
                new ResourceReference(),
                new ResourceReference(),
                IdentifierUtility.CreateIdentifier(randomIrradiationEventUid));

            Assert.Single(observations);

            Observation radiationEvent = observations.First();

            Assert.Single(radiationEvent.Identifier);
            Assert.Equal("urn:oid:" + randomIrradiationEventUid, radiationEvent.Identifier[0].Value);
            Assert.Equal(2,
                         radiationEvent.Component
                         .Count(component => component.Value is Quantity));
            Assert.Equal(1,
                         radiationEvent.Component
                         .Count(component => component.Value is CodeableConcept));
        }
Beispiel #25
0
        public async Task <IEnumerable <FhirTransactionRequestEntry> > BuildAsync(FhirTransactionContext context, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(context?.ChangeFeedEntry, nameof(context.ChangeFeedEntry));
            EnsureArg.IsNotNull(context.Request, nameof(context.Request));

            IResourceId     patientId       = context.Request.Patient.ResourceId;
            IResourceId     imagingStudyId  = context.Request.ImagingStudy.ResourceId;
            ChangeFeedEntry changeFeedEntry = context.ChangeFeedEntry;

            Identifier identifier = IdentifierUtility.CreateIdentifier(changeFeedEntry.StudyInstanceUid);

            IReadOnlyCollection <Observation> observations = _observationParser.Parse(changeFeedEntry.Metadata, patientId.ToResourceReference(), imagingStudyId.ToResourceReference(), identifier);

            if (observations.Count == 0)
            {
                return(Enumerable.Empty <FhirTransactionRequestEntry>());
            }

            Identifier imagingStudyIdentifier = imagingStudyId.ToResourceReference().Identifier;
            IEnumerable <Observation> existingDoseSummariesAsync = imagingStudyIdentifier != null
                ? await _fhirService
                                                                   .RetrieveObservationsAsync(
                imagingStudyId.ToResourceReference().Identifier,
                cancellationToken)
                : new List <Observation>();

            // TODO: Figure out a way to match existing observations with newly created ones.

            List <FhirTransactionRequestEntry> fhirRequests = new List <FhirTransactionRequestEntry>();

            foreach (var observation in observations)
            {
                fhirRequests.Add(new FhirTransactionRequestEntry(
                                     FhirTransactionRequestMode.Create,
                                     new Bundle.RequestComponent()
                {
                    Method = Bundle.HTTPVerb.POST,
                    Url    = ResourceType.Observation.GetLiteral()
                },
                                     new ClientResourceId(),
                                     observation));
            }

            return(fhirRequests);
        }
Beispiel #26
0
        protected UddiId GetProfileTModelId(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiId uddiId;

            // If doctype does't have a XPath expression to extract the document Profile
            // then we assume that the current document type does operate with OIOUBL profiles
            if (docTypeConfig.ProfileIdXPath == null)
            {
                uddiId = null;
            }
            else if (docTypeConfig.ProfileIdXPath.XPath == null)
            {
                uddiId = null;
            }
            else if (docTypeConfig.ProfileIdXPath.XPath.Equals(""))
            {
                uddiId = null;
            }
            else
            {
                // Fetch the OIOUBL profile name
                string profileName = DocumentXPathResolver.GetElementValueByXPathNavigator(
                    message.MessageXml,
                    docTypeConfig.ProfileIdXPath.XPath,
                    docTypeConfig.Namespaces);

                ProfileMappingCollectionConfig config = ConfigurationHandler.GetConfigurationSection <ProfileMappingCollectionConfig>();
                if (config.ContainsProfileMappingByName(profileName))
                {
                    ProfileMapping profileMapping    = config.GetMapping(profileName);
                    string         profileTModelGuid = profileMapping.TModelGuid;
                    uddiId = IdentifierUtility.GetUddiIDFromString(profileTModelGuid);
                }
                else
                {
                    throw new Exception("GetProfileTModelId failed for : " + profileName);
                }
            }

            return(uddiId);
        }
        public static ImagingStudy ValidateImagingStudyUpdate(string studyInstanceUid, string patientResourceId, FhirTransactionRequestEntry entry, bool hasAccessionNumber = true)
        {
            Identifier expectedIdentifier = IdentifierUtility.CreateIdentifier(studyInstanceUid);
            string     expectedRequestUrl = $"ImagingStudy/{entry.Resource.Id}";

            ValidateRequestEntryMinimumRequirementForWithChange(FhirTransactionRequestMode.Update, expectedRequestUrl, Bundle.HTTPVerb.PUT, actualEntry: entry);

            ImagingStudy updatedImagingStudy = Assert.IsType <ImagingStudy>(entry.Resource);

            Assert.Equal(ImagingStudy.ImagingStudyStatus.Available, updatedImagingStudy.Status);

            ValidateResourceReference(patientResourceId, updatedImagingStudy.Subject);

            Action <Identifier> studyIdValidaion          = identifier => ValidateIdentifier("urn:dicom:uid", $"urn:oid:{studyInstanceUid}", identifier);
            Action <Identifier> accessionNumberValidation = identifier => ValidateAccessionNumber(null, FhirTransactionContextBuilder.DefaultAccessionNumber, identifier);

            Assert.Collection(
                updatedImagingStudy.Identifier,
                hasAccessionNumber ? new[] { studyIdValidaion, accessionNumberValidation } : new[] { studyIdValidaion });

            return(updatedImagingStudy);
        }
Beispiel #28
0
        private static UddiId GetProfileTModelId(OiosiMessage message, DocumentTypeConfig docTypeConfig)
        {
            UddiId uddiId      = null;
            string profileName = GetProfileName(message, docTypeConfig);

            if (string.IsNullOrEmpty(profileName) == false)
            {
                var config = ConfigurationHandler.GetConfigurationSection <ProfileMappingCollectionConfig>();
                if (config.ContainsProfileMappingByName(profileName))
                {
                    ProfileMapping profileMapping    = config.GetMapping(profileName);
                    string         profileTModelGuid = profileMapping.TModelGuid;
                    uddiId = IdentifierUtility.GetUddiIDFromString(profileTModelGuid);
                }
                else
                {
                    throw new Exception("DocumentProfileMappingNotFoundException: " + profileName);
                }
            }

            return(uddiId);
        }
Beispiel #29
0
        public static ImagingStudy CreateNewImagingStudy(string studyInstanceUid, List <string> seriesInstanceUidList, List <string> sopInstanceUidList, string patientResourceId, string source = "defaultSouce")
        {
            // Create a new ImagingStudy
            ImagingStudy study = new ImagingStudy
            {
                Id      = "123",
                Status  = ImagingStudy.ImagingStudyStatus.Available,
                Subject = new ResourceReference(patientResourceId),
                Meta    = new Meta()
                {
                    VersionId = "1",
                    Source    = source,
                },
            };

            foreach (string seriesInstanceUid in seriesInstanceUidList)
            {
                ImagingStudy.SeriesComponent series = new ImagingStudy.SeriesComponent()
                {
                    Uid = seriesInstanceUid,
                };

                foreach (string sopInstanceUid in sopInstanceUidList)
                {
                    ImagingStudy.InstanceComponent instance = new ImagingStudy.InstanceComponent()
                    {
                        Uid = sopInstanceUid,
                    };

                    series.Instance.Add(instance);
                }

                study.Series.Add(series);
            }

            study.Identifier.Add(IdentifierUtility.CreateIdentifier(studyInstanceUid));

            return(study);
        }
        public static QsiChangeSearchPathActionNode VisitUseSchemaStatement(UseSchemaStatement context)
        {
            var schemaName = context.SchemaName;

            if (string.IsNullOrEmpty(schemaName))
            {
                schemaName = "DEFAULT";
            }

            var identifier = new QsiIdentifier(schemaName, IdentifierUtility.IsEscaped(schemaName));

            var node = new QsiChangeSearchPathActionNode
            {
                Identifiers = new[]
                {
                    identifier
                }
            };

            PTree.RawNode[node] = context;

            return(node);
        }