Monday, September 30, 2013

How to Add a Clinical Question in Orchard AP



  1. Create a 'Test' item
    1. File >> Table Setup >> Tests >> New
    2. Enter Test name, Abbreviation
    3. Keep Enterability as Enterable as numeric and text/choice list  (Keep this setting even if you want the question to have an enumerated set of answers, the answer choices will be set later.)
    4. Set Location (I set it to Veracyte, but it probably doesn't matter)
    5. Save


  2. Create a 'Clinical Information' item 
    1. File >> Table Setup >> Clinical Information
    2. Enter the Question. Note, questions are asked in Alphanumeric order.  You can prefix a number to control question order.
    3. Select the 'Tied Test' that you created in step 1.
    4. Set the 'Answer Type'.  Use 'Pre-Defined Text' for a question with Enumerated Answers.
    5. Set the Valid Answers (if applicable)
    6. Save









       
  3.  Attach the 'Clinical Information' to the 'Specimen'
    1. File >> Table Setup >> Specimens
    2. Click the Specimen you want to attach the Clinical Information To
    3. Click 'Clinical Info'
    4. Find the Clinical Information you created in step 2.
    5. Ctrl-click it to add it to the set of Questions
    6. OK
    7. Save




  4. Test your new Question
    1. Laboratory >> Order Patient Specimens
    2. Enter Patient
    3. Add Specimen
    4. Click Clinical Info
    5. See your Clinical Question



Monday, July 22, 2013

OSX Dock magnification/menus/hot corners not working!

Moved the Wireless mouse/keyboard dongle to the other input on the KVM switch.  Problem solved!

Wednesday, May 1, 2013

Zebra Printer Problems



I arrived at this script.  It works on a Gx420t with Factory defaults.  It’s not exactly what I was aiming for, but it’s pretty close. 

^XA
^LT10    //Label Top.  Sets the top edge of the label (determined experimentally)
^PW200   //Print Width.  Sets the left edge of the label (determined experimentally)
^LH10,15 //Label Home.  Offsets from left and top edges from which fields positions are relative to.
^PR2     //Print Rate.  2 is the slowest setting
^MD30    //Media Darkness.  Set to maximum darkness
^BY1     //Set the barcode bar-width to 1 dot … If not set, the previous setting will be used.  The factory default is too big for this label.
^FO0,0^BCN,26,N,N,N,N^FD%s^FS
^FO0,30^A0,20,17^FD%s^FS
^FO0,50^A0,20,17^FD%s^FS
^XZ

Some key insights:

a)      the gx420t has lower resolution(203dpi) than the gx430t (300dpi), so all positions and sizes needed to be determined again.  Multiplying everything by 2/3 was insufficient…I had to do it experimentally.  

b)      Some settings persist between print jobs (examples: ^PW, ^BY).  The printer maintains state between jobs.  Not all of the printers state is visible through the web interface.  It’s important to develop and test your scripts against a printer with factory default settings.  To restore factory defaults you must apply ‘restore default settings’ AND then power-cycle the printer.

Thursday, April 25, 2013

I was looking for quick way to 'encrypt' an integer into another integer.  I tried a few things:

I tried using Java Ciphers with 32-bit block size ( ex. "DES/OFB32/NoPadding")

I couldn't make Ciphers work.  The encrypted integers that were returned were not sufficiently distributed in the integer domain....probably because I was doing something wrong... I didn't have time to figure it out.  See java code snippet at the bottom of the message.

I found this code snipped implementing a Fiestel Network

http://wiki.postgresql.org/wiki/Pseudo_encrypt

I made the changes recommended by J. Jancar to implement this:

-- Function: pseudo_encrypt(integer)

-- DROP FUNCTION pseudo_encrypt(integer);

CREATE OR REPLACE FUNCTION pseudo_encrypt(value integer)
  RETURNS integer AS
$BODY$
DECLARE
l1 int;
l2 int;
r1 int;
r2 int;
i int:=0;
BEGIN
 l1:= (VALUE >> 16) & 65535;
 r1:= VALUE & 65535;
 WHILE i < 3 LOOP
   l2 := r1;
   r2 := l1 # ((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
   l1 := l2;
   r1 := r2;
   i := i + 1;
 END LOOP;
 RETURN ((r1 << 16) + l1);
END;
$BODY$
  LANGUAGE plpgsql IMMUTABLE STRICT
  COST 100;
ALTER FUNCTION pseudo_encrypt(integer)
  OWNER TO thyroid;





Tested x = f(f(x)) on 4 million positive integers, works.

Translated to Java:

    public static int pseudoEncrypt(int data) {
        int l1 = (data >> 16) & 65535;
        int r1 = data & 65535;
        for (int i = 0; i<3 br="" i="">            int l2 = r1;
            //Don't change these constants until and unless we understand this better
            int r2 = l1 ^ (int)((((1366.0 * r1 + 150889) % 714025) / 714025.0) * 32767);
            l1 = l2;
            r1 = r2;
        }
        return (r1 << 16) + l1;
    }


Tested x = f(f(x))Java integers.  Works.




    @Test
    public void test3() throws Exception {
        for (int i=0; i<1000 br="" i="">       
            final String keyString = "YKQ22ROLDQYU6===";
            final String ivParametersString = "TOSHCB6GRJBLC===";
           
            byte[] data = ByteBuffer.allocate(4).putInt(i).array();
   
            SecretKey secretKey = new SecretKeySpec(base32.decode(keyString), "DES");
            final IvParameterSpec iv = new IvParameterSpec(base32.decode(ivParametersString));
            Cipher cipher = Cipher.getInstance("DES/OFB32/NoPadding");
       
            cipher.init(Cipher.ENCRYPT_MODE, secretKey, iv);
            //IvParameterSpec iv = new IvParameterSpec(base32.decode(ivDataString));
            byte[] encryptedData = cipher.doFinal(data);
            int intEncrypted = ByteBuffer.wrap(encryptedData).getInt();
           
            cipher.init(Cipher.DECRYPT_MODE, secretKey, iv);
            byte[] decryptedData = cipher.doFinal(encryptedData);
   
            Assert.assertArrayEquals(data, decryptedData);
            int intDecrypted = ByteBuffer.wrap(decryptedData).getInt();
            System.out.printf("%s %s %s%n", i, intEncrypted, intDecrypted);
        }
    }


13 762798568 13
14 762798571 14
15 762798570 15
16 762798581 16
17 762798580 17
18 762798583 18
19 762798582 19
20 762798577 20
21 762798576 21
22 762798579 22
23 762798578 23
  <--i be="" br="" distributed="" encrypted="" expecting="" in="" integer="" space.="" the="" to="" values="" was="" widely="">


Monday, April 8, 2013

Remote Debugging Tomcat running as a Windows Service


To enable Remote Debugging in Tomcat7 running as a service



1. Run %TOMCAT_HOME/bin/Tomcat7w.exe
( ex. C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin)

2. Java Tab

3. Add these to 'Java Options' before the -D options


-Xdebug
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n


4. Apply

5. Start Tomcat service