public virtual void TestGetCodeValidArgument() { CodedTypeR2 <UnitsOfMeasureCaseSensitive> codedType = new CodedTypeR2 <UnitsOfMeasureCaseSensitive>(); codedType.Code = Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.CUP; Assert.AreEqual(codedType.Code, CodedTypeR2Helper.GetCode(codedType)); }
private object ResolveCodeValue(Relationship relationship, string attributeValue, VersionNumber version, bool isR2) { Type returnType = (Type)DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance()); Code codeLookup = CodeResolverRegistry.Lookup(returnType, attributeValue); object result = codeLookup; if (isR2) { result = CodedTypeR2Helper.ConvertCodedTypeR2(new CodedTypeR2 <Code>(codeLookup), returnType); } return(result); }
public virtual void TestConvertCodedTypeR2ToSpecificTypeNonCodeTypeArgument() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.CUP; object convertedValue = CodedTypeR2Helper.ConvertCodedTypeR2(codedType, typeof(string)); Assert.IsTrue(convertedValue is CodedTypeR2 <Code>); CodedTypeR2 <Code> actualValue = (CodedTypeR2 <Code>)convertedValue; Assert.AreEqual(codedType.Code, actualValue.Code); }
private string ValueAsString(object value, Relationship relationship) { string type = relationship.Type; if (type == null) { throw new MarshallingException("Relationship " + relationship.Name + " has no type information"); } else { if ("CS".Equals(type)) { if (CodedTypeR2Helper.IsCodedTypeR2(value)) { return(CodedTypeR2Helper.GetCodeValue(value)); } else { if (value is Code) { return(((Code)value).CodeValue); } else { throw new MarshallingException("Encountered value \"" + value + "\" of type " + value.GetType().FullName + " when Code was expected (" + relationship.Name + ")"); } } } else { if ("BL".Equals(type)) { return(true.Equals(value) ? "true" : "false"); } else { if ("ST".Equals(type)) { return((string)value); } else { throw new MarshallingException("Cannot handle structural attribute string of type " + type + " (" + relationship.Name + ")" ); } } } } }
public virtual void TestConvertCodedTypeR2ToSpecificType() { CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.CUP; codedType.CodeSystemName = "code system"; codedType.CodeSystemVersion = "version"; codedType.DisplayName = "display name"; codedType.NullFlavorForTranslationOnly = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.ASKED_BUT_UNKNOWN; codedType.OriginalText = new EncapsulatedData("original text"); IList <CodeRole> qualifier = new List <CodeRole>(); qualifier.Add(new CodeRole()); codedType.Qualifier = qualifier; IList <CodedTypeR2 <Code> > translation = new List <CodedTypeR2 <Code> >(); translation.Add(new CodedTypeR2 <Code>()); codedType.Translation = translation; codedType.SimpleValue = "simple value"; codedType.Operator = SetOperator.CONVEX_HULL; codedType.Value = new BigDecimal("5"); codedType.ValidTime = new Interval <PlatformDate>(new PlatformDate(), SetOperator.CONVEX_HULL); codedType.Qty = 32; object convertedValue = CodedTypeR2Helper.ConvertCodedTypeR2(codedType, typeof(UnitsOfMeasureCaseSensitive)); Assert.IsTrue(convertedValue is CodedTypeR2 <UnitsOfMeasureCaseSensitive>); CodedTypeR2 <UnitsOfMeasureCaseSensitive> actualValue = (CodedTypeR2 <UnitsOfMeasureCaseSensitive>)convertedValue; Assert.AreEqual(codedType.Code, actualValue.Code); Assert.AreEqual(codedType.CodeSystemName, actualValue.CodeSystemName); Assert.AreEqual(codedType.CodeSystemVersion, actualValue.CodeSystemVersion); Assert.AreEqual(codedType.DisplayName, actualValue.DisplayName); Assert.AreEqual(codedType.NullFlavorForTranslationOnly, actualValue.NullFlavorForTranslationOnly); Assert.AreEqual(codedType.OriginalText, actualValue.OriginalText); Assert.AreEqual(codedType.Qualifier, actualValue.Qualifier); Assert.AreEqual(codedType.Translation, actualValue.Translation); Assert.AreEqual(codedType.SimpleValue, actualValue.SimpleValue); Assert.AreEqual(codedType.Operator, actualValue.Operator); Assert.AreEqual(codedType.Value, actualValue.Value); Assert.AreEqual(codedType.ValidTime, actualValue.ValidTime); Assert.AreEqual(codedType.Qty, actualValue.Qty); }
public virtual void TestConvertCodedTypeR2ToSpecificTypeNullArgument() { Assert.IsNull(CodedTypeR2Helper.ConvertCodedTypeR2(null, typeof(UnitsOfMeasureCaseSensitive))); }
public virtual void TestGetCodeInvalidArgument() { CodedTypeR2Helper.GetCode(new CS_R2Impl <UnitsOfMeasureCaseSensitive>()); }
public virtual void TestGetCodeValueInvalidArgument() { CodedTypeR2Helper.GetCodeValue(new CD_R2Impl <Code>()); }
public virtual void TestIsCodedTypeR2True() { Assert.IsTrue(CodedTypeR2Helper.IsCodedTypeR2(new CodedTypeR2 <Code>())); Assert.IsTrue(CodedTypeR2Helper.IsCodedTypeR2(new CodedTypeR2 <UnitsOfMeasureCaseSensitive>())); }
public virtual void TestIsCodedTypeR2NotTrue() { Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(null)); Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(new CDImpl())); Assert.IsFalse(CodedTypeR2Helper.IsCodedTypeR2(new CD_R2Impl <Code>())); }
public virtual void TestCreateSXCMInstance() { BareANY bareANY = CodedTypeR2Helper.CreateSXCMInstance(typeof(UnitsOfMeasureCaseSensitive)); Assert.IsTrue(bareANY is SXCM_R2Impl <CodedTypeR2 <UnitsOfMeasureCaseSensitive> >); }
public virtual void TestCreateCSList() { CollectionHelper list = CodedTypeR2Helper.CreateCSList(typeof(UnitsOfMeasureCaseSensitive)); Assert.IsTrue(list is LISTImpl <CS_R2 <UnitsOfMeasureCaseSensitive>, CodedTypeR2 <UnitsOfMeasureCaseSensitive> >); }
public virtual void TestConvertCodedTypeR2FromSpecificTypeNullArgument() { Assert.IsNull(CodedTypeR2Helper.ConvertCodedTypeR2(null)); }
private void ValidateNonstructuralFixedValue(Relationship relationship, BareANY value, Hl7Source source, IList <XmlNode> nodes ) { if (relationship.HasFixedValue()) { bool valueProvided = (value != null && value.BareValue != null); bool valid = valueProvided || (!ConformanceLevelUtil.IsMandatory(relationship) && !ConformanceLevelUtil.IsPopulated(relationship )); // optional and required fixed values do not have to provide a value, but if they do they must conform to specified value if (valueProvided) { if ("BL".Equals(relationship.Type) && value is BL) { string valueAsString = ((BL)value).Value.ToString(); valid = relationship.FixedValue.EqualsIgnoreCase(valueAsString); } else { if ("ST".Equals(relationship.Type) && value is ST) { string valueAsString = ((ST)value).Value.ToString(); valid = relationship.FixedValue.EqualsIgnoreCase(valueAsString); } else { if ("INT.POS".Equals(relationship.Type) && value is INT) { string valueAsString = ((INT)value).Value.ToString(); valid = relationship.FixedValue.EqualsIgnoreCase(valueAsString); } else { if (relationship.CodedType) { if (source.IsR2()) { if (GenericClassUtil.IsInstanceOfANY(value)) { object value2 = GenericClassUtil.GetValueFromANY(value); Code code = value2 == null ? null : CodedTypeR2Helper.GetCode(value2); valid = (code != null && code.CodeValue != null && StringUtils.Equals(relationship.FixedValue, code.CodeValue)); } } else { if (value is CD) { Code code = ((CD)value).Value; valid = (code.CodeValue != null && StringUtils.Equals(relationship.FixedValue, code.CodeValue)); } } } else { source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.SYNTAX_ERROR, "Non-structural fixed-value attribute '" + relationship .Name + "' was of unexpected type '" + relationship.Type + "'", CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[0])); } } } } } if (!valid) { source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.MANDATORY_FIELD_NOT_PROVIDED, "Fixed-value attribute '" + relationship .Name + "' must have value '" + relationship.FixedValue + "'", CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[0])); } } }