Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: APSPCO

APSPCO.m

Go to the documentation of this file.
APSPCO ; IHS/MSC/PLS - List Manager Complete Orders ;24-Jul-2013 08:46;PLS
 ;;7.0;IHS PHARMACY MODIFICATIONS;**1013,1014,1015,1016**;Sep 23, 2004;Build 74
 ; Modified - IHS/MSC/PB - 09/28/012 - OERR+26 to remove patient language flag
 ;=================================================================
 ;IHS/MSC/MGH Patch 1016 ADDITEM +2,6,11 Added visual for a flagged order
EN ; -- main entry point for APSP COMPLETE ORDERS
 D:'$D(PSOPAR) ^PSOLSET I '$D(PSOPAR) D MSG^PSODPT G EX^PSOORFIN
 N APSPINS,APSPQ,LOCFLG,APSPLOCS,APSPSORT,APSPORPT
 N APSPPTAY,LOCLIEN,APSPFRST
 S APSPQ=0,APSPINS=""
 S APSPINS=$$DIR^APSPUTIL("Y","Would you like orders for all Ordering Institutions","Yes",,.APSPQ)
 I APSPINS D
 .S APSPINS="*"
 E  D  Q:APSPQ
 .S APSPINS=$$GETIEN^APSPUTIL(4,"Select Ordering Institution: ",.APSPQ)
 Q:APSPQ
 S APSPFRST=1
 D EN^VALM("APSP COMPLETE ORDERS")
 D CLEAR^VALM1
 D FULL^VALM1
 W:$D(IOF) @IOF
 Q
 ;
HDR ; -- header code
 ;S XQORM("#")=$O(^ORD(101,"B","APSPCO PROCESS SELECT",0))_"^1:"_VALMCNT
 S VALMHDR(1)="Outpatient Pharmacy Pending Orders"_"    Related Institution: "_$S(APSPINS:$$GET1^DIQ(4,APSPINS,.01),APSPINS="*":"ALL",1:" ")
 S VALMHDR(2)="Sorted by: "_$G(APSPSORT)_"   Restrict to locations: "_$S(LOCFLG:"ON for "_$$GET1^DIQ(9009033.6,$G(LOCLIEN),.01),1:"OFF")
 Q
 ;
INIT ; -- init variables and list array
 S LOCFLG=$G(LOCFLG,0)
 S APSPORPT=$G(APSPORPT,+$$GET^XPAR("ALL","APSPCO DEFAULT VIEW"))
 S APSPSORT=$S(APSPORPT:"Patient Name",1:"Order Date")
 D CLEAN^VALM10
 D BUILDLST(APSPINS)
 M SAVE=VALM
 S:APSPFRST APSPFRST=0
 Q
 ; Set line into array
SETARR(LINE,TEXT,IEN) ;EP-
 S @VALMAR@(LINE,0)=TEXT
 S:$G(IEN) @VALMAR@("IDX",LINE,LINE)=""
 S @VALMAR@(LINE,"POFIEN")=LINE_U_IEN
 Q
 ;
HELP ; -- help code
 S X="?" D DISP^XQORM1 W !!
 Q
 ;
EXIT ; -- exit code
 K SAVE
 Q
 ;
EXPND ; -- expand code
 Q
 ; Build list of pending orders
BUILDLST(INST) ;EP-
 I APSPORPT D TOGORPT Q
 N LD,RI,IEN
 S VALMCNT=0  ;LOCFLG=0
 ;D CHGCAP^VALM("ORDDT","Order Date")
 D UPDCOL(APSPORPT)
 S LD=0 F  S LD=$O(^PS(52.41,"AD",LD)) Q:'LD  D
 .S RI=0 F  S RI=$O(^PS(52.41,"AD",LD,RI)) Q:'RI  D
 ..Q:(INST'="*")&(RI'=INST)
 ..S IEN=0 F  S IEN=$O(^PS(52.41,"AD",LD,RI,IEN)) Q:'IEN  D
 ...D ADDITEM(IEN,INST)
 Q
 ; Add a single line item
