1 | MDPS2 ; HOIFO/NCA - CP/Medicine Report Generator (Cont.) ;5/18/04 09:41
|
---|
2 | ;;1.0;CLINICAL PROCEDURES;**2**;Apr 01, 2004
|
---|
3 | ; Integration Agreements:
|
---|
4 | ; Reference IA #2432 for Hospital Location File #44 FM Lookup
|
---|
5 | ; #1576 for DIVISION file 40.8 lookup
|
---|
6 | ; #2263 for XPAR Utilities
|
---|
7 | ; #4231 for Document CKP^GMTSUP usage.
|
---|
8 | ; #4428 for ORWRP TIME/OCC LIMITS ALL Parameter.
|
---|
9 | ; #10035 for Patient File (#2) Direct Global Reads
|
---|
10 | ; #10060 for New Person file (#200) Read w/FM
|
---|
11 | ; #10061 for ^VADPT call.
|
---|
12 | ; #10103 for XLFDT calls.
|
---|
13 | ;
|
---|
14 | GETDATA(MDGRS,MDDFN,MDPR,MDF,MDR,MDT,MDH) ; Return the text of the Medicine Report
|
---|
15 | ; Input: MDGRS - Return Global Array (Required)
|
---|
16 | ; MDDFN - Patient DFN (Required)
|
---|
17 | ; MDPR - Procedure name in file #697.2 (Required)
|
---|
18 | ; MDF - File number (Required)
|
---|
19 | ; MDR - Record number (Required)
|
---|
20 | ; MDT - The type of report (Full or Caption) (Required)
|
---|
21 | ; MDH - Header is needed or not (Required)
|
---|
22 | ;
|
---|
23 | I '$G(MDDFN)!('$D(MDGRS)) Q
|
---|
24 | N MDCT,MDDAT,MDERR,MDDRDR,MDFLD,MDFLD1,MDFTYP,MDDS0,MDDS1,MDGPRO,MDL1,MDLAB,MDLNE,MDLP,MDMCT,MDMFLD,MDN,MDNOD,MDNXT,MDPNAM,MDSUBF,MDTX,MDTXT,MDVAL,Y
|
---|
25 | S MDN=MDT
|
---|
26 | S MDERR=$$GETDATA^MCORMN1(MDPR,MDR,"^TMP(""MCORMN"",$J)",MDF,$S(MDT'="RD":"RD",1:MDT))
|
---|
27 | I +MDERR=0 S @MDGRS@(1,0)="No Report Text" Q
|
---|
28 | S MDGPRO=$O(^MCAR(697.2,"B",MDPR,0)),(MDDS0,MDDS1)=0,MDPNAM=$P($G(^MCAR(697.2,+MDGPRO,0)),U,8) S:MDPNAM="" MDPNAM=MDPR
|
---|
29 | I MDPR["PFT" S MDLNE=0 D GET^MDPFTP1(.MDGRS,MDF,MDR,MDPNAM,MDLNE,MDH) Q
|
---|
30 | F S MDDS1=+$O(^MCAR(690.2,"D",MDGPRO,MDDS1)) Q:'MDDS1!(MDDS0) D
|
---|
31 | .Q:'$D(^MCAR(690.2,MDDS1,0))
|
---|
32 | .S:$P(^MCAR(690.2,MDDS1,0),U,3)="F" MDDS0=MDDS1
|
---|
33 | I 'MDDS0 S @MDGRS@(1,0)="No Report Text" Q
|
---|
34 | S MDFLD="",(MDDRDR,MDLNE)=0,MDNOD=$NA(^TMP("MCORMN",$J)) D HEAD
|
---|
35 | ; Get the Single in the Medicine View File (#690.2)
|
---|
36 | F S MDFLD=$O(^MCAR(690.2,MDDS0,1,MDFLD)) Q:MDFLD="" S MDDRDR=+$G(^(MDFLD,0)) D
|
---|
37 | .Q:'MDDRDR
|
---|
38 | .S MDDAT=$G(@MDNOD@("F",MDF,MDDRDR,0)),MDLAB=$P(MDDAT,U),MDFTYP=$P(MDDAT,U,2)
|
---|
39 | .S:MDLAB'="" MDLAB=MDLAB_": "
|
---|
40 | .I +MDFTYP I $E($P(MDFTYP,+MDFTYP,2),1)?1U D SUBF Q
|
---|
41 | .I +MDFTYP&($P($G(@MDNOD@("F",+MDFTYP,.01,0)),U,2)["W") D Q
|
---|
42 | ..I MDT="CD" S MDNXT=$O(@MDNOD@("E",MDF,MDR,MDDRDR,0)) Q:'+MDNXT Q:$G(@MDNOD@("E",MDF,MDR,MDDRDR,+MDNXT))=""
|
---|
43 | ..D SETNODE(MDGRS," "),SETNODE(MDGRS,MDLAB)
|
---|
44 | ..S MDLP=0 F S MDLP=$O(@MDNOD@("E",MDF,MDR,MDDRDR,MDLP)) Q:MDLP<1 S MDVAL=" "_$G(^(MDLP)) D SETNODE(MDGRS,MDVAL)
|
---|
45 | ..D SETNODE(MDGRS," ")
|
---|
46 | ..Q
|
---|
47 | .I MDFTYP'["W"&(MDFTYP'["M") D Q
|
---|
48 | ..S MDTXT=$G(@MDNOD@("E",MDF,MDR,MDDRDR,1))
|
---|
49 | ..Q:MDT="CD"&(MDTXT="")
|
---|
50 | ..I MDFTYP["D" S MDTX=$$FMTE^XLFDT(MDTXT,2),MDTXT=MDTX
|
---|
51 | ..S MDVAL=MDLAB_$S(MDLAB'="":" "_MDTXT,1:"") D SETNODE(MDGRS,MDVAL)
|
---|
52 | ..Q
|
---|
53 | .Q
|
---|
54 | I +$P($G(^MCAR(MDF,MDR,2005,0)),U,4)>0 D
|
---|
55 | .D SETNODE(MDGRS," ")
|
---|
56 | .D SETNODE(MDGRS,"NOTE: Images are associated with this procedure.")
|
---|
57 | .D SETNODE(MDGRS," Please use Imaging Display to view the images.")
|
---|
58 | .Q
|
---|
59 | K ^TMP("MCORMN",$J)
|
---|
60 | D FOOTER
|
---|
61 | Q
|
---|
62 | SETNODE(NODE,VALUE) ;Set the node with the string
|
---|
63 | S MDLNE=MDLNE+1,@NODE@(MDLNE,0)=VALUE
|
---|
64 | Q
|
---|
65 | SUBF ; Get the Sub-file fields in the Medicine View File (#690.2)
|
---|
66 | S MDMFLD=$O(^MCAR(690.2,MDDS0,2,"B",+MDFTYP,0)) Q:'MDMFLD
|
---|
67 | S MDCT=0,MDMCT=0 F S MDCT=$O(@MDNOD@("E",+MDFTYP,MDCT)) Q:MDCT<1 S MDFLD1=0 F S MDFLD1=$O(@MDNOD@("E",+MDFTYP,MDCT,MDFLD1)) Q:MDFLD1="" D
|
---|
68 | .S:MDFLD1=".01" MDMCT=MDMCT+1
|
---|
69 | .Q:'+$O(^MCAR(690.2,MDDS0,2,MDMFLD,1,"B",MDFLD1,0))
|
---|
70 | .S MDDAT=$G(@MDNOD@("F",+MDFTYP,MDFLD1,0)),MDLAB=$P(MDDAT,U)
|
---|
71 | .S:MDLAB'="" MDLAB=MDLAB_": "
|
---|
72 | .I MDT="CD" Q:$G(@MDNOD@("E",+MDFTYP,MDCT,MDFLD1,1))=""
|
---|
73 | .I $P(MDDAT,U,2)["M" D Q
|
---|
74 | ..I MDMCT<2 D SETNODE(MDGRS," "),SETNODE(MDGRS,MDLAB)
|
---|
75 | ..S MDVAL=" "_$G(@MDNOD@("E",+MDFTYP,MDCT,MDFLD1,1)) D SETNODE(MDGRS,MDVAL) Q
|
---|
76 | .I $P(MDDAT,U,2)["D" S MDVAL=$G(@MDNOD@("E",+MDFTYP,MDCT,MDFLD1,1)),MDTX=$$FMTE^XLFDT(MDVAL,2),MDVAL=MDTX D SETNODE(MDGRS,MDLAB_MDVAL) Q
|
---|
77 | .S MDVAL=" "_MDLAB_$G(@MDNOD@("E",+MDFTYP,MDCT,MDFLD1,1)) D SETNODE(MDGRS,MDVAL) Q
|
---|
78 | .Q
|
---|
79 | Q
|
---|
80 | FOOTER ; Display Medicine Footer
|
---|
81 | Q:+$G(MDH)
|
---|
82 | N CODE,ERROR,PART,PDUZ,RDATE,SCD,SCRAMBLE,SDUZ,TDATE,TEMP,TRUE,TP,DIC,DR,DA,DIQ
|
---|
83 | N ENAME,EES,EDATE,NAME,NUM,VNAME,VES,VDATE,CODE,RELDATE,VERDATE,NA,MFD,MFDNAME,SUPD,CREATION,SUPNUM,SUPNUM,SUP1,SUP2,ROV,VERSION
|
---|
84 | N FT,FTYPE,FNAME,PERSON,DTEMP,TT,X,X1,X2
|
---|
85 | I '$D(^MCAR(MDF,+MDR,"ES")) Q
|
---|
86 | S TEMP=$G(^MCAR(MDF,MDR,"ES"))
|
---|
87 | ; Retrieve RC/ES Field (NA = Dont need)
|
---|
88 | S NAME="ENAME^NA^EDATE^VNAME^VES^VDATE^CODE^RDATE^VDATE^SUP1^SUP2^MFD^MFDNAME^SUPD^CREATION^SUPNUM",FTYPE="P^X^D^P^F^D^F^D^D^F^F^F^P^D^D^F"
|
---|
89 | F TT=1:1:16 S Y=$P(TEMP,U,TT),FT=$P(FTYPE,U,TT),FNAME=$P(NAME,U,TT) D DATE:FT="D",NAME:FT="P",FREE:FT="F"
|
---|
90 | S SCD=$S(MFD:EDATE,CODE["RV":VDATE,CODE["ROV":VDATE,CODE="RNV":RDATE,CODE="S":EDATE,1:EDATE)
|
---|
91 | S PERSON=$$DECODE(TEMP,CODE,MDF,MDR)
|
---|
92 | S ROV=$S(CODE["ROV":"Signing for "_VNAME,1:""),SUPNUM=+SUPNUM,TSUP2=SUP2,SUPNUM=SUPNUM+1
|
---|
93 | S:'SUP2 NUM=SUPNUM
|
---|
94 | D:SUP2 VERSION
|
---|
95 | S VERSION=SUPNUM_" of "_NUM,SS=""
|
---|
96 | S $P(SS," -",40)="" D SETNODE(MDGRS,SS)
|
---|
97 | S SS=$J(" ",18)_"R e p o r t R e l e a s e S t a t u s" D SETNODE(MDGRS,SS)
|
---|
98 | D SETNODE(MDGRS," ")
|
---|
99 | S SS="Current "_$J(" ",11)_"Date "_$J(" ",2)_"Person Who" D SETNODE(MDGRS,SS)
|
---|
100 | S SS="Report "_$J(" ",11)_$S(CODE["D":"Last ",1:"Status ")_" Last "_$S(CODE["D":"Edited",1:"Changed")
|
---|
101 | S SS=SS_$J(" ",13)_"Date of"_$J(" ",12)_"Report" D SETNODE(MDGRS,SS) S SS=""
|
---|
102 | S SS="Status "_$J(" ",11)_$S(CODE["D":"Edited",1:"Changed")_$J(" ",2)_$S(CODE["D":" Procedure",1:"The Status")_$J(" ",15)_" Entry "_$J(" ",12)_"Version" D SETNODE(MDGRS,SS) S SS=""
|
---|
103 | S $P(SS,"=",80)="" D SETNODE(MDGRS,SS)
|
---|
104 | I $G(MCSTAT)'="" D SETNODE(MDGRS,MCSTAT)
|
---|
105 | S SS=$J(" ",19)_SCD_$J(" ",2)_PERSON
|
---|
106 | S SS=SS_$J(" ",(52-$L(SS)))
|
---|
107 | S SS=SS_CREATION_$J(" ",(64-$L(SS)))_VERSION
|
---|
108 | D SETNODE(MDGRS,SS) K SS
|
---|
109 | D SETNODE(MDGRS,$J(" ",28)_ROV)
|
---|
110 | K MCFILE1
|
---|
111 | Q
|
---|
112 | NAME S Y=$$GET1^DIQ(200,+Y_",",.01,"E"),@FNAME=$P(Y,",",2)_" "_$P(Y,",",1) Q
|
---|
113 | DATE S @FNAME=+$E(Y,4,5)_"/"_+$E(Y,6,7)_"/"_$E((1700+$E(Y,1,3)),3,4) Q
|
---|
114 | FREE S @FNAME=Y Q
|
---|
115 | DECODE(TEMP,CODE,FILE,REC) ;Decode the Validation code 1
|
---|
116 | N CR,PDUZ,STR,PRE
|
---|
117 | S PRE=+$P(TEMP,U,1) S:PRE=0 PRE=DUZ
|
---|
118 | Q:(CODE="")!(CODE="D")!(CODE="PD")!(CODE="MFD")!(CODE="S") $$GET1^DIQ(200,PRE_",",.01) ;HUN-1095-22932
|
---|
119 | S CR=$P(TEMP,U,$S(CODE["RV":5,1:2))
|
---|
120 | S PDUZ=$P(TEMP,U,$S(CODE["RV":4,1:1))
|
---|
121 | S STR=$$SUM^MCESPRT($G(^MCAR(MDF,REC,0)))
|
---|
122 | Q $$DECODER^MCESPRT(CR,PDUZ,REC)
|
---|
123 | ;
|
---|
124 | VERSION ; Find the version number of a procedure
|
---|
125 | F NUM=SUPNUM:1 D CHECK Q:TSUP2=0
|
---|
126 | S NUM=NUM+1
|
---|
127 | Q
|
---|
128 | CHECK ; Find the number of times the report was superseded
|
---|
129 | S DTEMP=$G(^MCAR(MDF,TSUP2,"ES"))
|
---|
130 | S TSUP2=+$P(DTEMP,U,11)
|
---|
131 | Q
|
---|
132 | HEDSPAS(MDTX,MDSP1) ; surround text string X with space to length X1
|
---|
133 | N I,Y1
|
---|
134 | S (TY,Y1)="",$P(Y1," ",MDSP1-$L(MDTX)\2-1)=" ",TY=Y1_" "_MDTX_" "
|
---|
135 | F I=$L(TY):1:MDSP1 S TY=TY_" "
|
---|
136 | Q TY
|
---|
137 | SET ; Set GMTS variable
|
---|
138 | N MDLIM1 S MDLIM=GMTSNDM
|
---|
139 | D:+$G(MDLIM)<1 LIMIT(.MDLIM)
|
---|
140 | S MDTS2=(9999999-GMTS1),MDTS1=(9999999-GMTS2)
|
---|
141 | Q
|
---|
142 | LIMIT(MDLIM) ; Get all Report maximum occurrence limit
|
---|
143 | N LIM
|
---|
144 | S LIM=$$GET^XPAR("USR.`"_DUZ_"^DIV^SYS^PKG","ORWRP TIME/OCC LIMITS ALL",1,"I")
|
---|
145 | S MDLIM=$S(+$P(LIM,";",3):+$P(LIM,";",3),1:999)
|
---|
146 | Q
|
---|
147 | HEAD ; Display Header
|
---|
148 | N MDPG S MDPG=0
|
---|
149 | H1 ; Display Header with Page increment
|
---|
150 | Q:+$G(MDH)
|
---|
151 | N CODE,MDDOB,MDRB,MDTIME,MDWARD,MDTM,X
|
---|
152 | S MDPG=MDPG+1 D NOW^%DTC S X=% D DTIME^MCARP S MDTIME=$$FMTE^XLFDT(X,2)
|
---|
153 | S MCSTAT="",MDTM=$G(^MCAR(MDF,+MDR,"ES")),CODE=$P(MDTM,U,7),MFD=$P(MDTM,U,12) I CODE'="" S MCSTAT=$S(MFD:" Mark for Deletion",1:"X") S:MCSTAT="X" MCSTAT=$$STATUS^MCESEDT(MDF,CODE)
|
---|
154 | D DEM^VADPT
|
---|
155 | S SS="Pg. "_MDPG_$J(" ",25)_$$HOSP(DFN)
|
---|
156 | S SS=SS_$J(" ",(74-$L(SS_MDTIME)))_MDTIME D SETNODE(MDGRS,SS)
|
---|
157 | S SS=$$HEDSPAS(MDPNAM_" REPORT"_$S(MCSTAT="":"",1:" - "_MCSTAT),77) D SETNODE(MDGRS,SS) S SS=""
|
---|
158 | S SS=$$DEMO(DFN) D SETNODE(MDGRS,SS)
|
---|
159 | N FFF S $P(FFF,"- ",40)="- " D SETNODE(MDGRS,FFF)
|
---|
160 | Q
|
---|
161 | HOSP(DFN) ; Hospital for Header
|
---|
162 | N HOSP
|
---|
163 | S HOSP=$P($G(^DPT(DFN,.1)),U)
|
---|
164 | S:HOSP'="" HOSP=$$FIND1^DIC(44,,"X",HOSP)
|
---|
165 | S:HOSP'<1 HOSP=$$GET1^DIQ(44,HOSP,3.5,"I")
|
---|
166 | S:HOSP'="" HOSP=$P($G(^DG(40.8,HOSP,0)),U)
|
---|
167 | Q HOSP
|
---|
168 | DEMO(DFN) ; Demographics for Header
|
---|
169 | N SS1,MDDOB,MDWARD,SS1
|
---|
170 | D DEM^VADPT
|
---|
171 | S SS1=$G(VADM(1))_" "_$P($G(VADM(2)),U,2)_" "
|
---|
172 | S MDDOB=" DOB: "_$P($G(VADM(3)),U,2)_" ("_$G(VADM(4))_")"
|
---|
173 | S SS1=SS1_$J(" ",(39-$L(MDDOB)))_MDDOB
|
---|
174 | D KVAR^VADPT
|
---|
175 | D INP^VADPT S MDWARD=$S(VAIN(4)'="":$P(VAIN(4),U,2),1:"NOT INPATIENT"),MDRB=VAIN(5) D KVAR^VADPT
|
---|
176 | Q SS1_$J(" ",(72-$L(SS1)))_MDWARD_" "_MDRB
|
---|
177 | HDR ; Page Header
|
---|
178 | D CKP^GMTSUP Q:$D(GMTSQIT) W " CONSULT DATE/TIME",!
|
---|
179 | D CKP^GMTSUP Q:$D(GMTSQIT)
|
---|
180 | W " NUMBER COMPLETED PROCEDURES PERFORMED PROCEDURE CODE",!
|
---|
181 | D CKP^GMTSUP Q:$D(GMTSQIT)
|
---|
182 | W " ------- ------------------------------ ---------------- -----------------",!
|
---|
183 | Q
|
---|
184 | HSHDR ; Health Summary One Line Procedure Header
|
---|
185 | N MDLINE
|
---|
186 | S $P(MDLINE,"-",80)=""
|
---|
187 | D CKP^GMTSUP Q:$D(GMTSQIT) W !,MDLINE
|
---|
188 | D CKP^GMTSUP Q:$D(GMTSQIT) W !,$S(+$P(MDX1,U,13):$J($P(MDX1,U,13),9),1:""),?12,$E($P(MDX1,U,1),1,30),?44,$P(MDX1,U,6),?64,$P(MDX1,U,7)
|
---|
189 | D CKP^GMTSUP Q:$D(GMTSQIT) W !,MDLINE
|
---|
190 | D CKP^GMTSUP Q:$D(GMTSQIT) W !
|
---|
191 | Q
|
---|