SDES2EPT ;ALB/LAB,ANU/BLB,MCB,TJB - SDES2 GET PATIENT'S ExtendedProfile APPT INFO ; JUL 12,2024
;;5.3;Scheduling;**861,867,877,880,886**;Aug 13, 1993;Build 13
;;Per VHA Directive 6402, this routine should not be modified
;
Q
;
; Documented API's and Integration Agreements
; -------------------------------------------
; Reference to INP^DGPMV10 supported by ICR #7035
; Reference to ELIG^VADPT supported by ICR #10061
; Reference to Patient File supported by ICR #7019
; #10035 - ^DPT( references (Supported)
;
; RPC: SDES2 GET PATIENT EPT
;
; SDCONTEXT("ACHERON AUDIT ID") = 36 character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
; SDCONTEXT("USER DUZ") = The DUZ of the user taking action on the calling application.
; SDCONTEXT("USER NAME") = The name of the user taking action on the calling application.
; SDCONTEXT("PATIENT DFN") = The DFN of the patient taking action on the calling application.
; SDCONTEXT("PATIENT ICN") = The ICN of the patient taking action on the calling application.
; SDINPUT("PATIENT DFN") = Patient to pull data for
;
Q
;
GETPTIN(JSONRETURN,SDCONTEXT,SDINPUT) ; Get Patient's ExtendedProfile Appt Info
N SDAPPTDT,SDDFN,SDERRORS,SDRETURN,VALRET
;
; Validate SDCONTEXT
;
D VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
I $D(SDERRORS) M SDRETURN=SDERRORS S SDRETURN("ExtendedProfile",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN) Q
; Checking DFN separately, since it's required for this RPC
D VALFILEIEN^SDES2VALUTIL(.VALRET,.SDERRORS,2,$G(SDINPUT("PATIENT DFN")),1,0,1,2)
I 'VALRET,$D(SDERRORS) M SDRETURN=SDERRORS S SDRETURN("ExtendedProfile",1)="" D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN) Q
S SDDFN=SDINPUT("PATIENT DFN")
;
;
; Retrieve Patient's ExtendedProfile Appt Info
;
D GETPTINA(.SDRETURN,SDDFN)
;
; Build JSON return
;
I '$D(SDRETURN) S SDRETURN("ExtendedProfile",1)=""
D BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
Q
;
GETPTINA(SDRETURN,SDDFN) ;
N SDCOUNT,SDRESULT,PATIENTDATA,SDPOS,SDPOSN,SDCMBTV,SDCMBTVED,SDPOW,SDSW,DFN,VASV
N SDSTAT,SDST,SDSTA,SDLADMT,SDA,VAEL,RADEXP,PROJ112,AOEXP,AOEXPLOC
; Variables from VADPT and DGPMV10 becaused they leaked into this routine
N %,%I,%H,X,Y,VAERR,DGPMVI,DGPMDCD,DIERR,I
S SDCOUNT=1
S DFN=SDDFN
; .323 - Period of Service
D ELIG^VADPT,SVC^VADPT
S SDRETURN("ExtendedProfile",SDCOUNT,"Period of Service IEN")=$P(VAEL(2),U,1)
S SDRETURN("ExtendedProfile",SDCOUNT,"Period of Service Name")=$P(VAEL(2),U,2)
;
D GETS^DIQ(2,SDDFN,".01;.135;.525;.32102;.3213;.32103;.322013;.32115","IE","PATIENTDATA")
S SDRETURN("ExtendedProfile",SDCOUNT,"DFN")=SDDFN
S SDRETURN("ExtendedProfile",SDCOUNT,"Name")=$G(PATIENTDATA(2,SDDFN_",",.01,"E"))
;
; radiation exposure
S RADEXP=$G(PATIENTDATA(2,SDDFN_",",.32103,"I"))
S RADEXP=$S(RADEXP="Y":"Yes",RADEXP="N":"No",RADEXP="U":"Unknown",1:"")
S SDRETURN("ExtendedProfile",SDCOUNT,"Radiation Exposure")=RADEXP
;
; proj 112 shad
S PROJ112=$G(PATIENTDATA(2,SDDFN_",",.32115,"I"))
S PROJ112=$S(PROJ112=1:"Yes",PROJ112=0:"No",1:"")
S SDRETURN("ExtendedProfile",SDCOUNT,"Proj 112 Shad")=PROJ112
;
; agent orange
S AOEXP=$G(PATIENTDATA(2,SDDFN_",",.32102,"I"))
S AOEXPLOC=$G(PATIENTDATA(2,SDDFN_",",.3213,"E"))
S AOEXP=$S(AOEXP="Y":"Yes",AOEXP="N":"No",AOEXP="U":"Unknown",1:"")
S SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure")=AOEXP
;
I AOEXP'="Yes" S SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure Location")=""
I AOEXP="Yes" S SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure Location")=AOEXPLOC
;
; last discharge
D INP^DGPMV10
S SDRETURN("ExtendedProfile",SDCOUNT,"Last Discharge Date")=$$FMTISO^SDAMUTDT($$GET1^DIQ(405,$G(DGPMVI(17)),.01,"I"))
;
;
; COMBAT VETERAN
I $G(VASV(5)) D
. S SDCMBTV="Yes"
. S SDCMBTVED=$P($G(VASV(5,2)),U,2) ; =$$FMTISO^SDAMUTDT($$CONVDATE^SDESCOMPPEN($G(SDCMBTVED)))
I '$G(VASV(5)) D
. S SDCMBTV="No"
. S SDCMBTVED="N/A"
S SDRETURN("ExtendedProfile",SDCOUNT,"Combat Veteran")=$G(SDCMBTV)
S SDRETURN("ExtendedProfile",SDCOUNT,"Combat Veteran End Date")=$G(SDCMBTVED)
;
; PRISONER OF WAR - VADPT is not handling Unknown value
I $G(PATIENTDATA(2,SDDFN_",",.525,"I"))="Y" S SDPOW="Yes"
I $G(PATIENTDATA(2,SDDFN_",",.525,"I"))="N" S SDPOW="No"
I $G(PATIENTDATA(2,SDDFN_",",.525,"I"))="U" S SDPOW="Unknown"
S SDRETURN("ExtendedProfile",SDCOUNT,"Prisoner of War")=$G(SDPOW)
;
; PAGER NUMBER
S SDRETURN("ExtendedProfile",SDCOUNT,"Pager Number")=$G(PATIENTDATA(2,SDDFN_",",.135,"I"))
; SW ASIA CONDITIONS
I $G(PATIENTDATA(2,SDDFN_",",.322013,"I"))="Y" S SDSW="Yes"
I $G(PATIENTDATA(2,SDDFN_",",.322013,"I"))="N" S SDSW="No"
I $G(PATIENTDATA(2,SDDFN_",",.322013,"I"))="U" S SDSW="Unknown"
S SDRETURN("ExtendedProfile",SDCOUNT,"SW Asia Conditions")=$G(SDSW)
; STATUS, LAST ADMIT/LODGER DATE
S (SDLADMT,SDSTAT,SDST,SDSTA,SDA)=""
S SDRETURN("ExtendedProfile",SDCOUNT,"Status")=$G(SDSTAT)
S SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$G(SDLADMT)
I '$D(^DGPM("C",SDDFN)) S SDSTAT="NO INPT./LOD. ACT." Q
;
S VAIP("D")="L",VAIP("L")="" D INP^DGPMV10
S SDA=$S("^3^5^"[("^"_+DGPMVI(2)_"^"):0,1:+DGPMVI(2)),SDST=$S('SDA:"IN",1:"")_"ACTIVE ",SDSTA=$S("^4^5^"[("^"_+DGPMVI(2)_"^"):"LODGER",1:"INPATIENT")
S SDSTAT="" S SDSTAT=SDST_SDSTA
S SDLADMT="" S SDLADMT=$P($G(DGPMVI(13,1)),"^",2)
S SDRETURN("ExtendedProfile",SDCOUNT,"Status")=$G(SDSTAT)
;867
;S SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$G(SDLADMT)
S SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$$FMTISO^SDAMUTDT($$CONVDATE^SDESCOMPPEN($G(SDLADMT)))
K DGPMVI,VAIP
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HSDES2EPT 5711 printed Oct 16, 2024@18:54:22 Page 2
SDES2EPT ;ALB/LAB,ANU/BLB,MCB,TJB - SDES2 GET PATIENT'S ExtendedProfile APPT INFO ; JUL 12,2024
+1 ;;5.3;Scheduling;**861,867,877,880,886**;Aug 13, 1993;Build 13
+2 ;;Per VHA Directive 6402, this routine should not be modified
+3 ;
+4 QUIT
+5 ;
+6 ; Documented API's and Integration Agreements
+7 ; -------------------------------------------
+8 ; Reference to INP^DGPMV10 supported by ICR #7035
+9 ; Reference to ELIG^VADPT supported by ICR #10061
+10 ; Reference to Patient File supported by ICR #7019
+11 ; #10035 - ^DPT( references (Supported)
+12 ;
+13 ; RPC: SDES2 GET PATIENT EPT
+14 ;
+15 ; SDCONTEXT("ACHERON AUDIT ID") = 36 character unique ID number. Ex: 11d9dcc6-c6a2-4785-8031-8261576fca37
+16 ; SDCONTEXT("USER DUZ") = The DUZ of the user taking action on the calling application.
+17 ; SDCONTEXT("USER NAME") = The name of the user taking action on the calling application.
+18 ; SDCONTEXT("PATIENT DFN") = The DFN of the patient taking action on the calling application.
+19 ; SDCONTEXT("PATIENT ICN") = The ICN of the patient taking action on the calling application.
+20 ; SDINPUT("PATIENT DFN") = Patient to pull data for
+21 ;
+22 QUIT
+23 ;
GETPTIN(JSONRETURN,SDCONTEXT,SDINPUT) ; Get Patient's ExtendedProfile Appt Info
+1 NEW SDAPPTDT,SDDFN,SDERRORS,SDRETURN,VALRET
+2 ;
+3 ; Validate SDCONTEXT
+4 ;
+5 DO VALCONTEXT^SDES2VALCONTEXT(.SDERRORS,.SDCONTEXT)
+6 IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
SET SDRETURN("ExtendedProfile",1)=""
DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
QUIT
+7 ; Checking DFN separately, since it's required for this RPC
+8 DO VALFILEIEN^SDES2VALUTIL(.VALRET,.SDERRORS,2,$GET(SDINPUT("PATIENT DFN")),1,0,1,2)
+9 IF 'VALRET
IF $DATA(SDERRORS)
MERGE SDRETURN=SDERRORS
SET SDRETURN("ExtendedProfile",1)=""
DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
QUIT
+10 SET SDDFN=SDINPUT("PATIENT DFN")
+11 ;
+12 ;
+13 ; Retrieve Patient's ExtendedProfile Appt Info
+14 ;
+15 DO GETPTINA(.SDRETURN,SDDFN)
+16 ;
+17 ; Build JSON return
+18 ;
+19 IF '$DATA(SDRETURN)
SET SDRETURN("ExtendedProfile",1)=""
+20 DO BUILDJSON^SDES2JSON(.JSONRETURN,.SDRETURN)
+21 QUIT
+22 ;
GETPTINA(SDRETURN,SDDFN) ;
+1 NEW SDCOUNT,SDRESULT,PATIENTDATA,SDPOS,SDPOSN,SDCMBTV,SDCMBTVED,SDPOW,SDSW,DFN,VASV
+2 NEW SDSTAT,SDST,SDSTA,SDLADMT,SDA,VAEL,RADEXP,PROJ112,AOEXP,AOEXPLOC
+3 ; Variables from VADPT and DGPMV10 becaused they leaked into this routine
+4 NEW %,%I,%H,X,Y,VAERR,DGPMVI,DGPMDCD,DIERR,I
+5 SET SDCOUNT=1
+6 SET DFN=SDDFN
+7 ; .323 - Period of Service
+8 DO ELIG^VADPT
DO SVC^VADPT
+9 SET SDRETURN("ExtendedProfile",SDCOUNT,"Period of Service IEN")=$PIECE(VAEL(2),U,1)
+10 SET SDRETURN("ExtendedProfile",SDCOUNT,"Period of Service Name")=$PIECE(VAEL(2),U,2)
+11 ;
+12 DO GETS^DIQ(2,SDDFN,".01;.135;.525;.32102;.3213;.32103;.322013;.32115","IE","PATIENTDATA")
+13 SET SDRETURN("ExtendedProfile",SDCOUNT,"DFN")=SDDFN
+14 SET SDRETURN("ExtendedProfile",SDCOUNT,"Name")=$GET(PATIENTDATA(2,SDDFN_",",.01,"E"))
+15 ;
+16 ; radiation exposure
+17 SET RADEXP=$GET(PATIENTDATA(2,SDDFN_",",.32103,"I"))
+18 SET RADEXP=$SELECT(RADEXP="Y":"Yes",RADEXP="N":"No",RADEXP="U":"Unknown",1:"")
+19 SET SDRETURN("ExtendedProfile",SDCOUNT,"Radiation Exposure")=RADEXP
+20 ;
+21 ; proj 112 shad
+22 SET PROJ112=$GET(PATIENTDATA(2,SDDFN_",",.32115,"I"))
+23 SET PROJ112=$SELECT(PROJ112=1:"Yes",PROJ112=0:"No",1:"")
+24 SET SDRETURN("ExtendedProfile",SDCOUNT,"Proj 112 Shad")=PROJ112
+25 ;
+26 ; agent orange
+27 SET AOEXP=$GET(PATIENTDATA(2,SDDFN_",",.32102,"I"))
+28 SET AOEXPLOC=$GET(PATIENTDATA(2,SDDFN_",",.3213,"E"))
+29 SET AOEXP=$SELECT(AOEXP="Y":"Yes",AOEXP="N":"No",AOEXP="U":"Unknown",1:"")
+30 SET SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure")=AOEXP
+31 ;
+32 IF AOEXP'="Yes"
SET SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure Location")=""
+33 IF AOEXP="Yes"
SET SDRETURN("ExtendedProfile",SDCOUNT,"Agent Orange Exposure Location")=AOEXPLOC
+34 ;
+35 ; last discharge
+36 DO INP^DGPMV10
+37 SET SDRETURN("ExtendedProfile",SDCOUNT,"Last Discharge Date")=$$FMTISO^SDAMUTDT($$GET1^DIQ(405,$GET(DGPMVI(17)),.01,"I"))
+38 ;
+39 ;
+40 ; COMBAT VETERAN
+41 IF $GET(VASV(5))
Begin DoDot:1
+42 SET SDCMBTV="Yes"
+43 ; =$$FMTISO^SDAMUTDT($$CONVDATE^SDESCOMPPEN($G(SDCMBTVED)))
SET SDCMBTVED=$PIECE($GET(VASV(5,2)),U,2)
End DoDot:1
+44 IF '$GET(VASV(5))
Begin DoDot:1
+45 SET SDCMBTV="No"
+46 SET SDCMBTVED="N/A"
End DoDot:1
+47 SET SDRETURN("ExtendedProfile",SDCOUNT,"Combat Veteran")=$GET(SDCMBTV)
+48 SET SDRETURN("ExtendedProfile",SDCOUNT,"Combat Veteran End Date")=$GET(SDCMBTVED)
+49 ;
+50 ; PRISONER OF WAR - VADPT is not handling Unknown value
+51 IF $GET(PATIENTDATA(2,SDDFN_",",.525,"I"))="Y"
SET SDPOW="Yes"
+52 IF $GET(PATIENTDATA(2,SDDFN_",",.525,"I"))="N"
SET SDPOW="No"
+53 IF $GET(PATIENTDATA(2,SDDFN_",",.525,"I"))="U"
SET SDPOW="Unknown"
+54 SET SDRETURN("ExtendedProfile",SDCOUNT,"Prisoner of War")=$GET(SDPOW)
+55 ;
+56 ; PAGER NUMBER
+57 SET SDRETURN("ExtendedProfile",SDCOUNT,"Pager Number")=$GET(PATIENTDATA(2,SDDFN_",",.135,"I"))
+58 ; SW ASIA CONDITIONS
+59 IF $GET(PATIENTDATA(2,SDDFN_",",.322013,"I"))="Y"
SET SDSW="Yes"
+60 IF $GET(PATIENTDATA(2,SDDFN_",",.322013,"I"))="N"
SET SDSW="No"
+61 IF $GET(PATIENTDATA(2,SDDFN_",",.322013,"I"))="U"
SET SDSW="Unknown"
+62 SET SDRETURN("ExtendedProfile",SDCOUNT,"SW Asia Conditions")=$GET(SDSW)
+63 ; STATUS, LAST ADMIT/LODGER DATE
+64 SET (SDLADMT,SDSTAT,SDST,SDSTA,SDA)=""
+65 SET SDRETURN("ExtendedProfile",SDCOUNT,"Status")=$GET(SDSTAT)
+66 SET SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$GET(SDLADMT)
+67 IF '$DATA(^DGPM("C",SDDFN))
SET SDSTAT="NO INPT./LOD. ACT."
QUIT
+68 ;
+69 SET VAIP("D")="L"
SET VAIP("L")=""
DO INP^DGPMV10
+70 SET SDA=$SELECT("^3^5^"[("^"_+DGPMVI(2)_"^"):0,1:+DGPMVI(2))
SET SDST=$SELECT('SDA:"IN",1:"")_"ACTIVE "
SET SDSTA=$SELECT("^4^5^"[("^"_+DGPMVI(2)_"^"):"LODGER",1:"INPATIENT")
+71 SET SDSTAT=""
SET SDSTAT=SDST_SDSTA
+72 SET SDLADMT=""
SET SDLADMT=$PIECE($GET(DGPMVI(13,1)),"^",2)
+73 SET SDRETURN("ExtendedProfile",SDCOUNT,"Status")=$GET(SDSTAT)
+74 ;867
+75 ;S SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$G(SDLADMT)
+76 SET SDRETURN("ExtendedProfile",SDCOUNT,"Last Admit/Lodger Date")=$$FMTISO^SDAMUTDT($$CONVDATE^SDESCOMPPEN($GET(SDLADMT)))
+77 KILL DGPMVI,VAIP
+78 QUIT