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

PSSPOIM1.m

Go to the documentation of this file.
  1. PSSPOIM1 ;BIR/RTR,WRT - Manual create of Orderable Item continued ;Jun 23, 2020@13:14:33
  1. ;;1.0;PHARMACY DATA MANAGEMENT;**29,38,47,141,153,159,166,191,198,204,220,242**;9/30/97;Build 19
  1. ;
  1. CHK S PSNO=0 I $G(PSMAN) W !!,"Matching ",PSNAME,!," to",!,SPHOLD," ",$P($G(^PS(50.606,+DOSEPTR,0)),"^"),!
  1. I '$G(PSMAN) S PSMC=$P($G(^PS(50.7,PSSP,0)),"^") W !!,"Matching ",PSNAME,!," to",!,PSMC," ",$P($G(^PS(50.606,+$P(^PS(50.7,PSSP,0),"^",2),0)),"^"),!
  1. K DIR S DIR(0)="Y",DIR("B")="YES",DIR("A")="Is this OK" D ^DIR
  1. S:Y=0 PSNO=1 I Y'=1,'PSNO S PSOUT=1
  1. ;Add trace of whether inactive date is present.
  1. ;If one is added erroneously by code logic when the
  1. ;orderable item should remain active,
  1. ;the inactive date will be deleted at INACT^PSSPOIM1.
  1. K ^TMP($J,"INACTIVE_DATE")
  1. N PSOITMP
  1. S PSOITMP=$S($G(PSPOINT):PSPOINT,$G(PSSP):PSSP,1:"")
  1. I PSOITMP]"" S ^TMP($J,"INACTIVE_DATE",PSOITMP)=$P($G(^PS(50.7,PSOITMP,0)),"^",4)
  1. K PSMAN,PSOITMP
  1. Q
  1. END K ^TMP($J,"PSSOO"),PSSSSS,PSCREATE,^TMP("PSSLOOP",$J),^TMP($J,"INACTIVE_DATE")
  1. K AAA,ANS,APLU,COMM,DA,DIC,DIE,DOSEFORM,DOSEFV,DOSEPTR,DR,FFF,MATCH,NEWSP,NODE,NOFLAG,OTH,POINT,PSCNT,PSIEN,PSMAN,PSMC,PSNAME,PSNO,PSSP,PSND,PSOUT,SPHOLD,SPR,TMPTR,TT,VAGEN,X,Y,ZZ,PSOOOUT,PSXDATE,PSXADATE,PSXSDATE,AAAAA,BBBBB,ZXX,PSXDDATE
  1. K PSSDACT,PSSSACT,PSSAACT,PSSINACT,PSSDTENT,PSSCOMP,PSSDGDT,PSSDGIDL,PSSARR,PSSACT,PSSNEWIA
  1. Q
  1. MESS W !!,"This option enables you to match Dispense Drugs to an entry in the Pharmacy",!,"Orderable Item file, or create a new Pharmacy Orderable Item entry for a",!,"Dispense Drug.",! Q
  1. MESSZ S ^TMP("PSSLOOP",$J,DUZ)="" W !!,"This option is for matching IV Additives, IV Solutions, and all Dispense Drugs",!,"marked with an I, O, or U in the Application Packages' Use field to an",!,"Orderable Item."
  1. W !,"You will need to keep accessing this option until all drugs are matched.",!,"A check will be done every time this option is exited to see if the matching",!,"process is complete.",!!
  1. K DIR S DIR(0)="E" D ^DIR K DIR I X["^"!($D(DTOUT)) S PSOUT=1
  1. Q
  1. CHECK W !!!,"Checking Drug files, please wait..."
  1. S X1=DT,X2=-365 D C^%DTC S PSZXDATE=X,DONEFLAG=1
  1. F FFFF=0:0 S FFFF=$O(^PSDRUG(FFFF)) Q:'FFFF!('DONEFLAG) S QQNM=$P($G(^PSDRUG(FFFF,0)),"^") I QQNM'="",$D(^PSDRUG("B",QQNM)) D I ZZG I USAGE["O"!(USAGE["I")!(USAGE["U") I '$P($G(^PSDRUG(FFFF,2)),"^") S DONEFLAG=0
  1. .S USAGE=$P($G(^PSDRUG(FFFF,2)),"^",3)
  1. .S ZZG=1 S PSZZDATE=+$P($G(^PSDRUG(FFFF,"I")),"^") I PSZZDATE,PSZZDATE<PSZXDATE S ZZG=0
  1. I DONEFLAG=1 D
  1. .F QQQ=0:0 S QQQ=$O(^PS(52.6,QQQ)) Q:'QQQ!('DONEFLAG) S PSZNAME=$P($G(^PS(52.6,QQQ,0)),"^") I PSZNAME'="",$D(^PS(52.6,"B",PSZNAME)),$P($G(^PS(52.6,QQQ,0)),"^",2),'$P($G(^(0)),"^",11) D I ZZG S DONEFLAG=0
  1. ..S ZZG=1 S PSZZDATE=+$P($G(^PS(52.6,QQQ,"I")),"^") I PSZZDATE,PSZZDATE<PSZXDATE S ZZG=0
  1. .I DONEFLAG F QQQ=0:0 S QQQ=$O(^PS(52.7,QQQ)) Q:'QQQ!('DONEFLAG) S PSZNAME=$P($G(^PS(52.7,QQQ,0)),"^") I PSZNAME'="",$D(^PS(52.7,"B",PSZNAME)),$P($G(^PS(52.7,QQQ,0)),"^",2),'$P($G(^(0)),"^",11) D I ZZG S DONEFLAG=0
  1. ..S ZZG=1 S PSZZDATE=+$P($G(^PS(52.7,QQQ,"I")),"^") I PSZZDATE,PSZZDATE<PSZXDATE S ZZG=0
  1. MAIL I DONEFLAG W !!!,?3,"You are finished matching to the Orderable Item File!",!!,"A clean-up job is being queued now, and when it is finished, you will"
  1. I W !,"receive a mail message informing you of its completion.",! K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
  1. I $G(DONEFLAG) S PSSOMAIL=1,PSOUDUZ=DUZ S ZTRTN="DATE^PSSPOIM1",ZTIO="",ZTDTH=$H,ZTDESC="ORDERABLE ITEM CLEAN UP",ZTSAVE("DUZ")="",ZTSAVE("PSSOMAIL")="" D ^%ZTLOAD
  1. I 'DONEFLAG W $C(7),$C(7),!!?5,"There are still Drugs not matched, you will need to come back",!?5,"and continue matching Drugs!",! K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
  1. K DONEFLAG,QQQ,QQNM,PSZZDATE,PSZXDATE,ZZG,USAGE,FFFF,PSZNAME Q
  1. OTHER W @IOF W !,"There are other Dispense Drugs with the same VA Generic Name and same Dose",!,"Form already matched to orderable items. Choose a number to match, or enter",!,"'^' to enter a new one.",!!?6,"Disp. drug -> ",PSNAME,! Q
  1. EN(PSVAR) ;
  1. N PSSDACT,PSSSACT,PSSAACT,PSSINACT,PSSDTENT
  1. N PSSCOMP,PSSDGDT,PSSDGIDL,PSSARR,PSSACT
  1. W !?3,"Now editing Orderable Item:",!?3,$P(^PS(50.7,PSVAR,0),"^")," ",$P($G(^PS(50.606,+$P(^(0),"^",2),0)),"^")
  1. W ! K DIE,DA,DR N MFLG S PSBEFORE1=+$P(^PS(50.7,PSVAR,0),"^",2),PSAFTER=0,PSINORDE=""
  1. S DIE="^PS(50.7,",DA=PSVAR,DR="5;6" D ^DIE K DIE,DA,DR I $D(DTOUT)!($D(Y)>10) Q
  1. D INACT
  1. I $G(Y)["^"!($D(DTOUT))!($G(DUOUT)) Q
  1. D EN1
  1. Q
  1. ;
  1. INACT ;
  1. ;check to see if an inactive date was added by code logic
  1. ;(not by a user) but was erroneously added since there is
  1. ;an active component for this orderable item
  1. ;
  1. ;The inactive date can be erroneously added at EN1+15^PSSPOIDT
  1. ;when there is only one active component on an orderable item
  1. ;and that component is being edited.
  1. ;
  1. ;The logic in PSSPOIDT cannot be changed without restructuring
  1. ;much of the core logic. Hence, the decision to insert the
  1. ;following check to determine whether the inactive date
  1. ;was not present when the user invoked option PSS MAINTAIN
  1. ;ORDERABLE ITEM and was erroneously added to file 50.7 by
  1. ;EN1^PSSPOIDT.
  1. ;
  1. D CHECK^PSSPOID2(PSVAR)
  1. S PSBEFORE=$P(^PS(50.7,PSVAR,0),"^",4)
  1. I $G(^TMP($J,"INACTIVE_DATE",PSVAR))="",PSBEFORE]"" D
  1. . ;Information returned by CHECK^PSSPOID2(PSVAR):
  1. . ; PSSDACT = array of active dispense drugs
  1. . ; PSSSACT = array of active solutions
  1. . ; PSSAACT = array of active additives
  1. . I $O(PSSDACT(0))!($O(PSSSACT(0)))!($O(PSSAACT(0))) D
  1. . . ;Attempt to delete the inactive date since it
  1. . . ;may have been added erroneously.
  1. . . ;An inactive date may still be present after this call
  1. . . ;if all components have an inactive date and
  1. . . ;and one or more of those dates are in the future
  1. . . S DIE="^PS(50.7,",DA=PSVAR,DR=".04////@" D ^DIE K DIE,DA,DR
  1. . . S PSBEFORE=$P(^PS(50.7,PSVAR,0),"^",4)
  1. ;
  1. ;Check to see if an inactive date did not exist when user
  1. ;invoked the option and one has been added that is incorrect.
  1. ;This can occur if all components have an inactive date on
  1. ;file, and all inactive dates are today or in the past.
  1. ;If user is working on a component with the latest inactive
  1. ;date, that date was not set as the orderable item inactive
  1. ;date as it should have.
  1. ;
  1. D IACHK
  1. I $G(^TMP($J,"INACTIVE_DATE",PSVAR))="",PSSDGIDL]"",PSBEFORE]"",PSSDGIDL'=PSBEFORE D
  1. . S PSBEFORE=PSSDGIDL
  1. . S DIE="^PS(50.7,",DA=PSVAR,DR=".04////"_PSSDGIDL
  1. . D ^DIE K DIE,DA,DR
  1. D INACT1
  1. I $G(Y)["^"!($D(DTOUT))!($G(DUOUT)) Q
  1. D IACHK1
  1. Q
  1. ;
  1. INACT1 ;
  1. N PSSNEWIA S PSSNEWIA=""
  1. ;Does the user wish to add or change the inactive date
  1. K DIR S DIR(0)="DO",DIR("A")="INACTIVE DATE" D D ^DIR K DIR I $G(Y)["^"!($D(DTOUT))!($G(DUOUT)) Q
  1. .I $G(PSBEFORE) S Y=PSBEFORE D DD^%DT S DIR("B")=$G(Y)
  1. S DIE="^PS(50.7,",DA=PSVAR,PSSNEWIA=Y
  1. I $G(PSBEFORE),'PSSNEWIA D
  1. . I '$O(PSSDACT(0)),'$O(PSSSACT(0)),'$O(PSSAACT(0)) D Q
  1. . . W !!,?15,"All Drugs/Additives/Solutions matched to this"
  1. . . W !,?15,"Orderable Item are inactive."
  1. . . W !!,?15,"The INACTIVE DATE cannot be deleted.",!
  1. . S DR=".04////@"
  1. . D ^DIE K DIE,DA,DR
  1. . ;An inactive date may have been set if all components
  1. . ;are defined with an inactive date and one or more
  1. . ;of those dates are in the future.
  1. . I $P(^PS(50.7,PSVAR,0),"^",4)="" D
  1. . . W ?35,"The inactive date has been deleted.",!
  1. I PSSNEWIA D
  1. . S DR=".04////"_PSSNEWIA
  1. . D DD^%DT W ?40,Y,!
  1. . D ^DIE K DIE,DA,DR
  1. S PSSINACT=$P(^PS(50.7,PSVAR,0),"^",4)
  1. I PSSINACT="" Q
  1. ;
  1. ;Inform user if user specified that inactive date should
  1. ;be deleted.
  1. ;
  1. I 'PSSNEWIA D
  1. . W !,?15,"The Inactive Date is: "
  1. . S Y=PSSINACT D DD^%DT W Y,"."
  1. Q
  1. ;
  1. IACHK ;
  1. ;Check to see if the inactive date on the orderable item
  1. ;is greater than the greatest inactive date on
  1. ;corresponding Drugs/Additives/Solutions.
  1. ;Not automatically setting to that value unless the inactive date
  1. ;was null when user invoked the option.
  1. ;Otherwise, leave as is in case user wishes it defined as such.
  1. ;
  1. S PSSCOMP="",PSSACT=0
  1. F S PSSCOMP=$O(^PS(50.7,"A50",PSVAR,PSSCOMP)) Q:PSSCOMP="" D
  1. . S PSSARR(PSSCOMP)=""
  1. ;Latest inactive date = PSSDGIDL
  1. ;Inactive date on each component = PSSDGDT
  1. S PSSDGIDL=""
  1. F S PSSCOMP=$O(PSSARR(PSSCOMP)) Q:PSSCOMP="" D
  1. . S PSSDGDT=$G(^PSDRUG(PSSCOMP,"I"))
  1. . I PSSDGDT="" S PSSACT=1
  1. . I PSSDGDT>PSSDGIDL S PSSDGIDL=PSSDGDT
  1. Q
  1. ;
  1. IACHK1 ;
  1. ;message to user
  1. I PSSDGIDL]"",'PSSACT D
  1. . S Y=PSSDGIDL D DD^%DT
  1. . I PSSDGIDL<PSSINACT D Q
  1. . . W !!,?15,"**** **** NOTE **** ****",!
  1. . . W !,?15,"All Drugs/Additives/Solutions for this orderable item"
  1. . . W !,?15,"are inactive as of ",Y,".",!
  1. . . S Y=$P(^PS(50.7,PSVAR,0),"^",4) D DD^%DT
  1. . . W !,?15,"However, the orderable item ",$P(^PS(50.7,PSVAR,0),"^")
  1. . . W !,?15,"is inactive on ",Y,".",!
  1. . . W !,?15,"You may need to change the inactive date on the orderable item"
  1. . . W !,?15,"using option PSS EDIT ORDERABLE ITEMS.",!
  1. . . W !,?15,"**** **** **** **** ****",!
  1. . ;
  1. . W !,?15,"All Drugs/Additives/Solutions matched to this"
  1. . W !,?15,"Orderable Item are inactive as of ",Y,".",!
  1. Q
  1. ;
  1. EN1 ;
  1. ;PSSDTENT is used by routine PSSPOIMO
  1. N PSSDTENT
  1. S PSSDTENT=PSSINACT
  1. S PSSOTH=$P($G(^PS(59.7,1,40.2)),"^"),DIE="^PS(50.7,",DA=PSVAR
  1. S DR=".05;@1;D SETF^PSSPOIMO;.06;D DFR^PSSPOIMO(PSBEFORE1);10//YES;I X=""Y"" S Y=""@2"";S:$G(DUOUT) Y=""@3"";" D
  1. .S DR=DR_"D PDCHK^PSSPOIMO S:PSSFG Y=""@1"";S:$G(DUOUT) Y=""@3"";@2;K DIE(""NO^""),DIRUT;D MRSEL^PSSPOIMO;.07;.08;1;12//0;7;S:'$G(PSSOTH) Y=""@3"";7.1;@3" ;*191
  1. D ^DIE S PSAFTER=$P(^PS(50.7,PSVAR,0),"^",4) K DIE,DA,DR,PSSOTH,^TMP("PSJMR",$J),^TMP("PSSDMR",$J) I $D(PSSOU),'$G(PSSOU) D MRSEL^PSSPOIMO K ^TMP("PSJMR",$J)
  1. S:PSBEFORE&('PSAFTER) PSINORDE="D" S:PSAFTER PSINORDE="I"
  1. I PSINORDE'="" D REST^PSSPOIDT(PSVAR)
  1. K PSBEFORE,PSBEFORE1,PSAFTER,PSINORDE
  1. N DIE,DA,DR ; Indications for Use fields PSS*1*204,*242 - Other lang
  1. S DIE="^PS(50.7,",DA=PSVAR,DR="D LIND^PSSPOIMO;14;13;14.1T;14.2" D ^DIE K DIE
  1. IMMUN ;PSS*1*141 FOR 'IMMUNIZATIONS DOCUMENTATION BY BCMA'
  1. I $O(^PSDRUG("AOC",PSVAR,"IM000"))'["IM" G SYN ;ASK WHEN APPROPRIATE
  1. W ! S DIE="^PS(50.7,",DA=PSVAR,DR=9 D ^DIE K DIE
  1. SYN I $G(Y)["^"!($G(DIRUT))!$D(DTOUT)!($D(Y)>10) G FINS
  1. W ! K DIC S:'$D(^PS(50.7,PSVAR,2,0)) ^PS(50.7,PSVAR,2,0)="^50.72^0^0" S DIC="^PS(50.7,"_PSVAR_",2,",DA(1)=PSVAR,DIC(0)="QEAMZL",DIC("A")="Select SYNONYM: ",DLAYGO=50.72 D ^DIC K DIC
  1. I Y<0!($D(DTOUT))!($D(DUOUT)) K:'$O(^PS(50.7,PSVAR,2,0)) ^PS(50.7,PSVAR,2,0) S PSSNOOI=1 G FIN
  1. W ! S DA=+Y,DIE="^PS(50.7,"_PSVAR_",2,",DA(1)=PSVAR,DR=.01 D ^DIE K DIE G SYN
  1. FIN D EN^PSSPOIDT(PSVAR) I $G(PSVAR1) D EN2^PSSHL1(PSVAR,"MAD") G FINS
  1. D EN2^PSSHL1(PSVAR,"MUP")
  1. FINS K PSVAR,PSVAR1 Q
  1. ;
  1. DATE ;
  1. F ZZZ=0:0 S ZZZ=$O(^PS(50.7,ZZZ)) Q:'ZZZ S PSOTYPE=$P($G(^PS(50.7,ZZZ,0)),"^",3) D
  1. .I PSOTYPE,'$D(^PS(52.6,"AOI",ZZZ)),'$D(^PS(52.7,"AOI",ZZZ)),'$P($G(^PS(50.7,ZZZ,0)),"^",4) K DIE S DIE="^PS(50.7,",DA=ZZZ,DR=".04////"_DT D ^DIE K DIE Q
  1. .Q:PSOTYPE
  1. .D SUPP
  1. .I '$D(^PSDRUG("ASP",ZZZ)),'$P($G(^PS(50.7,ZZZ,0)),"^",4) K DIE S DIE="^PS(50.7,",DA=ZZZ,DR=".04////"_DT D ^DIE K DIE Q
  1. .D:'$P($G(^PS(50.7,ZZZ,0)),"^",4)
  1. ..S PSDFLAG=0 F WW=0:0 S WW=$O(^PSDRUG("ASP",ZZZ,WW)) Q:'WW!(PSDFLAG) S PSAPPL=$P($G(^PSDRUG(WW,2)),"^",3) I PSAPPL["I"!(PSAPPL["O")!(PSAPPL["U") S PSDFLAG=1
  1. ..I 'PSDFLAG K DIE S DIE="^PS(50.7,",DA=ZZZ,DR=".04////"_DT D ^DIE K DIE
  1. F ZZZ=0:0 S ZZZ=$O(^PS(52.7,ZZZ)) Q:'ZZZ S RRRR=$P($G(^PS(52.7,ZZZ,0)),"^",11) I RRRR,'$P($G(^PS(50.7,RRRR,0)),"^",3) K DIE S DA=ZZZ,DIE="^PS(52.7,",DR="9////"_"@" D ^DIE K DIE
  1. F ZZZ=0:0 S ZZZ=$O(^PS(52.6,ZZZ)) Q:'ZZZ S RRRR=$P($G(^PS(52.6,ZZZ,0)),"^",11) I RRRR,'$P($G(^PS(50.7,RRRR,0)),"^",3) K DIE S DA=ZZZ,DIE="^PS(52.6,",DR="15////"_"@" D ^DIE K DIE
  1. D:$G(PSCREATE) MAIL^PSSCREAT
  1. I '$G(PSSOMAIL) K PSOTYPE,DA,DIE,WW,RRRR,PSDFLAG,PSAPPL,GGG,HHH,ZZZZZ Q
  1. S PSOTEXT(1)="You have completed the matching process required for the installation of",PSOTEXT(2)="Outpatient V. 7.0 and Inpatient Medications V. 5.0!"
  1. S XMDUZ=.5,XMY(DUZ)="",XMTEXT="PSOTEXT(",XMSUB="Pharmacy Orderable Item File" D ^XMD
  1. S PSSITE=+$O(^PS(59.7,0)) S $P(^PS(59.7,PSSITE,80),"^",2)=3 K PSSITE
  1. D ^%ZISC K PSOTYPE,DA,DIE,WW,RRRR,PSDFLAG,PSAPPL,GGG,HHH,ZZZZZ,PSSOMAIL S:$D(ZTQUEUED) ZTREQ="@" Q
  1. RMES W !!,"This report takes a long time to first build the data to print, then to",!,"actually print the data. To avoid tying up a terminal for a long period of time,",!,"the report must be QUEUED to a printer."
  1. W !!,"This report must be QUEUED to a printer!"
  1. Q
  1. KMES W !!,"Due to the length of this report, and to avoid tying up a terminal for a long",!,"time, this report must be QUEUED to a printer!"
  1. Q
  1. SUPP ;Mark as supply
  1. N SSSUP,SSSIN,SSSAP,SSLOOP,SSSQUE,SSSQUEY,SSSQDATE,SLIP,SLDO,SLDP
  1. S (SSSQUE,SSSQUEY)=0 F SSLOOP=0:0 S SSLOOP=$O(^PSDRUG("ASP",ZZZ,SSLOOP)) Q:'SSLOOP!(SSSQUEY) D
  1. .I $P($G(^PSDRUG(SSLOOP,0)),"^",3)["S" S SSSAP=$P($G(^(2)),"^",3),SSSIN=$P($G(^("I")),"^") D
  1. ..I SSSAP["O"!(SSSAP["I")!(SSSAP["U") I 'SSSIN S $P(^PS(50.7,ZZZ,0),"^",9)=1 S (SSSQUEY,SSSQUE)=1 Q
  1. ..I SSSAP["O"!(SSSAP["I")!(SSSAP["U") I +SSSIN>DT S $P(^PS(50.7,ZZZ,0),"^",9)=1 S SSSQUE=1,SSSQDATE($E(SSSIN,1,7))=""
  1. I 'SSSQUEY,SSSQUE,$O(SSSQDATE(0)) F SLIP=0:0 S SLIP=$O(SSSQDATE(SLIP)) Q:'SLIP D
  1. .S ZTRTN="ENT^PSSPOIDT",ZTDESC="Supply update for Orderable Item",ZTIO="",ZTDTH=SLIP_.01 S SLDO=$G(PSSORDIT),SLDP=$G(PSSCROSS) S PSSORDIT=ZZZ,PSSCROSS=1 S ZTSAVE("PSSORDIT")="",ZTSAVE("PSSCROSS")="" D ^%ZTLOAD D
  1. ..S PSSORDIT=$G(SLDO) K:'PSSORDIT PSSORDIT
  1. ..S PSSCROSS=$G(SLDP) K:'PSSCROSS PSSCROSS
  1. Q
  1. ;