Ejemplo n.º 1
0
        public virtual void TestFormatPhysicalQuantityValidWithTranslations()
        {
            CodedTypeR2 <Code> translation1 = new CodedTypeR2 <Code>();

            translation1.Code = Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE;
            CodedTypeR2 <Code> translation2 = new CodedTypeR2 <Code>();

            translation2.Code = Ca.Infoway.Messagebuilder.Domainvalue.Controlact.ActStatus.ACTIVE;
            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;
            physicalQuantity.Translation.Add(translation1);
            physicalQuantity.Translation.Add(translation2);
            IDictionary <string, string> result = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("PQ"), physicalQuantity, null);

            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");
            string xml = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), new PQImpl(physicalQuantity
                                                                                                                              ), 0);

            AssertXml("should see translations", "<name unit=\"U/L\" value=\"33.45\"><translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" displayName=\"Male\"/><translation code=\"active\" codeSystem=\"2.16.840.1.113883.5.14\" displayName=\"Active\"/></name>"
                      , xml);
        }
Ejemplo n.º 2
0
        public virtual void TestFormatPhysicalQuantitySpecificNull()
        {
            PQImpl dataType = new PQImpl(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NOT_APPLICABLE);
            string result   = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), dataType);

            Assert.AreEqual("<name nullFlavor=\"NA\"/>", result.Trim(), "map size");
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 3
0
        public virtual void TestFormatPhysicalQuantityNull()
        {
            string result = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), 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.º 4
0
        public virtual void TestFormatPhysicalQuantityEmpty()
        {
            IDictionary <string, string> resultMap = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (CreateContext("PQ"), new PhysicalQuantity(), null);

            // an empty value for PQ elements results no attributes whatsoever
            Assert.AreEqual(0, resultMap.Count, "map size");
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 5
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 PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("PQ"), physicalQuantity, null);

            Assert.AreEqual(formattedQuantity, result.SafeGet("value"), "value " + quantity);
        }
Ejemplo n.º 6
0
        public virtual void TestFormatNonNullWithEmptyPq()
        {
            // nullFlavor, value, and unit are all optional in the schema (unit will default to "1")
            PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter formatter = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter
                                                                                    ();
            PQImpl pqImpl = new PQImpl();

            pqImpl.Value = new PhysicalQuantity();
            string result = formatter.FormatNonNullDataTypeForTest(CreateContext("PQ"), pqImpl, 0);

            Assert.AreEqual("<name/>", result.Trim());
        }
Ejemplo n.º 7
0
        public virtual void TestFormatPhysicalQuantityValueOrUnitNull()
        {
            // no name-value pairs
            PqR2PropertyFormatter formatter        = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter();
            PhysicalQuantity      physicalQuantity = new PhysicalQuantity();

            physicalQuantity.Unit = CeRxDomainTestValues.ENZYME_UNIT_MICROMOLES_MINUTE_PER_LITRE;
            string result = formatter.Format(CreateContext("PQ"), new PQImpl(physicalQuantity));

            Assert.IsTrue(this.result.IsValid());
            Assert.AreEqual("<name unit=\"U/L\"/>", result.Trim(), "map size");
        }
Ejemplo n.º 8
0
        public virtual void TestFormatPhysicalQuantityNotNullWithNullFlavor()
        {
            // in this case, NF "wins"
            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 PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), dataType);

            Assert.AreEqual("<name nullFlavor=\"NA\"/>", result.Trim(), "map size");
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 9
0
        public virtual void TestFormatValidPhysicalQuantity()
        {
            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(physicalQuantity);
            string result         = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), rawPq, 0);
            string expectedResult = "<name unit=\"U/L\" value=\"33.45\"/>";

            Assert.AreEqual(expectedResult, result.Trim(), "output");
        }
Ejemplo n.º 10
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 PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (CreateContext("PQ"), physicalQuantity, null);

            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.º 11
0
        public virtual void TestFormatValidPhysicalQuantityWithOperatorNotAllowed()
        {
            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(physicalQuantity);

            rawPq.Operator = SetOperator.PERIODIC_HULL;
            string result         = new PqR2PropertyFormatterTest.TestablePqR2PropertyFormatter().Format(CreateContext("PQ"), rawPq, 0);
            string expectedResult = "<name unit=\"U/L\" value=\"33.45\"/>";

            Assert.AreEqual(expectedResult, result.Trim(), "output");
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }