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

PSS50DAT.m

Go to the documentation of this file.
PSS50DAT ;BHAM ISC/TSS - CONTINUATION OF API FOR INFORMATION FROM FILE 50; 5 Sep 03 
 ;;1.0;PHARMACY DATA MANAGEMENT;**85,92,112,118**;9/30/97;Build 8
DATA ;
 ;PSSIEN - IEN of entry in 50
 ;PSSFT - Free Text name in 50
 ;PSSFL - Inactive flag - "" - All entries
 ;                        FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
 ;PSSPK - Application Package's Use - "" - All entries
 ;                                         Alphabetic codes that represent the DHCP packages that consider this drug to be
 ;                                         part of their formulary.
 ;PSSRTOI - Orderable Item - return only entries matched to a Pharmacy Orderable Item                                         
 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the Field Number of the data
 ;       piece being returned.
 ;Reference to ^PSNDF(50.68 is supported by DBIA 3735
 ;NEW UNPROTECTED FILEMAN VARIABLES
 N DO,DINDEX,DISUB,DIVAL
 N PSSBGCNT
 N PSSCNT
 N PSSTIEN
 N PSSTMP
 N PSSOLD
 N PSSALT
 N PSSMATCH
 N PSSSYN
 N PSSCAP
 S PSSBGCNT=0
 S SCR("S")=""
 I $G(LIST)']"" Q
 I +$G(PSSIEN)'>0,($G(PSSFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
 K ^TMP("DILIST",$J)
 K ^TMP($J,LIST)
 S SCR("S")=""
 I +$G(PSSFL)>0!($G(PSSPK)]"")!($G(PSSRTOI)=1) N PSS5ND,PSSZ3,PSSZ4 D SETSCRN^PSS50A
 I +$G(PSSIEN)>0 N PSSIEN2 S PSSIEN2=$$FIND1^DIC(50,"","A","`"_PSSIEN,,SCR("S"),"") D  K ^TMP("PSSP50",$J) D COUNTBG Q
 .I PSSIEN2>0 D DIRREAD
 I +$G(PSSIEN)=0 D
 .I PSSFT="??" D LOOPDIR D COUNTBG Q
 .D FIND^DIC(50,,"@;.01","QP",PSSFT,,"B",SCR("S"),,"") D LOOPDI D COUNTBG
 Q
 ;
COUNTBG ;CHECKS PSSBGCNT AND FILLS COUNT IN ON 0 NODE OF ^TMP($J,LIST)
 I PSSBGCNT>0 D
 .S ^TMP($J,LIST,0)=PSSBGCNT
 ELSE  S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND"
 Q
 ;
LOOPDI ;LOOPS ON "DILIST" FROM FILEMAN CALL (USED FOR RETURNING MULTIPLE DRUGS FROM PSSFT)
 S PSSTIEN=0 ;TEMP IEN TO ITERATE OVER DILIST
 F  S PSSTIEN=$O(^TMP("DILIST",$J,PSSTIEN)) Q:PSSTIEN=""  D
 .S PSSIEN2=($P(^TMP("DILIST",$J,PSSTIEN,0),U,1))
 .D DIRREAD
 Q
 ;
LOOPDIR ;LOOP FOR A DIRECT READ.  READS ALL IENs FOR ^PSDRUG(
 S PSSIEN2=0
 F  S PSSIEN2=$O(^PSDRUG(PSSIEN2)) Q:'PSSIEN2  D
 .I $P($G(^PSDRUG(PSSIEN2,0)),U,1)'="" D DIRALL
 Q
 ;
DIRALL ;TEST FOR PSSFL, PSSRTOI, PSSPK, BAILS IF CONDITIONS MEET TRUE
 I $G(PSSFL),$P($G(^PSDRUG(PSSIEN2,"I")),"^"),$P($G(^("I")),"^")'>PSSFL Q
 I $G(PSSRTOI)=1,'$P($G(^PSDRUG(PSSIEN2,2)),"^") Q
 I $G(PSSPK)]"" N PSSZ5,PSSZ6 S PSSZ5=0 F PSSZ6=1:1:$L(PSSPK) Q:PSSZ5  I $P($G(^PSDRUG(PSSIEN2,2)),U,3)[$E(PSSPK,PSSZ6) S PSSZ5=1
 I $G(PSSPK)]"",'PSSZ5 Q
 D DIRREAD
 Q
 ;
DIRREAD ;MAIN DIRECT READ FOR ENTIRE ROUTINE
 D DIRREAD^PSS50TMP
 D SYNONYM
 S ^TMP($J,LIST,"B",$G(^TMP($J,LIST,PSSIEN2,.01)),PSSIEN2)=""
 D FORMALT
 D OLD
 D SRVCODE($P(^TMP($J,LIST,PSSIEN2,22),U,1))
 S PSSBGCNT=PSSBGCNT+1
 Q
 ;
