PXRMVSIT ;SLC/PKR - Visit related info for reminders. ;23-Mar-2015 10:40;DU
;;2.0;CLINICAL REMINDERS;**4,6,1001,18,24,1005**;Feb 04, 2005;Build 23
;
;IHS/MSC/MGH Patch 1001 Line added to quit if null VIEN
;======================================================
GETDATA(DA,DATA,SVALUE) ;Return data for a specific Visit file entry.
;DBIA #2028 for Visit file.
N DONE,IEN,HLOCIEN,HTEMP,LOE,TEMP
Q:'DA
S TEMP=^AUPNVSIT(DA,0)
S DATA("VISIT")=DA
S DATA("DATE VISIT CREATED")=$P(TEMP,U,2)
S DATA("DFN")=$P(TEMP,U,5)
S (DATA("LOC. OF ENCOUNTER"),LOE)=$P(TEMP,U,6)
;DBIA #10090
S DATA("STATION NUMBER")=$$GET1^DIQ(4,LOE,99)
S DATA("OFFICAL VA NAME")=$$GET1^DIQ(4,LOE,100)
S DATA("SERVICE CATEGORY")=$P(TEMP,U,7)
I $G(SVALUE) S DATA("VALUE")=$P(TEMP,U,7)
S (DATA("HOSPITAL LOCATION"),HLOCIEN)=$P(TEMP,U,22)
;DBIA #10040, #2804
S HTEMP=$S(HLOCIEN="":"",1:^SC(HLOCIEN,0))
S DATA("HLOC")=$P(HTEMP,U,1)
S DATA("DSS ID")=$P(TEMP,U,8)
I DATA("DSS ID")="" S DATA("DSS ID")=$P(HTEMP,U,7)
S DATA("DIVISION IEN")=$P(HTEMP,U,15)
I HLOCIEN'="" S DATA("DIVISION")=$$GET1^DIQ(44,HLOCIEN,3.5)
;DBIA #557
I DATA("DSS ID")'="" S DATA("STOP CODE")=$P(^DIC(40.7,DATA("DSS ID"),0),U,2)
S DATA("OUTSIDE LOCATION")=$G(^AUPNVSIT(DA,21))
S DATA("VISIT COMMENTS")=$G(^AUPNVSIT(DA,811))
;DBIA #4850
S DATA("STATUS")=$$STATUS^SDPCE(DA)
;Get the primary provider.
;DBIA #3455 for V PROVIDER
S DATA("PRIMARY PROVIDER")="",IEN="",DONE=0
F S IEN=$O(^AUPNVPRV("AD",DA,IEN)) Q:(DONE)!(IEN="") D
. S TEMP=^AUPNVPRV(IEN,0)
. I $P(TEMP,U,4)="P" S DATA("PRIMARY PROVIDER")=$P(TEMP,U,1),DONE=1
Q
;
;======================================================
GAPSTAT(VIEN) ;Return the status of the appointment associated with the
;visit.
;DBIA #4850
Q $$STATUS^SDPCE(VIEN)
;
;======================================================
HENC(VIEN,INDENT,NLINES,TEXT) ;Display location and comment for historical
;encounters associated with the V files.
N COMMENT,HLOC,LOCATION,OLOC,NIN,TEXTIN,VDATA
D GETDATA(VIEN,.VDATA) I VDATA("SERVICE CATEGORY")'="E" Q
S NIN=0
S LOCATION=VDATA("LOC. OF ENCOUNTER")
I LOCATION'="" D
. S LOCATION=$$GET1^DIQ(4,LOCATION,.01)_" "_$$GET1^DIQ(4,LOCATION,99)
. S NIN=NIN+1,TEXTIN(NIN)="Location of Encounter: "_LOCATION_"\\"
S HLOC=VDATA("HOSPITAL LOCATION")
I HLOC'="" D
. S HLOC=$$GET1^DIQ(44,HLOC,.01)
. S NIN=NIN+1,TEXTIN(NIN)="Hospital Location: "_HLOC_"\\"
S OLOC=VDATA("OUTSIDE LOCATION")
I OLOC'="" D
. S NIN=NIN+1,TEXTIN(NIN)="Outside Location: "_OLOC_"\\"
S COMMENT=VDATA("COMMENT")
I COMMENT'="" D
. S NIN=NIN+1,TEXTIN(NIN)="Comment: "_COMMENT
I NIN>0 D
. N JND,NOUT,TEXTOUT
. S NLINES=NLINES+1
. S TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Historical Encounter Information:"
. D FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
. F JND=1:1:NOUT S NLINES=NLINES+1,TEXT(NLINES)=TEXTOUT(JND)
Q
;
;======================================================
ISHIST(VIEN) ;Return true if the encounter was historical.
;DBIA #2028
;IHS/MSC/MGH Patch 1001 Line added to quit if null VIEN
I +VIEN=0 Q 0
I $P($G(^AUPNVSIT(VIEN,0)),U,7)="E" Q 1
Q 0
;
;======================================================
VAPSTAT(VIEN) ;Return true if the appointment associated with
;the visit has a valid appointment status.
;Return false if the status is one of the following:
;CANCELLED BY CLINIC
;CANCELLED BY CLINIC & AUTO RE-BOOK
;CANCELLED BY PATIENT
;CANCELLED BY PATIENT & AUTO-REBOOK
;DELETED
;NO ACTION TAKEN
;NO-SHOW
;NO-SHOW & AUTO RE-BOOK
;NULL
N STATUS,VALID
;DBIA #4850
S STATUS=$P($$STATUS^SDPCE(VIEN),U,2)
S VALID=$S(STATUS["CANCELLED":0,STATUS["DELETED":0,STATUS["NO ACTION":0,STATUS["NO-SHOW":0,STATUS="":0,1:1)
Q VALID
;
PXRMVSIT ;SLC/PKR - Visit related info for reminders. ;23-Mar-2015 10:40;DU
+1 ;;2.0;CLINICAL REMINDERS;**4,6,1001,18,24,1005**;Feb 04, 2005;Build 23
+2 ;
+3 ;IHS/MSC/MGH Patch 1001 Line added to quit if null VIEN
+4 ;======================================================
GETDATA(DA,DATA,SVALUE) ;Return data for a specific Visit file entry.
+1 ;DBIA #2028 for Visit file.
+2 NEW DONE,IEN,HLOCIEN,HTEMP,LOE,TEMP
+3 IF 'DA
QUIT
+4 SET TEMP=^AUPNVSIT(DA,0)
+5 SET DATA("VISIT")=DA
+6 SET DATA("DATE VISIT CREATED")=$PIECE(TEMP,U,2)
+7 SET DATA("DFN")=$PIECE(TEMP,U,5)
+8 SET (DATA("LOC. OF ENCOUNTER"),LOE)=$PIECE(TEMP,U,6)
+9 ;DBIA #10090
+10 SET DATA("STATION NUMBER")=$$GET1^DIQ(4,LOE,99)
+11 SET DATA("OFFICAL VA NAME")=$$GET1^DIQ(4,LOE,100)
+12 SET DATA("SERVICE CATEGORY")=$PIECE(TEMP,U,7)
+13 IF $GET(SVALUE)
SET DATA("VALUE")=$PIECE(TEMP,U,7)
+14 SET (DATA("HOSPITAL LOCATION"),HLOCIEN)=$PIECE(TEMP,U,22)
+15 ;DBIA #10040, #2804
+16 SET HTEMP=$SELECT(HLOCIEN="":"",1:^SC(HLOCIEN,0))
+17 SET DATA("HLOC")=$PIECE(HTEMP,U,1)
+18 SET DATA("DSS ID")=$PIECE(TEMP,U,8)
+19 IF DATA("DSS ID")=""
SET DATA("DSS ID")=$PIECE(HTEMP,U,7)
+20 SET DATA("DIVISION IEN")=$PIECE(HTEMP,U,15)
+21 IF HLOCIEN'=""
SET DATA("DIVISION")=$$GET1^DIQ(44,HLOCIEN,3.5)
+22 ;DBIA #557
+23 IF DATA("DSS ID")'=""
SET DATA("STOP CODE")=$PIECE(^DIC(40.7,DATA("DSS ID"),0),U,2)
+24 SET DATA("OUTSIDE LOCATION")=$GET(^AUPNVSIT(DA,21))
+25 SET DATA("VISIT COMMENTS")=$GET(^AUPNVSIT(DA,811))
+26 ;DBIA #4850
+27 SET DATA("STATUS")=$$STATUS^SDPCE(DA)
+28 ;Get the primary provider.
+29 ;DBIA #3455 for V PROVIDER
+30 SET DATA("PRIMARY PROVIDER")=""
SET IEN=""
SET DONE=0
+31 FOR
SET IEN=$ORDER(^AUPNVPRV("AD",DA,IEN))
IF (DONE)!(IEN="")
QUIT
Begin DoDot:1
+32 SET TEMP=^AUPNVPRV(IEN,0)
+33 IF $PIECE(TEMP,U,4)="P"
SET DATA("PRIMARY PROVIDER")=$PIECE(TEMP,U,1)
SET DONE=1
End DoDot:1
+34 QUIT
+35 ;
+36 ;======================================================
GAPSTAT(VIEN) ;Return the status of the appointment associated with the
+1 ;visit.
+2 ;DBIA #4850
+3 QUIT $$STATUS^SDPCE(VIEN)
+4 ;
+5 ;======================================================
HENC(VIEN,INDENT,NLINES,TEXT) ;Display location and comment for historical
+1 ;encounters associated with the V files.
+2 NEW COMMENT,HLOC,LOCATION,OLOC,NIN,TEXTIN,VDATA
+3 DO GETDATA(VIEN,.VDATA)
IF VDATA("SERVICE CATEGORY")'="E"
QUIT
+4 SET NIN=0
+5 SET LOCATION=VDATA("LOC. OF ENCOUNTER")
+6 IF LOCATION'=""
Begin DoDot:1
+7 SET LOCATION=$$GET1^DIQ(4,LOCATION,.01)_" "_$$GET1^DIQ(4,LOCATION,99)
+8 SET NIN=NIN+1
SET TEXTIN(NIN)="Location of Encounter: "_LOCATION_"\\"
End DoDot:1
+9 SET HLOC=VDATA("HOSPITAL LOCATION")
+10 IF HLOC'=""
Begin DoDot:1
+11 SET HLOC=$$GET1^DIQ(44,HLOC,.01)
+12 SET NIN=NIN+1
SET TEXTIN(NIN)="Hospital Location: "_HLOC_"\\"
End DoDot:1
+13 SET OLOC=VDATA("OUTSIDE LOCATION")
+14 IF OLOC'=""
Begin DoDot:1
+15 SET NIN=NIN+1
SET TEXTIN(NIN)="Outside Location: "_OLOC_"\\"
End DoDot:1
+16 SET COMMENT=VDATA("COMMENT")
+17 IF COMMENT'=""
Begin DoDot:1
+18 SET NIN=NIN+1
SET TEXTIN(NIN)="Comment: "_COMMENT
End DoDot:1
+19 IF NIN>0
Begin DoDot:1
+20 NEW JND,NOUT,TEXTOUT
+21 SET NLINES=NLINES+1
+22 SET TEXT(NLINES)=$$INSCHR^PXRMEXLC(INDENT," ")_"Historical Encounter Information:"
+23 DO FORMAT^PXRMTEXT(INDENT+2,PXRMRM,NIN,.TEXTIN,.NOUT,.TEXTOUT)
+24 FOR JND=1:1:NOUT
SET NLINES=NLINES+1
SET TEXT(NLINES)=TEXTOUT(JND)
End DoDot:1
+25 QUIT
+26 ;
+27 ;======================================================
ISHIST(VIEN) ;Return true if the encounter was historical.
+1 ;DBIA #2028
+2 ;IHS/MSC/MGH Patch 1001 Line added to quit if null VIEN
+3 IF +VIEN=0
QUIT 0
+4 IF $PIECE($GET(^AUPNVSIT(VIEN,0)),U,7)="E"
QUIT 1
+5 QUIT 0
+6 ;
+7 ;======================================================
VAPSTAT(VIEN) ;Return true if the appointment associated with
+1 ;the visit has a valid appointment status.
+2 ;Return false if the status is one of the following:
+3 ;CANCELLED BY CLINIC
+4 ;CANCELLED BY CLINIC & AUTO RE-BOOK
+5 ;CANCELLED BY PATIENT
+6 ;CANCELLED BY PATIENT & AUTO-REBOOK
+7 ;DELETED
+8 ;NO ACTION TAKEN
+9 ;NO-SHOW
+10 ;NO-SHOW & AUTO RE-BOOK
+11 ;NULL
+12 NEW STATUS,VALID
+13 ;DBIA #4850
+14 SET STATUS=$PIECE($$STATUS^SDPCE(VIEN),U,2)
+15 SET VALID=$SELECT(STATUS["CANCELLED":0,STATUS["DELETED":0,STATUS["NO ACTION":0,STATUS["NO-SHOW":0,STATUS="":0,1:1)
+16 QUIT VALID
+17 ;