Reading values from repeating fields

lundi 23 février 2015

Dear all



Below is part of a PID segment with three repeating fields, each containing a patient identifier.



PID|||MR000223^^^MR~10000013^^^CRIS~111 111 1111^^^NHS| etc etc



Below is a snatch of the code I am hoping will pull out each identifier. There is an obvious problem in that there might not be three fields. Not all patients have all identifiers!



Is this the general way of doing this? Is there a better way?



Regards, Kevin





var localId = "";

var nhsNo = "";

var remoteId = "";



for (i = 0; i < 3; i++)

{

var type = msg['PID']['PID.3'][i]['PID.3.4'].toString();



If (type == "CRIS") {

localId = msg['PID']['PID.3'][i]['PID.3.1'].toString(); }

If (type == "NHS") {

nhsNo = msg['PID']['PID.3'][i]['PID.3.1'].toString(); }

If (type == "MR") {

remoteId = msg['PID']['PID.3'][i]['PID.3.1'].toString(); }

}





Reading values from repeating fields

0 commentaires:

Enregistrer un commentaire