Sidebar

Can I use mapping module to create a JSON with where the value is a number (not a string)?

0 votes
32 views
asked Jul 15 by thanatad-r-3439 (120 points)

Mapping block is what we use to create a JSON by mapping each HL7 nodes to each JSON node

We are using 3 functions to create a JSON message:

  • qie.createJSONMessage
  • message.setNode
  • source.getNode

Values by default is a string.

 

Sample code below:

qie.createJSONMessage("{\n" +
   "   \"Patient\": {},\n"
   "}", 'UTF-8');

message.setNode("/Patient/LastName", source.getNode("PID-5.1"));
message.setNode("/Patient/FirstName", source.getNode("PID-5.2"));

message.setNode("/Patient/Status", source.getNode("EVN-1"));

 

Output (as-is: strings)

"Patient": {
      "FirstName": "King",
      "LastName": "James",
      "Status": "1"
   }

Output (to-be: number - see status key value pair)

"Patient": {
      "FirstName": "King",
      "LastName": "James",
      "Status":  1 
   },

1 Answer

+1 vote

You can set a JSON number in QIE using 

qie.createJSONMessage("{\n" +
   "   \"Patient\": {},\n"
   "}", 'UTF-8');

message.setNode("/Patient/LastName", source.getNode("PID-5.1"));
message.setNode("/Patient/FirstName", source.getNode("PID-5.2"));

message.setJSONNumber("/Patient/Status", source.getNode("EVN-1"));

answered Jul 15 by michael-h-5027 (13,690 points)
commented Jul 16 by thanatad-r-3439 (120 points)


Where can I find docs on the library of functions on Qvera?
I went through the basic QIE JavaScript tutorial and I wasn't able to find setJSONNumber.  I think there are many other functions I can leverage.
commented Jul 18 by michael-h-5027 (13,690 points)
For a list of functions and description you can review the code wizard from any custom mapping function. https://www.qvera.com/kb/index.php/656
...