source: WorldVistAEHR/trunk/r/REGISTRATION-DGQE-DG-DPT-GRPX-VAD-VAF-VAS-VAT-VAU--VA-VIC--DGBT--DGJ--DGYA--VALM/DGPTUTL.m@ 724

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

initial load of WorldVistAEHR

File size: 5.2 KB
RevLine 
[613]1DGPTUTL ;ALB/AS - PTF UTILITY ROUTINE ; 8/14/03 11:35am
2 ;;5.3;Registration;**26,114,234,466,544**;Aug 13, 1993
3D I $L(Y)'<7 S %=$E(Y,4,5)*3,Y=$E("JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC",%-2,%)_" "_$S($E(Y,6,7):$J(+$E(Y,6,7),2)_",",1:"")_($E(Y,1,3)+1700)_$S(Y[".":" "_$E(Y_0,9,10)_":"_$E(Y_"000",11,12),1:"") Q
4 S Y="" Q
5PM ;sets variables from ^DGPM global
6 S DGPMCA=$O(^DGPM("APTF",PTF,0)),DGPMAN=$S($D(^DGPM(+DGPMCA,0)):^(0),1:"") Q
7MT ;Determine and store Means Test Indicator
8 ;S DGZEC=$S($D(^DPT(DFN,.36)):$P(^(.36),U,1),1:""),DGZEC=$S($D(^DIC(8,+DGZEC,0)):^(0),1:"") I $P(DGZEC,U,5)="N" S DGX="N" G DIE
9 ;-- get eligibility code
10 S DGZEC=$P($G(^DGPT(PTF,101)),U,8),DGZEC=$S($D(^DIC(8,+DGZEC,0)):^(0),1:"") I $P(DGZEC,U,5)="N" S DGX="N" G DIE
11 ;-- admit prior to 7/1/86 is an X
12 I DGADM<2860701 S DGX="X" G DIE
13 ;--
14 I $D(^DGPT(PTF,101)),$D(^DIC(45.1,+^(101),0)),$P(^(0),"^",4) S DGX="X" G DIE
15 I $P(^DG(43,1,0),U,21),DGADM]"",$D(^DIC(42,+$P(DGPMAN,U,6),0)),$P(^(0),U,3)="D" S DGX="X" G DIE
16 S DGT=$P($G(^DGPT(PTF,70)),"."),DGZ1=$$LST^DGMTU(DFN,DGT) G AS:'DGZ1
17 ;-- sc < 50 %, %O non comp, movements are sc
18 I $P(DGZEC,U,4)=3,$$SC^DGMTR(DFN),$$ANYSC^DGPTSCAN(PTF) S DGX="AS" G DIE
19 ;-- sc <50 %, %0 non-comp, no movement sc, mt =a
20 I $P(DGZEC,U,4)=3,$$SC^DGMTR(DFN),'$$ANYSC^DGPTSCAN(PTF),$P(DGZ1,U,4)="A" S DGX="AN" G DIE
21 ;-- sc, >0% - DG*5.3*544
22 I "^1^3^"[("^"_$P(DGZEC,U,4)_"^"),$P($G(^DPT(DFN,.3)),U,2)>0,$P(DGZ1,U,4)="A" S DGX="AS" G DIE
23 ;
24 S DGX=$S('$D(DGZ1):"U",1:$P(DGZ1,U,4))
25 ; Determine if the Pending Adjudication is for MT(C) GMT(G)
26 I DGX="P" D G DIE
27 . I '+$P($G(DGZ1),U) S DGX="U" Q
28 . S DGX=$$PA^DGMTUTL($P(DGZ1,U)),DGX=$S('$D(DGX):"U",DGX="MT":"C",DGX="GMT":"G",1:"U")
29 S DGX=$S(DGX="A":"AN","BCGN"[DGX:DGX,1:"U") G DIE:DGX'="N"
30 ;-- AO or IR
31AS S DGZ=$S($D(^DPT(DFN,.321)):^(.321),1:0) I $P(DGZ,U,2)="Y"!($P(DGZ,U,3)="Y") S DGX="AS" G DIE
32 ;-- EC
33 S DGZ=$S($D(^DPT(DFN,.322)):^(.322),1:0) I $P(DGZ,U,13)="Y" S DGX="AS" G DIE
34 ;-- NTR
35 N DGNTARR S DGZ=$S($$GETCUR^DGNTAPI(DFN,"DGNTARR")>0:DGNTARR("NTR"),1:"") I $P(DGZ,U)="Y" S DGX="AS" G DIE
36 ;-- MST
37 S DGZ=$$GETSTAT^DGMSTAPI(DFN) I $P(DGZ,U,2)="Y" S DGX="AS" G DIE
38 ;-- if veteran and AA or Housebound
39 I $P(DGZEC,U,5)="Y",$P(DGZEC,U,4)<4,"^2^15^"'[(U_$P(DGZEC,U,9)_U) S DGX="AS" G DIE
40 ;
41 I DGZEC]"" S DGX="AN" G DIE
42 ;
43 S DGX="U" I '$D(DGLN) W !,"===> this patient has a blank Eligibility Code"
44DIE I '$D(DGBGJ) S DA=PTF,DR="10///"_DGX_$S('$P(^DGPT(PTF,0),U,3):";3///`"_$P($$SITE^VASITE,U),1:""),DIE="^DGPT(" D ^DIE K DGZEC,DGZ,DGZ1,DG1,DGX,DR,DGT,DA,DIE Q
45 I DGX'=$P(^DGPT(PTF,0),"^",10) S DA=PTF,DR="10///"_DGX,DIE="^DGPT(" D ^DIE
46 K DGZEC,DGZ,DGZ1,DG1,DGX,DGT,DR,DA,DIE Q
47 ;
48RTY ; -- set rec type variables
49 ; input: Y := rec type #
50 ; output: DGRTY := rec type #
51 ; DGRTY0 := name of type (in future, may expand to 0th node)
52 ;
53 I Y=1 S DGRTY=1,DGRTY0="PTF"
54 I Y=2 S DGRTY=2,DGRTY0="CENSUS"
55 Q
56 ;
57HANG ;
58 R DGPTHANG:4 K DGPTHANG Q
59 ;
60CEN ; -- find current active census ; return ifn and 0th node
61 S DGCN=$O(^DG(45.86,"AC",1,0)),DGCN0=$S($D(^DG(45.86,+DGCN,0)):^(0),1:"")
62 Q
63 ;
64FMT ; -- determime PTF record format
65 ;
66 S Z=$S(Y:Y,1:DT)
67 S DGPTFMT=1 D FDT
68 I Z>Y S DGPTFMT=2
69 K Z
70 Q
71 ;
72FDT ; -- set new format date for testing
73 S Y=2901000 Q
74 ;
75UPDT ; -- update PTF record w/PTF and DFN defined
76 I '$D(^DGPT(PTF,0)) W:'$D(ZTQUEUED) !!,*7,">>> PTF record #",PTF," does not exist." G UPDTQ
77 S X=^(0)
78 I $P(X,U,11)>1 W:'$D(ZTQUEUED) !!,*7,">>> Record #",PTF," is not a PTF record." G UPDTQ
79 S DGPTFE=$P(X,U,4),(DGADM,AD)=+$P(X,U,2),DGST=$D(^DGP(45.84,PTF))>0
80 I DGST W:'$D(ZTQUEUED) !!,*7,">>> PTF record #",PTF," is closed out. No updating allowed." G UPDTQ
81 I DGPTFE W:'$D(ZTQUEUED) !!,*7,">>> PTF record #",PTF," is a fee PTF record. No updating is possible." G UPDTQ
82 N DGPMCA,DGPMAN D PM
83 I DGPMCA D:'$P(^DGPT(PTF,0),U,5) SUF^DGPTF D LE^DGPTTS,DC^DGPTF
84 ;
85UPDTQ K AGE,D0,D1,DA,DGADM,DGLAST,DGP,DGTY,DIC,DIE,DR,DIV,DIU,DISYS,DIK,DIKLM,DIG,DIH,DI,DIW,DIWL,DIWR,DIWT,DN,DOB,DQ,DG,DRG,SEX,TY,L,P1,DIS2,DGPTFE,DGST,DGX,DFN1,DFN2,PR,I1,TDD,AD
86 Q
87 ;
88EXPL ; -- explode string A(input) to DGA(output)
89 N J,L S DGA=$E(A,2,999)
90 I DGA["-" S X=DGA,DGA="" F J=1:1 S L=$P(X,",",J) Q:'L D EXPL1:L["-" S:L]"" DGA=DGA_L_"," Q:$P(X,",",J+1,999)=""
91 Q
92 ;
93EXPL1 ; -- explode string 'L' of form "1-12" ; input and output is 'L'
94 N I,X
95 I $P(L,"-")'?1N.N!($P(L,"-",2,999)'?1N.N) S L="" G EXPL1Q
96 I +L>$P(L,"-",2) S L="" G EXPL1Q
97 I +L=+$P(L,"-",2) S L=+L G EXPL1Q
98 S X="" F I=+L:1:+$P(L,"-",2) Q:($L(X)+$L(I)+1)>240 S X=X_I_","
99 S L=$E(X,1,$L(X)-1)
100EXPL1Q Q
101 ;
102CKPOS(ADEL,DEFAULT) ;-- This function will check the admitting eligibility
103 ; and the POS to make sure for Non-Vet eligibilities that a
104 ; 9 - Other or None POS is present.
105 ;
106 ; INPUT - ADEL : Admitting Eligibility (Pointer to file 8)
107 ; DEFAULT : Default POS (optional) (Pointer to file 21)
108 ; OUTPUT- POS : POS Code. 0 - Error
109 ;
110 N RESULT,X,Y
111 ;If DFN is not needed here, kill DFN to avoid VADPT error out.
112 I $G(DFN)="" N DFN S DFN=$G(DGSDFN) I $G(DFN)="" K DFN
113 D ELIG^VADPT
114 I $D(VAEL(1))=1 S RESULT=$G(DEFAULT) G CKPOSQ
115 S RESULT=0,Y=$G(DEFAULT)
116 I '$D(^DIC(8,+ADEL,0)) G CKPOSQ
117 S X=$G(^DIC(8.1,$P($G(^DIC(8,+ADEL,0)),U,9),0))
118 ;-- if non vet set POS to Other
119 I $P(X,U,5)="N" S RESULT=9
120 ;-- if vet then use default
121 I $P(X,U,5)="Y",Y'="" S RESULT=Y
122CKPOSQ ;
123 Q RESULT
124 ;
Note: See TracBrowser for help on using the repository browser.