ORLP1 ; SLC/DCM,CLA - Patient Lists, Store ; [1/3/01 1:37pm]
;;3.0;ORDER ENTRY/RESULTS REPORTING;**11,63,90,98**;Dec 17, 1997
;
STOR ;called by ORLP0 - Store lists
N %,DA,DIC,DIK,DIR,DLAYGO,DR,ORLIST,ORLN,I,J,X,Y
W !!,"Store list for future reference"
S %=1 D YN^DICN Q:%=-1
I %=0 W !,"You may store the newly compiled list. Answer YES or NO." G STOR
Q:%=2
;
GETNAME ; Call DIR to get user entry for new list name:
N ORTNAM
S ORTNAM=""
N ORNEWL ; Flag used to indicate a new list (v. existing list).
S ORNEWL=1 ; Begin w/assumption of a new list name.
F D Q:$D(X)
.S DIR(0)="FAO^3:30",DIR("A")="Enter a name for this list: "
.D ^DIR
.I '$D(X)!($D(DIRUT)) K DIRUT W " List not permanently stored." Q
.S (ORLN,ORTNAM)=X
.S X=$G(X),DIC="^OR(100.21,"
.D ^DIC
I '$D(X)!(X="") Q
I +Y>0 S ORLIST=+Y,ORLN=$P(Y,U,2) K DIC S Y=ORLIST S ORNEWL=0 ; List name already exists.
;
OVRWR ;
N ORABORT ; Flag for aborting process.
S ORABORT=0
;
; Check for problems with name entry:
I 'ORNEWL D
.I $$NAMCH(+ORLIST) S ORABORT=1
I ORABORT G GETNAME
;
; Ask - overwrite if an existing team by that name already?:
I 'ORNEWL D
.I $O(^OR(100.21,+Y,10,0)) D Q:%'=1 ; Any patients on list yet?
..F D Q:%
...W !,ORLN_" already has patients. Do you want to overwrite it"
...S %=2 D YN^DICN
...I %=2!(%=-1) W !,"List ",ORLN," unchanged.",! S ORABORT=1 Q
...I '% W !,"Answer YES or NO, if you answer YES the list "_ORLN_" will be cleared,",!,"and this temporary list will overwrite it.",! Q
.I ORABORT Q
.L +^OR(100.21,+ORLIST)
.I '$D(^OR(100.21,ORLIST,10,0))#2 S ^(0)="^100.2101AV^"
.I '$D(^OR(100.21,ORLIST,1,0))#2 S ^(0)="^100.212PA^"
.S I=0 F S I=$O(^OR(100.21,ORLIST,10,I)) Q:'I S DA=+I,DA(1)=+ORLIST,DIK="^OR(100.21,"_ORLIST_",10," D ^DIK
.L -^OR(100.21,+ORLIST)
I ORABORT G GETNAME
;
; If a new list name, write new team into OE/RR LIST file:
I ORNEWL D
.S DIC="^OR(100.21,",DLAYGO=100.21,DIC(0)="LEFQZ"
.D ^DIC
.I (Y<0!'$D(X)) S ORABORT=1 Q ; User aborted or there was a problem.
.S ORLIST=+Y
I ORABORT K DIC Q
;
; Assure other required entries if necessary:
I ORNEWL D
.I $P($G(^OR(100.21,+ORLIST,1,0)),U,2)'="P" D
..S DIE="^OR(100.21,",DA=ORLIST,DR="1///^S X=""P"""
..D ^DIE
..K DIE,DA
.I '$D(^OR(100.21,+ORLIST,1,DUZ)) S DA(1)=ORLIST,DIC="^OR(100.21,"_DA(1)_",1,",DIC(0)="LX",X="`"_DUZ D ^DIC K DIC
;
; Add selected patients to list (if any):
L +^OR(100.21,+ORLIST)
S ORI=0
F S ORI=$O(^XUTL("OR",$J,"ORLP",ORI)) Q:ORI<1 I $D(^(ORI,0)) S X=^(0),X="PT.`"_+$P(X,"^",3),DA(1)=ORLIST,DIC="^OR(100.21,"_ORLIST_",10,",DIC(0)="LX" D ^DIC
K DIC,ORI
L -^OR(100.21,ORLIST)
W !!,"List has been stored."
Q
;
MERG ;called by option ORLP MERG - merge patient lists
D CLEAR^ORLP ;clear XUTL for merge
D ASK^ORLP0(.X)
I (X<0)!(X>1) Q
S:'$D(ORCNT) ORCNT=0
W @IOF,!,"Merging patients from two or more Personal and/or Team patient lists.",!
S DIC="^OR(100.21,",DIC(0)="AEQM",DIC("S")="I ""PT""[$E($P(^(0),U,2))"
F ORK=1:1 S ORCT=0,DIC("A")="Select LIST "_ORK_": " D P1^ORLP0 Q:ORY<1 I ORCNT>0 W !!,ORCT_" Patients added, "_ORCNT_" total"
Q:$D(DTOUT)!($D(DUOUT))
I 'ORCNT W !!,"List empty.",! D END^ORLP0 Q
D PR2^ORLA1(OROPREF)
W !!,"LIST PATIENTS MERGED"
D LIST^ORLP0
D STOR,END^ORLP0
D BUILD^ORLA1 ;load XUTL with user's primary list
K DIC,ORCEND,ORCLIN,ORCNT,ORCOLW,ORCSTRT,ORCT,ORDEF,ORK,ORPRIM,ORPROV,ORSPEC,ORTITLE,ORUPNM,ORUSSN,ORWARD,Y
Q
;
DEL ;called by option ORLP DELETE - delete a list
I '$D(ORLST) S DIC="^OR(100.21,",DIC(0)="AEQM",DIC("S")="I $P(^(0),U,2)'=""P""",DIC("A")="Select Team PATIENT LIST to delete: "
I $D(ORLST) S DIC="^OR(100.21,",DIC(0)="AEQM",DIC("S")="I $P(^(0),U,2)=""P""&($D(^OR(100.21,""C"",DUZ,+Y)))",DIC("A")="Select Personal PATIENT LIST to delete: "
D ^DIC
K DIC
I Y<1 Q
S DLIST=Y
;
D2 ;
S %=""
I $$GET^XPAR("USR.`"_DUZ,"ORLP DEFAULT TEAM",1,"I")=+DLIST W !!,"This is your primary patient list, are you sure you want to remove it" S %=2 D YN^DICN
I %=0 W !,"Answer YES if you really want to remove this list." G D2
I %'="" Q:%'=1
W !!,"WARNING - Deleting a patient list will disable access by providers who use the",!,"list as their preferred patient list."
;
D1 ;
W !,"Are you ready to delete list ",$P(DLIST,"^",2)
S %=2 D YN^DICN
I %=0 W !,"Enter YES to delete the list, NO to quit." G D1
Q:%'=1
W !,"Processing........"
L +^OR(100.21,+DLIST)
S DA=+DLIST,DIK="^OR(100.21,"
D ^DIK
K DA,DIC,DIK
;
; Next 2 lines added by PKS, 2/8/2000:
W !,"Searching for/removing Consults pointers to deleted team..."
D CLNLIST^GMRCTU(+DLIST,0) ; Dump pointers to team in file 123.5.
;
W !,"List deletion completed.",!
L -^OR(100.21,+DLIST)
K DLIST,ORLPDUZ,Y,XX,^TMP("ORLP",$J,"TLIST") ;KILL temporary list
G DEL
Q
;
CLEAR(X) ;called by option ORLP CLEAR - clear active list
I '$D(^XUTL("OR",$J,"ORLP")) W !!,"No list currently defined" S X=1 Q
F D Q:X
. W !!,"Are you sure you want to clear the current pt selection list"
. S %=2 D YN^DICN
. I %=-1 S X=% Q
. I %=0 W !!,"YES will clear the current pt selection list and leave you with a blank slate to work from." S X=0 Q
. I %=1 K ^XUTL("OR",$J,"ORLP"),^("ORV"),^("ORU"),^("ORW") S:$D(ORCNT) ORCNT=0 W !!,"List cleared" S X=% Q
. W !!,"Nothing done."
. S X=2
Q
;
NAMCH(ORTEAM) ; Check for name duplication, proper team type.
;
; Variables used:
;
; ORTEAM = IEN of team in Team List file (^OR100.21).
;
; Check for name duplication and not a "Personal" type team:
I $P($G(^OR(100.21,ORTEAM,0)),U,2)'="P" D Q 1
.W !,ORTNAM," name already used - can't overwrite.",!
.K X,Y,ORLIST,ORLN
;
; Check for "Personal" type but not current user's team:
; ("CREATOR" field was added later, so not used here.)
; Is this user's DUZ in "USER" multiple?
I '$D(^OR(100.21,"C",DUZ,ORTEAM)) D Q 1
.W !,ORTNAM," name exists, you are not a user - can't overwrite.",!
.K X,Y,ORLIST,ORLN
;
Q 0
;
OWNER ; Get input from CAC for list user/owner.
;
; Variables used herein:
;
; DIR,X,Y = FM call variables.
; ORYY = NEW'd in calling routine (ORLP).
; OROWNER = NEW'd in calling routine (ORLP).
;
N DIR,X,Y
;
; Assign variables and get input from CAC for user/owner of list:
S OROWNER="" ; Default.
S DIR(0)="PAO^200,:AEMNQ"
S DIR("A")=" Enter owner of this Personal type list: "
S DIR("S")="I $D(X),$D(^VA(200,""AK.PROVIDER"",$P(^(0),U))),$$ACTIVE^XUSER(+Y)"
S DIR("?")="Only owner you specify can edit list after creation."
D ^DIR
S OROWNER=Y
K DIR,X,Y ; Clean up.
I OROWNER<1 S OROWNER="" Q ; No acceptable entry.
S OROWNER=+OROWNER ; Selected user's DUZ.
S $P(^OR(100.21,+ORYY,0),U,5)=OROWNER ; Assign CREATOR field.
;
Q
;
ORLP1 ; SLC/DCM,CLA - Patient Lists, Store ; [1/3/01 1:37pm]
+1 ;;3.0;ORDER ENTRY/RESULTS REPORTING;**11,63,90,98**;Dec 17, 1997
+2 ;
STOR ;called by ORLP0 - Store lists
+1 NEW %,DA,DIC,DIK,DIR,DLAYGO,DR,ORLIST,ORLN,I,J,X,Y
+2 WRITE !!,"Store list for future reference"
+3 SET %=1
DO YN^DICN
IF %=-1
QUIT
+4 IF %=0
WRITE !,"You may store the newly compiled list. Answer YES or NO."
GOTO STOR
+5 IF %=2
QUIT
+6 ;
GETNAME ; Call DIR to get user entry for new list name:
+1 NEW ORTNAM
+2 SET ORTNAM=""
+3 ; Flag used to indicate a new list (v. existing list).
NEW ORNEWL
+4 ; Begin w/assumption of a new list name.
SET ORNEWL=1
+5 FOR
Begin DoDot:1
+6 SET DIR(0)="FAO^3:30"
SET DIR("A")="Enter a name for this list: "
+7 DO ^DIR
+8 IF '$DATA(X)!($DATA(DIRUT))
KILL DIRUT
WRITE " List not permanently stored."
QUIT
+9 SET (ORLN,ORTNAM)=X
+10 SET X=$GET(X)
SET DIC="^OR(100.21,"
+11 DO ^DIC
End DoDot:1
IF $DATA(X)
QUIT
+12 IF '$DATA(X)!(X="")
QUIT
+13 ; List name already exists.
IF +Y>0
SET ORLIST=+Y
SET ORLN=$PIECE(Y,U,2)
KILL DIC
SET Y=ORLIST
SET ORNEWL=0
+14 ;
OVRWR ;
+1 ; Flag for aborting process.
NEW ORABORT
+2 SET ORABORT=0
+3 ;
+4 ; Check for problems with name entry:
+5 IF 'ORNEWL
Begin DoDot:1
+6 IF $$NAMCH(+ORLIST)
SET ORABORT=1
End DoDot:1
+7 IF ORABORT
GOTO GETNAME
+8 ;
+9 ; Ask - overwrite if an existing team by that name already?:
+10 IF 'ORNEWL
Begin DoDot:1
+11 ; Any patients on list yet?
IF $ORDER(^OR(100.21,+Y,10,0))
Begin DoDot:2
+12 FOR
Begin DoDot:3
+13 WRITE !,ORLN_" already has patients. Do you want to overwrite it"
+14 SET %=2
DO YN^DICN
+15 IF %=2!(%=-1)
WRITE !,"List ",ORLN," unchanged.",!
SET ORABORT=1
QUIT
+16 IF '%
WRITE !,"Answer YES or NO, if you answer YES the list "_ORLN_" will be cleared,",!,"and this temporary list will overwrite it.",!
QUIT
End DoDot:3
IF %
QUIT
End DoDot:2
IF %'=1
QUIT
+17 IF ORABORT
QUIT
+18 LOCK +^OR(100.21,+ORLIST)
+19 IF '$DATA(^OR(100.21,ORLIST,10,0))#2
SET ^(0)="^100.2101AV^"
+20 IF '$DATA(^OR(100.21,ORLIST,1,0))#2
SET ^(0)="^100.212PA^"
+21 SET I=0
FOR
SET I=$ORDER(^OR(100.21,ORLIST,10,I))
IF 'I
QUIT
SET DA=+I
SET DA(1)=+ORLIST
SET DIK="^OR(100.21,"_ORLIST_",10,"
DO ^DIK
+22 LOCK -^OR(100.21,+ORLIST)
End DoDot:1
+23 IF ORABORT
GOTO GETNAME
+24 ;
+25 ; If a new list name, write new team into OE/RR LIST file:
+26 IF ORNEWL
Begin DoDot:1
+27 SET DIC="^OR(100.21,"
SET DLAYGO=100.21
SET DIC(0)="LEFQZ"
+28 DO ^DIC
+29 ; User aborted or there was a problem.
IF (Y<0!'$DATA(X))
SET ORABORT=1
QUIT
+30 SET ORLIST=+Y
End DoDot:1
+31 IF ORABORT
KILL DIC
QUIT
+32 ;
+33 ; Assure other required entries if necessary:
+34 IF ORNEWL
Begin DoDot:1
+35 IF $PIECE($GET(^OR(100.21,+ORLIST,1,0)),U,2)'="P"
Begin DoDot:2
+36 SET DIE="^OR(100.21,"
SET DA=ORLIST
SET DR="1///^S X=""P"""
+37 DO ^DIE
+38 KILL DIE,DA
End DoDot:2
+39 IF '$DATA(^OR(100.21,+ORLIST,1,DUZ))
SET DA(1)=ORLIST
SET DIC="^OR(100.21,"_DA(1)_",1,"
SET DIC(0)="LX"
SET X="`"_DUZ
DO ^DIC
KILL DIC
End DoDot:1
+40 ;
+41 ; Add selected patients to list (if any):
+42 LOCK +^OR(100.21,+ORLIST)
+43 SET ORI=0
+44 FOR
SET ORI=$ORDER(^XUTL("OR",$JOB,"ORLP",ORI))
IF ORI<1
QUIT
IF $DATA(^(ORI,0))
SET X=^(0)
SET X="PT.`"_+$PIECE(X,"^",3)
SET DA(1)=ORLIST
SET DIC="^OR(100.21,"_ORLIST_",10,"
SET DIC(0)="LX"
DO ^DIC
+45 KILL DIC,ORI
+46 LOCK -^OR(100.21,ORLIST)
+47 WRITE !!,"List has been stored."
+48 QUIT
+49 ;
MERG ;called by option ORLP MERG - merge patient lists
+1 ;clear XUTL for merge
DO CLEAR^ORLP
+2 DO ASK^ORLP0(.X)
+3 IF (X<0)!(X>1)
QUIT
+4 IF '$DATA(ORCNT)
SET ORCNT=0
+5 WRITE @IOF,!,"Merging patients from two or more Personal and/or Team patient lists.",!
+6 SET DIC="^OR(100.21,"
SET DIC(0)="AEQM"
SET DIC("S")="I ""PT""[$E($P(^(0),U,2))"
+7 FOR ORK=1:1
SET ORCT=0
SET DIC("A")="Select LIST "_ORK_": "
DO P1^ORLP0
IF ORY<1
QUIT
IF ORCNT>0
WRITE !!,ORCT_" Patients added, "_ORCNT_" total"
+8 IF $DATA(DTOUT)!($DATA(DUOUT))
QUIT
+9 IF 'ORCNT
WRITE !!,"List empty.",!
DO END^ORLP0
QUIT
+10 DO PR2^ORLA1(OROPREF)
+11 WRITE !!,"LIST PATIENTS MERGED"
+12 DO LIST^ORLP0
+13 DO STOR
DO END^ORLP0
+14 ;load XUTL with user's primary list
DO BUILD^ORLA1
+15 KILL DIC,ORCEND,ORCLIN,ORCNT,ORCOLW,ORCSTRT,ORCT,ORDEF,ORK,ORPRIM,ORPROV,ORSPEC,ORTITLE,ORUPNM,ORUSSN,ORWARD,Y
+16 QUIT
+17 ;
DEL ;called by option ORLP DELETE - delete a list
+1 IF '$DATA(ORLST)
SET DIC="^OR(100.21,"
SET DIC(0)="AEQM"
SET DIC("S")="I $P(^(0),U,2)'=""P"""
SET DIC("A")="Select Team PATIENT LIST to delete: "
+2 IF $DATA(ORLST)
SET DIC="^OR(100.21,"
SET DIC(0)="AEQM"
SET DIC("S")="I $P(^(0),U,2)=""P""&($D(^OR(100.21,""C"",DUZ,+Y)))"
SET DIC("A")="Select Personal PATIENT LIST to delete: "
+3 DO ^DIC
+4 KILL DIC
+5 IF Y<1
QUIT
+6 SET DLIST=Y
+7 ;
D2 ;
+1 SET %=""
+2 IF $$GET^XPAR("USR.`"_DUZ,"ORLP DEFAULT TEAM",1,"I")=+DLIST
WRITE !!,"This is your primary patient list, are you sure you want to remove it"
SET %=2
DO YN^DICN
+3 IF %=0
WRITE !,"Answer YES if you really want to remove this list."
GOTO D2
+4 IF %'=""
IF %'=1
QUIT
+5 WRITE !!,"WARNING - Deleting a patient list will disable access by providers who use the",!,"list as their preferred patient list."
+6 ;
D1 ;
+1 WRITE !,"Are you ready to delete list ",$PIECE(DLIST,"^",2)
+2 SET %=2
DO YN^DICN
+3 IF %=0
WRITE !,"Enter YES to delete the list, NO to quit."
GOTO D1
+4 IF %'=1
QUIT
+5 WRITE !,"Processing........"
+6 LOCK +^OR(100.21,+DLIST)
+7 SET DA=+DLIST
SET DIK="^OR(100.21,"
+8 DO ^DIK
+9 KILL DA,DIC,DIK
+10 ;
+11 ; Next 2 lines added by PKS, 2/8/2000:
+12 WRITE !,"Searching for/removing Consults pointers to deleted team..."
+13 ; Dump pointers to team in file 123.5.
DO CLNLIST^GMRCTU(+DLIST,0)
+14 ;
+15 WRITE !,"List deletion completed.",!
+16 LOCK -^OR(100.21,+DLIST)
+17 ;KILL temporary list
KILL DLIST,ORLPDUZ,Y,XX,^TMP("ORLP",$JOB,"TLIST")
+18 GOTO DEL
+19 QUIT
+20 ;
CLEAR(X) ;called by option ORLP CLEAR - clear active list
+1 IF '$DATA(^XUTL("OR",$JOB,"ORLP"))
WRITE !!,"No list currently defined"
SET X=1
QUIT
+2 FOR
Begin DoDot:1
+3 WRITE !!,"Are you sure you want to clear the current pt selection list"
+4 SET %=2
DO YN^DICN
+5 IF %=-1
SET X=%
QUIT
+6 IF %=0
WRITE !!,"YES will clear the current pt selection list and leave you with a blank slate to work from."
SET X=0
QUIT
+7 IF %=1
KILL ^XUTL("OR",$JOB,"ORLP"),^("ORV"),^("ORU"),^("ORW")
IF $DATA(ORCNT)
SET ORCNT=0
WRITE !!,"List cleared"
SET X=%
QUIT
+8 WRITE !!,"Nothing done."
+9 SET X=2
End DoDot:1
IF X
QUIT
+10 QUIT
+11 ;
NAMCH(ORTEAM) ; Check for name duplication, proper team type.
+1 ;
+2 ; Variables used:
+3 ;
+4 ; ORTEAM = IEN of team in Team List file (^OR100.21).
+5 ;
+6 ; Check for name duplication and not a "Personal" type team:
+7 IF $PIECE($GET(^OR(100.21,ORTEAM,0)),U,2)'="P"
Begin DoDot:1
+8 WRITE !,ORTNAM," name already used - can't overwrite.",!
+9 KILL X,Y,ORLIST,ORLN
End DoDot:1
QUIT 1
+10 ;
+11 ; Check for "Personal" type but not current user's team:
+12 ; ("CREATOR" field was added later, so not used here.)
+13 ; Is this user's DUZ in "USER" multiple?
+14 IF '$DATA(^OR(100.21,"C",DUZ,ORTEAM))
Begin DoDot:1
+15 WRITE !,ORTNAM," name exists, you are not a user - can't overwrite.",!
+16 KILL X,Y,ORLIST,ORLN
End DoDot:1
QUIT 1
+17 ;
+18 QUIT 0
+19 ;
OWNER ; Get input from CAC for list user/owner.
+1 ;
+2 ; Variables used herein:
+3 ;
+4 ; DIR,X,Y = FM call variables.
+5 ; ORYY = NEW'd in calling routine (ORLP).
+6 ; OROWNER = NEW'd in calling routine (ORLP).
+7 ;
+8 NEW DIR,X,Y
+9 ;
+10 ; Assign variables and get input from CAC for user/owner of list:
+11 ; Default.
SET OROWNER=""
+12 SET DIR(0)="PAO^200,:AEMNQ"
+13 SET DIR("A")=" Enter owner of this Personal type list: "
+14 SET DIR("S")="I $D(X),$D(^VA(200,""AK.PROVIDER"",$P(^(0),U))),$$ACTIVE^XUSER(+Y)"
+15 SET DIR("?")="Only owner you specify can edit list after creation."
+16 DO ^DIR
+17 SET OROWNER=Y
+18 ; Clean up.
KILL DIR,X,Y
+19 ; No acceptable entry.
IF OROWNER<1
SET OROWNER=""
QUIT
+20 ; Selected user's DUZ.
SET OROWNER=+OROWNER
+21 ; Assign CREATOR field.
SET $PIECE(^OR(100.21,+ORYY,0),U,5)=OROWNER
+22 ;
+23 QUIT
+24 ;