Esempio n. 1
0
        public void GetImplementationGuideVocabulary_Valueset3()
        {
            Template           t  = this.tdb.GenerateTemplate("1.2.3.4.5", "Document", "Test Template 1", this.ig);
            TemplateConstraint tc = this.tdb.GenerateConstraint(t, null, null, "code", "SHALL", "1..1", valueConformance: "SHALL", valueSet: this.vs3);

            tc.IsStatic = true;

            VocabService service = new VocabService(this.tdb);
            string       vocXml  = service.GetImplementationGuideVocabulary(ig.Id, 0, 1, "UTF-8");
            XmlDocument  doc     = new XmlDocument();

            doc.LoadXml(vocXml);

            XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);

            nsManager.AddNamespace("voc", "http://www.lantanagroup.com/voc");

            Assert.AreEqual("systems", doc.DocumentElement.LocalName);
            Assert.AreEqual(1, doc.DocumentElement.ChildNodes.Count);

            XmlElement exportValueSet = doc.DocumentElement.ChildNodes[0] as XmlElement;

            Assert.AreEqual(4, exportValueSet.ChildNodes.Count);
            Assert.IsNotNull(exportValueSet.SelectSingleNode("voc:code[@value='1']", nsManager));
            Assert.IsNotNull(exportValueSet.SelectSingleNode("voc:code[@value='2']", nsManager));
            Assert.IsNotNull(exportValueSet.SelectSingleNode("voc:code[@value='4']", nsManager));
            Assert.IsNotNull(exportValueSet.SelectSingleNode("voc:code[@value='5']", nsManager));
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            this.context = context;

            if (string.IsNullOrEmpty(ValueSetOid) && ImplementationGuideId == null)
            {
                return;
            }

            // TODO: Make this an actual call to the service, rather than an instatiation of the service
            VocabularyService service = new VocabularyService();

            context.Response.Clear();
            context.Response.ContentType = "text/xml";

            if (!string.IsNullOrEmpty(ValueSetOid))
            {
                context.Response.Write(service.GetValueSet(ValueSetOid, (int)VocabularyOutputType.Default, "UTF-8"));
            }
            else if (ImplementationGuideId != null)
            {
                context.Response.Write(service.GetImplementationGuideVocabulary(ImplementationGuideId.Value, MaxValueSetMembers, (int)VocabularyOutputType.Default, "UTF-8"));
            }

            context.Response.Flush();
            context.Response.End();
        }
Esempio n. 3
0
        public void GetImplementationGuideVocabulary_NoStaticValuesets()
        {
            Template           t  = this.tdb.GenerateTemplate("1.2.3.4.5", "Document", "Test Template 1", this.ig);
            TemplateConstraint tc = this.tdb.GenerateConstraint(t, null, null, "code", "SHALL", "1..1", valueConformance: "SHALL", valueSet: this.vs1);

            tc.IsStatic = false;

            VocabService service = new VocabService(this.tdb);
            string       vocXml  = service.GetImplementationGuideVocabulary(ig.Id, 0, 1, "UTF-8");
            XmlDocument  doc     = new XmlDocument();

            doc.LoadXml(vocXml);

            Assert.AreEqual("systems", doc.DocumentElement.LocalName);
            Assert.AreEqual(0, doc.DocumentElement.ChildNodes.Count);
        }