ADDITEM(IEN,INST) ;EP-
 N NOD0,LINE,COM,PTLOCK,FLAG
 S FLAG=0
 S NOD0=$G(^PS(52.41,IEN,0))
 Q:'NOD0
 I LOCFLG Q:'$D(APSPLOCS($P(NOD0,U,13)))
 I $P($G(^PS(52.41,IEN,0)),"^",23)=1 S FLAG=1
 S VALMCNT=VALMCNT+1
 S COM=$P($G(^PS(52.41,IEN,4)),U)
 S LINE=$$SETFLD^VALM1(VALMCNT,"","ITEM")
 S LINE=$$SETFLD^VALM1($$HRN^AUPNPAT($P(NOD0,U,2),$S(INST:INST,1:DUZ(2))),LINE,"HRN")
 S LINE=$$SETFLD^VALM1($S($$PTLOCK($P(NOD0,U,2)):"*",1:"")_$$GET1^DIQ(2,$P(NOD0,U,2),.01),LINE,"PATIENT")
 S LINE=$$SETFLD^VALM1($$FMTE^XLFDT($$DOB^AUPNPAT($P(NOD0,U,2)),"5Z"),LINE,"DOB")
 S LINE=$$SETFLD^VALM1($S($L(COM):"#",1:""),LINE,"CFLG")
 S LINE=$$SETFLD^VALM1($TR($$FMTE^XLFDT($E($P(NOD0,U,6),1,12),"5Z"),"@"," "),LINE,"ORDDT")
 S LINE=$$SETFLD^VALM1($$GET1^DIQ(44,$P(NOD0,U,13),.01),LINE,"HOSPLOC")
 ;S LINE=$$SETFLD^VALM1($P(NOD0,U),LINE,"ORDNUM")
 S LINE=$$SETFLD^VALM1($S($L(COM)>30:$E(COM,1,27)_"...",1:COM),LINE,"COMMENT")
 I FLAG=1 D CNTRL^VALM10(VALMCNT,1,3,IORVON,IORVOFF,0)
 D SETARR(VALMCNT,LINE,IEN)
 Q
 ; Return lock state of patient record
PTLOCK(DFN) ;EP-
 Q ''$G(^XTMP("PSSLOCK",DFN))
 ;
LOCARY ;EP-
 N LOCARY,LP
 S LOCLIEN=$$PMTLLST^APSPCO1()
 Q:'LOCLIEN
 K APSPLOCS
 S LP=0
 F  S LP=$O(^APSPLRS(9009033.6,LOCLIEN,1,LP)) Q:'LP  D
 .S APSPLOCS(+^APSPLRS(9009033.6,LOCLIEN,1,LP,0))=""
 Q
 ; Build list of orders using location list
LOCLST ;EP-
 N LD,RI,IEN
 S VALMCNT=0
 D CLEAN^VALM10
 ;D CHGCAP^VALM("ORDDT","Order Date")
 D UPDCOL(APSPORPT)
 S LD=0 F  S LD=$O(^PS(52.41,"AD",LD)) Q:'LD  D
 .S RI=0 F  S RI=$O(^PS(52.41,"AD",LD,RI)) Q:'RI  D
 ..Q:(APSPINS'="*")&(RI'=APSPINS)
 ..S IEN=0 F  S IEN=$O(^PS(52.41,"AD",LD,RI,IEN)) Q:'IEN  D
 ...D ADDITEM(IEN,APSPINS)
 S VALMBCK="R"
 D FIRST^VALM4
 D RE^VALM4
 Q
 ; Custom sort list
