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

PSSCPRS.m

Go to the documentation of this file.
PSSCPRS ;BIR/ASJ-API for CPRS ;09/07/00
 ;;1.0;PHARMACY DATA MANAGEMENT;**38**;9/30/97
 ;Reference to $$CPRS^PSNAPIS supported by DBIA 2531
 ;
 ; PSDD -Dispense Drug, PSOI-Orderable Item, PSPK-Package
 ; PSDOS-Dosage,        PSDUD-Dispense Units per Dosage
 ;RESULT(1)=Dispense Drug^Dosage^Orderable Item^Dispense Units per Dosage
 ;RESULT(2)=ERROR DESCRIPTION
CPRS(PSSAR) ;
 N AA,BB,FLAG,PDOS,PDS,POSDOS,PSCORR,PSDOS1,PSDPD,PSDUPD,PSLI,PSMARK,PSND,PSNDSTR,PSNDUN,PSNODE2,PSOD,PSSND1,PSSND3,PSSNDF,PSSOP,PSSTR,PSUNT,PSNODE,PSUSE,PSDD,PSOI,PSDOS,PSDUD,PSPK,PSNODE8,X
 K RESULTS S RESULT(0)=-1,(FLAG,PSMARK)=0,U="^"
 S PSDD=$G(PSSAR("DRUG")),PSOI=$G(PSSAR("ITEM")),PSPK=$G(PSSAR("PACK"))
 S PSDOS=$G(PSSAR("DOSAGE")),PSDUD=$G(PSSAR("DUPD"))
 I 'PSDD!('PSOI) Q
 S PSNODE=$G(^PSDRUG(+PSDD,0)),PSUSE=$P($G(^(2)),U,3),PSNODE8=$G(^(8))
 S PSSNDF=$G(^PSDRUG(+PSDD,"ND")),PSSND1=$P(PSSNDF,U),PSSND3=$P(PSSNDF,U,3)
 G:PSPK="I" ^PSSCPRS1 G:+PSDUD>0 ND
 I 'PSSND1!('PSSND3) S RESULT(0)=-1,RESULT(2)="Problem in ND node!" Q
 S X=$$DFSU^PSNAPIS(PSSND1,PSSND3) I $P(X,U,4)="" D NNSI Q
 I $P(X,U)'="" D NNMI
 Q
ND ; O/P to I/P Transfer Rules - Numeric Dosages
 ; 
FR571 I '$P($G(^PSDRUG(+PSDD,"I")),"^")!($P($G(^("I")),"^")'<DT),(PSUSE["U") S RESULT(0)=1,RESULT(1)=PSDD_"^"_PSDOS,RESULT(2)="FR571" Q
 ;
FR572 S PSCORR=$P(PSNODE8,U,6) I PSCORR I '$P($G(^PSDRUG(PSCORR,"I")),"^")!($P($G(^("I")),"^")'<DT) S PSNODE2=$G(^PSDRUG(PSCORR,2)) D CP D
 .F PDS=0:0 S PDS=$O(^PSDRUG(PSCORR,"DOS1",PDS)) Q:'PDS  D
 ..S PSDOS1=^PSDRUG(PSCORR,"DOS1",PDS,0)
 ..I PSDOS'="",$P(PSDOS1,U,2)=PSDOS,($P(PSNODE2,U,3)["U")&($P(PSDOS1,U,3)["I") D
 ...I $P(X,U,4)=$P(PSDOSN,U,2),$P(X1,U)=$P(X,U) S RESULT(0)=1,RESULT(1)=PSCORR_"^"_PSDOS,RESULT(2)="FR572" Q
 Q:RESULT(0)=1
 ;
FR573 S AA=0 F  S AA=$O(^PSDRUG("ASP",+PSOI,AA)) Q:'AA  D
 .I $D(^PSDRUG(AA,"DOS1",0)) F PDS=0:0 S PDS=$O(^PSDRUG(AA,"DOS1",PDS)) Q:'PDS  D
 ..S BB=^PSDRUG(AA,"DOS1",PDS,0),PSNODE2=$G(^PSDRUG(AA,2))
 ..I PSDOS'="",$P(BB,U,2)=PSDOS,($P(PSNODE2,U,3)["U")&($P(BB,U,3)["I") S FLAG=1,PSLI(AA)=""
 ;
 I FLAG S AA=0 F  S AA=$O(PSLI(AA)) Q:'AA  F PDS=0:0 S PDS=$O(^PSDRUG(AA,"DOS1",PDS)) Q:'PDS  D
 .S POSDOS=^PSDRUG(AA,"DOS1",PDS,0) S PSDPD=+$P(POSDOS,U)
 .I '$D(PSDUPD)!(PSDPD<PSDUPD) S PSDUPD=PSDPD
 I FLAG S RESULT(0)=1,RESULT(1)=AA_"^"_$P(POSDOS,U,2),RESULT(2)="FR573",FLAG=0 Q
 ;
