R/DIAGNOSIS.R

Defines functions diagnosis_lvl_2 diagnosis_lvl_1

Documented in diagnosis_lvl_1 diagnosis_lvl_2

#' Diagnosis Performed
#'
#' @param col A column in PTOS data that typically starts with 'icd9_'
#'
#' @return It translations of the code into human friendly values.
#' @export
diagnosis_lvl_1 <- function(col) {
  col_value <-  case.(col >= 1 & col  < 140, 'Infectious And Parasitic Diseases',
                      col >= 140 & col  < 240, 'Neoplasms',
                      col >= 240 & col  < 280, 'Endocrine, Nutritional And Metabolic Diseases, And Immunity Disorders',
                      col >= 280 & col  < 290, 'Diseases Of The Blood And Blood-Forming Organs',
                      col >= 290 & col  < 320, 'Mental Disorders',
                      col >= 320 & col  < 390, 'Diseases Of The Nervous System And Sense Organs',
                      col >= 390 & col  < 460, 'Diseases Of The Circulatory System',
                      col >= 460 & col  < 520, 'Diseases Of The Respiratory System',
                      col >= 520 & col  < 580, 'Diseases Of The Digestive System',
                      col >= 580 & col  < 630, 'Diseases Of The Genitourinary System',
                      col >= 630 & col  < 680, 'Complications Of Pregnancy, Childbirth, And The Puerperium',
                      col >= 680 & col  < 710, 'Diseases Of The Skin And Subcutaneous Tissue',
                      col >= 710 & col  < 740, 'Diseases Of The Musculoskeletal System And Connective Tissue',
                      col >= 740 & col  < 760, 'Congenital Anomalies',
                      col >= 760 & col  < 780, 'Certain Conditions Originating In The Perinatal Period',
                      col >= 780 & col  < 800, 'Symptoms, Signs, And Ill-Defined Conditions',
                      col >= 800 & col  <= 999, 'Injury And Poisoning',
                      default =   'Not Documented' )
  return(col_value)
}

#' @rdname diagnosis_lvl_1
#' @export

