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

PSGOD.m

Go to the documentation of this file.
  1. PSGOD ;BIR/CML - CREATES NEW ORDER FROM OLD ONE ;Jul 27, 2020@09:22:09
  1. ;;5.0;INPATIENT MEDICATIONS;**67,58,111,133,181,286,281,315,338,256,347,367,327,399,372**;16 DEC 97;Build 153
  1. ;Per VHA Directive 2004-038, this routine should not be modified.
  1. ; Reference to ^PS(55 is supported by DBIA 2191.
  1. ; Reference to ^YSCLTST5 is supported by DBIA 7188.
  1. ; Reference to $$SDEA^XUSER supported by DBIA 2343
  1. ;
  1. ;*286 - Do not allow copied Unit Dose orders for outpatients
  1. D INP^VADPT I 'VAIN(4) W !,"You cannot copy Unit Dose orders for this patient!" H 2 Q
  1. I $P($G(^PS(55,PSGP,5,+PSJORD,0)),"^",22) D Q
  1. .W !,"This order is marked 'Not To Be Given' and can't be copied!" H 2
  1. ; /MZR PSJ*5*327 start
  1. N CLOZFLG D G:$G(ANQX) DONE
  1. .S CLOZFLG=$$ISCLOZ^PSJCLOZ(,,PSGP,+PSJORD) Q:'CLOZFLG ; continue just with Clozapine drug
  1. .N CLOZNUM,CLOZUID
  1. .S CLOZNUM=$$GET1^DIQ(55,DFN,53)
  1. .I CLOZNUM'="" S CLOZUID=$$FIND1^DIC(603.01,,"X",CLOZNUM)
  1. .I '$G(CLOZUID) D Q
  1. ..W !!,"*** This patient has no clozapine registration number ***"
  1. ..W !,"*** and must be reregistered ***"
  1. ..D PAUSE^VALM1 S ANQX=1 Q
  1. .S CLOZPAT=$$GET1^DIQ(603.01,CLOZUID,2,"I"),CLOZPAT=$S(CLOZPAT="M":2,CLOZPAT="B":1,CLOZPAT="W":0,1:90)
  1. ; /MZR PSJ*5*327 end
  1. F W !!,"Do you want to copy this order" S %=2 D YN^DICN Q:% D CH
  1. G:%'=1 DONE
  1. ;
  1. W !!,"...copying..." N OLDON
  1. K PSGORQF
  1. N PSGPDRG,Q
  1. N PSJOLDNM
  1. S PSGOEPR=$P($G(^PS(55,PSGP,5.1)),"^",2),OLDON=PSGORD,Q=""
  1. K PSGODN S F=$S(PSGORD["P":"^PS(53.1,"_+PSGORD_",",1:"^PS(55,"_PSGP_",5,"_+PSGORD_",") F N=0,.2,2,2.1,6 S PSGODN(N)=$G(@(F_N_")"))
  1. S PSGPR=$P(PSGODN(0),"^",2),PSGMR=$P(PSGODN(0),"^",3),PSGSM=$P(PSGODN(0),"^",5),PSGHSM=$P(PSGODN(0),"^",6),PSGST=$P(PSGODN(0),"^",7)
  1. S PSGPDRG=+PSGODN(.2),PSGDO=$P(PSGODN(.2),"^",2)
  1. ;
  1. ;*372
  1. I $G(PSGPDRG) N PDEA S PDEA="" D I (PDEA=1)!(PDEA=2)!(+PDEA=4) D PAUSE^VALM1 G ORIG
  1. . N PSJDEA S PSJDEA=$$OIDEA^PSSOPKI(PSGPDRG,"U"),PSJDEA=$P(PSJDEA,";",2)
  1. . I PSJDEA S PDEA=$$SDEA^XUSER(,+PSGPR,PSJDEA,,"I") I (PDEA=1)!(PDEA=2)!(+PDEA=4) D
  1. .. W !!,"Provider not authorized to prescribe medications in Federal Schedule "_PSJDEA_".",!,"Please contact the provider.",!
  1. ;
  1. ;*315
  1. S:$G(PSGODN(2.1))]"" PSGDUR=+PSGODN(2.1),PSGRMVT=$P(PSGODN(2.1),U,2),PSGRMV=$P(PSGODN(2.1),U,3),PSGRF=$P(PSGODN(2.1),U,4)
  1. S PSGSI=PSGODN(6)
  1. ; The naked reference below refers to the full reference inside indirection to ^PS(55,PSGP,5,+PSGORD, or ^PS(55,PSGP,"IV",+PSGORD, or ^PS(53.1,+PSGORD
  1. S PSGODN(3)=0 F Q=0:0 S Q=$O(@(F_"3,"_Q_")")) Q:'Q I $D(^(Q,0)) S PSGODN(3,Q)=^(0),PSGODN(3)=PSGODN(3)+1 S ^PS(53.45,PSJSYSP,1,Q,0)=^(0)
  1. ;S:PSGODN(12)>0 ^PS(53.45,PSJSYSP,4,0)="^53.4504" S:PSGODN(3)>0 ^PS(53.45,PSJSYSP,1,0)="^53.4501"
  1. S:PSGODN(3)>0 ^PS(53.45,PSJSYSP,1,0)="^53.4501"
  1. ; The naked reference below refers to the full reference inside indirection to ^PS(55,PSGP,5,+PSGORD, or ^PS(55,PSGP,"IV",+PSGORD, or ^PS(53.1,+PSGORD
  1. ;338
  1. N PSGK5345 S PSGK5345=0
  1. S (PSGODN(1),Q)=0 F S Q=$O(@(F_"1,"_Q_")")) Q:'Q S ND=$G(^(Q,0)) I ND D
  1. .I '$P(ND,"^",3),'PSGK5345 S PSGODN(1)=PSGODN(1)+1,PSGODN(1,PSGODN(1))=$P(ND,"^",1,2) S ^PS(53.45,PSJSYSP,2,PSGODN(1),0)=^(0)
  1. .I '$P(ND,"^",3),PSGK5345 S PSGODN(1,PSGODN(1))=$P(ND,"^",1,2) S ^PS(53.45,PSJSYSP,2,PSGODN(1),0)=^(0) S PSGODN(1)=PSGODN(1)+1,PSGK5345=0 K ^PS(53.45,PSJSYSP,2,PSGODN(1),0)
  1. .I $P(ND,"^",3) S PSGODN(1)=PSGODN(1)+1 K ^PS(53.45,PSJSYSP,2,PSGODN(1),0) S PSGK5345=1
  1. K PSGK5345
  1. S PSGS0Y=$P(PSGODN(2),"^",5),PSGS0XT=$P(PSGODN(2),"^",6),PSGNESD="",PSGSCH=$P(PSGODN(2),U)
  1. ;PSJ*5*256
  1. S PSJOLDNM("ORD_SCHD")=PSGSCH
  1. I $$CHKSCHD^PSJMISC2(.PSJOLDNM) W !!,"Order not copied." D PAUSE^VALM1 K PSJOLDNM G ORIG
  1. S:$G(PSJOLDNM("NEW_SCHD"))]"" PSGSCH=PSJOLDNM("NEW_SCHD") K PSJOLDNM
  1. S PSGODF=1,PSGNEDFD=$P($$GTNEDFD^PSGOE7("U",+PSGPDRG),U)_"^^"_PSGST_"^"_PSGSCH
  1. W "." D ^PSGNE3
  1. K PSGEFN,PSGOEEF,PSGOEE,PSGOEOS S PSGEFN="1:14" F X=1:1:14 S PSGEFN(X)="" ;*399-IND
  1. S PSGPDN=$$OINAME^PSJLMUTL(PSGPDRG),PSGOINST="",PSGSDN=$$ENDD^PSGMI(PSGNESD)_U_$$ENDTC^PSGMI(PSGNESD),PSGFDN=$$ENDD^PSGMI(PSGNEFD)_U_$$ENDTC^PSGMI(PSGNEFD)
  1. S PSGAT=PSGS0Y,PSGEBN=DUZ,PSGLIN=$$ENDD^PSGMI(PSGDT)_U_$$ENDTC^PSGMI(PSGDT),PSGEBN=$$ENNPN^PSGMI(DUZ),PSGSTAT=$S(PSGOEAV:"ACTIVE",1:"NON-VERIFIED")
  1. W "." D CHK^PSGOEV("^^"_PSGMR_"^^^^"_PSGST,PSGPDRG_U_PSGDO,PSGSCH_U_PSGNESD_"^^"_PSGNEFD)
  1. I $G(PSGSCH)]"" D
  1. .N X S X=PSGSCH N SWD,SDW,XABB,QX D ENOS^PSGS0 I $G(X)=""!$G(PSJNSS) S CHK=1 K PSJNSS Q
  1. .I $G(PSGAT)="",$G(PSGS0Y) S PSGAT=PSGS0Y
  1. .I $G(PSGAT),($G(PSGS0Y)="") S PSGS0Y=PSGAT
  1. .I $G(PSGS0XT)="D",$G(PSGS0Y)="" S CHK=1 D K PSJNSS
  1. ..W ! K DIR S DIR(0)="FOA",DIR("A")=" WARNING - Admin times are required for DAY OF WEEK schedules " D ^DIR K DIR
  1. S PSGSD=PSGNESD,PSGFD=PSGNEFD
  1. K PSJACEPT S VALMBCK="Q" D:$D(Y) EN^VALM("PSJU LM ACCEPT")
  1. I $G(PSJACEPT)=1 D OC S:$D(PSGORQF) PSJACEPT=0 S:$G(PSJACEPT)=1 VALMBCK="",PSJNOO=$$ENNOO^PSJUTL5("N")
  1. I '$G(PSJACEPT)!($G(PSJNOO)<0) W:'$G(PSJCOFLG) !!,"Order not copied." D PAUSE^VALM1:'$G(PSJCOFLG) G ORIG ;PSJCOFLG set in PSODGAL1 for allergies
  1. S PSGNESD=PSGSD,PSGNEFD=PSGFD
  1. K PSGOEE D ^PSGOETO S PSJORD=PSGORD I PSGOEAV D
  1. .I '$D(PSGOEE),+PSJSYSU=3 D EN^PSGPEN(PSGORD)
  1. .;; START NCC REMEDIATION >> 327*RJS
  1. .I +$G(PSGCOPY)!(+$G(PSGEDT)) D
  1. ..I CLOZFLG D
  1. ...I $D(^TMP($J,"PSGCLOZ",DFN,+$G(PSJORD),"SAND")) D K ^TMP($J,"PSGCLOZ",DFN,+PSJORD,"SAND")
  1. ....S DIE="^PS(55,"_DFN_",5,",DA=+PSJORD,DA(1)=DFN,DR="301////"_^TMP($J,"PSGCLOZ",DFN,+PSJORD,"SAND") D ^DIE
  1. ...N PSGDN S PSGDN=$P(CLOZFLG,U,2)
  1. ...D PSJFILE^PSJCLOZ(DFN),INPSND^YSCLTST5 K:$D(^TMP($J,"CLOZFLG",DFN)) ^TMP($J,"CLOZFLG",DFN)
  1. .;; END NCC REMEDIATION >> 327*RJS
  1. .D SETOC^PSJNEWOC(PSGORD) ;RTC 178789 Store allergy if auto vf is on
  1. D GETUD^PSJLMGUD(PSGP,PSGORD) N PSGOEEF S PSGOEEF=0 D ENSFE^PSGOEE0(PSGP,PSGORD),^PSGOE1,EN^VALM("PSJ LM UD ACTION")
  1. ;RTC 178789 - store allery if not verified the newly copied order
  1. I ($G(PSGORD)["P"),($P($G(^PS(53.1,+PSGORD,0)),U,9)="N"),($G(PSJOCFG)="COPY UD") D SETOC^PSJNEWOC(PSGORD)
  1. ;
  1. S PSGCANFL=0,(PSGORD,PSJORD)=OLDON W !!,"You are finished with the new order.",!,"The following ACTION prompt is for the original order."
  1. K DIR S DIR(0)="E" D ^DIR K DIR
  1. ORIG ;Redisplay original order
  1. D GETUD^PSJLMGUD(PSGP,OLDON),INIT^PSJLMUDE(PSGP,OLDON)
  1. DONE ;
  1. K %,%H,%I,DA,F,N,PSGODN,PSGODF,PSGS0XT,PSGS0Y,PSGNESD,PSGTOL,PSGTOO,PSGUOW,X,Y,^PS(53.45,PSJSYSP,1),^PS(53.45,PSJSYSP,2)
  1. K PSGPR,PSGMR,PSGSM,PSGHSM,PSGST,PSGPDRG,PSGDO,PSGNEDFD,PSGSCH,PSGNEFD
  1. Q
  1. ;
  1. CH ;
  1. W !!?2,"Answer 'YES' to have a new, non-verified order created for this patient,",!,"using the information from this order. (The START and STOP dates will be",!,"recalculated.) Enter 'NO' (or '^') to stop now." Q
  1. ;
  1. WH ;
  1. W !!?2,"Answer 'YES' to take action on this new order. Enter 'NO' (or '^') to return",!,"to the original order now." Q
  1. ;
  1. OC ;Perform order checks
  1. NEW PSJDD,X,PSJALLGY
  1. ;*286 - Order checks on current dispense drugs
  1. F X=0:0 S X=$O(^PS(53.45,PSJSYSP,2,X)) Q:'X D
  1. . S PSJDD=$G(^PS(53.45,PSJSYSP,2,X,0))
  1. . I +PSJDD S PSJALLGY(+PSJDD)=""
  1. ;S X=+$O(PSGODN(1,0)) Q:'X S PSJDD=+$G(PSGODN(1,X)) Q:'PSJDD
  1. S PSJDD=+$O(PSJALLGY(0)) Q:'PSJDD
  1. D FULL^VALM1
  1. ;; START NCC REMEDIATION >> 327*RJS FOR TOTAL DAILY DOSE
  1. I CLOZFLG S ANQX=0 D TDD^PSJCLOZ
  1. Q:$G(PSGORQF)
  1. ;/RJS Begin PSJ*5.0*327 modification FOR ORDER CHECKS
  1. S PSJDD=+$O(PSJALLGY(0)) Q:'PSJDD
  1. D FULL^VALM1
  1. D ENDDC^PSGSICHK($G(PSGP),PSJDD) Q:$G(PSGORQF)
  1. D IN^PSJOCDS($G(PSGORD),"UD",PSJDD) Q:$G(PSGORQF)
  1. D ORD^PSJCLOZ
  1. Q