private static void RemovePartType(object bean, IList <string> pathParts) { if (CollUtils.IsNotEmpty(pathParts)) { if (HasPartType(bean, pathParts[0])) { pathParts.RemoveAt(0); } } }
public virtual IList <SchematronContext> GetAllSchematronContexts(VersionNumber version) { MessageSet messageSet = FindMessageSet(version); if (messageSet != null) { return(messageSet.SchematronContexts); } return(CollUtils.EmptyList <SchematronContext>()); }
/// <summary>Get all children of a particular tag name as a list.</summary> /// <remarks>Get all children of a particular tag name as a list.</remarks> /// <param name="node">- the parent node</param> /// <param name="tagName">- the tag name to select</param> /// <returns>- the list of nodes</returns> public static IList <XmlNode> GetChildNodes(XmlNode node, string tagName) { if (node.NodeType != System.Xml.XmlNodeType.Element) { return(CollUtils.EmptyList <XmlNode>()); } else { return(AsList(((XmlElement)node).GetElementsByTagName(tagName))); } }
static TsDateFormats() { IDictionary <StandardDataType, IList <string> > map = new Dictionary <StandardDataType, IList <string> >(); map[StandardDataType.TS_FULLDATETIME] = Arrays.AsList("yyyyMMddHHmmss.SSS0ZZZZZ", "yyyyMMddHHmmss.SSSZZZZZ", "yyyyMMddHHmmssZZZZZ" ); map[StandardDataType.TS_FULLDATEPARTTIME] = Arrays.AsList("yyyyMMddHHmmss.SSS0ZZZZZ", "yyyyMMddHHmmss.SSS0", "yyyyMMddHHmmss.SSSZZZZZ" , "yyyyMMddHHmmss.SSS", "yyyyMMddHHmmssZZZZZ", "yyyyMMddHHmmss", "yyyyMMddHHmmZZZZZ", "yyyyMMddHHmm", "yyyyMMddHHZZZZZ", "yyyyMMddHH", "yyyyMMddZZZZZ", "yyyyMMdd"); // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx map[StandardDataType.TS_FULLDATE] = Arrays.AsList("yyyyMMdd"); // this is an abstract type and these formats are only used after issuing a warning (there should be a specializationType); only defined in MR2009 map[StandardDataType.TS_FULLDATEWITHTIME] = Arrays.AsList("yyyyMMddHHmmss.SSS0ZZZZZ", "yyyyMMddHHmmss.SSSZZZZZ", "yyyyMMddHHmmssZZZZZ" , "yyyyMMdd"); map[StandardDataType.TS_DATE] = Arrays.AsList("yyyyMMdd", "yyyyMM", "yyyy"); map[StandardDataType.TS_DATETIME] = Arrays.AsList("yyyyMMddHHmmss.SSS0ZZZZZ", "yyyyMMddHHmmss.SSS0", "yyyyMMddHHmmss.SSSZZZZZ" , "yyyyMMddHHmmss.SSS", "yyyyMMddHHmmssZZZZZ", "yyyyMMddHHmmss", "yyyyMMddHHmmZZZZZ", "yyyyMMddHHmm", "yyyyMMddHHZZZZZ", "yyyyMMddHH", "yyyyMMddZZZZZ", "yyyyMMdd", "yyyyMMZZZZZ", "yyyyMM", "yyyyZZZZZ", "yyyy"); // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx // not allowed if non-CeRx map[StandardDataType.TS] = map.SafeGet(StandardDataType.TS_DATETIME); formats = Ca.Infoway.Messagebuilder.CollUtils.CreateUnmodifiableDictionary(map); datetimeFormatsRequiringWarning = Arrays.AsList("yyyyMMddHHmmss.SSS0", "yyyyMMddHHmmss.SSS", "yyyyMMddHHmmss", "yyyyMMddHHmm" , "yyyyMMddHH"); IDictionary <string, string> _expandedFormats = new Dictionary <string, string>(); _expandedFormats["yyyyMMddHHmmss.SSSZZZZZ"] = "yyyyMMddHHmmss.SSS0ZZZZZ"; _expandedFormats["yyyyMMddHHmmss.SSS"] = "yyyyMMddHHmmss.SSS0"; expandedFormats = Ca.Infoway.Messagebuilder.CollUtils.CreateUnmodifiableDictionary(_expandedFormats); // some older versions have slightly different rules for allowable time formats IDictionary <StandardDataType, IList <string> > exceptionMapMR2007 = new Dictionary <StandardDataType, IList <string> >(); exceptionMapMR2007[StandardDataType.TS_FULLDATEWITHTIME] = CollUtils.EmptyList <string>(); IDictionary <StandardDataType, IList <string> > exceptionMapCeRx = new Dictionary <StandardDataType, IList <string> >(); exceptionMapCeRx[StandardDataType.TS_FULLDATEWITHTIME] = CollUtils.EmptyList <string>(); exceptionMapCeRx[StandardDataType.TS_FULLDATETIME] = Arrays.AsList("yyyyMMddHHmmss"); exceptionMapCeRx[StandardDataType.TS_DATETIME] = Arrays.AsList("yyyyMMddHHmmss.SSS0", "yyyyMMddHHmmss.SSS", "yyyyMMddHHmmss" , "yyyyMMddHHmm", "yyyyMMddHH", "yyyyMMdd", "yyyyMM", "yyyy"); IDictionary <Hl7BaseVersion, IDictionary <StandardDataType, IList <string> > > versionMap = new Dictionary <Hl7BaseVersion, IDictionary <StandardDataType, IList <string> > >(); versionMap[Hl7BaseVersion.MR2007] = Ca.Infoway.Messagebuilder.CollUtils.CreateUnmodifiableDictionary(exceptionMapMR2007); versionMap[Hl7BaseVersion.CERX] = Ca.Infoway.Messagebuilder.CollUtils.CreateUnmodifiableDictionary(exceptionMapCeRx); versionFormatExceptions = Ca.Infoway.Messagebuilder.CollUtils.CreateUnmodifiableDictionary(versionMap); }
/// <summary> /// Get all the message parts for a particular version. /// </summary> /// /// <param name="version">- the version</param> /// <returns>- the message parts</returns> public virtual ICollection <MessagePart> GetAllMessageParts(VersionNumber version) { foreach (MessageDefinitionService service in this.services) { ICollection <MessagePart> allMessageParts = service.GetAllMessageParts(version); if (allMessageParts != null && !allMessageParts.IsEmpty()) { return(allMessageParts); } } return(CollUtils.EmptyList <MessagePart>()); }
private IList <string> GetMapping(BeanProperty property) { Hl7XmlMappingAttribute annotation = property.GetAnnotation <Hl7XmlMappingAttribute>(); if (annotation != null) { return(Arrays.AsList(annotation.Value)); } else { return(CollUtils.EmptyList <string>()); } }
public static string[] GetAllDateFormats(StandardDataType standardDataType, VersionNumber version) { if (standardDataType == null || version == null) { return(new string[0]); } IDictionary <StandardDataType, IList <string> > exceptionMap = TsDateFormats.versionFormatExceptions.SafeGet(version.GetBaseVersion ()); IList <string> formats = (exceptionMap == null ? null : exceptionMap.SafeGet(standardDataType)); if (formats == null) { formats = TsDateFormats.formats.SafeGet(standardDataType); } return(CollUtils.IsEmpty(formats) ? new string[0] : formats.ToArray(new string[formats.Count])); }
public virtual IList <BaseRelationshipBridge> GetRelationshipBridges() { return(CollUtils.EmptyList <BaseRelationshipBridge>()); }
private PartBridge CreateNullPartBridge(Relationship relationship, Interaction interaction) { RelationshipSorter sorter = RelationshipSorter.Create(relationship.Name, null); MessagePartHolder currentMessagePart = GetMessagePart(interaction, relationship, null); if (currentMessagePart != null) { return(CreatePartBridge(sorter, interaction, currentMessagePart, new BridgeContext(), true)); } else { return(new PartBridgeImpl(relationship.Name, null, relationship.Type, CollUtils.EmptyList <BaseRelationshipBridge>(), false , true)); } }
/// <summary>Create a XML start element.</summary> /// <remarks>Create a XML start element.</remarks> /// <param name="name">- the tag name.</param> /// <param name="nameSpace">- namespace of the tag name</param> /// <param name="indentLevel">- the indent level</param> /// <param name="close">- indicates whether or not close the element.</param> /// <param name="lineBreak">- indicates whether or not to include a line break</param> /// <returns>- the formatted result.</returns> public static string CreateStartElement(string name, string nameSpace, int indentLevel, bool close, bool lineBreak) { return(CreateStartElement(name, nameSpace, CollUtils.EmptyList <KeyValuePair <string, string> >(), indentLevel, close, lineBreak )); }
public virtual ICollection <PartBridge> GetAssociationValues() { return(IsEmpty() ? CollUtils.EmptyList <PartBridge>() : this.parts); }
private void ValidatePostalAddressParts(PostalAddress postalAddress, string type, VersionNumber version, XmlElement element , string propertyPath, Hl7Errors errors) { int countBlankParts = 0; bool isBasic = StandardDataType.AD_BASIC.Type.Equals(type); bool isSearch = StandardDataType.AD_SEARCH.Type.Equals(type); bool isFull = StandardDataType.AD_FULL.Type.Equals(type); bool isAd = StandardDataType.AD.Type.Equals(type); foreach (PostalAddressPart postalAddressPart in postalAddress.Parts) { int partLength = StringUtils.Length(postalAddressPart.Value); if (partLength > MAX_PART_LENGTH) { // value max length of 80 CreateError("Address part types have a maximum allowed length of " + MAX_PART_LENGTH + " (length found: " + partLength + ")", element, propertyPath, errors); } // error if part type not allowed PostalAddressPartType partType = postalAddressPart.Type; if (partType == null) { countBlankParts++; // no part type : only allowed for BASIC (max 4, plus max 4 delimiter) if (!isBasic) { CreateError("Text without an address part only allowed for AD.BASIC", element, propertyPath, errors); } } else { if (partType == PostalAddressPartType.DELIMITER) { if (isSearch) { CreateError("Part type " + partType.Value + " is not allowed for AD.SEARCH", element, propertyPath, errors); } } else { if (isFull || isAd) { if (!PostalAddressPartType.IsFullAddressPartType(partType)) { CreateError("Part type " + partType.Value + " is not allowed for AD or AD.FULL", element, propertyPath, errors); } } else { if (!PostalAddressPartType.IsBasicAddressPartType(partType)) { CreateError("Part type " + partType.Value + " is not allowed for AD.BASIC or AD.SEARCH", element, propertyPath, errors); } } } } // code/codesystem are only for state/country if (postalAddressPart.Code != null) { if (partType != PostalAddressPartType.STATE && partType != PostalAddressPartType.COUNTRY) { CreateError("Part type " + partType.Value + " is not allowed to specify code or codeSystem", element, propertyPath, errors ); } } } if (isBasic && countBlankParts > MAX_DELIMITED_LINES) { CreateError("AD.BASIC is only allowed a maximum of " + MAX_DELIMITED_LINES + " delimiter-separated address lines (address lines without an address part type)" , element, propertyPath, errors); } if (isSearch && CollUtils.IsEmpty(postalAddress.Parts)) { CreateError("AD.SEARCH must specify at least one part type", element, propertyPath, errors); } // city/state/postalCode/country mandatory for AD.FULL // new change for R02.05 (pre-adopted by R02.04.03 AB) onwards - these fields are now only *required*, not mandatory if (isFull && !SpecificationVersion.IsExactVersion(SpecificationVersion.R02_04_03_AB, version)) { ValidatePartTypeProvided(PostalAddressPartType.CITY, postalAddress.Parts, element, propertyPath, errors); ValidatePartTypeProvided(PostalAddressPartType.STATE, postalAddress.Parts, element, propertyPath, errors); ValidatePartTypeProvided(PostalAddressPartType.POSTAL_CODE, postalAddress.Parts, element, propertyPath, errors); ValidatePartTypeProvided(PostalAddressPartType.COUNTRY, postalAddress.Parts, element, propertyPath, errors); } }
private EntityNamePart GetFirstPart(PersonName name, PersonNamePartType type) { IList <EntityNamePart> parts = FilterParts(name, type); return((CollUtils.IsEmpty(parts)) ? null : parts[0]); }
/// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception> public override BareANY Parse(ParseContext context, IList <XmlNode> nodes, XmlToModelResult xmlToModelResult) { xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Data type \"" + context.Type + "\" is not part of the pan-Canadian standard" , CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[0])); return(base.Parse(context, nodes, xmlToModelResult)); }
private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> ParseNameUses(string usesString, XmlElement element, XmlToModelResult xmlToModelResult) { ICollection <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse >()); if (StringUtils.IsNotBlank(usesString)) { StringTokenizer tokenizer = new StringTokenizer(usesString); while (tokenizer.HasMoreElements()) { string token = tokenizer.NextToken(); Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse nameUse = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.Basic.EntityNameUse >(token); if (nameUse != null) { uses.Add(nameUse); } else { RecordError("Name use '" + token + "' not recognized.", element, xmlToModelResult); } } } return(uses); }
public virtual bool HasPartTypeMappings() { return(CollUtils.IsNotEmpty(this.mappings)); }
private static IList <Mapping> From(Hl7XmlMappingAttribute mapping, Hl7MapByPartTypeAttribute[] exceptions) { return(mapping == null?CollUtils.EmptyList <Mapping>() : From(Arrays.AsList(mapping.Value), exceptions)); }
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])); } } }
/// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception> private void WriteAttribute(BeanWrapper bean, Hl7Source source, IList <XmlNode> nodes, Relationship relationship, string traversalName ) { if (relationship.Structural) { source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "Data found for relationship as an element but should have been an attribute. " + (nodes.IsEmpty() ? ("(" + relationship.Name + ")") : XmlDescriber.DescribePath(nodes[0])), CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[0])); } string type = DetermineType(nodes, relationship, source, source.GetResult()); ElementParser parser = (source.IsR2() ? ParserR2Registry.GetInstance().Get(type) : ParserRegistry.GetInstance().Get(type) ); if (parser != null) { try { ConstrainedDatatype constraints = source.GetService().GetConstraints(source.GetVersion(), relationship.ConstrainedType); ParseContextImpl context = new ParseContextImpl(relationship, constraints, source.GetVersion(), source.GetDateTimeZone(), source.GetDateTimeTimeZone(), CodeTypeRegistry.GetInstance(), source.IsCda()); BareANY @object = parser.Parse(context, nodes, source.GetResult()); ChangeDatatypeIfNecessary(type, relationship, @object); if (relationship.HasFixedValue()) { ValidateNonstructuralFixedValue(relationship, @object, source, nodes); } else { // fixed means nothing to write to bean bean.Write(relationship, @object); } } catch (InvalidCastException e) { source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "Can't parse relationship name=" + relationship. Name + ", traversalName=" + traversalName + " [" + e.Message + "]", CollUtils.IsEmpty(nodes) ? null : (XmlElement)nodes[ 0])); } } else { source.GetResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "No parser for type \"" + type + "\". " + (nodes .IsEmpty() ? ("(" + relationship.Name + ")") : XmlDescriber.DescribePath(nodes[0])), CollUtils.IsEmpty(nodes) ? null : ( XmlElement)nodes[0])); } }
private ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> ParseAddressUses(string nameUseAttribute, XmlNode node, XmlToModelResult xmlToModelResult) { ICollection <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse> uses = CollUtils.SynchronizedSet(new LinkedSet <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse >()); if (nameUseAttribute != null) { StringTokenizer tokenizer = new StringTokenizer(nameUseAttribute); while (tokenizer.HasMoreElements()) { string token = tokenizer.NextToken(); Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse postalAddressUse = CodeResolverRegistry.Lookup <Ca.Infoway.Messagebuilder.Domainvalue.PostalAddressUse >(token); if (postalAddressUse == null) { // error if a use is not found RecordError("PostalAddressUse '" + token + "' is not valid", (XmlElement)node, xmlToModelResult); } else { uses.Add(postalAddressUse); } } } return(uses); }