I'm trying to loop through all the DG1 segments that are send and populate a database field with the Diagnosis Type value. I have searched the forum to get some examples of looping through repeating segments. But I am having trouble getting each DG1 6.1 value into the DB successfully.
Here is what I am getting:
DG1Value value in DB: "<DG1.6.1>DA</DG1.6.1><DG1.6.1>DF</DG1.6.1>"
diagnosisValue value in DB: ""
Here is what I am getting:
DG1Value value in DB: "<DG1.6.1>DA</DG1.6.1><DG1.6.1>DF</DG1.6.1>"
diagnosisValue value in DB: ""
Code:
var sql = ""; for each (diagnosis in msg..DG1) { var DG1Value = msg['DG1']['DG1.6']['DG1.6.1'].toString(); var diagnosisValue = diagnosis['DG1']['DG1.6']['DG1.6.1'].toString(); sql = "insert into testdata values ('" + DG1Value + "')"; var result = dbConn.executeUpdate(sql); } dbConn.close();
Comment