ORDV07 ;SLC/DAN/KER - OE/RR Report extracts ; 01/09/2003
;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,120,159**;Dec 17,1997
;
; External References
; DBIA 10112 $$SITE^VASITE
; DBIA 10061 4^VADPT
; DBIA 10061 OAD^VADPT
; DBIA 10145 ALL^IBCNS1
; DBIA 767 ^DGSL(38.1,
; DBIA 1407 ^FHWHEA
; DBIA 3818 ICDS^GMTSDGP
; DBIA 3818 ICDP^GMTSDGP
; DBIA 418 ^DGPT("B"
; DBIA 794 ^DIC(36,
; DBIA 951 ^IBE(355.1,
;
;Dietetics components
DIETA(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;All diet
N ORTYPE S ORTYPE="DI" D DIET Q
DIETN(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Nutritional Status
N ORTYPE S ORTYPE="NS" D DIET Q
DIETS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Supplemental Feedings
N ORTYPE S ORTYPE="SF" D DIET Q
DIETT(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Tube feedings
N ORTYPE S ORTYPE="TF" D DIET Q
;
DIET ;Main diet entry point
;External calls to FHWHEA and SITE^VASITE
;Data returned in ^TMP("ORDATA",$J) by type:
; ALL=Facility^Start Date^End Date^Diet^Comment^Service(tray,dining room, etc)
; Nutritional Status=Facility^Status Date^Status
; Supplemental Feeding=Facility^Date Ordered^Date Canceled^10am feeding^2pm feeding^8pm feeding
; Tubefeeding=Facility^Date Ordered^Date Canceled^Product^Strength^Quantity^Daily CCs^Daily KCal^Comment
;
N GMTS1,GMTS2,GMTSNDM,ORSITE,SITE,ORDT
S GMTS1=OROMEGA-.24,GMTS2=ORALPHA,GMTSNDM=ORMAX
K ^TMP("ORDATA",$J)
D ^FHWHEA ;get all diet information. Returned in ^UTILITY($J)
Q:'$D(^UTILITY($J,ORTYPE)) ;no data to report for type selected
S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
S ORDT=0
F S ORDT=$O(^UTILITY($J,ORTYPE,ORDT)) Q:ORDT="" D
. S SITE=$S($L($G(^UTILITY($J,ORTYPE,ORDT,"facility"))):^("facility"),1:ORSITE)
. S ^TMP("ORDATA",$J,ORDT,"WP",1)="1^"_SITE ;Station ID
. S ^TMP("ORDATA",$J,ORDT,"WP",2)="2^"_$$DATE^ORDVU($P(^UTILITY($J,ORTYPE,ORDT,0),"^")) ;date
. S ^TMP("ORDATA",$J,ORDT,"WP",3)="3^"_$S(ORTYPE="NS":$P(^UTILITY($J,ORTYPE,ORDT,0),"^",2),1:$$DATE^ORDVU($P(^UTILITY($J,ORTYPE,ORDT,0),"^",2)))
. Q:ORTYPE="NS" ;no more data required for NS
. S ^TMP("ORDATA",$J,ORDT,"WP",4)="4^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",3)
. S ^TMP("ORDATA",$J,ORDT,"WP",5)="5^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",4)
. S ^TMP("ORDATA",$J,ORDT,"WP",6)="6^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",5)
. Q:ORTYPE'="TF"
. ;Get remaining data for tube feedings
. S ^TMP("ORDATA",$J,ORDT,"WP",7)="7^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",6)
. S ^TMP("ORDATA",$J,ORDT,"WP",8)="8^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",7)
. S ^TMP("ORDATA",$J,ORDT,"WP",9)="9^"_$P(^UTILITY($J,ORTYPE,ORDT,0),"^",8)
K ^UTILITY($J)
S ROOT=$NA(^TMP("ORDATA",$J))
Q
;
DEM(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ; ADT Demographics
; External calls to VASITE, VADPT, and ^DGSL(38.1
N VADM,VAPA,VAOA,ORSITE,SITE,I,ORDAT,ORETHN,ORRACE S (ORETHN,ORRACE)=""
K ^TMP("ORDATA",$J)
D 4^VADPT,OAD^VADPT
; Quit if error in data gathering, otherwise get
; demographic/address information as well as next
; of kin addres
Q:VAERR
S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
S SITE=ORSITE
; 1 Site
S ^TMP("ORDATA",$J,1,"WP",1)="1^"_SITE
; 2 Patient Name
S ^TMP("ORDATA",$J,1,"WP",2)="2^"_VADM(1)
; 3 SSN
S ^TMP("ORDATA",$J,1,"WP",3)="3^"_$P(VADM(2),"^")
; 4 Sex
S ^TMP("ORDATA",$J,1,"WP",4)="4^"_$P(VADM(5),"^",2)
; 5 Date of Birth
S ^TMP("ORDATA",$J,1,"WP",5)="5^"_$$DATE^ORDVU($P(VADM(3),"^"))
; 6 Religion
S ^TMP("ORDATA",$J,1,"WP",6)="6^"_$P(VADM(9),"^",2)
; 7 Marital Status
S ^TMP("ORDATA",$J,1,"WP",7)="7^"_$P(VADM(10),"^",2)
; 8 Phone Number
S ^TMP("ORDATA",$J,1,"WP",8)="8^"_VAPA(8)
; 9 Street Address (1-3), City, State, and ZIP
S ^TMP("ORDATA",$J,1,"WP",9,1)="9^"_VAPA(1) I $P(^(1),"^",2)="" K ^(1)
S ^TMP("ORDATA",$J,1,"WP",9,2)="9^"_VAPA(2) I $P(^(2),"^",2)="" K ^(2)
S ^TMP("ORDATA",$J,1,"WP",9,3)="9^"_VAPA(3) I $P(^(3),"^",2)="" K ^(3)
S ^TMP("ORDATA",$J,1,"WP",9,4)="9^"_VAPA(4)_$S($G(VAPA(4))'="":", ",1:"")_$P(VAPA(5),"^",2)_" "_VAPA(6)
; 11 Ethnicity
S I=0 F S I=$O(VADM(11,I)) Q:+I=0 D
. S ORDAT=$P(VADM(11,I),"^",2) Q:'$L(ORDAT)
. S ORETHN=$G(ORETHN)_", "_ORDAT
. S ^TMP("ORDATA",$J,1,"WP",11,I)="11^"_ORDAT
; 10 Race
S:$L(ORETHN) ^TMP("ORDATA",$J,1,"WP",10,1)="10^"
S I=0 F S I=$O(VADM(12,I)) Q:+I=0 D
. S ORDAT=$P($G(VADM(12,I)),"^",2) Q:'$L(ORDAT)
. S ORRACE=$G(ORRACE)_", "_ORDAT
. S ^TMP("ORDATA",$J,1,"WP",10,I)="10^"_ORDAT
S ORRACE=$P(ORRACE,", ",2,$L(ORRACE,", "))
I '$L($P($G(^TMP("ORDATA",$J,1,"WP",11,1)),"^",2)) D
. I '$L($P($G(^TMP("ORDATA",$J,1,"WP",10,1)),"^",2)) D
. . S ^TMP("ORDATA",$J,1,"WP",11,1)="11^"
. . S ^TMP("ORDATA",$J,1,"WP",10,1)="10^"_$P($G(VADM(8)),"^",2)
S ORETHN=$P(ORETHN,", ",2,$L(ORETHN,", "))
; 12 Next of Kin
S ^TMP("ORDATA",$J,1,"WP",12)="12^"_VAOA(9)
; 13 Next of Kin Relationship
S ^TMP("ORDATA",$J,1,"WP",13)="13^"_VAOA(10)
; 14 NOK Street Address (1-3), City, State, and ZIP
S ^TMP("ORDATA",$J,1,"WP",14,1)="14^"_VAOA(1) I $P(^(1),"^",2)="" K ^(1)
S ^TMP("ORDATA",$J,1,"WP",14,2)="14^"_VAOA(2) I $P(^(2),"^",2)="" K ^(2)
S ^TMP("ORDATA",$J,1,"WP",14,3)="14^"_VAOA(3) I $P(^(3),"^",2)=""
S ^TMP("ORDATA",$J,1,"WP",14,4)="14^"_VAOA(4)_$S($G(VAOA(4))'="":", ",1:"")_$P(VAOA(5),"^",2)_" "_VAOA(6)
; 15 Security Log
S ^TMP("ORDATA",$J,1,"WP",15)="15^"_$S($P($G(^DGSL(38.1,DFN,0)),"^",2):"YES",1:"NO")
S ROOT=$NA(^TMP("ORDATA",$J))
Q
ICDSUR(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return ICD Surgery Information
;External calls to VASITE, GMTSDGP
N ORSITE,SITE,T1,T2,I,J,GMS,PTF,ORDATE
K ^TMP("ORDATA",$J)
S T1=ORDEND,T2=ORDBEG,ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
F PTF=0:0 S PTF=$O(^DGPT("B",DFN,PTF)) Q:PTF="" D ICDS^GMTSDGP
S (I,ORDATE)=0
F S ORDATE=$O(GMS(ORDATE)) Q:ORDATE=""!(I'<ORMAX) S J=0 D
. F S J=$O(GMS(ORDATE,J)) Q:'J!(I'<ORMAX) S I=I+1 D ;Check for multiple procedures on same date
.. S SITE=$S($L($G(GMS(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,1)="1^"_SITE
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($P(GMS(ORDATE)," ",3)) ;Date of procedure
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,3)="3^"_$P($G(GMS(ORDATE,J)),"^") ;Surgery and code
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,4)="4^"_$P(GMS(ORDATE,J),"^",2) ;ICD code
S ROOT=$NA(^TMP("ORDATA",$J))
Q
PRC(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Procedure Information
;External calls to VASITE, GMTSDGP
N ORSITE,SITE,T1,T2,I,J,GMP,PTF,ORDATE
K ^TMP("ORDATA",$J)
S T1=ORDEND,T2=ORDBEG,PTF=0,ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3)
F S PTF=$O(^DGPT("B",DFN,PTF)) Q:PTF="" D ICDP^GMTSDGP
S (I,ORDATE)=0
F S ORDATE=$O(GMP(ORDATE)) Q:ORDATE=""!(I'<ORMAX) S J=0 D
. F S J=$O(GMP(ORDATE,J)) Q:'J!(I'<ORMAX) S I=I+1 D ;Check for multiple procedures on same date
.. S SITE=$S($L($G(GMP(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,1)="1^"_SITE
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($P(GMP(ORDATE)," ",2)) ;Date of procedure
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,3)="3^"_$P($G(GMP(ORDATE,J)),"^") ;Procedure and code
.. S ^TMP("ORDATA",$J,"WP",ORDATE,J,4)="4^"_$P(GMP(ORDATE,J),"^",2) ;ICD code
S ROOT=$NA(^TMP("ORDATA",$J))
Q
INS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Insurance Information
;External calls to VASITE and IBCNS1 and ^DIC(36, and ^IBE(355.1
N ORSITE,SITE,ORARRAY,I
K ^TMP("ORDATA",$J)
D ALL^IBCNS1(DFN,"ORARRAY")
Q:'$D(ORARRAY) ;quit if no insurance data returned
S ORSITE=$$SITE^VASITE,ORSITE=$P(ORSITE,"^",2)_";"_$P(ORSITE,"^",3),I=0
F S I=$O(ORARRAY(I)) Q:'I D
. S SITE=$S($L($G(ORARRAY(I,"facility"))):^("facility"),1:ORSITE)
. S ^TMP("ORDATA",$J,"WP",I,1)="1^"_SITE
. S ^TMP("ORDATA",$J,"WP",I,2)="2^"_$P($G(^DIC(36,+$P(ORARRAY(I,0),"^"),0)),"^") ;Insurance company
. S ^TMP("ORDATA",$J,"WP",I,3)="3^"_$P($G(^IBE(355.1,+$P(ORARRAY(I,355.3),"^",9),0)),"^") ;Policy type
. S ^TMP("ORDATA",$J,"WP",I,4)="4^"_$P(ORARRAY(I,355.3),"^",4) ;Group number
. S ^TMP("ORDATA",$J,"WP",I,5)="5^"_$S($P(ORARRAY(I,0),"^",6)="s":"SPOUSE",$P(ORARRAY(I,0),"^",6)="v":"SELF",1:"OTHER") ;Policy holder
. S ^TMP("ORDATA",$J,"WP",I,6)="6^"_$$DATE^ORDVU($P(ORARRAY(I,0),"^",8)) ;Effective date of policy
. S ^TMP("ORDATA",$J,"WP",I,7)="7^"_$$DATE^ORDVU($P(ORARRAY(I,0),"^",4)) ;Expiration date of policy
S ROOT=$NA(^TMP("ORDATA",$J))
Q
ORDV07 ;SLC/DAN/KER - OE/RR Report extracts ; 01/09/2003
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**109,120,159**;Dec 17,1997
+2 ;
+3 ; External References
+4 ; DBIA 10112 $$SITE^VASITE
+5 ; DBIA 10061 4^VADPT
+6 ; DBIA 10061 OAD^VADPT
+7 ; DBIA 10145 ALL^IBCNS1
+8 ; DBIA 767 ^DGSL(38.1,
+9 ; DBIA 1407 ^FHWHEA
+10 ; DBIA 3818 ICDS^GMTSDGP
+11 ; DBIA 3818 ICDP^GMTSDGP
+12 ; DBIA 418 ^DGPT("B"
+13 ; DBIA 794 ^DIC(36,
+14 ; DBIA 951 ^IBE(355.1,
+15 ;
+16 ;Dietetics components
DIETA(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;All diet
+1 NEW ORTYPE
SET ORTYPE="DI"
DO DIET
QUIT
DIETN(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Nutritional Status
+1 NEW ORTYPE
SET ORTYPE="NS"
DO DIET
QUIT
DIETS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Supplemental Feedings
+1 NEW ORTYPE
SET ORTYPE="SF"
DO DIET
QUIT
DIETT(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Tube feedings
+1 NEW ORTYPE
SET ORTYPE="TF"
DO DIET
QUIT
+2 ;
DIET ;Main diet entry point
+1 ;External calls to FHWHEA and SITE^VASITE
+2 ;Data returned in ^TMP("ORDATA",$J) by type:
+3 ; ALL=Facility^Start Date^End Date^Diet^Comment^Service(tray,dining room, etc)
+4 ; Nutritional Status=Facility^Status Date^Status
+5 ; Supplemental Feeding=Facility^Date Ordered^Date Canceled^10am feeding^2pm feeding^8pm feeding
+6 ; Tubefeeding=Facility^Date Ordered^Date Canceled^Product^Strength^Quantity^Daily CCs^Daily KCal^Comment
+7 ;
+8 NEW GMTS1,GMTS2,GMTSNDM,ORSITE,SITE,ORDT
+9 SET GMTS1=OROMEGA-.24
SET GMTS2=ORALPHA
SET GMTSNDM=ORMAX
+10 KILL ^TMP("ORDATA",$JOB)
+11 ;get all diet information. Returned in ^UTILITY($J)
DO ^FHWHEA
+12 ;no data to report for type selected
IF '$DATA(^UTILITY($JOB,ORTYPE))
QUIT
+13 SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+14 SET ORDT=0
+15 FOR
SET ORDT=$ORDER(^UTILITY($JOB,ORTYPE,ORDT))
IF ORDT=""
QUIT
Begin DoDot:1
+16 SET SITE=$SELECT($LENGTH($GET(^UTILITY($JOB,ORTYPE,ORDT,"facility"))):^("facility"),1:ORSITE)
+17 ;Station ID
SET ^TMP("ORDATA",$JOB,ORDT,"WP",1)="1^"_SITE
+18 ;date
SET ^TMP("ORDATA",$JOB,ORDT,"WP",2)="2^"_$$DATE^ORDVU($PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^"))
+19 SET ^TMP("ORDATA",$JOB,ORDT,"WP",3)="3^"_$SELECT(ORTYPE="NS":$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",2),1:$$DATE^ORDVU($PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",2)))
+20 ;no more data required for NS
IF ORTYPE="NS"
QUIT
+21 SET ^TMP("ORDATA",$JOB,ORDT,"WP",4)="4^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",3)
+22 SET ^TMP("ORDATA",$JOB,ORDT,"WP",5)="5^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",4)
+23 SET ^TMP("ORDATA",$JOB,ORDT,"WP",6)="6^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",5)
+24 IF ORTYPE'="TF"
QUIT
+25 ;Get remaining data for tube feedings
+26 SET ^TMP("ORDATA",$JOB,ORDT,"WP",7)="7^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",6)
+27 SET ^TMP("ORDATA",$JOB,ORDT,"WP",8)="8^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",7)
+28 SET ^TMP("ORDATA",$JOB,ORDT,"WP",9)="9^"_$PIECE(^UTILITY($JOB,ORTYPE,ORDT,0),"^",8)
End DoDot:1
+29 KILL ^UTILITY($JOB)
+30 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+31 QUIT
+32 ;
DEM(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ; ADT Demographics
+1 ; External calls to VASITE, VADPT, and ^DGSL(38.1
+2 NEW VADM,VAPA,VAOA,ORSITE,SITE,I,ORDAT,ORETHN,ORRACE
SET (ORETHN,ORRACE)=""
+3 KILL ^TMP("ORDATA",$JOB)
+4 DO 4^VADPT
DO OAD^VADPT
+5 ; Quit if error in data gathering, otherwise get
+6 ; demographic/address information as well as next
+7 ; of kin addres
+8 IF VAERR
QUIT
+9 SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+10 SET SITE=ORSITE
+11 ; 1 Site
+12 SET ^TMP("ORDATA",$JOB,1,"WP",1)="1^"_SITE
+13 ; 2 Patient Name
+14 SET ^TMP("ORDATA",$JOB,1,"WP",2)="2^"_VADM(1)
+15 ; 3 SSN
+16 SET ^TMP("ORDATA",$JOB,1,"WP",3)="3^"_$PIECE(VADM(2),"^")
+17 ; 4 Sex
+18 SET ^TMP("ORDATA",$JOB,1,"WP",4)="4^"_$PIECE(VADM(5),"^",2)
+19 ; 5 Date of Birth
+20 SET ^TMP("ORDATA",$JOB,1,"WP",5)="5^"_$$DATE^ORDVU($PIECE(VADM(3),"^"))
+21 ; 6 Religion
+22 SET ^TMP("ORDATA",$JOB,1,"WP",6)="6^"_$PIECE(VADM(9),"^",2)
+23 ; 7 Marital Status
+24 SET ^TMP("ORDATA",$JOB,1,"WP",7)="7^"_$PIECE(VADM(10),"^",2)
+25 ; 8 Phone Number
+26 SET ^TMP("ORDATA",$JOB,1,"WP",8)="8^"_VAPA(8)
+27 ; 9 Street Address (1-3), City, State, and ZIP
+28 SET ^TMP("ORDATA",$JOB,1,"WP",9,1)="9^"_VAPA(1)
IF $PIECE(^(1),"^",2)=""
KILL ^(1)
+29 SET ^TMP("ORDATA",$JOB,1,"WP",9,2)="9^"_VAPA(2)
IF $PIECE(^(2),"^",2)=""
KILL ^(2)
+30 SET ^TMP("ORDATA",$JOB,1,"WP",9,3)="9^"_VAPA(3)
IF $PIECE(^(3),"^",2)=""
KILL ^(3)
+31 SET ^TMP("ORDATA",$JOB,1,"WP",9,4)="9^"_VAPA(4)_$SELECT($GET(VAPA(4))'="":", ",1:"")_$PIECE(VAPA(5),"^",2)_" "_VAPA(6)
+32 ; 11 Ethnicity
+33 SET I=0
FOR
SET I=$ORDER(VADM(11,I))
IF +I=0
QUIT
Begin DoDot:1
+34 SET ORDAT=$PIECE(VADM(11,I),"^",2)
IF '$LENGTH(ORDAT)
QUIT
+35 SET ORETHN=$GET(ORETHN)_", "_ORDAT
+36 SET ^TMP("ORDATA",$JOB,1,"WP",11,I)="11^"_ORDAT
End DoDot:1
+37 ; 10 Race
+38 IF $LENGTH(ORETHN)
SET ^TMP("ORDATA",$JOB,1,"WP",10,1)="10^"
+39 SET I=0
FOR
SET I=$ORDER(VADM(12,I))
IF +I=0
QUIT
Begin DoDot:1
+40 SET ORDAT=$PIECE($GET(VADM(12,I)),"^",2)
IF '$LENGTH(ORDAT)
QUIT
+41 SET ORRACE=$GET(ORRACE)_", "_ORDAT
+42 SET ^TMP("ORDATA",$JOB,1,"WP",10,I)="10^"_ORDAT
End DoDot:1
+43 SET ORRACE=$PIECE(ORRACE,", ",2,$LENGTH(ORRACE,", "))
+44 IF '$LENGTH($PIECE($GET(^TMP("ORDATA",$JOB,1,"WP",11,1)),"^",2))
Begin DoDot:1
+45 IF '$LENGTH($PIECE($GET(^TMP("ORDATA",$JOB,1,"WP",10,1)),"^",2))
Begin DoDot:2
+46 SET ^TMP("ORDATA",$JOB,1,"WP",11,1)="11^"
+47 SET ^TMP("ORDATA",$JOB,1,"WP",10,1)="10^"_$PIECE($GET(VADM(8)),"^",2)
End DoDot:2
End DoDot:1
+48 SET ORETHN=$PIECE(ORETHN,", ",2,$LENGTH(ORETHN,", "))
+49 ; 12 Next of Kin
+50 SET ^TMP("ORDATA",$JOB,1,"WP",12)="12^"_VAOA(9)
+51 ; 13 Next of Kin Relationship
+52 SET ^TMP("ORDATA",$JOB,1,"WP",13)="13^"_VAOA(10)
+53 ; 14 NOK Street Address (1-3), City, State, and ZIP
+54 SET ^TMP("ORDATA",$JOB,1,"WP",14,1)="14^"_VAOA(1)
IF $PIECE(^(1),"^",2)=""
KILL ^(1)
+55 SET ^TMP("ORDATA",$JOB,1,"WP",14,2)="14^"_VAOA(2)
IF $PIECE(^(2),"^",2)=""
KILL ^(2)
+56 SET ^TMP("ORDATA",$JOB,1,"WP",14,3)="14^"_VAOA(3)
IF $PIECE(^(3),"^",2)=""
+57 SET ^TMP("ORDATA",$JOB,1,"WP",14,4)="14^"_VAOA(4)_$SELECT($GET(VAOA(4))'="":", ",1:"")_$PIECE(VAOA(5),"^",2)_" "_VAOA(6)
+58 ; 15 Security Log
+59 SET ^TMP("ORDATA",$JOB,1,"WP",15)="15^"_$SELECT($PIECE($GET(^DGSL(38.1,DFN,0)),"^",2):"YES",1:"NO")
+60 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+61 QUIT
ICDSUR(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return ICD Surgery Information
+1 ;External calls to VASITE, GMTSDGP
+2 NEW ORSITE,SITE,T1,T2,I,J,GMS,PTF,ORDATE
+3 KILL ^TMP("ORDATA",$JOB)
+4 SET T1=ORDEND
SET T2=ORDBEG
SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+5 FOR PTF=0:0
SET PTF=$ORDER(^DGPT("B",DFN,PTF))
IF PTF=""
QUIT
DO ICDS^GMTSDGP
+6 SET (I,ORDATE)=0
+7 FOR
SET ORDATE=$ORDER(GMS(ORDATE))
IF ORDATE=""!(I'<ORMAX)
QUIT
SET J=0
Begin DoDot:1
+8 ;Check for multiple procedures on same date
FOR
SET J=$ORDER(GMS(ORDATE,J))
IF 'J!(I'<ORMAX)
QUIT
SET I=I+1
Begin DoDot:2
+9 SET SITE=$SELECT($LENGTH($GET(GMS(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
+10 SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,1)="1^"_SITE
+11 ;Date of procedure
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($PIECE(GMS(ORDATE)," ",3))
+12 ;Surgery and code
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,3)="3^"_$PIECE($GET(GMS(ORDATE,J)),"^")
+13 ;ICD code
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,4)="4^"_$PIECE(GMS(ORDATE,J),"^",2)
End DoDot:2
End DoDot:1
+14 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+15 QUIT
PRC(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Procedure Information
+1 ;External calls to VASITE, GMTSDGP
+2 NEW ORSITE,SITE,T1,T2,I,J,GMP,PTF,ORDATE
+3 KILL ^TMP("ORDATA",$JOB)
+4 SET T1=ORDEND
SET T2=ORDBEG
SET PTF=0
SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
+5 FOR
SET PTF=$ORDER(^DGPT("B",DFN,PTF))
IF PTF=""
QUIT
DO ICDP^GMTSDGP
+6 SET (I,ORDATE)=0
+7 FOR
SET ORDATE=$ORDER(GMP(ORDATE))
IF ORDATE=""!(I'<ORMAX)
QUIT
SET J=0
Begin DoDot:1
+8 ;Check for multiple procedures on same date
FOR
SET J=$ORDER(GMP(ORDATE,J))
IF 'J!(I'<ORMAX)
QUIT
SET I=I+1
Begin DoDot:2
+9 SET SITE=$SELECT($LENGTH($GET(GMP(ORDATE,J,"facility"))):^("facility"),1:ORSITE)
+10 SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,1)="1^"_SITE
+11 ;Date of procedure
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,2)="2^"_$$DATEMMM^ORDVU($PIECE(GMP(ORDATE)," ",2))
+12 ;Procedure and code
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,3)="3^"_$PIECE($GET(GMP(ORDATE,J)),"^")
+13 ;ICD code
SET ^TMP("ORDATA",$JOB,"WP",ORDATE,J,4)="4^"_$PIECE(GMP(ORDATE,J),"^",2)
End DoDot:2
End DoDot:1
+14 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+15 QUIT
INS(ROOT,ORALPHA,OROMEGA,ORMAX,ORDBEG,ORDEND,OREXT) ;Return Insurance Information
+1 ;External calls to VASITE and IBCNS1 and ^DIC(36, and ^IBE(355.1
+2 NEW ORSITE,SITE,ORARRAY,I
+3 KILL ^TMP("ORDATA",$JOB)
+4 DO ALL^IBCNS1(DFN,"ORARRAY")
+5 ;quit if no insurance data returned
IF '$DATA(ORARRAY)
QUIT
+6 SET ORSITE=$$SITE^VASITE
SET ORSITE=$PIECE(ORSITE,"^",2)_";"_$PIECE(ORSITE,"^",3)
SET I=0
+7 FOR
SET I=$ORDER(ORARRAY(I))
IF 'I
QUIT
Begin DoDot:1
+8 SET SITE=$SELECT($LENGTH($GET(ORARRAY(I,"facility"))):^("facility"),1:ORSITE)
+9 SET ^TMP("ORDATA",$JOB,"WP",I,1)="1^"_SITE
+10 ;Insurance company
SET ^TMP("ORDATA",$JOB,"WP",I,2)="2^"_$PIECE($GET(^DIC(36,+$PIECE(ORARRAY(I,0),"^"),0)),"^")
+11 ;Policy type
SET ^TMP("ORDATA",$JOB,"WP",I,3)="3^"_$PIECE($GET(^IBE(355.1,+$PIECE(ORARRAY(I,355.3),"^",9),0)),"^")
+12 ;Group number
SET ^TMP("ORDATA",$JOB,"WP",I,4)="4^"_$PIECE(ORARRAY(I,355.3),"^",4)
+13 ;Policy holder
SET ^TMP("ORDATA",$JOB,"WP",I,5)="5^"_$SELECT($PIECE(ORARRAY(I,0),"^",6)="s":"SPOUSE",$PIECE(ORARRAY(I,0),"^",6)="v":"SELF",1:"OTHER")
+14 ;Effective date of policy
SET ^TMP("ORDATA",$JOB,"WP",I,6)="6^"_$$DATE^ORDVU($PIECE(ORARRAY(I,0),"^",8))
+15 ;Expiration date of policy
SET ^TMP("ORDATA",$JOB,"WP",I,7)="7^"_$$DATE^ORDVU($PIECE(ORARRAY(I,0),"^",4))
End DoDot:1
+16 SET ROOT=$NAME(^TMP("ORDATA",$JOB))
+17 QUIT