/// <summary> /// Determines the enum datatype for a given HL7 type name. /// </summary> /// /// <param name="name_0">the HL7 name of a datatype</param> /// <returns>the type enum corresponding to the input parameter name</returns> public static StandardDataType GetByTypeName(String name_0) { if (String.IsNullOrWhiteSpace(name_0)) { return(null); } StandardDataType result = null; name_0 = StringUtils.DeleteWhitespace(name_0); if (name_0 != null && name_0.EndsWith("_R2")) { name_0 = name_0.Substring(0, name_0.Length - 3); } if (IsList(name_0)) { result = StandardDataType.LIST; } else if (IsSet(name_0)) { result = StandardDataType.SET; } else if (isCollection(name_0)) { result = StandardDataType.COLLECTION; } else if (enumMap.ContainsKey(name_0)) { return(enumMap[name_0]); } return(result); }
private static void InitializeSimpleXmlMap() { if (simpleXmlMap == null) { IDictionary <String, StandardDataType> map = new Dictionary <String, StandardDataType>(); /* foreach */ foreach (StandardDataType type in Ca.Infoway.Messagebuilder.Lang.EnumPattern .GetEnumConstants(typeof(StandardDataType))) { String simpleXmlType_0 = type.simpleXmlType; if (Ca.Infoway.Messagebuilder.StringUtils.IsNotBlank(simpleXmlType_0)) { if (map.ContainsKey(simpleXmlType_0)) { StandardDataType other = ((Ca.Infoway.Messagebuilder.Datatype.StandardDataType)ILOG.J2CsMapping.Collections.Generics.Collections.Get(map, simpleXmlType_0)); if (String.Equals(other.RootType, type.RootType)) { ILOG.J2CsMapping.Collections.Generics.Collections.Put(map, (System.String)(simpleXmlType_0), (Ca.Infoway.Messagebuilder.Datatype.StandardDataType)(StandardDataType .GetByTypeName(type.RootType))); } else { throw new InvalidOperationException("Simple XML type " + simpleXmlType_0 + " is mapped to two incompatible types: " + type.Type + ", " + other.Type); } } else { ILOG.J2CsMapping.Collections.Generics.Collections.Put(map, (System.String)(simpleXmlType_0), (Ca.Infoway.Messagebuilder.Datatype.StandardDataType)(type)); } } } simpleXmlMap = ILOG.J2CsMapping.Collections.Generics.Collections.UnmodifiableMap(map); } }
public virtual void ShouldResolveSimpleXmlType() { Assert.AreEqual(StandardDataType.II, StandardDataType.ConvertSimpleXmlToDataType("InstanceIdentifier"), "II"); Assert.AreEqual(StandardDataType.TS_DATE, StandardDataType.ConvertSimpleXmlToDataType("PartialDate"), "TS.DATE"); }
/// <summary> /// Determines if the given datatype shares the same root HL7 datatype. /// </summary> /// /// <param name="dataType">the type to compare</param> /// <returns>whether the datatypes are eqivalent, that is, do they share the same root HL7 datatype</returns> public bool IsEquivalent(StandardDataType dataType) { return(dataType != null && RootType.Equals(dataType.RootType)); }