我正在研究一个宏,它接受ICD代码并将代码转换为大约16个诊断类别之一。它首先识别代码是ICD 9还是10 (此部分工作),移除前导零(此操作),删除小数后的任何内容(此操作有效),然后使用If语句确定该代码属于哪个类别(适用于ICD9,但不适用于ICD10)。
ICD-10码采用letter.##格式,如'K50.814'.工作表函数将其转换为“K50”(通用组)。我的宏接受'K50‘。
错误的一个例子:
输入: R57
输出:#值
调试:
Debug.Print (strDxLetter):r
Debug.Print VarType(strDxLetter):8
Debug.Print (intDxCode):57
Function DxGroup2(Diagnosis As Variant)
'Diagnosis as variant because ICD9 uses only numbers whereas ICD10 starts with letter followed by numbers
Dim strDxLetter As String
'Variable will be used to store the first letter of the icd10 dx
Dim intDxCode As Integer
'Here there are normally if statements for ICD9 codes. This part works fine
'If not ICD 9 then the coding method used must have been ICD 10
Else
'Get the first character of the ICD code which is the diagnosis group letter
strDxLetter = Left(Diagnosis, 1)
'Get the rest of the ICD code which was converted to an integer in the worksheet
intDxCode = Mid(Diagnosis, 2, Len(Diagnosis))
'Here is where I tried error testing. The first letter is being returned accurately, the data type is string for the letter, and the code is being returned correctly
Debug.Print (strDxLetter)
Debug.Print VarType(strDxLetter)
Debug.Print (intDxCode)
'First match up the letter code with the diagnosis group
If strDxLetter = "A" Or "B" Then
DxGroup2 = "Infectious and Parasitic Disease"
ElseIf strDxLetter = "C" Then
DxGroup2 = "Neoplasms"
ElseIf strDxLetter = "D" Then
If intDxCode >= 0 And intDxCode <= 9 Then
DxGroup2 = "Neoplasms"
ElseIf intDxCode >= 50 And intDxCode <= 89 Then
DxGroup2 = "Blood and Blood-Forming Organs"
Else
DxGroup2 = "Manually lookup this code"
End If
ElseIf strDxLetter = "E" Then
DxGroup2 = "Endocrine, Nutritional, Metabolic, Immunity"
ElseIf strDxLetter = "F" Then
DxGroup2 = "Mental Disorders, Don't count this patient"
ElseIf strDxLetter = "G" Then
DxGroup2 = "Nervous System and Sense Organs"
ElseIf strDxLetter = "H" Then
If intDxCode > 0 And intDxCode <= 59 Then
DxGroup2 = "Disease of eye and adnexa"
ElseIf intDxCode > 59 And intDxCode <= 95 Then
DxGroup2 = "Diseaase of the ear and mastoid"
Else
DxGroup2 = "Manually look up this code"
End If
ElseIf strDxLetter = "I" Then
DxGroup2 = "Circulatory System"
ElseIf strDxLetter = "J" Then
DxGroup2 = "Respiratory System"
ElseIf strDxLetter = "K" Then
DxGroup2 = "Digestive System"
ElseIf strDxLetter = "L" Then
DxGroup2 = "Skin and Subcutaneous Tissue"
ElseIf strDxLetter = "M" Then
DxGroup2 = "Musculoskeletal System and Connective Tissue"
ElseIf strDxLetter = "N" Then
DxGroup2 = "Genitourinary System"
ElseIf strDxLetter = "O" Then
DxGroup2 = "Pregnancy, Childbirth, and the Puerperium"
ElseIf strDxLetter = "P" Then
DxGroup2 = "Conditions Originating in the Perinatal Period"
ElseIf strDxLetter = "Q" Then
DxGroup2 = "Congenital Malformations, chromosomal abnormalities"
ElseIf strDxLetter = "R" Then
DxGroup2 = "Nonspecific Abnormal Findings"
ElseIf strDxLetter = "S" Or strDxLetter = "T" Then
DxGroup2 = "Injury and Poisoning"
ElseIf strDxLetter = "V" Or strDxLetter = "W" Or strDxLetter = "X" Or strDxLetter = "Y" Then
DxGroup2 = "Ill-Defined and Unknown Causes of Morbidity and Mortality"
Else
DxGroup2 = "Supplemental"
End If
End If
Debug.Print DxGroup2
End Function发布于 2016-01-04 23:35:40
这里有一个问题:
If strDxLetter = "A" Or "B" Then应该是
If strDxLetter = "A" Or strDxLetter = "B" Thenhttps://stackoverflow.com/questions/34601439
复制相似问题