source: FOIAVistA/trunk/r/SPINAL_CORD_DYSFUNCTION-SPN/SPNCMR2.m@ 711

Last change on this file since 711 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 2.1 KB
Line 
1SPNCMR2 ;HIRMFO/WAA-This routine will find all valid patient ; 9/3/93
2 ;;2.0;Spinal Cord Dysfunction;**7**;01/02/1997
3EN1 ;Loop thru the ^SC file to find all Scheduled appointments
4 Q:SPNSEL'["2"
5 S SPNX=0 D LP1,UNSCH(SPNST,SPNED,"D CB^SPNCMR2(Y,Y0,.SDSTOP)")
6 G EXIT
7LP1 S SPNX=$O(^TMP($J,"SPNWC",SPNX)) Q:SPNX<1
8 I $G(^TMP($J,"SPNWC",SPNX))'="W" D
9 .;this code finds all patients who are scheduled
10 .F SPNDATE=SPNST:0 S SPNDATE=$O(^SC(SPNX,"S",SPNDATE)) Q:SPNDATE<1!(SPNDATE>SPNED) D
11 ..S SPNIEN=0 F S SPNIEN=$O(^SC(SPNX,"S",SPNDATE,1,SPNIEN)) Q:SPNIEN<1 D
12 ...Q:'$D(^SC(SPNX,"S",SPNDATE,1,SPNIEN,0)) S SPNDFN=$P(^(0),U)
13 ...I "I"[$P($G(^DPT(SPNDFN,"S",SPNDATE,0)),U,2) D SETPT^SPNCMR3
14 ...Q
15 ..Q
16 .Q
17 G LP1
18UNSCH(SPNST,SPNED,SPNCB) ; -- find all patients who are Unscheduled
19 ; input: SPNST := start date
20 ; SPNED := end date
21 ; SPNCB := callback code executed for each encounter in
22 ; query's result set
23 ;
24 N SPNQRY
25 ;
26 ; -- set up scan
27 D OPEN^SDQ(.SPNQRY) ; -- initialize query
28 D INDEX^SDQ(.SPNQRY,"DATE/TIME","SET") ; -- which index to use
29 D DATE^SDQ(.SPNQRY,SPNST,SPNED,"SET") ; -- date range
30 D SCANCB^SDQ(.SPNQRY,SPNCB,"SET") ; -- callback code to use
31 D ACTIVE^SDQ(.SPNQRY,"TRUE","SET") ; -- activate query
32 ;
33 D SCAN^SDQ(.SPNQRY,"FORWARD") ; -- scan entries in query
34 ; result set
35 D CLOSE^SDQ(.SPNQRY) ; -- close query
36 Q
37 ;
38EXIT K SPNCS,SPNCS(0),SPNNUM,SPNX,SPNDFN,SPNDATE
39 Q
40 ;
41CB(SPNOE,SPNOE0,SPNSTOP) ; -- callback code called for each
42 ; record in query result set
43 ;
44 ; input: SPNOE := ien of Outpatient Encounter
45 ; SPNOE0 := zeroth node of Outpatient Encounter
46 ; SPNSTOP := tells query to stop processing by setting to 1
47 ;
48 N SPNX,SPNDFN,SPNDATE
49 IF $P(SPNOE0,U,6) G CBQ ; -- quit if encounter has parent
50 IF $P(SPNOE0,U,8)'=2 G CBQ ; -- quit if not standalone encounter
51 ;
52 S SPNDATE=+SPNOE0 ; -- encounter date
53 S SPNDFN=+$P(SPNOE0,U,2) ; -- patient
54 S SPNX=+$P(SPNOE0,U,4) ; -- clinic
55 IF SPNX D SETPT^SPNCMR3
56CBQ Q
57 ;
Note: See TracBrowser for help on using the repository browser.