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

DGPTFUT.m

Go to the documentation of this file.
  1. DGPTFUT ;WOIFO/PLT,HIOFO/FT,WIOFO/PMK - PTF UTILITIES WITH API - ICR #6130 ;05/04/15 10:07am
  1. ;;5.3;Registration;**884**;Aug 13, 1993;Build 31
  1. ;;Per VA Directive 6402, this routine should not be modified.
  1. ;
  1. ;direct entry not allowed
  1. QUIT
  1. ;
  1. ;dga=401, 501, 601, 701 or 801 of multiple fields of file #45 - ^dgpt
  1. ;dgb=ien of file #45 - ^dgpt
  1. ;.dgc=return values, initialized with kill, dgc(0)= discharge date for dga=701
  1. ; dgc(ien)= 401 sugery/procedure date, 501 movement date
  1. ; 601 procedure date, 701 discharge date
  1. ; 801 cpt record date/time
  1. PTFIEN(DGA,DGB,DGC) ;get the ien's for 701,401,501,601,801 and recd dt/time
  1. K DGC
  1. N A,B,C
  1. I DGA=701 S DGC(0)=$P($G(^DGPT(DGB,70)),U) QUIT
  1. S A=$S(DGA=401:"S",DGA=501:"M",DGA=601:"P",DGA=801:"C",1:"") QUIT:A=""
  1. ;the piece # of the record date/time
  1. S C=1 S:DGA=501 C=10
  1. S B=0 F S B=$O(^DGPT(DGB,A,B)) QUIT:'B S DGC(B)=$P($G(^(B,0)),U,C)
  1. QUIT
  1. ;
  1. ;dga=401, 501, 601, 701 or 801
  1. ;dgb=ien of file #45 - ptf
  1. ;dgc=ien of field multiple 401, 501, 601,801, nil if dga=701
  1. ;.dgd=return values, initialized with kill, dgd=^1 to ^15 demographic data, see tag 101
  1. ; ^16 rec date/time^17 405 ien if dga=501
  1. ; dgd(0)=prin dia ien^prin poa^icd code^poa external if dga=7/801
  1. ; dgd(1)=ien of icd1^poa1 internal^icd code^poa external, dgd(2)=...
  1. ; dgd(25)=ien of icd25^poa25 internal^icd code^poa external
  1. ; dgd(#) is undef if icd nil
  1. ;dge=1 for dgd(#,1)=short description, dgd(2,1)...,dgd(25,1)
  1. ; dge=2 dgd(1,2)=long description, dgd(2,2)...,dgd(25,2)
  1. ; dge=3 for both dgd(1,1) and dgd(1,2)..., dgd(25,1) and dgd(25,2)
  1. PTFICD(DGA,DGB,DGC,DGD,DGE) ;get icd/poa/description of file #45
  1. K DGD
  1. S DGD=$$101(DGB) S:$P(DGD,U,2) $P(DGD,U,12)=$$GETLABEL^DGPTIC10($P(DGD,U,11),$S(DGA=701!(DGA=501):"D",DGA=401!(DGA=601):"P",1:""))
  1. D @DGA
  1. QUIT
  1. ;
  1. ;
  1. ;ptf=ien of file #45
  1. ;value= ^1 patient name^2 patient ien^3 adm dt^4 fac^5 fee basis
  1. ; ^6 status^7 type record^8 ptf ien generating this census rec
  1. ; ^9 census date ptr^10 discharge date^11 effective date
  1. ; ^12 icd label if from tag ptficd
  1. 101(PTF) ;ef= value of ptf demographic data
  1. N A,B,C,D
  1. QUIT:'PTF "" QUIT:'$D(^DGPT(PTF)) ""
  1. S A=^DGPT(PTF,0),B=$G(^(70))
  1. S C=$$GET7DATE^DGPTIC10(PTF)
  1. S D=$P(^DPT(+A,0),U)_U_$P(A,U,1,4),$P(D,U,6)=$P(A,U,6)_U_$P(A,U,11)_U_$P(A,U,12)_U_$P(A,U,13)_U_$P(B,U)_U_C
  1. QUIT D
  1. ;
  1. ;
  1. 401 ;401 multiple operation icd
  1. N A,B,C
  1. QUIT:'$D(^DGPT(DGB,"S",DGC,0)) S A=^(0),B=$G(^(1)),$P(DGD,U,16)=$P(A,U)
  1. F C=8:1:27 S:$P(A,U,C)]"" DGD(C-7)=$P(A,U,C)_U_U_$$ICDCODE(80.1,$P(A,U,C))
  1. F C=1:1:5 S:$P(B,U,C)]"" DGD(C+20)=$P(B,U,C)_U_U_$$ICDCODE(80.1,$P(B,U,C))
  1. I $G(DGE) D DOPDES(80.1)
  1. QUIT
  1. ;
  1. ;
  1. 501 ;501 multiple - movement icd/poa
  1. N A,B,C,D
  1. QUIT:'$D(^DGPT(DGB,"M",DGC,0)) S A=^(0),B=$G(^(81)),C=$G(^(82)),$P(DGD,U,16)=$P(A,U,10)
  1. F D=5:1:9 S:$P(A,U,D)]"" DGD(D-4)=$P(A,U,D)_U_$P(C,U,D-4)_U_$$ICDCODE(80,$P(A,U,D))_U_$S($P(C,U,D-4)]"":$$EXTERNAL^DILFD(45.02,82.01,"",$P(C,U,D-4)),1:"")
  1. F D=11:1:15 S:$P(A,U,D)]"" DGD(D-5)=$P(A,U,D)_U_$P(C,U,D-5)_U_$$ICDCODE(80,$P(A,U,D))_U_$S($P(C,U,D-5)]"":$$EXTERNAL^DILFD(45.02,82.01,"",$P(C,U,D-5)),1:"")
  1. F D=1:1:15 S:$P(B,U,D)]"" DGD(D+10)=$P(B,U,D)_U_$P(C,U,D+10)_U_$$ICDCODE(80,$P(B,U,D))_U_$S($P(C,U,D+10)]"":$$EXTERNAL^DILFD(45.02,82.01,"",$P(C,U,D+10)),1:"")
  1. I $G(DGE) D DOPDES(80)
  1. QUIT
  1. ;
  1. ;
  1. 601 ;601 multiple - procedure icd
  1. N A,B,C
  1. QUIT:'$D(^DGPT(DGB,"P",DGC,0)) S A=^(0),B=$G(^(1)),$P(DGD,U,16)=$P(A,U)
  1. F C=5:1:24 S:$P(A,U,C)]"" DGD(C-4)=$P(A,U,C)_U_U_$$ICDCODE(80.1,$P(A,U,C))
  1. F C=1:1:5 S:$P(B,U,C)]"" DGD(C+20)=$P(B,U,C)_U_U_$$ICDCODE(80.1,$P(B,U,C))
  1. I $G(DGE) D DOPDES(80.1)
  1. QUIT
  1. ;
  1. ;
  1. 701 ;primary and secondary diagnosis icd/poa
  1. N A,B,C,D,E
  1. QUIT:'$D(^DGPT(DGB,0)) S A=$G(^(70)),B=$G(^(71)),C=$G(^(82))
  1. S E=$P(A,U,10) S:E="" E=$P(A,U,11)
  1. S:E]"" DGD(0)=E_U_$P(C,U,1)_U_$$ICDCODE(80,E)_U_$S($P(C,U,1)]"":$$EXTERNAL^DILFD(45,82.01,"",$P(C,U,1)),1:"")
  1. F D=16:1:24 S:$P(A,U,D)]"" DGD(D-15)=$P(A,U,D)_U_$P(C,U,D-14)_U_$$ICDCODE(80,$P(A,U,D))_U_$S($P(C,U,D-14)]"":$$EXTERNAL^DILFD(45,82.02,"",$P(C,U,D-14)),1:"")
  1. F D=1:1:15 S:$P(B,U,D)]"" DGD(D+9)=$P(B,U,D)_U_$P(C,U,D+10)_U_$$ICDCODE(80,$P(B,U,D))_U_$S($P(C,U,D+10)]"":$$EXTERNAL^DILFD(45,82.02,"",$P(C,U,D+10)),1:"")
  1. I $G(DGE) D DOPDES(80)
  1. QUIT
  1. ;
  1. ;
  1. 801 ;801 multiple - cpt code
  1. N A
  1. QUIT:'$D(^DGPT(DGB,"C",DGC,0)) S A=^(0)
  1. S:$P(A,U,4)]"" DGD(0)=$P(A,U,4)_U_U_$$ICDCODE(80,$P(A,U,4))
  1. I $G(DGE) D DOPDES(80)
  1. QUIT
  1. ;
  1. ;
  1. ;dga=80 or 80.1
  1. DOPDES(DGA) ;set diag,oper and procet short/long description in dgd array
  1. N DGB
  1. S DGB="" F S DGB=$O(DGD(DGB)) QUIT:DGB="" S:"13"[DGE DGD(DGB,1)=$$ICDDES(DGA,+DGD(DGB),$P(DGD,U,11),1) S:"23"[DGE DGD(DGB,2)=$$ICDDES(DGA,+DGD(DGB),$P(DGD,U,11),2)
  1. ;
  1. ;
  1. ;
  1. ;a= file #80 or #80.1
  1. ;b=ien
  1. ICDCODE(A,B) ;ef icd code or nil
  1. N C
  1. S C=$$CODEC^ICDEX(A,B)
  1. QUIT $S(C=-1:"",1:C)
  1. ;
  1. ;
  1. ;dgfn=80 for icd, 80.1 for opration/procedure
  1. ;dgien=ien of dgfn
  1. ;dgedt=effective date
  1. ;a=1 for short description, 2=long
  1. ICDDES(DGFN,DGIEN,DGEDT,A) ;ef= file 80 or 80.1 code description
  1. QUIT:A=1 $$VST^ICDEX(DGFN,DGIEN,DGEDT)
  1. QUIT $$VLT^ICDEX(DGFN,DGIEN,DGEDT)
  1. ;
  1. ;
  1. STR401(DG0,DG1) ; Builds 25 piece string with OPERATION codes
  1. ; DG0 = file 45 ien
  1. ; DG1 = ien of 401 multiple
  1. ; Returns a string of 25 pieces containing the OPERATION codes
  1. N DG401,DG401A,DGLOOP,DGSTRING
  1. S DG0=$G(DG0),DG1=$G(DG1)
  1. I 'DG0!'DG1 Q ""
  1. S DG401=$G(^DGPT(DG0,"S",DG1,0)),DG401A=$G(^DGPT(DG0,"S",DG1,1)),DGSTRING=""
  1. F DGLOOP=8:1:27 S $P(DGSTRING,U,DGLOOP-7)=$P(DG401,U,DGLOOP)
  1. F DGLOOP=1:1:5 S $P(DGSTRING,U,DGLOOP+20)=$P(DG401A,U,DGLOOP)
  1. Q DGSTRING
  1. ;
  1. STR501(DG0,DG1) ; Builds 25 piece string with MOVEMENT codes
  1. ; DG0 = file 45 ien
  1. ; DG1 = ien of 501 multiple
  1. ; Returns a string of 25 pieces containing the MOVEMENT codes
  1. N DG501,DG501A,DGLOOP,DGSTRING
  1. S DG0=$G(DG0),DG1=$G(DG1)
  1. I 'DG0!'DG1 Q ""
  1. S DG501=$G(^DGPT(DG0,"M",DG1,0)),DG501A=$G(^DGPT(DG0,"M",DG1,81)),DGSTRING=""
  1. F DGLOOP=5:1:9 S $P(DGSTRING,U,DGLOOP-4)=$P(DG501,U,DGLOOP)
  1. F DGLOOP=11:1:15 S $P(DGSTRING,U,DGLOOP-5)=$P(DG501,U,DGLOOP)
  1. F DGLOOP=1:1:15 S $P(DGSTRING,U,DGLOOP+10)=$P(DG501A,U,DGLOOP)
  1. Q DGSTRING
  1. ;
  1. STR601(DG0,DG1) ; Builds 25 piece string with PROCEDURE codes
  1. ; DG0 = file 45 ien
  1. ; DG1 = ien of 601 multiple
  1. ; Returns a string of 25 pieces containing the PROCEDURE codes
  1. N DG601,DG601A,DGLOOP,DGSTRING
  1. S DG0=$G(DG0),DG1=$G(DG1)
  1. I 'DG0!'DG1 Q ""
  1. S DG601=$G(^DGPT(DG0,"P",DG1,0)),DG601A=$G(^DGPT(DG0,"P",DG1,1)),DGSTRING=""
  1. F DGLOOP=5:1:24 S $P(DGSTRING,U,DGLOOP-4)=$P(DG601,U,DGLOOP)
  1. F DGLOOP=1:1:5 S $P(DGSTRING,U,DGLOOP+20)=$P(DG601A,U,DGLOOP)
  1. Q DGSTRING
  1. ;
  1. STR701(DG0) ; Builds 25 piece string with DIAGNOSTIC codes
  1. ; DG0 = file 45 ien
  1. ; Returns a string of 25 pieces containing the 701 codes. First piece is principal DX
  1. N DG701,DG701A,DGLOOP,DGSTRING
  1. S DG0=$G(DG0)
  1. I 'DG0 Q ""
  1. S DG701=$G(^DGPT(DG0,70)),DG701A=$G(^DGPT(DG0,71)),DGSTRING="",$P(DGSTRING,U,1)=$P(DG701,U,10)
  1. F DGLOOP=16:1:24 S $P(DGSTRING,U,DGLOOP-14)=$P(DG701,U,DGLOOP)
  1. F DGLOOP=1:1:15 S $P(DGSTRING,U,DGLOOP+10)=$P(DG701A,U,DGLOOP)
  1. Q DGSTRING
  1. ;
  1. STR701P(DG0) ; Builds 25 piece string with 701 Present On Admission (POA) codes
  1. ; DG0 = file 45 ien
  1. ; Returns a string of 25 pieces containing the 701 POA codes
  1. N DG82,DGLOOP,DGSTRING
  1. S DG0=$G(DG0)
  1. I 'DG0 Q ""
  1. S DG82=$G(^DGPT(DG0,82)),DGSTRING=""
  1. F DGLOOP=1:1:25 S $P(DGSTRING,U,DGLOOP)=$P(DG82,U,DGLOOP)
  1. Q DGSTRING
  1. ;
  1. STR501P(DG0,DG1) ; Builds 25 piece string with 501 Present On Admission (POA) codes
  1. ; DG0 = file 45 ien
  1. ; DG1 = ien of 501 multiple
  1. ; Returns a string of 25 pieces containing the 501 POA codes
  1. N DG82,DGLOOP,DGSTRING
  1. S DG0=$G(DG0),DG1=$G(DG1)
  1. I 'DG0!'DG1 Q ""
  1. S DG82=$G(^DGPT(DG0,"M",DG1,82)),DGSTRING=""
  1. F DGLOOP=1:1:25 S $P(DGSTRING,U,DGLOOP)=$P(DG82,U,DGLOOP)
  1. Q DGSTRING
  1. ;