source: WorldVistAEHR/trunk/r/ICR_IMMUNOLOGY_CASE_REGISTRY-IMR/IMRRX.m@ 846

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

initial load of WorldVistAEHR

File size: 3.6 KB
RevLine 
[613]1IMRRX ; HCIOFO-FAI/EXTRACT PHARMACY DATA FOR IMR REGISTRY ; 12/24/02 9:31am
2 ;;2.1;IMMUNOLOGY CASE REGISTRY;**3,8,5,15,18,19**;Feb 09, 1998
3 ;
4 ;***** EXTRACTS THE OUTPATIENT PHARMACY DATA
5 ;
6 ; IMRSD Start date
7 ; [IMRED] End date (unlimited by default)
8 ;
9GET(IMRSD,IMRED) ;
10 N IMRP,IMRR,NODE
11 S NODE=$NA(^PS(55,IMRDFN,"P")),IMRRX=0
12 S:$G(IMRED)'>0 IMRED=9999999
13 ;--- Get outpatient pharmacy data
14 S IMRP=IMRSD-1
15 F S IMRP=$O(@NODE@("A",IMRP)) Q:IMRP'>0 D
16 . S IMRR=0
17 . F S IMRR=$O(@NODE@("A",IMRP,IMRR)) Q:IMRR'>0 D RX^IMRUTL,OPT
18 ;--- Cleanup
19 K IMREXP,X,IMRX3,IMRDST,IMRX,IMRN,IMRRI,IMRNDF,IMRSTR,IMRRXD1,IMRRXDR,IMRPS,IMRRXD,IMRCL,IMRXX1,IMREF,IMRDST,IMRAR,IMRDSUP,IMRDU,IMRUCST,IMRQ
20 Q
21 ;
22 ;***** OUTPATIENT PHARMACY (RX SEGMENT)
23 ;
24 ; Uses the data loaded by the RX^IMRUTL (^TMP("PSOR",$J,...)
25 ;
26 ; piece 4=$S(0:original fill,1:1-n:refill number)
27 ; piece 5 (IMRRXD)=last dispensed date
28 ; piece 6 (IMRQ)=Quantity
29 ; piece 7 (IMRDSUP)=days supply
30 ; piece 8 (IMREF)=# of refills
31 ; piece 9 (IMRPS)=patient status
32 ; piece 10 (IMRCL)=clinic
33 ; piece 11 (IMRUCST)=unit price of drugs
34 ; piece 12 (IMRXSIG)=SIG
35 ; piece 13 (IMRNDF)=national drug file entry external format
36 ; piece 14 (IMRNFN)=National drug file entry internal format
37 ;
38OPT ;
39 N BUF,TMP
40 I 'IMRRXD1!('IMRXX1) Q ;quit if no issue date or drug
41 ;--- Quit if status is canceled or deleted
42 I IMRDST="CANCELLED"!(IMRDST="DELETED") Q
43 ;--- Quit if expiration is not greater than extract start date
44 I IMREXP,IMREXP'>IMRSD Q
45 ;--- Get internal name of national drug
46 S IMRNDF=$$NDF(IMRXX1,$S(+$G(IMRTRANS):"I",1:""))
47 ;--- Get external name of national drug
48 S IMRNFN=$$NDF(IMRXX1,$S(+$G(IMRTRANS):"E",1:""))
49 S IMRX3="RX^"_(IMRRXD1\1)_"^"_IMRRXDR ; RX^issue date^drug
50 ;--- If no last dispensed date, set last dispensed date =issue date
51 S:'IMRRXD IMRRXD=IMRRXD1
52 ;--- Use fill date if available
53 S:IMRFILDT IMRRXD=IMRFILDT
54 ;--- If no unit price of drugs, set it equal to price per
55 ;--- dispensed unit
56 S:'IMRUCST IMRUCST=IMRDU
57 ;--- If last dispensed date'<start date AND last dispensed date'>end
58 ;--- date, set message node.
59 I IMRRXD'<IMRSD,IMRRXD'>IMRED D
60 . S IMRC=IMRC+1
61 . S ^TMP($J,"IMRX",IMRC)=IMRX3_"^0^"_IMRRXD_"^"_IMRQ_"^"_IMRDSUP_"^"_IMREF_"^"_IMRPS_"^"_IMRCL_"^"_IMRUCST_"^^"_IMRNDF_"^"_IMRNFN
62 . S IMRC=IMRC+1,^TMP($J,"IMRX",IMRC)="RXS^"_IMRXSIG
63 . S IMRSEND=1 D LCHK^IMRDAT
64 . S:IMRRXD>IMRRX IMRRX=IMRRXD
65 ;--- Process the refills
66 S IMRN="",IMRRI=0
67 F S IMRN=$O(^TMP("PSOR",$J,IMRR,"REF",IMRN)) Q:IMRN="" D
68 . S BUF=$G(^TMP("PSOR",$J,IMRR,"REF",IMRN,0))
69 . S IMRRXD=$P(BUF,"^") ; Refill date
70 . Q:(IMRRXD'>IMRSD)!(IMRRXD>IMRED)
71 . S IMRUCST=$P(BUF,"^",6) ; Current unit price of drug
72 . ;--- If no current unit price, set IMRUCST=price per dispensed unit
73 . S:'IMRUCST IMRUCST=IMRDU
74 . ;--- Add RX and RXS segments
75 . S IMRRI=IMRRI+1,IMRC=IMRC+1
76 . S ^TMP($J,"IMRX",IMRC)=IMRX3_"^"_IMRRI_"^"_IMRRXD_"^"_$P(BUF,"^",4)_"^"_$P(BUF,"^",5)_"^^^^"_IMRUCST_"^^"_IMRNDF_"^"_IMRNFN
77 . S IMRC=IMRC+1,^TMP($J,"IMRX",IMRC)="RXS^"_IMRXSIG
78 . S IMRSEND=1 D LCHK^IMRDAT
79 . S:IMRRXD>IMRRX IMRRX=IMRRXD
80 Q
81 ;
82NDF(IMRDRG0,IMRFLG) ; Input: PSDRUG IEN, and either "I" or "E" or NULL for
83 ; Internal or External data format. A Null,"", will
84 ; return the external format.
85 ; RETURN: NDF IEN for Internal or NDF name for External.
86 S IMRDRG1=""
87 I $T(^PSNAPIS)]"","E"[IMRFLG,IMRDRG0,$P($G(^PSDRUG(IMRDRG0,"ND")),"^") S IMRDRG1=$$VAGN^PSNAPIS($P($G(^PSDRUG(IMRDRG0,"ND")),"^")) G EXIT ;use api if available
88 G:'IMRDRG0 EXIT
89 I IMRFLG="I" S IMRDRG1=$$GET1^DIQ(50,IMRDRG0,20,IMRFLG) ;File 50=DRUG file (^PSDRUG), field #20 is national drug file entry (pointer)
90EXIT Q IMRDRG1
Note: See TracBrowser for help on using the repository browser.