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

SCRPTP.m

Go to the documentation of this file.
  1. SCRPTP ;ALB/CMM - List of Team's Patients ; 29 Jun 99 04:11PM
  1. ;;5.3;Scheduling;**41,48,174,177,526,520**;AUG 13, 1993;Build 26
  1. ;
  1. PROMPTS ;Prompt for Institution, Team, Role, Patient Status and Print device
  1. N QTIME,PRNT,VAUTD,VAUTT,VAUTR,VAUTPS,NUMBER
  1. K SCUP
  1. S QTIME=""
  1. W ! D INST^SCRPU1 I Y=-1 G ERR
  1. W ! K Y D PRMTT^SCRPU1 I '$D(VAUTT) G ERR
  1. W ! K Y D ROLE^SCRPU1 I '$D(VAUTR) G ERR
  1. W ! K Y D PTSTAT^SCRPU2 I '$D(VAUTPS) G ERR
  1. W ! K Y S SORT=$$SORT2^SCRPU2()
  1. I SORT<1 G ERR
  1. W !!,"This report requires 132 column output!"
  1. D QUE(.VAUTD,.VAUTT,.VAUTR,VAUTPS,SORT) Q
  1. ;
  1. QUE(INST,TEAM,ROLE,PSTAT,SORT,IOP,ZTDTH) ;queue report
  1. ;INST - institutions selected (variable and array)
  1. ;TEAM - teams selected (variable and array)
  1. ;ROLE - roles selected (variable and array)
  1. ;PSTAT - patient status - 1=all or OPT or AC
  1. ;SORT - 1=d,t,ptname 2=d,t,Pt ID 3=d,t,pract,pt name 4=d,t,pract,Pt ID
  1. N ZTSAVE,II
  1. F II="INST","TEAM","ROLE","ROLE(","SORT","PSTAT","INST(","TEAM(" S ZTSAVE(II)=""
  1. W ! D EN^XUTMDEVQ("QENTRY^SCRPTP","Team Patient Listing",.ZTSAVE)
  1. Q
  1. ;
  1. ENTRY2(INST,TEAM,ROLE,PSTAT,SORT,IOP,ZTDTH) ;Second entry point for GUI to use
  1. ;INST - institutions selected (variable and array)
  1. ;TEAM - teams selected (variable and array)
  1. ;ROLE - roles selected (variable and array)
  1. ;PSTAT - patient status - 1=all or OPT or AC
  1. ;SORT - 1=d,t,ptname 2=d,t,Pt ID 3=d,t,pract,pt name 4=d,t,pract,Pt ID
  1. ;IOP - print device
  1. ;ZTDTH - queue time (optional)
  1. ;
  1. ;validate parameters
  1. I '$D(INST)!'$D(TEAM)!'$D(ROLE)!'$D(PSTAT)!'$D(SORT)!'$D(IOP)!(IOP="") Q
  1. N NUMBER
  1. S IOST=$P(IOP,"^",2),IOP=$P(IOP,"^")
  1. I IOP?1"Q;".E S IOP=$P(IOP,"Q;",2)
  1. I IOST?1"C-".E D QENTRY G RET
  1. I ZTDTH="" S ZTDTH=$H
  1. S ZTRTN="QENTRY^SCRPTP"
  1. S ZTDESC="List of Team's Patients",ZTIO=IOP
  1. N II
  1. F II="INST","TEAM","ROLE","ROLE(","SORT","PSTAT","INST(","TEAM(","IOP" S ZTSAVE(II)=""
  1. D ^%ZTLOAD
  1. RET S NUMBER=0
  1. I $D(ZTSK) S NUMBER=ZTSK
  1. D EXIT1
  1. Q NUMBER
  1. ;
  1. QENTRY ;driver entry point
  1. S TITL="Team Patient Listing",STORE="^TMP("_$J_",""SCRPTP"")"
  1. K @STORE
  1. S @STORE=0
  1. D FIND
  1. I $O(@STORE@(0))="" S NODATA=$$NODATA^SCRPU3(TITL)
  1. I '$D(NODATA) D PRINTIT^SCRPTP2(STORE,TITL)
  1. D EXIT2
  1. Q
  1. ERR ;
  1. EXIT1 ;
  1. K ZTDTH,ZTRTN,ZTDESC,ZTSK,ZTIO,ZTSAVE,SCUP
  1. Q
  1. EXIT2 ;
  1. K @STORE
  1. K STOP,STORE,TITL,IOP,TEAM,INST,ROLE,PSTAT,SORT,NODATA
  1. Q
  1. FIND ;
  1. N TIEN,ERR,LIST,OKAY
  1. I TEAM=1 D TALL^SCRPPAT3 ;gets all teams for all divisions selected
  1. S TIEN="",LIST="^TMP("_$J_",""SCRPTP ARRAY"")",ERR="ERROR"
  1. K @LIST,@ERR
  1. F S TIEN=$O(TEAM(TIEN)) Q:TIEN="" D
  1. .;TIEN - team ien
  1. .S OKAY=$$PTTM^SCAPMC2(TIEN,"",LIST,ERR)
  1. .; gets all patients for given team
  1. .D HITS^SCRPTP3(LIST,TIEN)
  1. .K @LIST,@ERR
  1. K @LIST,@ERR
  1. Q
  1. TINF(TIEN) ;team information
  1. ;TIEN - team ien
  1. ;returns: institution ien ^ team name ^ primary care ^ team phone
  1. N PC,PHONE,TNODE,TNAME
  1. S TNODE=$G(^SCTM(404.51,TIEN,0))
  1. S TNAME=$P(TNODE,"^") ;team name
  1. S PC=$S($P(TNODE,"^",5)=1:"YES",1:"NO") ;primary care team
  1. S PHONE=$P(TNODE,"^",2) ;team phone
  1. S INS=+$P(TNODE,"^",7) ;institution ien
  1. D TDESC^SCRPITP2(TIEN,INS) ;gets team description
  1. Q INS_"^"_TNAME_"^"_PC_"^"_PHONE
  1. ;
  1. PST(PTIEN,CLIEN) ;
  1. ;PTIEN - patient ien
  1. ;CLIEN - associated clinic ien
  1. ;returns 1=selected patient status, 0=not selected patient status
  1. ;
  1. N EN,NXT,FOUND,ENODE
  1. S EN="",(FOUND,NXT)=0
  1. Q:'$D(^DPT(PTIEN,"DE","B",CLIEN)) FOUND
  1. S EN=$O(^DPT(PTIEN,"DE","B",CLIEN,""))
  1. I EN=""&(PSTAT=1) S FOUND=1 Q FOUND
  1. Q:EN=""!'$D(^DPT(PTIEN,"DE",EN,1)) FOUND
  1. F S NXT=$O(^DPT(PTIEN,"DE",EN,1,NXT)) Q:(FOUND)!(NXT="")!(NXT'?.N) D
  1. .;check if active enrollment
  1. .S ENODE=$G(^DPT(PTIEN,"DE",EN,1,NXT,0))
  1. .I $P(ENODE,"^",3)'="",$P(ENODE,"^",3)<DT+1!$P(ENODE,"^")>DT Q ;not active enrollment
  1. .; ^ discharge date ^ enrollment date
  1. .Q:$P(ENODE,"^",2)'=$E(PSTAT,1)&(PSTAT'=1) ;not selected patient status
  1. .S FOUND=1
  1. Q FOUND
  1. ;
  1. FORMAT(INS,TIEN,PTIEN,PTNAME,PID,PIEN,PNAME,CNAME,PINF,ROLN,PCAP) ;Format column information
  1. ;INS - Institution ien
  1. ;TIEN - team ien
  1. ;PTIEN - patient ien
  1. ;PTNAME - patient name
  1. ;PID - SSN
  1. ;PIEN - practitioner ien
  1. ;PNAME - practitioner name
  1. ;CNAME - clinic name
  1. ;LAST - last appointment
  1. ;NEXT - next appointment
  1. ;ROLN - role name
  1. ;PCAP - PC?
  1. ;
  1. N SEC,TRD
  1. I PNAME="" S PNAME="[BAD DATA]"
  1. I PTNAME="" S PTNAME="[BAD DATA]"
  1. I PID="" S PID="*********"
  1. S @STORE@("P",INS,TIEN,PNAME,PIEN)="" ;practitioner
  1. S @STORE@("PT",INS,TIEN,PTNAME,PTIEN)="" ;patient
  1. S @STORE@("PID",INS,TIEN,PID,PTIEN)=""
  1. I (SORT=1)!(SORT=2) S SEC=PTIEN,TRD=PIEN ;sort doesn't include practitioner
  1. I (SORT=3)!(SORT=4) S SEC=PIEN,TRD=PTIEN ;sort includes practitioner
  1. S @STORE@(INS,TIEN,SEC,TRD)=$E(PTNAME,1,15) ;patient name
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),18)=PID ;9 digit pid
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),32)=$E(PNAME,1,22) ;practitioner name
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),56)=$E($G(ROLN),1,22) ;role name
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),80)=$G(PCAP) ;PC?
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),85)=$P(PINF,"^",8) ;last appointment
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),97)=$P(PINF,"^",9) ;next appointment
  1. S $E(@STORE@(INS,TIEN,SEC,TRD),109)=$E(CNAME,1,24) ;clinic name
  1. Q
  1. FORMATAC(SCCNT,CNAME,PINF,INS,TIEN,PTIEN,PTNAME,PID,PIEN,PNAME,ROLN,PCAP) ;Format MULTIPLES
  1. ;INS - Institution ien
  1. ;TIEN - team ien
  1. ;PTIEN - patient ien
  1. ;PTNAME - patient name
  1. ;PID - last 4 PID - includes pseudo notation as 5th
  1. ;PIEN - practitioner ien
  1. ;PNAME - practitioner name
  1. ;CNAME - clinic name
  1. ;LAST - last appointment
  1. ;NEXT - next appointment
  1. ;ROLN - role name
  1. ;PCAP - PC?
  1. ;
  1. N SEC,TRD
  1. I PNAME="" S PNAME="[BAD DATA]"
  1. I PTNAME="" S PTNAME="[BAD DATA]"
  1. I PID="" S PID="****"
  1. S @STORE@("P",INS,TIEN,PNAME,PIEN)="" ;practitioner
  1. S @STORE@("PT",INS,TIEN,PTNAME,PTIEN)="" ;patient
  1. S @STORE@("PID",INS,TIEN,PID,PTIEN)="" ;last 4 pid
  1. N TRD
  1. I (SORT=1)!(SORT=2) S SEC=PTIEN,TRD=PIEN ;sort doesn't include practitioner
  1. I (SORT=3)!(SORT=4) S SEC=PIEN,TRD=PTIEN ;sort includes practitioner
  1. I '$D(@STORE@(INS,TIEN,SEC,TRD,SCCNT)) D
  1. .S $E(@STORE@(INS,TIEN,SEC,TRD,SCCNT),85)=$P(PINF,"^",8) ;last appointment
  1. .S $E(@STORE@(INS,TIEN,SEC,TRD,SCCNT),97)=$P(PINF,"^",9) ;next appointment
  1. .S $E(@STORE@(INS,TIEN,SEC,TRD,SCCNT),109)=$E(CNAME,1,24) ;clinic name
  1. .Q
  1. Q