Difference between revisions of "ROUTINE C9CGMTSOBJ"

From VistApedia
Jump to: navigation, search
(MSTRECADM^C9CGMTSOBJ)
Line 229: Line 229:
 
159 MSTRECADM(DFN) --
 
159 MSTRECADM(DFN) --
 
             ;
 
             ;
 +
 +
160 +1    ;Output  Most Recent Admission for patient DFN - 1day
 
160 +1    N (DUZ,U,DT,DFN) N VAROOT,INDATA,VAHOW,VAIP
 
160 +1    N (DUZ,U,DT,DFN) N VAROOT,INDATA,VAHOW,VAIP
 
161 +2    SET VAROOT="INDATA",VAHOW=2,VAIP("D")="LAST"
 
161 +2    SET VAROOT="INDATA",VAHOW=2,VAIP("D")="LAST"
 
162 +3    DO IN5^VADPT
 
162 +3    DO IN5^VADPT
163 +4    Q $P(INDATA(13,1),U)
+
163 +4    ; want to start searching one day before recorded Admission Date
164 +5     ;
+
163 +4    S INDATA=$$FMADD^XLFDT($P(INDATA(13,1),U),-1)
 +
163 +4     Q INDATA
 
</pre>
 
</pre>
 +
 
== ARY^C9CGMTSOBJ ==
 
== ARY^C9CGMTSOBJ ==
 
<pre>
 
<pre>

Revision as of 18:09, 7 May 2015

^C9CGMTSOBJ

C9CGMTSOBJ * *  242 LINES,  10209 BYTES,  RSUM: 12810294/57868899 Page 1
        UCI: EHR,EHR    Site: Central Regional HospitalMAY 7,2015@12:44

