IBDFRPC3 ;ALB/AAS - AICS Identify patient form form id ; 12-FEB-96
;;3.0;AUTOMATED INFO COLLECTION SYS;;APR 24, 1997
;
; -- used by AICS Data Entry System (routine IBDFDE)
; used by AICS Workstation software
;
IDPAT(RESULT,FORMID) ; -- Procedure
; -- Broker call to identify patient, clinic, form, and appt. from
; Encounter form ID
; rpc := IBD EXPAND FORMID
;
; -- input FORMID = pointer to form tracking (357.96)
; Result = called by reference
;
; -- output The format of the returned array is as follows
; result = $p1 := Patient Name^
; $p2 := Patient IEN
; $p3:= patient primary identifier (pid)
; $p4 := form name
; $p5 := form IEN (pointer to 357)
; $p6 := Clinic Name
; $p7 := Clinic ien
; $p8 := Clinic Physical Location
; $p9 := Appt. date/time (fm format)
; $P10:= Appt. date/time (external format)
; $P11:= Appt Status internal
; $P12:= Appt Status external
; $P13:= form input status internal
; $p14:= form input status external
; $p15:= form definition ien (357.95)
; $p16:= default provider (for clinic) internal
; $p17:= default provider (for clinic) external
; $P18:= # Scannable pages on form
; $p19:= shortedge/long edge binding
; $p20:= check out date time
;
N C,I,J,X,Y,NODE,PATNM,DFN,PID,CLIN,CLINNM,FORMNM,FORM,APPT,APPTNM,STATUS,STATNM,FRMDEF,PROVDEF,APPTSTI,APPTSTE,CLINPH,DUPLX,SCANPG,CO
K RESULT
S FORMID("SOURCE")=1
;
; -- scanner may send in leading spaces, strip it off
I +FORMID'=FORMID,$L(FORMID) S FORMID=+$P(FORMID," ",3)
S RESULT="Form ID not a valid value, null or zero^^^"
I '$G(FORMID) D LOGERR^IBDF18E2(3579604,.FORMID) G IDPATQ
;
S RESULT="Form ID not found^^^"
S NODE=$G(^IBD(357.96,+FORMID,0))
I NODE="" D LOGERR^IBDF18E2(3579605,.FORMID) G IDPATQ
;
S DFN=$P(NODE,"^",2)
S PATNM=$P($G(^DPT(DFN,0)),"^"),PID=$P($G(^DPT(DFN,.36)),"^",3)
S APPT=+$P(NODE,"^",3)
S APPTSTI=$P($G(^DPT(DFN,"S",APPT,0)),"^",2)
S APPTNM=$$FMTE^XLFDT(APPT)
;
S X=$$STATUS^SDAM1(DFN,APPT,+$G(^DPT(DFN,"S",APPT,0)),$G(^(0)))
S APPTSTE=$P(X,";",3),CO=$P(X,";",5)
I $G(^DPT(DFN,"S",APPT,0))="",CO="" D
.S CO=+$$SDV(DFN,APPT)
.I CO S APPTSTE="COMPLETE"
.I +$G(CO)<1 S APPTSTE="ACTION REQUIRED"
;
S CLIN=+$P(NODE,"^",10)
S CLINNM=$P($G(^SC(CLIN,0)),"^"),CLINPH=$P($G(^SC(CLIN,0)),"^",11)
S PROVDEF=$$PRDEF(CLIN)
S FRMDEF=$P(NODE,"^",4)
S FORM=+$P($G(^IBD(357.95,+FRMDEF,0)),"^",21)
S FORMNM=$P($G(^IBE(357,FORM,0)),"^")
S DUPLX=$P($G(^IBE(357,FORM,0)),"^",2) ; Duplex/simplex
S (SCANPG,I)=0 F S I=$O(^IBD(357.96,+FORMID,9,I)) Q:'I S SCANPG=SCANPG+1
S STATUS=$P(NODE,"^",11)
S Y=STATUS,C=$P(^DD(357.96,.11,0),"^",2) D Y^DIQ S STATNM=Y
S RESULT=PATNM_"^"_DFN_"^"_PID_"^"_FORMNM_"^"_FORM_"^"_CLINNM_"^"_CLIN_"^"_CLINPH_"^"_APPT_"^"_APPTNM_"^"_APPTSTI_"^"_APPTSTE_"^"_STATUS_"^"_STATNM_"^"_FRMDEF_"^"_PROVDEF_"^"_$P($G(^VA(200,+PROVDEF,0)),"^")_"^"_SCANPG_"^"_DUPLX_"^"_CO
;
IDPATQ Q
;
PRDEF(CLIN) ;Provider Default for Clinic
; Input -- SDCL Hospital Location file IEN
; IF DEFINED: DFN - ptr to PATIENT File
; Output -- Default
N Y,X
S Y=$P($G(^SC(+$G(CLIN),"PR",+$O(^SC("ADPR",CLIN,0)),0)),"^")
I $G(Y)="",$G(^SC(+$G(CLIN),"PC")),$D(DFN),$L($T(NMPCPR^SCAPMCU2)) S Y=+$$NMPCPR^SCAPMCU2(DFN,DT,1)
Q $G(Y)
;
SDV(DFN,APPT) ; -- try to find checkout date of stand alone encounter
N CO,QUIT,SDV,SDV1,SDOE
S CO="",SDOE=""
S SDV=+$P(APPT,"."),QUIT=0
F S SDV=+$O(^SDV("C",DFN,SDV)) Q:'SDV!(QUIT) D
.S SDV1=0 F S SDV1=+$O(^SDV(+SDV,"CS",SDV1)) Q:'SDV1!(QUIT) D
..S SDOE=+$P($G(^SDV(+SDV,"CS",+SDV1,0)),"^",8)
..S X=$G(^SCE(+SDOE,0)) I +X=APPT S CO=$P(X,"^",7),QUIT=1
Q CO_"^"_SDOE
IBDFRPC3 ;ALB/AAS - AICS Identify patient form form id ; 12-FEB-96
+1 ;;3.0;AUTOMATED INFO COLLECTION SYS;;APR 24, 1997
+2 ;
+3 ; -- used by AICS Data Entry System (routine IBDFDE)
+4 ; used by AICS Workstation software
+5 ;
IDPAT(RESULT,FORMID) ; -- Procedure
+1 ; -- Broker call to identify patient, clinic, form, and appt. from
+2 ; Encounter form ID
+3 ; rpc := IBD EXPAND FORMID
+4 ;
+5 ; -- input FORMID = pointer to form tracking (357.96)
+6 ; Result = called by reference
+7 ;
+8 ; -- output The format of the returned array is as follows
+9 ; result = $p1 := Patient Name^
+10 ; $p2 := Patient IEN
+11 ; $p3:= patient primary identifier (pid)
+12 ; $p4 := form name
+13 ; $p5 := form IEN (pointer to 357)
+14 ; $p6 := Clinic Name
+15 ; $p7 := Clinic ien
+16 ; $p8 := Clinic Physical Location
+17 ; $p9 := Appt. date/time (fm format)
+18 ; $P10:= Appt. date/time (external format)
+19 ; $P11:= Appt Status internal
+20 ; $P12:= Appt Status external
+21 ; $P13:= form input status internal
+22 ; $p14:= form input status external
+23 ; $p15:= form definition ien (357.95)
+24 ; $p16:= default provider (for clinic) internal
+25 ; $p17:= default provider (for clinic) external
+26 ; $P18:= # Scannable pages on form
+27 ; $p19:= shortedge/long edge binding
+28 ; $p20:= check out date time
+29 ;
+30 NEW C,I,J,X,Y,NODE,PATNM,DFN,PID,CLIN,CLINNM,FORMNM,FORM,APPT,APPTNM,STATUS,STATNM,FRMDEF,PROVDEF,APPTSTI,APPTSTE,CLINPH,DUPLX,SCANPG,CO
+31 KILL RESULT
+32 SET FORMID("SOURCE")=1
+33 ;
+34 ; -- scanner may send in leading spaces, strip it off
+35 IF +FORMID'=FORMID
IF $LENGTH(FORMID)
SET FORMID=+$PIECE(FORMID," ",3)
+36 SET RESULT="Form ID not a valid value, null or zero^^^"
+37 IF '$GET(FORMID)
DO LOGERR^IBDF18E2(3579604,.FORMID)
GOTO IDPATQ
+38 ;
+39 SET RESULT="Form ID not found^^^"
+40 SET NODE=$GET(^IBD(357.96,+FORMID,0))
+41 IF NODE=""
DO LOGERR^IBDF18E2(3579605,.FORMID)
GOTO IDPATQ
+42 ;
+43 SET DFN=$PIECE(NODE,"^",2)
+44 SET PATNM=$PIECE($GET(^DPT(DFN,0)),"^")
SET PID=$PIECE($GET(^DPT(DFN,.36)),"^",3)
+45 SET APPT=+$PIECE(NODE,"^",3)
+46 SET APPTSTI=$PIECE($GET(^DPT(DFN,"S",APPT,0)),"^",2)
+47 SET APPTNM=$$FMTE^XLFDT(APPT)
+48 ;
+49 SET X=$$STATUS^SDAM1(DFN,APPT,+$GET(^DPT(DFN,"S",APPT,0)),$GET(^(0)))
+50 SET APPTSTE=$PIECE(X,";",3)
SET CO=$PIECE(X,";",5)
+51 IF $GET(^DPT(DFN,"S",APPT,0))=""
IF CO=""
Begin DoDot:1
+52 SET CO=+$$SDV(DFN,APPT)
+53 IF CO
SET APPTSTE="COMPLETE"
+54 IF +$GET(CO)<1
SET APPTSTE="ACTION REQUIRED"
End DoDot:1
+55 ;
+56 SET CLIN=+$PIECE(NODE,"^",10)
+57 SET CLINNM=$PIECE($GET(^SC(CLIN,0)),"^")
SET CLINPH=$PIECE($GET(^SC(CLIN,0)),"^",11)
+58 SET PROVDEF=$$PRDEF(CLIN)
+59 SET FRMDEF=$PIECE(NODE,"^",4)
+60 SET FORM=+$PIECE($GET(^IBD(357.95,+FRMDEF,0)),"^",21)
+61 SET FORMNM=$PIECE($GET(^IBE(357,FORM,0)),"^")
+62 ; Duplex/simplex
SET DUPLX=$PIECE($GET(^IBE(357,FORM,0)),"^",2)
+63 SET (SCANPG,I)=0
FOR
SET I=$ORDER(^IBD(357.96,+FORMID,9,I))
IF 'I
QUIT
SET SCANPG=SCANPG+1
+64 SET STATUS=$PIECE(NODE,"^",11)
+65 SET Y=STATUS
SET C=$PIECE(^DD(357.96,.11,0),"^",2)
DO Y^DIQ
SET STATNM=Y
+66 SET RESULT=PATNM_"^"_DFN_"^"_PID_"^"_FORMNM_"^"_FORM_"^"_CLINNM_"^"_CLIN_"^"_CLINPH_"^"_APPT_"^"_APPTNM_"^"_APPTSTI_"^"_APPTSTE_"^"_STATUS_"^"_STATNM_"^"_FRMDEF_"^"_PROVDEF_"^"_$PIECE($GET(^VA(200,+PROVDEF,0)),"^")_"^"_SCANPG_"^"_DUPLX_"^"_CO
+67 ;
IDPATQ QUIT
+1 ;
PRDEF(CLIN) ;Provider Default for Clinic
+1 ; Input -- SDCL Hospital Location file IEN
+2 ; IF DEFINED: DFN - ptr to PATIENT File
+3 ; Output -- Default
+4 NEW Y,X
+5 SET Y=$PIECE($GET(^SC(+$GET(CLIN),"PR",+$ORDER(^SC("ADPR",CLIN,0)),0)),"^")
+6 IF $GET(Y)=""
IF $GET(^SC(+$GET(CLIN),"PC"))
IF $DATA(DFN)
IF $LENGTH($TEXT(NMPCPR^SCAPMCU2))
SET Y=+$$NMPCPR^SCAPMCU2(DFN,DT,1)
+7 QUIT $GET(Y)
+8 ;
SDV(DFN,APPT) ; -- try to find checkout date of stand alone encounter
+1 NEW CO,QUIT,SDV,SDV1,SDOE
+2 SET CO=""
SET SDOE=""
+3 SET SDV=+$PIECE(APPT,".")
SET QUIT=0
+4 FOR
SET SDV=+$ORDER(^SDV("C",DFN,SDV))
IF 'SDV!(QUIT)
QUIT
Begin DoDot:1
+5 SET SDV1=0
FOR
SET SDV1=+$ORDER(^SDV(+SDV,"CS",SDV1))
IF 'SDV1!(QUIT)
QUIT
Begin DoDot:2
+6 SET SDOE=+$PIECE($GET(^SDV(+SDV,"CS",+SDV1,0)),"^",8)
+7 SET X=$GET(^SCE(+SDOE,0))
IF +X=APPT
SET CO=$PIECE(X,"^",7)
SET QUIT=1
End DoDot:2
End DoDot:1
+8 QUIT CO_"^"_SDOE