Sidebar

Required getPart function to use for array with examples

0 votes
371 views
asked Jun 11, 2021 by manoj-m-7223 (210 points)
Hi Team,

Need your help for getPart function to use for Array elements and provide with examples of getPart function.

Thanks & Regards,

Manoj
commented Jun 11, 2021 by brandon-w-8204 (33,270 points)
I am not sure what you mean by getPart. Can you please clarify what you are looking to accomplish. We are happy to assist just let us know more details.
commented Jun 12, 2021 by manoj-m-7223 (210 points)
hi Brandon,
Thanks for quick reply.  And im looking for getPart function to use how to get Firstname, middlename and lastname seperately for the Patient name ( Williams, Scott) while translation in QIE. Please correct me once.
Thank you.

2 Answers

0 votes

Here is some sample code:

//Remove ()
var originalName = StringUtils.replace(message.getNode('/'), '(', '');
originalName = StringUtils.replace(originalName, ')', '');

//Split it up
var parts = StringUtils.splitByWholeSeparator(originalName, ',');

//Get Last Name
var lastName = StringUtils.trim(parts[0]);
var firstMiddleName = StringUtils.trim(parts[1]);

//Split first and last name parts
var firstMiddleParts = StringUtils.splitByWholeSeparator(firstMiddleName, ' ');

//Get the first and last names
var firstName = firstMiddleParts[0];
var middleName = firstMiddleParts[1];

qie.debug('firstName: ' + firstName);
qie.debug('middleName: ' + middleName);
qie.debug('lastName: ' + lastName);

answered Jun 14, 2021 by brandon-w-8204 (33,270 points)
0 votes
Hey, Manoj.  That getPart function only exists in our instance of QIE (it is a function we built into our logic for pre-processing data before calling various message.setNode functions), so the broader QIE audience won't know how that function works.

Having said that, the syntax you're looking for would be this, assuming you're parsing a CSV with a column name of "Patient Name"

To get the last name: getPart("Patient Name", ",", 0)

To get the first name: getPart("Patient Name", ",", 1)
answered Jun 24, 2021 by scott-b-8720 (560 points)
...