Additional String Extraction Methods Pieces

Total Page:16

File Type:pdf, Size:1020Kb

Additional String Extraction Methods Pieces

Unit 17 – String Extraction 1

String Extraction

Unit 17

MEDITECH Level One - NPR Report Writer Workshop Unit 17 – String Extraction 2

String extraction operators provide a means of extracting a character or sub-string from a string of characters. Each data field contains a string of characters as its value. Each character in the string occupies a position within the string. The positions are numeric starting from left to right with position 0 (so the first character of every string is at position 0). The is the not operator and produces the opposite effect of the operator. String extraction is pri- marily used to extract characters from a string that has a set length, format or value. For in- stance, data fields with a data type of DATE are stored as an eight digit value in the form YYYYMMDD. The date 08/19/08 is stored as 20080819. The following example shows how the string extraction operator can be used to extract pieces of a date string:

The example which extracts the month shows how to extract a sub-string that exists in the middle of the string. It’s best to work from right to left so that the string positions will not change.

MEDITECH Level One - NPR Report Writer Workshop Unit 17 – String Extraction 3

Additional String Extraction Methods -- Pieces

Some data fields contain strings that are delimited by a certain character (Phone number, name or social security number). Pieces can be used to extract certain sub-strings from this type of value. This is accomplished by using the same string extractors we previously discussed and appending a quote, the number of the piece and the character that you want to delimit the field by.

Pieces change the method of calculating positions within the string. Instead of each character occupying one position within the string, the string is positioned by substrings. What this means is that each alphanumeric sub-string occupies a position and each non-alphanumeric character occupies a position.

The underscore can be used to concatenate strings together. In the example above this will concatenate the first and last name together with a space between the first and last name. When using the string extraction and concatenation, you will need to make sure parentheses are used on the second instance of string extraction. This is needed since report writer works strictly left to right. So, in order to perform string extraction only on the first name the @name#”0,” must be in parenthesis.

There are other ways in which to extract data from a string. For example you could use Tokens. Tokens can be used to extract certain sub-strings. This is accomplished by using the same string extractors we previously discussed and appending an A after the number. For more information on string extraction you can go to the Report Writer Product Resource Home Page. http://www.meditech.com/prrw/pages/RWcbASoperators.htm

MEDITECH Level One - NPR Report Writer Workshop Unit 17 – String Extraction 4

The pieces method allows the user to identify the delimiter within the string extraction statement. Workshop

 Edit this report to print the Social Security Number of the patient without dashes. o Try using two different methods. First with just the string extraction operators and then again with pieces.

MEDITECH Level One - NPR Report Writer Workshop

Recommended publications