Example #1
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;
            }
        }
Example #2
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;
            }
        }