Пример #1
0
	/// <summary> Parses the value string into a recognized type. If
	/// the type specified is not supported, the data will
	/// be held and returned as a string.
	/// *
	/// </summary>
	/// <param name="key">the context key for the data
	/// </param>
	/// <param name="type">the data type
	/// </param>
	/// <param name="value">the data
	///
	/// </param>
	public DataInfo(System.String key, System.String type, System.String value_Renamed) {
	    this.key = key;

	    if (type.ToUpper().Equals(TYPE_BOOLEAN.ToUpper())) {
		this.data = System.Boolean.Parse(value_Renamed);
	    } else if (type.ToUpper().Equals(TYPE_NUMBER.ToUpper())) {
		if (value_Renamed.IndexOf((System.Char) '.') >= 0) {
		    //UPGRADE_TODO: Format of parameters of constructor 'java.lang.Double.Double' are different in the equivalent in .NET. 'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="jlca1092"'
		    this.data = System.Double.Parse(value_Renamed);
		} else {
		    this.data = System.Int32.Parse(value_Renamed);
		}
	    } else {
		this.data = value_Renamed;
	    }
	}
Пример #2
0
        private static System.Drawing.Bitmap CreateBarcode(System.String data)
        {
            data = data.ToUpper();

            Bitmap barCode = new Bitmap(1, 1);

            Font threeOfNine = new Font("Free 3 of 9", 60, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
            Font timesNR = new Font("Times New Roman", 20, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);

            Graphics graphics = Graphics.FromImage(barCode);

            SizeF dataSize = new SizeF();

            SizeF dataSize_bar = graphics.MeasureString(data, threeOfNine);
            SizeF dataSize_text = graphics.MeasureString(data, timesNR);

            if (dataSize_bar.Width > dataSize_text.Width)
            {
                dataSize.Width = dataSize_bar.Width;
            }
            else
            {
                dataSize.Width = dataSize_text.Width;
            }

            dataSize.Height = (dataSize_bar.Height + dataSize_text.Height);

            barCode = new Bitmap(barCode, dataSize.ToSize());

            graphics = Graphics.FromImage(barCode);

            graphics.Clear(Color.White);

            graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixel;

            graphics.DrawString(data, threeOfNine, new SolidBrush(Color.Black), ((dataSize.Width / 2f) - (dataSize_bar.Width / 2f)), 0);
            graphics.DrawString(data, timesNR, new SolidBrush(Color.Black), ((dataSize.Width / 2f) - (dataSize_text.Width / 2f)), dataSize_bar.Height);

            graphics.Flush();

            threeOfNine.Dispose();

            graphics.Dispose();

            return barCode;
        }
Пример #3
0
        /// <summary> Changes the analysis level of the KAIST morpheme tag.</summary>
        /// <param name="tag">- morpheme tag
        /// </param>
        /// <param name="level">- the analysis level
        /// </param>
        /// <returns> the morpheme tag on the analysis level
        /// </returns>
        public static System.String getKaistTagOnLevel(System.String tag, int level)
        {
            if (tag == null || level > 4 || level < 1)
            {
                return null;
            }

            int tagLen = tag.Length;
            if (tagLen > level)
            {
                return tag.Substring(0, (level) - (0)).ToUpper();
            }
            else
            {
                return tag.ToUpper();
            }
        }
		/// <summary> Queries the normative database for a list of segments comprising
		/// the message structure.  The returned list may also contain strings
		/// that denote repetition and optionality.  Choice indicators (i.e. begin choice,
		/// next choice, end choice) for alternative segments are ignored, so that the class
		/// structure allows all choices.  The matter of enforcing that only a single choice is
		/// populated can't be handled by the class structure, and should be handled elsewhere.
		/// </summary>
		private static NuGenSegmentDef[] getSegments(System.String message, System.String version)
		{
			/*String sql = "select HL7Segments.seg_code, repetitional, optional, description " +
			"from (HL7MsgStructIDSegments inner join HL7Segments on HL7MsgStructIDSegments.seg_code = HL7Segments.seg_code " +
			"and HL7MsgStructIDSegments.version_id = HL7Segments.version_id) " +
			"where HL7Segments.version_id = 6 and message_structure = '" + message + "' order by seq_no";*/
			System.String sql = getSegmentListQuery(message, version);
			//System.out.println(sql.toString()); 	
			NuGenSegmentDef[] segments = new NuGenSegmentDef[200]; //presumably there won't be more than 200
			System.Data.OleDb.OleDbConnection conn = NuGenNormativeDatabase.Instance.Connection;
			System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
			System.Data.OleDb.OleDbCommand temp_OleDbCommand;
			temp_OleDbCommand = stmt;
			temp_OleDbCommand.CommandText = sql;
			System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();
			int c = - 1;
			while (rs.Read())
			{
				System.String name = NuGenSegmentGenerator.altSegName(System.Convert.ToString(rs[1 - 1]));
				bool repeating = rs.GetBoolean(2 - 1);
				bool optional = rs.GetBoolean(3 - 1);
				System.String desc = System.Convert.ToString(rs[4 - 1]);
				System.String groupName = version.ToUpper().Equals("2.3.1".ToUpper())?null:System.Convert.ToString(rs[6 - 1]); //group names are defined in DB for 2.3.1 but not used in the schema
				
				//ignore the "choice" directives ... the message class structure has to include all choices ...
				//  if this is enforced (i.e. exception thrown if >1 choice populated) this will have to be done separately.
				if (!(name.Equals("<") || name.Equals("|") || name.Equals(">")))
				{
					c++;
					segments[c] = new NuGenSegmentDef(name, groupName, !optional, repeating, desc);
				}
			}
			NuGenSegmentDef[] ret = new NuGenSegmentDef[c + 1];
			Array.Copy(segments, 0, ret, 0, c + 1);
			
			return ret;
		}
Пример #5
0
		/// <summary> Creates a new instance of HasAttributeFilter that accepts tags
		/// with the given attribute and value.
		/// </summary>
		/// <param name="attribute">The attribute to search for.
		/// </param>
		/// <param name="value">The value that must be matched,
		/// or null if any value will match.
		/// </param>
		public HasAttributeFilter(System.String attribute, System.String value_Renamed)
		{
			mAttribute = attribute.ToUpper(new System.Globalization.CultureInfo("en"));
			mValue = value_Renamed;
		}
		/// <summary> Creates a TagNameFilter that accepts tags with the given name.</summary>
		/// <param name="name">The tag name to match.
		/// </param>
		public TagNameFilter(System.String name)
		{
			mName = name.ToUpper(new System.Globalization.CultureInfo("en"));
		}
Пример #7
0
		/// <summary> Returns a property of a connection object.
		/// 
		/// </summary>
		/// <param name="name">  Name of the property to be returned.
		/// 
		/// The following read-only properties are available
		/// for any given connection:
		/// <ul>
		/// <li>Ldap_PROPERTY_SDK returns the version of this SDK,
		/// as a Float data type.</li>
		/// 
		/// <li>Ldap_PROPERTY_PROTOCOL returns the highest supported version of
		/// the Ldap protocol, as a Float data type.</li>
		/// 
		/// <li>Ldap_PROPERTY_SECURITY returns a comma-separated list of the
		/// types of authentication supported, as a
		/// string.</li>
		/// </ul>
		/// 
		/// A deep copy of the property is provided where applicable; a
		/// client does not need to clone the object received.
		/// 
		/// </param>
		/// <returns> The object associated with the requested property,
		/// or null if the property is not defined.
		/// 
		/// </returns>
		/// <seealso cref="LdapConstraints.getProperty">
		/// </seealso>
		/// <seealso cref="Object">
		/// </seealso>
		public virtual System.Object getProperty(System.String name)
		{
			if (name.ToUpper().Equals(Ldap_PROPERTY_SDK.ToUpper()))
				return Connection.sdk;
			else if (name.ToUpper().Equals(Ldap_PROPERTY_PROTOCOL.ToUpper()))
				return Connection.protocol;
			else if (name.ToUpper().Equals(Ldap_PROPERTY_SECURITY.ToUpper()))
				return Connection.security;
			else
			{
				return null;
			}
		}
		/// <summary> Returns the attribute matching the specified attrName.
		/// 
		/// For example:
		/// <ul>
		/// <li><code>getAttribute("cn")</code>      returns only the "cn" attribute</li>
		/// <li><code>getAttribute("cn;lang-en")</code> returns only the "cn;lang-en"
		/// attribute.</li>
		/// </ul>
		/// In both cases, <code>null</code> is returned if there is no exact match to
		/// the specified attrName.
		/// 
		/// Note: Novell eDirectory does not currently support language subtypes.
		/// It does support the "binary" subtype.
		/// 
		/// </summary>
		/// <param name="attrName">  The name of an attribute to retrieve, with or without
		/// subtype specifications. For example, "cn", "cn;phonetic", and
		/// "cn;binary" are valid attribute names.
		/// 
		/// </param>
		/// <returns> The attribute matching the specified attrName, or <code>null</code>
		/// if there is no exact match.
		/// </returns>
		public virtual LdapAttribute getAttribute(System.String attrName)
		{
			return (LdapAttribute) map[attrName.ToUpper()];
		}
		/// <summary> Gets a frame by name.
		/// Names are checked without case sensitivity and conversion to uppercase
		/// is performed with the locale provided.
		/// </summary>
		/// <param name="name">The name of the frame to retrieve.
		/// </param>
		/// <param name="locale">The locale to use when converting to uppercase.
		/// </param>
		/// <returns> The specified frame or <code>null</code> if it wasn't found.
		/// </returns>
		public virtual FrameTag GetFrame(System.String name, System.Globalization.CultureInfo locale)
		{
			INode node;
			FrameTag ret;
			
			ret = null;
			
			name = name.ToUpper(locale);
			for (ISimpleNodeIterator e = Frames.Elements(); e.HasMoreNodes() && (null == ret); )
			{
				node = e.NextNode();
				if (node is FrameTag)
				{
					ret = (FrameTag) node;
					if (!ret.FrameName.ToUpper(locale).Equals(name))
						ret = null;
				}
			}
			
			return (ret);
		}
Пример #10
0
			public virtual bool matchesLocale(System.String locale)
			{
				return (((this.locale == null) && (locale == null)) || locale.ToUpper().Equals(this.locale.ToUpper()));
			}
		/// <summary> Checks cardinality and creates an appropriate exception if out 
		/// of bounds.  The usage code is needed because if min cardinality
		/// is > 0, the min # of reps is only required if the usage code
		/// is 'R' (see HL7 v2.5 section 2.12.6.4).  
		/// </summary>
		/// <param name="reps">the number of reps
		/// </param>
		/// <param name="min">the minimum number of reps
		/// </param>
		/// <param name="max">the maximum number of reps (-1 means *)
		/// </param>
		/// <param name="usage">the usage code 
		/// </param>
		/// <param name="name">the name of the repeating structure (used in exception msg)
		/// </param>
		/// <returns> null if cardinality OK, exception otherwise
		/// </returns>
		protected internal virtual NuGenHL7Exception testCardinality(int reps, int min, int max, System.String usage, System.String name)
		{
			NuGenHL7Exception e = null;
			if (reps < min && usage.ToUpper().Equals("R".ToUpper()))
			{
				e = new NuGenProfileNotFollowedException(name + " must have at least " + min + " repetitions (has " + reps + ")");
			}
			else if (max > 0 && reps > max)
			{
				e = new NuGenProfileNotFollowedException(name + " must have no more than " + max + " repetitions (has " + reps + ")");
			}
			return e;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="linkTextToFind"></param>
		/// <param name="locale"></param>
		public LinkFindingVisitor(System.String linkTextToFind, System.Globalization.CultureInfo locale)
		{
			count = 0;
			this.locale = (null == locale)?new System.Globalization.CultureInfo("en"):locale;
			this.linkTextToFind = linkTextToFind.ToUpper(this.locale);
		}
		/// <summary> Get the <code>PARAM<code> tag with the given name.</summary>
		/// <param name="key">The object parameter name to get.
		/// </param>
		/// <returns> The value of the parameter or <code>null</code> if there is no parameter of that name.
		/// </returns>
		public virtual System.String GetParameter(System.String key)
		{
			return ((System.String) (ObjectParams[key.ToUpper()]));
		}
Пример #14
0
        /// <summary> Creates source code for a single data type in the HL7 normative
        /// database. 
        /// </summary>
        /// <param name="targetDirectory">the directory into which the file will be written
        /// </param>
        /// <param name="datatype">the name (e.g. ST, ID, etc.) of the data type to be created
        /// </param>
        /// <param name="version">the HL7 version of the intended data type
        /// </param>
        public static void make(System.IO.FileInfo targetDirectory, System.String dataType, System.String version)
        {
            Console.WriteLine(" Writing " + targetDirectory.FullName + dataType);
            //make sure that targetDirectory is a directory ...
            if (!System.IO.Directory.Exists(targetDirectory.FullName))
                throw new System.IO.IOException("Can't create file in " + targetDirectory.ToString() + " - it is not a directory.");

            //get any components for this data type
            //UPGRADE_NOTE: There are other database providers or managers under System.Data namespace which can be used optionally to better fit the application requirements. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1208'"
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            //UPGRADE_TODO: Method 'java.sql.Connection.createStatement' was converted to 'SupportClass.TransactionManager.manager.CreateStatement' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlConnectioncreateStatement'"
            System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            //this query is adapted from the XML SIG informative document
            sql.Append("SELECT HL7DataStructures.data_structure, HL7DataStructureComponents.seq_no, HL7DataStructures.description, HL7DataStructureComponents.table_id,  ");
            sql.Append("HL7Components.description, HL7Components.table_id, HL7Components.data_type_code, HL7Components.data_structure ");
            sql.Append("FROM HL7Versions LEFT JOIN (HL7DataStructures LEFT JOIN (HL7DataStructureComponents LEFT JOIN HL7Components ");
            sql.Append("ON HL7DataStructureComponents.comp_no = HL7Components.comp_no AND ");
            sql.Append("HL7DataStructureComponents.version_id = HL7Components.version_id) ");
            sql.Append("ON HL7DataStructures.version_id = HL7DataStructureComponents.version_id ");
            sql.Append("AND HL7DataStructures.data_structure = HL7DataStructureComponents.data_structure) ");
            sql.Append("ON HL7DataStructures.version_id = HL7Versions.version_id ");
            sql.Append("WHERE HL7DataStructures.data_structure = '");
            sql.Append(dataType);
            sql.Append("' AND HL7Versions.hl7_version = '");
            sql.Append(version);
            sql.Append("' ORDER BY HL7DataStructureComponents.seq_no");
            //System.out.println(sql.toString());  //for debugging
            //UPGRADE_TODO: Interface 'java.sql.ResultSet' was converted to 'System.Data.OleDb.OleDbDataReader' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javasqlResultSet'"
            System.Data.OleDb.OleDbCommand temp_OleDbCommand;
            temp_OleDbCommand = stmt;
            temp_OleDbCommand.CommandText = sql.ToString();
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList dataTypes = new System.Collections.ArrayList(20);
            System.Collections.ArrayList descriptions = new System.Collections.ArrayList(20);
            System.Collections.ArrayList tables = new System.Collections.ArrayList(20);
            System.String description = null;
            while (rs.Read())
            {
                if (description == null)
                    description = System.Convert.ToString(rs[3 - 1]);

                System.String de = System.Convert.ToString(rs[5 - 1]);
                System.String dt = System.Convert.ToString(rs[8 - 1]);
                int ta=-1;
                if(!rs.IsDBNull(4-1))
                    ta = rs.GetInt32(4 - 1);
                //trim all CE_x to CE
                if (dt != null)
                    if (dt.StartsWith("CE"))
                        dt = "CE";
                //System.out.println("Component: " + de + "  Data Type: " + dt);  //for debugging
                dataTypes.Add(dt);
                descriptions.Add(de);
                tables.Add((System.Int32) ta);
            }
            if(dataType.ToUpper().Equals("TS") && version!="2.5")
            {
                dataTypes[0] = "TSComponentOne";
            }

            rs.Close();
            //UPGRADE_ISSUE: Method 'java.sql.Statement.close' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javasqlStatementclose'"
            stmt.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            //if there is only one component make a Primitive, otherwise make a Composite
            System.String source = null;
            if (dataTypes.Count == 1)
            {
                if (dataType.Equals("FT") || dataType.Equals("ST") || dataType.Equals("TX") || dataType.Equals("NM") || dataType.Equals("SI") || dataType.Equals("TN") || dataType.Equals("GTS"))
                {
                    source = makePrimitive(dataType, description, version);
                }
                else
                {
                    source = null; //note: IS, ID, DT, DTM, and TM are coded manually
                }
            }
            else if (dataTypes.Count > 1)
            {
                int numComponents = dataTypes.Count;
                //copy data into arrays ...
                System.String[] type = new System.String[numComponents];
                System.String[] desc = new System.String[numComponents];
                int[] table = new int[numComponents];
                for (int i = 0; i < numComponents; i++)
                {
                    type[i] = ((System.String) dataTypes[i]);
                    desc[i] = ((System.String) descriptions[i]);
                    table[i] = ((System.Int32) tables[i]);
                }
                source = makeComposite(dataType, description, type, desc, table, version);
            }
            else
            {
                //no components?
                //throw new DataTypeException("The data type " + dataType + " could not be found");
                Console.WriteLine("No components for " + dataType);
            }
            //System.out.println(source);

            //write to file ...
            if (source != null)
            {
                System.String targetFile = targetDirectory.ToString() + "/" + dataType + ".cs";
                //UPGRADE_WARNING: At least one expression was used more than once in the target code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1181'"
                //UPGRADE_TODO: Constructor 'java.io.FileWriter.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriterFileWriter_javalangString_boolean'"
                //UPGRADE_TODO: Class 'java.io.FileWriter' was converted to 'System.IO.StreamWriter' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javaioFileWriter'"
                using(System.IO.StreamWriter writer = new System.IO.StreamWriter(targetFile))
                {
                    writer.Write(source);
                    writer.Write("}");//End namespace
                }
            }
            else
                Console.WriteLine("No Source for " + dataType);
        }
Пример #15
0
 private void processAnnotation(System.String field, System.String value_Renamed, Reaction reaction)
 {
     //logger.debug("Annote: ", field, "=", value_Renamed);
     if (field.Equals("RxnAtts") || field.Equals("RxnType"))
     {
         // reaction attributes
         System.String dictionary = "macie";
         if (value_Renamed.Equals("Acid") || value_Renamed.Equals("Base"))
         {
             dictionary = "chemical";
         }
         addDictRefedAnnotation(reaction, "Attributes", value_Renamed);
     }
     else if (field.Equals("ResiduesPresent") || field.Equals("GroupTransferred") || field.Equals("BondFormed") || field.Equals("ReactiveCentres") || field.Equals("BondCleaved") || field.Equals("BondFormed") || field.Equals("Products") || field.Equals("ResiduesPresent"))
     {
         reaction.setProperty(new DictRef("macie:" + field, value_Renamed), value_Renamed);
     }
     else if (field.Equals("Reversible"))
     {
         if (value_Renamed.ToUpper().Equals("yes".ToUpper()))
         {
             reaction.Direction = IReaction_Fields.BIDIRECTIONAL;
             addDictRefedAnnotation(reaction, "ReactionType", "ReversibleReaction");
         }
     }
     else if (field.Equals("OverallReactionType"))
     {
         SupportClass.Tokenizer tokenizer = new SupportClass.Tokenizer(value_Renamed, ",");
         int i = 0;
         while (tokenizer.HasMoreTokens())
         {
             System.String token = tokenizer.NextToken();
             i++;
             reaction.setProperty(DictionaryDatabase.DICTREFPROPERTYNAME + ":field:overallReactionType:" + i, "macie:" + token.ToLower());
         }
     }
     else
     {
         Match residueLocatorMatcher = residueLocator.Match(field);
         if (residueLocatorMatcher.Success)
         {
             //logger.debug("Found residueLocator: ", field);
             IAtom[] atoms = ReactionManipulator.getAllInOneContainer(reaction).Atoms;
             bool found = false;
             //logger.debug("Searching for given residueLocator through #atom: ", atoms.Length);
             //logger.debug("Taken from reaction ", reaction.ID);
             for (int i = 0; (i < atoms.Length && !found); i++)
             {
                 if (atoms[i] is PseudoAtom)
                 {
                     // that is what we are looking for
                     PseudoAtom atom = (PseudoAtom)atoms[i];
                     if (atom.Label.Equals(field))
                     {
                         // we have a hit, now mark Atom with dict refs
                         addDictRefedAnnotation(atom, "ResidueRole", value_Renamed);
                         found = true;
                     }
                 }
             }
             if (!found)
             {
                 //logger.error("MACiE annotation mentions a residue that does not exist: " + field);
             }
         }
         else
         {
             //logger.error("Did not parse annotation: ", field);
         }
     }
 }
Пример #16
0
		/// <summary> Returns the value of an attribute.</summary>
		/// <param name="name">Name of attribute, case insensitive.
		/// </param>
		/// <returns> The value associated with the attribute or null if it does
		/// not exist, or is a stand-alone or
		/// </returns>
		public virtual System.String GetAttribute(System.String name)
		{
			TagAttribute attribute;
			System.String ret;
			
			ret = null;
			
			if (name.ToUpper().Equals(SpecialHashtable.TAGNAME.ToUpper()))
				ret = ((TagAttribute) AttributesEx[0]).GetName();
			else
			{
				attribute = GetAttributeEx(name);
				if (null != attribute)
					ret = attribute.GetValue();
			}
			
			return (ret);
		}
Пример #17
0
		/// <summary> Returns the attribute with the given name.</summary>
		/// <param name="name">Name of attribute, case insensitive.
		/// </param>
		/// <returns> The attribute or null if it does
		/// not exist.
		/// </returns>
		public virtual TagAttribute GetAttributeEx(System.String name)
		{
			System.Collections.ArrayList attributes;
			int size;
			TagAttribute attribute;
			System.String string_Renamed;
			TagAttribute ret;
			
			ret = null;
			
			attributes = AttributesEx;
			if (null != attributes)
			{
				size = attributes.Count;
				for (int i = 0; i < size; i++)
				{
					attribute = (TagAttribute) attributes[i];
					string_Renamed = attribute.GetName();
					if ((null != string_Renamed) && name.ToUpper().Equals(string_Renamed.ToUpper()))
					{
						ret = attribute;
						i = size; // exit fast
					}
				}
			}
			
			return (ret);
		}
		/// <summary> Tests an element against the corresponding usage code.  The element 
		/// is required in its encoded form.  
		/// </summary>
		/// <param name="encoded">the pipe-encoded message element 
		/// </param>
		/// <param name="usage">the usage code (e.g. "CE")
		/// </param>
		/// <param name="name">the name of the element (for use in exception messages)
		/// </param>
		/// <returns>s null if there is no problem, an HL7Exception otherwise 
		/// </returns>
		private NuGenHL7Exception testUsage(System.String encoded, System.String usage, System.String name)
		{
			NuGenHL7Exception e = null;
			if (usage.ToUpper().Equals("R".ToUpper()))
			{
				if (encoded.Length == 0)
					e = new NuGenProfileNotFollowedException("Required element " + name + " is missing");
			}
			else if (usage.ToUpper().Equals("RE".ToUpper()))
			{
				//can't test anything 
			}
			else if (usage.ToUpper().Equals("O".ToUpper()))
			{
				//can't test anything
			}
			else if (usage.ToUpper().Equals("C".ToUpper()))
			{
				//can't test anything yet -- wait for condition syntax in v2.6 
			}
			else if (usage.ToUpper().Equals("CE".ToUpper()))
			{
				//can't test anything
			}
			else if (usage.ToUpper().Equals("X".ToUpper()))
			{
				if (encoded.Length > 0)
					e = new NuGenXElementPresentException("Element " + name + " is present but specified as not used (X)");
			}
			else if (usage.ToUpper().Equals("B".ToUpper()))
			{
				//can't test anything 
			}
			return e;
		}
Пример #19
0
		/// <summary> Reports if the attribute name contains the specified subtype.
		/// 
		/// For example, if you check for the subtype lang-en and the
		/// attribute name is cn;lang-en, this method returns true.
		/// 
		/// </summary>
		/// <param name="subtype"> The single subtype to check for.
		/// 
		/// </param>
		/// <returns> True, if the attribute has the specified subtype;
		/// false, if it doesn't.
		/// 
		/// @throws IllegalArgumentException if subtype is null
		/// </returns>
		public virtual bool hasSubtype(System.String subtype)
		{
			if ((System.Object) subtype == null)
			{
				throw new System.ArgumentException("subtype cannot be null");
			}
			if (null != this.subTypes)
			{
				for (int i = 0; i < subTypes.Length; i++)
				{
					if (subTypes[i].ToUpper().Equals(subtype.ToUpper()))
						return true;
				}
			}
			return false;
		}
Пример #20
0
        /// <summary> Bracketed text in a field description should be included in the accessor 
        /// name unless it corresponds to a data type name. Given the text that appears in 
        /// brackets in a field description, this method returns an empty string if it 
        /// corresponds to a data type name, or returns original text if not.  It isn't 
        /// convenient to actually check (e.g. with DataTypeGenerator) whether the given 
        /// text actually corresponds to a data type name, so we are going to conclude that 
        /// it is a data type if and only if it is all caps and has 2 or 3 characters.  
        /// </summary>
        private static System.String filterBracketedText(System.String text)
        {
            System.String filtered = "";
            bool isDataType = true;
            if (!text.Equals(text.ToUpper()))
                isDataType = false;
            if (text.Length < 2 || text.Length > 3)
                isDataType = false;

            if (!isDataType)
                filtered = text;
            return filtered;
        }
Пример #21
0
		// #######################################################################
		//   The following methods retrieve a SchemaElement given a Key name:
		// #######################################################################
		
		/// <summary> This function abstracts retrieving LdapSchemaElements from the local
		/// copy of schema in this LdapSchema class.  This is used by
		/// <code>getXXX(String name)</code> functions.
		/// 
		/// Note that the nameTable has all keys cast to Upper-case.  This is so
		/// we can have a case-insensitive HashMap.  The getXXX (String key)
		/// methods will also cast to uppercase.
		/// 
		/// The first character of a NAME string can only be an alpha character
		/// (see section 4.1 of rfc2252) Thus if the first character is a digit we
		/// can conclude it is an OID.  Note that this digit is ASCII only.
		/// 
		/// </summary>
		/// <param name="schemaType">Specifies which list is to be used in schema
		/// lookup.
		/// </param>
		/// <param name="key">       The key can be either an OID or a name string.
		/// </param>
		private LdapSchemaElement getSchemaElement(int schemaType, System.String key)
		{
			if ((System.Object) key == null || key.ToUpper().Equals("".ToUpper()))
				return null;
			char c = key[0];
			if (c >= '0' && c <= '9')
			{
				//oid lookup
				return (LdapSchemaElement) idTable[schemaType][key];
			}
			else
			{
				//name lookup
				return (LdapSchemaElement) nameTable[schemaType][key.ToUpper()];
			}
		}
Пример #22
0
 /// <summary> Creates a new instance of HasAttributeFilter that accepts tags
 /// with the given attribute and value.
 /// </summary>
 /// <param name="attribute">The attribute to search for.
 /// </param>
 /// <param name="value">The value that must be matched,
 /// or null if any value will match.
 /// </param>
 public AttributeRegexFilter(System.String attribute, System.String valuePattern, Boolean caseSensitive)
 {
     m_strAttribute = attribute.ToUpper(new System.Globalization.CultureInfo("en"));
     m_strValuePattern = valuePattern;
     m_bCaseSensitive = caseSensitive;
 }
Пример #23
0
		/// <summary> Parse filters from the given word
		/// 
		/// </summary>
		/// <param name="word">String to parse
		/// 
		/// </param>
		/// <returns> Analysis wavelet filter (first dimension: by direction,
		/// second dimension: by decomposition levels)
		/// </returns>
		private AnWTFilter[][] parseFilters(System.String word)
		{
			AnWTFilter[][] filt = new AnWTFilter[2][];
			for (int i = 0; i < 2; i++)
			{
				filt[i] = new AnWTFilter[1];
			}
			if (word.ToUpper().Equals("w5x3".ToUpper()))
			{
				filt[0][0] = new AnWTFilterIntLift5x3();
				filt[1][0] = new AnWTFilterIntLift5x3();
				return filt;
			}
			else if (word.ToUpper().Equals("w9x7".ToUpper()))
			{
				filt[0][0] = new AnWTFilterFloatLift9x7();
				filt[1][0] = new AnWTFilterFloatLift9x7();
				return filt;
			}
			else
			{
				throw new System.ArgumentException("Non JPEG 2000 part I filter: " + word);
			}
		}
Пример #24
0
		/// <summary> Creates a new instance of HasAttributeFilter that accepts tags
		/// with the given attribute and value.
		/// </summary>
		/// <param name="attribute">The attribute to search for.
		/// </param>
		/// <param name="value">The value that must be matched,
		/// or null if any value will match.
		/// </param>
        public AttributeRegexFilter(System.String attribute, System.String valuePattern)
		{
            m_strAttribute = attribute.ToUpper(new System.Globalization.CultureInfo("en"));
            m_strValuePattern = valuePattern;
		}
Пример #25
0
        /// <summary> Internal function used by equal to compare Attribute types.  Because
        /// attribute types could either be an OID or a name.  There needs to be a
        /// Translation mechanism.  This function will absract this functionality.
        /// 
        /// Currently if types differ (Oid and number) then UnsupportedOperation is
        /// thrown, either one or the other must used.  In the future an OID to name
        /// translation can be used.
        /// 
        /// 
        /// </summary>
        private bool equalAttrType(System.String attr1, System.String attr2)
        {
            if (System.Char.IsDigit(attr1[0]) ^ System.Char.IsDigit(attr2[0]))
            //isDigit tests if it is an OID
                throw new System.ArgumentException("OID numbers are not " + "currently compared to attribute names");

            return attr1.ToUpper().Equals(attr2.ToUpper());
        }
    // PrintRights() parses and prints the effective rights
    public static void PrintRights(System.String aName, int rights)
    {
        System.Text.StringBuilder rString = new System.Text.StringBuilder();

        if (aName.ToUpper().Equals("[Entry Rights]".ToUpper()))
        {
            // decode object rights
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_BROWSE) != 0?"BrowseEntry: true; ":"BrowseEntry: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_ADD) != 0?"AddEntry: true; ":"AddEntry: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_DELETE) != 0?"DeleteEntry: true; ":"DeleteEntry: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_RENAME) != 0?"RenameEntry: true; ":"RenameEntry: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_SUPERVISOR) != 0?"Supervisor: true; ":"Supervisor: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ENTRY_INHERIT_CTL) != 0?"Inherit_ctl: true.":"Inherit_ctl: false.");
        }
        else
        {
            // decode attribute rights no matter it's for
            // all attributes or a single attribute
            rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_COMPARE) != 0?"CompareAttributes: true; ":"CompareAttributes: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_READ) != 0?"ReadAttributes: true; ":"ReadAttributes: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_WRITE) != 0?"Write/Add/DeleteAttributes: true; ":"Write/Add/DeleteAttributes: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SELF) != 0?"Add/DeleteSelf: true; ":"Add/DeleteSelf: false; ");
            rString.Append((rights & LdapDSConstants.LDAP_DS_ATTR_SUPERVISOR) != 0?"Supervisor: true.":"Supervisor: false.");
        }

        //		System.Console.Out.WriteLine(rString);
    }
