internal static DocumentHealthcareEntitiesInternal DeserializeDocumentHealthcareEntitiesInternal(JsonElement element)
        {
            string id = default;
            IReadOnlyList <HealthcareEntity>             entities   = default;
            IReadOnlyList <HealthcareRelationInternal>   relations  = default;
            IReadOnlyList <TextAnalyticsWarningInternal> warnings   = default;
            Optional <TextDocumentStatistics>            statistics = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("entities"))
                {
                    List <HealthcareEntity> array = new List <HealthcareEntity>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HealthcareEntity.DeserializeHealthcareEntity(item));
                    }
                    entities = array;
                    continue;
                }
                if (property.NameEquals("relations"))
                {
                    List <HealthcareRelationInternal> array = new List <HealthcareRelationInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(HealthcareRelationInternal.DeserializeHealthcareRelationInternal(item));
                    }
                    relations = array;
                    continue;
                }
                if (property.NameEquals("warnings"))
                {
                    List <TextAnalyticsWarningInternal> array = new List <TextAnalyticsWarningInternal>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TextAnalyticsWarningInternal.DeserializeTextAnalyticsWarningInternal(item));
                    }
                    warnings = array;
                    continue;
                }
                if (property.NameEquals("statistics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    statistics = TextDocumentStatistics.DeserializeTextDocumentStatistics(property.Value);
                    continue;
                }
            }
            return(new DocumentHealthcareEntitiesInternal(id, entities, relations, warnings, Optional.ToNullable(statistics)));
        }
Пример #2
0
 internal static List<HealthcareEntity> ConvertToHealthcareEntityCollection(IEnumerable<HealthcareEntityInternal> healthcareEntities, IEnumerable<HealthcareRelationInternal> healthcareRelations)
 {
     var entities = healthcareEntities.Select((entity) => new HealthcareEntity(entity)).ToList();
     foreach (HealthcareRelationInternal relation in healthcareRelations) {
         string relationType = relation.RelationType;
         int sourceIndex = ParseHealthcareEntityIndex(relation.Source);
         int targetIndex = ParseHealthcareEntityIndex(relation.Target);
         HealthcareEntity sourceEntity = entities[sourceIndex];
         HealthcareEntity targetEntity = entities[targetIndex];
         sourceEntity.RelatedEntities.Add(targetEntity, relationType);
         if (relation.Bidirectional)
         {
             targetEntity.RelatedEntities.Add(sourceEntity, relationType);
         }
     }
     return entities;
 }
        /// <summary> Initializes a new instance of HealthcareRelation. </summary>
        /// <param name="relationType"> Type of relation. Examples include: `DosageOfMedication` or `FrequencyOfMedication`, etc. </param>
        /// <param name="bidirectional"> If true the relation between the entities is bidirectional, otherwise directionality is source to target. </param>
        /// <param name="source"> Reference link to the source entity. </param>
        /// <param name="target"> Reference link to the target entity. </param>
        /// <exception cref="ArgumentNullException"> <paramref name="relationType"/>, <paramref name="source"/>, or <paramref name="target"/> is null. </exception>
        internal HealthcareRelation(string relationType, bool bidirectional, HealthcareEntity source, HealthcareEntity target)
        {
            if (relationType == null)
            {
                throw new ArgumentNullException(nameof(relationType));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (target == null)
            {
                throw new ArgumentNullException(nameof(target));
            }

            RelationType  = relationType;
            Bidirectional = bidirectional;
            Source        = source;
            Target        = target;
        }
Пример #4
0
 internal HealthcareEntityRelationRole(HealthcareEntityInternal entity, string entityName)
 {
     Name   = entityName;
     Entity = new HealthcareEntity(entity);
 }
Пример #5
0
 internal HealthcareEntityRelationRole(HealthcareEntity entity, string entityName)
 {
     Name   = entityName;
     Entity = entity;
 }