PXBAPI ;ISL/JVS,ISA/KWP - PCE's API interview questions - encounter ;04/26/99
;;1.0;PCE PATIENT CARE ENCOUNTER;**19,67**;Aug 12, 1996
Q
;
INTV(WHAT,PACKAGE,SOURCE,PXBVST,PXBHLOC,PXBPAT,PXBAPPT,PXLIMDT,PXALHLOC) ;
;+This api will prompt the user for Visit and related V-file data used to document an encounter.
;+Interview Questions
;+Parameters
;+ WHAT Required, defines the series of prompts. Valid values are:
;+ "INTV" all of the prompts in the checkout interview.
;+ "ADQ" all of the administrative prompts related to the interview.
;+ "CODT" prompts for the Check Out Date/Time.
;+ "SCC" prompts for the service connected conditions.
;+ "PRV" prompts for the providers
;+ "CPT" prompts for the provider and then the procedures that
;+ the provider did.
;+ "POV" prompts for the diagnoses
;+ "STP" prompts for the stop codes
;+----------
;+ PACKAGE Required, text string of the package name space
;+ or a pointer to the Package file (#9.4)
;+ SOURCE Required, text string that discribes the source of the data.
;+ This will be added to the PCE Data Source file (#839.7) if
;+ it is not already in the file.
;+ PXBVST Required except for on "INTV" and "ADQ".
;+ This is a pointer to the Visit file (#9000010)
;+ PXBHLOC Optional (passed if known) pointer to the Hospital
;+ Location file (#44)
;+ PXBPAT Pointer to the Patient file (#2)
;+ Required if there is no PXBVST and there is a PXBAPPT
;+ otherwise it is Optional (passed if known)
;+ PXBAPPT Optional (passed if known) pointer to the Apointment
;+ subfile (#2.98) of the Patient file (#2)
;+ PXLIMDT Optional if passed then user can not create an encounter
;+ (Visit file entry) before this date.
;+ PXALHLOC Optional if is not passed, 0, or null then only clinics
;+ can be entered for hospital locations otherwise
;+ any non disposition hospital location can be entered.
;+
;+ Returns:
;+ 1 if no errors and process completely
;+ 0 if user up arrows out may have did part of the processing
;+ but at least have a visit
;+ -1 if user up arrows out or errors out and did not do anything
;+ -2 if could not get a visit
;+ -3 if called incorrectly
;
;---------------NEW CURSOR CONTROL VARIABLE-----------------------
N IOARM0,IOARM1,IOAWM0,IOAWM1,IOBOFF,IOBON,IOCOMMA,IOCUB,IOCUD,IOCUF
N IOCUON,IOCUOFF,IOCUU,IODCH,IODHLB,IODHLT,IODL,IODWL,IOECH,IOEDALL
N IOEDBOP,IOEDEOP,IOEFLD,IOELALL,IOELBOL,IOELEOL,IOENTER,IOFIND
N IOHDWN,IOHOME,IOHTS,IOHUP,IOICH,IOIL,IOIND,IOINHI,IOINLOW,IOINORM
N IOINSERT,IOKP0,IOKP1,IOKP2,IOKP3,IOKP4,IOKP5,IOKP6,IOKP7,IOKP8,IOKP9
N IOIRM0,IOIRM1,IOKPAM,IOKPNM,IOMC,IOMINUS,IONEL,IONEXTSC,IOPERIOD
N IOPF1,IOPF2,IOPF3,IOPF4,IOPREVSC,IOPROB,IOPTCH10,IOPTCH12,IOPTCH16
N IORC,IOREMOVE,IORESET,IORI,IORVOFF,IORVON,IOSC,IOSGR0,IOSELECT
N IOSTBM,IOSWL,IOTBC,IOTBCALL,IOUOFF,IOUON,IOIS
;
;------------------------*******----------------------------------
D FIX1^PXBCC
N DIQ,TANA
N PXBPXXX S PXBPXXX="1^1" ;--PROMPTING CONTROL VARIABLE
;
N PXBSOURC,PXBEXIT,PXBVSTDT,PXELAP,PXBCODT,PXB800,PXBPRBON,DFN
N PXBEXIT,PAT,ITEM,NF,POP,PXBCNTPL,Q,TEST,UID,PXBPKG
N VAL,VAR,PXBNCPTF,DXX,DYY
S PXBEXIT=1
;
I $G(WHAT)']"" W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""WHAT"", contact IRM." Q -3
I $G(PACKAGE)']"" W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""PACKAGE"", contact IRM." Q -3
I $G(SOURCE)']"" W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""SOURCE"", contact IRM." Q -3
;Get package pointer
I PACKAGE=+PACKAGE S PXBPKG=PACKAGE
E S PXBPKG=$$PKG2IEN^VSIT(PACKAGE)
I '($D(^DIC(9.4,PXBPKG,0))#2) W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a valid ""PACKAGE"", contact IRM." Q -3
;
;Lookup source in PCE DATA SOURCE file (#839.7) with LAYGO
I SOURCE=+SOURCE S PXBSOURC=SOURCE
E S PXBSOURC=$$SOURCE^PXAPIUTL(SOURCE)
;
I PXBVST'>0,WHAT'="INTV"&(WHAT'="ADQ")&(WHAT'="ADDEDIT") W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""VISIT"", contact IRM." Q -3
I PXBVST>0 D Q:PXBEXIT<1 PXBEXIT
. S PXBVSTDT=$P(^AUPNVSIT(PXBVST,0),"^",1)
. I PXBPAT'>0 S PXBPAT=$P(^AUPNVSIT(PXBVST,0),"^",5)
. E I PXBPAT'=$P(^AUPNVSIT(PXBVST,0),"^",5) W !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit for a different Patient, contact IRM." S PXBEXIT=-3 Q
. I PXBHLOC'>0 S PXBHLOC=$P(^AUPNVSIT(PXBVST,0),"^",22)
. E I PXBHLOC'=$P(^AUPNVSIT(PXBVST,0),"^",22) W !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit for a different Hospital Locations, contact IRM." S PXBEXIT=-3 Q
. I PXBAPPT'>0 D
.. I $D(^DPT(PXBPAT,"S",PXBVSTDT,0))#2,PXBHLOC'>0!(PXBHLOC=+^DPT(PXBPAT,"S",PXBVSTDT,0)) S PXBAPPT=PXBVSTDT S:PXBHLOC'>0 PXBHLOC=+^DPT(PXBPAT,"S",PXBVSTDT,0)
. E I '$D(^DPT(PXBPAT,"S",PXBVSTDT,0))#2!(PXBVSTDT'=PXBAPPT) W !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit and Appointment of different times, contact IRM." S PXBEXIT=-3 Q
E I PXBAPPT>0 D Q:PXBEXIT<1 PXBEXIT
. I PXBPAT'>0 W !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""PATIENT"", contact IRM." S PXBEXIT=-3 Q
. S PXBVSTDT=PXBAPPT
. I PXBHLOC'>0,+$G(^DPT(PXBPAT,"S",PXBAPPT,0)) S PXBHLOC=+^DPT(PXBPAT,"S",PXBAPPT,0)
S DFN=PXBPAT
S PXBPRBON=$L($T(^GMPLUTL)) ;see if Problem List exists
;+ If visit has been passed lock ^PXLCKUSR(VISIEN)
;+ and create XTMP("PXLCKUSR",VISIEN)=DUZ
N PXRESVAL,PXVISIEN
I PXBVST>0 S PXVISIEN=PXBVST D I 'PXRESVAL Q -2
.N PXMSG,PXUSR
.S PXMSG=""
.I $D(^XTMP("PXLCKUSR",PXVISIEN)) S PXUSR=$G(^VA(200,^XTMP("PXLCKUSR",PXVISIEN),0)),PXUSR=$S(PXUSR="":"Unknown",1:$P(PXUSR,"^")),PXMSG="Encounter Locked by "_PXUSR
.S PXRESVAL=$$LOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")",5,0,PXMSG,0)
.I 'PXRESVAL Q
.S PXRESVAL=$$CREATE^PXUAXTMP("PXLCKUSR",PXVISIEN,365,"PCE Encounter Lock",DUZ) I 'PXRESVAL D UNLOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")")
D PROCESS^PXBAPI1(.PXBEXIT)
W !," - - - - S o r r y A b o u t T h e W a i t - - - -"
W !,"This information is being stored or monitored by Scheduling"
W !,"Integrated Billing, Order Entry, Registration, Prosthetics"
W !,"PCE/Visit Tracking and Automated Med Information Exchange."
D EVENT^PXKMAIN
K PXVDR
I $G(PXVISIEN)>0 D UNLOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")"),DELETE^PXUAXTMP("PXLCKUSR",PXVISIEN)
Q PXBEXIT
;
PXBAPI ;ISL/JVS,ISA/KWP - PCE's API interview questions - encounter ;04/26/99
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**19,67**;Aug 12, 1996
+2 QUIT
+3 ;
INTV(WHAT,PACKAGE,SOURCE,PXBVST,PXBHLOC,PXBPAT,PXBAPPT,PXLIMDT,PXALHLOC) ;
+1 ;+This api will prompt the user for Visit and related V-file data used to document an encounter.
+2 ;+Interview Questions
+3 ;+Parameters
+4 ;+ WHAT Required, defines the series of prompts. Valid values are:
+5 ;+ "INTV" all of the prompts in the checkout interview.
+6 ;+ "ADQ" all of the administrative prompts related to the interview.
+7 ;+ "CODT" prompts for the Check Out Date/Time.
+8 ;+ "SCC" prompts for the service connected conditions.
+9 ;+ "PRV" prompts for the providers
+10 ;+ "CPT" prompts for the provider and then the procedures that
+11 ;+ the provider did.
+12 ;+ "POV" prompts for the diagnoses
+13 ;+ "STP" prompts for the stop codes
+14 ;+----------
+15 ;+ PACKAGE Required, text string of the package name space
+16 ;+ or a pointer to the Package file (#9.4)
+17 ;+ SOURCE Required, text string that discribes the source of the data.
+18 ;+ This will be added to the PCE Data Source file (#839.7) if
+19 ;+ it is not already in the file.
+20 ;+ PXBVST Required except for on "INTV" and "ADQ".
+21 ;+ This is a pointer to the Visit file (#9000010)
+22 ;+ PXBHLOC Optional (passed if known) pointer to the Hospital
+23 ;+ Location file (#44)
+24 ;+ PXBPAT Pointer to the Patient file (#2)
+25 ;+ Required if there is no PXBVST and there is a PXBAPPT
+26 ;+ otherwise it is Optional (passed if known)
+27 ;+ PXBAPPT Optional (passed if known) pointer to the Apointment
+28 ;+ subfile (#2.98) of the Patient file (#2)
+29 ;+ PXLIMDT Optional if passed then user can not create an encounter
+30 ;+ (Visit file entry) before this date.
+31 ;+ PXALHLOC Optional if is not passed, 0, or null then only clinics
+32 ;+ can be entered for hospital locations otherwise
+33 ;+ any non disposition hospital location can be entered.
+34 ;+
+35 ;+ Returns:
+36 ;+ 1 if no errors and process completely
+37 ;+ 0 if user up arrows out may have did part of the processing
+38 ;+ but at least have a visit
+39 ;+ -1 if user up arrows out or errors out and did not do anything
+40 ;+ -2 if could not get a visit
+41 ;+ -3 if called incorrectly
+42 ;
+43 ;---------------NEW CURSOR CONTROL VARIABLE-----------------------
+44 NEW IOARM0,IOARM1,IOAWM0,IOAWM1,IOBOFF,IOBON,IOCOMMA,IOCUB,IOCUD,IOCUF
+45 NEW IOCUON,IOCUOFF,IOCUU,IODCH,IODHLB,IODHLT,IODL,IODWL,IOECH,IOEDALL
+46 NEW IOEDBOP,IOEDEOP,IOEFLD,IOELALL,IOELBOL,IOELEOL,IOENTER,IOFIND
+47 NEW IOHDWN,IOHOME,IOHTS,IOHUP,IOICH,IOIL,IOIND,IOINHI,IOINLOW,IOINORM
+48 NEW IOINSERT,IOKP0,IOKP1,IOKP2,IOKP3,IOKP4,IOKP5,IOKP6,IOKP7,IOKP8,IOKP9
+49 NEW IOIRM0,IOIRM1,IOKPAM,IOKPNM,IOMC,IOMINUS,IONEL,IONEXTSC,IOPERIOD
+50 NEW IOPF1,IOPF2,IOPF3,IOPF4,IOPREVSC,IOPROB,IOPTCH10,IOPTCH12,IOPTCH16
+51 NEW IORC,IOREMOVE,IORESET,IORI,IORVOFF,IORVON,IOSC,IOSGR0,IOSELECT
+52 NEW IOSTBM,IOSWL,IOTBC,IOTBCALL,IOUOFF,IOUON,IOIS
+53 ;
+54 ;------------------------*******----------------------------------
+55 DO FIX1^PXBCC
+56 NEW DIQ,TANA
+57 ;--PROMPTING CONTROL VARIABLE
NEW PXBPXXX
SET PXBPXXX="1^1"
+58 ;
+59 NEW PXBSOURC,PXBEXIT,PXBVSTDT,PXELAP,PXBCODT,PXB800,PXBPRBON,DFN
+60 NEW PXBEXIT,PAT,ITEM,NF,POP,PXBCNTPL,Q,TEST,UID,PXBPKG
+61 NEW VAL,VAR,PXBNCPTF,DXX,DYY
+62 SET PXBEXIT=1
+63 ;
+64 IF $GET(WHAT)']""
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""WHAT"", contact IRM."
QUIT -3
+65 IF $GET(PACKAGE)']""
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""PACKAGE"", contact IRM."
QUIT -3
+66 IF $GET(SOURCE)']""
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""SOURCE"", contact IRM."
QUIT -3
+67 ;Get package pointer
+68 IF PACKAGE=+PACKAGE
SET PXBPKG=PACKAGE
+69 IF '$TEST
SET PXBPKG=$$PKG2IEN^VSIT(PACKAGE)
+70 IF '($DATA(^DIC(9.4,PXBPKG,0))#2)
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a valid ""PACKAGE"", contact IRM."
QUIT -3
+71 ;
+72 ;Lookup source in PCE DATA SOURCE file (#839.7) with LAYGO
+73 IF SOURCE=+SOURCE
SET PXBSOURC=SOURCE
+74 IF '$TEST
SET PXBSOURC=$$SOURCE^PXAPIUTL(SOURCE)
+75 ;
+76 IF PXBVST'>0
IF WHAT'="INTV"&(WHAT'="ADQ")&(WHAT'="ADDEDIT")
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""VISIT"", contact IRM."
QUIT -3
+77 IF PXBVST>0
Begin DoDot:1
+78 SET PXBVSTDT=$PIECE(^AUPNVSIT(PXBVST,0),"^",1)
+79 IF PXBPAT'>0
SET PXBPAT=$PIECE(^AUPNVSIT(PXBVST,0),"^",5)
+80 IF '$TEST
IF PXBPAT'=$PIECE(^AUPNVSIT(PXBVST,0),"^",5)
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit for a different Patient, contact IRM."
SET PXBEXIT=-3
QUIT
+81 IF PXBHLOC'>0
SET PXBHLOC=$PIECE(^AUPNVSIT(PXBVST,0),"^",22)
+82 IF '$TEST
IF PXBHLOC'=$PIECE(^AUPNVSIT(PXBVST,0),"^",22)
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit for a different Hospital Locations, contact IRM."
SET PXBEXIT=-3
QUIT
+83 IF PXBAPPT'>0
Begin DoDot:2
+84 IF $DATA(^DPT(PXBPAT,"S",PXBVSTDT,0))#2
IF PXBHLOC'>0!(PXBHLOC=+^DPT(PXBPAT,"S",PXBVSTDT,0))
SET PXBAPPT=PXBVSTDT
IF PXBHLOC'>0
SET PXBHLOC=+^DPT(PXBPAT,"S",PXBVSTDT,0)
End DoDot:2
+85 IF '$TEST
IF '$DATA(^DPT(PXBPAT,"S",PXBVSTDT,0))#2!(PXBVSTDT'=PXBAPPT)
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly with the Visit and Appointment of different times, contact IRM."
SET PXBEXIT=-3
QUIT
End DoDot:1
IF PXBEXIT<1
QUIT PXBEXIT
+86 IF '$TEST
IF PXBAPPT>0
Begin DoDot:1
+87 IF PXBPAT'>0
WRITE !,"Procedure ""INTV^PXAPI"" was called incorrectly without a ""PATIENT"", contact IRM."
SET PXBEXIT=-3
QUIT
+88 SET PXBVSTDT=PXBAPPT
+89 IF PXBHLOC'>0
IF +$GET(^DPT(PXBPAT,"S",PXBAPPT,0))
SET PXBHLOC=+^DPT(PXBPAT,"S",PXBAPPT,0)
End DoDot:1
IF PXBEXIT<1
QUIT PXBEXIT
+90 SET DFN=PXBPAT
+91 ;see if Problem List exists
SET PXBPRBON=$LENGTH($TEXT(^GMPLUTL))
+92 ;+ If visit has been passed lock ^PXLCKUSR(VISIEN)
+93 ;+ and create XTMP("PXLCKUSR",VISIEN)=DUZ
+94 NEW PXRESVAL,PXVISIEN
+95 IF PXBVST>0
SET PXVISIEN=PXBVST
Begin DoDot:1
+96 NEW PXMSG,PXUSR
+97 SET PXMSG=""
+98 IF $DATA(^XTMP("PXLCKUSR",PXVISIEN))
SET PXUSR=$GET(^VA(200,^XTMP("PXLCKUSR",PXVISIEN),0))
SET PXUSR=$SELECT(PXUSR="":"Unknown",1:$PIECE(PXUSR,"^"))
SET PXMSG="Encounter Locked by "_PXUSR
+99 SET PXRESVAL=$$LOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")",5,0,PXMSG,0)
+100 IF 'PXRESVAL
QUIT
+101 SET PXRESVAL=$$CREATE^PXUAXTMP("PXLCKUSR",PXVISIEN,365,"PCE Encounter Lock",DUZ)
IF 'PXRESVAL
DO UNLOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")")
End DoDot:1
IF 'PXRESVAL
QUIT -2
+102 DO PROCESS^PXBAPI1(.PXBEXIT)
+103 WRITE !," - - - - S o r r y A b o u t T h e W a i t - - - -"
+104 WRITE !,"This information is being stored or monitored by Scheduling"
+105 WRITE !,"Integrated Billing, Order Entry, Registration, Prosthetics"
+106 WRITE !,"PCE/Visit Tracking and Automated Med Information Exchange."
+107 DO EVENT^PXKMAIN
+108 KILL PXVDR
+109 IF $GET(PXVISIEN)>0
DO UNLOCK^PXUALOCK("^PXLCKUSR("_PXVISIEN_")")
DO DELETE^PXUAXTMP("PXLCKUSR",PXVISIEN)
+110 QUIT PXBEXIT
+111 ;