SORTLST ;EP-
 N NARY,APSPQ,LP,CNT,NOD0,IDX,CL,IEN,POFIEN,SELITMS
 D FULL^VALM1
 S APSPQ=0
 S CNT=0
 S SELITMS="1:HRN;2:Patient Name;3:DOB;4:Order Date;5:Hospital Location"
 S CL=+$$DIR^APSPUTIL("S^"_SELITMS,1,,.APSPQ)
 Q:APSPQ
 S APSPSORT=$P($P(SELITMS,";",CL),":",2)
 S LP=0
 F  S LP=$O(@VALMAR@(LP)) Q:'LP  D
 .S POFIEN=$P(@VALMAR@(LP,"POFIEN"),U,2)
 .Q:'POFIEN
 .S NOD0=$G(^PS(52.41,POFIEN,0))
 .Q:'NOD0
 .S IDX=$S(CL=1:+$$HRN^AUPNPAT($P(NOD0,U,2),$S(APSPINS:APSPINS,1:DUZ(2))),CL=2:$$GET1^DIQ(2,$P(NOD0,U,2),.01),CL=3:$$DOB^AUPNPAT($P(NOD0,U,2)),CL=5:$$GET1^DIQ(44,$P(NOD0,U,13),.01),1:$$SRTDT())  ;1:$P(NOD0,U,6))
 .S CNT=CNT+1
 .S NARY("IDX",IDX,POFIEN)=""
 D CLEAN^VALM10
 S VALMCNT=0
 S LP=""
 F  S LP=$O(NARY("IDX",LP)) Q:'$L(LP)  D
 .S IEN=0
 .F  S IEN=$O(NARY("IDX",LP,IEN)) Q:'IEN  D
 ..D ADDITEM(IEN,APSPINS)
 S VALMBCK="R"
 D FIRST^VALM4
 D RE^VALM4
 Q
 ; Return sort date
SRTDT() ;EP-
 Q $S($P(NOD0,U,6):$P(NOD0,U,6),$P(NOD0,U,12):$P(NOD0,U,12),1:$$NOW^XLFDT())
 ; Post message that patient record is locked
LOCCHK ;EP-
 N MSG,DFN,ITM,VAL
 S MSG="",VALMBCK=""
 D EN^VALM2(XQORNOD(0),"SO")
 S ITM=$O(VALMY(""))
 Q:'ITM
 S VAL=$P(@VALMAR@(ITM,"POFIEN"),U,2)
 Q:'VAL
 I 'APSPORPT D  Q:'DFN
 .S DFN=$P($G(^PS(52.41,VAL,0)),U,2)
 E  S DFN=VAL
 I $G(^XTMP("PSSLOCK",DFN)) D
 .S MSG=$$WHO^PSSLOCK(DFN)
 .S MSG=$$GET1^DIQ(200,+$P($G(^XTMP("PSSLOCK",DFN)),U),.01)_" is editing orders ("_$$FMTE^XLFDT($E($P($G(^XTMP("PSSLOCK",DFN)),U,2),1,12),"5Z")_")"
 S VALMSG=$S($L(MSG):MSG,1:"This patient is available for processing.")
 Q
 ;
SELORD ;
 N Y
 S Y=$P(XQORNOD(0),"=",2)
 D PROC1
 Q
 ; Process patient orders
PROCESS ;EP-
 N DIR,DUOUT,DIRUT,Y
 S DIR("A")="Select Orders by number",DIR(0)="LO^1:"_VALMCNT D ^DIR
 I $D(DIRUT)!$D(DUOUT) S VALMBCK="R" Q
