ECXUTL4 ;ALB/ESD - Utilities for DSS Extracts ;4/24/19 09:44
;;3.0;DSS EXTRACTS;**39,41,46,49,78,92,105,112,120,127,154,170,174,178,181**;Dec 22,1997;Build 71
;
OBSPAT(ECXIO,ECXTS,DSSID) ;
; Get observation patient indicator from DSS TREATING SPECIALTY
; TRANSLATION file (#727.831) or DSS Identifier
;
; Input:
; ECXIO - Inpatient/Outpatient indicator
; ECXTS - Treating specialty (from file #42.4)
; DSSID - DSS Identifier
;
;Output:
; ECXOBS - Observation patient indicator (YES/NO)
;
;- Check input vars
S ECXIO=$G(ECXIO),ECXTS=+$G(ECXTS),DSSID=+$G(DSSID)
S ECXOBS=""
D
.;- Look up obs patient indicator if treating spec is in file #727.831
. I $G(^ECX(727.831,ECXTS,0)) S ECXOBS=$P($G(^ECX(727.831,ECXTS,0)),"^",4)
. I ECXOBS'="" S ECXOBS=$S(ECXOBS="Y":"YES",1:"NO") Q
.;
.;- If outpatient and TS not in file, AND Feeder Key (CLI) or DSS ID
.;- (MTL,IVP,ECQ,QSR,NOS,SUR) is 290-297, Observation Patient Ind=YES
. I ECXIO="O",ECXOBS="",DSSID D
.. I $E(DSSID,1,3)>289&($E(DSSID,1,3)<298) S ECXOBS="YES"
.. E S ECXOBS="NO"
Q $S(ECXOBS'="":ECXOBS,1:"NO")
;
INOUTP(ECXTS) ;
; Get inpatient/outpatient indicator from DSS TREATING SPECIALTY
; TRANSLATION file (#727.831)
;
; Input:
; ECXTS - Treating specialty
;
; Output:
; Inpatient/Outpatient indicator (I/O)
;
S ECXTS=+$G(ECXTS)
S ECXIO=""
;
;- Look up inpat/outpat indicator if treating spec is in file
I $G(^ECX(727.831,ECXTS,0)) S ECXIO=$P($G(^ECX(727.831,ECXTS,0)),"^",5)
Q $S(ECXIO'="":ECXIO,1:"I")
;
ENCNUM(ECXIO,ECXSSN,ECXADT,ECXVDT,ECXTRT,ECXOBS,ECXEXT,ECXSTP,ECXSTP2) ;
; Get encounter number
;
; Input:
; ECXIO - Inpat/Outpat indicator = I or O
; ECXSSN - Patient SSN
; ECXADT - Admit Date
; ECXVDT - Visit Date
; ECXTRT - Treating Spec
; ECXOBS - Observation Pat Indicator
; ECXEXT - Extract
; ECXSTP - Stop Code (or stop code related) variable
; ECXSTP2 - Stop Code (or stop code related) addtl variable
; (used for SUR and ECS)
;
;Output:
; Encounter Number
;
N ENCNUM,ECXDATE,ECXSTCD
S (ENCNUM,ECXSTCD)=""
;
;- Check input vars
S ECXEXT=$G(ECXEXT),ECXIO=$G(ECXIO),ECXOBS=$G(ECXOBS),ECXTRT=+$G(ECXTRT)
S:ECXEXT'="ECS"&(ECXEXT'="ECQ") ECXSTP=+$G(ECXSTP) S ECXSTP2=+$G(ECXSTP2) ;154 Allow stop code/DSS ID for ECS&ECQ to be non-numeric
S ECXADT=+$G(ECXADT),ECXVDT=+$G(ECXVDT)
;
;- Don't use pseudo-SSN in encounter number
S ECXSSN=$E($G(ECXSSN),1,9)
;
D
. ;- Inpatient
. I ECXIO="I",ECXADT,ECXSSN'="" D Q
.. S ECXDATE=$$ADMITDT(ECXADT)
.. I ECXDATE'="" S ENCNUM=ECXSSN_ECXDATE_"I"
. ;
. ;- Outpatient branch
. I ECXIO="O" D
.. ;- Observation patient (outpatient)
.. I ECXOBS="YES",ECXSSN'="" D Q
... ;
... S ECXDATE=$S(ECXADT:$$JULDT(ECXADT),1:$$JULDT(ECXVDT))
... S ECXSTCD=$S(+$P($G(^ECX(727.831,ECXTRT,0)),"^",6):+$P($G(^ECX(727.831,ECXTRT,0)),"^",6),1:+$E(ECXSTP,1,3))
... Q:ECXDATE=""!(ECXSTCD="")
... S ENCNUM=ECXSSN_ECXDATE_ECXSTCD
.. ;
.. ;- Outpatient (no observation pat)
.. I ECXOBS="NO",ECXVDT,ECXSSN'="" D Q
... ;
... ;- ADM, MOV, TRT have no outpat encounter number
... I ECXEXT="ADM"!(ECXEXT="MOV")!(ECXEXT="TRT") Q
... ;
... ;- Use 1st 3 chars of DSS ID for NOS (feeder key for CLI)
... I ECXEXT="CLI"!(ECXEXT="NOS") S ECXSTCD=+$E(ECXSTP,1,3) Q:'ECXSTCD
... ;
... ;- 154, For ECS remove cost center conversion. For ECS and ECQ set stop code to first 3 characters of ECXSTP
... I ECXEXT="ECS"!(ECXEXT="ECQ") S ECXSTCD=$E(ECXSTP,1,3) ;154
... ;
... ;- These extracts have predetermined stop code values
... I ECXEXT="DEN" S ECXSTCD=180
... I ECXEXT="UDP"!(ECXEXT="PRE") S ECXSTCD="PHA" ;170
... ;I ECXEXT="IVP" S ECXSTCD=$S(ECXSTP=0:"PHA","^AN100^AN200^AN300^AN400^AN500^AN600^AN700^AN900^OP900^"[("^"_$G(ECVACL)_"^"):$E(ECXSTP,1,3),1:"PHA") ;170 Set stop code for IVP
... I ECXEXT="IVP" D ;170 Set stop code for IVP
.... N DRUGCLAS,DRUGSTCD
.... S DRUGCLAS="^AN100^AN200^AN300^AN400^AN500^AN600^AN700^AN900^OP900^" ;List of Chemo Drugs
.... S DRUGSTCD="^308^316^329^330^407^" ; List of MCAO-defined Stop Code for patch 178, 181 - Remove 153 from the list
.... ;Only set the ECXSTP variable to the Ordering Stop Code for Chemo drugs ordered from this range
.... S ECXSTCD=$S(ECXSTP=0:"PHA",DRUGCLAS[("^"_ECVACL_"^"):$S(DRUGSTCD[("^"_ECXSTP_"^"):$E(ECXSTP,1,3),1:"PHA"),1:"PHA") ;170;178
... I ECXEXT="LAB"!(ECXEXT="LAR")!(ECXEXT="LBB") S ECXSTCD=108
... I ECXEXT="MTL" S ECXSTCD=538
... I ECXEXT="NUR" S ECXSTCD=950
... I ECXEXT="PRO" S ECXSTCD=423
... I ECXEXT="NUT" S ECXSTCD="NUT"
... I ECXEXT="BCM" S ECXSTCD="BCM"
... ;
... ;- If Imaging Type fld=2, use 109 otherwise use 105
... I ECXEXT="RAD" S ECXSTCD=$S(ECXSTP=2:109,1:105)
... ;
... ;- Use STOP CODE fld if populated or if non-OR procedure use 435
... ;- otherwise if null use 429
... I ECXEXT="SUR" S ECXSTCD=$S(ECXSTP:ECXSTP,$P($G(ECNO),U)="Y":435,1:429) ;174 If no stop code, default to 435 for non-OR procedure else 429
... ;
... ;- Get Julian Date
... S ECXDATE=$$JULDT(ECXVDT)
... I ECXDATE'="" S ENCNUM=ECXSSN_ECXDATE_ECXSTCD
Q ENCNUM
;
ADMITDT(ECXINDT) ; Returns date in YYMMDD format
;
; Input:
; ECXINDT - Date (can also include time) in internal FM format
;
;Output:
; Date in YYMMDD form
;
N ECXDT
S ECXDT=""
S ECXINDT=+$G(ECXINDT)
;
;- If no input or full FM date not passed in, quit
I 'ECXINDT!($L(ECXINDT)<7) G ADMTDTQ
;
;- Date in YYMMDD form
S ECXDT=$TR($$FMTE^XLFDT(ECXINDT,"4DF")," /","0")
ADMTDTQ Q ECXDT
;
;
JULDT(ECXINDT) ; Returns Julian Date in MMDDD format
;
; Input:
; ECINDT - Date (can also include time) in internal FM format
;
;Output:
; Julian date in MM_DDD form
;
N ECXDDD,ECXDT,ECXJUL,ECXMM
S (ECXDDD,ECXMM)=""
;
;- If no input or full FM date not passed in, quit
S ECXINDT=+$G(ECXINDT)
I 'ECXINDT!($L(ECXINDT)<7) G JULDTQ
;
;- Extract date portion
S ECXDT=$E(ECXINDT,1,7)
;
;- Get month (MM)
S ECXMM=$E(ECXINDT,2,3)
;
;- Number of day within year (DDD)
S ECXDDD=$$RJ^XLFSTR($$FMDIFF^XLFDT(ECXDT,$E(ECXDT,1,3)_"0101",1)+1,3,"0")
JULDTQ Q ECXMM_ECXDDD
;
CNHSTAT(ECXDFN) ; Get CNH (Contract Nursing Home) status
;
; Input:
; ECXDFN - Patient DFN
;
;Output:
; CNH status (YES/NO)
;
N ECXCNH
S ECXDFN=+$G(ECXDFN)
S ECXCNH=$P($G(^DPT(ECXDFN,"NHC")),U)
Q $S(ECXCNH="Y":"YES",ECXCNH="N":"NO",1:"")
;
CANC(ECXNOR,ECXTMOR) ; Get Surgery Cancelled/Aborted Status
;
; Function called after determining CANCEL DATE in SURGERY record exists
;
; Input:
; ECXNOR - Non-OR DSS ID
; ECXTMOR - Time Pat in OR
;
;Output:
; Cancelled/aborted status (C/A)
;
N ECXCANC
S ECXCANC=""
S ECXNOR=$G(ECXNOR)
;
;- If Non-OR DSS ID or Time Pat in OR, ECXCANC = "A" else = "C"
D
. I ECXNOR'=""&(ECXNOR'="UNKNOWN") S ECXCANC="A" Q
. I +$G(ECXTMOR) S ECXCANC="A" Q
. S ECXCANC="C"
Q ECXCANC
;
HNCI(ECXDFN) ; Get head & neck cancer indicator
;
; Input:
; ECXDFN - Patient DFN
;
;Output:
; Head/Neck CA DX (Y/N)
;
N ECXHNCI,DGNT
S ECXHNCI=""
S ECXDFN=+$G(ECXDFN) I ECXDFN D
.I $$GETCUR^DGNTAPI(ECXDFN,"DGNT") S ECXHNCI=$P(DGNT("HNC"),U)
Q ECXHNCI
;
TSMAP(ECXTS) ;Determines DSS Identifier for the following observation
; treating specialty
; Input:
; ECXTS - Observation Treating Specialty
;
; Output:
; DSS Identifier (Stop Code)
;
N TS,SC,I
S TS="^18^23^24^41^65^94^108^",SC="^293^295^290^296^291^292^297^"
F I=1:1:$L(TS) Q:$P(TS,"^",I)=ECXTS
Q $P(SC,"^",I)_"000"
OEFDATA ;
;get patient OEF/OIF status and date of return
S (ECXOEF,ECXOEFDT)=""
I $G(VASV(11))>0 S ECXOEF=ECXOEF_"OIF"
I $G(VASV(12))>0 S ECXOEF=ECXOEF_"OEF"
I $G(VASV(13))>0 S ECXOEF=ECXOEF_"UNK"
I ECXOEF'="" D
. S ECXOEFDT=""
. I $G(VASV(11))>0 S ECXOEFDT=$P($G(VASV(11,$G(VASV(11)),3)),"^")
. I $G(VASV(12))>0,$P($G(VASV(12,$G(VASV(12)),3)),"^")>ECXOEFDT S ECXOEFDT=$P($G(VASV(12,$G(VASV(12)),3)),"^")
. I $G(VASV(13))>0,$P($G(VASV(13,$G(VASV(13)),3)),"^")>ECXOEFDT S ECXOEFDT=$P($G(VASV(13,$G(VASV(13)),3)),"^")
. I ECXOEFDT>0 S ECXOEFDT=17000000+ECXOEFDT
;
S ECXPAT("ECXOEF")=ECXOEF
S ECXPAT("ECXOEFDT")=ECXOEFDT
Q
;
SHAD(ECXDFN) ; Get PROJ 112/SHAD indicator
;
; Input:
; ECXDFN - Patient DFN
;
;Output:
; PROJ 112/SHAD DX (Y/N/U)
; Error -1, missing parameter
;
N ECXSHAD
S ECXDFN=$G(ECXDFN)
S ECXSHAD=$$GETSHAD^DGUTL3(ECXDFN)
S ECXSHAD=$S(ECXSHAD=1:"Y",ECXSHAD=0:"N",ECXSHAD="":"U",1:-1)
Q ECXSHAD
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECXUTL4 8730 printed Dec 13, 2024@01:54:26 Page 2
ECXUTL4 ;ALB/ESD - Utilities for DSS Extracts ;4/24/19 09:44
+1 ;;3.0;DSS EXTRACTS;**39,41,46,49,78,92,105,112,120,127,154,170,174,178,181**;Dec 22,1997;Build 71
+2 ;
OBSPAT(ECXIO,ECXTS,DSSID) ;
+1 ; Get observation patient indicator from DSS TREATING SPECIALTY
+2 ; TRANSLATION file (#727.831) or DSS Identifier
+3 ;
+4 ; Input:
+5 ; ECXIO - Inpatient/Outpatient indicator
+6 ; ECXTS - Treating specialty (from file #42.4)
+7 ; DSSID - DSS Identifier
+8 ;
+9 ;Output:
+10 ; ECXOBS - Observation patient indicator (YES/NO)
+11 ;
+12 ;- Check input vars
+13 SET ECXIO=$GET(ECXIO)
SET ECXTS=+$GET(ECXTS)
SET DSSID=+$GET(DSSID)
+14 SET ECXOBS=""
+15 Begin DoDot:1
+16 ;- Look up obs patient indicator if treating spec is in file #727.831
+17 IF $GET(^ECX(727.831,ECXTS,0))
SET ECXOBS=$PIECE($GET(^ECX(727.831,ECXTS,0)),"^",4)
+18 IF ECXOBS'=""
SET ECXOBS=$SELECT(ECXOBS="Y":"YES",1:"NO")
QUIT
+19 ;
+20 ;- If outpatient and TS not in file, AND Feeder Key (CLI) or DSS ID
+21 ;- (MTL,IVP,ECQ,QSR,NOS,SUR) is 290-297, Observation Patient Ind=YES
+22 IF ECXIO="O"
IF ECXOBS=""
IF DSSID
Begin DoDot:2
+23 IF $EXTRACT(DSSID,1,3)>289&($EXTRACT(DSSID,1,3)<298)
SET ECXOBS="YES"
+24 IF '$TEST
SET ECXOBS="NO"
End DoDot:2
End DoDot:1
+25 QUIT $SELECT(ECXOBS'="":ECXOBS,1:"NO")
+26 ;
INOUTP(ECXTS) ;
+1 ; Get inpatient/outpatient indicator from DSS TREATING SPECIALTY
+2 ; TRANSLATION file (#727.831)
+3 ;
+4 ; Input:
+5 ; ECXTS - Treating specialty
+6 ;
+7 ; Output:
+8 ; Inpatient/Outpatient indicator (I/O)
+9 ;
+10 SET ECXTS=+$GET(ECXTS)
+11 SET ECXIO=""
+12 ;
+13 ;- Look up inpat/outpat indicator if treating spec is in file
+14 IF $GET(^ECX(727.831,ECXTS,0))
SET ECXIO=$PIECE($GET(^ECX(727.831,ECXTS,0)),"^",5)
+15 QUIT $SELECT(ECXIO'="":ECXIO,1:"I")
+16 ;
ENCNUM(ECXIO,ECXSSN,ECXADT,ECXVDT,ECXTRT,ECXOBS,ECXEXT,ECXSTP,ECXSTP2) ;
+1 ; Get encounter number
+2 ;
+3 ; Input:
+4 ; ECXIO - Inpat/Outpat indicator = I or O
+5 ; ECXSSN - Patient SSN
+6 ; ECXADT - Admit Date
+7 ; ECXVDT - Visit Date
+8 ; ECXTRT - Treating Spec
+9 ; ECXOBS - Observation Pat Indicator
+10 ; ECXEXT - Extract
+11 ; ECXSTP - Stop Code (or stop code related) variable
+12 ; ECXSTP2 - Stop Code (or stop code related) addtl variable
+13 ; (used for SUR and ECS)
+14 ;
+15 ;Output:
+16 ; Encounter Number
+17 ;
+18 NEW ENCNUM,ECXDATE,ECXSTCD
+19 SET (ENCNUM,ECXSTCD)=""
+20 ;
+21 ;- Check input vars
+22 SET ECXEXT=$GET(ECXEXT)
SET ECXIO=$GET(ECXIO)
SET ECXOBS=$GET(ECXOBS)
SET ECXTRT=+$GET(ECXTRT)
+23 ;154 Allow stop code/DSS ID for ECS&ECQ to be non-numeric
if ECXEXT'="ECS"&(ECXEXT'="ECQ")
SET ECXSTP=+$GET(ECXSTP)
SET ECXSTP2=+$GET(ECXSTP2)
+24 SET ECXADT=+$GET(ECXADT)
SET ECXVDT=+$GET(ECXVDT)
+25 ;
+26 ;- Don't use pseudo-SSN in encounter number
+27 SET ECXSSN=$EXTRACT($GET(ECXSSN),1,9)
+28 ;
+29 Begin DoDot:1
+30 ;- Inpatient
+31 IF ECXIO="I"
IF ECXADT
IF ECXSSN'=""
Begin DoDot:2
+32 SET ECXDATE=$$ADMITDT(ECXADT)
+33 IF ECXDATE'=""
SET ENCNUM=ECXSSN_ECXDATE_"I"
End DoDot:2
QUIT
+34 ;
+35 ;- Outpatient branch
+36 IF ECXIO="O"
Begin DoDot:2
+37 ;- Observation patient (outpatient)
+38 IF ECXOBS="YES"
IF ECXSSN'=""
Begin DoDot:3
+39 ;
+40 SET ECXDATE=$SELECT(ECXADT:$$JULDT(ECXADT),1:$$JULDT(ECXVDT))
+41 SET ECXSTCD=$SELECT(+$PIECE($GET(^ECX(727.831,ECXTRT,0)),"^",6):+$PIECE($GET(^ECX(727.831,ECXTRT,0)),"^",6),1:+$EXTRACT(ECXSTP,1,3))
+42 if ECXDATE=""!(ECXSTCD="")
QUIT
+43 SET ENCNUM=ECXSSN_ECXDATE_ECXSTCD
End DoDot:3
QUIT
+44 ;
+45 ;- Outpatient (no observation pat)
+46 IF ECXOBS="NO"
IF ECXVDT
IF ECXSSN'=""
Begin DoDot:3
+47 ;
+48 ;- ADM, MOV, TRT have no outpat encounter number
+49 IF ECXEXT="ADM"!(ECXEXT="MOV")!(ECXEXT="TRT")
QUIT
+50 ;
+51 ;- Use 1st 3 chars of DSS ID for NOS (feeder key for CLI)
+52 IF ECXEXT="CLI"!(ECXEXT="NOS")
SET ECXSTCD=+$EXTRACT(ECXSTP,1,3)
if 'ECXSTCD
QUIT
+53 ;
+54 ;- 154, For ECS remove cost center conversion. For ECS and ECQ set stop code to first 3 characters of ECXSTP
+55 ;154
IF ECXEXT="ECS"!(ECXEXT="ECQ")
SET ECXSTCD=$EXTRACT(ECXSTP,1,3)
+56 ;
+57 ;- These extracts have predetermined stop code values
+58 IF ECXEXT="DEN"
SET ECXSTCD=180
+59 ;170
IF ECXEXT="UDP"!(ECXEXT="PRE")
SET ECXSTCD="PHA"
+60 ;I ECXEXT="IVP" S ECXSTCD=$S(ECXSTP=0:"PHA","^AN100^AN200^AN300^AN400^AN500^AN600^AN700^AN900^OP900^"[("^"_$G(ECVACL)_"^"):$E(ECXSTP,1,3),1:"PHA") ;170 Set stop code for IVP
+61 ;170 Set stop code for IVP
IF ECXEXT="IVP"
Begin DoDot:4
+62 NEW DRUGCLAS,DRUGSTCD
+63 ;List of Chemo Drugs
SET DRUGCLAS="^AN100^AN200^AN300^AN400^AN500^AN600^AN700^AN900^OP900^"
+64 ; List of MCAO-defined Stop Code for patch 178, 181 - Remove 153 from the list
SET DRUGSTCD="^308^316^329^330^407^"
+65 ;Only set the ECXSTP variable to the Ordering Stop Code for Chemo drugs ordered from this range
+66 ;170;178
SET ECXSTCD=$SELECT(ECXSTP=0:"PHA",DRUGCLAS[("^"_ECVACL_"^"):$SELECT(DRUGSTCD[("^"_ECXSTP_"^"):$EXTRACT(ECXSTP,1,3),1:"PHA"),1:"PHA")
End DoDot:4
+67 IF ECXEXT="LAB"!(ECXEXT="LAR")!(ECXEXT="LBB")
SET ECXSTCD=108
+68 IF ECXEXT="MTL"
SET ECXSTCD=538
+69 IF ECXEXT="NUR"
SET ECXSTCD=950
+70 IF ECXEXT="PRO"
SET ECXSTCD=423
+71 IF ECXEXT="NUT"
SET ECXSTCD="NUT"
+72 IF ECXEXT="BCM"
SET ECXSTCD="BCM"
+73 ;
+74 ;- If Imaging Type fld=2, use 109 otherwise use 105
+75 IF ECXEXT="RAD"
SET ECXSTCD=$SELECT(ECXSTP=2:109,1:105)
+76 ;
+77 ;- Use STOP CODE fld if populated or if non-OR procedure use 435
+78 ;- otherwise if null use 429
+79 ;174 If no stop code, default to 435 for non-OR procedure else 429
IF ECXEXT="SUR"
SET ECXSTCD=$SELECT(ECXSTP:ECXSTP,$PIECE($GET(ECNO),U)="Y":435,1:429)
+80 ;
+81 ;- Get Julian Date
+82 SET ECXDATE=$$JULDT(ECXVDT)
+83 IF ECXDATE'=""
SET ENCNUM=ECXSSN_ECXDATE_ECXSTCD
End DoDot:3
QUIT
End DoDot:2
End DoDot:1
+84 QUIT ENCNUM
+85 ;
ADMITDT(ECXINDT) ; Returns date in YYMMDD format
+1 ;
+2 ; Input:
+3 ; ECXINDT - Date (can also include time) in internal FM format
+4 ;
+5 ;Output:
+6 ; Date in YYMMDD form
+7 ;
+8 NEW ECXDT
+9 SET ECXDT=""
+10 SET ECXINDT=+$GET(ECXINDT)
+11 ;
+12 ;- If no input or full FM date not passed in, quit
+13 IF 'ECXINDT!($LENGTH(ECXINDT)<7)
GOTO ADMTDTQ
+14 ;
+15 ;- Date in YYMMDD form
+16 SET ECXDT=$TRANSLATE($$FMTE^XLFDT(ECXINDT,"4DF")," /","0")
ADMTDTQ QUIT ECXDT
+1 ;
+2 ;
JULDT(ECXINDT) ; Returns Julian Date in MMDDD format
+1 ;
+2 ; Input:
+3 ; ECINDT - Date (can also include time) in internal FM format
+4 ;
+5 ;Output:
+6 ; Julian date in MM_DDD form
+7 ;
+8 NEW ECXDDD,ECXDT,ECXJUL,ECXMM
+9 SET (ECXDDD,ECXMM)=""
+10 ;
+11 ;- If no input or full FM date not passed in, quit
+12 SET ECXINDT=+$GET(ECXINDT)
+13 IF 'ECXINDT!($LENGTH(ECXINDT)<7)
GOTO JULDTQ
+14 ;
+15 ;- Extract date portion
+16 SET ECXDT=$EXTRACT(ECXINDT,1,7)
+17 ;
+18 ;- Get month (MM)
+19 SET ECXMM=$EXTRACT(ECXINDT,2,3)
+20 ;
+21 ;- Number of day within year (DDD)
+22 SET ECXDDD=$$RJ^XLFSTR($$FMDIFF^XLFDT(ECXDT,$EXTRACT(ECXDT,1,3)_"0101",1)+1,3,"0")
JULDTQ QUIT ECXMM_ECXDDD
+1 ;
CNHSTAT(ECXDFN) ; Get CNH (Contract Nursing Home) status
+1 ;
+2 ; Input:
+3 ; ECXDFN - Patient DFN
+4 ;
+5 ;Output:
+6 ; CNH status (YES/NO)
+7 ;
+8 NEW ECXCNH
+9 SET ECXDFN=+$GET(ECXDFN)
+10 SET ECXCNH=$PIECE($GET(^DPT(ECXDFN,"NHC")),U)
+11 QUIT $SELECT(ECXCNH="Y":"YES",ECXCNH="N":"NO",1:"")
+12 ;
CANC(ECXNOR,ECXTMOR) ; Get Surgery Cancelled/Aborted Status
+1 ;
+2 ; Function called after determining CANCEL DATE in SURGERY record exists
+3 ;
+4 ; Input:
+5 ; ECXNOR - Non-OR DSS ID
+6 ; ECXTMOR - Time Pat in OR
+7 ;
+8 ;Output:
+9 ; Cancelled/aborted status (C/A)
+10 ;
+11 NEW ECXCANC
+12 SET ECXCANC=""
+13 SET ECXNOR=$GET(ECXNOR)
+14 ;
+15 ;- If Non-OR DSS ID or Time Pat in OR, ECXCANC = "A" else = "C"
+16 Begin DoDot:1
+17 IF ECXNOR'=""&(ECXNOR'="UNKNOWN")
SET ECXCANC="A"
QUIT
+18 IF +$GET(ECXTMOR)
SET ECXCANC="A"
QUIT
+19 SET ECXCANC="C"
End DoDot:1
+20 QUIT ECXCANC
+21 ;
HNCI(ECXDFN) ; Get head & neck cancer indicator
+1 ;
+2 ; Input:
+3 ; ECXDFN - Patient DFN
+4 ;
+5 ;Output:
+6 ; Head/Neck CA DX (Y/N)
+7 ;
+8 NEW ECXHNCI,DGNT
+9 SET ECXHNCI=""
+10 SET ECXDFN=+$GET(ECXDFN)
IF ECXDFN
Begin DoDot:1
+11 IF $$GETCUR^DGNTAPI(ECXDFN,"DGNT")
SET ECXHNCI=$PIECE(DGNT("HNC"),U)
End DoDot:1
+12 QUIT ECXHNCI
+13 ;
TSMAP(ECXTS) ;Determines DSS Identifier for the following observation
+1 ; treating specialty
+2 ; Input:
+3 ; ECXTS - Observation Treating Specialty
+4 ;
+5 ; Output:
+6 ; DSS Identifier (Stop Code)
+7 ;
+8 NEW TS,SC,I
+9 SET TS="^18^23^24^41^65^94^108^"
SET SC="^293^295^290^296^291^292^297^"
+10 FOR I=1:1:$LENGTH(TS)
if $PIECE(TS,"^",I)=ECXTS
QUIT
+11 QUIT $PIECE(SC,"^",I)_"000"
OEFDATA ;
+1 ;get patient OEF/OIF status and date of return
+2 SET (ECXOEF,ECXOEFDT)=""
+3 IF $GET(VASV(11))>0
SET ECXOEF=ECXOEF_"OIF"
+4 IF $GET(VASV(12))>0
SET ECXOEF=ECXOEF_"OEF"
+5 IF $GET(VASV(13))>0
SET ECXOEF=ECXOEF_"UNK"
+6 IF ECXOEF'=""
Begin DoDot:1
+7 SET ECXOEFDT=""
+8 IF $GET(VASV(11))>0
SET ECXOEFDT=$PIECE($GET(VASV(11,$GET(VASV(11)),3)),"^")
+9 IF $GET(VASV(12))>0
IF $PIECE($GET(VASV(12,$GET(VASV(12)),3)),"^")>ECXOEFDT
SET ECXOEFDT=$PIECE($GET(VASV(12,$GET(VASV(12)),3)),"^")
+10 IF $GET(VASV(13))>0
IF $PIECE($GET(VASV(13,$GET(VASV(13)),3)),"^")>ECXOEFDT
SET ECXOEFDT=$PIECE($GET(VASV(13,$GET(VASV(13)),3)),"^")
+11 IF ECXOEFDT>0
SET ECXOEFDT=17000000+ECXOEFDT
End DoDot:1
+12 ;
+13 SET ECXPAT("ECXOEF")=ECXOEF
+14 SET ECXPAT("ECXOEFDT")=ECXOEFDT
+15 QUIT
+16 ;
SHAD(ECXDFN) ; Get PROJ 112/SHAD indicator
+1 ;
+2 ; Input:
+3 ; ECXDFN - Patient DFN
+4 ;
+5 ;Output:
+6 ; PROJ 112/SHAD DX (Y/N/U)
+7 ; Error -1, missing parameter
+8 ;
+9 NEW ECXSHAD
+10 SET ECXDFN=$GET(ECXDFN)
+11 SET ECXSHAD=$$GETSHAD^DGUTL3(ECXDFN)
+12 SET ECXSHAD=$SELECT(ECXSHAD=1:"Y",ECXSHAD=0:"N",ECXSHAD="":"U",1:-1)
+13 QUIT ECXSHAD