Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: DGPTSUDO

DGPTSUDO.m

Go to the documentation of this file.
DGPTSUDO ;ALB/MTC,HIOFO/FT,WOIFO/PMK - PTF UPDATE TRANSFER DRG NODE ;6/2/15 11:27am
 ;;5.3;Registration;**441,510,478,785,850,884**;Aug 13, 1993;Build 31
 ;;ADL;Update for CSV Project;;Mar 28, 2003
 ;
 ; ICDXCODE APIs - #5699
 ; ^VA(200) reads - #10060
 ;
UTIL S ^UTILITY($J,"T",(9999999.9999999-I))=K_"^"_$S($D(^DIC(45.7,J,0)):$P(^(0),"^",2),1:0)_"^"_X_"^^"_$P(Y,"^",8)
 Q
SUDO1 ;
 N DGPOA,DGDXPOA
 K ^UTILITY($J,"T"),T
 F I=0:0 S I=$O(^DGPM("ATS",DFN,DGPMCA,I)) Q:I'>0  D
 . S J=$O(^DGPM("ATS",DFN,DGPMCA,I,0)) I J D  ;^(J,0) on next line references global on this line
 .. S K=+$O(^(J,0)) I $D(^DGPM(K,0)) S Y=^(0),X=$S($D(^("PTF")):$P(^("PTF"),"^",2),1:"") I $D(^DGPT(PTF,"M",+X,0))!($D(^DGPM("APHY",+$P(Y,"^",14),K))) D UTIL
 Q:'$D(^UTILITY($J,"T"))
VARS I '$D(^UTILITY($J,"T")) G SUDO1
 S (DGPRD,DGNXD)=$O(^UTILITY($J,"T",0)) G Q:DGPRD'>0 S T(DGPRD)=^(DGPRD),(DGEXP,DGDMS,DGTRS,DGTLOS,DGLOS,DGDAT)=0,DGPT(70)=$S($D(^DGPT(PTF,70)):^(70),1:""),SEX=$P(^DPT(DFN,0),U,2),DOB=$P(^(0),U,3)
 S (DGDX,DGNSV,DGPSV,DGPOA,DGDXPOA)=""
 N EFFDATE,DGTEMP,IMPDATE
 D EFFDATE^DGPTIC10(PTF) S DGDAT=EFFDATE
 K DGSURG,DGPROC S (DGSURG,DGPROC)=U
 ;
 ;-- build DGSURG array
 F I=0:0 S I=$O(^DGPT(PTF,"S",I)) Q:I'>0  D
 . K DG401
 . D PTFICD^DGPTFUT(401,PTF,I,.DG401)
 . Q:'$O(DG401(0))
 . ;S Y=+$P(DG401,U,16),Y=$S('$D(DGSURG(Y)):Y,Y[".":Y_I_1,1:Y_".0000"_I_1),DGSURG(Y)=""
 . S Y=I/100000000+$P(DG401,U,16),DGSURG(Y)=""
 . S DGLOOP=0
 . F  S DGLOOP=$O(DG401(DGLOOP)) Q:'DGLOOP  D
 .. Q:$P(DG401(DGLOOP),U,1)=""
 .. S DGPTTMP=$$ICDDATA^ICDXCODE("PROC",$P(DG401(DGLOOP),U,1),EFFDATE)
 .. I +DGPTTMP>0 S DGSURG(Y)=DGSURG(Y)_$P(DG401(DGLOOP),U,1)_U
 K DG401,DGLOOP
 ;
 ;-- build DGPROC array
 F I=0:0 S I=$O(^DGPT(PTF,"P",I)) Q:I'>0  D
 . K DG601
 . D PTFICD^DGPTFUT(601,PTF,I,.DG601)
 . Q:'$O(DG601(0))
 . ;S Y=+$P(DG601,U,16),Y=$S('$D(DGPROC(Y)):Y,Y[".":Y_I_1,1:Y_".0000"_I_1),DGPROC(Y)=""
 . S Y=I/100000000+$P(DG601,U,16),DGPROC(Y)=""
 . S DGLOOP=0
 . F  S DGLOOP=$O(DG601(DGLOOP)) Q:'DGLOOP  D
 .. Q:$P(DG601(DGLOOP),U,1)=""
 .. S DGPTTMP=$$ICDDATA^ICDXCODE("PROC",$P(DG601(DGLOOP),U,1),EFFDATE)
 .. I +DGPTTMP>0 S DGPROC(Y)=DGPROC(Y)_$P(DG601(DGLOOP),U,1)_U
 K DG601,DGLOOP
 ;
 I $D(^DGPT(PTF,"401P")),+DGPT(70),+DGPT(70)<2871000 S X=^("401P") I X]"",X'="^^^^" D
 . F I=1:1:5 I $P(X,U,I)]"" S DGPTTMP=$$ICDDATA^ICDXCODE("PROC",$P(X,U,I),EFFDATE) I +EFFDATE>0 S DGPROC=DGPROC_$P(X,U,I)_U,DG401P=1
 ;
