#!/usr/bin/mumps

      s i=$zsqlite("pragma","journal_mode=off")
      s i=$zsqlite("pragma","synchronous=off")

      w "pragma journal_mode=off;",!
      w "pragma synchronous=off;",!

      set date=^date
      set time=^time

      set i=$zsrand(7777)

      set labs=^labs

      use 5

      write "drop table if exists labs;",!
      write "create table labs (ptid char(10), test_date date, test_time time, test_name int, result int, icd_code int, trnsaction int); ",!

      for %=1:1:10 do
      . set ptid=100000
      . for i=1:1:^ptcount(0) do
      .. set ptid=ptid+1000
      .. set tran=^Tran(0) set ^Tran(0)=^Tran(0)+1
      .. write "insert into labs values ( "
      .. write "'",ptid,"', "
      .. set d=^dates($r(date)+1)
      .. set t=^time($r(time)+1)
      .. write "'",d,"', "
      .. write "'",t,"', "
      .. write $r(labs)+1,", "

      .. set kk=0
      .. for k=$o(^picd(ptid,k)) s kk=kk+1
      .. for k=$o(^picd(ptid,k)) if $r(kk)=0 break
      .. if k="" s k=$o(^picd(ptid,""))

      .. write $r(100),", ",k,", ",tran," );",!
