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

PSSMSTR.m

Go to the documentation of this file.
  1. PSSMSTR ;BIR/PWC-Send Master Drug File to External Interface ;04/05/04
  1. ;;1.0;PHARMACY DATA MANAGEMENT;**82,193**;09/30/97;Build 17
  1. ;Reference to ^PS(59 supported by IA # 1976
  1. ;
  1. ;This routine will loop through the Drug file and send all drugs
  1. ;to each dispensing machine for each outpatient site file.
  1. ;It will only send to each site that has a dispensing machine running
  1. ;HL7 V.2.4 and has the Master File Update enabled.
  1. ;As part of Pharmacy Interface Automation Project (PIA), this routine
  1. ;is modified to send all drugs to an active Pharmacy Automated Dispensing
  1. ;Equipment (PADE), located at the point of care areas such as
  1. ;Inpatient wards, Outpatient Clinics etc.
  1. ;Task this job out
  1. ;
  1. EN ; Begin processing PSS Master File All send drugs via HL7
  1. W @IOF N ZTSAVE,ZTRTN,ZTDESC,ZTIO,ZTDTH,X,Y
  1. D KV
  1. S DIR("A")="Send Drug file to which External Interface below?"
  1. S DIR(0)="SO^1:Outpatient Interface (OPAI);2:Inpatient Interface (PADE)"
  1. S DIR("?",1)=" Option 1 is for sending to the Outpatient Pharmacy Automation Interface."
  1. S DIR("?",2)=" Option 2 is for sending to the Pharmacy Automated Dispensing Equipment (PADE)"
  1. S DIR("?",3)=" located at the point of care."
  1. S DIR("?",4)=" OR Enter '^' to quit."
  1. S DIR("?",5)=""
  1. S DIR("?")="*Caution: This is usually done on the initial setup of the dispensing equipment."
  1. D ^DIR Q:'Y
  1. W !!,"You selected to send the Drug file to the "_Y(0),!
  1. I Y=1 D Q
  1. . S ZTRTN="BUILD^PSSMSTR",ZTDESC="MASTER DRUG FILE UPDATE",ZTIO=""
  1. . S ZTDTH=$H D NOW^%DTC S PSSDTM=% D ^%ZTLOAD
  1. ;*193 - PADE
  1. N SPNAM,PROT S SPNAM="PSS MFNM01 SERVER"
  1. S PROT=$O(^ORD(101,"B",SPNAM,0))
  1. I '$$SNDHL7() W !!,"*Drug transmission is not setup for PADE",!! H 2 G EN
  1. I 'PROT W !!,"Drug Update Protocol "_SPNAM_" is NOT Installed",!! H 2 G EN
  1. EN1 ;
  1. W !!,?5,"This only sends your Drug selections as NEW additions to PADE"
  1. W !?5,"If you need to send drug updates, then use the PSS DRUG/ENTER EDIT option"
  1. W !
  1. D KV
  1. S DIR("A")="Send all or selected drugs to the PADE system?"
  1. S DIR(0)="SO^1:Send all drugs marked for a package;2:Send selected drugs"
  1. S DIR("?",1)=" Option 1 is for sending all the active drugs by package"
  1. S DIR("?",2)=" Option 2 is for sending selected drugs only"
  1. S DIR("?",3)=" OR Enter '^' to quit."
  1. S DIR("?",4)=""
  1. S DIR("?")="*Caution: Option 1 is usually done on the initial setup of the dispensing equipment."
  1. D ^DIR G:'Y EN
  1. N PSSPADE S PSSPADE=1
  1. G:Y=2 SDRG
  1. I '$D(^XUSEC("PSS PADE INIT",DUZ)) D G EN1
  1. .W $C(7),!!,?9,"**You need the PSS PADE INIT key."
  1. .W !,?11,"Please contact your Pharmacy Coordinator for access",! H 2
  1. N PSSCPK S PSSCPK=""
  1. I '$D(IOINORM)!('$D(IOINHI)) N IORVOFF,IORVON,IOINHI,IOINORM D
  1. .S X="IORVOFF;IORVON;IOINHI;IOINORM" D ENDR^%ZISS
  1. W !,"WARNING - With this option, you will be sending a large number of"
  1. W !,"drugs from your drug file to ""build"" a working database or drugs"
  1. W !,"on your PADE system. It is imperative to ",IORVON_IOINHI,"NOT",IOINORM_IORVOFF," RUN this option if you"
  1. W !,"already have a working formulary of drugs on your PADE system;"
  1. W !,"as resending may overwrite modifications to the fields that you"
  1. W !,"have made on your PADE system.",!!
  1. D KV ; CHECK FOR APPLICATION PACKAGE USAGE U,IV or Ward Stock
  1. S DIR(0)="Y",DIR("B")="NO",DIR("A")="Do you want to continue"
  1. S DIR("?")="Enter Y for Yes or N for No." D ^DIR K DIR
  1. G:'Y EN
  1. D KV W !
  1. S DIR(0)="Y",DIR("B")="NO",DIR("A")="Do you want to send drugs marked for UD package"
  1. S DIR("?")="Enter Y for Yes or N for No." D ^DIR K DIR
  1. G:$D(DIRUT) EN1
  1. S:Y PSSCPK="U"
  1. W !
  1. S DIR(0)="Y",DIR("B")="NO",DIR("A")="Do you want to send drugs marked for IV package"
  1. S DIR("?",1)="This option will look for 'I' in the application package field"
  1. S DIR("?",2)="of the drug file (#50) in determining if the drug is marked for"
  1. S DIR("?",3)="this package. The system will NOT check to see if there is an"
  1. S DIR("?",4)="additive or solution associated with the drug in determining if"
  1. S DIR("?",5)="it will be sent."
  1. S DIR("?",6)=""
  1. S DIR("?")="Enter Y for Yes or N for No." D ^DIR K DIR
  1. G:$D(DIRUT) EN1
  1. S:Y PSSCPK=$G(PSSCPK)_"I"
  1. W !
  1. S DIR(0)="Y",DIR("B")="NO",DIR("A")="Do you want to send drugs marked for Ward Stock package"
  1. S DIR("?",1)="This option will only look for 'W' in the application package field"
  1. S DIR("?",2)="of the drug file (#50) in determining if the drug is marked for"
  1. S DIR("?",3)="this package. It is possible for drugs to be used in the AR/WS"
  1. S DIR("?",4)="package but NOT marked with a 'W' in the application package field."
  1. S DIR("?",5)="Those drugs would not be sent with this option and must be added to"
  1. S DIR("?",6)="your PADE system manually."
  1. S DIR("?",7)=""
  1. S DIR("?")="Enter Y for Yes or N for No." D ^DIR K DIR
  1. G:$D(DIRUT) EN1
  1. G:PSSCPK=""&('Y) EN1
  1. S:Y PSSCPK=$G(PSSCPK)_"W"
  1. EPD ;
  1. W !!,"Drug File Queued to be sent to PADE" H 2
  1. ;D PADE
  1. ;Q
  1. S ZTRTN="PADE^PSSMSTR",ZTDESC="MASTER DRUG FILE UPDATE TO PADE",ZTIO=""
  1. S ZTSAVE("PSSCPK")="",ZTSAVE("PSSPADE")="",ZTDTH=$H D NOW^%DTC S PSSDTM=% D ^%ZTLOAD
  1. Q
  1. ;
  1. BUILD ;
  1. N XX,DVER,DMFU,DNSNAM,DNSPORT
  1. F XX=0:0 S XX=$O(^PSDRUG(XX)) Q:'XX D
  1. . F YY=0:0 S YY=$O(^PS(59,YY)) Q:'YY D
  1. .. S DVER=$$GET1^DIQ(59,YY_",",105,"I") Q:DVER'="2.4" ;HL7 2.4
  1. .. S DMFU=$$GET1^DIQ(59,YY_",",105.2) Q:DMFU'="YES" ;enable MFU
  1. .. S DNSNAM=$$GET1^DIQ(59,YY_",",2006) ;DNS name of dispense machine
  1. .. S DNSPORT=$$GET1^DIQ(59,YY_",",2007) ;Port # of dispense machine
  1. .. I DNSNAM'="" D DRG^PSSDGUPD(XX,"NEW",DNSNAM,DNSPORT)
  1. K XX,YY,DVER,DMFU,DNSNAM,DNSPORT
  1. Q
  1. ;
  1. PADE ;
  1. N PSSG,PSSAP,PSSDRG,SPNAM,I S SPNAM="PSS MFNM01 SERVER"
  1. S PSSDRG=0,PSSAP=""
  1. F S PSSDRG=$O(^PSDRUG(PSSDRG)) Q:'PSSDRG D
  1. .Q:$G(^PSDRUG(PSSDRG,"I"))&($P($G(^("I")),"^")<DT)
  1. .S PSSAP=$P($G(^(2)),"^",3),PSSG=0 Q:PSSAP=""
  1. .F I=1:1:$L(PSSCPK) I PSSAP[$E(PSSCPK,I) S PSSG=1 Q
  1. .Q:'PSSG
  1. .D SPADE
  1. Q
  1. ;
  1. SPADE ;
  1. N XX,VR,DNSNAM,DNSPORT,PSSD,PSSNM
  1. S XX=0 F S XX=$O(^PS(58.7,XX)) Q:'XX D
  1. .S PSSD=$G(^PS(58.7,XX,0))
  1. .Q:PSSD=""
  1. .S PSSNM=$P(PSSD,"^"),DNSNAM=$P(PSSD,"^",2),DNSPORT=$P(PSSD,"^",3)
  1. .Q:PSSNM=""!(DNSNAM="")!(DNSPORT="") ;CHECK PADE, DNS NAME & PORT ARE DEFINED
  1. .S VR=$P(PSSD,"^",4) Q:VR&(VR<DT) ;INACTIVE DATE CHECK
  1. .S VR=$P(PSSD,"^",5) Q:VR="X"!(VR="") ;SEND DRUG UPDATE
  1. .D PROCESS1^PSSHLDFS(SPNAM,PSSDRG,"MAD",DNSNAM,DNSPORT)
  1. Q
  1. SNDHL7() ; Check if at least one PADE vendor equipment is setup to accept
  1. ; HL7 Drug messages.
  1. ; Input - None
  1. ; Output - 1, send HL7 message
  1. ; 0, don't send message
  1. ;
  1. N XX,VR,FLG,SPNAM,DNSNAM,DNSPORT,PSSD,PSSNM
  1. S (FLG,XX)=0 F S XX=$O(^PS(58.7,XX)) Q:'XX!(FLG) D
  1. .S PSSD=$G(^PS(58.7,XX,0))
  1. .Q:PSSD=""
  1. .S PSSNM=$P(PSSD,"^"),DNSNAM=$P(PSSD,"^",2),DNSPORT=$P(PSSD,"^",3)
  1. .Q:PSSNM=""!(DNSNAM="")!(DNSPORT="") ;CHECK PADE, DNS NAME & PORT ARE DEFINED
  1. .S VR=$P(PSSD,"^",4) Q:VR&(VR<DT) ;INACTIVE DATE CHECK
  1. .S VR=$P(PSSD,"^",5) Q:VR="X"!(VR="") ;SEND NONE
  1. .S FLG=$S(VR="U":1,VR="N":2,1:3) ;SEND DRUG MESSAGES
  1. Q FLG
  1. ;
  1. KV K DIR,DIRUT,DUOUT,DTOUT
  1. Q
  1. ;
  1. SDRG ;
  1. W !!,?5,"You may select a single Drug or several Drugs",!!
  1. N PSSDRUG K DIC,DUOUT,DTOUT S DIC(0)="QEAM",DIC="^PSDRUG("
  1. S DIC("S")="I $S('$D(^PSDRUG(+Y,""I"")):1,'^(""I""):1,DT'>^(""I""):1,1:0)"
  1. F D ^DIC Q:Y<0 D
  1. . S PSSDRUG(+Y)=""
  1. K DA,DIC
  1. I $G(DUOUT)!($G(DTOUT))!('$O(PSSDRUG(""))) G EN
  1. N PSSDRG,SPNAM S SPNAM="PSS MFNM01 SERVER"
  1. S PSSDRG=0
  1. F S PSSDRG=$O(PSSDRUG(PSSDRG)) Q:'PSSDRG D SPADE
  1. Q
  1. ;