VistA-FOIAVistA/r/MENTAL_HEALTH-YS-RUCL-YI-YT/YSD40062.m

84 lines
2.4 KiB
Mathematica

YSD40062 ;DALISC/LJA - Restore Medical Records ; [ 07/13/94 2:06 PM ]
;;5.01;MENTAL HEALTH;;Dec 30, 1994
;;
;
MR ;
; YSD40, YSD4CIEN -- req
;
; Counter variable
S (YSD4CT,YSD4GCT)=0
; Quit if not Converted...
QUIT:$P(YSD40,U,2)'="C" ;->
;
; If any entries are restored, kill "MR" nodes...
K ^YSD(627.99,"AS","MR CONVERSION COMPLETED")
K ^YSD(627.99,"AS","MR CONVERSION STARTED")
K ^YSD(627.99,"AS","MR LAST STARTED")
K ^YSD(627.99,"AS","MR NUMBER CONVERTED")
;
; Set needed vars for xrefs, etc
S YSD4REF=$P(YSD40,U) ;Reference to Medical Record
S YSD4IEN=+YSD4REF ;Medical Record's IEN
;
; Loop thru nodes...
S YSD4NODE=0,YSD4CT=0
F S YSD4NODE=$O(^YSD(627.99,+YSD4CIEN,YSD4NODE)) QUIT:'$$OKNODE(YSD4NODE) D
. S YSD4CT=YSD4CT+1 W:'(YSD4CT#50) "."
. D @YSD4NODE
K ^YSD(627.99,+YSD4CIEN)
K ^YSD(627.99,"B",YSD4REF,+YSD4CIEN)
S X=$P(^YSD(627.99,0),U,4)-1,X=$S(X>0:X,1:0),$P(^YSD(627.99,0),U,4)=X
;
; Up counter and dot
S ^TMP($J,"MR")=$G(^TMP($J,"MR"))+1
S YSD4GCT=YSD4GCT+1 W:'(YSD4GCT#50) "."
;
QUIT
;
DX ;
S YSD4DXNO=0
F S YSD4DXNO=$O(^YSD(627.99,+YSD4CIEN,"DX",YSD4DXNO)) QUIT:YSD4DXNO'>0 D
. S YSD4ODX=$G(^YSD(627.99,+YSD4CIEN,"DX",+YSD4DXNO,0))
. QUIT:YSD4ODX']"" ;->
. S YSD4NDX=$P($G(^MR(+YSD4IEN,"DX",+YSD4DXNO,0)),U)
. QUIT:YSD4NDX']"" ;->
. K ^MR(+YSD4IEN,"DX","B",+YSD4NDX,+YSD4DXNO)
. S ^MR(+YSD4IEN,"DX","B",+YSD4ODX,+YSD4DXNO)=""
. S $P(^MR(+YSD4IEN,"DX",+YSD4DXNO,0),U)=YSD4ODX
. K ^YSD(627.99,+YSD4CIEN,"DX",+YSD4DXNO)
QUIT
;
DX1 ;
S YSD4ODX1=$G(^YSD(627.99,+YSD4CIEN,"DX1"))
QUIT:$P(YSD4ODX1,U,2)']""&($P(YSD4ODX1,U,4)']"") ;->
F YSD4P=2,4 D
. S YSD4ODX=$P(YSD4ODX1,U,+YSD4P)
. QUIT:YSD4ODX']"" ;->
. S $P(^MR(+YSD4IEN,"DX1"),U,+YSD4P)=YSD4ODX
K ^YSD(627.99,+YSD4CIEN,"DX1")
QUIT
;
PDX ;
S YSD4PDX=0
F S YSD4PDX=$O(^YSD(627.99,+YSD4CIEN,"PDX",YSD4PDX)) QUIT:YSD4PDX'>0 D
. S YSD4ODX=$P($G(^YSD(627.99,+YSD4CIEN,"PDX",+YSD4PDX,0)),U)
. QUIT:YSD4ODX']"" ;->
. S $P(^MR(+YSD4IEN,"PDX",+YSD4PDX,0),U)=YSD4ODX
. K ^YSD(627.99,+YSD4CIEN,"PDX",+YSD4PDX)
QUIT
;
XDX ;
S YSD4PDX=0
F S YSD4PDX=$O(^YSD(627.99,+YSD4CIEN,"XDX",YSD4PDX)) QUIT:YSD4PDX'>0 D
. S YSD4ODX=$P($G(^YSD(627.99,+YSD4CIEN,"XDX",+YSD4PDX,0)),U)
. QUIT:YSD4ODX']"" ;->
. S $P(^MR(+YSD4IEN,"XDX",+YSD4PDX,0),U)=YSD4ODX
. K ^YSD(627.99,+YSD4CIEN,"XDX",+YSD4PDX)
QUIT
;
OKNODE(NODE) ;
QUIT:$G(NODE)']"" 0
QUIT NODE["DX"!(NODE["DX1")!(NODE["PDX")!(NODE["XDX")
;
EOR ;YSD40061 - Restore Medical Records ; 4/8/94 13:20