Accessing array variables on destination side using mirth #4964
Replies: 6 comments 16 replies
-
This is a very basic, basic example, but hopefully it will lead you in the right direction. In your Source transformer, you need to do something like this so that its available in the Destination. Use the last line of code in your Destination to pull in the variable(s) from the Source:
|
Beta Was this translation helpful? Give feedback.
-
testfile.txt |
Beta Was this translation helpful? Give feedback.
-
#This code works if I have just one claim in a message and file is not getting picked up and remains in received status for long time when there are multiple claims.
var SubscriberLastName = new Array();
var counter = 0;
for(var i = 0; i < msg['SBR'].length(); i++) {
if(msg['SBR'][i]['SBR.01']['SBR.01.1'].toString() == 'P') {
for each(SBR in getSegmentsAfter(msg, msg['SBR'][0], 'NM1', false,msg['SBR'][1])) {
if(msg['NM1'][i]['NM1.01']['NM1.01.1'].toString() == 'IL') {
SubscriberLastName[counter] = (msg['NM1'][i]['NM1.03']['NM1.03.1'].toString());
counter += 1;
channelMap.put("SubscriberLastName",SubscriberLastName);
var found = true;
}
}
}
if(found == true) break;
} I commented out the code var found and dropped same message with multiple claims. same last name keeps on storing 6 times. I know the reason why but so far these are the things I tried. var SubscriberLastName = new Array();
var counter = 0;
for(var i = 0; i < msg['SBR'].length(); i++) {
if(msg['SBR'][i]['SBR.01']['SBR.01.1'].toString() == 'P') {
for each(SBR in getSegmentsAfter(msg, msg['SBR'][0], 'NM1', false,msg['SBR'][1])) {
if(msg['NM1'][i]['NM1.01']['NM1.01.1'].toString() == 'IL') {
SubscriberLastName[counter] = (msg['NM1'][i]['NM1.03']['NM1.03.1'].toString());
counter += 1;
channelMap.put("SubscriberLastName",SubscriberLastName);
// var found = true;
}
}
}
// if(found == true) break; |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hello
I am trying to access array variables
Source transformer script to create an array of all the billing provider Id's in an 837P claim that has multiple CLM segments
var BillingProviderId = new Array(); var counter = 0; for (var i = 0; i < getArrayOrXmlLength(msg['NM1']); i++) { msgNM1 = (msg['NM1'][i]['NM1.01']['NM1.01.1'].toString()); if (msgNM1 == '85') { BillingProviderId[counter] = (msg['NM1'][i]['NM1.09']['NM1.09.1'].toString()); counter += 1; channelMap.put("BillingProviderId",BillingProviderId); } }
On destination side I am trying to access this array variable BillingProviderId and write to DB. once record per array element. I was able to write to DB entire array.
My destination side code is
`var dbConn;
var result;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection('net.sourceforge.jtds.jdbc.Driver','jdbc:sqlserver://172.00.00.65:1433;instanceName=DEVSQL;databaseName=GeneralHospital;integratedSecurity=true);
var params = new java.util.ArrayList();
var BillingProviderId = new Packages.java.util.ArrayList();
var BillingProviderId = channelMap.get("BillingProviderId");
var expression = "INSERT INTO stage.StagedClaim (BillingProviderId,BillingProviderOrganizationName, ClaimNumber, MedicalRecordNumber, SubscriberId, SubscriberLastName, SubscriberFirstName, SubscriberDateOfBirth, SubscriberGender, PatientIsSubscriber, Payer, PatientId,PatientLastName,PatientFirstName,PatientDateOfBirth,PatientGender,TotalCharges,ClaimStatusId,ClaimType,AdmitDate,DischargeDate) VALUES (?,?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?,?,?,?)";
var result = dbConn.executeUpdate(expression, params);
} finally {
if (dbConn) {
dbConn.close();
}
}`
above code write to DB whole array in one row in DB at this time other variables are not arrays.
I did try to iterate over the array BillingProviderId and write insert query inside for loop and outside for loop as well but I was not successful. Any suggestions will be helpful
Beta Was this translation helpful? Give feedback.
All reactions