PSS781 ;BHM/DB - API FOR PHARMACY PATIENT FILE ; 15 JUN 05
;;1.0;PHARMACY DATA MANAGEMENT;**106**;9/30/97
PSS(PSSDFN,PSSNUM,LIST) ;
;PSSDFN: IEN of Patient [REQUIRED]
;PSSNUM: CLOZAPINE REGISTRATION NUMBER
;LIST: Subscript name used in ^TMP global [REQUIRED]
I $G(LIST)="" Q
K ^TMP($J,LIST) N PSSIEN,DA,DR,DIC
I $G(PSSDFN)'>0,$G(PSSNUM)="" S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
I $G(PSSNUM)'="",$G(PSSDFN)'>0 S PSSDFN=$O(^PS(55,"ASAND1",PSSNUM,0)) I $G(PSSDFN)'>0 G NODATA
S PSSIEN=$G(PSSDFN) K ^UTILITY("DIQ1",$J),DIQ
S (DA,IEN)=PSSDFN,DIC=55,DR="53:58",DIQ(0)="IE" D EN^DIQ1 I '$D(^UTILITY("DIQ1",$J)) G NODATA
F PSSIEN=53:1:58 S ^TMP($J,LIST,PSSDFN,PSSIEN)=$G(^UTILITY("DIQ1",$J,55,IEN,PSSIEN,"I"))
F PSSIEN=54,55,56,57,58 S ^TMP($J,LIST,PSSDFN,PSSIEN)=$S($G(^UTILITY("DIQ1",$J,55,IEN,PSSIEN,"I"))=$G(^UTILITY("DIQ1",$J,55,IEN,PSSIEN,"E")):"",1:^TMP($J,LIST,PSSDFN,PSSIEN))_"^"_$G(^UTILITY("DIQ1",$J,55,IEN,PSSIEN,"E"))
F X=53:1:58 I $G(^TMP($J,LIST,PSSDFN,X))="^" S ^TMP($J,LIST,PSSDFN,X)=""
K ^UTILITY("DIQ1",$J),DIQ,DIC,DA Q
NODATA S ^TMP($J,LIST,0)="-1^NO DATA FOUND"
Q Q
WRT(PSSDFN,PSSSTAT,LIST) ;Sets Clozapine Status field for Mental Health
;PSSDFN = DFN of Patient (REQUIRED)
;PSSSTAT = Clozapine Status (REQUIRED)
;LIST: Subscript name used in ^TMP global [REQUIRED]
I $G(PSSDFN)'>0 Q
I $G(PSSSTAT)="" Q
I $G(LIST)="" Q
I '$D(^PS(55,PSSDFN)) S ^TMP($J,LIST,0)=0 Q
I $G(PSSSTAT)'="D",$G(PSSSTAT)'="H",$G(PSSSTAT)'="A" S ^TMP($J,LIST,0)=0 Q
S $P(^PS(55,PSSDFN,"SAND"),"^",2)=PSSSTAT,^TMP($J,LIST,0)=1 Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPSS781 1569 printed Dec 13, 2024@02:30:21 Page 2
PSS781 ;BHM/DB - API FOR PHARMACY PATIENT FILE ; 15 JUN 05
+1 ;;1.0;PHARMACY DATA MANAGEMENT;**106**;9/30/97
PSS(PSSDFN,PSSNUM,LIST) ;
+1 ;PSSDFN: IEN of Patient [REQUIRED]
+2 ;PSSNUM: CLOZAPINE REGISTRATION NUMBER
+3 ;LIST: Subscript name used in ^TMP global [REQUIRED]
+4 IF $GET(LIST)=""
QUIT
+5 KILL ^TMP($JOB,LIST)
NEW PSSIEN,DA,DR,DIC
+6 IF $GET(PSSDFN)'>0
IF $GET(PSSNUM)=""
SET ^TMP($JOB,LIST,0)=-1_"^"_"NO DATA FOUND"
QUIT
+7 IF $GET(PSSNUM)'=""
IF $GET(PSSDFN)'>0
SET PSSDFN=$ORDER(^PS(55,"ASAND1",PSSNUM,0))
IF $GET(PSSDFN)'>0
GOTO NODATA
+8 SET PSSIEN=$GET(PSSDFN)
KILL ^UTILITY("DIQ1",$JOB),DIQ
+9 SET (DA,IEN)=PSSDFN
SET DIC=55
SET DR="53:58"
SET DIQ(0)="IE"
DO EN^DIQ1
IF '$DATA(^UTILITY("DIQ1",$JOB))
GOTO NODATA
+10 FOR PSSIEN=53:1:58
SET ^TMP($JOB,LIST,PSSDFN,PSSIEN)=$GET(^UTILITY("DIQ1",$JOB,55,IEN,PSSIEN,"I"))
+11 FOR PSSIEN=54,55,56,57,58
SET ^TMP($JOB,LIST,PSSDFN,PSSIEN)=$SELECT($GET(^UTILITY("DIQ1",$JOB,55,IEN,PSSIEN,"I"))=$GET(^UTILITY("DIQ1",$JOB,55,IEN,PSSIEN,"E")):"",1:^TMP($JOB,LIST,PSSDFN,PSSIEN))_"^"_$GET(^UTILITY("DIQ1",$JOB,55,IEN,PSSIEN,"E"))
+12 FOR X=53:1:58
IF $GET(^TMP($JOB,LIST,PSSDFN,X))="^"
SET ^TMP($JOB,LIST,PSSDFN,X)=""
+13 KILL ^UTILITY("DIQ1",$JOB),DIQ,DIC,DA
QUIT
NODATA SET ^TMP($JOB,LIST,0)="-1^NO DATA FOUND"
Q QUIT
WRT(PSSDFN,PSSSTAT,LIST) ;Sets Clozapine Status field for Mental Health
+1 ;PSSDFN = DFN of Patient (REQUIRED)
+2 ;PSSSTAT = Clozapine Status (REQUIRED)
+3 ;LIST: Subscript name used in ^TMP global [REQUIRED]
+4 IF $GET(PSSDFN)'>0
QUIT
+5 IF $GET(PSSSTAT)=""
QUIT
+6 IF $GET(LIST)=""
QUIT
+7 IF '$DATA(^PS(55,PSSDFN))
SET ^TMP($JOB,LIST,0)=0
QUIT
+8 IF $GET(PSSSTAT)'="D"
IF $GET(PSSSTAT)'="H"
IF $GET(PSSSTAT)'="A"
SET ^TMP($JOB,LIST,0)=0
QUIT
+9 SET $PIECE(^PS(55,PSSDFN,"SAND"),"^",2)=PSSSTAT
SET ^TMP($JOB,LIST,0)=1
QUIT