#1
|
|||
|
|||
![]()
I need to take these results queried from a database and create 1 OBR segment for each time listed in the OBR_7 column and follow it by multiple OBX's.
OBR_7 OBX_1 OBX_2 OBX_3 OBX_5 20180625130000 9 NM NBP_S 176 20180625130000 10 NM NBP_D 88 20180625130000 11 NM NBP_M 117 20180625130100 9 NM NBP_S 178 20180625130100 10 NM NBP_D 84 20180625130100 11 NM NBP_M 115 Something similar to this, OBR|||||||20180914130000 OBX|0|ST|HR||70||||||R OBX|1|ST|PVC||1||||||R OBX|2|ST|ST-I||0.30||||||R OBX|3|ST|ST-II||-0.10||||||R OBX|4|ST|ST-III||-0.40||||||R OBX|5|ST|ST-V1||0.50||||||R OBX|6|ST|ST-AVR||-0.10||||||R OBX|7|ST|ST-AVL||0.30||||||R OBX|8|ST|ST-AVF||-0.20||||||R OBR|||||||20180914130100 OBX|0|ST|HR||71||||||R OBX|1|ST|PVC||0||||||R OBX|2|ST|ST-I||0.30||||||R OBX|3|ST|ST-II||-0.10||||||R OBX|4|ST|ST-III||-0.50||||||R OBX|5|ST|ST-V1||0.30||||||R OBX|6|ST|ST-AVR||-0.10||||||R OBX|7|ST|ST-AVL||0.40||||||R OBX|8|ST|ST-AVF||-0.30||||||R Thanks! |
#2
|
|||
|
|||
![]()
Is there anything you have already done, and is not working? Show us your code please.
__________________
HL7v2.7 Certified Control Specialist! |
#3
|
|||
|
|||
![]()
The only thing that I have completed so far is to get the data from the database, just not sure how to interpret it into the OBR's with OBX's.
The following is just pulling the OBR field from the database as a starting point. var acct = msg['QRD']['QRD.8']['QRD.8.1'].toString(); var from = msg['QRF']['QRF.2']['QRF.2.1']; var thru = msg['QRF']['QRF.3']['QRF.3.1']; var qt = '\''; var dbConn = DatabaseConnectionFactory.createDatabaseConnection var sql = "SELECT DISTINCT OBR_7 from <tablename> where PID_3 =" + qt + acct + qt + "and OBR_7 >=" + qt + from + qt + "and OBR_7 <=" + qt + thru + qt; var results = dbConn.executeCachedQuery(sql); var obr = ""; while(results.next()) { obr = results.getString(1); } dbConn.close(); |
#4
|
|||
|
|||
![]()
I now have data pulling in, but my last line in my delimited file is "undefined", not sure where that is coming from? I did check the resultSize variable to the database query and it is correct.
Here is what I have; var result = dbConn.executeCachedQuery(resultquery); var resultSize = result.size(); //logger.info(resultSize); for (var i = 0;i < resultSize;i++) { (result.next()) var data = result.getString(4); var output = data + "\r" + output; channelMap.put('Data',output) } When it writes the file, the last line is always "undefined", ....... OBX|9|ST|InspCO2||0||||||R undefined |
#5
|
|||
|
|||
![]()
You're appending what is already stored in output to the end of data and storing the result in output, but since you never initialized output, the first time you call it, the previous value is undefined.
|
#6
|
|||
|
|||
![]()
Well, that was a simple fix.
Thanks |
![]() |
Thread Tools | |
Display Modes | |
|
|