The COREScriptUtilities class is a general purpose utilities class packed with useful methods. There is one instance of this class you can find CORE HL7 C# Script in globals.Utilities.
Static Properties: Access via CoreScriptUtilities.<property>
Property Name |
Data Type |
CR, CRLF, and LF |
string - CR is Carriage Return Hex 0D, CRLF is Carriage Return Line Feed Hex 0D-0A, LF is Line Feed Hex 0A. |
DoubleQuote |
string - Will be a string of a single double quote character " |
DTFormatMilliseconds |
string - Will be "hh:mm:ss.fff tt". Example: string x = DateTime.Now.Tostring(COREScriptUtilities.DTFormatMilliseconds); |
DTFormatSeconds |
string - Will be "hh:mm:ss tt". Example: string x = DateTime.Now.Tostring(COREScriptUtilities.DTFormatSeconds); |
DTFormatUniversal |
string - Will be "yyyy-MM-dd HH:mm:ss.fff". Example: string x = DateTime.Now.Tostring(COREScriptUtilities.DTFormatUniversal); NOTE: A string in this format can ALWAYS be used with DateTime.Parse() into a DateTime value regardless of the local machine regional settings making it useful for storing in XML. |
UndefinedDate |
DateTime - Will be System.DateTime.MinValue. |
Static Methods: Access via CoreScriptUtilities.<Method()>
Method |
Return Value |
Base64Decode(string value) |
string - Will attempt to do a Base64 decode operation on value. Will return an empty string if it fails. Also any Carriage Returns or Line Feed characters are removed from value beforehand. |
Base64Encode(string value) |
string - Will Base64 encode value and return the result. |
DataSetToXML(DataSet ds) |
string - Will convert a System.Data.DataSet object ds to an XML string including all embedded DataTables. |
DataTableToXML(DataTable dt) |
string - Will convert a System.Data.DataTable object dt to an XML string. |
DateIt(object value) |
DateTime - Will attempt to convert the object value into a DateTime. Returns COREScriptUtilities.UndefinedDate on failure. Useful with values from a Database. |
DBString(object value) |
string - Will attempt to convert the object value into a string. Returns empty string on failure or null value. Useful with values from a Database. |
DoubleSpace() |
string - Will return 2 Environment.NewLines. Useful shortcut when creating Text documents. |
IIF ( bool expression, object truePart, object falsePart, object errorPart = null ) |
object - A conditional evaluator method, expression is evaluated, if true truePart is returned, if false falsePart is returned, on error errorPart is returned. NOTE: There are 3 other variations on this method. All work the same except with different return data types and different data types for truePart, falsePart and errorPart. They are: IIFB() which returns and uses bool values, IIFInt() which returns and uses int values, and IIFS() which returns and uses string values. |
InStr ( string strToSearch, string sVal, bool ignoreCase = false ) |
int - A 1 based version of string.IndexOf(). Created for VB programmers new to C#. Returns the position of string sVal within strToSearch. If ignoreCase is false does a case-sensitive search. Returns 0 if not found.
NOTE: Remember this is a 1 based search. The position of "A" within "ABC" is 1 as opposed to 0 when using string.IndexOf(). |
InStr ( int startingIndex, string strToSearch, string sVal, bool ignoreCase = false ) |
int - A 1 based version of string.IndexOf(). Created for VB programmers new to C#. Returns the position of string sVal within strToSearch starting at position startingIndex. If ignoreCase is false does a case-sensitive search. Returns 0 if not found.
NOTE: Remember this is a 1 based search. The position of "A" within "ABC" is 1 as opposed to 0 when using string.IndexOf(). |
IsAlpha ( string value, string otherAllowableCharacters = "" ) |
bool - Returns true if value contains only A-Z or a-z OR it contains any characters in otherAllowableCharacters. |
IsAlphaNumeric ( string value, string otherAllowableCharacters = "" ) |
bool - Returns true if value contains only 0-9 or A-Z or a-z OR it contains any characters in otherAllowableCharacters. |
IsNumeric ( string value, string otherAllowableCharacters = "" ) |
bool - Returns true if value contains only characters 0-9 OR it contains any characters in otherAllowableCharacters. |
XMLToDataSet(string dsXML) |
System.Data.DataSet - Converts an XML string dsXML created with DataSetToXML() back into a System.Data.DataSet object. On failure it will return a NEW System.Data.DataSet object. |
XMLToDataTable(string dtXML) |
System.Data.DataTable - Converts an XML string dtXML created with DataTableToXML() back into a System.Data.DataTable object. On failure it will return a NEW System.Data.DataTable object. |
Property Name |
Data Type |
DefaultBOM |
string (read only) - Will return the ANSI HL7 default BOM (Begin Message) character. |
DefaultComponentDelimiter |
string (read only) - Will return the ANSI HL7 default component delimiter ^ . |
DefaultEOM |
string (read only) - Will return the ANSI HL7 default EOM (End of Message) characters. |
DefaultEscapeDelimiter |
string (read only) - Will return the ANSI HL7 default escape delimiter \ . |
DefaultFieldDelimiter |
string (read only) - Will return the ANSI HL7 default Field delimiter |. |
DefaultRepeatDelimiter |
string (read only) - Will return the ANSI HL7 default Repeat delimiter ~. |
DefaultSOM |
string (read only) - Will return the ANSI HL7 default SOM (Segment Delimiter) character which is a single Carriage Return COREScriptUtilities.CR. |
DefaultSubComponentDelimiter |
string (read only) - Will return the ANSI HL7 default Subcomponent delimiter &. |
TempFolder |
string - Will return the Windows Temporary folder with a trailing back slash \. |
Public Methods:
Method |
Return Value |
AddBackSlash(string value) |
string - Will append a backslash character \ to the end of value if one is not present. Useful when building folder names and file names. |
CountFilesInFolder ( string folder, string searchPattern = "*.*", int minimumDaysOld = 0 ) |
int - Will return a count of files in the Windows Directory folder that match searchPattern. The count will only include files which are at least minimumDaysOld based on the Last Modified date of each file. |
CountTokens ( string source, string token, bool ignoreCase = true ) |
int - Will count the number of times token occurs in string source. If ignoreCase is false does a case-sensitive search. |
DecodeBase64(string value) |
string- A non-static equivalent of COREScriptUtilities.Base64Decode() |
EncodeBase64(string value) |
string- A non-static equivalent of COREScriptUtilities.Base64Encode() |
GetAllFiles ( string fullPath, string searchPattern, SearchOptions options = SearchOptions.TopDirectoryOnly ) |
string[] - Will return a string array of file names found in fullPath matching searchPattern. Use options to perform a recursive directory search for files. Items in the array will be the full path/filename. If no files are found will return an empty array. |
IsFile(string fileName) |
bool - Implementation of File.Exists() with error trapping. |
IsFolder(string path) |
bool - Implementation of Directory.Exists() with error trapping. |
KillAFile(string fileName) |
bool - Implementation of File.Delete() with error trapping. It will make up to 3 attempts to delete file fileName. |
KillAllFiles ( string fullPath, string searchPattern, SearchOptions options = SearchOptions.TopDirectoryOnly ) |
COREException - Deletes all files in directory fullPath that match searchPattern. Use options to perform a recursive directory delete if wanted. The searchPattern is a standard windows file wildcard value, Example: "*.*" or "*.xml". Check the COREException.HasException() return value to see if any errors occurred. |
MyIPV4Addresses() |
SortedList<string, System.Net.IPAddress> - Will be a SortedList containing all of the IP Version 4 addresses detected on the local machine. |
NewMessageControlID() |
string- Returns a 20 character HL7 compliant message control id suitable for use in MSH 10.1 |

Under Construction Check Back Soon