APCDAACD ; IHS/CMI/LAB - CDMIS TO PCC LINK ;
;;2.0;IHS PCC SUITE;;MAY 14, 2009
;
;
;cdmis to pcc link
;cdmis system will pass array ACDEV
;ACDEV("TYPE")=A,E OR D
;
EP ;EP - call from APCDALD DRIVER
D MAIN
D EOJ
Q
;
MAIN ;
W:'$D(ZTQUEUED) !!,"Updating PCC .. hold on.."
K APCDQUIT,APCDALVR
D ECHK
I $G(APCDQUIT) D VSERROR Q
D @ACDEV("TYPE")
Q
;
ECHK ;ERROR CHECK
I '$D(ACDEV) S APCDQUIT=4 Q ; no array defined
F X="CLINIC","LOCATION","PAT","POV","PRI PROV","SITE TYPE","SVC CAT","TYPE","V DATE","VISIT" D Q:$G(APCDQUIT)
. S X=""""_X_""""
. S:X["POV" X=X_",1"
. I '$D(@("ACDEV("_X_")")) S APCDQUIT=5 Q ; required var missing
. I $G(@("ACDEV("_X_")"))="" S APCDQUIT=6 Q ; required var null
. Q
Q:$G(APCDQUIT)
I "AED"'[ACDEV("TYPE") S APCDQUIT=7 Q ; no appropriate type
Q
;
A ;EP-added a record
;//^APCDAAC2
D CHECK
I $G(APCDQUIT) Q ; quit if not a visit pcc wants
D VISIT ; set up and create visit
I $G(APCDQUIT) Q
D ^APCDALV ; create visit
I $D(APCDALVR("APCDAFLG")) S APCDQUIT=APCDALVR("APCDAFLG") D VSERROR Q
S APCDVSIT=APCDALVR("APCDVSIT")
D VFILES^APCDAAC1
;call protocol signifying a complete visit added to pcc files
S APCDV("9000010")=APCDVSIT
D COMPLETE^APCDALD
Q
;
CHECK ; SEE IF PCC WANTS VISIT
Q
;
VISIT ;EP
;//^APCDAAC2
S APCDALVR("APCDAUTO")="" S:ACDEV("TYPE")="A" APCDALVR("APCDADD")=""
S APCDALVR("APCDPAT")=ACDEV("PAT")
S (APCDALVR("APCDDATE"),APCDDATK)=ACDEV("V DATE")
D GETLOC ; get location of visit
I $G(APCDQUIT) D VSERROR Q
D GETTYPE ; get type of visit
I $G(APCDQUIT) D VSERROR Q
S APCDALVR("APCDCAT")=ACDEV("SVC CAT")
S APCDALVR("APCDCLN")=ACDEV("CLINIC")
S APCDALVR("APCDAPPT")="U"
DEBUG ;ZW APCDALVR D PAUSE^ACDDEU
Q
;
GETLOC ;get location of encounter
S APCDALVR("APCDLOC")=ACDEV("LOCATION")
Q
; ********** DO WE NEED SOMETHING HERE **********
I '$D(ACDEV("ACTLOC")) S APCDQUIT=21 Q ;can't tell activity location
S APCDACTL=$P(ACDEV("ACTLOC"),U,5)
S APCDLOC=$P(ACDEV("DATA0"),U,5)
I APCDLOC S APCDALVR("APCDLOC")=APCDLOC Q ;quit if have a hosp/clinic pointer
I APCDACTL="HC" S APCDQUIT=24 Q
;home visit
I APCDACTL="HM" S APCDLOC=$P(ACDEV("SITE"),U,5) I APCDLOC="" S APCDQUIT=22 Q
I APCDACTL="CH" S APCDLOC=$P(ACDEV("SITE"),U,6) I APCDLOC="" S APCDQUIT=27 Q
I 'APCDLOC S APCDLOC=$P(ACDEV("SITE"),U,9) I APCDLOC="" S APCDQUIT=23 Q
S APCDALVR("APCDLOC")=APCDLOC
Q
;
GETTYPE ;get type of visit
S APCDALVR("APCDTYPE")=ACDEV("SITE TYPE")
Q
; ********** DO WE NEED SOMETHING HERE *********
S APCDLOC=$P(^AUTTLOC(APCDALVR("APCDLOC"),0),U,10) I $E(APCDLOC,5,6)>49 S APCDALVR("APCDTYPE")="T" Q ;if not a clinic, set to tribal and quit
S APCDALVR("APCDTYPE")=$P(ACDEV("SITE"),U,4) Q:APCDALVR("APCDTYPE")'=""
S X=$P(^AUTTLOC(APCDALVR("APCDLOC"),0),U,25) I X]"" S APCDALVR("APCDTYPE")=$S(X=1:"I",X=2:"6",X=3:"C",X=6:"T",1:"O") Q ;if loc updated use it
S X=$P($G(^APCCCTRL(DUZ(2),0)),U,4) I X]"" S APCDALVR("APCDTYPE")=X Q ;use pcc master control if all else fails
S APCDALVR("APCDTYPE")="T" ;default to T if can't determine
Q
;
E ;edited a cdmis record
D E^APCDAAC2
Q
;
D ;deleted a cdmis record
D D^APCDAAC2
Q
;
EOJ ;
K APCDLINK,APCDFILE,APCDERR,APCDQUIT,APCDALVR,APCDTYPE,APCDLOC,APCDDATK,APCDACTL,APCDIEN,APCDX,APCDGOT,APCDVSIT
K ACDEV
Q
;
VSERROR ;EP
S APCDFILE="VISIT"
S APCDIEN=$G(ACDEV("VISIT"))
S APCDERR="VE"_APCDQUIT,APCDERR=$P($T(@APCDERR),";;",2)
D LBULL^APCDALD
Q
;
VE2 ;;inability to create visit
VE3 ;;invalid visit parameters (date, location etc.)
VE4 ;;ACDEV array not passed
VE5 ;;Required variable not passed
VE6 ;;Required variable is null
VE7 ;;No appropriate type (i.e., A,E,D)
VE21 ;;No activity location passed. No Location determined.
VE22 ;;No IHS Location for HOME in CDMIS SITE PARAMETER File.
VE23 ;;No IHS Location for OTHER in CDMIS SITE PARAMETER File.
VE24 ;;No Location of Encounter when Activity location is Hospital/Clinic.
VE27 ;;No Location of Encounter for OFFICE in CDMIS SITE PARAMETER file.
VE28 ;;Error attempting to modify visit
APCDAACD ; IHS/CMI/LAB - CDMIS TO PCC LINK ;
+1 ;;2.0;IHS PCC SUITE;;MAY 14, 2009
+2 ;
+3 ;
+4 ;cdmis to pcc link
+5 ;cdmis system will pass array ACDEV
+6 ;ACDEV("TYPE")=A,E OR D
+7 ;
EP ;EP - call from APCDALD DRIVER
+1 DO MAIN
+2 DO EOJ
+3 QUIT
+4 ;
MAIN ;
+1 IF '$DATA(ZTQUEUED)
WRITE !!,"Updating PCC .. hold on.."
+2 KILL APCDQUIT,APCDALVR
+3 DO ECHK
+4 IF $GET(APCDQUIT)
DO VSERROR
QUIT
+5 DO @ACDEV("TYPE")
+6 QUIT
+7 ;
ECHK ;ERROR CHECK
+1 ; no array defined
IF '$DATA(ACDEV)
SET APCDQUIT=4
QUIT
+2 FOR X="CLINIC","LOCATION","PAT","POV","PRI PROV","SITE TYPE","SVC CAT","TYPE","V DATE","VISIT"
Begin DoDot:1
+3 SET X=""""_X_""""
+4 IF X["POV"
SET X=X_",1"
+5 ; required var missing
IF '$DATA(@("ACDEV("_X_")"))
SET APCDQUIT=5
QUIT
+6 ; required var null
IF $GET(@("ACDEV("_X_")"))=""
SET APCDQUIT=6
QUIT
+7 QUIT
End DoDot:1
IF $GET(APCDQUIT)
QUIT
+8 IF $GET(APCDQUIT)
QUIT
+9 ; no appropriate type
IF "AED"'[ACDEV("TYPE")
SET APCDQUIT=7
QUIT
+10 QUIT
+11 ;
A ;EP-added a record
+1 ;//^APCDAAC2
+2 DO CHECK
+3 ; quit if not a visit pcc wants
IF $GET(APCDQUIT)
QUIT
+4 ; set up and create visit
DO VISIT
+5 IF $GET(APCDQUIT)
QUIT
+6 ; create visit
DO ^APCDALV
+7 IF $DATA(APCDALVR("APCDAFLG"))
SET APCDQUIT=APCDALVR("APCDAFLG")
DO VSERROR
QUIT
+8 SET APCDVSIT=APCDALVR("APCDVSIT")
+9 DO VFILES^APCDAAC1
+10 ;call protocol signifying a complete visit added to pcc files
+11 SET APCDV("9000010")=APCDVSIT
+12 DO COMPLETE^APCDALD
+13 QUIT
+14 ;
CHECK ; SEE IF PCC WANTS VISIT
+1 QUIT
+2 ;
VISIT ;EP
+1 ;//^APCDAAC2
+2 SET APCDALVR("APCDAUTO")=""
IF ACDEV("TYPE")="A"
SET APCDALVR("APCDADD")=""
+3 SET APCDALVR("APCDPAT")=ACDEV("PAT")
+4 SET (APCDALVR("APCDDATE"),APCDDATK)=ACDEV("V DATE")
+5 ; get location of visit
DO GETLOC
+6 IF $GET(APCDQUIT)
DO VSERROR
QUIT
+7 ; get type of visit
DO GETTYPE
+8 IF $GET(APCDQUIT)
DO VSERROR
QUIT
+9 SET APCDALVR("APCDCAT")=ACDEV("SVC CAT")
+10 SET APCDALVR("APCDCLN")=ACDEV("CLINIC")
+11 SET APCDALVR("APCDAPPT")="U"
DEBUG ;ZW APCDALVR D PAUSE^ACDDEU
+1 QUIT
+2 ;
GETLOC ;get location of encounter
+1 SET APCDALVR("APCDLOC")=ACDEV("LOCATION")
+2 QUIT
+3 ; ********** DO WE NEED SOMETHING HERE **********
+4 ;can't tell activity location
IF '$DATA(ACDEV("ACTLOC"))
SET APCDQUIT=21
QUIT
+5 SET APCDACTL=$PIECE(ACDEV("ACTLOC"),U,5)
+6 SET APCDLOC=$PIECE(ACDEV("DATA0"),U,5)
+7 ;quit if have a hosp/clinic pointer
IF APCDLOC
SET APCDALVR("APCDLOC")=APCDLOC
QUIT
+8 IF APCDACTL="HC"
SET APCDQUIT=24
QUIT
+9 ;home visit
+10 IF APCDACTL="HM"
SET APCDLOC=$PIECE(ACDEV("SITE"),U,5)
IF APCDLOC=""
SET APCDQUIT=22
QUIT
+11 IF APCDACTL="CH"
SET APCDLOC=$PIECE(ACDEV("SITE"),U,6)
IF APCDLOC=""
SET APCDQUIT=27
QUIT
+12 IF 'APCDLOC
SET APCDLOC=$PIECE(ACDEV("SITE"),U,9)
IF APCDLOC=""
SET APCDQUIT=23
QUIT
+13 SET APCDALVR("APCDLOC")=APCDLOC
+14 QUIT
+15 ;
GETTYPE ;get type of visit
+1 SET APCDALVR("APCDTYPE")=ACDEV("SITE TYPE")
+2 QUIT
+3 ; ********** DO WE NEED SOMETHING HERE *********
+4 ;if not a clinic, set to tribal and quit
SET APCDLOC=$PIECE(^AUTTLOC(APCDALVR("APCDLOC"),0),U,10)
IF $EXTRACT(APCDLOC,5,6)>49
SET APCDALVR("APCDTYPE")="T"
QUIT
+5 SET APCDALVR("APCDTYPE")=$PIECE(ACDEV("SITE"),U,4)
IF APCDALVR("APCDTYPE")'=""
QUIT
+6 ;if loc updated use it
SET X=$PIECE(^AUTTLOC(APCDALVR("APCDLOC"),0),U,25)
IF X]""
SET APCDALVR("APCDTYPE")=$SELECT(X=1:"I",X=2:"6",X=3:"C",X=6:"T",1:"O")
QUIT
+7 ;use pcc master control if all else fails
SET X=$PIECE($GET(^APCCCTRL(DUZ(2),0)),U,4)
IF X]""
SET APCDALVR("APCDTYPE")=X
QUIT
+8 ;default to T if can't determine
SET APCDALVR("APCDTYPE")="T"
+9 QUIT
+10 ;
E ;edited a cdmis record
+1 DO E^APCDAAC2
+2 QUIT
+3 ;
D ;deleted a cdmis record
+1 DO D^APCDAAC2
+2 QUIT
+3 ;
EOJ ;
+1 KILL APCDLINK,APCDFILE,APCDERR,APCDQUIT,APCDALVR,APCDTYPE,APCDLOC,APCDDATK,APCDACTL,APCDIEN,APCDX,APCDGOT,APCDVSIT
+2 KILL ACDEV
+3 QUIT
+4 ;
VSERROR ;EP
+1 SET APCDFILE="VISIT"
+2 SET APCDIEN=$GET(ACDEV("VISIT"))
+3 SET APCDERR="VE"_APCDQUIT
SET APCDERR=$PIECE($TEXT(@APCDERR),";;",2)
+4 DO LBULL^APCDALD
+5 QUIT
+6 ;
VE2 ;;inability to create visit
VE3 ;;invalid visit parameters (date, location etc.)
VE4 ;;ACDEV array not passed
VE5 ;;Required variable not passed
VE6 ;;Required variable is null
VE7 ;;No appropriate type (i.e., A,E,D)
VE21 ;;No activity location passed. No Location determined.
VE22 ;;No IHS Location for HOME in CDMIS SITE PARAMETER File.
VE23 ;;No IHS Location for OTHER in CDMIS SITE PARAMETER File.
VE24 ;;No Location of Encounter when Activity location is Hospital/Clinic.
VE27 ;;No Location of Encounter for OFFICE in CDMIS SITE PARAMETER file.
VE28 ;;Error attempting to modify visit