source: WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMGECM.m@ 701

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

initial load of WorldVistAEHR

File size: 5.7 KB
Line 
1PXRMGECM ;SLC/JVS GEC-Score Reports-cont'd ;7/14/05 10:43
2 ;;2.0;CLINICAL REMINDERS;**4**;Feb 04, 2005;Build 21
3 Q
4SUM ;By Summary by Patient
5 N CAT,HF,DATE,DFN,Y,HFN,CNTREF,X,REFNUM,SUM,GSUM,CATDANA,PAGE
6 N DATER,SDATE,SCNT
7 D E^PXRMGECV("HS1",1,BDT,EDT,"F",DFNONLY)
8 I FORMAT="D" S FOR=0
9 I FORMAT="F" S FOR=1
10 W @IOF
11 S CATDANA("GEC REFERRAL BASIC ADL")=""
12 S CATDANA("GEC REFERRAL IADL")=""
13 S CATDANA("GEC REFERRAL SKILLED CARE")=""
14 S CATDANA("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")=""
15 ;
16 S Y=1,SUM=0,DATER=0,GSUM=0
17 S DFN="" F S DFN=$O(^TMP("PXRMGEC",$J,"HS1",DFN)) Q:DFN=""!(Y=0) D
18 .S CNTREF="",REFNUM=0 F S CNTREF=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF)) Q:CNTREF=""!(Y=0) D
19 ..S REFNUM=REFNUM+1
20 ..S SDATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,0)) D
21 ...S DATER=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,SDATE,0))
22 ..S DATE=0 F S DATE=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE)) Q:DATE=""!(Y=0) D
23 ...S VDT=0 F S VDT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT)) Q:VDT=""!(Y=0) D
24 ....S CAT=0 F S CAT=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT)) Q:CAT=""!(Y=0) D
25 .....Q:'$D(CATDANA(CAT))
26 .....S SUM=0
27 .....S DATEV=0 F S DATEV=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV)) Q:DATEV=""!(Y=0) D
28 ......S DA=0 F S DA=$O(^TMP("PXRMGEC",$J,"HS1",DFN,CNTREF,DATE,VDT,CAT,DATEV,DA)) Q:DA=""!(Y=0) D
29 .......S HFN=$$HFNAME^PXRMGECR(DA)
30 .......S SUM=SUM+$$VALUE($P($G(^AUPNVHF(DA,0)),"^",1))
31 .......S CATSUM(CAT)=SUM
32 ..S GSUM=+$G(CATSUM("GEC REFERRAL IADL"))+(+$G(CATSUM("GEC REFERRAL BASIC ADL")))+(+$G(CATSUM("GEC REFERRAL SKILLED CARE")))+(+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")))
33 ..S ^TMP("PXRMGEC",$J,"S",DFN,SDATE,DATER,+$G(CATSUM("GEC REFERRAL IADL")),+$G(CATSUM("GEC REFERRAL BASIC ADL")),+$G(CATSUM("GEC REFERRAL SKILLED CARE")),+$G(CATSUM("GEC REFERRAL PATIENT BEHAVIORS/SYMPTOM")),GSUM)=""
34 ..K CATSUM
35 ;
36DIS ;Start of Display
37 S REF="^TMP(""PXRMGEC"",$J,""S"")"
38 W !,"=============================================================================="
39 W !,"GEC Patient-Summary (Score)"
40 W !,"Data on Complete Referrals Only"
41 W !,"From: "_$$FMTE^XLFDT(BDT,"5ZM")_" To: "_$$FMTE^XLFDT(EDT,"5ZM")
42 W !
43 I FOR W !,?33,"Finished",?49,"Basic",?55,"Skilled",?63,"Patient",?73,"TOTAL"
44 I FOR W !,"Name",?22,"SSN",?33,"Date",?44,"IADL",?49,"ADL",?55,"Care",?63,"Behaviors",?73,"ACROSS"
45 I 'FOR W !,"Name^SSN^Referral Date^IADL^Basic ADL^Skilled Care^Behaviors^Totals"
46 W !,"=============================================================================="
47 S PAGE=1
48 N S1,S2,S3,S4,S5,S1T,S2T,S3T,S4T,S5T
49 S (S1T,S2T,S3T,S4T,S5T,CNT)=0
50 S DFN="" F S DFN=$O(@REF@(DFN)) Q:DFN="" D
51 .S SDATE="" F S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE="" D
52 ..S DATER="" F S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER="" D
53 ...S CNT=CNT+1
54 ...S S1="" F S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1="" D
55 ....S S1T=S1T+S1
56 ....S S2="" F S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2="" D
57 .....S S2T=S2T+S2
58 .....S S3="" F S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3="" D
59 ......S S3T=S3T+S3
60 ......S S4="" F S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4="" D
61 .......S S4T=S4T+S4
62 .......S S5="" F S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5="" D
63 ........S S5T=S5T+S5
64 ........I FOR W !,$E($P(DFN," ",1,$L(DFN," ")-1),1,19),?20," ("_$P(DFN," ",$L(DFN," "))_")",?33,$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),?44,$J(S1,3),?49,$J(S2,3),?55,$J(S3,3),?63,$J(S4,3),?73,$J(S5,3) D PAGE^PXRMGECZ
65 ........I 'FOR W !,$P(DFN," ",1,$L(DFN," ")-1),"^",$P(DFN," ",$L(DFN," ")),"^",$P($$FMTE^XLFDT(DATER,"5ZM"),"@",1),"^",S1,"^",S2,"^",S3,"^",S4,"^",S5 D PAGE^PXRMGECZ
66 Q:CNT=0
67 I FOR W !,?44,"_________________________________" D PAGE^PXRMGECZ
68 I FOR W !,?33,"Totals > >",?44,$J(S1T,3),?49,$J(S2T,3),?55,$J(S3T,3),?63,$J(S4T,3),?72,$J(S5T,4) D PAGE^PXRMGECZ
69 I FOR W !,?34,"Means > >",?44,$J($FN(S1T/CNT,"",1),3),?49,$J($FN(S2T/CNT,"",1),3),?55,$J($FN(S3T/CNT,"",1),3),?63,$J($FN(S4T/CNT,"",1),3),?72,$J($FN(S5T/CNT,"",1),4) D PAGE^PXRMGECZ
70 S (S1T,S2T,S3T,S4T,S5T,SCNT)=0
71 N S1TDEV,S1TDEVT,S2TDEV,S2TDEVT,S3TDEV,S3TDEVT,S4TDEV,S4TDEVT,S5TDEV,S5TDEVT
72 S (S1TDEVT,S2TDEVT,S3TDEVT,S4TDEVT,S5TDEVT)=0
73 S DFN="" F S DFN=$O(@REF@(DFN)) Q:DFN="" D
74 .S SDATE="" F S SDATE=$O(@REF@(DFN,SDATE)) Q:SDATE="" D
75 ..S DATER="" F S DATER=$O(@REF@(DFN,SDATE,DATER)) Q:DATER="" D
76 ...S S1="" F S S1=$O(@REF@(DFN,SDATE,DATER,S1)) Q:S1="" D
77 ....S S1TDEV=(S1-(S1T/CNT))*(S1-(S1T/CNT)) S S1TDEVT=S1TDEVT+S1TDEV
78 ....S S2="" F S S2=$O(@REF@(DFN,SDATE,DATER,S1,S2)) Q:S2="" D
79 .....S S2TDEV=(S2-(S2T/CNT))*(S2-(S2T/CNT)) S S2TDEVT=S2TDEVT+S2TDEV
80 .....S S3="" F S S3=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3)) Q:S3="" D
81 ......S S3TDEV=(S3-(S3T/CNT))*(S3-(S3T/CNT)) S S3TDEVT=S3TDEVT+S3TDEV
82 ......S S4="" F S S4=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4)) Q:S4="" D
83 .......S S4TDEV=(S4-(S4T/CNT))*(S4-(S4T/CNT)) S S4TDEVT=S4TDEVT+S4TDEV
84 .......S S5="" F S S5=$O(@REF@(DFN,SDATE,DATER,S1,S2,S3,S4,S5)) Q:S5="" D
85 ........S S5TDEV=(S5-(S5T/CNT))*(S5-(S5T/CNT)) S S5TDEVT=S5TDEVT+S5TDEV
86 I FOR W !,?20,"Standard Deviations > >"
87 I CNT<2 S CNT=CNT+1
88 I FOR W ?44,$J($FN($$SQROOT(S1TDEVT/(CNT-1)),"",1),3),?49,$J($FN($$SQROOT(S2TDEVT/(CNT-1)),"",1),3),?55,$J($FN($$SQROOT(S3TDEVT/(CNT-1)),"",1),3),?63,$J($FN($$SQROOT(S4TDEVT/(CNT-1)),"",1),3)
89 I FOR W ?72,$J($FN($$SQROOT(S5TDEVT/(CNT-1)),"",1),4) D PAGE^PXRMGECZ
90 K ^TMP("PXRMGEC",$J)
91 D KILL^%ZISS
92 Q
93 ;
94SQROOT(NUM) ;Calculat Square Root
95 N PREC,ROOT S ROOT=0 GOTO SQROOTX:NUM=0
96 S:NUM<0 NUM=-NUM S ROOT=$S(NUM>1:NUM\1,1:1/NUM)
97 S ROOT=$E(ROOT,1,$L(ROOT)+1\2) S:NUM'>1 ROOT=1/ROOT
98 F PREC=1:1:6 S ROOT=NUM/ROOT+ROOT*.5
99SQROOTX Q ROOT
100 ;
101VALUE(DA) ;Return value for score
102 N CAT,SYN,VALUE,PICE
103 S SYN=$P($G(^AUTTHF(DA,0)),"^",9)
104 Q:$E(SYN,5,5)'="F" VALUE
105 Q:SYN="" VALUE
106 Q:$E(SYN,5,5)="C" VALUE
107 S VALUE=$P(SYN," ",$L(SYN," "))
108 Q VALUE
109 ;
110 ;
Note: See TracBrowser for help on using the repository browser.