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

PSBCSUTY.m

Go to the documentation of this file.
PSBCSUTY ;BIRMINGHAM/TEJ- BCMA-HSC COVER SHEET UTILITIES 3 ;Mar 2004
 ;;3.0;BAR CODE MED ADMIN;**16,32**;Mar 2004;Build 32
 ;Per VHA Directive 2004-038 (or future revisions regarding same), this routine should not be modified.
 ;
 ; Reference/IA
 ; $$GET1^DIQ/2056
 ; File 200/10060
CMT ; Comment per admin.
 S (PSBIENX,PSBPRNRE)="",PSBIENX=+$P(PSBADMS(PSBONMBR,PSBSCHTM),U,3),PSBPRNRE=$P(PSBADMS(PSBONMBR,PSBSCHTM),U,8)
 D:+$O(^PSB(53.79,PSBIENX,.3,""),-1)>0
 .S PSBI2=0 F  S PSBI2=$O(^PSB(53.79,PSBIENX,.3,PSBI2)) Q:PSBI2=""  D
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U)="CMT",$P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,2)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U)
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,4)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,2)
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,5)=$$GET1^DIQ(200,$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,2)_",","INITIAL")
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,6)=$P(^PSB(53.79,PSBIENX,.3,PSBI2,0),U,3),PSBCNT2=PSBCNT2+1
 D:($G(PSBPRNRE)]"")&($$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS")]"")
 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U)="CMT",$P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,3)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS")
 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,4)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED BY","I")
 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,5)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED BY:INITIAL")
 .S $P(^TMP("PSB",$J,"CVRSHT2",PSBI1,PSBCNT2),U,6)=$$GET1^DIQ(53.79,PSBIENX_",","PRN EFFECTIVENESS ENTERED AT","I"),PSBCNT2=PSBCNT2+1
 Q
XFERBAGS ;
 ;  Logic to "move IV bags"
 ;  Construct Temp arrays PSBADMX,PSBDONE
 Q:PSBPONX']""
 K PSBCHKED
 S PSBNX2=PSBONX,PSBDFN2=PSBDFN,PSBPNX2=PSBPONX,PSBFN2=PSBFON F  Q:PSBFN2]""  D  Q:PSBPONX']""  S PSBPNX2=PSBPONX I $G(PSBCHKED(PSBPONX))=1 K PSBCHKED Q
 .D CLEAN^PSBVT S PSBPONX=PSBPNX2,PSBCHKED(PSBPONX)=1 D PSJ1^PSBVT(PSBDFN2,PSBPONX)
 .S (PSBXX,PSBXXX)="" F  S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX=""  D
 ..S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""  Q:$P(^PSB(53.79,PSBXXX,0),U,9)="C"  S:'$D(PSBDONE(PSBXXX)) (PSBADMX(PSBNX2,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
 ; Refresh data
 D CLEAN^PSBVT,PSJ1^PSBVT(PSBDFN2,PSBNX2)
 K PSBNX2,PSBDFN2,PSBPNX2,PSBFN2
 Q