SYNONYM ; FILLS SYNONYM MULTIPLE
 S PSSCNT=0
 S PSSTMP=""
 S PSSSYN=""
 F  S PSSSYN=$O(^PSDRUG(PSSIEN2,1,PSSSYN)) Q:PSSSYN=""  D
 .I $P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,1)'="" D
 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,.01)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,1)
 ..;;;;;INTENDED USE
 ..S PSSTMP=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,3)
 ..I PSSTMP="0" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"TRADE NAME"
 ..I PSSTMP="1" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"QUICK CODE"
 ..I PSSTMP="D" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"DRUG ACCOUNTABILITY"
 ..I PSSTMP="C" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=PSSTMP_U_"CONTROLLED SUBSTANCES"
 ..I PSSTMP="" S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,1)=""
 ..;;;;;NDC CODE
 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,2)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,2)
 ..S ^TMP($J,LIST,PSSIEN2,"SYN",PSSSYN,403)=$P($G(^PSDRUG(PSSIEN2,1,PSSSYN,0)),U,7)
 ..S PSSCNT=PSSCNT+1
 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"SYN",0)="-1^NO DATA FOUND"
 ELSE  S ^TMP($J,LIST,PSSIEN2,"SYN",0)=PSSCNT
 Q
 ;
FORMALT ;FILLS FORMULARY ALTERATIVE MULTIPLE
 S PSSCNT=0
 S PSSALT=0
 F  S PSSALT=$O(^PSDRUG(PSSIEN2,65,PSSALT)) Q:PSSALT=""  D
 .I $P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1)'="" D
 ..S ^TMP($J,LIST,PSSIEN2,"FRM",PSSALT,2)=$P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1)_U_$P($G(^PSDRUG($P($G(^PSDRUG(PSSIEN2,65,PSSALT,0)),U,1),0)),U,1)
 ..S PSSCNT=PSSCNT+1
 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"FRM",0)="-1^NO DATA FOUND"
 ELSE  S ^TMP($J,LIST,PSSIEN2,"FRM",0)=PSSCNT
 Q
 ;
OLD ;FILLS THE OLD NAME MULTIPLE
 S PSSCNT=0
 S PSSOLD=0
 F  S PSSOLD=$O(^PSDRUG(PSSIEN2,900,PSSOLD)) Q:PSSOLD=""  D
 .I $P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,2)'="" D
 ..S PSSCAP=$$UP^XLFSTR($$FMTE^XLFDT($P(^PSDRUG(PSSIEN2,900,PSSOLD,0),U,2)))
 ..S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.02)=$P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,2)_U_PSSCAP
 .ELSE  S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.02)=""
 .I $P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,1)'="" D
 ..S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.01)=$P($G(^PSDRUG(PSSIEN2,900,PSSOLD,0)),U,1)
 ..S PSSCNT=PSSCNT+1
 .ELSE  S ^TMP($J,LIST,PSSIEN2,"OLD",PSSOLD,.01)=""
 I PSSCNT=0 S ^TMP($J,LIST,PSSIEN2,"OLD",0)="-1^NO DATA FOUND"
 ELSE  S ^TMP($J,LIST,PSSIEN2,"OLD",0)=PSSCNT
 Q
 ;
SRVCODE(PSSMATCH)     ;FILLS SERVICE CODE MULTIPLE
 I PSSMATCH'="" S ^TMP($J,LIST,PSSIEN2,400)=$P($G(^PSNDF(50.68,PSSMATCH,"PFS")),U,1)
 I $P($G(^TMP($J,LIST,PSSIEN2,400)),U,1)="" S ^TMP($J,LIST,PSSIEN2,400)=$P($G(^PSDRUG(PSSIEN2,"PFS")),U,1)
 I $P($G(^TMP($J,LIST,PSSIEN2,400)),U,1)="" S ^TMP($J,LIST,PSSIEN2,400)=600000
 Q
 ;