diagnosis_lvl_2 <- function(col) {
  col_value <-  case.(col >= 1 & col  < 10, 'Intestinal Infectious Diseases',
                      col >= 10 & col  < 20, 'Tuberculosis',
                      col >= 20 & col  < 30, 'Zoonotic Bacterial Diseases',
                      col >= 30 & col  < 42, 'Other Bacterial Diseases',
                      col >= 42 & col  < 45, 'Human Immunodeficiency Virus (Hiv) Infection',
                      col >= 45 & col  < 50, 'Poliomyelitis And Other Non-Arthropod-Borne Viral Diseases And Prion Diseases Of Central Nervous System',
                      col >= 50 & col  < 60, 'Viral Diseases Generally Accompanied By Exanthem',
                      col >= 60 & col  < 70, 'Arthropod-Borne Viral Diseases',
                      col >= 70 & col  < 80, 'Other Diseases Due To Viruses And Chlamydiae',
                      col >= 80 & col  < 90, 'Rickettsioses And Other Arthropod-Borne Diseases',
                      col >= 90 & col  < 100, 'Syphilis And Other Venereal Diseases',
                      col >= 100 & col  < 110, 'Other Spirochetal Diseases',
                      col >= 110 & col  < 120, 'Mycoses',
                      col >= 120 & col  < 130, 'Helminthiases',
                      col >= 130 & col  < 137, 'Other Infectious And Parasitic Diseases',
                      col >= 137 & col  < 140, 'Late Effects Of Infectious And Parasitic Diseases',
                      col >= 140 & col  < 150, 'Malignant Neoplasm Of Lip, Oral Cavity, And Pharynx',
                      col >= 150 & col  < 160, 'Malignant Neoplasm Of Digestive Organs And Peritoneum',
                      col >= 160 & col  < 170, 'Malignant Neoplasm Of Respiratory And Intrathoracic Organs',
                      col >= 170 & col  < 179, 'Malignant Neoplasm Of Bone, Connective Tissue, Skin, And Breast',
                      col >= 179 & col  < 190, 'Malignant Neoplasm Of Genitourinary Organs',
                      col >= 190 & col  < 200, 'Malignant Neoplasm Of Other And Unspecified Sites',
                      col >= 200 & col  < 209, 'Malignant Neoplasm Of Lymphatic And Hematopoietic Tissue',
                      col >= 209 & col  < 210, 'Neuroendocrine Tumors',
                      col >= 210 & col  < 230, 'Benign Neoplasms',
                      col >= 230 & col  < 235, 'Carcinoma In Situ',
                      col >= 235 & col  < 239, 'Neoplasms Of Uncertain Behavior',
                      col >= 239 & col  < 240, 'Neoplasms Of Unspecified Nature',
                      col >= 240 & col  < 249, 'Disorders Of Thyroid Gland',
                      col >= 249 & col  < 260, 'Diseases Of Other Endocrine Glands',
                      col >= 260 & col  < 270, 'Nutritional Deficiencies',
                      col >= 270 & col  < 290, 'Other Metabolic And Immunity Disorders',
                      col >= 290 & col  < 290, 'Psychoses',
                      col >= 290 & col  < 295, 'Organic Psychotic Conditions',
                      col >= 295 & col  < 300, 'Other Psychoses',
                      col >= 300 & col  < 317, 'Neurotic Disorders, Personality Disorders, And Other Nonpsychotic Mental Disorders',
                      col >= 317 & col  < 320, 'Intellectual Disabilities',
                      col >= 320 & col  < 327, 'Inflammatory Diseases Of The Central Nervous System',
                      col >= 327 & col  < 330, 'Organic Sleep Disorders',
                      col >= 330 & col  < 338, 'Hereditary And Degenerative Diseases Of The Central Nervous System',
                      col >= 338 & col  < 339, 'Pain',
                      col >= 339 & col  < 340, 'Other Headache Syndromes',
                      col >= 340 & col  < 350, 'Other Disorders Of The Central Nervous System',
                      col >= 350 & col  < 360, 'Disorders Of The Peripheral Nervous System',
                      col >= 360 & col  < 380, 'Disorders Of The Eye And Adnexa',
                      col >= 380 & col  < 390, 'Diseases Of The Ear And Mastoid Process',
                      col >= 390 & col  < 393, 'Acute Rheumatic Fever',
                      col >= 393 & col  < 401, 'Chronic Rheumatic Heart Disease',
                      col >= 401 & col  < 410, 'Hypertensive Disease',
                      col >= 410 & col  < 415, 'Ischemic Heart Disease',
                      col >= 415 & col  < 420, 'Diseases Of Pulmonary Circulation',
                      col >= 420 & col  < 430, 'Other Forms Of Heart Disease',
                      col >= 430 & col  < 440, 'Cerebrovascular Disease',
                      col >= 440 & col  < 451, 'Diseases Of Arteries, Arterioles, And Capillaries',
                      col >= 451 & col  < 460, 'Diseases Of Veins And Lymphatics, And Other Diseases Of Circulatory System',
                      col >= 460 & col  < 470, 'Acute Respiratory Infections',
                      col >= 470 & col  < 480, 'Other Diseases Of The Upper Respiratory Tract',
                      col >= 480 & col  < 490, 'Pneumonia And Influenza',
                      col >= 490 & col  < 500, 'Chronic Obstructive Pulmonary Disease And Allied Conditions',
                      col >= 500 & col  < 510, 'Pneumoconioses And Other Lung Diseases Due To External Agents',
                      col >= 510 & col  < 520, 'Other Diseases Of Respiratory System',
                      col >= 520 & col  < 530, 'Diseases Of Oral Cavity, Salivary Glands, And Jaws',
                      col >= 530 & col  < 540, 'Diseases Of Esophagus, Stomach, And Duodenum',
                      col >= 540 & col  < 550, 'Appendicitis',
                      col >= 550 & col  < 555, 'Hernia Of Abdominal Cavity',
                      col >= 555 & col  < 560, 'Noninfectious Enteritis And Colitis',
                      col >= 560 & col  < 570, 'Other Diseases Of Intestines And Peritoneum',
                      col >= 570 & col  < 580, 'Other Diseases Of Digestive System',
                      col >= 580 & col  < 590, 'Nephritis, Nephrotic Syndrome, And Nephrosis',
                      col >= 590 & col  < 600, 'Other Diseases Of Urinary System',
                      col >= 600 & col  < 610, 'Diseases Of Male Genital Organs',
                      col >= 610 & col  < 614, 'Disorders Of Breast',
                      col >= 614 & col  < 617, 'Inflammatory Disease Of Female Pelvic Organs',
                      col >= 617 & col  < 630, 'Other Disorders Of Female Genital Tract',
                      col >= 630 & col  < 634, 'Ectopic And Molar Pregnancy',
                      col >= 634 & col  < 640, 'Other Pregnancy With Abortive Outcome',
                      col >= 640 & col  < 650, 'Complications Mainly Related To Pregnancy',
                      col >= 650 & col  < 660, 'Normal Delivery, And Other Indications For Care In Pregnancy, Labor, And Delivery',
                      col >= 660 & col  < 670, 'Complications Occurring Mainly In The Course Of Labor And Delivery',
                      col >= 670 & col  < 678, 'Complications Of The Puerperium',
                      col >= 678 & col  < 680, 'Other Maternal And Fetal Complications',
                      col >= 680 & col  < 690, 'Infections Of Skin And Subcutaneous Tissue',
                      col >= 690 & col  < 700, 'Other Inflammatory Conditions Of Skin And Subcutaneous Tissue',
                      col >= 700 & col  < 710, 'Other Diseases Of Skin And Subcutaneous Tissue',
                      col >= 710 & col  < 720, 'Arthropathies And Related Disorders',
                      col >= 720 & col  < 725, 'Dorsopathies',
                      col >= 725 & col  < 730, 'Rheumatism, Excluding The Back',
                      col >= 730 & col  < 760, 'Osteopathies, Chondropathies, And Acquired Musculoskeletal Deformities',
                      col >= 760 & col  < 764, 'Maternal Causes Of Perinatal Morbidity And Mortality',
                      col >= 764 & col  < 780, 'Other Conditions Originating In The Perinatal Period',
                      col >= 780 & col  < 790, 'Symptoms',
                      col >= 790 & col  < 797, 'Nonspecific Abnormal Findings',
                      col >= 797 & col  < 800, 'Ill-Defined And Unknown Causes Of Morbidity And Mortality',
                      col >= 800 & col  < 800, 'Fractures',
                      col >= 800 & col  < 805, 'Fracture Of Skull',
                      col >= 805 & col  < 810, 'Fracture Of Neck And Trunk',
                      col >= 810 & col  < 820, 'Fracture Of Upper Limb',
                      col >= 820 & col  < 830, 'Fracture Of Lower Limb',
                      col >= 830 & col  < 840, 'Dislocation',
                      col >= 840 & col  < 850, 'Sprains And Strains Of Joints And Adjacent Muscles',
                      col >= 850 & col  < 860, 'Intracranial Injury, Excluding Those With Skull Fracture',
                      col >= 860 & col  < 870, 'Internal Injury Of Thorax, Abdomen, And Pelvis',
                      col >= 870 & col  < 870, 'Open Wounds',
                      col >= 870 & col  < 880, 'Open Wound Of Head, Neck, And Trunk',
                      col >= 880 & col  < 890, 'Open Wound Of Upper Limb',
                      col >= 890 & col  < 900, 'Open Wound Of Lower Limb',
                      col >= 900 & col  < 905, 'Injury To Blood Vessels',
                      col >= 905 & col  < 910, 'Late Effects Of Injuries, Poisonings, Toxic Effects, And Other External Causes',
                      col >= 910 & col  < 920, 'Superficial Injury',
                      col >= 920 & col  < 925, 'Contusion With Intact Skin Surface',
                      col >= 925 & col  < 930, 'Crushing Injury',
                      col >= 930 & col  < 940, 'Effects Of Foreign Body Entering Through Orifice',
                      col >= 940 & col  < 950, 'Burns',
                      col >= 950 & col  < 958, 'Injury To Nerves And Spinal Cord',
                      col >= 958 & col  < 960, 'Certain Traumatic Complications And Unspecified Injuries',
                      col >= 960 & col  < 980, 'Poisoning By Drugs, Medicinal And Biological Substances',
                      col >= 980 & col  < 990, 'Toxic Effects Of Substances Chiefly Nonmedicinal As To Source',
                      col >= 990 & col  < 996, 'Other And Unspecified Effects Of External Causes',
                      col >= 996 & col  <= 999, 'Complications Of Surgical And Medical Care, Not Elsewhere Classified',

                      default =   'Not Documented' )
  return(col_value)
}

#' @rdname diagnosis_lvl_2
#' @export
ultramattyice/traumaR documentation built on June 11, 2020, 2:22 p.m.