Esempio n. 4
0
        public void GetImplementationGuideVocabularySpreadsheet()
        {
            Template t = this.tdb.GenerateTemplate("1.2.3.4.5", "Document", "Test Template 1", this.ig);

            this.tdb.GenerateConstraint(t, null, null, "code", "SHALL", "1..1", valueConformance: "SHALL", valueSet: this.vs1);
            this.tdb.GenerateConstraint(t, null, null, "value", "SHALL", "1..1", valueConformance: "SHALL", valueSet: this.vs2);

            VocabService service = new VocabService(this.tdb);

            byte[] spreadsheetBytes = service.GetImplementationGuideVocabularySpreadsheet(this.ig.Id, 100);

            Assert.IsNotNull(spreadsheetBytes);

            using (MemoryStream ms = new MemoryStream(spreadsheetBytes))
            {
                SpreadsheetDocument doc = SpreadsheetDocument.Open(ms, false);

                Sheets sheets = doc.WorkbookPart.Workbook.GetFirstChild <Sheets>();
                Assert.IsNotNull(sheets);

                // Affected Value Sets
                Sheet summarySheet = sheets.FirstChild as Sheet;
                Assert.IsNotNull(summarySheet);
                Assert.AreEqual("Affected Value Sets", summarySheet.Name.Value);

                WorksheetPart summarySheetPart = doc.WorkbookPart.WorksheetParts.FirstOrDefault();
                Assert.IsNotNull(summarySheetPart, "Expected to find two worksheets, but didn't find any.");

                Columns summarySheetCols = summarySheetPart.Worksheet.GetFirstChild <Columns>();
                Assert.IsNotNull(summarySheetCols);

                SheetData summarySheetData = summarySheetPart.Worksheet.GetFirstChild <SheetData>();
                Assert.IsNotNull(summarySheetData);

                Assert.AreEqual(3, summarySheetData.ChildElements.Count);
                Row summaryHeaderRow = summarySheetData.ChildElements[0] as Row;
                Assert.IsNotNull(summaryHeaderRow);
                Assert.AreEqual((uint)1, summaryHeaderRow.RowIndex.Value);
                Assert.AreEqual(2, summaryHeaderRow.ChildElements.Count);

                Cell summaryHeaderCell1 = summaryHeaderRow.Elements <Cell>().Single(y => y.CellReference == "A1");
                Cell summaryHeaderCell2 = summaryHeaderRow.Elements <Cell>().Single(y => y.CellReference == "B1");
                Assert.AreEqual("Value Set Name", summaryHeaderCell1.CellValue.Text);
                Assert.AreEqual("Value Set OID", summaryHeaderCell2.CellValue.Text);

                Row valueSet1Row = summarySheetData.ChildElements[1] as Row;
                Assert.IsNotNull(valueSet1Row);

                Cell valueSet1Cell1 = valueSet1Row.Elements <Cell>().Single(y => y.CellReference == "A2");
                Cell valueSet1Cell2 = valueSet1Row.Elements <Cell>().Single(y => y.CellReference == "B2");
                Assert.AreEqual(this.vs1.Name, valueSet1Cell1.CellValue.Text);
                Assert.AreEqual(this.vs1.Oid, valueSet1Cell2.CellValue.Text);

                Row valueSet2Row = summarySheetData.ChildElements[2] as Row;
                Assert.IsNotNull(valueSet1Row);

                Cell valueSet2Cell1 = valueSet2Row.Elements <Cell>().Single(y => y.CellReference == "A3");
                Cell valueSet2Cell2 = valueSet2Row.Elements <Cell>().Single(y => y.CellReference == "B3");
                Assert.AreEqual(this.vs2.Name, valueSet2Cell1.CellValue.Text);
                Assert.AreEqual(this.vs2.Oid, valueSet2Cell2.CellValue.Text);

                // Value Set Members
                Sheet membersSheet = sheets.LastChild as Sheet;
                Assert.IsNotNull(membersSheet);
                Assert.AreEqual("Value Set Members", membersSheet.Name.Value);

                WorksheetPart membersSheetPart = doc.WorkbookPart.WorksheetParts.LastOrDefault();
                Assert.IsNotNull(membersSheetPart, "Expected to find two worksheets, but didn't find any.");

                Columns membersSheetCols = membersSheetPart.Worksheet.GetFirstChild <Columns>();
                Assert.IsNotNull(membersSheetCols);

                SheetData membersSheetData = membersSheetPart.Worksheet.GetFirstChild <SheetData>();
                Assert.IsNotNull(membersSheetData);

                Assert.AreEqual(7, membersSheetData.ChildElements.Count);
                Row membersHeaderRow = membersSheetData.ChildElements[0] as Row;
                Assert.IsNotNull(membersHeaderRow);
                Assert.AreEqual((uint)1, membersHeaderRow.RowIndex.Value);
                Assert.AreEqual(5, membersHeaderRow.ChildElements.Count);

                Cell membersHeaderCell1 = membersHeaderRow.Elements <Cell>().Single(y => y.CellReference == "A1");
                Cell membersHeaderCell2 = membersHeaderRow.Elements <Cell>().Single(y => y.CellReference == "B1");
                Cell membersHeaderCell3 = membersHeaderRow.Elements <Cell>().Single(y => y.CellReference == "C1");
                Cell membersHeaderCell4 = membersHeaderRow.Elements <Cell>().Single(y => y.CellReference == "D1");
                Cell membersHeaderCell5 = membersHeaderRow.Elements <Cell>().Single(y => y.CellReference == "E1");
                Assert.AreEqual("Value Set OID", membersHeaderCell1.CellValue.Text);
                Assert.AreEqual("Value Set Name", membersHeaderCell2.CellValue.Text);
                Assert.AreEqual("Code", membersHeaderCell3.CellValue.Text);
                Assert.AreEqual("Display Name", membersHeaderCell4.CellValue.Text);
                Assert.AreEqual("Code System Name", membersHeaderCell5.CellValue.Text);
            }
        }