source: WorldVistAEHR/trunk/r/SURGERY-SR/SROPCE0A.m@ 703

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

initial load of WorldVistAEHR

File size: 6.6 KB
Line 
1SROPCE0A ;BIR/ADM - PCE FILING STATUS REPORT, LONG FORM ;03/17/05
2 ;;3.0; Surgery ;**58,62,69,77,50,86,88,127,142**;24 Jun 93
3 ;
4 ; Reference to ^ECC(723 supported by DBIA #205
5 ;
6 S (SRFCPT,SRQCPT,SRFICD,SRQICD,SRUCPT,SRUICD)=0
7 D HDR F S SRSDT=$O(^SRF("AC",SRSDT)) Q:'SRSDT!(SRSDT>SRSEDT)!SRSOUT S SRTN=0 F S SRTN=$O(^SRF("AC",SRSDT,SRTN)) Q:'SRTN I $D(^SRF(SRTN,0)),$$DIV^SROUTL0(SRTN),$P($G(^SRF(SRTN,30)),"^")="" D UTIL Q:SRSOUT
8 D:'SRSOUT TOTAL
9 Q
10TOTAL D:$Y+10>IOSL PAGE Q:SRSOUT W !,?28,"CPT",?36,"ICD",!,?20,"CASES",?27,"CODES",?35,"CODES",!,?13,"FILED: ",$J(CNT(1),5),?27,$J(SRFCPT,5),?35,$J(SRFICD,5)
11 W !,?9,"NOT FILED: "_$J(CNT(4),5) F I=1:1:5 S CNT(6)=CNT(6)+CNT(I)
12 W:CNT(5) !,?9,"UNCERTAIN: "_$J(CNT(5),5) W !,?20,"-----",?27,"-----",?35,"-----",!,?13,"TOTAL: ",$J(CNT(6),5),?27,$J(SRFCPT+SRQCPT+SRUCPT,5),?35,$J(SRFICD+SRQICD+SRUICD,5)
13 Q
14UTIL ; process case
15 S SRDIV=$P($G(^SRF(SRTN,8)),"^") I SRDIV S SRSPS=$O(^SRO(133,"B",SRDIV,0))
16 I 'SRDIV S SRSPS=SRSITE
17 S X=^SRO(133,SRSPS,0),SRPARAM=$P(X,"^",15),SRSR=$P(X,"^",19) I SRPARAM=""!(SRPARAM="N") Q
18 S SRINOUT=$P(^SRF(SRTN,0),"^",12) I SRPARAM="O",SRINOUT'="",SRINOUT'="O" Q
19 S SRNON=0 I $P($G(^SRF(SRTN,"NON")),"^")="Y" S SRNON=1
20 I SRFLG=1!(SRFLG=3&('SRNON)) Q:'$P($G(^SRF(SRTN,.2)),"^",12)
21 I SRFLG=2!(SRFLG=3&SRNON) Q:'$P($G(^SRF(SRTN,"NON")),"^",5)
22 Q:SRFLG=2&('SRNON) Q:SRFLG=1&(SRNON)
23 S SRSS=$S('SRNON:$P(^SRF(SRTN,0),"^",4),1:$P(^SRF(SRTN,"NON"),"^",8)) I SRSPEC,SRSPEC'=SRSS Q
24 S SRSSNM=$S('SRNON:$P(^SRO(137.45,SRSS,0),"^"),1:$P(^ECC(723,SRSS,0),"^"))
25 I SRPARAM="O",SRINOUT="" S SRSTATUS=5,CNT(5)=CNT(5)+1 D CASE,CHK^SROPCE0,MISS Q
26 I $P(^SRF(SRTN,0),"^",15) S SRSTATUS=1,CNT(1)=CNT(1)+1 D CASE,LINE Q
27 S SRSTATUS=4,CNT(4)=CNT(4)+1 D CASE,CHK^SROPCE0,MISS
28 Q
29MISS ; list fields missing data
30 Q:SRSOUT S SRFLD="" S SRFLD=$O(SRX(SRFLD)) I SRFLD="" W !,?15,"No Missing Information" D LINE Q
31 S SRCT=1,SRFLD="" W !,?15,"Missing Information:" F S SRFLD=$O(SRX(SRFLD)) Q:SRFLD="" D:$Y+5>IOSL PAGE Q:SRSOUT W !,$J(SRCT_". ",20),SRX(SRFLD) S SRCT=SRCT+1
32LINE I 'SRSOUT W ! F I=1:1:IOM W "-"
33 Q
34CASE ; print case info
35 D:$Y+9>IOSL PAGE Q:SRSOUT D DEM,SCHED^SROPCE0B
36 W !,SRSDATE,?22,SRSNM,?49,SRPROV,?71,SRSSNM,?113,$S(SRSTATUS=1:"FILED",SRSTATUS=4:"NOT FILED",1:"UNCERTAIN")
37 W !,SRTN,?22,SRSSN_" ("_SRAGE_")",?49,SRATT,?71,SRDIAG(1),?113,$E(SRSCHED,1,17),!
38 W:(SRFLG=3)&SRNON "NON-OR" W ?22,SRPROC(1) W:$D(SRDIAG(2)) ?71,SRDIAG(2) W:$D(SRPROC(2)) !,?22,SRPROC(2) W:$D(SRPROC(3)) !,?22,SRPROC(3) W !
39 I "1,2,3"[SRSTATUS F SRI=1:1 Q:'$D(SRCPT(SRI))&'$D(SRDX(SRI)) D:$Y+4>IOSL PAGE Q:SRSOUT W ! D W:$D(SRDX(SRI)) ?71,"ICD Diagnosis Code: "_SRDX(SRI)
40 .I $D(SRCPT(SRI)) S SRCPT(SRI)=$S($D(SRDX(SRI)):$E(SRCPT(SRI),1,68),1:SRCPT(SRI)) W ?1,SRCPT(SRI)
41 Q
42DEM ; get patient demographic information
43 S SR(0)=^SRF(SRTN,0),DFN=$P(SR(0),"^") D DEM^VADPT S SRSNM=VADM(1),SRSSN=VA("PID"),Y=SRSDT X ^DD("DD") S SRSDATE=Y,X1=$E(SRSDT,1,7),X2=$P(VADM(3),"^"),SRAGE=$E(X1,1,3)-$E(X2,1,3)-($E(X1,4,7)<$E(X2,4,7))
44 I $L(SRSNM)>25 S X=SRSNM,SRSNM=$P(X,",")_","_$E($P(X,",",2))_"."
45PROC ; get principal procedure and other case information
46 K SRPROC S X=$P(^SRF(SRTN,"OP"),"^") I $L(X)<60 S SRPROC(1)=X
47 I $L(X)>59 S K=1 F D I $L(X)<60 S SRPROC(K)=X Q
48 .F I=0:1:58 S J=59-I,Y=$E(X,J) I Y=" " S SRPROC(K)=$E(X,1,J-1),X=$E(X,J+1,$L(X)) S K=K+1 Q
49 K SRDIAG S X=$S(SRNON:$P($G(^SRF(SRTN,33)),"^",2),1:$P($G(^SRF(SRTN,34)),"^")) I $L(X)<40 S SRDIAG(1)=X
50 I $L(X)>39 S K=1 F D I $L(X)<40 S SRDIAG(K)=X Q
51 .F I=0:1:38 S J=39-I,Y=$E(X,J) I Y=" " S SRDIAG(K)=$E(X,1,J-1),X=$E(X,J+1,$L(X)) S K=K+1 Q
52 I SRDIAG(1)="" S SRDIAG(1)="NOT ENTERED"
53 I SRNON S X=$G(^SRF(SRTN,"NON")) S SRPROV=$S($P(X,"^",6):$P(^VA(200,$P(X,"^",6),0),"^"),1:"NOT ENTERED"),SRATT=$S($P(X,"^",7):$P(^VA(200,$P(X,"^",7),0),"^"),1:"NOT ENTERED")
54 I 'SRNON S X=$G(^SRF(SRTN,.1)) S SRPROV=$S($P(X,"^",4):$P(^VA(200,$P(X,"^",4),0),"^"),1:"NOT ENTERED"),SRATT=$S($P(X,"^",13):$P(^VA(200,$P(X,"^",13),0),"^"),1:"NOT ENTERED")
55 I $L(SRPROV)>20 S X=SRPROV,SRPROV=$P(X,",")_","_$E($P(X,",",2))_"."
56 I $L(SRATT)>20 S X=SRATT,SRATT=$P(X,",")_","_$E($P(X,",",2))_"."
57 Q:"1,2,3"'[SRSTATUS
58CPT ; get CPT codes
59 N SRICPT K SRCPT S SRJ=1,X=$P($G(^SRO(136,SRTN,0)),"^",2) I X D
60 .S SRICPT=$$CPT^ICPTCOD(X,$P($G(^SRF(SRTN,0)),"^",9)),SRCPT(1)="CPT Code: "_$P(SRICPT,"^",2)_" "_$P(SRICPT,"^",3),SRJ=SRJ+1
61 .S:SRSTATUS=1 SRFCPT=SRFCPT+1 S:SRSTATUS=2 SRQCPT=SRQCPT+1 S:SRSTATUS=3 SRUCPT=SRUCPT+1
62 .I X,$O(^SRO(136,SRTN,1,0)) D
63 ..N SRI,SRX,SRY,SRZ S SRX=" Modifiers: -"
64 ..S SRI=0 F S SRI=$O(^SRO(136,SRTN,1,SRI)) Q:'SRI D
65 ...S SRZ=$P(^SRO(136,SRTN,1,SRI,0),"^"),SRY=$$MOD^ICPTMOD(SRZ,"I",$P($G(^SRF(SRTN,0)),"^",9)),SRX=SRX_$P(SRY,"^",2)_" "_$P(SRY,"^",3)
66 ...S SRCPT(SRJ)=SRX,SRJ=SRJ+1,SRX=" -"
67 S SROP=0 F S SROP=$O(^SRO(136,SRTN,3,SROP)) Q:'SROP S X=$P($G(^SRO(136,SRTN,3,SROP,0)),"^") I X D
68 .S SRICPT=$$CPT^ICPTCOD(X,$P($G(^SRF(SRTN,0)),"^",9)),SRCPT(SRJ)="CPT Code: "_$P(SRICPT,"^",2)_" "_$P(SRICPT,"^",3),SRJ=SRJ+1
69 .I $O(^SRO(136,SRTN,3,SROP,1,0)) D
70 ..N SRI,SRX,SRY,SRZ S SRX=" Modifiers: -"
71 ..S SRI=0 F S SRI=$O(^SRO(136,SRTN,3,SROP,1,SRI)) Q:'SRI D
72 ...S SRZ=$P(^SRO(136,SRTN,3,SROP,1,SRI,0),"^"),SRY=$$MOD^ICPTMOD(SRZ,"I",$P($G(^SRF(SRTN,0)),"^",9)),SRX=SRX_$P(SRY,"^",2)_" "_$P(SRY,"^",3)
73 ...S SRCPT(SRJ)=SRX,SRJ=SRJ+1,SRX=" -"
74 .S:SRSTATUS=1 SRFCPT=SRFCPT+1 S:SRSTATUS=2 SRQCPT=SRQCPT+1 S:SRSTATUS=3 SRUCPT=SRUCPT+1
75DX ; get diagnosis and ICD codes
76 K SRDX S SRJ=1,X=$P($G(^SRO(136,SRTN,0)),"^",3) I X D
77 .S SRDX(1)=$$ICDDX^ICDCODE(X,$P($G(^SRF(SRTN,0)),"^",9)),SRDX(1)=$P(SRDX(1),"^",2)_" "_$P(SRDX(1),"^",4),SRJ=SRJ+1
78 .S:SRSTATUS=1 SRFICD=SRFICD+1 S:SRSTATUS=2 SRQICD=SRQICD+1 S:SRSTATUS=3 SRUICD=SRUICD+1
79 S SRPODX=0 F S SRPODX=$O(^SRO(136,SRTN,4,SRPODX)) Q:'SRPODX S X=$P(^SRO(136,SRTN,4,SRPODX,0),"^") I X D
80 .S SRDX(SRJ)=$$ICDDX^ICDCODE(X,$P($G(^SRF(SRTN,0)),"^",9)),SRDX(SRJ)=$P(SRDX(SRJ),"^",2)_" "_$P(SRDX(SRJ),"^",4),SRJ=SRJ+1
81 .S:SRSTATUS=1 SRFICD=SRFICD+1 S:SRSTATUS=2 SRQICD=SRQICD+1 S:SRSTATUS=3 SRUICD=SRUICD+1
82 Q
83PAGE I $E(IOST)="P"!SRHDR G HDR
84 W ! K DIR S DIR(0)="E" D ^DIR K DIR I $D(DTOUT)!$D(DUOUT) S SRSOUT=1 Q
85HDR ; print heading
86 I $D(ZTQUEUED) D ^SROSTOP I SRHALT S SRSOUT=1 Q
87 W:$Y @IOF W:$E(IOST)="P" !,?(IOM-$L(SRINST)\2),SRINST W !,?(IOM-$L(SRRPT)\2),SRRPT,?(IOM-10),$J("PAGE "_SRPAGE,9),!,?(IOM-$L(SRTITLE)\2),SRTITLE,!,?(IOM-$L(SRFRTO)\2),SRFRTO W:$E(IOST)="P" !,?(IOM-$L(SRPRINT)\2),SRPRINT
88 W !!,"DATE OF "_$S(SRFLG=1:"OPERATION",SRFLG=2:"PROCEDURE",1:"OP/PROCEDURE"),?22,"PATIENT NAME",?49,$S(SRFLG=1:"SURGEON",SRFLG=2:"PROVIDER",1:"SURGEON/PROVIDER"),?71,"SPECIALTY",?113,"PCE FILING STATUS"
89 W !,"CASE #",?22,"PATIENT ID (AGE)",?49,"ATTENDING",?71,"PRINCIPAL "_$S(SRFLG=1:"POST-OP ",1:"")_"DIAGNOSIS",?113,"SCHED STATUS",!,?22,"PRINCIPAL PROCEDURE"
90 S SRHDR=0,SRPAGE=SRPAGE+1 W ! F I=1:1:IOM W "="
91 Q
Note: See TracBrowser for help on using the repository browser.