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

SCRPO.m

Go to the documentation of this file.
  1. SCRPO ;BP-CIOFO/KEITH - Report prompting utilities ; 20 Aug 99 7:46 AM
  1. ;;5.3;Scheduling;**177,297**;AUG 13, 1993
  1. ;
  1. DTR(SC,SCDTB,SCDTE) ;Date range prompts
  1. ;Input: SC=name of array to return values
  1. ; @SC@("DTR","BDT")=begin date (internal^external)
  1. ; @SC@("DTR","EDT")=end date (internal^external)
  1. ;Input: SCDTB=array to manipulate %DT begin date values (optional)
  1. ;Input: SCDTE=array to manipulate %DT end date values (optional)
  1. ;Output: '1' for success, '0' otherwise
  1. N %DT M %DT=SCDTB W !
  1. S:'$L($G(%DT)) %DT="AEPX"
  1. I %DT["A" S:'$L($G(%DT("A"))) %DT("A")="Select beginning date: "
  1. D ^%DT I Y<1 Q 0
  1. S @SC@("DTR","BEGIN")=Y X ^DD("DD") S @SC@("DTR","PBDT")=Y
  1. EDT K %DT M %DT=SCDTE W !
  1. S:'$L($G(%DT)) %DT="AEPX"
  1. I %DT["A" S:'$L($G(%DT("A"))) %DT("A")=" Select ending date: "
  1. D ^%DT I Y<1 K SC Q 0
  1. I Y<@SC@("DTR","BEGIN") W !!,$C(7),"End date cannot be before begin date!",! G EDT
  1. S @SC@("DTR","END")=Y X ^DD("DD") S @SC@("DTR","PEDT")=Y
  1. S @SC@("DTR","INCL")=0
  1. D XR(.SC,"DTR","Date Range") Q 1
  1. ;
  1. ATYPE(SC) ;Prompt for assignment types
  1. ;Input: SC=array to return values (pass by reference)
  1. ; @SC@("ATYPE")=assignment types (internal^external)
  1. ;Output: '1' for success, '0' otherwise
  1. N DIR,DTOUT,DUOUT
  1. S DIR(0)="S^P:PRIMARY CARE ASSIGNMENTS;N:NON-PRIMARY CARE ASSIGNMENTS;B:BOTH PC AND NON-PC"
  1. S DIR("A")="Specify the type of assignments to include",DIR("B")="BOTH"
  1. W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) 0
  1. S @SC@("ATYPE")=Y_U_Y(0)
  1. D XR(.SC,"ATYPE","Type of Assignments") Q 1
  1. ;
  1. DSUM(SC) ;Prompt for detail or summary
  1. ;Input SC=array to return values (pass by reference)
  1. ; @SC@("FMT")=format (internal^external)
  1. ;Output: '1' for success, '0' otherwise
  1. N DIR,DTOUT,DUOUT
  1. K DIR S DIR(0)="S^D:DETAIL + SUMMARY;S:SUMMARY ONLY"
  1. S DIR("A")="Specify output format",DIR("B")="DETAIL + SUMMARY"
  1. W ! D ^DIR Q:$D(DTOUT)!$D(DUOUT) 0
  1. S @SC@("FMT")=Y_U_Y(0)
  1. D XR(.SC,"FMT","Report Format") Q 1
  1. ;
  1. LIST(SC,WHAT,SUBH,LIMIT) ;Get list of entries from a file
  1. ;Input: SC=array to return values (pass by reference)
  1. ; @SC@(WHAT)="ALL" for all entries, or,
  1. ; @SC@(WHAT,ifn)=name of record
  1. ; @SC@(WHAT,name,ifn)=""
  1. ;Input: WHAT=type of selection
  1. ; "DIV" for division
  1. ; "TEAM" for TEAM
  1. ; "ROLE" for STANDARD POSITION
  1. ; "POS" for TEAM POSITION
  1. ; "PCP" for PC provider (NEW PERSON)
  1. ; "ASPR" for assigned provider (NEW PERSON)
  1. ; "APR" for associate provider (NEW PERSON)
  1. ; "CLINIC" for enrolled clinic (HOSPITAL LOCATION)
  1. ;Input: SUBH='1' to display category subheader (optional)
  1. ;Input: LIMIT=maximum selections (optional, default 20)
  1. ;Output: '1' for success, '0' otherwise
  1. ;
  1. N SCW,SCI,SCOUT,DIC,X,Y,SCA,SCB,SCQUIT,SCS,DTOUT,DUOUT
  1. Q:'$L(WHAT) 0 S:'$G(LIMIT) LIMIT=20 S (SCOUT,SCQUIT)=0
  1. F SCI="DIV","TEAM","ROLE","POS","PCP","ASPR","APR","CLINIC" S SCW(SCI)=""
  1. Q:'$D(SCW(WHAT)) 0
  1. D @WHAT S DIC(0)="AEMQ"
  1. I $G(SUBH) D SUBT^SCRPW50("**** "_SCA_" Selection ****")
  1. S SCB=$J("Select "_SCA_": ",29),DIC("A")=SCB_"ALL// "
  1. I $L($G(SCS)) S DIC("S")=SCS
  1. F SCI=1:1:LIMIT D Q:SCOUT!SCQUIT
  1. .W ! D ^DIC I $D(DTOUT)!$D(DUOUT) S SCQUIT=1 Q
  1. .I SCI=1,X="" W " (ALL)" S @SC@(WHAT)="ALL",SCOUT=1 Q
  1. .I X="" S SCOUT=1 Q
  1. .I Y>0 S @SC@(WHAT,+Y)=$P(Y,U,2),@SC@(WHAT,$P(Y,U,2),+Y)=""
  1. .S DIC("A")=SCB
  1. .Q
  1. D XR(.SC,WHAT,SCA) Q 'SCQUIT
  1. ;
  1. DIV S DIC="^DIC(4,",SCA="Institution",SCS="I $D(^SCTM(404.51,""AINST"",+Y))" Q
  1. TEAM S DIC="^SCTM(404.51,",SCA="Team" Q
  1. ROLE S DIC="^SD(403.46,",SCA="Role" Q
  1. POS S DIC="^SCTM(404.57,",SCA="Team Position" Q
  1. PCP S DIC="^VA(200,",SCA="PC Provider" Q
  1. ASPR S DIC="^VA(200,",SCA="Assigned Provider" Q
  1. APR S DIC="^VA(200,",SCA="Associate Provider" Q
  1. CLINIC S DIC="^SC(",SCA="Associated Clinic",DIC("S")="I $P(^(0),U,3)=""C""" Q
  1. ;
  1. SORT(SC,SCEL,SCSP) ;Prompt for optional sort elements
  1. ;Input: SC=array to return sort order (pass by reference)
  1. ;Input: SCX=comma delimited string of element acronyms where
  1. ; 'IN' = INSTITUTION
  1. ; 'TM' = TEAM
  1. ; 'RO' = ROLE
  1. ; 'TP' = TEAM POSITION
  1. ; 'PR' = PROVIDER
  1. ; 'AC' = ASSOCIATED CLINIC
  1. ; 'EC' = ENROLLED CLINIC
  1. ; 'PT' = PATIENT
  1. ; 'PA' = PATIENT
  1. ;Input: SCSP=acronym of last sort to add if not selected (optional)
  1. ;Output: '0' for abnormal exit, '1' otherwise
  1. ; @SC@("SORT",1,elementacronym)=element
  1. ; @SC@("SORT",2,elementacronym)=element, etc.
  1. ;
  1. N DIR,SCI,SCX,SCY,SCQUIT,SCZ
  1. Q:'$L(SCEL)
  1. S SCQUIT=0
  1. F SCI=1:1:$L(SCEL,",") D
  1. .S SCX=$P(SCEL,",",SCI),SCX=$S(SCX="PA":"PT",SCX="DV":"IN",1:SCX),SCY(SCX)=SCI,SCZ=$P($T(@SCX),";;",2)
  1. .S SCZ(SCX)=$P(SCZ,U,2),SCX=$P(SCZ,U)
  1. .I $L(SCX) S SCX(SCI)=";"_SCX
  1. .Q
  1. Q:'$O(SCX(""))
  1. S SCI=0 D QSORT("Sort output by")
  1. I $L($G(SCSP)),$D(SCY(SCSP)) D
  1. .S SCI=SCI+1,SCZ=$P($T(@SCSP),";;",2),@SC@("SORT",SCI)=$P(SCZ,":")_U_$P(SCZ,":",2)
  1. .Q
  1. D XR(.SC,"SORT","Output will be sorted by") Q 'SCQUIT
  1. ;
  1. QSORT(DIRA) ;Prompt for sort
  1. N DTOUT,DUOUT
  1. S DIR("A")=DIRA
  1. S DIR(0)=$$DIR0() Q:DIR(0)=""
  1. D ^DIR I $D(DTOUT)!$D(DUOUT) S SCQUIT=1 Q
  1. Q:X=""
  1. S SCI=SCI+1,@SC@("SORT",SCI)=$S(Y="IN":"DV",Y="PT":"PA",1:Y)_U_Y(0)_U_SCZ(Y)
  1. K SCX(SCY(Y)),SCY(Y) D QSORT("Within "_Y(0)_", sort by")
  1. Q
  1. ;
  1. DIR0() ;Return value for DIR(0)
  1. N SCI
  1. S SCX="",SCI=0
  1. F S SCI=$O(SCX(SCI)) Q:'SCI S SCX=SCX_SCX(SCI)
  1. S SCX=$E(SCX,2,999) S:$L(SCX) SCX="SO^"_SCX
  1. Q SCX
  1. ;
  1. DV ;;IN:INSTITUTION^SCDIV
  1. IN ;;IN:INSTITUTION^SCDIV
  1. TM ;;TM:TEAM^SCTEAM
  1. RO ;;RO:ROLE^SCROLE
  1. TP ;;TP:TEAM POSITION^SCPOS
  1. PR ;;PR:PROVIDER^SCPROV
  1. EC ;;EC:ENROLLED CLINIC^SCLINIC
  1. AC ;;AC:ASSOCIATED CLINIC^SCLINIC
  1. PA ;;PA:PATIENT^SCPAT
  1. PT ;;PT:PATIENT^SCPAT
  1. ;
  1. XR(SC,SUB,VAL) ;Create x-ref for printing parameters
  1. ;Input: SC=array to return parameters
  1. ;Input: SUB=name of subscript holding parameters being x-ref'd
  1. ;Input: VAL=value for item subtitle (optional)
  1. ;
  1. S @SC@("XR")=$G(@SC@("XR"))+1,@SC@("XR",@SC@("XR"),SUB)=$G(VAL) Q
  1. ;
  1. PPAR(SC,OK,SCT) ;Print report parameters
  1. ;Input: SC=array of report parameters
  1. ;Input: OK='1' to prompt for parameter ok (optional)
  1. ;Input: SCT=report title
  1. ;Output: '1' if ok, '0' otherwise
  1. ;
  1. N SCL,SCI,SCX,SCOUT,SCLAB,SCF,SCVAL,COL,DTOUT,DUOUT
  1. S COL=$S($E(IOST)="C":12,1:38)
  1. S (SCI,SCOUT)=0,SCLAB="",SCL=1
  1. F S SCI=$O(@SC@("XR",SCI)) Q:'SCI!SCOUT D
  1. .S SCX=$O(@SC@("XR",SCI,"")),SCLAB=@SC@("XR",SCI,SCX)
  1. .I $E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
  1. .I $E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
  1. .S SCL=SCL+1 W ! Q:SCX="SPACE"
  1. .S SCL=SCL+1 W !?(COL),$J(SCLAB,24),": "
  1. .I SCX="DTR" W @SC@("DTR","PBDT")," to ",@SC@("DTR","PEDT") Q
  1. .I $G(@SC@(SCX))="ALL" W "ALL" Q
  1. .I $D(@SC@(SCX))=1 W $P(@SC@(SCX),U,2) Q
  1. .I SCX="SORT" S SCF=0,SCVAL=0 D Q
  1. ..F S SCVAL=$O(@SC@(SCX,SCVAL)) Q:'SCVAL!SCOUT D
  1. ...I SCF,$E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
  1. ...I SCF,$E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
  1. ...I SCF W ! S SCL=SCL+1
  1. ...W ?(COL+26+$S(SCX="SORT":(SCF*2),1:0)),$P(@SC@(SCX,SCVAL),U,2)
  1. ...S SCF=SCF+1
  1. ...Q
  1. ..Q
  1. .S SCF=0,SCVAL=999999999999
  1. .F S SCVAL=$O(@SC@(SCX,SCVAL)) Q:SCVAL=""!SCOUT D
  1. ..I $E(IOST)="C",SCL>18 D WAIT Q:SCOUT S SCL=0
  1. ..I $E(IOST)="P",$Y>(IOSL-4) D HDR(.SCT) Q:SCOUT
  1. ..I SCF W ! S SCL=SCL+1
  1. ..W ?(COL+26+$S(SCX="SORT":(SCF*2),1:0)),SCVAL
  1. ..S SCF=SCF+1
  1. ..Q
  1. .Q
  1. S SCX=1 I $G(OK) N DIR S DIR(0)="Y",DIR("B")="YES",DIR("A")="OK" D
  1. .W ! D ^DIR I $D(DTOUT)!$D(DUOUT) S SCX=0 Q
  1. .S SCX=Y
  1. .Q
  1. Q SCX
  1. ;
  1. WAIT N DIR S DIR(0)="E" W ! D ^DIR S SCOUT=Y'=1 W @IOF Q
  1. ;
  1. HDR(SCT,SCIOM) ;Print report header
  1. ;Input: SCT=array of header lines
  1. ;Input: SCIOM=right margin (optional)
  1. ;
  1. N SCI
  1. S:'$G(SCIOM) SCIOM=IOM
  1. I $E(IOST)="C",SCFF N DIR S DIR(0)="E" W ! D ^DIR S SCOUT=Y'=1 Q:SCOUT
  1. D STOP Q:SCOUT
  1. I SCFF!($E(IOST)="C") W $$XY^SCRPW50(IOF,1,0)
  1. I $X W $$XY^SCRPW50("",0,0)
  1. W SCLINE
  1. S SCI=0 F S SCI=$O(SCT(SCI)) Q:'SCI D
  1. .W !?(SCIOM-$L(SCT(SCI))\2),SCT(SCI)
  1. .Q
  1. W !,SCLINE,!,"Date printed: ",SCPNOW,?(SCIOM-6-$L(SCPAGE)),"Page: ",SCPAGE
  1. W !,SCLINE S SCFF=1,SCPAGE=SCPAGE+1
  1. Q
  1. ;
  1. STOP ;Check for stop task request
  1. S:$D(ZTQUEUED) (SCOUT,ZTSTOP)=$S($$S^%ZTLOAD:1,1:0) Q
  1. ;
  1. ELIG(DFN) ;Get Primary Eligibility
  1. ;Input: DFN=patient ifn
  1. N PRIM,PRIM1
  1. S PRIM=$P($G(^DPT(DFN,.36)),U) Q:PRIM<1 "[unknown]"
  1. S PRIM=$P($G(^DIC(8,PRIM,0)),U,9) Q:PRIM<1 "[unknown]"
  1. ;MAS Primary Eligibility Code
  1. S PRIM=$P($G(^DIC(8.1,PRIM,0)),U) Q:PRIM="" "[unknown]"
  1. S PRIM1=PRIM
  1. ;
  1. S PRIM=$TR(PRIM,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  1. I PRIM="NON-SERVICE CONNECTED" S PRIM="NSC"
  1. I PRIM["SERVICE CONNECTED" S PRIM=$P(PRIM,"SERVICE CONNECTED")_"SC"_$P(PRIM,"SERVICE CONNECTED",2,999)
  1. I PRIM["LESS THAN" S PRIM=$P(PRIM,"LESS THAN")_"<"_$P(PRIM,"LESS THAN",2,999)
  1. I PRIM[" TO " S PRIM=$P(PRIM," TO ")_"-"_$P(PRIM," TO ",2,999)
  1. I PRIM["%" S PRIM=$TR(PRIM,"%","")
  1. S PRIM=$E(PRIM,1,9)
  1. Q PRIM1_U_PRIM