Пример #27
0
        /// <summary> Try to convert a string into a number, boolean, or null. If the string
        /// can't be converted, return the string.
        /// </summary>
        /// <param name="s">A String.
        /// </param>
        /// <returns> A simple JSON value.
        /// </returns>
        public static System.Object stringToValue(System.String s)
        {
            if (s.Equals(""))
            {
                return s;
            }
            if (s.ToUpper().Equals("true".ToUpper()))
            {
                return true;
            }
            if (s.ToUpper().Equals("false".ToUpper()))
            {
                return false;
            }
            if (s.ToUpper().Equals("null".ToUpper()))
            {
                return JSONObject.NULL;
            }

            /*
            * If it might be a number, try converting it.
            * We support the non-standard 0x- convention.
            * If a number cannot be produced, then the value will just
            * be a string. Note that the 0x-, plus, and implied string
            * conventions are non-standard. A JSON parser may accept
            * non-JSON forms as long as it accepts all correct JSON forms.
            */

            char b = s[0];
            if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+')
            {
                if (b == '0' && s.Length > 2 && (s[1] == 'x' || s[1] == 'X'))
                {
                    try
                    {
                        //UPGRADE_TODO: Method 'java.lang.Integer.parseInt' was converted to 'System.Convert.ToInt32' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073'"
                        return (System.Int32)System.Convert.ToInt32(s.Substring(2), 16);
                    }
                    catch (System.Exception ignore)
                    {
                    }
                }
                try
                {
                    if (s.IndexOf('.') > -1 || s.IndexOf('e') > -1 || s.IndexOf('E') > -1)
                    {
                        return System.Double.Parse(s);
                    }
                    else
                    {
                        System.Int64 myLong = System.Int64.Parse(s);
                        if ((long)myLong == (int)myLong)
                        {
                            return (System.Int32)myLong;
                        }
                        else
                        {
                            return myLong;
                        }
                    }
                }
                catch (System.Exception ignore)
                {
                }
            }
            return s;
        }
