private bool AdaptValue(string dataType) { Hl7DataTypeName type = Hl7DataTypeName.Create(dataType); string typeName = StringUtils.DeleteWhitespace(type.GetUnqualifiedVersion().ToString()); return("LIST<SXCM<TS>>".Equals(typeName)); }
protected virtual string CreateElement(FormatContext context, string name, QTY <T> value, Boolean?inclusive, bool isSxcm, int indentLevel) { string type = Hl7DataTypeName.GetParameterizedType(context.Type); if (isSxcm) { type = "SXCM<" + type + ">"; } PropertyFormatter formatter = FormatterR2Registry.GetInstance().Get(type); if (formatter != null) { bool isSpecializationType = false; FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, isSpecializationType , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, Cardinality.Create("1"), name, context); string result = formatter.Format(newContext, value, indentLevel); if (inclusive != null) { // TM - small hack to add in the inclusive attribute (low/high) (operator, simple only, is already formatted by using the SXCM type) result = result.ReplaceFirst(" value=", " inclusive=\"" + inclusive.ToString().ToLower() + "\" value="); } return(result); } else { throw new ModelToXmlTransformationException("No formatter found for " + type); } }
protected override string FormatDenominator(FormatContext context, PhysicalQuantity denominator, int indentLevel) { string denominatorType = Hl7DataTypeName.Create(context.Type).GetInnerTypes()[1].ToString(); FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(denominatorType, context .IsSpecializationType(), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), "denominator" , context); return(this.pqFormatter.Format(newContext, new PQImpl(denominator), indentLevel)); }
//http://www.hl7.org/v3ballot/html/infrastructure/itsxml/datatypes-its-xml.htm#dtimpl-RTO protected override string FormatNumerator(FormatContext context, Money numerator, int indentLevel) { string numeratorType = Hl7DataTypeName.Create(context.Type).GetInnerTypes()[0].ToString(); FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(numeratorType, context .IsSpecializationType(), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), "numerator", context); return(this.moFormatter.Format(newContext, new MOImpl(numerator), indentLevel)); }
private CollectionHelper CreateCollectionHelper(string dataType, Type expectedReturnType) { Hl7DataTypeName type = Hl7DataTypeName.Create(dataType); string typeName = StringUtils.DeleteWhitespace(type.GetUnqualifiedVersion().ToString()); CollectionHelper result = typeName.StartsWith("LIST") ? HandleListTypes(typeName, expectedReturnType) : HandleBagTypes(typeName ); if (result == null) { throw new MarshallingException("Cannot create a data type construct for data type " + dataType); } return(result); }
/// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception> private string GetSubType(ParseContext context) { string subType = Hl7DataTypeName.GetParameterizedType(context.Type); if (StringUtils.IsNotBlank(subType)) { return(subType); } else { throw new XmlToModelTransformationException("Cannot find the sub type for " + context.Type); } }
private CollectionHelper CreateCollectionHelper(string dataType) { Hl7DataTypeName type = Hl7DataTypeName.Create(dataType); string typeName = StringUtils.DeleteWhitespace(type.GetUnqualifiedVersion().ToString()); if ("BAG<AD>".Equals(typeName)) { return(new LISTImpl <AD, PostalAddress>(typeof(ADImpl))); } else { if ("BAG<GTS>".Equals(typeName)) { return(new LISTImpl <GTS, GeneralTimingSpecification>(typeof(GTSImpl))); } else { if ("BAG<II>".Equals(typeName)) { return(new LISTImpl <II, Identifier>(typeof(IIImpl))); } else { if ("BAG<PN>".Equals(typeName)) { return(new LISTImpl <PN, PersonName>(typeof(PNImpl))); } else { if ("BAG<ST>".Equals(typeName)) { return(new LISTImpl <ST, string>(typeof(STImpl))); } else { if ("BAG<TEL>".Equals(typeName)) { return(new LISTImpl <TEL, TelecommunicationAddress>(typeof(TELImpl))); } else { throw new MarshallingException("Cannot create a data type construct for data type " + dataType); } } } } } } }
protected virtual string CreateElement(FormatContext context, string name, QTY <T> value, int indentLevel) { string type = Hl7DataTypeName.GetParameterizedType(context.Type); PropertyFormatter formatter = FormatterRegistry.GetInstance().Get(type); if (formatter != null) { bool isSpecializationType = false; return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, isSpecializationType , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, Cardinality.Create("1"), name, context), value, indentLevel)); } else { throw new ModelToXmlTransformationException("No formatter found for " + type); } }
protected override Ratio <N, D> ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType , XmlToModelResult xmlToModelResult) { Ratio <N, D> result = new Ratio <N, D>(); IList <Hl7DataTypeName> innerTypes = Hl7DataTypeName.Create(context.Type).GetInnerTypes(); if (innerTypes.Count != 2) { // this should never happen unless a message set is incorrect; ok to abort with exception (parsing will continue after this datatype) throw new XmlToModelTransformationException("RTO data type must have two inner types. Type " + context.Type + " has " + innerTypes .Count + "."); } bool numeratorFound = false; bool denominatorFound = false; XmlNodeList childNodes = node.ChildNodes; foreach (XmlNode childNode in new XmlNodeListIterable(childNodes)) { if (childNode is XmlElement) { XmlElement element = (XmlElement)childNode; string name = NodeUtil.GetLocalOrTagName(element); if ("numerator".Equals(name)) { numeratorFound = true; result.Numerator = GetNumeratorValue(element, innerTypes[0].ToString(), context, xmlToModelResult); } else { if ("denominator".Equals(name)) { denominatorFound = true; result.Denominator = GetDenominatorValue(element, innerTypes[1].ToString(), context, xmlToModelResult); } } } } if (!numeratorFound) { RecordMissingElementError("Numerator", context, node, xmlToModelResult); } if (!denominatorFound) { RecordMissingElementError("Denominator", context, node, xmlToModelResult); } return(result); }
private bool IsValidTypeForAny(string parentType, string specializationType) { if (StringUtils.IsBlank(specializationType)) { return(false); } bool valid = AnyHelper.IsValidTypeForAny(parentType, specializationType); if (!valid) { // unqualify only the inner types string innerUnqualified = Hl7DataTypeName.UnqualifyInnerTypes(specializationType); valid = AnyHelper.IsValidTypeForAny(parentType, innerUnqualified); } if (!valid) { // unqualify both outer and inner types) string bothUnqualified = Hl7DataTypeName.Unqualify(specializationType); valid = AnyHelper.IsValidTypeForAny(parentType, bothUnqualified); } return(valid); }
protected virtual string CreateWidthElement(FormatContext context, string name, BareDiff diff, int indentLevel) { if (IsTimestamp(context)) { return(CreateTimestampWidthElement(context, name, diff, indentLevel)); } else { string type = Hl7DataTypeName.GetParameterizedType(context.Type); PropertyFormatter formatter = FormatterRegistry.GetInstance().Get(type); if (formatter != null) { bool isSpecializationType = false; return(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(type, isSpecializationType , Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), name, context), WrapWithHl7DataType (type, diff), indentLevel)); } else { throw new ModelToXmlTransformationException("No formatter found for " + type); } } }
private bool IsTimestamp(FormatContext context) { return("TS".Equals(Hl7DataTypeName.Unqualify(Hl7DataTypeName.GetParameterizedType(context.Type)))); }
private string GetParameterizedType(ParseContext context) { return(Hl7DataTypeName.GetParameterizedType(context.Type)); }
private bool IsTimestampType(ParseContext context) { string type = GetParameterizedType(context); return("TS".Equals(Hl7DataTypeName.Unqualify(type))); }
private CollectionHelper CreateCollectionHelper(string dataType) { Hl7DataTypeName type = Hl7DataTypeName.Create(dataType); string typeName = StringUtils.DeleteWhitespace(type.GetUnqualifiedVersion().ToString()); if ("SET<CV>".Equals(typeName)) { return(new SETImpl <CV, Code>(typeof(CVImpl))); } else { if ("SET<II>".Equals(typeName)) { return(new SETImpl <II, Identifier>(typeof(IIImpl))); } else { if ("SET<PIVL>".Equals(typeName)) { return(new SETImpl <PIVL, PeriodicIntervalTime>(typeof(PIVLImpl))); } else { if ("SET<PN>".Equals(typeName)) { return(new SETImpl <PN, PersonName>(typeof(PNImpl))); } else { if ("SET<RTO<PQ,PQ>>".Equals(typeName)) { return(new SETImpl <RTO <PhysicalQuantity, PhysicalQuantity>, Ratio <PhysicalQuantity, PhysicalQuantity> >(typeof(RTOImpl <object , object>))); } else { if ("SET<ST>".Equals(typeName)) { return(new SETImpl <ST, string>(typeof(STImpl))); } else { if ("SET<TEL>".Equals(typeName)) { return(new SETImpl <TEL, TelecommunicationAddress>(typeof(TELImpl))); } else { if ("SET<TS>".Equals(typeName)) { return(new SETImpl <TS, PlatformDate>(typeof(TSImpl))); } else { if ("SET<CD>".Equals(typeName)) { return(new SETImpl <CD, Code>(typeof(CDImpl))); } else { if ("SET<CS>".Equals(typeName)) { return(new SETImpl <CS, Code>(typeof(CSImpl))); } else { if ("SET<AD>".Equals(typeName)) { return(new SETImpl <AD, PostalAddress>(typeof(ADImpl))); } else { if ("SET<TN>".Equals(typeName)) { return(new SETImpl <TN, TrivialName>(typeof(TNImpl))); } else { throw new MarshallingException("Cannot create a data type construct for data type " + dataType); } } } } } } } } } } } } }
private ParseContext ConvertContext(ParseContext context) { string newType = "IVL<" + Hl7DataTypeName.GetParameterizedType(context.Type) + ">"; return(ParseContextImpl.CreateWithConstraints(newType, context)); }
private CollectionHelper CreateCollectionHelper(string dataType) { Hl7DataTypeName type = Hl7DataTypeName.Create(dataType); string typeName = StringUtils.DeleteWhitespace(type.GetUnqualifiedVersion().ToString()); if ("LIST<AD>".Equals(typeName)) { return(new LISTImpl <AD, PostalAddress>(typeof(ADImpl))); } else { if ("LIST<GTS>".Equals(typeName)) { return(new LISTImpl <GTS, GeneralTimingSpecification>(typeof(GTSImpl))); } else { if ("LIST<II>".Equals(typeName)) { return(new LISTImpl <II, Identifier>(typeof(IIImpl))); } else { if ("LIST<PN>".Equals(typeName)) { return(new LISTImpl <PN, PersonName>(typeof(PNImpl))); } else { if ("LIST<TEL>".Equals(typeName)) { return(new LISTImpl <TEL, TelecommunicationAddress>(typeof(TELImpl))); } else { if ("LIST<ON>".Equals(typeName)) { return(new LISTImpl <ON, OrganizationName>(typeof(ONImpl))); } else { if ("LIST<CD>".Equals(typeName)) { return(new LISTImpl <CD, Code>(typeof(CDImpl))); } else { if ("LIST<CS>".Equals(typeName)) { return(new LISTImpl <CS, Code>(typeof(CSImpl))); } else { if ("LIST<CE>".Equals(typeName)) { return(new LISTImpl <CE, Code>(typeof(CEImpl))); } else { if ("LIST<SXCM<TS>>".Equals(typeName)) { return(new LISTImpl <SXCM <TS>, SetComponent <TS> >(typeof(TSImpl))); } else { if ("LIST<ANY>".Equals(typeName)) { return(new LISTImpl <ANY <object>, object>(typeof(ANYImpl <object>))); } else { if ("LIST<INT>".Equals(typeName)) { return(new LISTImpl <INT, Int32?>(typeof(INTImpl))); } else { if ("LIST<PQ>".Equals(typeName)) { return(new LISTImpl <PQ, PhysicalQuantity>(typeof(PQImpl))); } else { if ("LIST<ST>".Equals(typeName)) { return(new LISTImpl <ST, string>(typeof(STImpl))); } else { if ("LIST<SXCMTSCDAR1>".Equals(typeName)) { return(new LISTImpl <SXCMTSCDAR1, MbDate>(typeof(SXCMTSCDAR1Impl))); } else { throw new MarshallingException("Cannot create a data type construct for data type " + dataType); } } } } } } } } } } } } } } } }