PROC1 ;EP-
 N SAVEPAT,LASTDFN,APSPORD,LST,APSPLP,PSODFN,PAT,PSOLK
 N MEDA,PSOFIN,X,MEDP,PATA,ORD
 K APSPPTAY
 S SAVEPAT=""
 I +Y D FULL^VALM1 S LST=Y
 D BLDPTARY(.APSPPTAY,LST,APSPORPT)
 S LASTDFN=0
 S APSPLP=0 F  S APSPLP=$O(APSPPTAY(APSPLP)) Q:'APSPLP  D
 .N VALM,VALMPGE
 .I SAVEPAT'=APSPLP,$O(PSORX("PSOL",0))!($D(RXRS)) D
 ..N ZP
 ..S ZP=PSODFN
 ..S PSODFN=+PSODFN D LBL^PSOORFIN  ;MGH ADD
 ..S PSODFN=ZP
 .S (PAT,SAVEPAT)=APSPLP
 .I '$D(^PS(52.41,"P",PAT)) D
 ..W !,"The orders for this patient have already been processed!"
 .D LK^PSOORFIN I $G(POERR("QFLG")) K POERR("QFLG") S PSOLK=1 Q
 .I $$CHK^PSODPT(PAT_U_$P($G(^DPT(PAT,0)),U),1,1)<0 S PSOLK=1 S X=PAT D ULP^PSOORFIN K PSOQFLG,PSOQQ Q
 .S (PSODFN,Y)=PAT_U_$P($G(^DPT(PAT,0)),U)
 .S (PATA,LASTDFN)=+PSODFN
 .D SETPTCX^APSPFUNC(+PSODFN)
 .D:'$G(MEDA) PROFILE^PSOORFI2 M VALM=SAVE
 .S Y=PSODFN
 .I $G(MEDP) D  Q
 ..D SPL^PSOORFIN D OERR(Y) S PSOFIN=1 D QU^PSOORFIN S X=PSOPTLOK D KLLP^PSOORFIN,ULP^PSOORFIN,KLL^PSOORFIN
 .D SDFN^PSOORFIN
 .D POST(Y)
 .I $G(PSOQFLG)!($G(PSOQUIT)) S:$G(PSOQUIT) POERR("QFLG")=1 S X=SAVEPAT D ULP^PSOORFIN K PSOQFLG Q
 .S APSPORD=0 F  S APSPORD=$O(^PS(52.41,"P",APSPLP,APSPORD)) Q:'APSPORD!($G(POERR("QFLG")))!($G(PSOQQ))  D
 ..S ORD=APSPORD
 ..D:$P(^PS(52.41,APSPORD,0),U,3)'="DC"&($P(^(0),U,3)'="DE") PP^PSOORFIN,LK1^PSOORFIN,ORD^PSOORFIN Q
 .S PSOFIN=1,X=PAT D ULP^PSOORFIN K PSOQQ
 I $O(PSORX("PSOL",0))!($D(RXRS)) S PSODFN=+PSODFN D LBL^PSOORFIN ;MGH Get the last one
 I $G(PSOQUIT) K PSOQUIT
 D EX^PSOORFIN
 M VALM=SAVE
 D INIT
 D RE^VALM4
 S VALMBCK="R"
 Q
 ; Toggle Orders/Patients