Пример #28
0
        /// <summary> Attempts to retrieve the value of a leaf tag without using DOM or SAX.  
        /// This method searches the given message string for the given tag name, and returns 
        /// everything after the given tag and before the start of the next tag.  Whitespace
        /// is stripped.  This is intended only for lead nodes, as the value is considered to 
        /// end at the start of the next tag, regardless of whether it is the matching end 
        /// tag or some other nested tag.  
        /// </summary>
        /// <param name="message">a string message in XML form
        /// </param>
        /// <param name="tagName">the name of the XML tag, e.g. "MSA.2"
        /// </param>
        /// <param name="startAt">the character location at which to start searching
        /// </param>
        /// <throws>  HL7Exception if the tag can not be found </throws>
        protected internal virtual System.String parseLeaf(System.String message, System.String tagName, int startAt)
        {
            System.String value_Renamed = null;

            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int tagStart = message.IndexOf("<" + tagName, startAt);
            if (tagStart < 0)
            {
                //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
                tagStart = message.IndexOf("<" + tagName.ToUpper(), startAt);
            }
            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int valStart = message.IndexOf(">", tagStart) + 1;
            //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'"
            int valEnd = message.IndexOf("<", valStart);

            if (tagStart >= 0 && valEnd >= valStart)
            {
                value_Renamed = message.Substring(valStart, (valEnd) - (valStart));
            }
            else
            {
                throw new HL7Exception("Couldn't find " + tagName + " in message beginning: " + message.Substring(0, (System.Math.Min(150, message.Length)) - (0)), HL7Exception.REQUIRED_FIELD_MISSING);
            }

            return value_Renamed;
        }