FR574 S PSCORR=$P(PSNODE8,U,6) I PSCORR I '$P($G(^PSDRUG(PSCORR,"I")),"^")!($P($G(^("I")),"^")'<DT) D CP D
 .I $P(X,U,4)=$P(PSDOSN,U,2),$P(X1,U)=$P(X,U) S RESULT(0)=1,RESULT(1)=PSDD,RESULT(2)="FR574"
 Q:RESULT(0)=1
 ;
FR575 S RESULT(0)=-1,RESULT(2)="All Numeric Dosage Rules failed!"
 Q
 ;
NNSI ; O/P to I/P Transfer Rules- NON-NUMERIC Single Ingredient 
FR581 I '$P($G(^PSDRUG(+PSDD,"I")),"^")!($P($G(^("I")),"^")'<DT),(PSUSE["U")&(PSUSE["O") S RESULT(0)=1,RESULT(1)=PSDD_"^"_PSDOS_"^"_PSOI_"^"_PSDUD,RESULT(2)="FR581" Q
 ;
FR582 I (PSUSE'["U")&(PSUSE'["O") S PSCORR=$P(PSNODE8,U,6) I PSCORR I '$P($G(^PSDRUG(PSCORR,"I")),"^")!($P($G(^("I")),"^")'<DT) D CP D  Q:RESULT(0)=1
 .S PDOS=$G(^PSDRUG(PSCORR,"DOS")),PSSTR=$P(PDOS,U),PSUNT=$P(PDOS,U,2)
 .I (PSSTR'="")&(PSUNT'=""),(PSSTR=PSNDSTR&(PSUNT=PSNDUN)) D
 ..I $P(X,U,4)=$P(PSDOSN,U,2),$P(X1,U)=$P(X,U) S RESULT(0)=1,RESULT(1)=PSCORR_"^"_PSDOS_"^"_PSOI_"^"_PSDUD,RESULT(2)="FR582"
 ;
FR583 S AA=0 F  S AA=$O(^PSDRUG("ASP",+PSOI,AA)) Q:'AA  D
 .S PSSTR=$P($G(^PSDRUG(AA,"DOS")),U),PSUNT=$P($G(^("DOS")),U,2)
 .S X=$$CPRS^PSNAPIS(PSSND1,PSSND3) S PSNDSTR=$P(X,U,3),PSNDUN=$P(X,U,4)
 .I (PSSTR'="")&(PSUNT'=""),(PSSTR=PSNDSTR)&(PSUNT=PSNDUN) S RESULT(0)=1,RESULT(1)=AA_"^"_PSDOS_"^"_PSOI_"^"_PSDUD,RESULT(2)="FR583"
 Q:RESULT(0)=1
FR584 S RESULT(0)=-1
 Q
 ;
NNMI ; O/P to I/P Transfer Rules- Multi-Ingredient
 ;
FR591 I '$P($G(^PSDRUG(+PSDD,"I")),"^")!($P($G(^("I")),"^")'<DT),(PSUSE["U")&(PSUSE["O") S RESULT(0)=1,RESULT(1)=PSDD_"^"_PSDOS_"^"_PSOI_"^"_PSDUD,RESULT(2)="FR591" Q
 ;
FR592 I (PSUSE'["U")&(PSUSE'["O") S PSCORR=$P(PSNODE8,U,6) I PSCORR I '$P($G(^PSDRUG(PSCORR,"I")),"^")!($P($G(^("I")),"^")'<DT) D CP D
 .I $P(X,U,4)=$P(PSDOSN,U,2),$P(X1,U)=$P(X,U) S RESULT(0)=1,RESULT(1)=PSCORR_"^"_PSOD_"^"_PSSOP_"^"_PSDUD,RESULT(2)="FR592"
 Q
 ;
CP S PSND=$G(^PSDRUG(PSCORR,"ND")) S X=$$CPRS^PSNAPIS($P(PSND,"^"),$P(PSND,"^",3)),PSNDSTR=$P(X,U,3),PSNDUN=$P(X,U,4)
 S PSDOSN=$G(^PSDRUG(PSDD,"DOS")),X1=$$CPRS^PSNAPIS(PSSND1,PSSND3)
 Q