/// <summary> /// Constructs an EntityNamePart using the supplied parameters. /// This constructor may not make sense to have as public. May become private in a later release. /// </summary> /// <param name="value_ren"></param> /// <param name="type_0"></param> /// <param name="qualifier"></param> /// <param name="nullFlavor"></param> public EntityNamePart(String value_ren, NamePartType type_0, EntityNamePartQualifier qualifier, NullFlavor nullFlavor) { this.value_ren = value_ren; this.type = type_0; this.qualifier = qualifier; this.nullFlavor = nullFlavor; }
public NamePart(NamePartType type, String text) { if (type != NamePartType.NULL) { KnownType = type; } Value = text; }
private void SetValue(string name, string value, string system, NamePartType type, string description, int position, BehaviourType behaviour) { Name = name; Value = value; System = system; Type = type; Description = description; Position = position; Behaviour = behaviour; }
private void CheckPartTypeForOn(NamePartType type, FormatContext context) { // valid types are null, delimiter, prefix, suffix if (type != null) { string typeValue = type.Value == null ? null : type.Value.ToUpper(); //.NET conversion OrganizationNamePartType onType = EnumPattern.ValueOf <OrganizationNamePartType>(typeValue); if (onType == null) { RecordError(context, System.String.Format("Name parts of type {0} are not valid for ON data types. Only delimiter, prefix, suffix, and free-format text are allowed." , type.Value)); } } }
private IList <EntityNamePart> ParseNameParts(ParseContext context, XmlNodeList childNodes, XmlToModelResult xmlToModelResult ) { IList <EntityNamePart> parts = new List <EntityNamePart>(); foreach (XmlNode childNode in new XmlNodeListIterable(childNodes)) { if (childNode is XmlElement) { XmlElement element = (XmlElement)childNode; string name = NodeUtil.GetLocalOrTagName(element); if (!StringUtils.Equals(AbstractNameR2ElementParser <V> .VALID_TIME_ELEMENT, name)) { if (StringUtils.Equals("TN", context.Type)) { RecordError("TN fields only support text and a single (optional) validTime element. Found element: " + name, element, xmlToModelResult ); } else { NullFlavor nullFlavor = GetNullFlavor(element, xmlToModelResult); string value = GetTextValue(element, xmlToModelResult); EntityNamePartQualifier qualifier = GetQualifier(context, element, xmlToModelResult); if (StringUtils.IsNotBlank(value) || nullFlavor != null) { NamePartType namePartType = GetNamePartType(name, context.Type, element, xmlToModelResult); if (namePartType != null) { parts.Add(new EntityNamePart(value, namePartType, qualifier, nullFlavor)); } } } } } else { if (IsNonBlankTextNode(childNode)) { parts.Add(new EntityNamePart(childNode.Value.Trim(), null)); } } } return(parts); }
private NamePartType GetNamePartType(string value, string type, XmlElement element, XmlToModelResult xmlToModelResult) { NamePartType partType = null; try { if (StringUtils.Equals(AbstractNameR2ElementParser <V> .ORGANIZATION_NAME_TYPE, type)) { partType = GetNamePartType <OrganizationNamePartType>(value); } else { partType = GetNamePartType <PersonNamePartType>(value); } } catch (XmlToModelTransformationException e) { RecordError(e.Message, element, xmlToModelResult); } return(partType); }
// 1 warning stating EN treated as PN, 1 for missing "use" private void AssertNamePartAsExpected(string message, EntityNamePart namePart, NamePartType expectedType, string expectedValue ) { Assert.AreEqual(expectedType, namePart.Type, message + " type"); Assert.AreEqual(expectedValue, namePart.Value, message + " value"); }
public NamePart(string name, string value, string system, NamePartType type, string description, int position, BehaviourType behaviour) { SetValue(name, value, system, type, description, position, behaviour); }
private void AssertNamePartAsExpected(string message, EntityNamePart namePart, NamePartType expectedType, string expectedValue , string expectedQualifier) { AssertNamePartAsExpected(message, namePart, expectedType, expectedValue, expectedQualifier, null); }
/// <summary> /// Constructs an EntityNamePart using the supplied parameters. /// </summary> /// <param name="value_ren">the name part value</param> /// <param name="type_0">the name part type</param> public EntityNamePart(String value_ren, NamePartType type_0) : this(value_ren, type_0, null) { }
/** * Build out this name part with a type. * * @param type The type. * @return this. */ public NamePart SetType(NamePartType type) { KnownType = type; return(this); }
public EntityNamePart(NamePartType type_0, NullFlavor nullFlavor) : this(null, type_0, null, nullFlavor) { }
/// <summary> /// Constructs an EntityNamePart using the supplied parameters. /// </summary> /// /// <param name="value">the name part value</param> /// <param name="type_0">the name part type</param> public EntityNamePart(String value_ren, NamePartType type_0, EntityNamePartQualifier qualifier) : this(value_ren, type_0, qualifier, null) { }
private void ValidatePersonNameParts(PersonName personName, string type, Hl7BaseVersion baseVersion, XmlElement element, string propertyPath, Hl7Errors errors) { bool isBasic = StandardDataType.PN_BASIC.Type.Equals(type); bool isSimple = StandardDataType.PN_SIMPLE.Type.Equals(type); bool isFull = StandardDataType.PN_FULL.Type.Equals(type); bool isSearch = StandardDataType.PN_SEARCH.Type.Equals(type); int countBlankParts = 0; bool isCeRx = IsCeRx(baseVersion); int numParts = personName.Parts.Count; if (numParts > MAX_PARTS) { CreateError("A maximum of " + MAX_PARTS + " name parts are allowed. Found: " + numParts, element, propertyPath, errors); } foreach (EntityNamePart personNamePart in personName.Parts) { int partLength = StringUtils.Length(personNamePart.Value); if ((isCeRx && partLength > MAX_PART_LENGTH_CERX) || partLength > MAX_PART_LENGTH) { CreateError("Name part types have a maximum allowed length of " + (isCeRx ? MAX_PART_LENGTH_CERX : MAX_PART_LENGTH) + " (length found: " + partLength + ")", element, propertyPath, errors); } // error if part type not allowed NamePartType partType = personNamePart.Type; if (partType == null) { countBlankParts++; // no part type : only allowed for SIMPLE or, if CeRx, BASIC (max 1 in both cases) if (!isSimple && !(isBasic && isCeRx)) { CreateError("Names without a part type are not allowed", element, propertyPath, errors); } } else { if (!ALLOWABLE_NAME_PARTS.Contains(partType.Value)) { CreateError("Part type " + partType.Value + " is not allowed for " + type, element, propertyPath, errors); } } EntityNamePartQualifier qualifier = personNamePart.Qualifier; if (qualifier != null) { if (isCeRx || (!IsMr2007(baseVersion) && isBasic)) { if (!"IN".Equals(qualifier.CodeValue)) { CreateError("Qualifier '" + qualifier.CodeValue + "' not valid. Only 'IN' is allowed.", element, propertyPath, errors); } } else { if (!ALLOWABLE_NAME_PART_QUALIFIERS.Contains(qualifier.CodeValue)) { CreateError("Qualifier '" + qualifier.CodeValue + "' not valid.", element, propertyPath, errors); } } } } if (isSimple && (countBlankParts > 1 || numParts > 1 || (numParts > 0 && countBlankParts == 0))) { CreateError("For PN.SIMPLE, only one simple name (a name without a part type) is allowed, and no other name parts are allowed." , element, propertyPath, errors); } if ((isBasic && isCeRx) && ((countBlankParts > 1) || (countBlankParts == 1 && numParts > 1))) { CreateError("For CeRx PN.BASIC a name can be provided without a part type, but only a single simple name (i.e. a name without a part type) is allowed in this case. Multiple name parts can be provided, but then all name parts must have part types." , element, propertyPath, errors); } // confirmed with CHI that simple and basic types do not have to provide any name parts if (numParts == 0 && (isFull || isSearch)) { CreateError("At least one name part must be specified.", element, propertyPath, errors); } }
/** * Build up this name form with a part. * * @param partType The part type. * @param value The value. * @return this. */ public NameForm SetPart(NamePartType partType, String value) { AddPart(new NamePart(partType, value)); return(this); }
/** * Build up this name form with a part. * * @param partType The part type. * @param value The value. * @return this. */ public NameForm SetPart(NamePartType partType, String value) { AddPart(new NamePart(partType, value)); return this; }
/** * Build out this name part with a type. * * @param type The type. * @return this. */ public NamePart SetType(NamePartType type) { KnownType = type; return this; }
private void AssertNamePartAsExpected(string message, EntityNamePart namePart, NamePartType expectedType, string expectedValue , string expectedQualifier) { Assert.AreEqual(expectedType, namePart.Type, message + " type"); Assert.AreEqual(expectedValue, namePart.Value, message + " value"); Assert.AreEqual(expectedQualifier, namePart.Qualifier == null ? null : namePart.Qualifier.CodeValue, message + " qualifier" ); }
public string ExtractName(Person gxPerson, NamePartType namePartType) { return(gxPerson.Names?.FirstOrDefault()?.NameForm?.Parts ?.FirstOrDefault(p => p.KnownType == namePartType)?.Value ?? ""); }