Пример #29
0
        /// <summary> Creates source code for a single data type in the HL7 normative
        /// database. 
        /// </summary>
        /// <param name="targetDirectory">the directory into which the file will be written
        /// </param>
        /// <param name="datatype">the name (e.g. ST, ID, etc.) of the data type to be created
        /// </param>
        /// <param name="version">the HL7 version of the intended data type
        /// </param>
        public static void make(System.IO.FileInfo targetDirectory, System.String dataType, System.String version)
        {
            Console.WriteLine(" Writing " + targetDirectory.FullName + dataType);
            //make sure that targetDirectory is a directory ...
            if (!System.IO.Directory.Exists(targetDirectory.FullName))
                throw new System.IO.IOException("Can't create file in " + targetDirectory.ToString() + " - it is not a directory.");

            //get any components for this data type
            System.Data.OleDb.OleDbConnection conn = NormativeDatabase.Instance.Connection;
            System.Data.OleDb.OleDbCommand stmt = SupportClass.TransactionManager.manager.CreateStatement(conn);
            System.Text.StringBuilder sql = new System.Text.StringBuilder();
            //this query is adapted from the XML SIG informative document
            sql.Append("SELECT HL7DataStructures.data_structure, HL7DataStructureComponents.seq_no, HL7DataStructures.description, HL7DataStructureComponents.table_id,  ");
            sql.Append("HL7Components.description, HL7Components.table_id, HL7Components.data_type_code, HL7Components.data_structure ");
            sql.Append("FROM HL7Versions LEFT JOIN (HL7DataStructures LEFT JOIN (HL7DataStructureComponents LEFT JOIN HL7Components ");
            sql.Append("ON HL7DataStructureComponents.comp_no = HL7Components.comp_no AND ");
            sql.Append("HL7DataStructureComponents.version_id = HL7Components.version_id) ");
            sql.Append("ON HL7DataStructures.version_id = HL7DataStructureComponents.version_id ");
            sql.Append("AND HL7DataStructures.data_structure = HL7DataStructureComponents.data_structure) ");
            sql.Append("ON HL7DataStructures.version_id = HL7Versions.version_id ");
            sql.Append("WHERE HL7DataStructures.data_structure = '");
            sql.Append(dataType);
            sql.Append("' AND HL7Versions.hl7_version = '");
            sql.Append(version);
            sql.Append("' ORDER BY HL7DataStructureComponents.seq_no");
            System.Data.OleDb.OleDbCommand temp_OleDbCommand;
            temp_OleDbCommand = stmt;
            temp_OleDbCommand.CommandText = sql.ToString();
            System.Data.OleDb.OleDbDataReader rs = temp_OleDbCommand.ExecuteReader();

            System.Collections.ArrayList dataTypes = new System.Collections.ArrayList(20);
            System.Collections.ArrayList descriptions = new System.Collections.ArrayList(20);
            System.Collections.ArrayList tables = new System.Collections.ArrayList(20);
            System.String description = null;
            while (rs.Read())
            {
                if (description == null)
                    description = System.Convert.ToString(rs[3 - 1]);

                System.String de = System.Convert.ToString(rs[5 - 1]);
                System.String dt = System.Convert.ToString(rs[8 - 1]);
                int ta = -1;
                if (!rs.IsDBNull(4 - 1))
                    ta = rs.GetInt32(4 - 1);
                //trim all CE_x to CE
                if (dt != null)
                    if (dt.StartsWith("CE"))
                        dt = "CE";
                //System.out.println("Component: " + de + "  Data Type: " + dt);  //for debugging
                dataTypes.Add(dt);
                descriptions.Add(de);
                tables.Add((System.Int32)ta);
            }
            if (dataType.ToUpper().Equals("TS"))
            {
                dataTypes[0] = "TSComponentOne";
            }

            rs.Close();
            stmt.Dispose();
            NormativeDatabase.Instance.returnConnection(conn);

            //if there is only one component make a Primitive, otherwise make a Composite
            System.String source = null;
            if (dataTypes.Count == 1)
            {
                if (dataType.Equals("FT") || dataType.Equals("ST") || dataType.Equals("TX") || dataType.Equals("NM") || dataType.Equals("SI") || dataType.Equals("TN") || dataType.Equals("GTS"))
                {
                    source = makePrimitive(dataType, description, version);
                }
                else
                {
                    source = null; //note: IS, ID, DT, DTM, and TM are coded manually
                }
            }
            else if (dataTypes.Count > 1)
            {
                int numComponents = dataTypes.Count;
                //copy data into arrays ...
                System.String[] type = new System.String[numComponents];
                System.String[] desc = new System.String[numComponents];
                int[] table = new int[numComponents];
                for (int i = 0; i < numComponents; i++)
                {
                    type[i] = ((System.String)dataTypes[i]);
                    desc[i] = ((System.String)descriptions[i]);
                    table[i] = ((System.Int32)tables[i]);
                }
                source = makeComposite(dataType, description, type, desc, table, version);
            }
            else
            {
                //no components?
                //throw new DataTypeException("The data type " + dataType + " could not be found");
                Console.WriteLine("No components for " + dataType);
            }
            //System.out.println(source);

            //write to file ...
            if (source != null)
            {
                System.String targetFile = targetDirectory.ToString() + "/" + dataType + ".cs";
                using (System.IO.StreamWriter writer = new System.IO.StreamWriter(targetFile))
                {
                    writer.Write(source);
                    writer.Write("}");//End namespace
                }
            }
            else
                Console.WriteLine("No Source for " + dataType);
        }
