source: WorldVistAEHR/trunk/r/PHARMACY_DATA_MANAGEMENT-PSS/PSSHL1.m@ 1042

Last change on this file since 1042 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 5.1 KB
Line 
1PSSHL1 ;BIR/RLW/WRT-BUILD HL7 MESSAGE TO POPULATE ORDERABLE ITEM FILE ;09/08/97
2 ;;1.0;PHARMACY DATA MANAGEMENT;**38,68,125**;9/30/97;Build 2
3 ;External reference to ORD(101 supported by DBIA 872
4 ; PSJEC=event code from HL7 table 8.4.2.1
5 ; PSJSPIEN=ien to super-primary drug file (#50.7)
6 ; SPDNAME=.01 field (name) of super-primary drug
7 ; LIMIT=number of fields in HL7 segment being built
8 ;
9 W !!?3,"This routine should not be accessed through programmer mode!",!
10 Q
11EN1 ; start here for pre-install auto load
12 N MENU,MENUP,ITEM
13 D PRO Q:$G(XPDABORT)
14 S PSSMFU=+$O(^PS(59.7,0)) I $P(^PS(59.7,PSSMFU,80),"^",2)=4 K PSSMFU Q
15 N APPL,CODE,FIELD,LIMIT,MFE,PSJI,SEGMENT,SPDNAME,SYN,SYNONYM,USAGE,X
16 I '$D(^XTMP("PSO_V7 INSTALL",0)) S X1=DT,X2=+7 D C^%DTC S ^XTMP("PSO_V7 INSTALL",0)=DT_"^"_X_"^OUTPATIENT V7 KIDS INSTALL" L +^XTMP("PSO_V7 INSTALL",0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) G SKIP
17 F Q:'$D(^XTMP("PSO_V7 INSTALL",0)) L +^XTMP("PSO_V7 INSTALL",0):$S($G(DILOCKTM)>0:DILOCKTM,1:3) Q:$T
18 I '$D(^XTMP("PSO_V7 INSTALL",0)) S X1=DT,X2=+7 D C^%DTC S ^XTMP("PSO_V7 INSTALL",0)=DT_"^"_X_"^OUTPATIENT V7 KIDS INSTALL" L +^XTMP("PSO_V7 INSTALL",0):$S($G(DILOCKTM)>0:DILOCKTM,1:3)
19 I $P(^PS(59.7,PSSMFU,80),"^",2)=4 L -^XTMP("PSO_V7 INSTALL",0) K ^XTMP("PSO_V7 INSTALL",0) Q
20SKIP ;
21 S PSJEC="MAD",CODE="REP"
22 D INIT
23 D LOOP,MF^PSSHLU(PSJI)
24 S PSLSITE=+$O(^PS(59.7,0)) S $P(^PS(59.7,PSLSITE,80),"^",2)=4 K PSLSITE
25 L -^XTMP("PSO_V7 INSTALL",0) K ^XTMP("PSO_V7 INSTALL",0)
26 K ^TMP("HLS",$J,"PS"),PSJEC,PSJSPIEN,PSJCLEAR,PSSMFU Q
27 ;
28EN2(PSJSPIEN,PSJEC) ; start here for "manual" update
29 S PSLSITE=+$O(^PS(59.7,0)) I +$P($G(^PS(59.7,PSLSITE,80)),"^",2)<4 K PSLSITE Q
30 ; passed in: internal entry # of super-primary drug, entry code
31 S:'$P($G(^PS(50.7,PSJSPIEN,0)),"^",4) PSJEC="MAC"
32 K PSLSITE N APPL,CODE,FIELD,PSJI,LIMIT,MFE,SEGMENT,SPDNAME,SYN,SYNONYM,USAGE,X,ZCOUNT,ZUSAGE
33 S CODE="UPD"
34 D INIT
35 D MFE(PSSIVID),MF^PSSHLU(PSJI)
36 K ^TMP("HLS",$J,"PS")
37 Q
38 ;
39 ;
40INIT ; initialize HL7 variables, set master file identification segment fields
41 S PSJI=0,LIMIT=6,HLMTN="MFN",PSSIVID=$$GTIVID()
42 D INIT^PSSHLU X PSJCLEAR
43 S FIELD(0)="MFI"
44 S FIELD(1)="50.7^PHARMACY ORDERABLE ITEM^99DD"
45 S FIELD(3)=CODE
46 S FIELD(6)="NE"
47 D SEGMENT^PSSHLU(LIMIT)
48 Q
49 ;
50LOOP ; loop through PHARMACY ORDERABLE ITEM file
51 ;F L +^PS(59.7,PSSIVID,31) Q:$T H 1
52 S PSJSPIEN=0 F S PSJSPIEN=$O(^PS(50.7,PSJSPIEN)) Q:'PSJSPIEN D MFE(PSSIVID)
53 ;L -^PS(59.7,PSSIVID,31)
54 Q
55 ;
56MFE(PSSIVID) ; set master file entry segment fields
57 ; Input: PSSIVID-IV Identifier
58 S LIMIT=4 X PSJCLEAR
59 S X=$G(^PS(50.7,PSJSPIEN,0))
60 S FIELD(0)="MFE"
61 S FIELD(1)=PSJEC
62 S FIELD(3)=$P($G(^PS(50.7,PSJSPIEN,0)),"^",4) I FIELD(3) S FIELD(3)=$$HLDATE^HLFNC(FIELD(3))
63 S FIELD(4)="^^^"_PSJSPIEN_"^"_$P(X,"^")_"~"_$P($G(^PS(50.606,$P(X,"^",2),0)),"^")_"~"_$S($P($G(^PS(50.7,PSJSPIEN,0)),"^",3):$G(PSSIVID),1:"")_"^99PSP"
64 D SEGMENT^PSSHLU(LIMIT)
65 D ZPS,ZSY
66 Q
67 ;
68ZPS ; get USAGE from dispense drug(s), set ZPS segment
69 S LIMIT=2 X PSJCLEAR
70 S FIELD(0)="ZPS"
71 S USAGE=$$USAGE^PSSHLU(PSJSPIEN)
72 Q:USAGE=""&('$P($G(^PS(50.7,PSJSPIEN,0)),"^",9))&('$P($G(^PS(50.7,PSJSPIEN,0)),"^",12))
73 F I="I","O","A","B","V" S:+$P(USAGE,I,2)>0 FIELD(1)=FIELD(1)_I
74 S:$P($G(^PS(50.7,PSJSPIEN,0)),"^",9) FIELD(1)=FIELD(1)_"S"
75 S:$P($G(^PS(50.7,PSJSPIEN,0)),"^",10) FIELD(1)=FIELD(1)_"N"
76 S:$P($G(^PS(50.7,PSJSPIEN,0)),"^",12) FIELD(2)=1
77 D SEGMENT^PSSHLU(LIMIT)
78 Q
79 ;
80ZSY ; get SYNONYMs
81 S LIMIT=2 X PSJCLEAR
82 S FIELD(0)="ZSY"
83 S SYNONYM="",(J,SYNIEN)=0 F S SYNIEN=$O(^PS(50.7,PSJSPIEN,2,SYNIEN)) Q:'SYNIEN S SYNONYM=$P($G(^(SYNIEN,0)),"^") Q:SYNONYM="" D
84 .S FIELD(1)="1",FIELD(2)=SYNONYM D SEGMENT^PSSHLU(LIMIT)
85 Q
86PRO ;Check for protocols
87 S MENU="PS MFSEND OR",ITEM="OR ITEM RECEIVE",MENUP=$O(^ORD(101,"B",MENU,0))
88 S X=$O(^ORD(101,"B",ITEM,0)) I 'X W !!?5,"Sorry, you need the OR ITEM RECEIVE protocol to proceed,",!?5,"which is exported with Order Entry/Results Reporting V3!",! S XPDABORT=1 Q
89 Q:$D(^ORD(101,MENUP,10,"B",X))
90 I $D(^ORD(101,MENUP,10,0))[0 S ^ORD(101,MENUP,10,0)="^"_"101.01PA"
91 K DD,DA,DO,DIC S DIC="^ORD(101,"_MENUP_",10,",DIC(0)="L",DLAYGO=101.01,DA(1)=MENUP D FILE^DICN K DD,DO
92 K DIC I Y<0 W !!?5,"Sorry, unable to add OR ITEM RECEIVE protocol as an Item to the PS MFSEND",!,"protocol, cannot proceed!",! S XPDABORT=1
93 Q
94ENIVID ; Edit IV Identifier field to be displayed with IV Orderable Items.
95 Q
96 N DA,DIC,DIE,DRG,PSSOI,PSSIVID,PSSFIL,PSSDRG,X,Y
97 S DIC=59.7,DIC(0)="AEMQ" D ^DIC Q:Y<0
98 W !!!,"Changing the IV Identifier will update the name of ALL Orderable Items",!,"marked as an IV!",!!
99 S PSSIVID=$P($G(^PS(59.7,+Y,31)),U,2),DIE=59.7,(DA,PSSSITE)=+Y,DR=32 D ^DIE
100 Q:PSSIVID=$P($G(^PS(59.7,PSSSITE,31)),U,2)
101 W !!,"Updating Orderable Item names in OE/RR"
102 F PSSOI=0:0 S PSSOI=$O(^PS(50.7,"AIV",1,PSSOI)) Q:'PSSOI D:$D(^PS(50.7,PSSOI)) EN2^PSSHL1(PSSOI,"MUP") W "."
103 ;F PSSFIL=52.6,52.7 F PSSOI=0:0 S PSSOI=$O(^PS(PSSFIL,"AOI",PSSOI)) Q:'PSSOI D:$D(^PS(50.7,PSSOI)) EN2^PSSHL1(PSSOI,"MUP") W "."
104 Q
105 ;
106GTIVID() ; Return IV Identifier. If being edited, wait until edit is done.
107 N X,PX S (X,PX)=$O(^PS(59.7,0)) Q:'X
108 F L +^PS(59.7,X,31):$S($G(DILOCKTM)>0:DILOCKTM,1:3) Q:$T H 2
109 S X=$P($G(^PS(59.7,X,31)),U,2)
110 L -^PS(59.7,PX,31)
111 Q X
Note: See TracBrowser for help on using the repository browser.