Пример #1
0
        protected override RetrieveValueSetResponseType Convert(VocabularySystems systems)
        {
            var response = new RetrieveValueSetResponseType();

            response.cacheExpirationHint          = DateTime.Now.Date;
            response.cacheExpirationHintSpecified = true;

            if (systems.Systems.Length > 0)
            {
                ValueSetResponseType valueSet = new ValueSetResponseType();
                valueSet.displayName = systems.Systems[0].ValueSetName;
                valueSet.id          = systems.Systems[0].ValueSetOid;
                valueSet.version     = string.Empty;
                var concepts = new List <CE>();
                foreach (var code in systems.Systems[0].Codes)
                {
                    concepts.Add(new CE()
                    {
                        code           = code.Value,
                        codeSystem     = code.CodeSystem,
                        codeSystemName = code.CodeSystemName,
                        displayName    = code.DisplayName
                    });
                }

                var conceptList = new ConceptListType()
                {
                    Concept = concepts.ToArray()
                };
                valueSet.ConceptList = new ConceptListType[] { conceptList };
                response.ValueSet    = valueSet;
            }

            return(response);
        }
Пример #2
0
        public string GetImplementationGuideVocabulary(int implementationGuideId, int maxValueSetMembers, int vocabOutputType, string encoding)
        {
            try
            {
                TDBImplementationGuide ig = tdb.ImplementationGuides.SingleOrDefault(y => y.Id == implementationGuideId);

                if (ig == null)
                {
                    throw new Exception("Could not find ImplementationGuide specified.");
                }

                bool?onlyStatic = VocabularyOutputTypeTranslator.FromInt(vocabOutputType) != VocabularyOutputType.FHIR ? (bool?)true : null;
                List <ImplementationGuideValueSet> valueSets = ig.GetValueSets(tdb, onlyStatic);
                List <VocabularySystem>            systems   = new List <VocabularySystem>();

                foreach (ImplementationGuideValueSet cValueSet in valueSets)
                {
                    VocabularySystem newSystem = this.GetSystem(tdb, cValueSet.ValueSet, cValueSet.BindingDate);
                    systems.Add(newSystem);
                }

                VocabularySystems schema = new VocabularySystems();
                schema.Systems = systems.ToArray();
                VocabularyOutputTypeAdapter adapter = new VocabularyOutputTypeAdapter(schema, VocabularyOutputTypeTranslator.FromInt(vocabOutputType), Encoding.GetEncoding(encoding));
                return(adapter.AsXML());
            }
            catch (Exception ex)
            {
                Log.For(this).Critical("Error occurred while retrieving vocabulary for an implementation guide.", ex);
                throw;
            }
        }
Пример #3
0
        protected VocabularySystems GetSystems(int implementationGuideId, int maxValueSetMembers, bool?onlyStatic = null)
        {
            try
            {
                ImplementationGuide ig = tdb.ImplementationGuides.SingleOrDefault(y => y.Id == implementationGuideId);

                if (ig == null)
                {
                    throw new Exception("Could not find ImplementationGuide specified.");
                }

                IIGTypePlugin igTypePlugin = ig.ImplementationGuideType.GetPlugin();
                List <ImplementationGuideValueSet> valueSets = ig.GetValueSets(tdb, onlyStatic);
                List <VocabularySystem>            systems   = new List <VocabularySystem>();
                bool isCDA = ig.ImplementationGuideType.SchemaURI == "urn:hl7-org:v3";

                foreach (ImplementationGuideValueSet cValueSet in valueSets)
                {
                    VocabularySystem newSystem = this.GetSystem(igTypePlugin, tdb, cValueSet.ValueSet, cValueSet.BindingDate, isCDA);
                    systems.Add(newSystem);
                }

                VocabularySystems schema = new VocabularySystems();
                schema.Systems = systems.ToArray();

                return(schema);
            }
            catch (Exception ex)
            {
                Log.For(this).Critical("Error occurred while retrieving vocabulary for an implementation guide.", ex);
                throw;
            }
        }
Пример #4
0
        public byte[] GetExport(int implementationGuideId, int maxValueSetMembers, Encoding encoding, bool?onlyStatic = null)
        {
            VocabularySystems systems = this.GetSystems(implementationGuideId, maxValueSetMembers, onlyStatic);
            T model = this.Convert(systems);

            return(this.Serialize(model, encoding));
        }
Пример #5
0
        public byte[] GetExport(int valueSetId, Encoding encoding)
        {
            ValueSet valueSet = this.tdb.ValueSets.Single(y => y.Id == valueSetId);

            VocabularySystems systems = new VocabularySystems();

            systems.Systems = new VocabularySystem[] { this.GetSystem(null, this.tdb, valueSet, DateTime.Now, false) };

            T model = this.Convert(systems);

            return(this.Serialize(model, encoding));
        }
