source: ccr/trunk/p/C0CFM1.m@ 1742

Last change on this file since 1742 was 1586, checked in by Sam Habiel, 12 years ago

Changed license to AGPL. Some clean-up for XINDEX

  • Property svn:mergeinfo set to (toggle deleted branches)
    /ccr/branches/ohum/o-old/p/C0CFM1.m1290
    /ccr/branches/ohum/p/C0CFM1.m1291-1543
    /ccr/branches/ohum/p/p/C0CFM1.m1287-1289
File size: 6.7 KB
RevLine 
[1544]1C0CFM1 ; CCDCCR/GPL - CCR FILEMAN utilities; 12/6/08
[1586]2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
3 ;Copyright 2009 George Lilly.
[1544]4 ;
[1586]5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU Affero General Public License as
7 ; published by the Free Software Foundation, either version 3 of the
8 ; License, or (at your option) any later version.
[1544]9 ;
[1586]10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU Affero General Public License for more details.
[1544]14 ;
[1586]15 ; You should have received a copy of the GNU Affero General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
[1544]17 ;
[1586]18 ;
[1544]19 W "This is the CCR FILEMAN Utility Library ",!
20 W !
21 Q
22 ;
23PUTRIM(DFN,ZWHICH) ;DFN IS PATIENT , WHICH IS ELEMENT TYPE
24 ;
25 S C0CGLB=$NA(^TMP("GPLRIM","VARS",DFN))
26 I '$D(ZWHICH) S ZWHICH="ALL"
27 I ZWHICH'="ALL" D ; SINGLE SECTION REQUESTED
28 . S C0CVARS=$NA(@C0CGLB@(ZWHICH))
29 . D PUTRIM1(DFN,ZWHICH,C0CVARS) ; IF ONE SECTION
30 E D ; MULTIPLE SECTIONS
31 . S C0CVARS=$NA(@C0CGLB)
32 . S C0CI=""
33 . F S C0CI=$O(@C0CVARS@(C0CI)) Q:C0CI="" D ;FOR EACH SECTION
34 . . S C0CVARSN=$NA(@C0CVARS@(C0CI)) ; GRAB ONE SECTION
35 . . D PUTRIM1(DFN,C0CI,C0CVARSN)
36 Q
37 ;
38PUTRIM1(DFN,ZZTYP,ZVARS) ; PUT ONE SECTION OF VARIABLES INTO CCR ELEMENTS
39 ; ZVARS IS PASSED BY NAME AN HAS THE FORM @ZVARS@(1,"VAR1")="VAL1"
40 S C0CX=0
41 F S C0CX=$O(@ZVARS@(C0CX)) Q:C0CX="" D ; FOR EACH OCCURANCE
42 . W "ZOCC=",C0CX,!
43 . S C0CV=$NA(@ZVARS@(C0CX)) ; VARIABLES FOR THIS OCCURANCE
44 . D PUTELS(DFN,ZZTYP,C0CX,C0CV) ; PUT THEM TO THE CCR ELEMENTS FILE
45 Q
46 ;
47PUTELS(DFN,ZTYPE,ZOCC,ZVALS) ; PUT CCR VALUES INTO THE CCR ELEMENTS FILE
48 ; ^C0C(171.201, DFN IS THE PATIENT IEN PASSED BY VALUE
49 ; ZTYPE IS THE NODE TYPE IE RESULTS,PROBLEMS PASSED BY VALUE
50 ; ZOCC IS THE OCCURANCE NUMBER IE PROBLEM NUMBER 1,2,3 ETC
51 ; ZVALS ARE THE VARIABLES AND VALUES PASSED BY NAME AND IN THE FORM
52 ; @ZVALS@("VAR1")="VALUE1" FOR ALL VARIABLES IN THIS ELEMENT
53 ; AND @ZVALS@("M",SUBOCCUR,"VAR2")="VALUE2" FOR SUB VARIABLES
54 ;
55 S ZSRC=1 ; CCR SOURCE IS ASSUMED TO BE THIS EHR, WHICH IS ALWAYS SOURCE 1
56 ; PUT THIS IN PARAMETERS - SO SOURCE NUMBER FOR PROCESSING IN CONFIGURABLE
57 N ZF,ZFV S ZF=171.201 S ZFV=171.2012
58 S ZSUBF=171.20122 ;FILE AND SUBFILE NUMBERS
59 N ZSFV S ZSFV=171.201221 ; SUBFILE VARIABLE FILE NUMBER
60 N ZTYPN S ZTYPN=$O(^C0CDIC(170.101,"B",ZTYPE,""))
61 W "ZTYPE: ",ZTYPE," ",ZTYPN,!
62 N ZVARN ; IEN OF VARIABLE BEING PROCESSED
63 ;N C0CFDA ; FDA FOR CCR ELEMENT UPDATE
64 S C0CFDA(ZF,"?+1,",.01)=DFN
65 S C0CFDA(ZF,"?+1,",.02)=ZSRC
66 S C0CFDA(ZF,"?+1,",.03)=ZTYPN
67 S C0CFDA(ZF,"?+1,",.04)=ZOCC ;CREATE OCCURANCE
68 K ZERR
69 D UPDATE^DIE("","C0CFDA","","ZERR") ;ASSIGN RECORD NUMBER
[1586]70 I $D(ZERR) S $EC=",U1,"
[1544]71 K C0CFDA
72 S ZD0=$O(^C0C(ZF,"C",DFN,ZSRC,ZTYPN,ZOCC,""))
73 W "RECORD NUMBER: ",ZD0,!
74 ;B
75 S ZCNT=0
76 S ZC0CI="" ;
77 F S ZC0CI=$O(@ZVALS@(ZC0CI)) Q:ZC0CI="" D ;
78 . I ZC0CI'="M" D ; NOT A SUBVARIABLE
79 . . S ZCNT=ZCNT+1 ;INCREMENT COUNT
80 . . S ZVARN=$$VARPTR(ZC0CI,ZTYPE) ;GET THE POINTER TO THE VAR IN THE CCR DICT
81 . . ; WILL ALLOW FOR LAYGO IF THE VARIABLE IS NOT FOUND
82 . . S C0CFDA(ZFV,"?+"_ZCNT_","_ZD0_",",.01)=ZVARN
83 . . S C0CFDA(ZFV,"?+"_ZCNT_","_ZD0_",",1)=@ZVALS@(ZC0CI)
84 . . ;S C0CFDA(ZSFV,"+1,"_DFN_","_ZSRC_","_ZTYPN_","_ZOCC_",",.01)=ZVARN
85 . . ;S C0CFDA(ZSFV,"+1,"_DFN_","_ZSRC_","_ZTYPN_","_ZOCC_",",1)=@ZVALS@(ZC0CI)
86 ;S GT1(170,"?+1,",.01)="ZZZ NEW MEDVEHICLETEXT"
87 ;S GT1(170,"?+1,",12)="DIR"
88 ;S GT1(171.201221,"?+1,1,5,1,",.01)="ZZZ NEW MEDVEHICLETEXT"
89 ;S GT1(171.201221,"+1,1,5,1,",1)="THIRD NEW MED DIRECTION TEXT"
90 D CLEAN^DILF
91 D UPDATE^DIE("","C0CFDA","","ZERR")
92 Q
93 ;
94VARPTR(ZVAR,ZTYP) ;EXTRINSIC WHICH RETURNS THE POINTER TO ZVAR IN THE
95 ; CCR DICTIONARY. IT IS LAYGO, AS IT WILL ADD THE VARIABLE TO
96 ; THE CCR DICTIONARY IF IT IS NOT THERE. ZTYP IS REQUIRED FOR LAYGO
97 ;
98 N ZCCRD,ZVARN,C0CFDA2
99 S ZCCRD=170 ; FILE NUMBER FOR CCR DICTIONARY
100 S ZVARN=$O(^C0CDIC(170,"B",ZVAR,"")) ;FIND IEN OF VARIABLE
101 I ZVARN="" D ; VARIABLE NOT IN CCR DICTIONARY - ADD IT
102 . I '$D(ZTYP) D Q ; WON'T ADD A VARIABLE WITHOUT A TYPE
103 . . W "CANNOT ADD VARIABLE WITHOUT A TYPE: ",ZVAR,!
104 . S C0CFDA2(ZCCRD,"?+1,",.01)=ZVAR ; NAME OF NEW VARIABLE
105 . S C0CFDA2(ZCCRD,"?+1,",12)=ZTYP ; TYPE EXTERNAL OF NEW VARIABLE
106 . D CLEAN^DILF ;MAKE SURE ERRORS ARE CLEAN
107 . D UPDATE^DIE("E","C0CFDA2","","ZERR") ;ADD VAR TO CCR DICTIONARY
108 . I $D(ZERR) D ; LAYGO ERROR
109 . . W "ERROR ADDING "_ZC0CI_" TO CCR DICTIONARY",!
110 . E D ;
111 . . D CLEAN^DILF ; CLEAN UP
112 . . S ZVARN=$O(^C0CDIC(170,"B",ZVAR,"")) ;FIND IEN OF VARIABLE
113 . . W "ADDED ",ZVAR," TO CCR DICTIONARY, IEN:",ZVARN,!
114 Q ZVARN
115 ;
116BLDTYPS ; ROUTINE TO POPULATE THE CCR NODE TYPES FILE (^C0CDIC(170.101,)
117 ; THE CCR DICTIONARY (^C0CDIC(170, ) HAS MOST OF WHAT'S NEEDED
118 ;
119 N C0CDIC,C0CNODE ;
120 S C0CDIC=$$FILEREF^C0CRNF(170) ; CLOSED FILE REFERENCE TO THE CCR DICTIONARY
121 S C0CNODE=$$FILEREF^C0CRNF(170.101) ; CLOSED REF TO CCR NODE TYPE FILE
122 Q
123 ;
124FIXSEC ;FIX THE SECTION FIELD OF THE CCR DICTIONARY.. IT HAS BEEN REDEFINED
125 ; AS A POINTER TO CCR NODE TYPE INSTEAD OF BEING A SET
126 ; THE SET VALUES ARE PRESERVED IN ^KBAI("SECTION") TO FACILITATE THIS
127 ; CONVERSION
128 ;N C0CC,C0CI,C0CJ,C0CN,C0CZX
129 D FIELDS^C0CRNF("C0CC",170)
130 S C0CI=""
131 F S C0CI=$O(^KBAI("SECTION",C0CI)) Q:C0CI="" D ; EACH SECTION
132 . S C0CZX=""
133 . F S C0CZX=$O(^KBAI("SECTION",C0CI,C0CZX)) Q:C0CZX="" D ; EACH VARIABLE
134 . . W "SECTION ",C0CI," VAR ",C0CZX
135 . . S C0CV=$O(^C0CDIC(170.101,"B",C0CI,""))
136 . . W " TYPE: ",C0CV,!
137 . . D SETFDA("SECTION",C0CV)
138 . . ;ZWR C0CFDA
139 Q
140 ;
141SETFDA(C0CSN,C0CSV) ; INTERNAL ROUTINE TO MAKE AN FDA ENTRY FOR FIELD C0CSN
142 ; TO SET TO VALUE C0CSV.
143 ; C0CFDA,C0CC,C0CZX ARE ASSUMED FROM THE CALLING ROUTINE
144 ; C0CSN,C0CSV ARE PASSED BY VALUE
145 ;
146 N C0CSI,C0CSJ
147 S C0CSI=$$ZFILE(C0CSN,"C0CC") ; FILE NUMBER
148 S C0CSJ=$$ZFIELD(C0CSN,"C0CC") ; FIELD NUMBER
149 S C0CFDA(C0CSI,C0CZX_",",C0CSJ)=C0CSV
150 Q
151ZFILE(ZFN,ZTAB) ; EXTRINSIC TO RETURN FILE NUMBER FOR FIELD NAME PASSED
152 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 1 OF C0CA(ZFN)
153 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
154 I '$D(ZTAB) S ZTAB="C0CA"
155 N ZR
156 I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",1)
157 E S ZR=""
158 Q ZR
159ZFIELD(ZFN,ZTAB) ;EXTRINSIC TO RETURN FIELD NUMBER FOR FIELD NAME PASSED
160 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 2 OF C0CA(ZFN)
161 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
162 I '$D(ZTAB) S ZTAB="C0CA"
163 N ZR
164 I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",2)
165 E S ZR=""
166 Q ZR
167 ;
168ZVALUE(ZFN,ZTAB) ;EXTRINSIC TO RETURN VALUE FOR FIELD NAME PASSED
169 ; BY VALUE IN ZFN. FILE NUMBER IS PIECE 3 OF C0CA(ZFN)
170 ; IF ZTAB IS NULL, IT DEFAULTS TO C0CA
171 I '$D(ZTAB) S ZTAB="C0CA"
172 N ZR
173 I $D(@ZTAB@(ZFN)) S ZR=$P(@ZTAB@(ZFN),"^",3)
174 E S ZR=""
175 Q ZR
176 ;
Note: See TracBrowser for help on using the repository browser.