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); }
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()); }
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()); }
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()); }
/// <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); }
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()); }
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"); }
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()); }
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"); }
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"); }
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); }