schibsted / jslt

JSON query and transformation language
Apache License 2.0
630 stars 119 forks source link

hang or error when defined function exceeds 1100+ lines? #216

Open vincentytran opened 3 years ago

vincentytran commented 3 years ago

I need to do a lookup / translation for a coded value and grab it's description.

def taxonomyCodeToSpecialtyAttrSubGroup(code)
    if ($code == "193200000X") ""
    else if ($code == "193400000X") ""
    else if ($code == "207K00000X") ""
    else if ($code == "207KA0200X") "Allergy"
    else if ($code == "207KI0005X") "Clinical & Laboratory Immunology"
    else if ($code == "207L00000X") ""

and I noticed once I get into 1100+ else if statements it seems to hang in apache camel and the jslt demo playground. I don't know the exact number it hangs though but it's close to 1100 somewhere.

Any ideas or alternatives would be helpful thanks!

EDIT, I noticed that if I break the defined function from 1600 to two functions of 800 lines each, then it works in the demo playground. So I believe the root of this error might be the maximum number of lines that could exist in an if statement OR the maximum number of lines that can exist in a custom defined function?

larsga commented 3 years ago

You can do it like this:

def taxonomyCodeToSpecialtyAttrSubGroup(code)
    let table = { "193200000X" : "",
      "193400000X" : "",
      "207K00000X" :  "",
      "207KA0200X" : "Allergy",
      "207KI0005X" : "Clinical & Laboratory Immunology",
      "207L00000X" : "",
   }
   get-key($table, $code)

However, it would be interesting to see your transform with 1100+ else branches, and to check the performance of it. Could you attach it to the issue as a file?

vincentytran commented 3 years ago

attached is an example that would break apache camel or the jslt playground that has around 1700 else if statements, thanks for the better solution to the problem, I will test it out.

large function many else if hang example.txt

catull commented 3 years ago

You can also leave out all the keys which produce an empty string, thus

def taxonomyCodeToSpecialtyAttrSubGroup(code)
    let table = { "193200000X" : "",
      "207KA0200X" : "Allergy",
      "207KI0005X" : "Clinical & Laboratory Immunology"
   }
   get-key($table, $code, "")

Here, if code is any one of '193400000X', '207K00000X' or '207L00000X', the result is "". That way you reduce the table map considerably.

Good luck.

catull commented 3 years ago

I reduced the foot-print from 1715 lines down to 1243.

Also, most codes appeared twice, so now the code I have in the playground clocks in at 626 lines. Way more manageable.

Here, my JSON input:

{
  "code": "3418M1130X"
}

And here's the JSTL code:

let codeMap = {
  "101YA0400X": "Addiction (Substance Use Disorder)",
  "101YM0800X": "Mental Health",
  "101YP1600X": "Pastoral",
  "101YP2500X": "Professional",
  "101YS0200X": "School",
  "103TA0400X": "Addiction (Substance Use Disorder)",
  "103TA0700X": "Adult Development & Aging",
  "103TB0200X": "Cognitive & Behavioral",
  "103TC0700X": "Clinical",
  "103TC1900X": "Counseling",
  "103TC2200X": "Clinical Child & Adolescent",
  "103TE1100X": "Exercise & Sports",
  "103TF0000X": "Family",
  "103TF0200X": "Forensic",
  "103TH0004X": "Health",
  "103TH0100X": "Health Service",
  "103TM1800X": "Intellectual & Developmental Disabilities",
  "103TP0016X": "Prescribing (Medical)",
  "103TP0814X": "Psychoanalysis",
  "103TP2701X": "Group Psychotherapy",
  "103TR0400X": "Rehabilitation",
  "103TS0200X": "School",
  "1041C0700X": "Clinical",
  "1041S0200X": "School",
  "111NI0013X": "Independent Medical Examiner",
  "111NI0900X": "Internist",
  "111NN0400X": "Neurology",
  "111NN1001X": "Nutrition",
  "111NP0017X": "Pediatric Chiropractor",
  "111NR0200X": "Radiology",
  "111NR0400X": "Rehabilitation",
  "111NS0005X": "Sports Physician",
  "111NT0100X": "Thermography",
  "111NX0100X": "Occupational Health",
  "111NX0800X": "Orthopedic",
  "1223D0001X": "Dental Public Health",
  "1223D0004X": "Dentist Anesthesiologist",
  "1223E0200X": "Endodontics",
  "1223G0001X": "General Practice",
  "1223P0106X": "Oral and Maxillofacial Pathology",
  "1223P0221X": "Pediatric Dentistry",
  "1223P0300X": "Periodontics",
  "1223P0700X": "Prosthodontics",
  "1223S0112X": "Oral and Maxillofacial Surgery",
  "1223X0008X": "Oral and Maxillofacial Radiology",
  "1223X0400X": "Orthodontics and Dentofacial Orthopedics",
  "1223X2210X": "Orofacial Pain",
  "133NN1002X": "Nutrition, Education",
  "133VN1004X": "Nutrition, Pediatric",
  "133VN1005X": "Nutrition, Renal",
  "133VN1006X": "Nutrition, Metabolic",
  "133VN1101X": "Nutrition, Gerontological",
  "133VN1201X": "Nutrition, Obesity and Weight Management",
  "133VN1301X": "Nutrition, Oncology",
  "133VN1401X": "Nutrition, Pediatric Critical Care",
  "133VN1501X": "Nutrition, Sports Dietetics",
  "152WC0802X": "Corneal and Contact Management",
  "152WL0500X": "Low Vision Rehabilitation",
  "152WP0200X": "Pediatrics",
  "152WS0006X": "Sports Vision",
  "152WV0400X": "Vision Therapy",
  "152WX0102X": "Occupational Vision",
  "156FC0800X": "Contact Lens",
  "156FC0801X": "Contact Lens Fitter",
  "156FX1100X": "Ophthalmic",
  "156FX1101X": "Ophthalmic Assistant",
  "156FX1201X": "Optometric Assistant",
  "156FX1202X": "Optometric Technician",
  "156FX1700X": "Ocularist",
  "156FX1800X": "Optician",
  "156FX1900X": "Orthoptist",
  "163WA0400X": "Addiction (Substance Use Disorder)",
  "163WA2000X": "Administrator",
  "163WC0200X": "Critical Care Medicine",
  "163WC0400X": "Case Management",
  "163WC1400X": "College Health",
  "163WC1500X": "Community Health",
  "163WC1600X": "Continuing Education/Staff Development",
  "163WC2100X": "Continence Care",
  "163WC3500X": "Cardiac Rehabilitation",
  "163WD0400X": "Diabetes Educator",
  "163WD1100X": "Dialysis, Peritoneal",
  "163WE0003X": "Emergency",
  "163WE0900X": "Enterostomal Therapy",
  "163WF0300X": "Flight",
  "163WG0000X": "General Practice",
  "163WG0100X": "Gastroenterology",
  "163WG0600X": "Gerontology",
  "163WH0200X": "Home Health",
  "163WH0500X": "Hemodialysis",
  "163WH1000X": "Hospice",
  "163WI0500X": "Infusion Therapy",
  "163WI0600X": "Infection Control",
  "163WL0100X": "Lactation Consultant",
  "163WM0102X": "Maternal Newborn",
  "163WM0705X": "Medical-Surgical",
  "163WM1400X": "Nurse Massage Therapist (NMT)",
  "163WN0002X": "Neonatal Intensive Care",
  "163WN0003X": "Neonatal, Low-Risk",
  "163WN0300X": "Nephrology",
  "163WN0800X": "Neuroscience",
  "163WN1003X": "Nutrition Support",
  "163WP0000X": "Pain Management",
  "163WP0200X": "Pediatrics",
  "163WP0218X": "Pediatric Oncology",
  "163WP0807X": "Psychiatric/Mental Health, Child & Adolescent",
  "163WP0808X": "Psychiatric/Mental Health",
  "163WP0809X": "Psychiatric/Mental Health, Adult",
  "163WP1700X": "Perinatal",
  "163WP2201X": "Ambulatory Care",
  "163WR0006X": "Registered Nurse First Assistant",
  "163WR0400X": "Rehabilitation",
  "163WR1000X": "Reproductive Endocrinology/Infertility",
  "163WS0121X": "Plastic Surgery",
  "163WS0200X": "School",
  "163WU0100X": "Urology",
  "163WW0000X": "Wound Care",
  "163WW0101X": "Women's Health Care, Ambulatory",
  "163WX0002X": "Obstetric, High-Risk",
  "163WX0003X": "Obstetric, Inpatient",
  "163WX0106X": "Occupational Health",
  "163WX0200X": "Oncology",
  "163WX0601X": "Otorhinolaryngology & Head-Neck",
  "163WX0800X": "Orthopedic",
  "163WX1100X": "Ophthalmic",
  "163WX1500X": "Ostomy Care",
  "1710I1002X": "Independent Duty Corpsman",
  "1710I1003X": "Independent Duty Medical Technicians",
  "171WH0202X": "Home Modifications",
  "171WV0202X": "Vehicle Modifications",
  "1744G0900X": "Graphics Designer",
  "1744P3200X": "Prosthetics Case Management",
  "1744R1102X": "Research Study",
  "1744R1103X": "Research Data Abstracter/Coder",
  "174MM1900X": "Medical Research",
  "1835C0205X": "Critical Care",
  "1835G0303X": "Geriatric",
  "1835N0905X": "Nuclear",
  "1835N1003X": "Nutrition Support",
  "1835P0018X": "Pharmacist Clinician (PhC)/ Clinical Pharmacy Specialist",
  "1835P0200X": "Pediatrics",
  "1835P1200X": "Pharmacotherapy",
  "1835P1300X": "Psychiatric",
  "1835P2201X": "Ambulatory Care",
  "1835X0200X": "Oncology",
  "207KA0200X": "Allergy",
  "207KI0005X": "Clinical & Laboratory Immunology",
  "207LA0401X": "Addiction Medicine",
  "207LC0200X": "Critical Care Medicine",
  "207LH0002X": "Hospice and Palliative Medicine",
  "207LP2900X": "Pain Medicine",
  "207LP3000X": "Pediatric Anesthesiology",
  "207ND0101X": "MOHS-Micrographic Surgery",
  "207ND0900X": "Dermatopathology",
  "207NI0002X": "Clinical & Laboratory Dermatological Immunology",
  "207NP0225X": "Pediatric Dermatology",
  "207NS0135X": "Procedural Dermatology",
  "207PE0004X": "Emergency Medical Services",
  "207PE0005X": "Undersea and Hyperbaric Medicine",
  "207PH0002X": "Hospice and Palliative Medicine",
  "207PP0204X": "Pediatric Emergency Medicine",
  "207PS0010X": "Sports Medicine",
  "207PT0002X": "Medical Toxicology",
  "207QA0000X": "Adolescent Medicine",
  "207QA0401X": "Addiction Medicine",
  "207QA0505X": "Adult Medicine",
  "207QB0002X": "Obesity Medicine",
  "207QG0300X": "Geriatric Medicine",
  "207QH0002X": "Hospice and Palliative Medicine",
  "207QS0010X": "Sports Medicine",
  "207QS1201X": "Sleep Medicine",
  "207RA0000X": "Adolescent Medicine",
  "207RA0001X": "Advanced Heart Failure and Transplant Cardiology",
  "207RA0002X": "Adult Congenital Heart Disease",
  "207RA0201X": "Allergy & Immunology",
  "207RA0401X": "Addiction Medicine",
  "207RB0002X": "Obesity Medicine",
  "207RC0000X": "Cardiovascular Disease",
  "207RC0001X": "Clinical Cardiac Electrophysiology",
  "207RC0200X": "Critical Care Medicine",
  "207RE0101X": "Endocrinology, Diabetes & Metabolism",
  "207RG0100X": "Gastroenterology",
  "207RG0300X": "Geriatric Medicine",
  "207RH0000X": "Hematology",
  "207RH0002X": "Hospice and Palliative Medicine",
  "207RH0003X": "Hematology & Oncology",
  "207RH0005X": "Hypertension Specialist",
  "207RI0001X": "Clinical & Laboratory Immunology",
  "207RI0008X": "Hepatology",
  "207RI0011X": "Interventional Cardiology",
  "207RI0200X": "Infectious Disease",
  "207RM1200X": "Magnetic Resonance Imaging (MRI)",
  "207RN0300X": "Nephrology",
  "207RP1001X": "Pulmonary Disease",
  "207RR0500X": "Rheumatology",
  "207RS0010X": "Sports Medicine",
  "207RS0012X": "Sleep Medicine",
  "207RT0003X": "Transplant Hepatology",
  "207RX0202X": "Medical Oncology",
  "207SC0300X": "Clinical Cytogenetics",
  "207SG0201X": "Clinical Genetics (M.D.)",
  "207SG0202X": "Clinical Biochemical Genetics",
  "207SG0203X": "Clinical Molecular Genetics",
  "207SG0205X": "Ph.D. Medical Genetics",
  "207SM0001X": "Molecular Genetic Pathology",
  "207UN0901X": "Nuclear Cardiology",
  "207UN0902X": "Nuclear Imaging & Therapy",
  "207UN0903X": "In Vivo & In Vitro Nuclear Medicine",
  "207VB0002X": "Obesity Medicine",
  "207VC0200X": "Critical Care Medicine",
  "207VE0102X": "Reproductive Endocrinology",
  "207VF0040X": "Female Pelvic Medicine and Reconstructive Surgery",
  "207VG0400X": "Gynecology",
  "207VH0002X": "Hospice and Palliative Medicine",
  "207VM0101X": "Maternal & Fetal Medicine",
  "207VX0000X": "Obstetrics",
  "207VX0201X": "Gynecologic Oncology",
  "207WX0009X": "Glaucoma Specialist",
  "207WX0107X": "Retina Specialist",
  "207WX0108X": "Uveitis and Ocular Inflammatory Disease",
  "207WX0109X": "Neuro-ophthalmology",
  "207WX0110X": "Pediatric Ophthalmology and Strabismus Specialist",
  "207WX0120X": "Cornea and External Diseases Specialist",
  "207WX0200X": "Ophthalmic Plastic and Reconstructive Surgery",
  "207XP3100X": "Pediatric Orthopaedic Surgery",
  "207XS0106X": "Hand Surgery",
  "207XS0114X": "Adult Reconstructive Orthopaedic Surgery",
  "207XS0117X": "Orthopaedic Surgery of the Spine",
  "207XX0004X": "Foot and Ankle Surgery",
  "207XX0005X": "Sports Medicine",
  "207XX0801X": "Orthopaedic Trauma",
  "207YP0228X": "Pediatric Otolaryngology",
  "207YS0012X": "Sleep Medicine",
  "207YS0123X": "Facial Plastic Surgery",
  "207YX0007X": "Plastic Surgery within the Head & Neck",
  "207YX0602X": "Otolaryngic Allergy",
  "207YX0901X": "Otology & Neurotology",
  "207YX0905X": "Otolaryngology/Facial Plastic Surgery",
  "207ZB0001X": "Blood Banking & Transfusion Medicine",
  "207ZC0006X": "Clinical Pathology",
  "207ZC0008X": "Clinical Informatics",
  "207ZC0500X": "Cytopathology",
  "207ZD0900X": "Dermatopathology",
  "207ZF0201X": "Forensic Pathology",
  "207ZH0000X": "Hematology",
  "207ZI0100X": "Immunopathology",
  "207ZM0300X": "Medical Microbiology",
  "207ZN0500X": "Neuropathology",
  "207ZP0007X": "Molecular Genetic Pathology",
  "207ZP0101X": "Anatomic Pathology",
  "207ZP0102X": "Anatomic Pathology & Clinical Pathology",
  "207ZP0104X": "Chemical Pathology",
  "207ZP0105X": "Clinical Pathology/Laboratory Medicine",
  "207ZP0213X": "Pediatric Pathology",
  "2080A0000X": "Adolescent Medicine",
  "2080B0002X": "Obesity Medicine",
  "2080C0008X": "Child Abuse Pediatrics",
  "2080H0002X": "Hospice and Palliative Medicine",
  "2080I0007X": "Clinical & Laboratory Immunology",
  "2080N0001X": "Neonatal-Perinatal Medicine",
  "2080P0006X": "Developmental - Behavioral Pediatrics",
  "2080P0008X": "Neurodevelopmental Disabilities",
  "2080P0201X": "Pediatric Allergy/Immunology",
  "2080P0202X": "Pediatric Cardiology",
  "2080P0203X": "Pediatric Critical Care Medicine",
  "2080P0204X": "Pediatric Emergency Medicine",
  "2080P0205X": "Pediatric Endocrinology",
  "2080P0206X": "Pediatric Gastroenterology",
  "2080P0207X": "Pediatric Hematology-Oncology",
  "2080P0208X": "Pediatric Infectious Diseases",
  "2080P0210X": "Pediatric Nephrology",
  "2080P0214X": "Pediatric Pulmonology",
  "2080P0216X": "Pediatric Rheumatology",
  "2080S0010X": "Sports Medicine",
  "2080S0012X": "Sleep Medicine",
  "2080T0002X": "Medical Toxicology",
  "2080T0004X": "Pediatric Transplant Hepatology",
  "2081H0002X": "Hospice and Palliative Medicine",
  "2081N0008X": "Neuromuscular Medicine",
  "2081P0004X": "Spinal Cord Injury Medicine",
  "2081P0010X": "Pediatric Rehabilitation Medicine",
  "2081P0301X": "Brain Injury Medicine",
  "2081P2900X": "Pain Medicine",
  "2081S0010X": "Sports Medicine",
  "2082S0099X": "Plastic Surgery Within the Head and Neck",
  "2082S0105X": "Surgery of the Hand",
  "2083A0100X": "Aerospace Medicine",
  "2083A0300X": "Addiction Medicine",
  "2083B0002X": "Obesity Medicine",
  "2083C0008X": "Clinical Informatics",
  "2083P0011X": "Undersea and Hyperbaric Medicine",
  "2083P0500X": "Preventive Medicine/Occupational Environmental Medicine",
  "2083P0901X": "Public Health & General Preventive Medicine",
  "2083S0010X": "Sports Medicine",
  "2083T0002X": "Medical Toxicology",
  "2083X0100X": "Occupational Medicine",
  "2084A0401X": "Addiction Medicine",
  "2084A2900X": "Neurocritical Care",
  "2084B0002X": "Obesity Medicine",
  "2084B0040X": "Behavioral Neurology & Neuropsychiatry",
  "2084D0003X": "Diagnostic Neuroimaging",
  "2084E0001X": "Epilepsy",
  "2084F0202X": "Forensic Psychiatry",
  "2084H0002X": "Hospice and Palliative Medicine",
  "2084N0008X": "Neuromuscular Medicine",
  "2084N0400X": "Neurology",
  "2084N0402X": "Neurology with Special Qualifications in Child Neurology",
  "2084N0600X": "Clinical Neurophysiology",
  "2084P0005X": "Neurodevelopmental Disabilities",
  "2084P0015X": "Psychosomatic Medicine",
  "2084P0301X": "Brain Injury Medicine",
  "2084P0800X": "Psychiatry",
  "2084P0802X": "Addiction Psychiatry",
  "2084P0804X": "Child & Adolescent Psychiatry",
  "2084P0805X": "Geriatric Psychiatry",
  "2084P2900X": "Pain Medicine",
  "2084S0010X": "Sports Medicine",
  "2084S0012X": "Sleep Medicine",
  "2084V0102X": "Vascular Neurology",
  "2085B0100X": "Body Imaging",
  "2085D0003X": "Diagnostic Neuroimaging",
  "2085H0002X": "Hospice and Palliative Medicine",
  "2085N0700X": "Neuroradiology",
  "2085N0904X": "Nuclear Radiology",
  "2085P0229X": "Pediatric Radiology",
  "2085R0001X": "Radiation Oncology",
  "2085R0202X": "Diagnostic Radiology",
  "2085R0203X": "Therapeutic Radiology",
  "2085R0204X": "Vascular & Interventional Radiology",
  "2085R0205X": "Radiological Physics",
  "2085U0001X": "Diagnostic Ultrasound",
  "2086H0002X": "Hospice and Palliative Medicine",
  "2086S0102X": "Surgical Critical Care",
  "2086S0105X": "Surgery of the Hand",
  "2086S0120X": "Pediatric Surgery",
  "2086S0122X": "Plastic and Reconstructive Surgery",
  "2086S0127X": "Trauma Surgery",
  "2086S0129X": "Vascular Surgery",
  "2086X0206X": "Surgical Oncology",
  "2088F0040X": "Female Pelvic Medicine and Reconstructive Surgery",
  "2088P0231X": "Pediatric Urology",
  "208VP0000X": "Pain Medicine",
  "208VP0014X": "Interventional Pain Medicine",
  "213EP0504X": "Public Medicine",
  "213EP1101X": "Primary Podiatric Medicine",
  "213ER0200X": "Radiology",
  "213ES0000X": "Sports Medicine",
  "213ES0103X": "Foot & Ankle Surgery",
  "213ES0131X": "Foot Surgery",
  "224ZE0001X": "Environmental Modification",
  "224ZF0002X": "Feeding, Eating & Swallowing",
  "224ZL0004X": "Low Vision",
  "224ZR0403X": "Driving and Community Mobility",
  "2251C2600X": "Cardiopulmonary",
  "2251E1200X": "Ergonomics",
  "2251E1300X": "Electrophysiology, Clinical",
  "2251G0304X": "Geriatrics",
  "2251H1200X": "Hand",
  "2251H1300X": "Human Factors",
  "2251N0400X": "Neurology",
  "2251P0200X": "Pediatrics",
  "2251S0007X": "Sports",
  "2251X0800X": "Orthopedic",
  "2255A2300X": "Athletic Trainer",
  "2255R0406X": "Rehabilitation, Blind",
  "225CA2400X": "Assistive Technology Practitioner",
  "225CA2500X": "Assistive Technology Supplier",
  "225CX0006X": "Orientation and Mobility Training Provider",
  "225XE0001X": "Environmental Modification",
  "225XE1200X": "Ergonomics",
  "225XF0002X": "Feeding, Eating & Swallowing",
  "225XG0600X": "Gerontology",
  "225XH1200X": "Hand",
  "225XH1300X": "Human Factors",
  "225XL0004X": "Low Vision",
  "225XM0800X": "Mental Health",
  "225XN1300X": "Neurorehabilitation",
  "225XP0019X": "Physical Rehabilitation",
  "225XP0200X": "Pediatrics",
  "225XR0403X": "Driving and Community Mobility",
  "2278C0205X": "Critical Care",
  "2278E0002X": "Emergency Care",
  "2278E1000X": "Educational",
  "2278G0305X": "Geriatric Care",
  "2278G1100X": "General Care",
  "2278H0200X": "Home Health",
  "2278P1004X": "Pulmonary Diagnostics",
  "2278P1005X": "Pulmonary Rehabilitation",
  "2278P1006X": "Pulmonary Function Technologist",
  "2278P3800X": "Palliative/Hospice",
  "2278P3900X": "Neonatal/Pediatrics",
  "2278P4000X": "Patient Transport",
  "2278S1500X": "SNF/Subacute Care",
  "2279C0205X": "Critical Care",
  "2279E0002X": "Emergency Care",
  "2279E1000X": "Educational",
  "2279G0305X": "Geriatric Care",
  "2279G1100X": "General Care",
  "2279H0200X": "Home Health",
  "2279P1004X": "Pulmonary Diagnostics",
  "2279P1005X": "Pulmonary Rehabilitation",
  "2279P1006X": "Pulmonary Function Technologist",
  "2279P3800X": "Palliative/Hospice",
  "2279P3900X": "Neonatal/Pediatrics",
  "2279P4000X": "Patient Transport",
  "2279S1500X": "SNF/Subacute Care",
  "231HA2400X": "Assistive Technology Practitioner",
  "231HA2500X": "Assistive Technology Supplier",
  "2355A2700X": "Audiology Assistant",
  "2355S0801X": "Speech-Language Assistant",
  "246QB0000X": "Blood Banking",
  "246QC1000X": "Chemistry",
  "246QC2700X": "Cytotechnology",
  "246QH0000X": "Hematology",
  "246QH0401X": "Hemapheresis Practitioner",
  "246QH0600X": "Histology",
  "246QI0000X": "Immunology",
  "246QL0900X": "Laboratory Management",
  "246QL0901X": "Laboratory Management, Diplomate",
  "246QM0706X": "Medical Technologist",
  "246QM0900X": "Microbiology",
  "246RH0600X": "Histology",
  "246RM2200X": "Medical Laboratory",
  "246RP1900X": "Phlebotomy",
  "246XC2901X": "Cardiovascular Invasive Specialist",
  "246XC2903X": "Vascular Specialist",
  "246XS1301X": "Sonography",
  "246YC3301X": "Coding Specialist, Hospital Based",
  "246YC3302X": "Coding Specialist, Physician Office Based",
  "246YR1600X": "Registered Record Administrator",
  "246ZA2600X": "Art, Medical",
  "246ZB0301X": "Biomedical Engineering",
  "246ZB0302X": "Biomedical Photographer",
  "246ZB0500X": "Biochemist",
  "246ZB0600X": "Biostatistician",
  "246ZC0007X": "Surgical Assistant",
  "246ZE0500X": "EEG",
  "246ZE0600X": "Electroneurodiagnostic",
  "246ZG0701X": "Graphics Methods",
  "246ZG1000X": "Geneticist, Medical (PhD)",
  "246ZI1000X": "Illustration, Medical",
  "246ZN0300X": "Nephrology",
  "246ZS0410X": "Surgical Technologist",
  "246ZX2200X": "Orthopedic Assistant",
  "2470A2800X": "Assistant Record Technician",
  "2471B0102X": "Bone Densitometry",
  "2471C1101X": "Cardiovascular-Interventional Technology",
  "2471C1106X": "Cardiac-Interventional Technology",
  "2471C3401X": "Computed Tomography",
  "2471C3402X": "Radiography",
  "2471M1202X": "Magnetic Resonance Imaging",
  "2471M2300X": "Mammography",
  "2471N0900X": "Nuclear Medicine Technology",
  "2471Q0001X": "Quality Management",
  "2471R0002X": "Radiation Therapy",
  "2471S1302X": "Sonography",
  "2471V0105X": "Vascular Sonography",
  "2471V0106X": "Vascular-Interventional Technology",
  "2472B0301X": "Biomedical Engineering",
  "2472D0500X": "Darkroom",
  "2472E0500X": "EEG",
  "2472R0900X": "Renal Dialysis",
  "2472V0600X": "Veterinary",
  "247ZC0005X": "Clinical Laboratory Director, Non-physician",
  "261QA0005X": "Ambulatory Family Planning Facility",
  "261QA0006X": "Ambulatory Fertility Facility",
  "261QA0600X": "Adult Day Care",
  "261QA0900X": "Amputee",
  "261QA1903X": "Ambulatory Surgical",
  "261QA3000X": "Augmentative Communication",
  "261QB0400X": "Birthing",
  "261QC0050X": "Critical Access Hospital",
  "261QC1500X": "Community Health",
  "261QC1800X": "Corporate Health",
  "261QD0000X": "Dental",
  "261QD1600X": "Developmental Disabilities",
  "261QE0002X": "Emergency Care",
  "261QE0700X": "End-Stage Renal Disease (ESRD) Treatment",
  "261QE0800X": "Endoscopy",
  "261QF0050X": "Family Planning, Non-Surgical",
  "261QF0400X": "Federally Qualified Health Center (FQHC)",
  "261QG0250X": "Genetics",
  "261QH0100X": "Health Service",
  "261QH0700X": "Hearing and Speech",
  "261QI0500X": "Infusion Therapy",
  "261QL0400X": "Lithotripsy",
  "261QM0801X": "Mental Health (Including Community Mental Health Center)",
  "261QM0850X": "Adult Mental Health",
  "261QM0855X": "Adolescent and Children Mental Health",
  "261QM1000X": "Migrant Health",
  "261QM1100X": "Military/U.S. Coast Guard Outpatient",
  "261QM1101X": "Military and U.S. Coast Guard Ambulatory Procedure",
  "261QM1102X": "Military Outpatient Operational (Transportable) Component",
  "261QM1103X": "Military Ambulatory Procedure Visits Operational (Transportable)",
  "261QM1200X": "Magnetic Resonance Imaging (MRI)",
  "261QM1300X": "Multi-Specialty",
  "261QM2500X": "Medical Specialty",
  "261QM2800X": "Methadone",
  "261QM3000X": "Medically Fragile Infants and Children Day Care",
  "261QP0904X": "Public Health, Federal",
  "261QP0905X": "Public Health, State or Local",
  "261QP1100X": "Podiatric",
  "261QP2000X": "Physical Therapy",
  "261QP2300X": "Primary Care",
  "261QP2400X": "Prison Health",
  "261QP3300X": "Pain",
  "261QR0200X": "Radiology",
  "261QR0206X": "Radiology, Mammography",
  "261QR0207X": "Radiology, Mobile Mammography",
  "261QR0208X": "Radiology, Mobile",
  "261QR0400X": "Rehabilitation",
  "261QR0401X": "Rehabilitation, Comprehensive Outpatient Rehabilitation Facility (CORF)",
  "261QR0404X": "Rehabilitation, Cardiac Facilities",
  "261QR0405X": "Rehabilitation, Substance Use Disorder",
  "261QR0800X": "Recovery Care",
  "261QR1100X": "Research",
  "261QR1300X": "Rural Health",
  "261QS0112X": "Oral and Maxillofacial Surgery",
  "261QS0132X": "Ophthalmologic Surgery",
  "261QS1000X": "Student Health",
  "261QS1200X": "Sleep Disorder Diagnostic",
  "261QU0200X": "Urgent Care",
  "261QV0200X": "VA",
  "261QX0100X": "Occupational Medicine",
  "261QX0200X": "Oncology",
  "261QX0203X": "Oncology, Radiation",
  "281PC2000X": "Children",
  "282NC0060X": "Critical Access",
  "282NC2000X": "Children",
  "282NR1301X": "Rural",
  "282NW0100X": "Women",
  "283XC2000X": "Children",
  "2865M2000X": "Military General Acute Care Hospital",
  "2865X1600X": "Military General Acute Care Hospital. Operational (Transportable)",
  "3104A0625X": "Assisted Living, Mental Illness",
  "3104A0630X": "Assisted Living, Behavioral Disturbances",
  "311ZA0620X": "Adult Care Home",
  "3140N1450X": "Nursing Care, Pediatric",
  "3245S0500X": "Substance Abuse Treatment, Children",
  "332BC3200X": "Customized Equipment",
  "332BD1200X": "Dialysis Equipment & Supplies",
  "332BN1400X": "Nursing Facility Supplies",
  "332BP3500X": "Parenteral & Enteral Nutrition",
  "332BX2000X": "Oxygen Equipment & Supplies",
  "3336C0002X": "Clinic Pharmacy",
  "3336C0003X": "Community/Retail Pharmacy",
  "3336C0004X": "Compounding Pharmacy",
  "3336H0001X": "Home Infusion Therapy Pharmacy",
  "3336I0012X": "Institutional Pharmacy",
  "3336L0003X": "Long Term Care Pharmacy",
  "3336M0002X": "Mail Order Pharmacy",
  "3336M0003X": "Managed Care Organization Pharmacy",
  "3336N0007X": "Nuclear Pharmacy",
  "3336S0011X": "Specialty Pharmacy",
  "3416A0800X": "Air Transport",
  "3416L0300X": "Land Transport",
  "3416S0300X": "Water Transport",
  "3418M1110X": "Military or U.S. Coast Guard Ambulance, Ground Transport",
  "3418M1120X": "Military or U.S. Coast Guard Ambulance, Air Transport",
  "3418M1130X": "Military or U.S. Coast Guard Ambulance, Water Transport",
  "363AM0700X": "Medical",
  "363AS0400X": "Surgical",
  "363LA2100X": "Acute Care",
  "363LA2200X": "Adult Health",
  "363LC0200X": "Critical Care Medicine",
  "363LC1500X": "Community Health",
  "363LF0000X": "Family",
  "363LG0600X": "Gerontology",
  "363LN0000X": "Neonatal",
  "363LN0005X": "Neonatal, Critical Care",
  "363LP0200X": "Pediatrics",
  "363LP0222X": "Pediatrics, Critical Care",
  "363LP0808X": "Psychiatric/Mental Health",
  "363LP1700X": "Perinatal",
  "363LP2300X": "Primary Care",
  "363LS0200X": "School",
  "363LW0102X": "Women's Health",
  "363LX0001X": "Obstetrics & Gynecology",
  "363LX0106X": "Occupational Health",
  "364SA2100X": "Acute Care",
  "364SA2200X": "Adult Health",
  "364SC0200X": "Critical Care Medicine",
  "364SC1501X": "Community Health/Public Health",
  "364SC2300X": "Chronic Care",
  "364SE0003X": "Emergency",
  "364SE1400X": "Ethics",
  "364SF0001X": "Family Health",
  "364SG0600X": "Gerontology",
  "364SH0200X": "Home Health",
  "364SH1100X": "Holistic",
  "364SI0800X": "Informatics",
  "364SL0600X": "Long-Term Care",
  "364SM0705X": "Medical-Surgical",
  "364SN0000X": "Neonatal",
  "364SN0800X": "Neuroscience",
  "364SP0200X": "Pediatrics",
  "364SP0807X": "Psychiatric/Mental Health, Child & Adolescent",
  "364SP0808X": "Psychiatric/Mental Health",
  "364SP0809X": "Psychiatric/Mental Health, Adult",
  "364SP0810X": "Psychiatric/Mental Health, Child & Family",
  "364SP0811X": "Psychiatric/Mental Health, Chronically Ill",
  "364SP0812X": "Psychiatric/Mental Health, Community",
  "364SP0813X": "Psychiatric/Mental Health, Geropsychiatric",
  "364SP1700X": "Perinatal",
  "364SP2800X": "Perioperative",
  "364SR0400X": "Rehabilitation",
  "364SS0200X": "School",
  "364ST0500X": "Transplantation",
  "364SW0102X": "Women's Health",
  "364SX0106X": "Occupational Health",
  "364SX0200X": "Oncology",
  "364SX0204X": "Oncology, Pediatrics",
  "3747A0650X": "Attendant Care Provider",
  "3747P1801X": "Personal Care Attendant",
  "385HR2050X": "Respite Care Camp",
  "385HR2055X": "Respite Care, Mental Illness, Child",
  "385HR2060X": "Respite Care, Intellectual and/or Developmental Disabilities, Child",
  "385HR2065X": "Respite Care, Physical Disabilities, Child",
}