Пример #30
0
        /// <summary>
        /// Checks whether the submitted IBAN (International Bank Account Number) is valid.
        ///
        /// The IBAN is an ISO standard (ISO 13616) designed to ensure that account details are given in a
        /// standard format (bank plus account). IBAN was introduced to provide an international standard
        /// for payee account details and to make details more easy to check. IBAN is a standardised
        /// international format for entering account details which consists of the country code (bank which
        /// maintains the account), the local bank code (eg. in the UK this is the sortcode), the (payee)
        /// account number and a two check digits. Please note that IBANs do not start with "IBAN " and do not
        /// contain spaces when stored in computer systems.
        /// Here is an example of an IBAN: DE89370400440532013000
        ///     DE = ISO 3166-1 country code
        ///         (NOTE: The country code used in an IBAN can deviate from the country code used in a BIC!
        ///     89 = two check digits
        ///     37040044 = sortcode
        ///     0532013000 = account number.
        /// IBANs are only issued by the bank where the account it is issued for is held.
        ///
        /// </summary>
        /// <param name="AIban">String that should be checked</param>
        /// <param name="AResult"></param>
        /// <returns>True if AIban is a valid Iban or an empty String or nil, False if it is
        /// not valid.
        /// </returns>
        public static bool CheckIBAN(System.String AIban, out TVerificationResult AResult)
        {
            AResult = null;

            int IbanLength;
            string IbanCountryCode;
            int IbanCheckDigits;
            int Index = -1;
            bool ReturnValue = true;

            // this list was up-to-date as of Jan 2014 (http://www.swift.com/dsp/resources/documents/IBAN_Registry.pdf)
            string[, ] COUNTRY_DATA =
            {
                { "AD", "Andorra", "24" },
                { "AE", "United Arab Emirates", "23" },
                { "AL", "Albania", "28" },
                { "AT", "Austria", "20" },
                { "AZ", "Azerbaijan", "28" },
                { "BA", "Bosnia and Herzegovina", "20" },
                { "BE", "Belgium", "16" },
                { "BG", "Bulgaria", "22" },
                { "BH", "Bahrain", "22" },
                { "BR", "Brazil", "29" },
                { "CH", "Switzerland", "21" },
                { "CR", "Costa Rica", "21" },
                { "CY", "Cyprus", "28" },
                { "CZ", "Czech Republic", "24" },
                { "DE", "Germany", "22" },
                { "DK", "Denmark", "18" },
                { "DO", "Dominican Republic", "28" },
                { "EE", "Estonia", "20" },
                { "ES", "Spain", "24" },
                { "FI", "Finland", "18" },
                { "FO", "Faroe Islands", "18" },
                { "FR", "France", "27" },
                { "GE", "Georgia", "22" },
                { "GI", "Gibraltar", "23" },
                { "GB", "United Kingdom", "22" },
                { "GL", "Greenland", "18" },
                { "GR", "Greece", "27" },
                { "GT", "Guatemala", "28" },
                { "HR", "Croatia", "21" },
                { "HU", "Hungary", "28" },
                { "IE", "Republic of Ireland", "22" },
                { "IL", "Israel", "23" },
                { "IS", "Iceland", "26" },
                { "IT", "Italy", "27" },
                { "JO", "Jordan", "30" },
                { "KU", "Kuwait", "30" },
                { "KZ", "Kazakhstan", "20" },
                { "LB", "Lebanon", "28" },
                { "LI", "Lichtenstein", "21" },
                { "LU", "Luxembourg", "20" },
                { "LV", "Latvia", "21" },
                { "LT", "Lithuania", "20" },
                { "MC", "Monaco", "27" },
                { "MD", "Moldova", "24" },
                { "ME", "Montenegro", "22" },
                { "MK", "Macedonia", "19" },
                { "MR", "Mauritania", "27" },
                { "MT", "Malta", "31" },
                { "MU", "Mauritius", "30" },
                { "NL", "The Netherlands", "18" },
                { "NO", "Norway", "15" },
                { "PK", "Pakistan", "24" },
                { "PL", "Poland", "28" },
                { "PS", "Palestine", "29" },
                { "PT", "Portugal", "25" },
                { "QA", "Qatar", "29" },
                { "RO", "Romania", "24" },
                { "RS", "Serbia", "22" },
                { "SA", "Saudi Arabia", "24" },
                { "SE", "Sweden", "24" },
                { "SI", "Slovenia", "19" },
                { "SK", "Slovak Republic", "24" },
                { "SM", "San Marino", "27" },
                { "TN", "Tunisia", "24" },
                { "TR", "Turkey", "26" },
                { "VG", "Virgin Islands", "24" }
            };

            // remove all spaces
            AIban = AIban.Replace(" ", "");

            // make string uppercase for ease
            AIban = AIban.ToUpper();

            // get length
            IbanLength = AIban.Length;

            // check length (must be less or equal to 34 characters)
            if (IbanLength > 34)
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_TOO_LONG));

                return false;
            }

            // check first and second character to be A-Z
            if ((IbanLength < 2) || !Regex.IsMatch(AIban.Substring(0, 2), @"^[A-Z]+$"))
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_NOTBEGINWITHTWOLETTERS));

                return false;
            }
            else
            {
                IbanCountryCode = AIban.Substring(0, 2);
            }

            // check third and fourth character to form a number
            if ((IbanLength < 4) || !Regex.IsMatch(AIban.Substring(2, 2), @"^[0-9]+$"))
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_THIRDANDFORTHNOTDIGITS));

                return false;
            }
            else
            {
                IbanCheckDigits = Convert.ToInt32(AIban.Substring(2, 2));
            }

            // verify check digits (must be within range 02-98)
            if ((IbanCheckDigits < 2) || (IbanCheckDigits == 99))
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_CHECKDIGITSAREWRONG));

                return false;
            }

            // find the index of the country code (if it exists)
            for (int i = 0; i < COUNTRY_DATA.GetLength(0); i++)
            {
                if (COUNTRY_DATA[i, 0] == IbanCountryCode)
                {
                    Index = i;
                    break;
                }
            }

            if (Index == -1)
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_COUNTRYNOTDEFINIED, IbanCountryCode));

                ReturnValue = false;
            }

            // check the length of the IBAN for defined countries
            if ((Index != -1) && (Convert.ToInt32(COUNTRY_DATA[Index, 2]) != IbanLength))
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_WRONGLENGTH, new string[4]
                        {
                            COUNTRY_DATA[Index, 1], COUNTRY_DATA[Index, 0], COUNTRY_DATA[Index, 2].ToString(), IbanLength.ToString()
                        }));

                return false;
            }

            /* calculate and check the checksum */

            // put country and check digits to the end
            AIban = AIban.Substring(4) + AIban.Substring(0, 4);

            //replace each letter by numerical equivalent
            AIban = Regex.Replace(AIban, @"\D", x => ((int)x.Value[0] - 55).ToString());

            int Remainder = 0;

            // Interpret the IBAN as a decimal integer and compute the remainder of that number on division by 97
            while (AIban.Length >= 7)
            {
                Remainder = Convert.ToInt32(AIban.Substring(0, 7)) % 97;
                AIban = Remainder.ToString() + AIban.Substring(7);
            }

            if (AIban.Length > 0)
            {
                Remainder = Convert.ToInt32(AIban) % 97;
            }

            // checksum only valid if Remainder = 1
            if (Remainder != 1)
            {
                AResult = new TVerificationResult(
                    "CommonRoutines.CheckIBAN",
                    ErrorCodes.GetErrorInfo(PetraErrorCodes.ERR_IBAN_CHECKSUMMISMATCH));

                ReturnValue = false;
            }

            return ReturnValue;
        }