Index: EWD/ewdapps/bb/pages/bb.ewd
===================================================================
--- EWD/ewdapps/bb/pages/bb.ewd	(revision 1284)
+++ EWD/ewdapps/bb/pages/bb.ewd	(revision 1284)
@@ -0,0 +1,143 @@
+<ewd:comment>
+ Ajax page contains the beds that gets auto-updated every 5 seconds.
+ V 0.4
+ (c) Sam Habiel
+ Licensed under AGPL
+</ewd:comment>
+<ewd:config pageType="ajax" applyTemplate="false" prePageScript="getbeds^jjihbb">
+<div>
+    <table width="100%" style="border: 1px solid #CFCFC3; border-style: outset">
+        <ewd:comment>
+        First Row: Ward Names
+        ; Ward Data has the following structure:
+        ; occ beds/total^occmale/maletotal^occfemale/femaletotal^oos^emptymale/emptyfemale/emptytotal
+        </ewd:comment>
+        <tr>
+            <ewd:forEach sessionName="wardbed" index="$ward" return="$warddata">
+            <ewd:getPiece data="$warddata" asciiDelimiter="94" pieceNumber="1" return="$nBed">
+            <ewd:getPiece data="$warddata" asciiDelimiter="94" pieceNumber="2" return="$nMale">
+            <ewd:getPiece data="$warddata" asciiDelimiter="94" pieceNumber="3" return="$nFemale">
+            <ewd:getPiece data="$warddata" asciiDelimiter="94" pieceNumber="4" return="$nOOS">
+            <ewd:getPiece data="$warddata" asciiDelimiter="94" pieceNumber="5" return="$nAvail">
+            <th style="color: white; font-weight: bold; background-color: #357AE8; border: 1px solid #2F5BB7; text-align: center">
+                <?= $ward ?> <br />
+                <ewd:getPiece data="$nBed" asciiDelimiter="47" pieceNumber="1" return="$nWardCensus">
+                (Census: <?= $nWardCensus ?>) <br />
+                (M: <?= $nMale ?> F: <?= $nFemale ?> OOS: <?= $nOOS ?>) <br />
+                <ewd:getPiece data="$nAvail" asciiDelimiter="47" pieceNumber="1" return="$nEmptyMaleBeds">
+                <ewd:getPiece data="$nAvail" asciiDelimiter="47" pieceNumber="2" return="$nEmptyFemaleBeds">
+                <ewd:getPiece data="$nAvail" asciiDelimiter="47" pieceNumber="3" return="$nEmptyBeds">
+                (Availability: M: <?= $nEmptyMaleBeds ?> F: <?= $nEmptyFemaleBeds ?> T: <?= $nEmptyBeds ?> )
+            </th>
+            </ewd:forEach>
+        </tr>
+
+        <ewd:comment>Second Row: Contents.
+        We use valign and style vertical align on the td b/c only valign works even though it's deprecated!
+        </ewd:comment>
+        <tr>
+            <ewd:forEach sessionName="wardbed" index="$ward">
+            <td valign="top" style="verical-align: top;">
+                <table style="padding:0; border:0"> 
+                    <ewd:forEach sessionName="wardbed" param1="$ward" index="$bed" return="$beddata">
+                    <ewd:comment>
+                    Bed Data is as follows:
+                    pt name^pt sex^adm date^lodger^EDW^MOT^bed oos?^bed oos msg^bed oss comment
+                    </ewd:comment>
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="1" return="$ptname">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="2" return="$sex">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="3" return="$admDate">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="4" return="$lodger">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="5" return="$edw">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="6" return="$mot">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="7" return="$oos">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="8" return="$oosmsg">
+                    <ewd:getPiece data="$beddata" asciiDelimiter="94" pieceNumber="9" return="$ooscomment">
+                    <ewd:getPiece data="$bed" asciidelimiter="45" pieceNumber="3" return="$bedsex">
+                    <tr>
+                        <ewd:comment>Bed: Color beds for males and females</ewd:comment>
+                        <ewd:if firstValue="$bedsex" operation="=" secondValue="M">
+                        <td class="mbed"><?= $bed ?></td>
+                        <ewd:elseif firstValue="$bedsex" operation="=" secondValue="F">
+                        <td class="fbed"><?= $bed ?></td>
+                        <ewd:else>
+                        <td class="nbed"><?= $bed ?></td>
+                        </ewd:if>
+
+                        <ewd:comment>Now, Patients...</ewd:comment>
+                        <td>
+                        <ewd:if firstValue="$ptname" operation="=" secondValue="">
+                            <ewd:comment>Do nothing here, for now.</ewd:comment>
+                        <ewd:else> 
+                            
+                            <ewd:comment> Print patients; mismatched beds show up in a different color</ewd:comment>
+                            <ewd:if firstValue="$bedsex" operation="=" secondValue="">
+                                <span class="okbed"><?= $ptname ?></span>
+                            <ewd:else>
+                                <ewd:if firstValue="$bedsex" operation="[" secondValue="$sex">
+                                <span class="okbed"><?= $ptname ?></span>
+                                <ewd:else>
+                                <span class="mismatch"><?= $ptname ?></span>
+                                </ewd:if>
+                            </ewd:if>
+                            
+                            <ewd:comment>Lodger</ewd:comment>
+                            <ewd:if firstValue="$lodger" operation="=" secondValue="1">
+                            <br />
+                            <span class="lodger">(reserved) (since <?= $admDate ?>)</span>
+                            </ewd:if>
+                            
+                            <ewd:comment>EDW</ewd:comment>
+                            <ewd:if firstValue="$edw" operation="=" secondValue="1">
+                            &nbsp;<span class="EDW">EDW</span>
+                            </ewd:if>
+                            
+                            <ewd:comment>MOT</ewd:comment>
+                            <ewd:if firstValue="$mot" operation="=" secondValue="1">
+                            &nbsp;<span class="MOT">MOT</span>
+                            </ewd:if>
+                        
+                        </ewd:if>
+
+                        <ewd:comment>Deal with Out Of Service Beds</ewd:comment>
+                        <ewd:if firstValue="$oos" operation="=" secondvalue="1">
+                            <span class="oos"><?= $oosmsg ?>: <?= $ooscomment ?></span>
+                        </ewd:if>
+                        </td>
+                    </tr>
+                    </ewd:forEach>
+                </table>
+            </td>
+            </ewd:forEach>
+        </tr>
+    </table>
+    <br />
+    <ewd:comment>
+    Here we have the Census Table
+    wardbed=beds^males^females^empty beds^occupancy %
+    </ewd:comment>
+    <ewd:getPiece data="#wardbed" asciiDelimiter="94" pieceNumber="1" return="$tBed">
+    <ewd:getPiece data="#wardbed" asciiDelimiter="94" pieceNumber="2" return="$tMale">
+    <ewd:getPiece data="#wardbed" asciiDelimiter="94" pieceNumber="3" return="$tFemale">
+    <ewd:getPiece data="#wardbed" asciiDelimiter="94" pieceNumber="4" return="$tEmptyBed">
+    <ewd:getPiece data="#wardbed" asciiDelimiter="94" pieceNumber="5" return="$occper">
+    <table width="100%" style="border: 1px solid #CFCFC3">
+        <tr>
+            <th colspan="100%" style="color: white; font-weight: bold; background-color: #357AE8">Census</th>
+        </tr>
+        <tr style="color: white; font-weight: bold; background-color: #357AE8; border: 1px solid #2F5BB7; text-align: center">
+            <td width="20%">Total Beds</td>
+            <td width="20%">Males</td>
+            <td width="20%">Females</td>
+            <td width="20%">Empty Beds</td>
+            <td width="20%">% Occupation</td>
+        </tr>
+        <tr style="font-weight: bold; text-align: center">
+            <td><?= $tBed ?></td>
+            <td><?= $tMale ?></td>
+            <td><?= $tFemale ?></td>
+            <td><?= $tEmptyBed ?></td>
+            <td><?= $occper ?></td>
+        </tr>
+    </table>
+</div>
Index: EWD/ewdapps/bb/pages/ewdTemplate.ewd
===================================================================
--- EWD/ewdapps/bb/pages/ewdTemplate.ewd	(revision 1284)
+++ EWD/ewdapps/bb/pages/ewdTemplate.ewd	(revision 1284)
@@ -0,0 +1,41 @@
+<ewd:comment>
+BB Template File
+Bed Board v 0.5
+</ewd:comment>
+
+<ewd:Template>
+    <ewd:config defaultTimeout="99999999999" homePage="index.ewd">
+    <ewd:head>    
+    <ewd:comment>
+    Load the Session Values for DUZ etc.
+    </ewd:comment>
+    <ewd:execute method="r^ewdu" type="procedure" param1="#ewd_sessid">
+        <style type="text/css">
+            .fbed { color: white; background-color: #661A4C; font-weight: bold; padding: 2 ; border-radius: 5 ; white-space: nowrap }
+            .mbed { color: white; background-color: blue; font-weight: bold; padding: 2; border-radius: 5 ; white-space: nowrap }
+            .nbed { color: black; background-color: cornsilk; font-weight: bold; padding: 2; border-radius: 5; white-space: nowrap }
+            .okbed { }
+            .mismatch { background-color: yellow }
+            .small { font-size: x-small }
+            .oos { color: red; font-weight: bold }
+            .EDW { color: white; background-color: red; font-weight: bold; padding: 2; border-radius: 5 }
+            .MOT { color: white; background-color: green; font-weight: bold; padding: 2; border-radius: 5 }
+            h1,h2,h3,h4,h5,h6,p,td,th,span,a { font-family: sans-serif }
+            .end { color: white; background-color: black; border-top: 1px solid gray ; padding: 2px }
+        </style>
+    </ewd:head>
+    <ewd:body>
+    <ewd:header>
+    </ewd:header>
+    
+    <ewd:footer>
+    <div class="end">
+        <span class="small">EWD Session # <?= #ewd_sessid ?></span>
+        <span class="small">DUZ <?= #DUZ ?></span>
+        <span class="small">U <?= #U ?></span>
+        <span class="small">IO <?= #IO ?></span>
+        <a class="small" href="ewdLogout.ewd">Logout</a>
+    </div>
+    </ewd:footer>
+</ewd:body>
+</ewd:Template>
Index: EWD/ewdapps/bb/pages/index.ewd
===================================================================
--- EWD/ewdapps/bb/pages/index.ewd	(revision 1284)
+++ EWD/ewdapps/bb/pages/index.ewd	(revision 1284)
@@ -0,0 +1,43 @@
+<ewd:comment>
+ Index Page
+ v 0.5
+ (c) Sam Habiel
+ Licensed under AGPL
+</ewd:comment>
+
+<ewd:config isFirstPage="false" prePageScript="init^jjihbb">
+<!DOCTYPE html>
+<html>
+<head>
+<title><?= #sitename ?> Bed Board</title>
+</head>
+<body>
+<h1 style="text-align: center"><?= #sitename ?> Bed Board</h1>
+<div id="bb" ajaxPage="bb" event="onTimer" time="5">
+Please wait 5 seconds for initial load...
+</div>
+<div id="legend">
+ <h3>Legend</h3>
+    <table border="1">
+    <tr>
+     <th>Color</th>
+     <th>Meaning</th>
+    </tr>
+    <tr>
+     <td class="mbed">210-B</td>
+     <td>Male Bed</td>
+    </tr>
+    <tr>
+     <td class="fbed">111-A</td>
+     <td>Female Bed</td>
+    </tr>
+    <tr>
+     <td class="mismatch">TEST,PATIENT</td>
+     <td>Male Patient in Female bed or the converse</td>
+    </tr>
+    <tr>
+     <td class="oos">TEST COMMENT</td>
+     <td>Bed is Out of Service</td>
+    </table>
+</div>
+</body>
Index: EWD/ewdapps/bb/r/jjihbb.m
===================================================================
--- EWD/ewdapps/bb/r/jjihbb.m	(revision 1284)
+++ EWD/ewdapps/bb/r/jjihbb.m	(revision 1284)
@@ -0,0 +1,213 @@
+jjihbb ; JJIH/SMH - Bed Board Stuff ; 9/22/11 3:27pm
+ ;;0.5;INTRACARE SPECIFIC MODIFICATIONS;;
+ ; (C) Sam Habiel
+ ; Licensed under AGPL latest
+ ; 
+ ; Bed Board routine for EWD pages index.ewd and bb.ewd
+ ;
+ ; New in 0.3: 
+ ; - Added a bunch of counts everywhere.
+ ; 
+ ; New in 0.4:
+ ; - Added EDW and MOT fields
+ ; - Patients with no beds are included!
+ ; 
+ ; New in 0.5:
+ ; - Fixed division by zero problem if db is completely unconfigured
+ ;
+init(sessid)  ; Populate index.ewd with site name
+ new DIQUIET set DIQUIET=1  ; Fileman - be quiet
+ do DT^DICRW                ; Set-up miniumum variables for VISTA
+ new sitename set sitename=$piece($$SITE^VASITE,"^",2)
+ set sitename=$$TITLE^XLFSTR(sitename)  ; Make uppercase title case.
+ do setSessionValue^%zewdAPI("sitename",sitename,sessid)
+ quit ""
+ ;
+getbeds(sessid) ; Populate bb.ewd with bed board information
+ ;
+ ; To run this on your terminal, set debug to 1 and type: w $$getbeds^jjihbb(80)
+ new debug set debug=0      ; Make this 1 to be talkative
+ new DIQUIET set DIQUIET=1  ; Fileman - be quiet
+ do DT^DICRW                ; Set-up miniumum variables for VISTA
+ ; Ask Fileman for the list of the wards, taking out inactive ones
+ ; File 42; .01 field only, "Packed Output, don't re-sort", use "B" index
+ ; Screen inactive wards out using Fileman Screen on File.
+ n wards1,err
+ D LIST^DIC(42,"","@;.01","PQ","","","","B","S D0=Y D WIN^DGPMDDCF I 'X","","wards1","err")
+ i $d(err) s $EC=",U101,"  ; we shouldn't ever have any messages - crash if so
+ n wards2 ; better wards!
+ m wards2=wards1("DILIST")
+ ; expected output:
+ ; wards2(0)="5^*^0^"
+ ; wards2(0,"MAP")="IEN^.01"
+ ; wards2(1,0)="15^Adolescent 2L 201-213 South"
+ ; wards2(2,0)="11^Child 2R 214-225 South"
+ ; wards2(3,0)="14^DAPA 3R 314-326"
+ ; wards2(4,0)="13^General/Adult 3L 300-313 South"
+ ; wards2(5,0)="10^Restore 1L 101-111 South"
+ ; Now, walk the beds a la ABB^DGPMRBA1
+ n wardbed  ; return array
+ n i s i=0
+ for  s i=$o(wards2(i)) q:'i  do
+ . n wardien s wardien=$piece(wards2(i,0),"^")
+ . zwrite:debug wardien
+ . n roomien s roomien=0
+ . for  s roomien=$o(^DG(405.4,"W",wardien,roomien)) q:'roomien  do
+ . . zwrite:debug roomien
+ . . quit:'$d(^DG(405.4,roomien,0))
+ . . new bed set bed=$P(^(0),"^")
+ . . new admien set admien=$o(^DGPM("ARM",roomien,0))
+ . . new lodger,ptnode,edw,mot
+ . . if admien d 
+ . . . set lodger=^(admien)
+ . . . set ptnode=^DGPM(admien,0) ; note naked sexy ref
+ . . . set edw=+$p($g(^("JJIH0")),"^")
+ . . . set mot=+$p($g(^("JJIH0")),"^",2)
+ . . write:debug "ptnode: "_$g(ptnode),!
+ . . write:debug "edw: "_$g(edw),!
+ . . write:debug "mot: "_$g(mot),!
+ . . ; 
+ . . ; Bed Message
+ . . ; pt name^pt sex^adm date^lodger^EDW^MOT^bed oos?^bed oos msg^bed oss comment
+ . . n bedmsg
+ . . i $g(ptnode) d  ; if we have a patient, that's the bed msg
+ . . . n dfn s dfn=$p(ptnode,"^",3)
+ . . . s bedmsg=$p(^DPT(dfn,0),"^",1,2) ; Patient name and sex
+ . . . ; s $p(bedmsg,"^",3)=$$FMTE^XLFDT($p(ptnode,"^")) ; Admission date
+ . . . s $p(bedmsg,"^",3)=$$DATE^TIULS($p(ptnode,"^"),"AMTH DD@HR:MIN") ; Admission date using TIU API
+ . . . s $p(bedmsg,"^",4)=$g(lodger)
+ . . . s $p(bedmsg,"^",5)=$g(edw)
+ . . . s $p(bedmsg,"^",6)=$g(mot)
+ . . d  ; Out of Service Checks?
+ . . . n oos s oos=$$oos(roomien) ; 0 or 1^msg^comment
+ . . . s $p(bedmsg,"^",7,9)=oos
+ . . ;
+ . . s wardbed($piece(wards2(i,0),"^",2),bed)=bedmsg
+ ;
+ ; Loop through inpatients to find patients without a bed
+ ; Bed Message (reminder!)
+ ; pt name^pt sex^adm date^lodger^EDW^MOT^bed oos?^bed oos msg^bed oss comment
+ n i,j s (i,j)=""
+ n counter s counter=0
+ for  s i=$o(^DPT("CN",i)) q:i=""  for  s j=$o(^DPT("CN",i,j)) q:j=""  do
+ . n admien s admien=^(j) ; Patient Movement IEN stored in Index
+ . n dfn s dfn=j
+ . n bed s bed=$get(^DPT(dfn,.101))
+ . i bed'="" quit  ; if bed is not empty, quit!
+ . s counter=counter+1
+ . n wardname s wardname=^DPT(dfn,.1)
+ . s wardbed(wardname,"NONE"_counter)=$p(^DPT(dfn,0),"^",1,2) ; name, sex
+ . n admdate s admdate=$P(^DGPM(admien,0),"^")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",3)=$$DATE^TIULS(admdate,"AMTH DD@HR:MIN")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",4)=0 ; lodger
+ . n edw s edw=+$p($g(^("JJIH0")),"^")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",5)=edw
+ . n mot s mot=+$p($g(^("JJIH0")),"^",2)
+ . s $p(wardbed(wardname,"NONE"_counter),"^",6)=mot
+ ;
+ ; Loop through lodgers to find lodgers without a bed
+ ; Bed Message (reminder!)
+ ; pt name^pt sex^adm date^lodger^EDW^MOT^bed oos?^bed oos msg^bed oss comment
+ n i,j s (i,j)=""
+ for  s i=$o(^DPT("LD",i)) q:i=""  for  s j=$o(^DPT("LD",i,j)) q:j=""  do
+ . n admien s admien=^(j) ; Patient Movement IEN stored in Index
+ . n dfn s dfn=j
+ . n bed s bed=$get(^DPT(dfn,.108))
+ . i bed'="" quit  ; if bed is not empty, quit!
+ . s counter=counter+1
+ . n wardname s wardname=^DPT(dfn,.107)
+ . s wardbed(wardname,"NONE"_counter)=$p(^DPT(dfn,0),"^",1,2) ; name, sex
+ . n admdate s admdate=$P(^DGPM(admien,0),"^")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",3)=$$DATE^TIULS(admdate,"AMTH DD@HR:MIN")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",4)=1 ; lodger
+ . n edw s edw=+$p($g(^("JJIH0")),"^")
+ . s $p(wardbed(wardname,"NONE"_counter),"^",5)=edw
+ . n mot s mot=+$p($g(^("JJIH0")),"^",2)
+ . s $p(wardbed(wardname,"NONE"_counter),"^",6)=mot
+ ;
+ ; Now loop through the results and count beds, males, and females
+ ; Result will be in wardbed("ward name")=
+ ; occ beds/total^occmale/maletotal^occfemale/femaletotal^oos^
+ ; emptymale/emptyfemale/emptytotal
+ n i s i="" n j s j=""  ; i loops through wards, j beds
+ f  s i=$o(wardbed(i)) q:i=""  d
+ . n nBed,nMale,nFemale,nOOS,nMaleBed,nFemaleBed,nEmptyMaleBed,nEmptyFemaleBed
+ . s (nBed,nMale,nFemale,nOOS,nMaleBed,nFemaleBed,nEmptyMaleBed,nEmptyFemaleBed)=0
+ . ;
+ . f  s j=$o(wardbed(i,j)) q:j=""  d
+ . . n node s node=wardbed(i,j)
+ . . i +j s nBed=nBed+1 ; if bed is numeric, then count it as a bed. If NONE, won't count
+ . . i $p(j,"-",3)["M" s nMaleBed=nMaleBed+1                ; Male Bed
+ . . i $p(j,"-",3)["F" s nFemaleBed=nFemaleBed+1            ; Female Bed
+ . . i $p(j,"-",3)["M"&($p(node,"^")="") s nEmptyMaleBed=nEmptyMaleBed+1     ; Empty Male Bed
+ . . i $p(j,"-",3)["F"&($p(node,"^")="") s nEmptyFemaleBed=nEmptyFemaleBed+1 ; Empty Female Bed
+ . . i $p(node,"^",2)="M" s nMale=nMale+1                   ; Male Patient
+ . . i $p(node,"^",2)="F" s nFemale=nFemale+1               ; Female Patient
+ . . i $p(node,"^",7)="1" s nOOS=nOOS+1                     ; Out of Service Bed
+ . ;
+ . n nOccupied s nOccupied=nMale+nFemale
+ . n nAvailBed s nAvailBed=nBed-nOccupied
+ . n % s %="/"
+ . s wardbed(i)=nOccupied_%_nBed_U_nMale_%_nMaleBed_U_nFemale_%_nFemaleBed_U_nOOS_U_nEmptyMaleBed_%_nEmptyFemaleBed_%_nAvailBed
+ ;
+ ; Now, loop again and count the counts for a total census.
+ n i s i=""
+ n tBed,tMale,tFemale,tOOS s (tBed,tMale,tFemale,tOOS)=0  ; Totals
+ f  s i=$o(wardbed(i)) q:i=""  d
+ . n node s node=wardbed(i)
+ . n nBed s nBed=$p($p(wardbed(i),"^"),"/",2)
+ . n nMale s nMale=$p(wardbed(i),"^",2)
+ . n nFemale s nFemale=$p(wardbed(i),"^",3)
+ . n nOOS s nOOS=$p(wardbed(i),"^",4)
+ . s tBed=tBed+nBed
+ . s tMale=tMale+nMale
+ . s tFemale=tFemale+nFemale
+ . s tOOS=tOOS+nOOS
+ ; done
+ ;
+ ; Set the totals at the top top node in the following format
+ ; wardbed=beds^males^females^empty beds^occupancy %
+ n tEmptyBed s tEmptyBed=tBed-(tMale+tFemale+tOOS) ; Empty beds
+ ;
+ n %occupancy
+ ; Prevent div by zero error if beds are not there!!!
+ i tBed=0 s %occupancy=0
+ e  s %occupancy=(1-(tEmptyBed/tBed))*100 ; Reader: math quiz for you
+ s %occupancy=$fn(%occupancy,"",0)  ; Round up to 0 decimal places
+ ;
+ s wardbed=tBed_U_tMale_U_tFemale_U_tEmptyBed_U_%occupancy
+ ;
+ ; Put it in the EWD Session
+ do clearSessionArray^%zewdAPI("wardbed",sessid)
+ do mergeArrayToSession^%zewdAPI(.wardbed,"wardbed",sessid)
+ ;
+ zwrite:debug wardbed
+ quit ""
+ ;
+oos(bedien) ; Is the bed out of service ; Public $$
+ ; Input: bedien
+ ; Output: 0 -> not out of service -> Active
+ ;         1^reason -> Out of service and reason
+ ;
+ ; First OOS date in the inverse index is the latest
+ N X S X=$O(^DG(405.4,bedien,"I","AINV",0))
+ I 'X Q 0  ; if none, quit
+ ;
+ S X=$O(^(+X,0)) ; Then get ifn
+ Q:'$d(^DG(405.4,bedien,"I",+X,0)) 0  ; confirm that entry exists
+ ;
+ N DGND S DGND=^(0)                 ; Out of Service Node
+ N OOSD S OOSD=$P(DGND,"^")         ; Out of Service Date
+ N OOSR S OOSR=$P(DGND,"^",4)       ; Out of Service Restore
+ N NOW S NOW=$$NOW^XLFDT()          ; Now
+ ;
+ I OOSD>NOW Q 0                     ; If OOSD in future, bed is active
+ ;
+ ; at this point, OOSD is now or in the past.
+ ; Is there a restore date less than today's date? if yes, bed is active
+ I OOSR'="",OOSR<NOW Q 0
+ ;
+ ; at this point, we are sure that the bed is inactive.
+ N reasonifn s reasonifn=$p(DGND,"^",2)
+ N comment s comment=$p(DGND,"^",3)
+ Q 1_"^"_$$GET1^DIQ(405.5,reasonifn,.01)_"^"_comment
Index: EWD/ewdapps/rsemu/pages/index.ewd
===================================================================
--- EWD/ewdapps/rsemu/pages/index.ewd	(revision 1284)
+++ EWD/ewdapps/rsemu/pages/index.ewd	(revision 1284)
@@ -0,0 +1,28 @@
+<ewd:config isFirstPage="true" websockets="true" cachePage="false">
+<html>
+<head>
+<title>Roll and Scroll Emulator</title>
+<script type="text/javascript">
+    //must be defined before body is loaded.
+    EWD.sockets.serverMessageHandler = function (msg)
+    {
+       document.getElementById("message").innerHTML = "Sent from GT.M: " + msg.message;
+    };
+
+    //can only work after body is loaded. Body loads socket.io.
+    function helloSockets() {
+        EWD.sockets.sendMessage({type: "testing", message:  "This is my message for you to use"});
+     };
+    
+    //GT.M Test
+    function GTMTest() {
+        EWD.sockets.sendMessage({type: "M", message: "hello"});
+    };
+
+</script>
+</head>
+<body onload="helloSockets()">
+<div id="message">
+</div>
+</body>
+</html>
Index: EWD/ewdapps/so/pages/cvc.ewd
===================================================================
--- EWD/ewdapps/so/pages/cvc.ewd	(revision 1284)
+++ EWD/ewdapps/so/pages/cvc.ewd	(revision 1284)
@@ -0,0 +1,37 @@
+<ewd:comment>
+(C) Sam Habiel 2011
+Inherits EWD License, whatever it is.
+</ewd:comment>
+<ewd:config isFirstPage="false" prePageScript="whoami^ewdu">
+<html>
+<head>
+    <title>Change Verify Code</title>
+</head>
+<body>
+<h1>Change Verify Code</h1>
+<form id="content" method="POST" action="ewd">
+  <table>
+     <tr>
+       <td>Username: </td>
+       <td><?= #Name ?></td>
+     </tr>
+     <tr>
+       <td><label for="vc1">Verify Code (existing):</label> </td>
+       <td><input type="password" name="vc1" value="<?= #vc ?>"></td>
+     </tr>
+     <tr>
+       <td><label for="vc2">Verify Code (new):</label> </td>
+       <td><input type="password" name="vc2"></td>
+     </tr>
+     <tr>
+       <td><label for="vc3">Verify Code (confirm):</label> </td>
+       <td><input type="password" name="vc3"></td>
+     </tr>
+     <tr>
+       <td><input type="submit" id="submit" name="submit" value="Save" action="cvc^ewdu" nextpage="menu"></td>
+     </tr>
+  </table>
+</form>
+</body>
+</html>
+
Index: EWD/ewdapps/so/pages/ewdTemplate.ewd
===================================================================
--- EWD/ewdapps/so/pages/ewdTemplate.ewd	(revision 1284)
+++ EWD/ewdapps/so/pages/ewdTemplate.ewd	(revision 1284)
@@ -0,0 +1,365 @@
+<ewd:comment>
+Sign On Template File.
+Contains CSS and JS
+V 0.1
+Author: Sam Habiel
+License: Same as EWD License
+
+CSS inspired by: 
+http://www.red-team-design.com/slick-login-form-with-html5-css3?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+redteamdesign+%28Red+Team+Design%29&utm_content=FeedBurner
+</ewd:comment>
+
+<ewd:Template>
+    <ewd:config defaultTimeout="99999999999" homePage="index.ewd">
+    <ewd:execute method="r^ewdu" type="procedure" param1="#ewd_sessid">
+    <ewd:head>    
+        <style type="text/css">
+            html, body
+            {
+                height: 100%;
+            }
+
+            body
+            {
+                font: 12px 'Lucida Sans Unicode', 'Trebuchet MS', Arial, Helvetica;    
+                margin: 0;
+                background-color: #d9dee2;
+                background-repeat: no-repeat;
+                background-image: -webkit-gradient(linear, left top, left bottom, from(#ebeef2), to(#d9dee2));
+                background-image: -webkit-linear-gradient(top, #ebeef2, #d9dee2);
+                background-image: -moz-linear-gradient(top, #ebeef2, #d9dee2);
+                background-image: -ms-linear-gradient(top, #ebeef2, #d9dee2);
+                background-image: -o-linear-gradient(top, #ebeef2, #d9dee2);
+                background-image: linear-gradient(top, #ebeef2, #d9dee2);    
+            }
+
+            /*--------------------*/
+
+            #login, #content
+            {
+                text-align: center;
+                background-color: #fff;
+                background-image: -webkit-gradient(linear, left top, left bottom, from(#fff), to(#eee));
+                background-image: -webkit-linear-gradient(top, #fff, #eee);
+                background-image: -moz-linear-gradient(top, #fff, #eee);
+                background-image: -ms-linear-gradient(top, #fff, #eee);
+                background-image: -o-linear-gradient(top, #fff, #eee);
+                background-image: linear-gradient(top, #fff, #eee);  
+                /*height: 240px;*/
+                width: 600px;
+                margin: 0px 0 0 -300px;
+                padding: 30px;
+                position: absolute;
+                top: 5%;
+                left: 49%;
+                z-index: 0;
+                -moz-border-radius: 3px;
+                -webkit-border-radius: 3px;
+                border-radius: 3px;  
+                -webkit-box-shadow:
+                      0 0 2px rgba(0, 0, 0, 0.2),
+                      0 1px 1px rgba(0, 0, 0, .2),
+                      0 3px 0 #fff,
+                      0 4px 0 rgba(0, 0, 0, .2),
+                      0 6px 0 #fff,  
+                      0 7px 0 rgba(0, 0, 0, .2);
+                -moz-box-shadow:
+                      0 0 2px rgba(0, 0, 0, 0.2),  
+                      1px 1px   0 rgba(0,   0,   0,   .1),
+                      3px 3px   0 rgba(255, 255, 255, 1),
+                      4px 4px   0 rgba(0,   0,   0,   .1),
+                      6px 6px   0 rgba(255, 255, 255, 1),  
+                      7px 7px   0 rgba(0,   0,   0,   .1);
+                box-shadow:
+                      0 0 2px rgba(0, 0, 0, 0.2),  
+                      0 1px 1px rgba(0, 0, 0, .2),
+                      0 3px 0 #fff,
+                      0 4px 0 rgba(0, 0, 0, .2),
+                      0 6px 0 #fff,  
+                      0 7px 0 rgba(0, 0, 0, .2);
+            }
+
+            #login:before, #content:before
+            {
+                content: '';
+                position: absolute;
+                z-index: -1;
+                border: 1px dashed #ccc;
+                top: 5px;
+                bottom: 5px;
+                left: 5px;
+                right: 5px;
+                -moz-box-shadow: 0 0 0 1px #fff;
+                -webkit-box-shadow: 0 0 0 1px #fff;
+                box-shadow: 0 0 0 1px #fff;
+            }
+
+            /*--------------------*/
+
+            h1
+            {
+                text-shadow: 0 1px 0 rgba(255, 255, 255, .7), 0px 2px 0 rgba(0, 0, 0, .5);
+                text-transform: uppercase;
+                text-align: center;
+                color: #666;
+                margin: 0 0 30px 0;
+                letter-spacing: 4px;
+                font: normal 26px/1 Verdana, Helvetica;
+                position: relative;
+            }
+
+            h1:after, h1:before
+            {
+                background-color: #777;
+                content: "";
+                height: 1px;
+                position: absolute;
+                top: 15px;
+                width: 20px;   
+            }
+
+            h1:after
+            { 
+                background-image: -webkit-gradient(linear, left top, right top, from(#777), to(#fff));
+                background-image: -webkit-linear-gradient(left, #777, #fff);
+                background-image: -moz-linear-gradient(left, #777, #fff);
+                background-image: -ms-linear-gradient(left, #777, #fff);
+                background-image: -o-linear-gradient(left, #777, #fff);
+                background-image: linear-gradient(left, #777, #fff);      
+                right: 0;
+            }
+
+            h1:before
+            {
+                background-image: -webkit-gradient(linear, right top, left top, from(#777), to(#fff));
+                background-image: -webkit-linear-gradient(right, #777, #fff);
+                background-image: -moz-linear-gradient(right, #777, #fff);
+                background-image: -ms-linear-gradient(right, #777, #fff);
+                background-image: -o-linear-gradient(right, #777, #fff);
+                background-image: linear-gradient(right, #777, #fff);
+                left: 0;
+            }
+
+            /*--------------------*/
+
+            fieldset
+            {
+                border: 0;
+                padding: 0;
+                margin: 0;
+            }
+
+            /*--------------------*/
+
+            #inputs input[type="password"]
+            {
+                background: #f1f1f1 ;
+                padding: 15px 15px 15px 30px;
+                margin: 0 0 10px 0;
+                width: 353px; /* 353 + 2 + 45 = 400 */
+                border: 1px solid #ccc;
+                -moz-border-radius: 5px;
+                -webkit-border-radius: 5px;
+                border-radius: 5px;
+                -moz-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+                -webkit-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+                box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+            }
+
+            #inputs input[type="checkbox"]
+            {
+                background: #f1f1f1 ;
+                padding: 15px 15px 15px 30px;
+                margin: 0 0 10px 0;
+                border: 1px solid #ccc;
+                -moz-border-radius: 5px;
+                -webkit-border-radius: 5px;
+                border-radius: 5px;
+                -moz-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+                -webkit-box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+                box-shadow: 0 1px 1px #ccc inset, 0 1px 0 #fff;
+            }
+
+            #username
+            {
+                background-position: 5px -2px !important;
+            }
+
+            #password
+            {
+                background-position: 5px -52px !important;
+            }
+
+            #inputs input:focus
+            {
+                background-color: #fff;
+                border-color: #e8c291;
+                outline: none;
+                -moz-box-shadow: 0 0 0 1px #e8c291 inset;
+                -webkit-box-shadow: 0 0 0 1px #e8c291 inset;
+                box-shadow: 0 0 0 1px #e8c291 inset;
+            }
+
+            /*--------------------*/
+            #actions
+            {
+                margin: 25px 0 0 0;
+            }
+
+            #submit
+            {       
+                background-color: #ffb94b;
+                background-image: -webkit-gradient(linear, left top, left bottom, from(#fddb6f), to(#ffb94b));
+                background-image: -webkit-linear-gradient(top, #fddb6f, #ffb94b);
+                background-image: -moz-linear-gradient(top, #fddb6f, #ffb94b);
+                background-image: -ms-linear-gradient(top, #fddb6f, #ffb94b);
+                background-image: -o-linear-gradient(top, #fddb6f, #ffb94b);
+                background-image: linear-gradient(top, #fddb6f, #ffb94b);
+                
+                -moz-border-radius: 3px;
+                -webkit-border-radius: 3px;
+                border-radius: 3px;
+                
+                text-shadow: 0 1px 0 rgba(255,255,255,0.5);
+                
+                 -moz-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
+                 -webkit-box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;
+                 box-shadow: 0 0 1px rgba(0, 0, 0, 0.3), 0 1px 0 rgba(255, 255, 255, 0.3) inset;    
+                
+                border-width: 1px;
+                border-style: solid;
+                border-color: #d69e31 #e3a037 #d5982d #e3a037;
+
+                float: left;
+                height: 35px;
+                padding: 0;
+                width: 120px;
+                cursor: pointer;
+                font: bold 15px Arial, Helvetica;
+                color: #8f5a0a;
+            }
+
+            #submit:hover,#submit:focus
+            {       
+                background-color: #fddb6f;
+                background-image: -webkit-gradient(linear, left top, left bottom, from(#ffb94b), to(#fddb6f));
+                background-image: -webkit-linear-gradient(top, #ffb94b, #fddb6f);
+                background-image: -moz-linear-gradient(top, #ffb94b, #fddb6f);
+                background-image: -ms-linear-gradient(top, #ffb94b, #fddb6f);
+                background-image: -o-linear-gradient(top, #ffb94b, #fddb6f);
+                background-image: linear-gradient(top, #ffb94b, #fddb6f);
+            }   
+
+            #submit:active
+            {       
+                outline: none;
+               
+                 -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
+                 -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;
+                 box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5) inset;        
+            }
+
+            #submit::-moz-focus-inner
+            {
+              border: none;
+            }
+
+            #actions a
+            {
+                color: #3151A2;    
+                float: right;
+                line-height: 35px;
+                margin-left: 10px;
+            }
+
+            /*--------------------*/
+
+            #back
+            {
+                display: block;
+                text-align: center;
+                position: relative;
+                top: 60px;
+                color: #999;
+            }
+
+            #intro
+            {
+                height: 200px;
+                overflow: auto;
+                margin-bottom: 30px;
+            }
+
+            #error
+            {
+                font-weight: bold;
+                color: red;
+            }
+
+            table
+            {
+                width: 90%;
+                margin-left: 5%;
+                margin-right: 5%;
+                border: 0;
+            }
+
+            table td
+            {
+                text-align: right;
+                vertical-align: middle;
+            }
+
+            .small 
+            { 
+            font-size: x-small 
+            }
+            
+            .small a
+            {
+                color: white;
+            }
+
+            .small a:hover
+            {
+                color: yellow;
+            }
+            
+            .footer 
+            { 
+                color: white; 
+                background-color: black; 
+                border-top: 1px solid gray ;
+                padding: 2px ; 
+                position: fixed; 
+                bottom: 0 
+            }
+
+            .left
+            {
+                left: 0;
+            }
+
+            .right
+            {
+                right: 0;
+            }
+        </style>
+    </ewd:head>
+    <ewd:body>
+    <ewd:header>
+    </ewd:header>
+    
+    <ewd:footer>
+    <div class="footer left small">
+        <span>EWD Session # <?= #ewd_sessid ?></span>
+        <a href="ewdLogout.ewd">Sign Out</a>
+    </div>
+    <div class="footer right small">
+        <span>DUZ <?= #DUZ ?></span>
+        <span>U <?= #U ?></span>
+        <span>IO <?= #IO ?></span>
+    </div>
+    </ewd:footer>
+</ewd:body>
+</ewd:Template>
Index: EWD/ewdapps/so/pages/index.ewd
===================================================================
--- EWD/ewdapps/so/pages/index.ewd	(revision 1284)
+++ EWD/ewdapps/so/pages/index.ewd	(revision 1284)
@@ -0,0 +1,62 @@
+<ewd:comment>
+(C) Sam Habiel 2011
+License: Inherits EWD License, whatever it is.
+</ewd:comment>
+
+<ewd:config isFirstPage="true" prePageScript="SETUP^ewdu">
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>VISTA Sign-On</title>
+    
+    <!-- Redirect Javascript for EWD Errors -->
+    <script type="text/javascript">
+        var VISTA = {};  // Mi Casa
+        VISTA.redirectEWDErrorToDiv = function () {
+            EWD.page.errorMessage = function (msg) {
+                if (msg !== '') 
+                {
+                    var errDiv = document.getElementById('error');
+                    errDiv.innerHTML = msg;
+                }
+            };
+        };
+    </script>
+    <!-- End -->
+
+    </head>
+    <body onload="VISTA.redirectEWDErrorToDiv()">
+       <form id="login" method="post" action="ewd">
+            <h1>Sign On to VISTA</h1>
+            <div id="intro">
+                <p>
+                    <ewd:forEach sessionName="introtxt" index="$n" return="$line">
+                    <?= $line ?> <br />
+                    </ewd:forEach>
+                </p>
+            </div>
+            <fieldset id="inputs">
+                <table>
+                    <tr>
+                    <td valign="middle"><label for="ac">Access Code</label></td>
+                    <td valign="middle"><input id="ac" type="password" placeholder="Access Code" autofocus required></td>
+                    </tr>
+                    <tr>
+                    <td valign="middle"><label for="vc">Verify Code</label></td>
+                    <td valign="middle"><input id="vc" type="password" placeholder="Verify Code" required></td>
+                    </tr>
+                    <tr>
+                    <td>&nbsp;</td>
+                    <td><label for="cvc">Change Verify Code</label><input id="cvc" value="cvc" type="checkbox"></td>
+                    </tr>
+                </table>
+            </fieldset>
+            <div id="error">
+            </div>
+            <fieldset id="actions">
+                <input type="submit" name="submit" id="submit" value="Sign On" action="so^ewdu" nextpage="menu">
+                <a href="">Help</a>
+            </fieldset>
+        </form>
+    </body>
+</html>
Index: EWD/ewdapps/so/pages/menu.ewd
===================================================================
--- EWD/ewdapps/so/pages/menu.ewd	(revision 1284)
+++ EWD/ewdapps/so/pages/menu.ewd	(revision 1284)
@@ -0,0 +1,20 @@
+<ewd:config isFirstPage="false" prePageScript="SETUP^ewdu">
+<!DOCTYPE html>
+<html>
+    <head>
+        <title>Menu System</title>
+    </head>
+    <body>
+        <div id="intro">
+            <p>Where do you want to go?</p>
+        </div>
+       <form id="menu" method="post" action="ewd">
+            <h1>Menu</h1>
+            <fieldset id="menu">
+                <input type="submit" name="Submit" id="submit" value="Bed Board" action="sss^ewdu">
+                <a href="">Help</a>
+            </fieldset>
+        </form> 
+    </body>
+</html>
+
Index: EWD/ewdapps/so/r/ewdu.m
===================================================================
--- EWD/ewdapps/so/r/ewdu.m	(revision 1284)
+++ EWD/ewdapps/so/r/ewdu.m	(revision 1284)
@@ -0,0 +1,107 @@
+ewdu ; JJIH/SMH - Utilities for EWD to VISTA interaction ; 11/4/11 10:44pm
+ ;
+r(sessid) ; Restore Symbol Table
+ d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",sessid)
+ d mergeArrayFromSession^%zewdAPI(.IO,"IO",sessid)
+ s U=$$getSessionValue^%zewdAPI("U",sessid)
+ quit
+ ;
+s(sessid) ; Save to Symbol Table
+ d mergeArrayToSession^%zewdAPI(.DUZ,"DUZ",sessid)
+ d mergeArrayToSession^%zewdAPI(.IO,"IO",sessid)
+ d setSessionValue^%zewdAPI("U","^",sessid)
+ quit
+ ;
+NULL ; Open Null Device
+ s %ZIS="0H",IOP="NULL" d ^%ZIS
+ i POP s $ec=",U1,"  ; this crashes everything... intended...
+ q
+ ;
+SETUP(sessid) ; Set-up and SSO
+ ; TODO: Set IO("CLNM")
+ i '$data(IO) d NULL                  ; Open Null Device
+ s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
+ n return
+ d SETUP^XUSRB(.return)               ; Set-up and Try SSO
+ i $g(return(5)),DUZ>0 q $$s(sessid)  ; Single Sign-On Successful!
+ e  d  q ""                           ; Otherwise, get INTRO text
+ . N RET
+ . D INTRO^XUSRB(.RET)
+ . d mergeArrayToSession^%zewdAPI(.RET,"introtxt",sessid)
+ ; ---
+so(sessid) ; SO from EWD; routes to $$SO
+ ; TODO: Set IO("CLNM")
+ d NULL                             ; IO set-up
+ s IO("IP")=$$getServerValue^%zewdAPI("REMOTE_ADDR",sessid)
+ d SETUP^XUSRB();                   ; This time, just need partition set-up
+ n ac s ac=$$getSessionValue^%zewdAPI("ac",sessid)
+ n vc s vc=$$getSessionValue^%zewdAPI("vc",sessid)
+ n result s result=$$SO(ac,vc)
+ ;
+ ; Change Verify Code Logic Ahead... Damn Complex!
+ i $l(result),result="CVC" d  q ""  ; User must change Verify Code
+ . S DUZ=$$STATE^XWBSEC("XUS DUZ")  ; VISTA kills off DUZ if vc needs changing.
+ .                                  ; That's fine when it can get it back. But we are not a stateful process.
+ .                                  ; By the time the second request is made, XUS DUZ is gone gone gone.
+ . d s(sessid)                      ; Save symbol table for next page (including DUZ)
+ . d setRedirect^%zewdAPI("cvc",sessid) ; Next page is cvc.
+ . d setSessionValue^%zewdAPI("cvcForced",1,sessid) ; Need to know that the user is toast!
+ ;
+ i $l(result) q result  ; General Error Message - User can't log-in
+ ;
+ e  d  q ""  ; Everything Okay
+ . d s(sessid)
+ . i $$isCheckboxOn^%zewdAPI("cvc","cvc",sessid) d setRedirect^%zewdAPI("cvc",sessid)
+ ;
+SO(ac,vc) ; Sign-on to VISTA, AV way
+ ; TODO: Handle the rest of the return values
+ N return
+ D VALIDAV^XUSRB(.return,$$ENCRYP^XUSRB1(ac_";"_vc))
+ i return(0)>0,'return(2) q "" ; Sign on successful!
+ i return(0)=0,return(2) q "CVC"  ; Verify Code must be changed NOW!
+ i $l(return(3)) q return(3)  ; Error Message returned whole
+ ; Note: division selection not implemented here
+ quit ""
+ ; ---
+sss(id) ; Test
+ d setRedirect^%zewdAPI("index",id,"bb")
+ q ""
+whoami(sessid) ; Who Am I? PrePage Script
+ d r(sessid)
+ n Name s Name=$$GET1^DIQ(200,DUZ,.01) ; User Name
+ d setSessionValue^%zewdAPI("Name",Name,sessid)
+ q ""
+cvc(sessid) ; Change Verify Code
+ ; get stored session values for DUZ, IO, and U
+ d r(sessid) ; Restore the Symbol Table
+ n VC1,VC2,VC3
+ s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
+ s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
+ s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
+ ; Uppercase them -- otherwise CVC will fail.
+ s VC1=$$UP^XLFSTR(VC1)
+ s VC2=$$UP^XLFSTR(VC2)
+ s VC3=$$UP^XLFSTR(VC3)
+ ; Roman Cipher them vista-wise
+ n eVC1,eVC2,eVC3
+ s eVC1=$$ENCRYP^XUSRB1(VC1)
+ s eVC2=$$ENCRYP^XUSRB1(VC2)
+ s eVC3=$$ENCRYP^XUSRB1(VC3)
+ ; Set-up Call
+ n vcString s vcString=eVC1_U_eVC2_U_eVC3
+ n ret
+ d CVC^XUSRB(.ret,vcString)
+ ;;test
+ M ^ZZSAM=ret
+ i ret(0)=0 q ""  ; Success
+ i ret(0)>0 q ret(1)  ; Failure
+;;
+;;return(0)=0
+;;return(1)=0
+;;return(2)=1
+;;return(3)="VERIFY CODE must be changed before continued use."
+;;return(4)=0
+;;return(5)=0
+;;return(6)=""
+;;return(7)="Good evening DOCTOR,TEN"
+;;return(8)="     You last signed on today at 22:19"
Index: EWD/ewdapps/tutorial/pages/Page1a.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page1a.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page1a.ewd	(revision 1284)
@@ -0,0 +1,10 @@
+<ewd:config>
+<html>
+<head>
+<title>Test Page</title>
+</head>
+<body bgcolor="#C5E3E4">
+<p>This is a test page</p>
+</body>
+</html>
+
Index: EWD/ewdapps/tutorial/pages/Page1b.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page1b.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page1b.ewd	(revision 1284)
@@ -0,0 +1,10 @@
+<ewd:config>
+<head>
+<title>Test Page</title>
+</head>
+<body bgcolor="#C5E3E4">
+<p>This is a test page</p>
+<a href=Page2b.ewd>Go to page 2</a><br><br>
+<a href=ewdLogout.ewd>Log out</a>
+</body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page1c.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page1c.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page1c.ewd	(revision 1284)
@@ -0,0 +1,12 @@
+<ewd:config isFirstPage="true">
+<html>
+ <head>
+  <title>Test Page</title>
+ </head>
+ <body bgcolor="#C5E3E4">
+  <p>This is a test page</p>
+  <a href=Page2c.ewd>Go to page 2</a><br><br>
+  <a href=Page3c.ewd>Go to page 3</a><br><br>
+  <a href=ewdLogout.ewd>Log out</a>
+ </body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page1d.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page1d.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page1d.ewd	(revision 1284)
@@ -0,0 +1,27 @@
+<ewd:config isFirstPage="true">
+<html>
+ <head>
+  <title>Test Page</title>
+ </head>
+ <body bgcolor="#C5E3E4">
+  <p>This is a test page</p>
+  <h3>Please enter your username and password:</h3>
+  <form method="POST" action=ewd>
+   <table border=0>
+     <tr>
+      <td>Username: </td>
+        <td><input type="text" name="username" focus="true" value="*"></td>
+     </tr>
+     <tr>
+        <td>Password: </td>
+        <td><input type="password" name="password"></td>
+     </tr>
+     <tr>
+        <td><input type="submit" name="Submit" value="Login" action="login^KBANDemo" nextpage="Page2d"></td>
+     </tr>
+   </table>
+  </form>
+  <br><br>
+  <a href=ewdLogout.ewd>Log out</a>
+ </body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page1e.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page1e.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page1e.ewd	(revision 1284)
@@ -0,0 +1,26 @@
+<ewd:config isFirstPage="true" />
+
+<html>
+<head><title>Test Page</title></head>
+<body bgcolor="#C5E3E4">
+<p>This is a test page</p>
+<h3>Please enter your username and password:</h3>
+<form method="post" action="ewd">
+ <table border=0>
+  <tr>
+   <td>Username: </td>
+   <td><input type="text" name="username" focus="true" /></td>
+  </tr>
+  <tr>
+   <td>Password: </td>
+   <td><input type="password" name="password" /></td>
+  </tr>
+  <tr>
+   <td><input type="submit" name="Submit" value="Login" action="login^KBANDemo" nextpage="Page2e" /></td>
+  </tr>
+ </table>
+</form>
+<br /><br />
+<a href="ewdLogout.ewd">Log out</a>
+</body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page2b.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page2b.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page2b.ewd	(revision 1284)
@@ -0,0 +1,11 @@
+<ewd:config>
+<html>
+<head>
+<title>Test Page</title>
+</head>
+<body bgcolor="#C5E3E4">
+<p>This is a second test page</p>
+<a href=Page1b.ewd>Go back to to page 1</a><br><br>
+<a href=ewdLogout.ewd>Log out</a>
+</body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page2c.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page2c.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page2c.ewd	(revision 1284)
@@ -0,0 +1,11 @@
+<ewd:config isFirstPage="false">
+<html>
+ <head>
+  <title>Test Page</title>
+ </head>
+ <body bgcolor="#C5E3E4">
+  <p>This is a second test page</p>
+  <a href=Page1c.ewd>Go back to to page 1</a><br><br>
+  <a href=ewdLogout.ewd>Log out</a>
+ </body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page2d.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page2d.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page2d.ewd	(revision 1284)
@@ -0,0 +1,15 @@
+<ewd:config isFirstPage="false">
+<html>
+ <head>
+  <title>Test Page</title>
+ </head>
+ <body bgcolor="#C5E3E4">
+  <p>This is a second test page</p>
+  <br>Hello <?= #username ?><br>
+  Your password is <?= #password ?><br>
+  Your session ID is <?= #ewd_sessid ?>
+  <br><br>
+  <a href=ewdLogout.ewd>Log out</a>
+  <hr>
+ </body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page2e.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page2e.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page2e.ewd	(revision 1284)
@@ -0,0 +1,21 @@
+<ewd:config isFirstPage="false" prePageScript="getUsernames^KBANDemo">
+<html>
+<head><title>Test Page</title></head>
+<body bgcolor="#C5E3E4">
+<h3>Select a user to edit</h3>
+<form method="post" action="ewd">
+  <table border=1>
+     <tr>
+       <td colspan=2>Select an existing username :</td>
+     </tr>
+     <tr>
+       <td><select name="user"></select>
+       <td><input type="submit" name="Edit" value="Select" nextpage="Page3e"></td>
+     </tr>
+  </table>
+</form>
+<br><br>
+<a href=ewdLogout.ewd>Log out</a>
+</body>
+</html>
+
Index: EWD/ewdapps/tutorial/pages/Page3c.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page3c.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page3c.ewd	(revision 1284)
@@ -0,0 +1,11 @@
+<ewd:config isFirstPage="false">
+<html>
+ <head>
+  <title>Test Page mod</title>
+ </head>
+ <body bgcolor="#C5E3E4">
+  <p>This is a third test page</p>
+  <a href=Page1c.ewd>Go back to to page 1</a><br><br>
+  <a href=ewdLogout.ewd>Log out</a>
+ </body>
+</html>
Index: EWD/ewdapps/tutorial/pages/Page3e.ewd
===================================================================
--- EWD/ewdapps/tutorial/pages/Page3e.ewd	(revision 1284)
+++ EWD/ewdapps/tutorial/pages/Page3e.ewd	(revision 1284)
@@ -0,0 +1,38 @@
+<ewd:config isFirstPage="false" prePageScript="getInfo^KBANDemo">
+<html>
+<head><title>Test Page</title></head>
+<body bgcolor="#C5E3E4">
+<p>Set/Modify Verify Code</p>
+<form method="POST" action="ewd">
+  <table border=1>
+     <tr>
+       <td>Username: </td>
+       <td><?= #Name ?></td>
+     </tr>
+     <tr>
+       <td>Verify Code (existing): </td>
+       <td><input type="text" name="vc1" value="*"></td>
+     </tr>
+     <tr>
+       <td>Verify Code (new): </td>
+       <td><input type="text" name="vc2" value="*"></td>
+     </tr>
+     <tr>
+       <td>Verify Code (confirm): </td>
+       <td><input type="text" name="vc3" value="*"></td>
+     </tr>
+     <tr>
+       <td><input type="submit" name="save" value="Save" action="CVC^KBANDemo" nextpage="Page2e"></td>
+     </tr>
+  </table>
+</form>
+<p>Change other info</p>
+<form method="POST" action="ewd">
+<p>Office Phone: <input type="text" name="officePhone" value="<?= #officePhone ?>" /></p>
+<p><input type="submit" name="save2" value="Save Phones" action="savePhones^KBANDemo" /></p>
+<br><br>
+<a href="Page2e.ewd">Select another username</a><br><br>
+<a href=ewdLogout.ewd>Log out</a>
+</body>
+</html>
+
Index: EWD/ewdapps/tutorial/r/KBANDemo.m
===================================================================
--- EWD/ewdapps/tutorial/r/KBANDemo.m	(revision 1284)
+++ EWD/ewdapps/tutorial/r/KBANDemo.m	(revision 1284)
@@ -0,0 +1,61 @@
+KBANDemo ; Test to demo EWD
+ ;;
+login(sessid)
+ n error s error=""
+ n un,pw
+ s un=$$getTextValue^%zewdAPI("username",sessid)
+ s pw=$$getPasswordValue^%zewdAPI("password",sessid)
+ s %ZIS="0H",IOP="NULL"
+ d ^%ZIS
+ i POP s error="Programming error" d ^%ZTER g EXIT
+ d SETUP^XUSRB() ; Set-up for GUI signon
+ n RETURN
+ D VALIDAV^XUSRB(.RETURN,$$ENCRYP^XUSRB1(un_";"_pw))
+ n DUZ s DUZ=RETURN(0)
+ i DUZ'>0 s error="No a valid login"
+ i error="" d  ; everything is okay; save symtab crap
+ . d mergeArrayToSession^%zewdAPI(.DUZ,"DUZ",sessid)
+ . d mergeArrayToSession^%zewdAPI(.IO,"IO",sessid)
+ . d setSessionValue^%zewdAPI("U","^",sessid)
+ q error
+EXIT D:$G(DUZ) LOGOUT^XUSRB
+ Q error
+getUsernames(sessid)
+ d clearList^%zewdAPI("user",sessid)
+ n sam
+ d LIST^DIC(200,"","@;.01","PKU","*","","","","","","sam")
+ n i s i=0
+ f  s i=$o(sam("DILIST",i)) q:i=""  d
+ . n entry s entry=sam("DILIST",i,0)
+ . d appendToList^%zewdAPI("user",$p(entry,U,2),$p(entry,U),sessid)
+ quit ""
+getInfo(sessid)
+ n DUZ s DUZ=$$getSessionValue^%zewdAPI("user",sessid)
+ n Name s Name=$$GET1^DIQ(200,DUZ,.01)
+ n officePhone s officePhone=$$GET1^DIQ(200,DUZ,"OFFICE PHONE")
+ d setSessionValue^%zewdAPI("Name",Name,sessid)
+ d setSessionValue^%zewdAPI("officePhone",officePhone,sessid)
+ quit ""
+savePhones(sessid)
+ quit ""
+CVC(sessid)
+ ; get stored session values for DUZ, IO, and U
+ d FillSymTab(sessid)
+ n VC1,VC2,VC3
+ s VC1=$$getPasswordValue^%zewdAPI("vc1",sessid)
+ s VC2=$$getPasswordValue^%zewdAPI("vc2",sessid)
+ s VC3=$$getPasswordValue^%zewdAPI("vc3",sessid)
+ n eVC1,eVC2,eVC3
+ s eVC1=$$ENCRYP^XUSRB1(VC1)
+ s eVC2=$$ENCRYP^XUSRB1(VC2)
+ s eVC3=$$ENCRYP^XUSRB1(VC3)
+ n vcString s vcString=eVC1_U_eVC2_U_eVC3
+ n ret
+ d CVC^XUSRB(.ret,vcString)
+ i ret(0)=0 q ""
+ i ret(0)>0 q ret(1)
+FillSymTab(id) ; Fill symbol table
+ d mergeArrayFromSession^%zewdAPI(.DUZ,"DUZ",id)
+ d mergeArrayFromSession^%zewdAPI(.IO,"IO",id)
+ s U=$$getSessionValue^%zewdAPI("U",id)
+ quit
