Announcement

Collapse
No announcement yet.

processing repeated segments

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • processing repeated segments

    I am having a rough time trying to figure out how to properly use cntr in the code below so that the search and replaces will be performed on all the OBR segments within a message. Any help appreciated. Thanks in advance!

    var cntr = 0;

    for each (seg in msg.children()) {


    if (seg.name().toString() == "OBR") {

    cntr++;

    var new_value = seg['OBR.4'][cntr]['OBR.4.1'].toString();
    var sample_value = seg['OBR.4'][cntr]['OBR.4.1'].toString();



    // logger.info('Sample value is ' + sample_value);
    // logger.info('Sample value using indexof ' + sample_value.indexOf('GI Bleeding Scan NM'));

    // new_value = sample_value.replace('Barium Enema w/Hypaque','88932759');
    if(sample_value == 'Barium Enema w/Hypaque'){new_value = '88932759';}

    // new_value = sample_value.replace('Blood Patch DX','19274535');
    if(sample_value == 'Blood Patch DX'){new_value = '19274535'};

    // new_value = sample_value.replace(EEG^Electroencephalogram^^^52 3527036...etc... -- 22837314

    //new_value = sample_value.replace('Coccyx X-Ray (min 2V)','26639');
    if(sample_value == 'Coccyx X-Ray (min 2V)'){new_value = '26639';}

    // new_value = sample_value.replace('ESI Lumbar/ Caudal SP2','33406327');
    if(sample_value == 'ESI Lumbar/ Caudal SP2'){new_value = '33406327';}

    //new_value = sample_value.replace('GI Bleeding Scan NM', '25039');
    if(sample_value == 'GI Bleeding Scan NM'){new_value = '25039';}

    //new_value = sample_value.replace('Consult, Nuclear Medicine','25155');
    if(sample_value == 'Consult, Nuclear Medicine'){new_value = '25155';}

    // new_value = sample_value.replace('Humerus Left (min 2V)','26721');
    if(sample_value == 'Humerus Left (min 2V)'){new_value = '26721';}


    // new_value = sample_value.replace('Humerus Right (min 2V)','3179740');
    if(sample_value == 'Humerus Right (min 2V)'){new_value = '3179740'; }

    // new_value = sample_value.replace('Interpretation  w/ Report','201439');
    if(sample_value == 'Interpretation  w/ Report'){new_value = '201439';}

    // new_value = sample_value.replace('Knee Lt 3 View, SF','86975411');
    if(sample_value == 'Knee Lt 3 View, SF'){new_value = '86975411';}

    // new_value = sample_value.replace('Lung Perfusion \T\ Ventilation Scan NM','25123');
    // if(sample_value == 'Lung Perfusion \T\ Ventilation Scan NM'){new_value = '25123';}

    if(sample_value == 'Lung Perfusion \T\ Ventilation Scan NM'){new_value = '25123';}

    logger.info('1st check New value is ' + new_value);
    logger.info('1st check Sample value is ' + sample_value);

    // new_value = sample_value.replace('Knee Rt 3 View, SF','36975340');
    if(sample_value == 'Knee Rt 3 View, SF'){new_value = '36975340';}

    // new_value = sample_value.replace('Lymphangiogram Injection Only NM','207219503');
    if(sample_value == 'Lymphangiogram Injection Only NM'){new_value = '207219503';}

    // new_value = sample_value.replace("Meckel's Scan NM","25136");
    if(sample_value == "Meckel's Scan NM"){new_value = "25136"};

    // new_value = sample_value.replace('Nose X-Ray (min 3V)','27418');
    if(sample_value == 'Nose X-Ray (min 3V)'){new_value = '27418'};

    // new_value = sample_value.replace('Outside Film Reading','27429');
    if(sample_value == 'Outside Film Reading'){new_value = '27429';}

    // new_value = sample_value.replace('Parathyroid NM','25169');
    if(sample_value == 'Parathyroid NM'){new_value = '25169'}

    // new_value = sample_value.replace('PICC Insertion, IC','171768715');
    if(sample_value == 'PICC Insertion, IC'){new_value = '171768715';}

    // new_value = sample_value.replace('Transhepatic Biliary Drainage SP','27954');
    if(sample_value == 'Transhepatic Biliary Drainage SP'){new_value = '27954';}

    // new_value = sample_value.replace('Ultrasound Abdomen Doppler IC','145806196');
    if(sample_value == 'Ultrasound Abdomen Doppler IC'){new_value = '145806196';}

    // new_value = sample_value.replace('Ultrasound Carotid Imaging IC','69764058');
    if(sample_value == 'Ultrasound Carotid Imaging IC'){new_value = '69764058';}

    // new_value = sample_value.replace('Ultrasound Post Void Residual - IC','74726263');
    if(sample_value == 'Ultrasound Post Void Residual - IC'){new_value = '74726263';}

    // new_value = sample_value.replace('USV Arterial, LE Bilat','176833028');
    if(sample_value == 'USV Arterial, LE Bilat'){new_value = '176833028';}

    // new_value = sample_value.replace('USV Arterial, LE LT','176833035');
    if(sample_value == 'USV Arterial, LE LT'){new_value = '176833035';}

    // new_value = sample_value.replace('USV Arterial, LE RT','176833048');
    if(sample_value == 'USV Arterial, LE RT'){new_value = '176833048';}

    // new_value = sample_value.replace('USV Arterial, UE LT','176832975');
    if(sample_value == 'USV Arterial, UE LT'){new_value = '176832975';}

    // new_value = sample_value.replace('USV Carotid/Vertebral Bilat','176832882');
    if(sample_value == 'USV Carotid/Vertebral Bilat'){new_value = 'USV Carotid/Vertebral Bilat';}

    // new_value = sample_value.replace('USV Venous, LE Bilat Duplex','176833148');
    if(sample_value == 'USV Venous, LE Bilat Duplex'){new_value = '176833148';}

    // new_value = sample_value.replace('USV Venous, LE Unilat LT','176833243');
    if(sample_value == 'USV Venous, LE Unilat LT'){new_value = '176833243';}

    // new_value = sample_value.replace('USV Venous, LE Unilat RT','176833300');
    if(sample_value == 'USV Venous, LE Unilat RT'){new_value = '176833300'}

    // new_value = new_value.replace('ECH','EKG');
    if(sample_value == 'ECH'){new_value = 'EKG';}

    new_value = new_value.replace('CD:','');


    logger.info('Last check New value is ' + new_value);
    logger.info('Last check Sample value is ' + sample_value);

    seg['OBR.4'][cntr]['OBR.4.1'] = new_value;
    seg['OBR.4'][cntr]['OBR.4.3'] = 'OLOL_EAP_RAD';
    }
    }

  • #2
    It'd be much easier to use a replacement object:

    Code:
    var table = {
    	'Barium Enema w/Hypaque':	'88932759',
    	'Blood Patch DX':		'19274535',
    	'Coccyx X-Ray (min 2V)':	'26639',
    	'ESI Lumbar/ Caudal SP2':	'33406327',
    	'GI Bleeding Scan NM':		'25039',
    	'Consult, Nuclear Medicine':	'25155',
    	// etc.
    	find:function(str) {return (this[str.toString()] || str.toString()).replace(/CD:/g,'');}
    };
    
    for each (obr in msg.OBR)
    	obr['OBR.4']['OBR.4.1'] = table.find(obr['OBR.4']['OBR.4.1']);
    Also, you're not property escaping those hardcoded escape sequences (\T\), so make sure to do that as well.
    Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

    Nicholas Rupley
    Work: 949-237-6069
    Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


    - How do I foo?
    - You just bar.

    Comment

    Working...
    X