def taxonomyCodeToSpecialtyAttrSubGroup (code)
  get-key ($codeMap, $code, "")

taxonomyCodeToSpecialtyAttrSubGroup (.code)
catull commented 3 years ago

If the input is

{
  "code" : "193400000X"
}

the result is "".

QED.

larsga commented 3 years ago

Checking the behaviour of the attached transform I find that (on the command-line) it doesn't hang, but causes a stack overflow, as expected:

Exception in thread "main" java.lang.StackOverflowError
        at com.schibsted.spt.data.jslt.parser.JJTJsltParserState.clearNodeScope(JJTJsltParserState.java:72)
        at com.schibsted.spt.data.jslt.parser.JsltParser.BaseExpr(JsltParser.java:592)
        at com.schibsted.spt.data.jslt.parser.JsltParser.MultiplicativeExpr(JsltParser.java:463)
        at com.schibsted.spt.data.jslt.parser.JsltParser.AdditiveExpr(JsltParser.java:391)
        at com.schibsted.spt.data.jslt.parser.JsltParser.ComparativeExpr(JsltParser.java:291)
        ...

The problem is that the AST stores the expression as a tree where the ifs are nested inside the else branches, and the tree gets really deep. Note the strange class names: this is the real AST, not the object structure we build from it. So it's not even able to finish parsing, which makes this much harder to solve.