source: WorldVistAEHR/trunk/r/NATIONAL_DRUG_FILE-PSN/PSN50P65.m@ 701

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

initial load of WorldVistAEHR

File size: 4.1 KB
Line 
1PSN50P65 ;BIR/LDT - API FOR INFORMATION FROM FILE 50.605; 5 Sep 03
2 ;;4.0; NATIONAL DRUG FILE;**80**; 30 Oct 98
3 ;
4IEN(PSNIEN,PSNFT,LIST) ;
5 ;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
6 ;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
7 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
8 ; Field Number of the data piece beingreturned.
9 ;Returns CODE field (#.01), and CLASSIFICATION field (#1) of VA DRUG CLASS file (#50.605).
10 N DIERR,ZZERR,PSN50P65,PSN
11 I $G(LIST)']"" Q
12 K ^TMP($J,LIST)
13 I +$G(PSNIEN)'>0,($G(PSNFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
14 I $G(PSNIEN)]"",+$G(PSNIEN)'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
15 I $G(PSNIEN)]"" N PSNIEN2 S PSNIEN2=$$FIND1^DIC(50.605,"","B","`"_PSNIEN,,,"") D
16 .I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
17 .S ^TMP($J,LIST,0)=1
18 .D GETS^DIQ(50.605,+PSNIEN2,".01;1","IE","PSN50P65") S PSN(1)=0
19 .F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO
20 I $G(PSNIEN)="",$G(PSNFT)]"" D
21 .I PSNFT["??" D LOOP(1) Q
22 .D FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"B",,,"")
23 .I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
24 .I +^TMP("DILIST",$J,0)>0 S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0) N PSNXX S PSNXX=0 F S PSNXX=$O(^TMP("DILIST",$J,PSNXX)) Q:'PSNXX D
25 ..S PSNIEN=+^TMP("DILIST",$J,PSNXX,0) K PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1","IE","PSN50P65") S PSN(1)=0
26 ..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO
27 K ^TMP("DILIST",$J)
28 Q
29 ;
30ROOT(PSNC) ;
31 ;Q "^PS(50.605, ""C"")" if PSNC is passed in as 1. If PSNC is null, Q "^PS(50.605,"
32 I $G(PSNC)'=1 Q "^PS(50.605,"
33 Q "^PS(50.605,""C"")"
34 ;
35C(PSNIEN,PSNFT,LIST) ;
36 ;PSNIEN - IEN of entry in VA DRUG CLASS file (#50.605).
37 ;PSNFT - Free Text name in VA DRUG CLASS file (#50.605).
38 ;LIST - Subscript of ^TMP array in the form ^TMP($J,LIST,Field Number where Field Number is the
39 ; Field Number of the data piece being returned.
40 ;Returns CODE field (#.01), CLASSIFICATION field (#1),PARENT CLASS field (#2), and TYPE field (#3)
41 ;of VA DRUG CLASS file (#50.605).
42 N DIERR,ZZERR,PSN50P65,PSN
43 I $G(LIST)']"" Q
44 K ^TMP($J,LIST)
45 I +$G(PSNIEN)'>0,($G(PSNFT)']"") S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
46 I $G(PSNIEN)]"",+$G(PSNIEN)'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
47 I +$G(PSNIEN)>0 N PSNIEN2 S PSNIEN2=$$FIND1^DIC(50.605,"","A","`"_PSNIEN,"C",,"") D
48 .I +PSNIEN2'>0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
49 .S ^TMP($J,LIST,0)=1
50 .D GETS^DIQ(50.605,+PSNIEN2,".01;1;2;3","IE","PSN50P65") S PSN(1)=0
51 .F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO2
52 I $G(PSNIEN)="",$G(PSNFT)]"" D
53 .I PSNFT["??" D LOOP(2) Q
54 .D FIND^DIC(50.605,,"@;.01;1","QP",PSNFT,,"C",,,"")
55 .I +$G(^TMP("DILIST",$J,0))=0 S ^TMP($J,LIST,0)=-1_"^"_"NO DATA FOUND" Q
56 .I +^TMP("DILIST",$J,0)>0 S ^TMP($J,LIST,0)=+^TMP("DILIST",$J,0) N PSNXX S PSNXX=0 F S PSNXX=$O(^TMP("DILIST",$J,PSNXX)) Q:'PSNXX D
57 ..S PSNIEN=+^TMP("DILIST",$J,PSNXX,0) K PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65") S PSN(1)=0
58 ..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D SETZRO2
59 K ^TMP("DILIST",$J)
60 Q
61 ;
62SETZRO ;
63 S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P65(50.605,PSN(1),.01,"I"))
64 S ^TMP($J,LIST,"B",$G(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
65 S ^TMP($J,LIST,+PSN(1),1)=$G(PSN50P65(50.605,PSN(1),1,"I"))
66 Q
67 ;
68SETZRO2 ;
69 S ^TMP($J,LIST,+PSN(1),.01)=$G(PSN50P65(50.605,PSN(1),.01,"I"))
70 S ^TMP($J,LIST,"C",$G(PSN50P65(50.605,PSN(1),.01,"I")),+PSN(1))=""
71 S ^TMP($J,LIST,+PSN(1),1)=$G(PSN50P65(50.605,PSN(1),1,"I"))
72 S ^TMP($J,LIST,+PSN(1),2)=$S($G(PSN50P65(50.605,PSN(1),2,"I"))="":"",1:PSN50P65(50.605,PSN(1),2,"I")_"^"_PSN50P65(50.605,PSN(1),2,"E"))
73 S ^TMP($J,LIST,+PSN(1),3)=$S($G(PSN50P65(50.605,PSN(1),3,"I"))="":"",1:PSN50P65(50.605,PSN(1),3,"I")_"^"_PSN50P65(50.605,PSN(1),3,"E"))
74 Q
75 ;
76LOOP(PSN) ;
77 N PSNIEN,CNT S CNT=0
78 S PSNIEN=0 F S PSNIEN=$O(^PS(50.605,PSNIEN)) Q:'PSNIEN D
79 .K PSN50P65 D GETS^DIQ(50.605,+PSNIEN,".01;1;2;3","IE","PSN50P65") S PSN(1)=0 D
80 ..F S PSN(1)=$O(PSN50P65(50.605,PSN(1))) Q:'PSN(1) D @(PSN) S CNT=CNT+1
81 S ^TMP($J,LIST,0)=$S(+CNT>0:CNT,1:"-1^NO DATA FOUND")
82 Q
831 ;
84 D SETZRO
85 Q
86 ;
872 ;
88 D SETZRO2
89 Q
Note: See TracBrowser for help on using the repository browser.