SUDO2 ;
 S DGNXD=$O(^UTILITY($J,"T",DGNXD))
 G ONE:DGNXD'>0 S T(DGNXD)=^UTILITY($J,"T",DGNXD),I1=+$P(T(DGNXD),U,3),DGDOC=$P(T(DGNXD),U,5)
 F I=DGPRD,DGNXD S L1(I)=$P(T(I),U,2)
 G:L1(DGPRD)=L1(DGNXD) SWCH
 S DGPSV=$S($D(^DIC(42.4,+L1(DGPRD),0)):$P(^(0),U,3),1:""),DGNSV=$S($D(^DIC(42.4,+L1(DGNXD),0)):$P(^(0),U,3),1:"")
 G:DGPSV']""!(DGNSV']"") SWCH
 I "^I^SCI^B^NH^D^RE^"'[(U_DGPSV_U),$D(^DGPT(PTF,"M",I1,0)) D
 . S DGNODE=^(0) ;^(0) references global on line above
 . D BLD I DGPSV'=DGNSV D DRG S DGSURG=U,DGDX="",DGDXPOA="",DGLOS=0 I '$D(DG401P) S DGPROC=U
SWCH ;
 K DGLEV,DGPAS
 S DGPRD=DGNXD,T(DGPRD)=T(DGNXD),(DGNSV,DGPSV)=""
 G SUDO2
 ;
BLD ;
 D PTFICD^DGPTFUT(501,PTF,I1,.DG501)
 QUIT:'$O(DG501(0))
 S DGLOOP=0 F  S DGLOOP=$O(DG501(DGLOOP)) Q:'DGLOOP  D
 . I $P(DGNODE,U,1)]"" S DGPTTMP=$$ICDDATA^ICDXCODE("DIAG",$P(DG501(DGLOOP),U,1),EFFDATE) I +DGPTTMP>0 S DGDX=DGDX_$P(DG501(DGLOOP),U,1)_U,DGDXPOA=DGDXPOA_$P(DG501(DGLOOP),U,2)_U
 K DG501,DGLOOP
 ;S:$L(DGDX)>200 DGDX=$P(DGDX,U,1,30)
 S DGLEV=$P(DGNODE,U,3),DGPAS=$P(DGNODE,U,4),X1=DGNXD,X2=DGPRD D ^%DTC S X=$S(X>0:X,1:1)-DGLEV-DGPAS,DGLOS=DGLOS+X
 N I,J,X,Y,Z
 F I=0:0 S I=$O(DGSURG(I)) Q:I'>0!(I\1>(DGNXD\1))  D SU
 I '$D(DG401P) F I=0:0 S I=$O(DGPROC(I)) Q:I'>0!((I\1)>(DGNXD\1))  D
 .S X=DGPROC(I)
 .F J=1:1:25 S Y=$P(X,U,J) Q:Y=""  D
 ..;Q:$L(DGPROC)>240 ; - no longer needed
 ..S Z=U_Y_U
 ..S DGPROC=DGPROC_Y_U
 ..S DGPROC(J)=Y
 ..K DGPROC(I)
 Q
SU ;
 I I<DGNXD!(DGPSV=DGNSV)!(DGPSV="S") D
 .S X=DGSURG(I)
 .F J=1:1:25 S Y=$P(X,U,J) Q:Y=""  D
 ..;Q:$L(DGSURG)>240 ; - no longer needed
 ..S Z=U_Y_U
 ..S DGSURG=DGSURG_Y_U
 ..S ICDSURG(J)=Y
 ..K DGSURG(I)
 Q
DRG ;
 S AGE=DGPRD-DOB\10000,DGTLOS=DGTLOS+DGLOS,DRG=""
 D ^DGPTICD
 S DGDOC=$S($D(^VA(200,+DGDOC)):DGDOC,1:"")
 N DGFDA,DGMSG
 S DGFDA(45.02,I1_","_PTF_",",20)=DRG     ;transfer drg
 S DGFDA(45.02,I1_","_PTF_",",21)=DGPSV   ;losing service
 S DGFDA(45.02,I1_","_PTF_",",22)=DGNXD   ;transfer date
 S DGFDA(45.02,I1_","_PTF_",",23)=DGLOS   ;los in service
 S DGFDA(45.02,I1_","_PTF_",",24)=DGDOC   ;provider
 S DGFDA(45.02,I1_","_PTF_",",25)=DGTLOS  ;cumulative los
 D FILE^DIE("","DGFDA","DGMSG")
 Q
ONE ;
 S DGNXD=$S(+$P(^DGPT(PTF,"M",1,0),U,10):$P(^(0),U,10),1:DT),L1(DGNXD)=$P(^(0),U,2) S:'$D(T(DGNXD)) T(DGNXD)=T(DGPRD),DGDOC=$P(T(DGNXD),U,5)
 S:$P(DGPT(70),U,3)>5 DGEXP=1 S:$P(DGPT(70),U,3)=4 DGDMS=1 S:$P(DGPT(70),U,13) DGTRS=1
 I L1(DGNXD),$D(^DIC(42.4,+L1(DGNXD),0)) S I1=1,DGPSV=$P(^(0),U,3),DGADM=$P(^DGPT(PTF,0),U,2)
 S DGNODE=$S($D(^DGPT(PTF,"M",1,0)):^(0),1:""),I1=1
 D BLD
 I $D(^DGPT("AADA",DGADM,PTF)) F I=10,11 I $P(DGPT(70),U,I) S DGDX=$P(DGPT(70),U,I)_U_DGDX,DGDXPOA=$P($G(^DGPT(PTF,82)),U)_U_$G(DGDXPOA) QUIT
 D DRG,^DGPTSUD1
Q ;
 K DGDMS,DGDOC,DGDX,DGEXP,DGLEV,DGLOS,DGNODE,DGNSV,DGNXD,DGPAS,DGPRD,DGPROC,DGPSV,DGPT,DGSURG,ICDSURG,DGTLOS,DGTRS,DG401P,DGDXPOA,I,I1,I2,J,L1,T,X,X1,X2,Y
 Q