GETADMX ;
 S (PSBXX,PSBXXX)="" F  S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX=""  D
 .Q:(PSBXX<PSBMHBCK)&'PSBLVIV
 .F  S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""  Q:(PSBFON]"")&($P(^PSB(53.79,PSBXXX,0),U,9)'="C")&(PSBLVIV)  D
 ..S (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
 ; Check "actions" that DO NOT get filed into AORDX !!
 S (PSBXX,PSBXXX)="" F  S PSBXX=$O(^PSB(53.79,"AORD",PSBDFN,PSBONX,PSBXX)) Q:PSBXX=""  D
 .F  S PSBXXX=$O(^PSB(53.79,"AORD",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""  D
 ..S:('$D(PSBDONE(PSBXXX)))&($P(^PSB(53.79,PSBXXX,0),U,6)'<PSBMHBCK) PSBADMX(PSBONX,PSBXX,PSBXXX)=""
 K PSBXX,PSBXXX,PSBDONE
 Q
LVIV ;
 ; Set up variables to later extract LVIV data
 ; Add all LVIVs that have been active with in the window!!
 I (PSBOSP'<PSBWBEG)&(PSBOSP'>PSBWEND) D ADD^PSBVDLU1(PSBREC,PSBOTXT,PSBNOW\1_".",PSBDDS,PSBSOLS,PSBADDS,"CVRSHT")
 S PSBEXPRD=0 I (PSBFON']"")&(PSBOSP<PSBNOW) S PSBEXPRD=1
 S (PSBXX,PSBXXX)="" F  S PSBXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX)) Q:PSBXX=""  D
 .S PSBXXX=$O(^PSB(53.79,"AORDX",PSBDFN,PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""
 .I "IS"[$P(^PSB(53.79,PSBXXX,0),U,9)&(PSBFON']"") S PSBEXPRD=0
 .S:'$D(PSBDONE(PSBXXX))&(PSBFON="") (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
 S (PSBXX,PSBXXX)="" F  S PSBXX=$O(PSBADMX(PSBONX,PSBXX)) Q:PSBXX=""  D
 .S PSBXXX=$O(PSBADMX(PSBONX,PSBXX,PSBXXX)) Q:PSBXXX=""
 .I "IS"[$P(^PSB(53.79,PSBXXX,0),U,9)&(PSBFON']"") S PSBEXPRD=0
 .S:'$D(PSBDONE(PSBXXX))&(PSBFON="") (PSBADMX(PSBONX,PSBXX,PSBXXX),PSBDONE(PSBXXX))=""
 Q
QUT() ;
 S QUT=0
 I PSBOST>($$FMADD^XLFDT($$NOW^XLFDT,,,$$GET^XPAR("DIV","PSB ADMIN BEFORE"))) S QUT=1 Q QUT
 I '(($F("ED",PSBOSTS)'>1)&(PSBOSP'<%)) S QUT=1 Q QUT
 Q QUT
USED() ;
 S (PSBXIEN,PSBUSD,USED)=0,PSBBAGX=$P(PSBXREC,U,2)
 I $$QUT() S (PSBUSD,USED)=1 Q PSBUSD
 S PSBXXX="" F  S PSBXXX=$O(^PSB(53.79,"AUID",PSBDFNX,PSBXXX)) Q:PSBXXX=""  D  Q:PSBUSD
 .I $D(^PSB(53.79,"AUID",PSBDFNX,PSBXXX,PSBBAGX)) S PSBXIEN=$O(^PSB(53.79,"AUID",PSBDFNX,PSBXXX,PSBBAGX,"")) S:$F("GICSHRM",$P(^PSB(53.79,PSBXIEN,0),U,9))>1 (PSBUSD,USED)=1,PSBOBAG(PSBONMBR)=""
 Q USED
ORC ; Ord cmmnts
 S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORC",$P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,2)=^TMP("PSB",$J,PSBTAB,PSBI1),PSBRECHD="ORF"
 Q
ORF ; Ordr flag  "ORF^FLAG^Flg Comment"
 K ^TMP("PSJ1",$J),PSBNOX
 D EN^PSJBCMA1(PSBDFN,PSBONMBR,1)
 ;Set STAT FLAG
 I $P(^TMP("PSJ1",$J,7),U,1) S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^STAT"
 ;Set IM/CPRS ord flg and cmment
 I $P(^TMP("PSJ1",$J,7),U,2) D
 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^CPRS^"_$P(^TMP("PSJ1",$J,7),U,3)_U_$P(^TMP("PSJ1",$J,7),U,4)
 .I $P(^TMP("PSJ1",$J,7),U,3)']"" D
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,2)="CPRS"
 ..S $P(^TMP("PSB",$J,"CVRSHT2",PSBCNT2),U,3)="*PSJ DATA ERROR* ^ PSJ Order Flag Error"
 K ^TMP("PSJ1",$J)
 ;Set No Act Flag
 I ('$D(^PSB(53.79,"AORDX",PSBDFN,PSBONMBR))) I (PSBLRGIV) I '$D(PSBADMX(PSBONMBR)) I $P(PSBORREC,U,26)>$G(%,PSBNOW) D
 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)="ORF^NOX^No Action Taken On Order"
 .S PSBNOX(PSBONMBR,PSBCNT2)=""
 S PSBRECHD="MED"
 Q
MED ; Cnstr DD,ADD,SOL,ID
 F I=PSBI1:1 S PSBXREC=^TMP("PSB",$J,PSBTAB,I) Q:PSBXREC="END"  D
 .I $P(PSBXREC,U)="ID" S PSBUSED=$$USED()  Q:PSBUSED
 .S PSBCNT2=PSBCNT2+1,^TMP("PSB",$J,"CVRSHT2",PSBCNT2)=PSBXREC
 S PSBI1=I-1
 Q
FINALPAS ;
 S PSBI1="^TMP(""PSB"",$J,""CVRSHT"")",PSBCNT1=0
 F  S PSBI1=$Q(@PSBI1) Q:PSBI1["CVRSHT2"  D
 .I $QS(PSBI1,4)'>1 S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
 .K PSBX2 M PSBX2=^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4))
 .I $QS(PSBI1,5)="" S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
 .K PSBDONE
 .I '$D(PSBX2(1)) S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=@PSBI1,PSBCNT1=PSBCNT1+1 Q
 .F PSBI2=1:1 Q:'$D(PSBX2(PSBI2))  D  ;sort actn/cmmnt rev. chrono
 ..Q:$D(PSBDONE(PSBI2))
 ..S PSBXDTTM=(-1*($P(PSBX2(PSBI2),U,6)))_+($E($P(PSBX2(PSBI2),U,4),$L($P(PSBX2(PSBI2),U,4))-6,999)),PSBMCODE=$P(PSBX2(PSBI2),U)
 ..D:(+PSBXDTTM<0)&(PSBMCODE["ADM")
 ...S PSBX3(+PSBXDTTM,-999)=PSBX2(PSBI2),PSBDONE(PSBI2)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2)
 ...F PSBI3=1:1 Q:'$D(PSBX2(PSBI2+PSBI3))  Q:$P(PSBX2(PSBI2+PSBI3),U)'["CMT"  D
 ....S PSBX3(+PSBXDTTM,-1*PSBI3)=PSBX2(PSBI2+PSBI3),PSBDONE(PSBI2+PSBI3)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2+PSBI3)
 ..D:(+PSBXDTTM=0)&(PSBMCODE["ADM")
 ...S PSBX3(PSBI2,0)=PSBX2(PSBI2),PSBDONE(PSBI2)="" K ^TMP("PSB",$J,"CVRSHT",$QS(PSBI1,4),PSBI2)
 .I $D(PSBX3) D  K PSBX3
 ..S PSBI2="" F  S PSBI2=$O(PSBX3(PSBI2)) Q:PSBI2=""  S PSBI3="" F  S PSBI3=$O(PSBX3(PSBI2,PSBI3)) Q:PSBI3=""  D
 ...S ^TMP("PSB",$J,"CVRSHT2",PSBCNT1)=PSBX3(PSBI2,PSBI3),PSBCNT1=PSBCNT1+1
 S $P(^TMP("PSB",$J,"CVRSHT2",0),U)=PSBCNT1-1
 Q