#!/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

      use 5
      write "drop table if exists officeVisit;",!
      write "create table officeVisit ( ptid char(10), physician_code int, date date, time time, trnsaction int);",!
      for %=1:1:10 do
      . set ptid=100000
      . for i=1:1:^ptcount(0) do
      .. set tran=^Tran(0) set ^Tran(0)=^Tran(0)+1
      .. set ptid=ptid+1000
      .. write "insert into officeVisit values ( '",ptid,"', "

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

      .. write k,", "
      .. write " '",^dates($r(date)+1),"', "
      .. write " '",^time($r(time)+1),"', ",tran,"); ",!
