source: WorldVistAEHR/trunk/r/INPATIENT_MEDICATIONS-PSJ-PSIV-PSG--PSGW/PSJ0050.m@ 623

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

initial load of WorldVistAEHR

File size: 2.4 KB
Line 
1PSJ0050 ;BIR/JLC - BCMA MED LOG CONVERSION FOR PSJ*5*50;02 May 2001
2 ;;5.0; INPATIENT MEDICATIONS ;**50**;16 DEC 97
3 ;
4 ; Reference to ^PSB(53.79 is supported by DBIA# 3370.
5 ; Reference to ^PSDRUG is supported by DBIA# 2192.
6 ; Reference to ^PS(51.2 is supported by DBIA# 2178.
7 ;
8 Q
9EN(PSJDFN,PSJORD,PSJCURR,PSJNEW) ;;
10 N S1,S2,ND0,ND1,DA,DR,DIE
11 I '$D(^PSB(53.79,"AOIP",PSJDFN,PSJCURR)) Q ;no administration entries for this orderable item for the specified patient
12 S S1=""
13 F S S1=$O(^PSB(53.79,"AOIP",PSJDFN,PSJCURR,S1)) Q:S1="" D
14 . S S2=""
15 . F S S2=$O(^PSB(53.79,"AOIP",PSJDFN,PSJCURR,S1,S2)) Q:S2="" D
16 . . S ND0=^PSB(53.79,S2,0),ND1=^(.1)
17 . . I +$P(ND1,"^")'=+PSJORD Q ;not the same order number
18 . . I +$P(ND0,"^",8)'=+PSJCURR Q ;not the orderable item we were expecting
19 . . S DIE="^PSB(53.79,",DA=S2,DR=".08////"_PSJNEW D ^DIE
20 Q
21 ;
22ENIVUD ;Conversion of Pending orders to set UD/IV PROMPT field in 53.1
23 N PSJORD,PSJOTYP,PSJCOI,PSJPDFN,PSJOI,PSJDD,PSJMR,PSJTYP
24 S PSJPDFN=0 F S PSJPDFN=$O(^PS(53.1,"AS","P",PSJPDFN)) Q:'PSJPDFN S PSJORD=0 F S PSJORD=$O(^PS(53.1,"AS","P",PSJPDFN,PSJORD)) Q:'PSJORD D
25 .S PSJOI=+$G(^PS(53.1,PSJORD,.2)),PSJDD=+$G(^PS(53.1,PSJORD,1,1,0)),PSJMR=$P($G(^PS(53.1,PSJORD,0)),U,3),PSJTYP=$P($G(^(0)),U,4) Q:PSJTYP="F"
26 .S:PSJDD>0 PSJPRO=$$ORTYP(PSJMR,PSJDD) S:PSJDD=0 PSJPRO=$$TRYAGAIN(PSJMR,PSJOI)
27 .S $P(^PS(53.1,PSJORD,0),U,13)=PSJPRO
28 Q
29ORTYP(MDRT,DDRG) ;Entry point to determine order type for 53.1
30 ;MDRT=Med Route from 51.2, DDRG=Dispense Drug
31 Q:'+MDRT Q:'+DDRG
32 S ORTYP=""
33 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PSDRUG(DDRG,2),"^",3)'["U" S ORTYP="" Q ORTYP
34 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP="" Q ORTYP
35 I $P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP=1 Q ORTYP
36 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PS(51.2,MDRT,0),"^",6)=1 S ORTYP=1 Q ORTYP
37 I $P(^PSDRUG(DDRG,2),"^",3)["I",$P(^PSDRUG(DDRG,2),"^",3)'["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP=1 Q ORTYP
38 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PSDRUG(DDRG,2),"^",3)'["I",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP="" Q ORTYP
39 I $P(^PSDRUG(DDRG,2),"^",3)["U",$P(^PS(51.2,MDRT,0),"^",6)'=1 S ORTYP=1 Q ORTYP
40 S ORTYP="" Q ORTYP
41 ;
42TRYAGAIN(MDRT,OI) ;
43 ;MDRT=Med Route from 51.2, OI=Orderable Item
44 Q:'+MDRT Q:'+OI
45 S ORTYP=""
46 N DDRG S DDRG=0 F S DDRG=$O(^PSDRUG("ASP",OI,DDRG)) Q:'DDRG S ORTYP=$$ORTYP(MDRT,DDRG) Q:ORTYP]""
47 Q ORTYP
Note: See TracBrowser for help on using the repository browser.