TOGORPT ;EP-
 N PNM,IEN,PTOCNT,DFN,LD,RI
 S PNM=""  ;,LOCFLG=0
 ;Reset LOCFLG on when APSPORPT for patient list
 ;S LOCFLG=$S('APSPORPT:LOCFLG,1:0)
 S (VALMCNT,PTOCNT,DFN)=0
 D CLEAN^VALM10
 ;S APSPSORT="Patient Name"
 S APSPSORT=$S(APSPORPT:"Patient Name",1:"Order Date")
 D UPDCOL(APSPORPT)
 I 'APSPORPT D
 .;D CHGCAP^VALM("ORDDT","Order Date")
 .S LD=0 F  S LD=$O(^PS(52.41,"AD",LD)) Q:'LD  D
 ..S RI=0 F  S RI=$O(^PS(52.41,"AD",LD,RI)) Q:'RI  D
 ...Q:(APSPINS'="*")&(RI'=APSPINS)
 ...S IEN=0 F  S IEN=$O(^PS(52.41,"AD",LD,RI,IEN)) Q:'IEN  D
 ....D:$L($G(^PS(52.41,IEN,0))) ADDITEM(IEN,APSPINS)
 E  D
 .;D CHGCAP^VALM("ORDDT","Order Count")
 .N LOCNM
 .S LOCNM=""
 .F  S PNM=$O(^PS(52.41,"PN",PNM)) Q:PNM=""  D  I PTOCNT>0 D ADDPT(DFN,APSPINS,PTOCNT,LOCNM)
 ..S DFN=0,PTOCNT=0
 ..S IEN=0  F  S IEN=$O(^PS(52.41,"PN",PNM,IEN)) Q:'IEN  D
 ...Q:'$L($G(^PS(52.41,IEN,0)))
 ...Q:(APSPINS'="*")&(+$G(^PS(52.41,IEN,"INI"))'=APSPINS)  ;check institution
 ...Q:"DEDC"[$P($G(^PS(52.41,IEN,0)),U,3)   ;="DC"  ;Discontinued or Discontinued (Edit)
 ...S PTOCNT=PTOCNT+1
 ...S LOCNM=$$GET1^DIQ(44,$P(^PS(52.41,IEN,0),U,13),.01)
 ...S:'DFN DFN=$P(^PS(52.41,IEN,0),U,2)
 S VALMBCK="R"
 I 'APSPFRST D
 .D FIRST^VALM4
 .D RE^VALM4
 Q
 ; Add patient to array
ADDPT(DFN,INST,ORDCNT,LOCNM) ;EP-
 N LINE,PTLOCK
 ;Exclude patient if LOCFLG enabled and not part of location array list.
 Q:$$NOLOC(DFN)
 S VALMCNT=VALMCNT+1
 D UPDCOL(APSPORPT)
 S LINE=$$SETFLD^VALM1(VALMCNT,"","ITEM")
 S LINE=$$SETFLD^VALM1($$HRN^AUPNPAT(DFN,$S(INST:INST,1:DUZ(2))),LINE,"HRN")
 S LINE=$$SETFLD^VALM1($S($$PTLOCK(DFN):"*",1:"")_$$GET1^DIQ(2,DFN,.01),LINE,"PATIENT")
 S LINE=$$SETFLD^VALM1($$FMTE^XLFDT($$DOB^AUPNPAT(DFN),"5Z"),LINE,"DOB")
 S LINE=$$SETFLD^VALM1(ORDCNT,LINE,"ORDDT")
 S LINE=$$SETFLD^VALM1(LOCNM,LINE,"HOSPLOC")
 D SETARR(VALMCNT,LINE,DFN)
 Q
 ;Returns a 1 if patient lacks an order with location in APSPLOCS array when LOCFLG=1
NOLOC(DFN) ;EP-
 N LP,RES
 Q:'LOCFLG 0
 S LP=0
 F  S LP=$O(APSPLOCS(LP)) Q:'LP  D  Q:RES
 .S RES=''$D(^PS(52.41,"HLP",LP,DFN))
 Q 'RES
 ; Build a patient array
BLDPTARY(ARY,LST,TYP) ;EP-
 N ITM,POFIEN,DFN,IEN,VAL
 F ITM=1:1:$L(LST,",") Q:$P(LST,",",ITM)']""  S VAL=$P(LST,",",ITM) D
 .I TYP D
 ..S DFN=$P(@VALMAR@(VAL,"POFIEN"),U,2)
 ..Q:'DFN
 ..S ARY(DFN)=DFN
 .E  D
 ..S IEN=$P(@VALMAR@(VAL,"POFIEN"),U,2)
 ..Q:'IEN
 ..S DFN=$P($G(^PS(52.41,IEN,0)),U,2)
 ..Q:'DFN
 ..S ARY(DFN)=DFN
 Q
 ; Update column headings
 ; Input- 0=Order  1=Patient
UPDCOL(MODE) ;EP-
 D CHGCAP^VALM("ORDDT",$S(MODE:"Order Count",1:"Order Date"))
 D CHGCAP^VALM("CFLG",$S(MODE:"",1:"C"))
 D CHGCAP^VALM("COMMENT",$S(MODE:"",1:"Comment"))
 Q
 ;
CHGCOM ;EP-
 D CHGCOM^APSPCO1
 Q
 ;
POST(Y) ;
 N PSOFINY,VALM,VALMCNT,VALMAR,APSPDFN
 S (APSPDFN,PSOFINY)=+$G(Y) D ^PSOBUILD S Y=$G(PSOFINY) K PSOFINY
 M VALM=SAVE
 ;D OERR(APSPDFN)
 Q:$G(PSOQFLG)
 ;S PSODFN=APSPDFN
 S (DFN,PSODFN)=+Y,PSORX("NAME")=$P(Y,"^",2)
 K PSOQFLG F PT="GET","DEAD","INP","CNH","TPB","ADDRESS","COPAY" S RTN=PT_"^PSOPTPST" D @RTN K PSOXFLG Q:$G(POERR("DEAD"))!($G(PSOQFLG))
 I $G(POERR("DEAD")) S POERR("QFLG")=1 Q
 K PSOERR("DEAD") I $G(PSOQFLG) Q
 D ^PSOORUT2
 D BLD^PSOORUT1
 D EN^PSOLMUTL
 Q
 ;
OERR(Y) ;EP-Copied from PSORX1
 N PSODFN,PSOQFLG,DFN,NOPROC,DIC,DR,DIQ,DA,PSOFIN,PSOLOUD,DIE,DLAYGO
 N:$G(MEDP) PAT,POERR K PSOXFLG
 S (DFN,PSODFN)=+Y,PSORX("NAME")=$P(Y,"^",2)
 ;K NPPROC,PSOQFLG,DIC,DR,DIQ
 S DIC=2,DA=PSODFN,DR=.351,DIQ="PSOPTPST"
 D EN^DIQ1 K DIC,DA,DR,DIQ
 D DEAD^PSOPTPST I $G(PSOQFLG) S NOPROC=1 Q
 I $P($G(^PS(55,PSODFN,"LAN")),"^") W !,"Patient has another language preference!",! H 3
 I $G(^PS(55,"ASTALK",PSODFN)) W !,"Patient is enrolled to receive ScripTalk 'talking' prescription labels.",! H 2 D MAIL^PSORX1
 D NOW^%DTC S TM=$E(%,1,12),TM1=$P(TM,".",2) S ^TMP("PSOBB",$J)=TM_"^"_TM1
 I '$G(MEDP) S X="PPPPDA1" X ^%ZOSF("TEST") S:$T X=$$PDA^PPPPDA1(PSODFN)
 S PSOQFLG=0,DIC="^PS(55,",DLAYGO=55
 I $G(PSOFIN) S SSN=$P(^DPT(PSODFN,0),"^",9) W !!?10,$C(7),PSORX("NAME")_" ("_$E(SSN,1,3)_"-"_$E(SSN,4,5)_"-"_$E(SSN,6,9)_")" K SSN
 K PSOPBM ; KILL SO THAT WON'T CARRY OVER PRIOR PATIENT'S VALUE
 I '$D(^PS(55,PSODFN,0)) D
 .S PSOPBM=$P(TM,".")
 .K DD,DO S DIC(0)="L",(DINUM,X)=PSODFN D FILE^DICN D:Y<1  K DIC,DA,DR,DD,DO
 ..S $P(^PS(55,PSODFN,0),"^")=PSODFN K DIK S DA=PSODFN,DIK="^PS(55,",DIK(1)=.01 D EN^DIK K DIK
 S PSOLOUD=1 D:$P($G(^PS(55,PSODFN,0)),"^",6)'=2 EN^PSOHLUP(PSODFN) K PSOLOUD
 I $G(^PS(55,PSODFN,"PS"))']"" D  I $G(POERR("QFLG")) G EOJ
 .L +^PS(55,PSODFN):0 I '$T W $C(7),!!,"Patient Data is Being Edited by Another User!",! S POERR("QFLG")=1 S:$G(PSOFIN) PSOQUIT=1 Q
 .S PSOXFLG=1,SSN=$P(^DPT(PSODFN,0),"^",9) W !!?10,$C(7),PSORX("NAME")_" ("_$E(SSN,1,3)_"-"_$E(SSN,4,5)_"-"_$E(SSN,6,9)_")",! K SSN
 .;IHS/MSC/PB - 09/28/2012 - Remove other language field
 .;S DIE=55,DR=".02;.03;.04;.05;1;D ELIG^PSORX1;3;50;106;106.1",DA=PSODFN W !!,?5,">>PHARMACY PATIENT DATA<<",! D ^DIE L -^PS(55,PSODFN)
 .S DIE=55,DR=".02;.03;.04;.05;1;D ELIG^PSORX1;3;50;106.1",DA=PSODFN W !!,?5,">>PHARMACY PATIENT DATA<<",! D ^DIE L -^PS(55,PSODFN)
 S PSOX=$G(^PS(55,PSODFN,"PS")) I PSOX]"" S PSORX("PATIENT STATUS")=$P($G(^PS(53,PSOX,0)),"^")
 I $G(^PS(55,PSODFN,"PS"))']"" D  I $G(POERR("QFLG")) G EOJ
 .W !!,"Patient Status Required!!",! D ELIG^PSORX1
 .W ! K POERR("QFLG"),DIC,DR,DIE S DIC("A")="PATIENT STATUS: ",DIC(0)="QEAMZ",DIC=53 D ^DIC K DIC
 .I $D(DIRUT)!(Y=-1) D  Q
 ..W $C(7),"Required Data!",! S POERR("QFLG")=1 S:$G(PSOFIN) PSOQUIT=1
 ..I $G(PSOPBM) D  K PSOPBM
 ...I $O(^PS(55,PSODFN,0))="" S DA=PSODFN,DIK="^PS(55," D ^DIK
 .S ^PS(55,PSODFN,"PS")=+Y,PSORX("PATIENT STATUS")=$P(^PS(53,+Y,0),"^")
 .K DIRUT,DTOUT,DUOUT,X,Y,DA
 Q:$G(PSOFIN)
 I '$G(PSOPBM),'$P(^PS(55,PSODFN,0),"^",7),$P(^(0),"^",8)']"" S PSOPBM=$P(TM,".")
 D ^PSOBUILD
 F PT="GET","DEAD","INP","CNH","TPB","ADDRESS","COPAY" S RTN=PT_"^PSOPTPST" D @RTN Q:$G(POERR("DEAD"))!($G(PSOQFLG))
 I $G(POERR("DEAD")) S POERR("QFLG")=1 F II=0:0 S II=$O(^PS(52.41,"P",PSODFN,II)) D:$P($G(^PS(52.41,II,0)),"^",3)'="DC"&($P($G(^(0)),"^",3)'="DE") DC^PSOORFI2
 K PSOERR("DEAD"),II
 I $G(PSOQFLG) S POERR("QFLG")=1 G EOJ
 S (PAT,PSOXXDFN)=PSODFN,POERR=1 D ^PSOORUT2,BLD^PSOORUT1,EN^PSOLMUTL
 D CLEAR^VALM1 M VALM=SAVE G:$G(PSOQUIT) PTX D EN^PSOLMAO
EOJ K PSOX,PSORXED
 Q
PTX ;
 K X,Y,^TMP("PS",$J),C,DEA,PRC,PSCNT,PSOACT,PSOCLC,PSOCS,PSOCT,PSOFINFL,PSOHD,PSOLST,PSOOPT,PSOPF,PSOX,PSOX1,PSOXXDFN,SIGOK,STP,STR
 Q
 ;
SELLLST ;EP-Supports the APSPCO LOC RESTRICT SEL protocol
 ;S LOCLLIEN=$$PMTLLST^APSPCO1()
 D FULL^VALM1
 D LOCARY
 D LOCLST
 Q
 ;
EDTLLST ;EP-Supports the APSPCO LOC RESTRICT EDIT protocol
 D FULL^VALM1
 D EDTLLST^APSPCO1
 S VALMBCK="R"
 Q
 ;
UPDLST ;EP- Updates list based on current criteria
 D TOGORPT
 Q