Ejemplo n.º 1
0
        public virtual void TestFormatPhysicalQuantityNull()
        {
            string result = new PqPropertyFormatterTest.TestablePqPropertyFormatter().Format(CreateContext("PQ.BASIC"), new PQImpl());

            // a null value for PQ elements results in a nullFlavor attribute (but not via calling getAttributeNameValuePairs, only through format() itself)
            Assert.AreEqual("<name nullFlavor=\"NI\"/>", result.Trim(), "map size");
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 2
0
        public virtual void TestFormatPhysicalQuantityNullMissingOriginalText()
        {
            PQImpl dataType = new PQImpl(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NOT_APPLICABLE);
            string result   = new PqPropertyFormatterTest.TestablePqPropertyFormatter().Format(CreateContext("PQ.LAB"), dataType);

            Assert.AreEqual("<name nullFlavor=\"NA\"/>", result.Trim(), "map size");
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Ejemplo n.º 3
0
        public virtual void TestFormatPhysicalQuantityEmpty()
        {
            IDictionary <string, string> resultMap = new PqPropertyFormatterTest.TestablePqPropertyFormatter().GetAttributeNameValuePairs
                                                         (CreateContext("PQ.BASIC"), new PhysicalQuantity());

            // an empty value for PQ elements results in a nullFlavor attribute
            Assert.AreEqual(1, resultMap.Count, "map size");
            Assert.IsTrue(resultMap.ContainsKey("nullFlavor"), "key as expected");
            Assert.AreEqual(AbstractPropertyFormatter.NULL_FLAVOR_NO_INFORMATION, resultMap.SafeGet("nullFlavor"), "value as expected"
                            );
        }
Ejemplo n.º 4
0
        /// <exception cref="System.Exception"></exception>
        private void AssertFormattingAsExpected(string quantity, string formattedQuantity)
        {
            PhysicalQuantity physicalQuantity = new PhysicalQuantity();

            physicalQuantity.Quantity = new BigDecimal(quantity);
            physicalQuantity.Unit     = CeRxDomainTestValues.CENTIMETRE;
            IDictionary <string, string> result = new PqPropertyFormatterTest.TestablePqPropertyFormatter().GetAttributeNameValuePairs
                                                      (CreateContext("PQ.BASIC"), physicalQuantity);

            Assert.AreEqual(formattedQuantity, result.SafeGet("value"), "value " + quantity);
        }
Ejemplo n.º 5
0
        public virtual void TestFormatNonNullWithEmptyPq()
        {
            PqPropertyFormatterTest.TestablePqPropertyFormatter formatter = new PqPropertyFormatterTest.TestablePqPropertyFormatter();
            PQImpl pqImpl = new PQImpl();

            pqImpl.Value = new PhysicalQuantity();
            string @string   = formatter.FormatNonNullDataTypeForTest(CreateContext("PQ.BASIC"), pqImpl, 0);
            string lineBreak = Runtime.GetProperty("line.separator");

            Assert.AreEqual("<name nullFlavor=\"NI\"/>" + lineBreak, @string);
        }
Ejemplo n.º 6
0
        public virtual void TestFormatPhysicalQuantityValueOrUnitNull()
        {
            // no name-value pairs
            PqPropertyFormatter formatter        = new PqPropertyFormatterTest.TestablePqPropertyFormatter();
            PhysicalQuantity    physicalQuantity = new PhysicalQuantity();

            physicalQuantity.Unit = CeRxDomainTestValues.ENZYME_UNIT_MICROMOLES_MINUTE_PER_LITRE;
            formatter.Format(CreateContext("PQ.BASIC"), new PQImpl(physicalQuantity));
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            Assert.AreEqual("No value provided for physical quantity", this.result.GetHl7Errors()[0].GetMessage(), "exception message null quantity"
                            );
        }
Ejemplo n.º 7
0
        public virtual void TestFormatPhysicalQuantityNotNullWithNullFlavorMissingOriginalText()
        {
            PhysicalQuantity pq = new PhysicalQuantity(null, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.
                                                       CENTIMETRE);
            PQImpl dataType = new PQImpl(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NOT_APPLICABLE);

            dataType.Value = pq;
            string result = new PqPropertyFormatterTest.TestablePqPropertyFormatter().Format(CreateContext("PQ.LAB"), dataType);

            Assert.AreEqual("<name nullFlavor=\"NA\"/>", result.Trim(), "map size");
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(2, this.result.GetHl7Errors().Count);
        }
Ejemplo n.º 8
0
        public virtual void TestFormatPhysicalQuantityValid()
        {
            string quantity = "33.45";

            Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive unit = CeRxDomainTestValues.ENZYME_UNIT_MICROMOLES_MINUTE_PER_LITRE;
            PhysicalQuantity physicalQuantity = new PhysicalQuantity();

            physicalQuantity.Quantity = new BigDecimal(quantity);
            physicalQuantity.Unit     = unit;
            IDictionary <string, string> result = new PqPropertyFormatterTest.TestablePqPropertyFormatter().GetAttributeNameValuePairs
                                                      (CreateContext("PQ.BASIC"), physicalQuantity);

            Assert.AreEqual(2, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual(quantity, result.SafeGet("value"), "value");
            Assert.IsTrue(result.ContainsKey("unit"), "unit key as expected");
            Assert.AreEqual(unit.CodeValue, result.SafeGet("unit"), "unit");
        }
Ejemplo n.º 9
0
        public virtual void TestFormatPhysicalQuantityValidWithOriginalText()
        {
            string quantity = "33.45";

            Ca.Infoway.Messagebuilder.Domainvalue.UnitsOfMeasureCaseSensitive unit = CeRxDomainTestValues.ENZYME_UNIT_MICROMOLES_MINUTE_PER_LITRE;
            PhysicalQuantity physicalQuantity = new PhysicalQuantity();

            physicalQuantity.Quantity = new BigDecimal(quantity);
            physicalQuantity.Unit     = unit;
            PQ rawPq = new PQImpl();

            rawPq.OriginalText = "some original text";
            rawPq.Value        = physicalQuantity;
            string result         = new PqPropertyFormatterTest.TestablePqPropertyFormatter().Format(CreateContext("PQ.BASIC"), rawPq, 0);
            string expectedResult = "<name unit=\"U/L\" value=\"33.45\">" + SystemUtils.LINE_SEPARATOR + "  <originalText>some original text</originalText>"
                                    + SystemUtils.LINE_SEPARATOR + "</name>" + SystemUtils.LINE_SEPARATOR;

            Assert.AreEqual(expectedResult, result, "output");
        }