ORQPTQ6 ; SLC/PKS [8/27/03 11:20am]
;;3.0;ORDER ENTRY/RESULTS REPORTING;**82,85,187**;Dec 17, 1997
;
; Called by BUILD^ORQPT (LM) and DEFLIST^ORQPTQ11 (GUI).
;
Q
;
COMBPTS(ORQLM,ORQCPTR,ORBDATE,OREDATE) ; Build "Combination" pt. list.
; SLC/PKS.
;
; NOTE: Any calls to this tag need to deal with ORQLM passed
; variable appropriately. Notice where it is evaluated
; and make sure code specifies the setting of ORQLM (a
; boolean variable) properly for the call.
;
; Variables used:
;
; MSG = Holds error message, if any.
; ORBDATE = PASSED: Beginning date for clinic appointments.
; OREDATE = PASSED: End date for clinic appointments.
; ORQCNT = Counter for patients.
; ORQCPTR = PASSED: Combination file [^OR(100.24,] pointer.
; ORQDUZ = DUZ of current user.
; ORQERR = Array for error msg(s) return from DB calls.
; ORQFILE = Combo source entry file.
; ORQLM = PASSED: Called from LM ("1") or GUI ("0")?
; ORQPDAT = String holder for arrays and ^TMP file values.
; ORQPDOB = Patient DOB.
; ORQPFMDT = Hold app't date/time in FM internal format.
; ORQPIEN = Variable for patient IEN, ^TMP("OR",$J,"PTSCOMBO")
; ORQPMOR = Appointment or Room/Bed information.
; ORQPNM = Variable for patient name, ^TMP("OR",$J,"PTSCOMBO")
; ORQPSNM = Source name display string holder.
; ORQPSSN = Patient ID (first letter of last name, last 4 SSN).
; ORQPSTAT = Ipt or Opt (or C/NS) status for clinic lists.
; ORQPTMP = Temporary string construction holder.
; ORQPTR = Pointer to combo source entry.
; ORQRTN = Holds return value from DB calls.
; ORQSPCH = Holds return value from SELCHK^ORWPT.
; ORQSRC = Variable to hold each combo source subscript.
; ORQSRCID = IEN of source.
; ORQTXT = Variable to hold stored values.
; ORY = Array used in sub-calls.
;
; (NOTE: LCNT,LIST,MSG,NUM,SORT new'd in calling routines for LM.)
;
N ORQCNT,ORQDUZ,ORQERR,ORQFILE,ORQPCNT,ORQPDAT,ORQPDOB,ORQPFMDT,ORQPIEN,ORQPNM,ORQPMOR,ORQPSNM,ORQPSSN,ORQPSTAT,ORQPTMP,ORQPTR,ORQRTN,ORQSPCH,ORQSRC,ORQSRCID,ORQTXT,ORY
;
K ^TMP("OR",$J,"PATIENTS") ; Safety cleanup.
;
; Do preliminary settings, cleanup, look for an existing user record:
S MSG="" ; Default.
I '$D(DUZ) D
.S MSG="No user DUZ info."
.I 'ORQLM D GUIABORT
.Q
S ORQDUZ=DUZ
K ORQERR
S ORQRTN=$$FIND1^DIC(100.24,"","QX",ORQDUZ,"","","ORQERR")
K ORQERR
D CLEAN^DILF ; Clean up after DB call.
;
; If no combination record, then punt:
I +ORQRTN<1 D
.S MSG="No combination entry."
.I 'ORQLM D GUIABORT
.Q
;
I ORQLM D CLEAN^VALM10 ; VALM housekeeping.
;
; Order through the user's combination source entries:
I 'ORQLM S SORT="A" ; Required variable for PTSCOMBO^ORQPTQ5.
S ORQSRC=0
F S ORQSRC=$O(^OR(100.24,ORQRTN,.01,ORQSRC)) Q:'ORQSRC D
.K ORY ; Clean up each time.
.S ORQTXT="" ; Initialize.
.S ORQTXT=$G(^OR(100.24,ORQRTN,.01,ORQSRC,0)) ; Get record's value.
.;
.; In case of error, punt:
.I ORQTXT="" D
..S MSG="Combination source entry error."
..I 'ORQLM D GUIABORT ; GUI is different.
..Q
.I ORQTXT="" Q
.S ORQPTR=$P(ORQTXT,";") ; Get pointer.
.S ORQFILE="^"_$P(ORQTXT,";",2) ; Get file.
.;
.; Get info for each source entry and build ORY array accordingly.
.I ORQFILE="^DIC(42," D Q ; Wards.
..D WARDPTS^ORQPTQ2(.ORY,ORQPTR)
..I $D(ORY) D PTSCOMBO^ORQPTQ5("W",ORQPTR) ; Process ORY array.
.I ORQFILE="^VA(200," D Q ; Providers.
..D PROVPTS^ORQPTQ2(.ORY,ORQPTR)
..I $D(ORY) D PTSCOMBO^ORQPTQ5("P",ORQPTR) ; Process ORY array.
.I ORQFILE="^DIC(45.7," D Q ; Specialties.
..D SPECPTS^ORQPTQ2(.ORY,ORQPTR)
..I $D(ORY) D PTSCOMBO^ORQPTQ5("S",ORQPTR) ; Process ORY array.
.I ORQFILE="^OR(100.21," D Q ; Team Lists
..D TEAMPTS^ORQPTQ1(.ORY,ORQPTR)
..I $D(ORY) D PTSCOMBO^ORQPTQ5("T",ORQPTR) ; Process ORY array.
.I ORQFILE="^SC(" D Q ; Clinics.
..D CLINPTS^ORQPTQ2(.ORY,ORQPTR,ORBDATE,OREDATE)
..I $D(ORY) D PTSCOMBO^ORQPTQ5("C",ORQPTR) ; Process ORY array.
;
; Order thru ^TMP file "B" node entries returned by previous calls:
S ORQCNT=0 ; Reset for final use.
I $D(^TMP("OR",$J,"PATIENTS")) D
.S ORQPDAT=""
.F S ORQPDAT=$O(^TMP("OR",$J,"PATIENTS","B",ORQPDAT)) Q:ORQPDAT="" D
..;
..; Clear variables each time through:
..S (ORQTXT,ORQPFMDT,ORQPIEN,ORQPNM,ORQPSSN,ORQPSTAT,ORQPDOB,ORQPSNM,ORQPMOR,ORQSRCID)=""
..;
..; Retrieve node's value:
..S ORQTXT=$G(^TMP("OR",$J,"PATIENTS","B",ORQPDAT))
..;
..; Set indvidual variables:
..S ORQPIEN=$P(ORQTXT,U) ; Patient DFN.
..S ORQPNM=$P(ORQTXT,U,2) ; Patient name.
..S ORQPSSN=$P(ORQTXT,U,3) ; Patient ID.
..S ORQPDOB=$P(ORQTXT,U,4) ; Patient DOB.
..S ORQPSNM=$P(ORQTXT,U,5) ; Source data.
..S ORQPMOR=$P(ORQTXT,U,6) ; App't or R/B info.
..S ORQSRCID=$P(ORQTXT,U,7) ; Source IEN.
..S ORQPFMDT=$P(ORQTXT,U,8) ; App't FM date/time.
..S ORQPSTAT=$P(ORQTXT,U,9) ; Ipt/Opt status.
..S ORQCNT=ORQCNT+1 ; Increment counter.
..;
..; If a "sensitive" patient, reassign SSN, DOB data:
..S ORQSPCH=$$SSN^DPTLK1(ORQPIEN)
..I ORQSPCH["*" S ORQPSSN=""
..S ORQPDOB=$$DOB^DPTLK1(ORQPIEN)
..;
..; Make some preliminary data settings:
..S ORQPTMP=""
..I ORQPSNM'="" S ORQPTMP=ORQPSNM_" "
..S ORQPTMP=ORQPTMP_ORQPMOR
..;
..; Write new ^TMP file "PATIENTS" nodes:
..I ORQLM D ; For LM.
...S ^TMP("OR",$J,"PATIENTS","IDX",ORQCNT)=ORQPIEN_U_ORQPNM
...S ^TMP("OR",$J,"PATIENTS",ORQCNT,0)=$$LJ^XLFSTR(ORQCNT,5)_$$LJ^XLFSTR(ORQPNM,31)_$$LJ^XLFSTR(ORQPSSN,10)_$$LJ^XLFSTR(ORQPDOB,15)_ORQPTMP_$$LJ^XLFSTR(ORQPDOB,15)_$$RJ^XLFSTR(ORQSRCID,8)_" "_ORQPFMDT
...D CNTRL^VALM10(ORQCNT,1,5,IOINHI,IOINORM)
..;
..I 'ORQLM D ; For GUI.
...S ORQTXT=ORQPIEN_U_ORQPNM_U_ORQPSNM_U_ORQPMOR_U_ORQPSSN_U_ORQPDOB_U_ORQSRCID_U_ORQPFMDT_U_ORQPSTAT
...S ^TMP("OR",$J,"PATIENTS",ORQCNT,0)=ORQTXT ; Actual global write.
;
; Set counters for return, if applicable; do cleanup:
I ORQCNT S (LCNT,NUM)=ORQCNT
K ORY
;
; If no patients found, prepare user message:
I 'ORQCNT S MSG="No patients found."
;
; If an error message exists, dump any partial processing and quit:
I MSG'="" D Q
.I 'ORQLM D GUIABORT
.I ORQLM K ^TMP("OR",$J,"PATIENTS")
;
; Next lines create #line^^#pts^context value entry:
I ORQLM D
.S ^TMP("OR",$J,"PATIENTS",0)=ORQCNT_U_ORQCNT_U_$G(LIST)
.S ^TMP("OR",$J,"PATIENTS","#")=$O(^ORD(101,"B","ORQPT SELECT PATIENT",0))_"^1:"_ORQCNT
;
; Standard clean-up for GUI:
I 'ORQLM D
.K LCNT,LIST,MSG,NUM,SORT
.K ^TMP("OR",$J,"PATIENTS","B")
;
Q
;
GUIABORT ; Cleanup when aborting when called from GUI.
;
K ^TMP("OR",$J,"PATIENTS")
S ^TMP("OR",$J,"PATIENTS",0)=""
K LCNT,LIST,MSG,NUM,SORT
;
Q
;
ORQPTQ6 ; SLC/PKS [8/27/03 11:20am]
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**82,85,187**;Dec 17, 1997
+2 ;
+3 ; Called by BUILD^ORQPT (LM) and DEFLIST^ORQPTQ11 (GUI).
+4 ;
+5 QUIT
+6 ;
COMBPTS(ORQLM,ORQCPTR,ORBDATE,OREDATE) ; Build "Combination" pt. list.
+1 ; SLC/PKS.
+2 ;
+3 ; NOTE: Any calls to this tag need to deal with ORQLM passed
+4 ; variable appropriately. Notice where it is evaluated
+5 ; and make sure code specifies the setting of ORQLM (a
+6 ; boolean variable) properly for the call.
+7 ;
+8 ; Variables used:
+9 ;
+10 ; MSG = Holds error message, if any.
+11 ; ORBDATE = PASSED: Beginning date for clinic appointments.
+12 ; OREDATE = PASSED: End date for clinic appointments.
+13 ; ORQCNT = Counter for patients.
+14 ; ORQCPTR = PASSED: Combination file [^OR(100.24,] pointer.
+15 ; ORQDUZ = DUZ of current user.
+16 ; ORQERR = Array for error msg(s) return from DB calls.
+17 ; ORQFILE = Combo source entry file.
+18 ; ORQLM = PASSED: Called from LM ("1") or GUI ("0")?
+19 ; ORQPDAT = String holder for arrays and ^TMP file values.
+20 ; ORQPDOB = Patient DOB.
+21 ; ORQPFMDT = Hold app't date/time in FM internal format.
+22 ; ORQPIEN = Variable for patient IEN, ^TMP("OR",$J,"PTSCOMBO")
+23 ; ORQPMOR = Appointment or Room/Bed information.
+24 ; ORQPNM = Variable for patient name, ^TMP("OR",$J,"PTSCOMBO")
+25 ; ORQPSNM = Source name display string holder.
+26 ; ORQPSSN = Patient ID (first letter of last name, last 4 SSN).
+27 ; ORQPSTAT = Ipt or Opt (or C/NS) status for clinic lists.
+28 ; ORQPTMP = Temporary string construction holder.
+29 ; ORQPTR = Pointer to combo source entry.
+30 ; ORQRTN = Holds return value from DB calls.
+31 ; ORQSPCH = Holds return value from SELCHK^ORWPT.
+32 ; ORQSRC = Variable to hold each combo source subscript.
+33 ; ORQSRCID = IEN of source.
+34 ; ORQTXT = Variable to hold stored values.
+35 ; ORY = Array used in sub-calls.
+36 ;
+37 ; (NOTE: LCNT,LIST,MSG,NUM,SORT new'd in calling routines for LM.)
+38 ;
+39 NEW ORQCNT,ORQDUZ,ORQERR,ORQFILE,ORQPCNT,ORQPDAT,ORQPDOB,ORQPFMDT,ORQPIEN,ORQPNM,ORQPMOR,ORQPSNM,ORQPSSN,ORQPSTAT,ORQPTMP,ORQPTR,ORQRTN,ORQSPCH,ORQSRC,ORQSRCID,ORQTXT,ORY
+40 ;
+41 ; Safety cleanup.
KILL ^TMP("OR",$JOB,"PATIENTS")
+42 ;
+43 ; Do preliminary settings, cleanup, look for an existing user record:
+44 ; Default.
SET MSG=""
+45 IF '$DATA(DUZ)
Begin DoDot:1
+46 SET MSG="No user DUZ info."
+47 IF 'ORQLM
DO GUIABORT
+48 QUIT
End DoDot:1
+49 SET ORQDUZ=DUZ
+50 KILL ORQERR
+51 SET ORQRTN=$$FIND1^DIC(100.24,"","QX",ORQDUZ,"","","ORQERR")
+52 KILL ORQERR
+53 ; Clean up after DB call.
DO CLEAN^DILF
+54 ;
+55 ; If no combination record, then punt:
+56 IF +ORQRTN<1
Begin DoDot:1
+57 SET MSG="No combination entry."
+58 IF 'ORQLM
DO GUIABORT
+59 QUIT
End DoDot:1
+60 ;
+61 ; VALM housekeeping.
IF ORQLM
DO CLEAN^VALM10
+62 ;
+63 ; Order through the user's combination source entries:
+64 ; Required variable for PTSCOMBO^ORQPTQ5.
IF 'ORQLM
SET SORT="A"
+65 SET ORQSRC=0
+66 FOR
SET ORQSRC=$ORDER(^OR(100.24,ORQRTN,.01,ORQSRC))
IF 'ORQSRC
QUIT
Begin DoDot:1
+67 ; Clean up each time.
KILL ORY
+68 ; Initialize.
SET ORQTXT=""
+69 ; Get record's value.
SET ORQTXT=$GET(^OR(100.24,ORQRTN,.01,ORQSRC,0))
+70 ;
+71 ; In case of error, punt:
+72 IF ORQTXT=""
Begin DoDot:2
+73 SET MSG="Combination source entry error."
+74 ; GUI is different.
IF 'ORQLM
DO GUIABORT
+75 QUIT
End DoDot:2
+76 IF ORQTXT=""
QUIT
+77 ; Get pointer.
SET ORQPTR=$PIECE(ORQTXT,";")
+78 ; Get file.
SET ORQFILE="^"_$PIECE(ORQTXT,";",2)
+79 ;
+80 ; Get info for each source entry and build ORY array accordingly.
+81 ; Wards.
IF ORQFILE="^DIC(42,"
Begin DoDot:2
+82 DO WARDPTS^ORQPTQ2(.ORY,ORQPTR)
+83 ; Process ORY array.
IF $DATA(ORY)
DO PTSCOMBO^ORQPTQ5("W",ORQPTR)
End DoDot:2
QUIT
+84 ; Providers.
IF ORQFILE="^VA(200,"
Begin DoDot:2
+85 DO PROVPTS^ORQPTQ2(.ORY,ORQPTR)
+86 ; Process ORY array.
IF $DATA(ORY)
DO PTSCOMBO^ORQPTQ5("P",ORQPTR)
End DoDot:2
QUIT
+87 ; Specialties.
IF ORQFILE="^DIC(45.7,"
Begin DoDot:2
+88 DO SPECPTS^ORQPTQ2(.ORY,ORQPTR)
+89 ; Process ORY array.
IF $DATA(ORY)
DO PTSCOMBO^ORQPTQ5("S",ORQPTR)
End DoDot:2
QUIT
+90 ; Team Lists
IF ORQFILE="^OR(100.21,"
Begin DoDot:2
+91 DO TEAMPTS^ORQPTQ1(.ORY,ORQPTR)
+92 ; Process ORY array.
IF $DATA(ORY)
DO PTSCOMBO^ORQPTQ5("T",ORQPTR)
End DoDot:2
QUIT
+93 ; Clinics.
IF ORQFILE="^SC("
Begin DoDot:2
+94 DO CLINPTS^ORQPTQ2(.ORY,ORQPTR,ORBDATE,OREDATE)
+95 ; Process ORY array.
IF $DATA(ORY)
DO PTSCOMBO^ORQPTQ5("C",ORQPTR)
End DoDot:2
QUIT
End DoDot:1
+96 ;
+97 ; Order thru ^TMP file "B" node entries returned by previous calls:
+98 ; Reset for final use.
SET ORQCNT=0
+99 IF $DATA(^TMP("OR",$JOB,"PATIENTS"))
Begin DoDot:1
+100 SET ORQPDAT=""
+101 FOR
SET ORQPDAT=$ORDER(^TMP("OR",$JOB,"PATIENTS","B",ORQPDAT))
IF ORQPDAT=""
QUIT
Begin DoDot:2
+102 ;
+103 ; Clear variables each time through:
+104 SET (ORQTXT,ORQPFMDT,ORQPIEN,ORQPNM,ORQPSSN,ORQPSTAT,ORQPDOB,ORQPSNM,ORQPMOR,ORQSRCID)=""
+105 ;
+106 ; Retrieve node's value:
+107 SET ORQTXT=$GET(^TMP("OR",$JOB,"PATIENTS","B",ORQPDAT))
+108 ;
+109 ; Set indvidual variables:
+110 ; Patient DFN.
SET ORQPIEN=$PIECE(ORQTXT,U)
+111 ; Patient name.
SET ORQPNM=$PIECE(ORQTXT,U,2)
+112 ; Patient ID.
SET ORQPSSN=$PIECE(ORQTXT,U,3)
+113 ; Patient DOB.
SET ORQPDOB=$PIECE(ORQTXT,U,4)
+114 ; Source data.
SET ORQPSNM=$PIECE(ORQTXT,U,5)
+115 ; App't or R/B info.
SET ORQPMOR=$PIECE(ORQTXT,U,6)
+116 ; Source IEN.
SET ORQSRCID=$PIECE(ORQTXT,U,7)
+117 ; App't FM date/time.
SET ORQPFMDT=$PIECE(ORQTXT,U,8)
+118 ; Ipt/Opt status.
SET ORQPSTAT=$PIECE(ORQTXT,U,9)
+119 ; Increment counter.
SET ORQCNT=ORQCNT+1
+120 ;
+121 ; If a "sensitive" patient, reassign SSN, DOB data:
+122 SET ORQSPCH=$$SSN^DPTLK1(ORQPIEN)
+123 IF ORQSPCH["*"
SET ORQPSSN=""
+124 SET ORQPDOB=$$DOB^DPTLK1(ORQPIEN)
+125 ;
+126 ; Make some preliminary data settings:
+127 SET ORQPTMP=""
+128 IF ORQPSNM'=""
SET ORQPTMP=ORQPSNM_" "
+129 SET ORQPTMP=ORQPTMP_ORQPMOR
+130 ;
+131 ; Write new ^TMP file "PATIENTS" nodes:
+132 ; For LM.
IF ORQLM
Begin DoDot:3
+133 SET ^TMP("OR",$JOB,"PATIENTS","IDX",ORQCNT)=ORQPIEN_U_ORQPNM
+134 SET ^TMP("OR",$JOB,"PATIENTS",ORQCNT,0)=$$LJ^XLFSTR(ORQCNT,5)_$$LJ^XLFSTR(ORQPNM,31)_$$LJ^XLFSTR(ORQPSSN,10)_$$LJ^XLFSTR(ORQPDOB,15)_ORQPTMP_$$LJ^XLFSTR(ORQPDOB,15)_$$RJ^XLFSTR(ORQSRCID,8)_" "_ORQPFMDT
+135 DO CNTRL^VALM10(ORQCNT,1,5,IOINHI,IOINORM)
End DoDot:3
+136 ;
+137 ; For GUI.
IF 'ORQLM
Begin DoDot:3
+138 SET ORQTXT=ORQPIEN_U_ORQPNM_U_ORQPSNM_U_ORQPMOR_U_ORQPSSN_U_ORQPDOB_U_ORQSRCID_U_ORQPFMDT_U_ORQPSTAT
+139 ; Actual global write.
SET ^TMP("OR",$JOB,"PATIENTS",ORQCNT,0)=ORQTXT
End DoDot:3
End DoDot:2
End DoDot:1
+140 ;
+141 ; Set counters for return, if applicable; do cleanup:
+142 IF ORQCNT
SET (LCNT,NUM)=ORQCNT
+143 KILL ORY
+144 ;
+145 ; If no patients found, prepare user message:
+146 IF 'ORQCNT
SET MSG="No patients found."
+147 ;
+148 ; If an error message exists, dump any partial processing and quit:
+149 IF MSG'=""
Begin DoDot:1
+150 IF 'ORQLM
DO GUIABORT
+151 IF ORQLM
KILL ^TMP("OR",$JOB,"PATIENTS")
End DoDot:1
QUIT
+152 ;
+153 ; Next lines create #line^^#pts^context value entry:
+154 IF ORQLM
Begin DoDot:1
+155 SET ^TMP("OR",$JOB,"PATIENTS",0)=ORQCNT_U_ORQCNT_U_$GET(LIST)
+156 SET ^TMP("OR",$JOB,"PATIENTS","#")=$ORDER(^ORD(101,"B","ORQPT SELECT PATIENT",0))_"^1:"_ORQCNT
End DoDot:1
+157 ;
+158 ; Standard clean-up for GUI:
+159 IF 'ORQLM
Begin DoDot:1
+160 KILL LCNT,LIST,MSG,NUM,SORT
+161 KILL ^TMP("OR",$JOB,"PATIENTS","B")
End DoDot:1
+162 ;
+163 QUIT
+164 ;
GUIABORT ; Cleanup when aborting when called from GUI.
+1 ;
+2 KILL ^TMP("OR",$JOB,"PATIENTS")
+3 SET ^TMP("OR",$JOB,"PATIENTS",0)=""
+4 KILL LCNT,LIST,MSG,NUM,SORT
+5 ;
+6 QUIT
+7 ;