DRG ;
 ;PSSIEN - IEN of entry in 50
 ;PSSFT - Free Text name in 50
 ;PSSFL - Inactive flag - "" - All entries
 ;                        FileMan Date - Only entries with no Inactive Date or an Inactive Date greater than this date.
 ;PSSPK - Application Package's Use - "" - All entries
 ;                                         Alphabetic codes that represent the DHCP packages that consider this drug to be
 ;                                         part of their formulary.
 ;PSSRTOI - Orderable Item - return only entries matched to a Pharmacy Orderable Item
 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the Field Number of the data
 ;       piece being returned.
 N DIERR,ZZERR,PSSP50,SCR,PSS,PSSMLCT
 I $G(LIST)']"" Q
 K ^TMP($J,LIST)
 I +$G(PSSIEN)'>0,($G(PSSFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
 S SCR("S")=""
 I +$G(PSSFL)>0!($G(PSSPK)]"")!($G(PSSRTOI)=1) N PSS5ND,PSSZ3,PSSZ4 D SETSCRN^PSS50A
 I +$G(PSSIEN)>0 N PSSIEN2 S PSSIEN2=$$FIND1^DIC(50,"","A","`"_PSSIEN,,SCR("S"),"") D  K ^TMP("PSSP50",$J) Q
 .K ^TMP("DIERR",$J)
 .I +PSSIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
 .S ^TMP($J,LIST,0)=1
 .K ^TMP("PSSP50",$J) D GETS^DIQ(50,+PSSIEN2,".01;62.01:62.05;905","IE","^TMP(""PSSP50"",$J)") S PSS(1)=0
 .F  S PSS(1)=$O(^TMP("PSSP50",$J,50,PSS(1))) Q:'PSS(1)  D SETDRG^PSS50A1
 I $G(PSSIEN)'="" S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
 I $G(PSSFT)]"" D
 .I PSSFT["??" D LOOP^PSS50A1 Q
 .K ^TMP("DILIST",$J)
 .D FIND^DIC(50,,"@;.01","QP",PSSFT,,"B",SCR("S"),,"")
 .I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
 .I +^TMP("DILIST",$J,0)>0 S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0) N PSSXX S PSSXX=0 F  S PSSXX=$O(^TMP("DILIST",$J,PSSXX)) Q:'PSSXX  D
 ..S PSSIEN=+^TMP("DILIST",$J,PSSXX,0)
 ..K ^TMP("PSSP50",$J) D GETS^DIQ(50,+PSSIEN,".01;62.01:62.05;905","IE","^TMP(""PSSP50"",$J)") S PSS(1)=0
 ..F  S PSS(1)=$O(^TMP("PSSP50",$J,50,PSS(1))) Q:'PSS(1)  D SETDRG^PSS50A1
 K ^TMP("DILIST",$J),^TMP("PSSP50",$J)
 Q
 ;
LOOP ;
 N PSS50DD1,PSS50DD2,PSS50DD3,PSS50DD4,PSS50ER1,PSS50ER2,PSS50ER3,PSS50ER4,PSS51NFD,PSS52NFD,PSSG2N,PSS501NX
 D FIELD^DID(50,51,"Z","POINTER","PSS50DD1","PSS50ER1") S PSS51NFD=$G(PSS50DD1("POINTER"))
 D FIELD^DID(50,52,"Z","POINTER","PSS50DD2","PSS50ER2") S PSS52NFD=$G(PSS50DD2("POINTER"))
 D FIELD^DID(50,301,"Z","POINTER","PSS50DD3","PSS50ER3") S PSSG2N=$G(PSS50DD3("POINTER"))
 D FIELD^DID(50.1,1,"Z","POINTER","PSS50DD4","PSS50ER4") S PSS501NX=$G(PSS50DD4("POINTER"))
 N PSSENCT
 S PSSENCT=0
 S PSS(1)=0 F  S PSS(1)=$O(^PSDRUG(PSS(1))) Q:'PSS(1)  D
 .I $P($G(^PSDRUG(PSS(1),0)),"^")="" Q
 .I $G(PSSFL),$P($G(^PSDRUG(PSS(1),"I")),"^"),$P($G(^("I")),"^")'>PSSFL Q
 .I $G(PSSRTOI)=1,'$P($G(^PSDRUG(PSS(1),2)),"^") Q
 .;Naked reference below refers to ^PSDRUG(PSS(1),2)
 .I $G(PSSPK)]"" N PSSZ5,PSSZ6 S PSSZ5=0 F PSSZ6=1:1:$L(PSSPK) Q:PSSZ5  I $P($G(^(2)),"^",3)[$E(PSSPK,PSSZ6) S PSSZ5=1
 .I $G(PSSPK)]"",'PSSZ5 Q
 .D SETSUB1^PSS50AQM(PSS(1)),SETSUB2^PSS50AQM(PSS(1)),SETSUB3^PSS50AQM(PSS(1))
 .D SETALL^PSS50AQM,SETOLD^PSS50AQM,SETSYN^PSS50AQM,SETFMA^PSS50AQM
 .S PSSENCT=PSSENCT+1
 S ^TMP($J,LIST,0)=$S($G(PSSENCT):$G(PSSENCT),1:"-1^NO DATA FOUND")
 Q