private void ValidateCodeExists(Code value, string domainType, VersionNumber version, bool isCda, string propertyPath, Hl7Errors errors) { Type returnType = null; if (StringUtils.IsNotBlank(domainType)) { returnType = (Type)DomainTypeHelper.GetReturnType(domainType, version, CodeTypeRegistry.GetInstance()); } if (returnType == null) { // for CDA usage, domainType not always supplied if (!isCda) { errors.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Could not locate a registered domain type to match \"" + domainType + "\"", propertyPath)); } } else { if (GetCode(returnType, value.CodeValue, value.CodeSystem) == null) { errors.AddHl7Error(CreateCodeValueNotFoundError(value, returnType, propertyPath)); } } }
internal static object GetFixedValue(Relationship relationship, VersionNumber version, bool isR2, Hl7Errors errors, string propertyPath) { string fixedValue = relationship.FixedValue; if (StringUtils.Equals("BL", relationship.Type)) { return(true.ToString().EqualsIgnoreCase(fixedValue)); } else { if (StringUtils.Equals("INT.POS", relationship.Type)) { return(System.Convert.ToInt32(fixedValue)); } else { if (StringUtils.Equals("ST", relationship.Type)) { return(fixedValue); } else { if (relationship.CodedType) { Type codeType = DomainTypeHelper.GetReturnType(relationship, version, CodeTypeRegistry.GetInstance()); if (codeType == null) { codeType = typeof(Code); } Code code = CodeResolverRegistry.Lookup(codeType, fixedValue); if (code == null) { string message = System.String.Format("Fixed code lookup could not find match for {0}.{1}", relationship.DomainType, fixedValue ); errors.AddHl7Error(new Hl7Error(Hl7ErrorCode.VALUE_NOT_IN_CODE_SYSTEM, ErrorLevel.WARNING, message, propertyPath)); } //Fixup for .NET if (isR2) { return(code == null ? null : new CodedTypeR2 <Code>(code)); } else { return(code); } } else { throw new MarshallingException("Cannot handle a fixed relationship of type: " + relationship.Type); } } } } }
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 System.Type GetExpectedReturnType() { return(DomainTypeHelper.GetReturnType(this.relationship, this.version, this.codeTypeHandler)); }
public Type GetTypeAsClass(String version) { return(DomainTypeHelper.GetReturnType(this.type, version, CodeTypeRegistry.GetInstance())); }