1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
783 views
by mike-r-7535 (13.8k points)
I need to provide a unique 16 character identifying string that can still be used to look up an order in my emr.  How can I use the PatientId/ordernum from Centricity to create a unique 16 character identifier?

1 Answer

0 votes
 
Best answer

In Centricity, the orders.ordernum field is only unique for the given patient. However, if you use the orders.orderid field, that is the primary key for the entire orders table.

The trick is changing a 19 digit (base 10) number to a base 16 or base 36 number.

Here is a code snippet of how you can do that.

var orderid = java.lang.Long.MAX_VALUE;
 
// Hex (base 16) can have 16 different values in each digit 0-9, a-f
var hexString = java.lang.Long.toString(orderid, 16);
var unHex = java.lang.Long.parseLong(hexString, 16);
 
// Base36 can have 36 different values in each digit 0-9, a-z
var base36String = java.lang.Long.toString(orderid, 36);
var unBase36 = java.lang.Long.parseLong(base36String, 36);
 
// unBase36, unHex, and orderid are all equal
qie.info("orderid = " + orderid + "... length=" + java.lang.String(orderid).length());
qie.info("hexString = " + hexString + "... length=" + hexString.length());
qie.info("base36String = " + base36String + "... length=" + base36String.length());
if (orderid === unBase36 && orderid === unHex) {
   qie.info("Yeah, the reverse is equal!");
}

Here is the net result from the logs:

Yeah, the reverse is equal!
base36String = 1y2p0ij32e8e7... length=13
hexString = 7fffffffffffffff... length=16
orderid = 9223372036854776000... length=19

 

by mike-r-7535 (13.8k points)
...