programming

SQL: Clarity and encounters

August 30, 2011
By

$sql= “SELECT SPECIALTY, EXTERNAL_NAME, CONTACT_DATE FROM PATIENT INNER JOIN (PAT_ENC INNER JOIN CLARITY_DEP ON PAT_ENC.DEPARTMENT_ID = CLARITY_DEP.DEPARTMENT_ID) ON PATIENT.PAT_ID = PAT_ENC.PAT_ID WHERE PATIENT.PAT_MRN_ID=’”.$mrn_long.”‘ ORDER BY NOTED_DATE DESC”;

Read more »

SQL: DB2 and blood cultures

August 30, 2011
By

C BL 6000501 C BL2 6000497 C BL3 6000495 C BL4 6000493 select * from LURS.VLU_LAB_RESULT where order_fac_id=’HAY’ and MRN = ‘xxxxxxxx’ and (PERFORMED_TEST_CD = ’1000878′ or PERFORMED_TEST_CD = ’1000778′) AND COLLECTION_DATE BETWEEN ’2009-12-01′ and ’2010-10-31′ ; (PERFORMED_TEST_CD = ’6000501′ or PERFORMED_TEST_CD = ’6000497′ or PERFORMED_TEST_CD = ’6000495′ or PERFORMED_TEST_CD = ’6000493′) So… select...

Read more »

SQL: DB2 and Na (sodium) between 90-133

August 30, 2011
By

SELECT substr(MRN,5) as ID, ORDER_FAC_ID as FACILITY, VERIFY_TECH_ID as TECH, PERFORMED_TEST_CD as TEST, TEST_RESULT as VAL, COLLECTION_DATE as COLLECTED FROM LURS.VLU_LAB_RESULT where COLLECTION_DATE BETWEEN ’2010-12-31′ AND ’2011-1-1′ AND PERFORMED_TEST_CD = ’1001700′ AND TEST_RESULT BETWEEN ‘ 90′ AND ‘ 133′ AND TEST_RESULT NOT LIKE ‘%TND%’ substr(MRN,5) truncates the mrn to only 8 digits

Read more »

SQL: DB2 and microbiology

August 30, 2011
By

Looking for blood cultures in the DB2 system in KPHC? Here is the SQL command: Here is the SQL statement I used: select distinct ORGANISM_CHRT_NAME, COLLECTION_DATE, ACCESSION_NUMB,PERFORMED_TEST_CD from LURS.VLU_MICRO_RESULT where order_fac_id=’HAY’ and MRN = ‘xxxxxxx’ and (PERFORMED_TEST_CD = ’6000501′ or PERFORMED_TEST_CD = ’6000497′ or PERFORMED_TEST_CD = ’6000495′ or PERFORMED_TEST_CD = ’6000493′) You may not...

Read more »

SQL: DB2 limiting the count of rows which you want to see

August 30, 2011
By

I always forget how to limit the number of rows which return using DB2 and sql. Well, here it is: using db2, you can limit the number or count of rows by using this at the END of an sql statement: FETCH FIRST 3 ROW ONLY This won’t work for MySQL or Clarity SQL...

Read more »

php foreach

August 28, 2011
By

I have always found “foreach” a bit complicated: <?php $arr = array(“one”, ”two”, ”three”); reset($arr); while (list($key, $value) = each($arr)) { echo ”Key: $key; Value: $value<br />\n”; } foreach ($arr as $key => $value) { echo ”Key: $key; Value: $value<br />\n”; } ?> the above was taken from php manual: http://php.net/manual/en/control-structures.foreach.php

Read more »