Пример #6
0
        public string GetValueSet(string valueSetOid, int vocabOutputType, string encoding)
        {
            try
            {
                TDBValueSet valueSet = tdb.ValueSets.SingleOrDefault(y => y.Oid == valueSetOid);

                if (valueSet == null)
                {
                    throw new Exception("Could not find ValueSet specified.");
                }

                VocabularySystems schema = new VocabularySystems();
                schema.Systems = new VocabularySystem[] { GetSystem(tdb, valueSet, DateTime.Now) };
                VocabularyOutputTypeAdapter adapter = new VocabularyOutputTypeAdapter(schema, VocabularyOutputTypeTranslator.FromInt(vocabOutputType), Encoding.GetEncoding(encoding));

                return(adapter.AsXML());
            }
            catch (Exception ex)
            {
                Log.For(this).Critical("Error occurred while retrieving a valueset for oid '" + valueSetOid + "'", ex);
                throw;
            }
        }
Пример #7
0
        private VocabularySystem GetSystem(IObjectRepository tdb, TDBValueSet valueSet, DateTime?bindingDate)
        {
            if (valueSet == null)
            {
                throw new Exception("Could not find ValueSet specified.");
            }

            VocabularySystems schema         = new VocabularySystems();
            VocabularySystem  schemaValueSet = new VocabularySystem()
            {
                ValueSetOid  = valueSet.Oid,
                ValueSetName = valueSet.Name
            };

            if (isCDA && schemaValueSet.ValueSetOid.StartsWith("urn:oid:"))
            {
                schemaValueSet.ValueSetOid = schemaValueSet.ValueSetOid.Substring(8);
            }

            schemaValueSet.Codes = GetCodes(valueSet, bindingDate).ToArray();

            return(schemaValueSet);
        }
Пример #8
0
        private VocabularySystem GetSystem(IIGTypePlugin igTypePlugin, IObjectRepository tdb, ValueSet valueSet, DateTime?bindingDate, bool isCDA)
        {
            if (valueSet == null)
            {
                throw new Exception("Could not find ValueSet specified.");
            }

            VocabularySystems schema         = new VocabularySystems();
            VocabularySystem  schemaValueSet = new VocabularySystem()
            {
                ValueSetOid  = valueSet.GetIdentifier(igTypePlugin),
                ValueSetName = valueSet.Name
            };

            if (isCDA && schemaValueSet.ValueSetOid.StartsWith("urn:oid:"))
            {
                schemaValueSet.ValueSetOid = schemaValueSet.ValueSetOid.Substring(8);
            }

            schemaValueSet.Codes = GetCodes(valueSet, bindingDate, isCDA);

            return(schemaValueSet);
        }
Пример #9
0
        protected override SVS.MultipleValueSet.RetrieveMultipleValueSetsResponseType Convert(VocabularySystems systems)
        {
            var response  = new RetrieveMultipleValueSetsResponseType();
            var valueSets = new List <DescribedValueSet>();

            foreach (var vocab in systems.Systems)
            {
                if (vocab.Codes.Length > 0)
                {
                    var valueSet = new DescribedValueSet();

                    valueSet.Binding = DescribedValueSetBinding.Static;

                    if (vocab.Binding != null && vocab.Binding.ToLower() == DYNAMIC_BINDING)
                    {
                        valueSet.Binding = DescribedValueSetBinding.Dynamic;
                    }

                    valueSet.BindingSpecified        = true;
                    valueSet.CreationDateSpecified   = false;
                    valueSet.displayName             = vocab.ValueSetName;
                    valueSet.EffectiveDateSpecified  = false;
                    valueSet.ExpirationDateSpecified = false;
                    valueSet.ID = vocab.ValueSetOid;
                    valueSet.RevisionDateSpecified = false;
                    valueSet.Type      = DescribedValueSetType.Expanded;
                    valueSet.version   = "";
                    valueSet.Source    = "";
                    valueSet.SourceURI = "";

                    var concepts = new List <CE>();
                    foreach (var code in vocab.Codes)
                    {
                        concepts.Add(new CE()
                        {
                            code           = code.Value,
                            codeSystem     = code.CodeSystem,
                            codeSystemName = code.CodeSystemName,
                            displayName    = code.DisplayName
                        });
                    }
                    valueSet.ConceptList = new ConceptListType()
                    {
                        Concept = concepts.ToArray()
                    };
                    valueSets.Add(valueSet);
                }
            }

            response.DescribedValueSet = valueSets.ToArray();

            return(response);
        }
Пример #10
0
 protected abstract T Convert(VocabularySystems systems);
Пример #11
0
 public VocabularyOutputTypeAdapter(VocabularySystems aVocabSystems, VocabularyOutputType aOutputType, Encoding aEncoding)
     : this(aVocabSystems, aOutputType)
 {
     _encoding = aEncoding;
 }
Пример #12
0
 public VocabularyOutputTypeAdapter(VocabularySystems aVocabSystems, VocabularyOutputType aOutputType)
 {
     _vocabOutputType = aOutputType;
     _vocabSystems    = aVocabSystems;
     _encoding        = Encoding.UTF8;
 }