I cannot find a definitive guide to icd9 code formats.
Can anyone explain the format - especially the use of trailing and leading zeros?
A C# regex for icd9 and icd10 codes would also be nice.
Thanks!
I was looking for the same thing and found what I believe to be a more complete answer. Thought I'd help anyone else coming in the future.
ICD-9 Regex
The ICD 9 format has a bunch of ways it can be formatted. It can begin with V, E, or a number.
If it begins with V, then it has 2 numbers, a decimal, then up to
two numbers
Examples: V10.12 and V12
If it begins when E, then it has 3 numbers, the decimal place, then up to two numbers
Examples: E000.0 and E002
If it begins with a number, then it is up to 3 numbers, a decimal, then up to two numbers
Examples: 730.12 and 730
A good regex that checks all these rules is (Credit goes to sascomunitt)
^(V\d{2}(\.\d{1,2})?|\d{3}(\.\d{1,2})?|E\d{3}(\.\d)?)$
ICD-10 Regex
According to www.cms.gov ICD-10 has the following rules:
3-7 Characters
Character 1 is alpha (cannot be U)
Character 2 is numeric
Characters 3-7 are alphanumeric
After 3 characters you use a decimal
Use of dummy placeholder "x" (This is the only one I am not accounting for in my regex...)
Alpha characters are not case sensitive
Here is the regex I came up with:
^[A-TV-Z][0-9][A-Z0-9](\.[A-Z0-9]{1,4})?$
Note These regexes are for javascript and may need tweaked for C# (I'm too lazy to test it right now)
An ICD-9 code looks like this:
two/three-digit numeric code (may have leading zeroes to pad to three digits)
an optional dot
if that dot is present, there will be one or two following digits, depending on the preceding three digits. Which digits are allowed specifically is very variable.
Some codes are prefixed by an E or V.
An ICD-10 code looks like this:
an uppercase ASCII letter (A-Z)
two digits
an optional dot
if that dot is present, there will be one or two following digits. Again, it's highly variable which ICD codes allow for which digits after the dot.
Sometimes, you'll find an asterisk, a plus sign (at least in ASCII texts), or an exclamation point after a code. They are used in certain combination codes.
So, in essence, you could use regex to find ICD codes in a text, but you won't be able to validate them.
A C# regex for ICD-9 codes could look like this: #"\b[EV]?\d{2,3}(?:\.\d{1,2})?\b".
For an ICD-10 code: #"\b[A-Z]\d{2}(?:\.\d{1,2})?\b[*+!]?"
Are you referring to ICD-9 diagnosis codes? Then see this thread: ICD-9 Code List in XML, CSV, or Database format.
There are 2 types of ICD 9 codes: Diagnosis Codes & Procedure Codes
for the Diagnosis Codes Gordon Tucker has the correct answer:
^(V\d{2}(\.\d{1,2})?|\d{3}(\.\d{1,2})?|E\d{3}(\.\d)?)$
ICD-9-CM procedure codes are 2 numbers, a decimal, then up to two numbers (to be a complete code 2 numbers are required)
A regex for these codes would be:
^\d{2}.\d{1,2}$
ICD-9-CM Procedure Codes
2012 ICD-9-CM Diagnosis Codes
Related
I Want to apply SuperScript to String for display
It works fine with numbers in superscript, doesn't work for String characters.
Suggestions needed.
Works fine for :
var o2 = "O₂"; // or "O\x2082"
var unit2 = "unit²"; // or "unit\xB2"
Does not work for :
var xyz = "ABC365\xBTM"
Can not get TM superscripted over string ABC365.
Suggestions appreciated.
You seem to have completely misunderstood what is going on here, so I'll try a very basic explanation.
Unicode defines a large number of characters (some 1,114,111 if I remember right). These came from a large number of historic sources, and there's no great rhyme or reason about which characters made it in and which didn't. The available characters include some subscript and superscript digits, for example x2082 is subscript 2, and x00B2 is superscript 2. It also includes some special symbols such as the trademark symbol x2122 which are traditionally rendered with a superscript appearance.
But there's no general mechanism in Unicode to render any character in superscript or subscript rendition. If you want to write Xn, Unicode won't help you: to achieve that I had to resort to mechanisms outside Unicode, specifically HTML tagging. HTML allows you to render anything as subscript or superscript; Unicode only handles a few select cases.
C# recognizes the escape sequences \xHH and \xHHHH (depending on context), where H is any hex digit, to represent special characters by their Unicode code point value. So if there's a codepoint x2082 meaning subscript 2, you can write it as \x2082 in a Unicode string literal. But there's no codepoint for subscript-lowercase-italic N, so there's no way of representing that.
Now when you write \xBTM it should be clear that's nonsense. \x must be followed by 2 or 4 hex digits (depending on context). If you want the trademark symbol, you can use \x2122. If you want the two characters "T" and "M" in superscript rendition, you're out of luck; if you need to pass that sort of thing around in your application, you will need to pass strings containing HTML markup, rather than just plain Unicode.
You indicate that you're trying to create strings that will be used as input to an XSLT transformation. My suggestion would to pass XML documents rather than plain strings: but I would need to understand the requirement in better detail before saying that's definitively the right solution.
I know there are many questions about making regular expressions, but they all seem to be about a single problem than the general usage. I, too, have a problem like to solve. I have tried to learn by reading about regular expressions, but it gets tricky quick. Here's my question:
C#
I need to validate two textboxes that exist on the same form. The math operations I've coded can handle any floating point number. For this particular application I know of three formats the numbers will be in or there is a mistake on the users behalf. I'd like to prevent those mistakes in example if an extra number is accidentally typed or if enter is hit too early, etc.
Here are the formats: "#.####" "##.####" "###.##" where the "#" represents a mandatory digit. The formats starting with a one or two digit whole number must have 4 trailing digits or more. I've capped it at 8, or so I tried to lol.The format starting with a three digit whole number should never be allowed to have more than two digits trailing the decimal.
Here's what I have tried thus far.
Regex acceptedInputRegex = new Regex(#"^\b[0-9]{3}.[0-9]{2}|[0-9]{1,2}.[0-9]{4,8}$");
Regex acceptedInputRegex = new Regex(#"^\b\d{3}.\d{2} | \d{1,2}.\d{4,8}$");
I have tried it in thinking a match was what I wanted to achieve and as if a match to my negated expression means there is a problem. I was unsuccessful in both attempts. This is the code:
if (acceptedInputRegex.IsMatch(txtMyTextBox1.Text) || acceptedInputRegex.IsMatch(txtMyTextBox2.Text))
{
} else
{
MessageBox.Show("Numbers are not in the right format", "Invalid Input!");
return;
}
Are regular expressions what I should be using to solve this problem?
If not, please tell me what you recommend. If so, please help me correct my regex.
Thanks.
You are close, you need to escape the dots and group the alternatives so that the ^ and $ anchors could be applied to both of them:
#"^(?:\d{3}\.\d{2}|\d{1,2}\.\d{4,8})$"
See the regex demo.
Details:
^ - start of string
(?: - start of a non-capturing group matching either of the two alternatives:
\d{3}\.\d{2} - 3 digits, . and 2 digits
| - or
\d{1,2}\.\d{4,8} - 1 or 2 digits, ., 4 to 8 digits
) - end of the non-capturing group
$ - end of string.
To make \d match only ASCII digits, use RegexOptions.ECMAScript option:
var isValid = Regex.IsMatch(s, #"^(?:\d{3}\.\d{2}|\d{1,2}\.\d{4,8})$", RegexOptions.ECMAScript);
I need a regular expression validation expression that will
ALLOW
positive number(0-9)
, and .
DISALLOW
letter(a-z)
any other letter or symbol except . and ,
for example, on my asp.net text box, if I type anything#!#--, the regular expression validation will disallow it, if I type 10.000,50 or 10,000.50 it should allowed.
I've been trying to use this regex:
^\d+(\.\d\d)?$
but my textbox also must allow , symbol and I tried using only integer regex validation, it did disallow if I type string, but it also disallow . and , symbol while it should allow number(0-9) and also . and , symbol
Don't Use \d to match [0-9] in .NET
First off, in .NET, \d will match any digits in any script, such as:
654۳۲١८৮੪૯୫୬१७੩௮௫౫೮൬൪๘໒໕២៧៦᠖
So you really want to be using [0-9]
Incomplete Spec
You say you want to only allow "digits, commas and periods", but I don't think that's the whole spec. That would be ^[0-9,.]+$, and that would match
...,,,
See demo.
Tweaking the Spec
It's hard to guess what you really want to allow: would 10,1,1,1 be acceptable?
We could start with something like this, to get some fairly well-formed strings:
^(?:[0-9]+(?:[.,][0-9]+)?|[1-9][0-9]{0,2}(?:(?:\.[0-9]{3})*|(?:,[0-9]{3})*)(?:\.[0-9]+)?)$
Play with the demo, see what should and shouldn't match... When you are sure about the final spec, we can tweak the regex.
Sample Matches:
0
12
12.123
12,12
12,123,123
12,123,123.12456
12.125.457.22
Sample Non-Matches:
12,
123.
1,1,1,1
Your regex would be,
(?:\d|[,\.])+
OR
^(?:\d|[,\.])+$
It matches one or more numbers or , or . one or more times.
DEMO
Maybe you can use this one (starts with digit, ends with digit):
(\d+[\,\.])*\d+
If you need more sophisticated price Regex you should use:
(?:(?:[1-9]\d?\d?([ \,\.]?\d{3})*)|0)(?:[\.\,]\d+)?
Edit: To make it more reliable (and dont get 00.50) you can add starting and ending symbol check:
(^|\s)(?:(?:[1-9]\d?\d?([ \,\.]?\d{3})*)|0)(?:[\.\,]\d+)($|\s)?
I think the best regex for your condition will be :
^[\d]+(?:,\d+)*(?:\.\d+)?$
this will validate whatever you like
and at the same time:
not validate:
numbers ending in ,
numbers ending in .
numbers having . before comma
numbers having more than one decimal points
check out the demo here : http://regex101.com/r/zI0mJ4
Your format is a bit strange as it is not a standard format.
My first thought was to put a float instead of a string and put a Range validation attribute to avoid negative number.
But because of formatting, not sure it would work.
Another way is the regex, of course.
The one you propose means :
"some numbers then possibly a group formed by a dot and two numbers exactly".
This is not what you exepected.
Strictly fitted your example of a number lower than 100,000.99 one regex could be :
^[0-9]{1-2}[\.,][0-9]{3}([\.,][0-9]{1-2})?$
A more global regex, that accept all positive numbers is the one posted by Avinash Raj : (?:\d|[,\.])+
I am translating some code from VB to C# and came across this:
Format(seg.R, " 00.00000;-00.00000") // <-- There is a leading space in the first format string
...which prints...
00.00000 //or...
-00.00000
...depending on whether the decimal is positive or negative. Is there an easy way to do this with the C# string.Format or myObj.ToString("[format here]") functions?
EDIT: Notice the extra space in the format string. This makes the strings the same length by adding a leading space when there is no negative sign.
Yes:
http://blog.stevex.net/string-formatting-in-csharp/
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
Here's a quick answer for what you posted above:
whateverstring.ToString(" 00.00000;-00.00000");
-29.69 -> "-29.69000"
48 -> " 48.00000" <-notice space padding the front.
The semi colon separated formatting string: "00.00;##.##" applies the 00.00 pattern to Positive and zero values, and the ##.## pattern to negative values.
In other words, what you had before for a formatting string works without any tweaking :-)
Yes, String.Format() will do anything VB Classic's Format function would do.
http://blogs.msdn.com/b/kathykam/archive/2006/03/29/564426.aspx
I want to display a negative symbol from a string in .NET. I want a string that represents an equation that looks something like this:
7--5=12
But when displayed, I want the 2nd minus sign to be slightly raised so it looks more natural as a negative sign instead of just 2 minus signs in a row.
Is this possible?
Not sure if theres a character for what you want but a simple solution (and one that would be easily understood and implemented) would be to surround your negative number in brackets:
7 - (-5) = 13
Use the Unicode character SUPERSCRIPT MINUS (U+207B) ⁻.
For example:
7-⁻5 = 13
EDIT: Or, with a MINUS SIGN (U+2212) ⁻ for the minus:
7 − ⁻5 = 13
Provided that you're using unicode you can use a true minus sign, "−" (U+2212) rather than a hyphen-minus, "-" (U+002D). Just be aware that it's not ASCII compatible
Here's your example showing them:
7 - −5=13
Also, here's some fun wiki-articles on all sorts of dash-hyphen-minus lines:
http://en.wikipedia.org/wiki/Dash#Common_dashes
http://en.wikipedia.org/wiki/Minus_sign#Character_codes
This is a great resource on format strings in C#:
SteveX Compiled - Format Strings
You can choose how a negative number is displayed by using a range expression for your format string. It's in the format:
{0:<PositiveFormat>;<NegativeFormat>;<ZeroFormat>}
For example, this is how to display a negative number in parenthesis and the word "Zero" for 0:
{0:#;(#);Zero}
Using this technique, I think you can try it with the superscript version of negative (which is ascii code U+207B) in the negative format string.
{0:#;⁻#;Zero}
HTH, Anderson
Traditionally in math typography you use an en dash U+2013 or minus U+2212 (but not a hyphen!) for both binary (subtraction) and unary (negation) minus, and they are differentiated with spacing (spaces before and after a binary minus, no space between a unary minus and the number it negates).
But if you want to further distinguish the unary, I'd recommend substituting the superscript minus U+207B (but keep the spacing around the subtraction minus):
7 − ⁻5 = 13
You can use the Unicode character U+2212 (Minus Sign): 7-−5=13
In the font I'm using, the minus sign is displayed slightly raised relative to the dash. Your results may vary.
Unicode "superscript minus" http://www.fileformat.info/info/unicode/char/207b/index.htm
char c = '\u207b';