VistA-WorldVistAEHR/r/OUTPATIENT_PHARMACY-PSO-APS.../PSOHLSG5.m

29 lines
1.3 KiB
Mathematica

PSOHLSG5 ;BIR/SJA,PWC-Logical Links derive ;08/13/01 13:46
;;7.0;OUTPATIENT PHARMACY;**70,156**;DEC 1997
;Reference to ^SC( is supported by DBIA #10040
;Reference to ^DG(40.8 is supported by DBIA #1576
;Reference to ^HLCS(870 is supported by DBIA #1496
;
STRT N PSONODE,PSOLL,INPTRX,NN,PSOCOI,II,CLIN,PSOS,PSRX,PXIEN,PSODISP
S II=0 F S II=$O(^UTILITY($J,"PSOHLL",II)) Q:'II S PSONODE=$G(^(II)) D
.S PXIEN=$P(PSONODE,"^"),CLIN=$P($G(^PSRX(PXIEN,0)),"^",5)
.S PSODISP=$$GET1^DIQ(59,PSOSITE_",",105,"I")
.I CLIN D OI
.I 'CLIN!($G(PSOLL)="") D LL2
.I $G(PSOLL)="" S PSOLL="PSO LLP1"
.I $G(PSODISP)=2.4 S PSOLL="PSO DISP" ;dispensing machine using V.2.4
.S $P(^UTILITY($J,"PSOHLL",II),"^",11)=CLIN_"^"_PSOLL
Q
OI S PSOCOI="" S:'$D(^SC(CLIN,0)) CLIN=""
S INPTRX=0 I $G(CLIN) S PSOCOI=$P($G(^SC(CLIN,0)),"^",4)
I '$G(PSOCOI) D
.I $G(CLIN) S INPTRX=$P($G(^SC(CLIN,0)),"^",15)
.I '$G(INPTRX) S INPTRX=$O(^DG(40.8,0))
.I '$G(DT) S DT=$$DT^XLFDT
.S PSOCOI=+$$SITE^VASITE(DT,INPTRX)
LL1 S NN=0 F S NN=$O(^PS(59,PSOSITE,"INI1",NN)) Q:'NN!($G(PSOLL)) S PSOS=$G(^(NN,0)) I $P(PSOS,"^")=PSOCOI S PSOLL=$$GET1^DIQ(870,+$P(PSOS,"^",2),.01)
Q
LL2 ;Derive the LOCICAL LINK from the top level LL field.
S PSOLL=$P($G(^PS(59,PSOSITE,8)),"^",4),PSOLL=$$GET1^DIQ(870,+PSOLL,.01)
Q