1 | C0QSET ;GPL - SET OPERATIONS ON LISTS ;818/11 8:50pm
|
---|
2 | ;;1.0;MU PACKAGE;;;Build 13
|
---|
3 | ;
|
---|
4 | ;2011 George Lilly glilly@glilly.net - Licensed under the terms of the GNU
|
---|
5 | ;General Public License See attached copy of the License.
|
---|
6 | ;
|
---|
7 | ;This program is free software; you can redistribute it and/or modify
|
---|
8 | ;it under the terms of the GNU General Public License as published by
|
---|
9 | ;the Free Software Foundation; either version 2 of the License, or
|
---|
10 | ;(at your option) any later version.
|
---|
11 | ;
|
---|
12 | ;This program is distributed in the hope that it will be useful,
|
---|
13 | ;but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | ;GNU General Public License for more details.
|
---|
16 | ;
|
---|
17 | ;You should have received a copy of the GNU General Public License along
|
---|
18 | ;with this program; if not, write to the Free Software Foundation, Inc.,
|
---|
19 | ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
---|
20 | ;
|
---|
21 | Q
|
---|
22 | ;
|
---|
23 | TEST ; TEST OF UNITY ROUTINE
|
---|
24 | ;
|
---|
25 | S A(1)=""
|
---|
26 | S A(2)=""
|
---|
27 | S A(3)=""
|
---|
28 | S B(3)=""
|
---|
29 | S B(4)=""
|
---|
30 | D UNITY("C","A","B")
|
---|
31 | ZWR C
|
---|
32 | Q
|
---|
33 | ;
|
---|
34 | TEST2 ; WHICH PATIENTS HAVE MEDICATIONS? WHICH DON'T?
|
---|
35 | ; WHAT BAD PATIENT POINTERS ARE IN THE MEDICATIONS FILE?
|
---|
36 | S PATS=$NA(^DPT)
|
---|
37 | S MEDS=$NA(^PS(55))
|
---|
38 | D UNITY("DELTA",PATS,MEDS)
|
---|
39 | W !,"PATIENTS WITH NO MEDS",!
|
---|
40 | ZWR DELTA(0,*)
|
---|
41 | W !,"BAD POINTERS IN THE MEDS FILE",!
|
---|
42 | ZWR DELTA(2,*)
|
---|
43 | Q
|
---|
44 | ;
|
---|
45 | UNITY(ZRTN,ZNEW,ZOLD) ; RETURNS THE DELTA BETWEEN THE NEW AND OLD LISTS
|
---|
46 | ; ONLY NUMERIC LISTS SUPPORTED. FOR LIST WITH STRINGS SEE UNITYS
|
---|
47 | ; ZRTN,ZNEW AND ZOLD ARE ALL PASSED BY NAME
|
---|
48 | ; FORMAT OF RETURN ARRAY:
|
---|
49 | ; @ZRTN@(0,X)="" ; X IS MISSING FROM OLD
|
---|
50 | ; @ZRTN@(1,Y)="" ; Y IS IN BOTH NEW AND OLD - NOT MISSING
|
---|
51 | ; @ZRTN@(2,Z)="" ; Z IS EXTRA IN OLD - WOULD BEED TO BE DELETED FOR UNITY
|
---|
52 | N C0QD ; TEMP WORK ARRAY
|
---|
53 | N ZI S ZI=0
|
---|
54 | F S ZI=$O(@ZNEW@(ZI)) Q:+ZI=0 D ; FOR EACH ITEM IN NEW
|
---|
55 | . S C0QD(ZI)=0 ; SET THEM ALL AS 0 MEANING NEW
|
---|
56 | S ZI=0
|
---|
57 | F S ZI=$O(@ZOLD@(ZI)) Q:+ZI=0 D ; FOR EACH ITEM IN OLD
|
---|
58 | . I $D(C0QD(ZI)) S C0QD(ZI)=1 ; NOT NEW - PRESENT IN NEW AND OLD
|
---|
59 | . E S C0QD(ZI)=2 ; EXTRA IN OLD - WOULD NEED TO BE DELETED
|
---|
60 | S ZI=0
|
---|
61 | F S ZI=$O(C0QD(ZI)) Q:+ZI=0 D ; FOR EACH ITEM
|
---|
62 | . S @ZRTN@(C0QD(ZI),ZI)="" ; SET RESULTS IN RETURN ARRAY
|
---|
63 | Q
|
---|
64 | ;
|
---|
65 | UNITYS(ZRTN,ZNEW,ZOLD) ; RETURNS THE DELTA BETWEEN THE NEW AND OLD LISTS
|
---|
66 | ; THIS VERSION HAS SUPPORT FOR NUMBERS AND STRINGS IN A LIST
|
---|
67 | ; ZRTN,ZNEW AND ZOLD ARE ALL PASSED BY NAME
|
---|
68 | ; FORMAT OF RETURN ARRAY:
|
---|
69 | ; @ZRTN@(0,X)="" ; X IS MISSING FROM OLD
|
---|
70 | ; @ZRTN@(1,Y)="" ; Y IS IN BOTH NEW AND OLD - NOT MISSING
|
---|
71 | ; @ZRTN@(2,Z)="" ; Z IS EXTRA IN OLD - WOULD BEED TO BE DELETED FOR UNITY
|
---|
72 | N C0QD ; TEMP WORK ARRAY
|
---|
73 | N ZI S ZI=""
|
---|
74 | F S ZI=$O(@ZNEW@(ZI)) Q:ZI="" D ; FOR EACH ITEM IN NEW
|
---|
75 | . S C0QD(ZI)=0 ; SET THEM ALL AS 0 MEANING NEW
|
---|
76 | S ZI=""
|
---|
77 | F S ZI=$O(@ZOLD@(ZI)) Q:ZI="" D ; FOR EACH ITEM IN OLD
|
---|
78 | . I $D(C0QD(ZI)) S C0QD(ZI)=1 ; NOT NEW - PRESENT IN NEW AND OLD
|
---|
79 | . E S C0QD(ZI)=2 ; EXTRA IN OLD - WOULD NEED TO BE DELETED
|
---|
80 | S ZI=""
|
---|
81 | F S ZI=$O(C0QD(ZI)) Q:ZI="" D ; FOR EACH ITEM
|
---|
82 | . S @ZRTN@(C0QD(ZI),ZI)="" ; SET RESULTS IN RETURN ARRAY
|
---|
83 | Q
|
---|
84 | ;
|
---|
85 | AND(ZRTN,ZNEW,ZOLD) ; RETURNS A LIST OF WHAT IS COMMON TO BOTH NEW AND OLD
|
---|
86 | N ZD
|
---|
87 | D UNITY("ZD",ZNEW,ZOLD)
|
---|
88 | M @ZRTN=ZD(1)
|
---|
89 | Q
|
---|
90 | ;
|
---|
91 | NAND(ZRTN,ZNEW,ZOLD) ; RETURNS WHAT IS IN A OR B BUT NOT BOTH
|
---|
92 | N ZD
|
---|
93 | D UNITY("ZD",ZNEW,ZOLD)
|
---|
94 | M @ZRTN=ZD(0)
|
---|
95 | M @ZRTN=ZD(2)
|
---|
96 | Q
|
---|
97 | ;
|
---|
98 | AMINUSB(ZRTN,ZA,ZB) ; WHAT'S LEFT IN A AFTER REMOVING B FROM IT
|
---|
99 | N ZD
|
---|
100 | D UNITY("ZD",ZA,ZB)
|
---|
101 | M @ZRTN=ZD(0)
|
---|
102 | Q
|
---|
103 | ;
|
---|
104 | OR(ZRTN,ZA,ZB) ; WHAT'S IN A OR B OR BOTH
|
---|
105 | N ZD
|
---|
106 | D UNITY("ZD",ZA,ZB)
|
---|
107 | M @ZRTN=ZD(0)
|
---|
108 | M @ZRTN=ZD(1)
|
---|
109 | M @ZRTN=ZD(2)
|
---|
110 | Q
|
---|
111 | ;
|
---|
112 | END ;end of C0QSET;
|
---|