C9CGMTSOBJ^C9CGMTSOBJ

  1 C9CGMTSOBJ --
            ; SLC/KER - HS Object - Create/Test/Display   ; 01/06/2003
  2 +1     ;;2.7;Health Summary;**58,63,LOCAL**;Oct 20, 1995;Build 1
  3 +2     ;
  4 +3     ; External References
  5 +4     ;   DBIA  2320  $$DEL^%ZISH
  6 +5     ;   DBIA  2320  $$FTG^%ZISH
  7 +6     ;   DBIA  2320  $$PWD^%ZISH
  8 +7     ;   DBIA  2320  CLOSE^%ZISH
  9 +8     ;   DBIA  2320  OPEN^%ZISH
 10 +9     ;   DBIA 10006  ^DIC (file #142.5 and #2)
 11 +10    ;   DBIA 10013  ^DIK
 12 +11    ;   DBIA  2054  $$CREF^DILF
 13 +12    ;   DBIA  2054  $$OREF^DILF
 14 +13    ;   DBIA 10026  ^DIR
 15 +14    ;   DBIA 10103  $$NOW^XLFDT
 16 +15    ;
 17 +16    Q

MGR^C9CGMTSOBJ

 18 MGR    ; Create/Modify Health Summary Object (Manager)
 19 +1     N GMTSMGR S GMTSMGR="" G OBJ
 20 +2     ;

DEVOBJ^C9CGMTSOBJ

 21 DEVOBJ ; Create/Modify Health Summary Object (Developer)
 22 +1     N GMTSDEV S GMTSDEV=5000
 23 +2     ;
 24 OBJ    ; Create/Modify Health Summary Object
 25 +1     ;   Option:  GMTS OBJ ENTER/EDIT
 26 +2     ;            Create/Modify Health Summary Object
 27 +3     N BOLD,DA,DFN,DIC,DIE,DIR,DIROUT,DLAYGO,DR,DTOUT,DUOUT,GMP,GMTS
 28 +4     N GMTSBLK,GMTSCHD,GMTSCON,GMTSDEC,GMTSDEF,GMTSDIF,GMTSDLD,GMTSDT
 29 +5     N GMTSHDR,GMTSI,GMTSL,GMTSLBL,GMTSLEN,GMTSLIM,GMTSNEW,GMTSO,GMTSOBJ
 30 +6     N GMTSOBN,GMTSPER,GMTSPRO,GMTSPX1,GMTSPX2,GMTSQ,GMTSR,GMTSRDT,GMTSR
            HD
 31 +7     N GMTST,GMTSTD,GMTSTIM,GMTSTYP,GMTSUNIT,GMTSUNT,GMTSV,GMTSVER,GMTSX
 32 +8     N IOINHI,IOINORM,NORM,OBJ,D,D0,D1,DI,DILN,X,Y
 33 +9     S DIC("S")="I +Y<50000000!(+Y>59999999)" K:+($G(GMTSDEV))=5000 DIC(
            "S")
 34 +10    D OBJ^GMTSOBA
 35 +11    Q
 36 +12    ;

CRE^C9CGMTSOBJ

 37 CRE(NAME) --
            ; Create/Modify Health Summary Object named 'NAME'
 38 +1     ;
 39 +2     ;   Input    NAME    Name of Object to Create or Edit
 40 +3     ;   Output   Internal Entry Number of Object file if
 41 +4     ;            found or created
 42 +5     ;
 43 +6     N X,BOLD,DA,DFN,DIC,DIE,DIR,DIROUT,DLAYGO,DR,DTOUT,DUOUT,GMP,GMTS
 44 +7     N GMTSBLK,GMTSCHD,GMTSCON,GMTSDEC,GMTSDEF,GMTSDIF,GMTSDLD,GMTSDT
 45 +8     N GMTSHDR,GMTSI,GMTSL,GMTSLBL,GMTSLEN,GMTSLIM,GMTSNAM,GMTSNEW,GMTSO
 46 +9     N GMTSOBJ,GMTSOBN,GMTSPER,GMTSPRO,GMTSPX1,GMTSPX2,GMTSQ,GMTSR,GMTSR
            DT
 47 +10    N GMTSRHD,GMTST,GMTSTD,GMTSTIM,GMTSTYP,GMTSUNIT,GMTSUNT,GMTSV,GMTSV
            ER
 48 +11    N GMTSX,IOINHI,IOINORM,NORM,OBJ,D,D0,D1,DI,DILN,Y S GMTSNAM=$G(NAME
            )
 49 +12    S:'$L(GMTSNAM) GMTSNAM=$$NAME^C9CGMTSOBV("") Q:'$L(GMTSNAM) -1
 50 +13    S DIC("S")="I +Y<50000000!(+Y>59999999)" K:+($G(GMTSDEV))=5000 DIC(
            "S")
 51 +14    D OBJ^GMTSOBA K DIC S DIC="^GMT(142.5,",DIC(0)="XM",X=GMTSNAM
 52 +15    D ^DIC,CRD^C9CGMTSOBV(+Y),^DIC S X=+Y S:X'>0 X=-1
 53 +16    Q X
 54 +17    ;

TYPE^C9CGMTSOBJ

 55 TYPE(NAME) --
            ; Edit Health Summary Type named NAME
 56 +1     ;
 57 +2     ;   Input    NAME    Name of Health Summary Type to Edit
 58 +3     ;   Output   None
 59 +4     D ET^GMTSOBA2($G(NAME))
 60 +5     Q
 61 +6     ;
 62 INQ    ; Inquire to Health Summary Object
 63 +1     ;   Option:  GMTS OBJ INQ
 64 +2     ;            Health Summary Object Inquiry
 65 +3     N DIC,D,D0,D1,DI,DILN,GMTSP,GMTSPL,GMTSL,GMTSEXIT
 66 +4     S U="^",DIC="^GMT(142.5,",DIC(0)="AEMQF",GMTSP=$G(IOST),GMTSPL=0,GM
            TSL=0,GMTSEXIT=0
 67 +5     S DIC("A")=" Select Health Summary Object:  " D ^DIC K DIC("A")
 68 +6     W:$L($G(IOF)) @IOF W:+($G(Y))>0 ! D:+($G(Y))>0 SO^C9CGMTSOBS(+Y),CO
            NT^C9CGMTSOBS
 69 +7     Q
 70 +8     ;

DEVDEL^C9CGMTSOBJ

 71 DEVDEL ; Delete Health Summary Object (Developer)
 72 +1     N GMTSDEV S GMTSDEV=5000
 73 +2     ;

DEL^C9CGMTSOBJ

 74 DEL    ; Delete Health Summary Object
 75 +1     ;   Option:  GMTS OBJ DELETE
 76 +2     ;            Delete Health Summary Object
 77 +3     N D,D0,D1,DI,DILN,DIC,DIR,DIK,DA,X,Y,GMTSP,GMTSPL,GMTSL,GMTSEXIT S
            U="^",(DIK,DIC)="^GMT(142.5,",DIC(0)="AEMQF"
 78 +4     I $$UACT^GMTSU2(+($G(DUZ)))'>0 W !!," >> You are not authorized to
            delete a Health Summary Object." Q
 79 +5     S DIC("A")=" Select Health Summary Object to Delete:  "
 80 +6     S DIC("S")="I (+($P($G(^GMT(142.5,+Y,0)),""^"",17))=0!(+($P($G(^GMT
            (142.5,+Y,0)),""^"",17))=+($G(DUZ))))&(+($P($G(^GMT(142.5,+Y,0)),"
            "^"",20))'>0)"
 81 +7     S:'$D(GMTSDEV) DIC("S")="I +($$DEL^C9CGMTSOBV(+Y))>0"
 82 +8     K:$D(GMTSDEV) DIC("S") I +($G(Y))>50000000,+($G(Y))<59999999,'$D(GM
            TSDEV) W !,"     Can not delete a nationally exported object." Q
 83 +9     D ^DIC I +($G(Y))>0 D
 84 +10    . N GMTSDEL,GMTSO S GMTSDEL="" W ! D SO^C9CGMTSOBS(+Y)
 85 +11    . S DA=+Y,GMTSO=$P($G(^GMT(142.5,+Y,0)),"^",1)
 86 +12    . S:$L(GMTSO) GMTSO=" """_GMTSO_""""
 87 +13    . S DIR("B")="NO",DIR(0)="YAO",DIR("A")=" Delete Health Summary Obj
            ect"_GMTSO_"?  "
 88 +14    . S (DIR("?"),DIR("??"))="     Enter either 'Y' or 'N'."
 89 +15    . W ! D ^DIR I +Y>0 D ^DIK
 90 +16    . I '$D(^GMT(142.5,+DA,0)) W !,"     <deleted>",!
 91 +17    Q
 92 +18    ;

TEST^C9CGMTSOBJ

 93 TEST   ; Test Health Summary Object
 94 +1     ;   Option:  GMTS OBJ TEST
 95 +2     ;            Test a Health Summary Object
 96 +3     N BOLD,D,D0,D1,DI,DILN,DA,DFN,DIC,DIE,DIR,DIROUT,DLAYGO,DR,DTOUT
 97 +4     N DUOUT,GMP,GMTS,GMTSBLK,GMTSCHD,GMTSCON,GMTSDEC,GMTSDEF,GMTSDIF
 98 +5     N GMTSDLD,GMTSDT,GMTSHDR,GMTSI,GMTSL,GMTSLBL,GMTSLEN,GMTSLIM,GMTSNE
            W
 99 +6     N GMTSO,GMTSOBJ,GMTSOBN,GMTSPER,GMTSPRO,GMTSPX1,GMTSPX2,GMTSQ,GMTSR
100 +7     N GMTSRDT,GMTSRHD,GMTST,GMTSTD,GMTSTIM,GMTSTYP,GMTSUNIT,GMTSUNT
101 +8     N GMTSV,GMTSVER,GMTSX,IOINHI,IOINORM,NORM,OBJ,X,Y
102 +9     D PAT^C9CGMTSOBV I +($G(DFN))'>0 W !!,"    No Patient Selected" Q
103 +10    S GMTSL=$G(IOSL) N IOSL S IOSL=99999999
104 +11    S DIC="^GMT(142.5,",DIC("A")=" Select HEALTH SUMMARY OBJECT to test
            :  ",U="^"
105 +12    S DIC(0)="AEMQ" K DLAYGO D ^DIC S GMTSOBJ=+($G(Y))
106 +13    I +GMTSOBJ'>0 W !!,"    No Health Summary Object Selected" Q
107 +14    K ^TMP("GMTSOBJ",$J,DFN) D GET(DFN,GMTSOBJ),DEV^C9CGMTSOBS
108 +15    Q
109 +16    ;

EXP^C9CGMTSOBJ

110 EXP    ; Export a Health Summary Object
111 +1     D EN^C9CGMTSOBE
112 +2     Q
113 +3     ;

INS^C9CGMTSOBJ

114 INS    ; Install Imported Health Summary Object
115 +1     D EN^C9CGMTSOBI
116 +2     Q
117 +3     ;

GET^C9CGMTSOBJ

118 GET(DFN,OBJ) --
            ; Get Health Summary Object
119 +1     ;
120 +2     ;   Input    DFN     IEN for Patient (#2)
121 +3     ;            OBJ     IEN for Health Summary Object (#142.5)
122 +4     ;
123 +5     ;   Output   Global array of Health Summary data
124 +6     ;
125 +7     ;                    ^TMP("GMTSOBJ",$J,DFN,#,0)
126 +8     ;
127 +9     K ^TMP("GMTSOBJ",$J,DFN) D ARY(DFN,OBJ,$NA(^TMP("GMTSOBJ",$J,DFN)))
128 +10    Q
129 +11    ;

TIU^C9CGMTSOBJ

130 TIU(DFN,OBJ,C9CMARK,C9CORDER) --
            ; Get Health Summary Object (TIU)
131 +1     ;
132 +2     ;   Input    DFN     IEN for Patient (#2)
133 +3     ;            OBJ     IEN for Health Summary Object (#142.5)
134 +4     ;            C9CMARK  IEN for CRH MARKER TEXT (#300001)
135 +5     ;            ORDER   == "CHRONOLOGICAL" if objects are ordered
136 +6     ;                    by earliest first- order,
137 +7     ;                    == undefined or "" (empty) if most recent firs
            t
138 +8     ;
139 +9     ;   Output   Global array of Health Summary data
140 +10    ;
141 +11    ;                    ^TMP("TIUHSOBJ",$J,"FGBL",0)
142 +12    ;                    ^TMP("TIUHSOBJ",$J,"FGBL",#,0)
143 +13    ;
144 +14    N ERRMSG,HSTYPE
145 +15    ;;BEGIN CRH DJW 7/2012 - admit Marker Text
146 +16    I $G(C9CMARK)]"" D
147 +17    . I C9CMARK'=+C9CMARK S C9CMARK=$O(^DIZ(300001,"B",C9CMARK,""))
148 +18    . I C9CMARK=+C9CMARK K:$D(^DIZ(300001,C9CMARK,0))[0 C9CMARK Q  ; in
            put is IEN
149 +19    . K C9CMARK Q  ;if not a good IEN, kill off
150 +20    S C9CMADM=$$MSTRECADM(DFN)
151 +21    ;;END CRH
152 +22    S HSTYPE=$P($G(^GMT(142.5,OBJ,0)),U,3)
153 +23    I $G(HSTYPE)="" Q "No Health Summary Report Found"
154 +24    I $D(^GMT(142,HSTYPE,1))'>0 D  Q ERRMSG
155 +25    . S ERRMSG="There are no components in the Health Summary Type:  "_
            $P($G(^GMT(142,HSTYPE,0)),U)
156 +26    K ^TMP("TIUHSOBJ",$J) D ARY(DFN,OBJ,$NA(^TMP("TIUHSOBJ",$J,"FGBL"))
            )
157 +27    Q:+($G(^TMP("TIUHSOBJ",$J,"FGBL",0)))>0 "~@"_$NA(^TMP("TIUHSOBJ",$J
            ,"FGBL"))
158 +28    Q "No Health Summary Report Found"

MSTRECADM^C9CGMTSOBJ

159 MSTRECADM(DFN) --
            ;

160 +1     ;Output   Most Recent Admission for patient DFN - 1day
160 +1     N (DUZ,U,DT,DFN) N VAROOT,INDATA,VAHOW,VAIP
161 +2     SET VAROOT="INDATA",VAHOW=2,VAIP("D")="LAST"
162 +3     DO IN5^VADPT
163 +4     ; want to start searching one day before recorded Admission Date
163 +4     S INDATA=$$FMADD^XLFDT($P(INDATA(13,1),U),-1)
163 +4     Q INDATA

ARY^C9CGMTSOBJ

165 ARY(DFN,OBJ,ROOT) --
            ; Build Array ROOT
166 +1     ;
167 +2     ;   Input    DFN     IEN for Patient (#2)
168 +3     ;            OBJ     IEN for Health Summary Object (#142.5)
169 +4     ;            ROOT    Closed root (global or local array)
170 +5     ;
171 +6     ;   Output   Array of Health Summary data in ROOT
172 +7     ;
173 +8     N GMTSBLK,GMTSFILE,GMTSHFN,GMTSNC,GMTSNCT,GMTSND,GMTSNDT,GMTSNN,GMT
            SIOM
174 +9     N GMTSPATH,GMTSPRE,GMTSRT,GMTSRTO,GMTSRTC,GMTSRNN,GMTSRNC,GMTS0,POP
            ,X,Y
175 +10    Q:$G(^GMT(142.5,+($G(OBJ)),0))=""  S GMTSRT=$G(ROOT)
176 +11    Q:'$L(GMTSRT)  Q:$E(GMTSRT,1)'="^"&($E(GMTSRT,1)'?1U)
177 +12    S GMTSRTO=$$OREF^DILF(GMTSRT),GMTSRTC=$$CREF^DILF(GMTSRT)
178 +13    Q:'$L(GMTSRTO)  Q:'$L(GMTSRTC)  Q:'$L($TR(GMTSRTC,")",""))
179 +14    Q:$E(GMTSRTO,$L(GMTSRTO))'=","&($E(GMTSRTO,$L(GMTSRTO))'="(")
180 +15    Q:GMTSRTO'[$TR(GMTSRTC,")","")  S GMTS0=GMTSRTO_"0)"
181 +16    S GMTSPATH=$$PWD^%ZISH,GMTSFILE=$J_$TR($$NOW^XLFDT,".","")_".DAT"
182 +17    D OPEN^%ZISH("WRITEFILE",GMTSPATH,GMTSFILE,"W"),DIS(+($G(DFN)),+($G
            (OBJ)))
183 +18    D CLOSE^%ZISH("WRITEFILE") K ^TMP("GMTSOBJ",$J,"OGBL")
184 +19    S Y=$$FTG^%ZISH(GMTSPATH,GMTSFILE,$NA(^TMP("GMTSOBJ",$J,"OGBL",1)),
            4)
185 +20    S GMTSHFN(GMTSFILE)="",Y=$$DEL^%ZISH(GMTSPATH,$NA(GMTSHFN))
186 +21    S (GMTSBLK,GMTSNCT,GMTSPRE)=0 S GMTSNN="^TMP(""GMTSOBJ"","_$J_",""O
            GBL"")"
187 +22    S GMTSNC="^TMP(""GMTSOBJ"","_$J_",""OGBL"","
188 +23    F  S GMTSNN=$Q(@GMTSNN) Q:GMTSNN=""!(GMTSNN'[GMTSNC)  D
189 +24    . S GMTSND=@GMTSNN,GMTSNDT=$$TRIM^C9CGMTSOBV(GMTSND)
190 +25    . I 'GMTSBLK S:GMTSNDT="" GMTSBLK=1 Q:GMTSBLK
191 +26    . Q:GMTSPRE&(GMTSNDT="")  S GMTSNCT=GMTSNCT+1
192 +27    . S @(GMTSRTO_GMTSNCT_",0)")=GMTSND
193 +28    . S @GMTS0=$G(@GMTS0)+1
194 +29    . S GMTSPRE=$S(GMTSNDT="":1,1:0)
195 +30    K ^TMP("GMTSOBJ",$J,"OGBL")
196 +31    Q
197 +32    ;

SHOW^C9CGMTSOBJ

198 SHOW(X) ; Show a Health Summary Object Definition
199 +1     ;
200 +2     ;   Input    X       IEN for Health Summary Object (#142.5)
201 +3     ;
202 +4     D SO^C9CGMTSOBS(+($G(X)))
203 +5     Q

EXTRACT^C9CGMTSOBJ

204 EXTRACT(X,ARY) --
            ; Show a Health Summary Object Definition
205 +1     ;
206 +2     ;   Input    X       IEN for Health Summary Object (#142.5)
207 +3     ;   Output   ARY()   Array of fields and values
208 +4     ;                    (passed by reference)
209 +5     ;
210 +6     ;      ARY(IEN,<field #>,"I") = Internal Value
211 +7     ;      ARY(IEN,<field #>,"E") = External Value
212 +8     ;      ARY(IEN,<field #>,"NAME") = Field Name
213 +9     ;      ARY(IEN,<field #>,"PROMT") = Mixed Case of Field Name
214 +10    ;
215 +11    D GET^C9CGMTSOBS2(+($G(X)),.ARY)
216 +12    Q

DEF^C9CGMTSOBJ

217 DEF(X,ARY) --
            ; Extract a Health Summary Object Definition
218 +1     ;
219 +2     ;   Input    X       IEN for Health Summary Object (#142.5)
220 +3     ;   Output   ARY()   Array of fields and values
221 +4     ;                    (passed by reference)
222 +5     ;
223 +6     ;      ARY("D",0) = # of lines in Definition
224 +7     ;      ARY("D",#) = Definition Text
225 +8     ;      ARY("E",0) = # of lines in Example
226 +9     ;      ARY("E",#) = Example Text
227 +10    ;
228 +11    D DEF^C9CGMTSOBS(+($G(X)),.ARY)
229 +12    Q

DIS^C9CGMTSOBJ

230 DIS(DFN,OBJ) --
            ; Display Object
231 +1     ;
232 +2     ;   Input    DFN     IEN for Patient (#2)
233 +3     ;            OBJ     IEN for Health Summary Object (#142.5)
234 +4     ;
235 +5     ;   Output   Display of Health Summary data
236 +6     ;
237 +7     D DIS^C9CGMTSOBS2(+($G(DFN)),$G(OBJ))
238 +8     Q
239 STMP   ; Show TMP
240 +1     N GMTSNN,GMTSNC S GMTSNN="^TMP(""GMTSOBJ"","_$J_",""OGBL"")",GMTSNC
            ="^TMP(""GMTSOBJ"","_$J_",""OGBL"","
241 +2     F  S GMTSNN=$Q(@GMTSNN) Q:GMTSNN=""!(GMTSNN'[GMTSNC)  W !,GMTSNN,"=
            ",@GMTSNN
242 +3     Q