source: WorldVistAEHR/trunk/r/PHARMACY_DATA_MANAGEMENT-PSS/PSSUTIL.m@ 1111

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

initial load of WorldVistAEHR

File size: 8.6 KB
Line 
1PSSUTIL ;BIR/RTR-utility routine for NDF changes ;04/04/00
2 ;;1.0;PHARMACY DATA MANAGEMENT;**34,38**;9/30/97
3 ;Reference to ^PS(50.607 supported by DBIA 2221
4 ;
5EN(PSSDIEN) ;Recieve Drug entries unmatched as a result of NDF changes
6 ;Not called, NDF deletes the possible and local possible dosages
7 Q
8EN1(PSSDIEN,PSSTALK) ;Receive Drug entries that have been unmatched
9 N PSSLD,PSSLOCV
10 S PSSLOCV=$O(^PS(59.7,0))
11 ;I $P($G(^PS(59.7,+$G(PSSLOCV),80)),"^",3)<2 Q
12 W !!,"Deleting Possible Dosages.."
13 K ^PSDRUG(PSSDIEN,"DOS"),^PSDRUG(PSSDIEN,"DOS1")
14 H 1 W "."
15 I '$G(PSSTALK) K ^PSDRUG(PSSDIEN,"DOS2") G EQ
16 I '$O(^PSDRUG(PSSDIEN,"DOS2",0)) W !
17 I $O(^PSDRUG(PSSDIEN,"DOS2",0)) D W ! K DIR S DIR(0)="Y",DIR("B")="Y",DIR("A")="Delete these Local Possible Dosages" D ^DIR K DIR I Y=1 W !!,"Deleting Local Possible Dosages.." K ^PSDRUG(PSSDIEN,"DOS2") H 1 W "." W ! G EQ
18 .W !!,"LOCAL POSSIBLE DOSAGES:"
19 .W ! F PSSLD=0:0 S PSSLD=$O(^PSDRUG(PSSDIEN,"DOS2",PSSLD)) Q:'PSSLD D
20 ..W !,$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLD,0)),"^")_" "_$S($P($G(^(0)),"^",2)="":"(No package)",1:"(Package -> "_$P($G(^(0)),"^",2)_")")
21 I $O(^PSDRUG(PSSDIEN,"DOS2",0)) W !!,"Local Possible Dosages not deleted.",!
22EQ Q
23EN2(PSSDIEN,PSSTALK) ;Receive Drug entries matched to NDF
24 ;Do we need entry point on an Orderable Item match (not matched to NDF)
25 Q:'$D(^PSDRUG(PSSDIEN,0))
26 K ^PSDRUG(PSSDIEN,"DOS"),^PSDRUG(PSSDIEN,"DOS1")
27 N PSSLOC,PSSO,PSSI,PSSND,PSSND1,PSSBOTH,PSSONLYI,PSSONLYO,PSSNODE,PSSDF,PSSST,PSSUN,PSSTOT,PSSTOTX,PSSDUPD,PSSTODOS,PSSFLAG
28 S PSSLOC=$O(^PS(59.7,0))
29 ;I $P($G(^PS(59.7,+$G(PSSLOC),80)),"^",3)<3 Q
30 I $G(PSSTALK) W !!,"Resetting Possible Dosages..",! K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
31 S PSSBOTH=1
32 S (PSSONLYI,PSSONLYO,PSSFLAG)=0
33 S PSSND=$P($G(^PSDRUG(PSSDIEN,"ND")),"^",3),PSSND1=$P($G(^("ND")),"^") I 'PSSND!('PSSND1) G LOC
34 S PSSNODE=$$DFSU^PSNAPIS(PSSND1,PSSND) S PSSDF=$P(PSSNODE,"^"),PSSST=$P(PSSNODE,"^",4),PSSUN=$P(PSSNODE,"^",5)
35 I 'PSSDF!('PSSUN)!($G(PSSST)="") G LOC
36 I '$D(^PS(50.606,PSSDF,0))!('$D(^PS(50.607,PSSUN,0))) G LOC
37 I PSSST'?.N&(PSSST'?.N1".".N) G LOC
38 S (PSSI,PSSO)=0
39 I $D(^PS(50.606,"ACONI",PSSDF,PSSUN)),$O(^PS(50.606,"ADUPI",PSSDF,0)) S PSSI=1
40 I $D(^PS(50.606,"ACONO",PSSDF,PSSUN)),$O(^PS(50.606,"ADUPO",PSSDF,0)) S PSSO=1
41 I 'PSSO,'PSSI G LOC
42 I PSSI,'PSSO D S:PSSTOT>1 PSSTOTX=PSSTOT-1,^PSDRUG(PSSDIEN,"DOS")=PSSST_"^"_PSSUN,PSSONLYO=1,PSSBOTH=0,^PSDRUG(PSSDIEN,"DOS1",0)="^50.0903^"_$G(PSSTOTX)_"^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):"IO",1:"I") S ^PSDRUG(PSSDIEN,"DOS1","B",PSSDUPD,PSSTOT)="" S PSSTOT=PSSTOT+1
54 I PSSO,PSSI D S:PSSTOT>1 PSSTOTX=PSSTOT-1,PSSFLAG=1,^PSDRUG(PSSDIEN,"DOS")=PSSST_"^"_PSSUN,^PSDRUG(PSSDIEN,"DOS1",0)="^50.0903^"_$G(PSSTOTX)_"^"_$G(PSSTOTX)
55 .F PSSDUPD=0:0 S PSSDUPD=$O(^PS(50.606,"ADUPO",PSSDF,PSSDUPD)) Q:'PSSDUPD D
56 ..I $D(^PS(50.606,"ADUPI",PSSDF,PSSDUPD)) Q
57 ..S PSSTODOS=PSSDUPD*PSSST
58 ..S ^PSDRUG(PSSDIEN,"DOS1",PSSTOT,0)=PSSDUPD_"^"_PSSTODOS_"^O",^PSDRUG(PSSDIEN,"DOS1","B",PSSDUPD,PSSTOT)="" S PSSTOT=PSSTOT+1
59 Q
60LOC ;Set local possible dosages
61 N PSSOITEM,PSSOID,PSSLTOT,PSSLTOTX,PSDUPDPT,PSNOUN,PSNOUNPA,PSNOUNPT,PSALL,PSDOD,PSSLPT,PSSLPTX,PSSLPNO,PSSLP,PSSNL,PSSNLF,PSSNLX
62 S PSSOITEM=$P($G(^PSDRUG(PSSDIEN,2)),"^") Q:'PSSOITEM
63 S PSSOID=$P($G(^PS(50.7,PSSOITEM,0)),"^",2) Q:'PSSOID
64 Q:'$O(^PS(50.606,PSSOID,"NOUN",0))
65 I $O(^PSDRUG(PSSDIEN,"DOS2",0)) G LOCMRG
66 I '$G(PSSTALK) G QUIET
67 W ! K DIR S DIR("A")="This drug has no Local Possible Dosages, do you want to create them",DIR("B")="Y",DIR(0)="Y"
68 S DIR("?")=" ",DIR("?",1)="If you answer 'YES', Local Possible Dosages will be created for this drug using",DIR("?",2)="nouns associated with the "_$P($G(^PS(50.606,+$G(PSSOID),0)),"^")_" Dosage Form."
69 D ^DIR K DIR I Y'=1 Q
70 W !!,"Setting Local Possible Dosages..",!
71 K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
72QUIET ;
73 I $O(^PS(50.606,PSSOID,"DUPD",0)) D S:PSSLTOT>1 PSSLTOTX=PSSLTOT-1,^PSDRUG(PSSDIEN,"DOS2",0)="^50.0904^"_$G(PSSLTOTX)_"^"_$G(PSSLTOTX) Q
74 .S PSSLTOT=1
75 .F PSNOUN=0:0 S PSNOUN=$O(^PS(50.606,PSSOID,"NOUN",PSNOUN)) Q:'PSNOUN S PSNOUNPT=$P($G(^(PSNOUN,0)),"^"),PSNOUNPA=$P($G(^(0)),"^",2) D:PSNOUNPT'=""
76 ..Q:PSNOUNPA=""
77 ..F PSDOD=0:0 S PSDOD=$O(^PS(50.606,PSSOID,"DUPD",PSDOD)) Q:'PSDOD S PSDUPDPT=$P($G(^(PSDOD,0)),"^") D:PSDUPDPT'=""
78 ...I $G(PSSONLYO),PSNOUNPA'["O" Q
79 ...I $G(PSSONLYI),PSNOUNPA'["I" Q
80 ...D TEST^PSSDOSCR
81 ...S PSALL=$G(PSDUPDPT)_" "_$S($G(PSSNLF):$G(PSSNLX),1:$G(PSNOUNPT)) K PSSNL,PSSNLF,PSSNLX
82 ...S ^PSDRUG(PSSDIEN,"DOS2",PSSLTOT,0)=$G(PSALL)_"^"_$G(PSNOUNPA),^PSDRUG(PSSDIEN,"DOS2","B",$E(PSALL,1,30),PSSLTOT)="" S PSSLTOT=PSSLTOT+1
83 S PSSLTOT=1 F PSNOUN=0:0 S PSNOUN=$O(^PS(50.606,PSSOID,"NOUN",PSNOUN)) Q:'PSNOUN S PSNOUNPT=$P($G(^(PSNOUN,0)),"^"),PSNOUNPA=$P($G(^(0)),"^",2) D:PSNOUNPT'=""
84 .Q:PSNOUNPA=""
85 .I $G(PSSONLYI),PSNOUNPA'["I" Q
86 .I $G(PSSONLYO),PSNOUNPA'["O" Q
87 .S ^PSDRUG(PSSDIEN,"DOS2",PSSLTOT,0)=PSNOUNPT_"^"_$G(PSNOUNPA),^PSDRUG(PSSDIEN,"DOS2","B",$E(PSNOUNPT,1,30),PSSLTOT)="" S PSSLTOT=PSSLTOT+1
88 I PSSLTOT>1 S PSSLTOTX=PSSLTOT-1 S ^PSDRUG(PSSDIEN,"DOS2",0)="^50.0904^"_$G(PSSLTOTX)_"^"_$G(PSSLTOTX)
89 Q
90LOCMRG ;Merge new Local Possible Dosages with existing ones
91 N PSSLIEN,PSSLIENX
92 I '$G(PSSTALK) G QUIET1
93 W !!,"This drug has the following Local Possible Dosages:",!
94 F PSSLIEN=0:0 S PSSLIEN=$O(^PSDRUG(PSSDIEN,"DOS2",PSSLIEN)) Q:'PSSLIEN D
95 .S PSSLIENX=$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLIEN,0)),"^")
96 .I $L(PSSLIENX)'>53 W !,PSSLIENX,?55,"PACKAGE: ",$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLIEN,0)),"^",2) Q
97 .W !,PSSLIENX,!,?55,"PACKAGE: ",$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLIEN,0)),"^",2)
98 W ! K DIR S DIR(0)="Y",DIR("B")="Y",DIR("A")="Do you want to merge new Local Possible Dosages"
99 S DIR("?")=" ",DIR("?",1)="If you answer 'YES', any new Local Possible Dosages found based on the nouns",DIR("?",2)="associated with the "_$P($G(^PS(50.606,+$G(PSSOID),0)),"^")_" Dosage Form"
100 S DIR("?",3)="will be added to you current Local Possible Dosages."
101 D ^DIR K DIR I Y'=1 Q
102 W !!,"Setting Local Possible Dosages..",!
103 K DIR S DIR(0)="E",DIR("A")="Press Return to continue" D ^DIR K DIR
104QUIET1 ;
105 I $O(^PS(50.606,PSSOID,"DUPD",0)) D Q
106 .F PSNOUN=0:0 S PSNOUN=$O(^PS(50.606,PSSOID,"NOUN",PSNOUN)) Q:'PSNOUN S PSNOUNPT=$P($G(^(PSNOUN,0)),"^"),PSNOUNPA=$P($G(^(0)),"^",2) D:PSNOUNPT'=""
107 ..Q:PSNOUNPA=""
108 ..F PSDOD=0:0 S PSDOD=$O(^PS(50.606,PSSOID,"DUPD",PSDOD)) Q:'PSDOD S PSDUPDPT=$P($G(^(PSDOD,0)),"^") D:PSDUPDPT'=""
109 ...I $G(PSSONLYO),PSNOUNPA'["O" Q
110 ...I $G(PSSONLYI),PSNOUNPA'["I" Q
111 ...D TEST^PSSDOSCR
112 ...S PSALL=$G(PSDUPDPT)_" "_$S($G(PSSNLF):$G(PSSNLX),1:$G(PSNOUNPT)) K PSSNL,PSSNLF,PSSNLX
113 ...S (PSSLPT,PSSLPTX,PSSLPNO)=0 F PSSLP=0:0 S PSSLP=$O(^PSDRUG(PSSDIEN,"DOS2",PSSLP)) Q:'PSSLP S PSSLPTX=PSSLPTX+1 S PSSLPT=PSSLP I PSALL=$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLP,0)),"^") S PSSLPNO=1
114 ...Q:PSSLPNO
115 ...S PSSLPT=PSSLPT+1,PSSLPTX=PSSLPTX+1
116 ...S ^PSDRUG(PSSDIEN,"DOS2",PSSLPT,0)=$G(PSALL)_"^"_$G(PSNOUNPA),^PSDRUG(PSSDIEN,"DOS2","B",$E(PSALL,1,30),PSSLPT)="",^PSDRUG(PSSDIEN,"DOS2",0)="^50.0904^"_$G(PSSLPT)_"^"_$G(PSSLPTX)
117 F PSNOUN=0:0 S PSNOUN=$O(^PS(50.606,PSSOID,"NOUN",PSNOUN)) Q:'PSNOUN S PSNOUNPT=$P($G(^(PSNOUN,0)),"^"),PSNOUNPA=$P($G(^(0)),"^",2) D:PSNOUNPT'=""
118 .Q:PSNOUNPA=""
119 .I $G(PSSONLYO),PSNOUNPA'["O" Q
120 .I $G(PSSONLYI),PSNOUNPA'["I" Q
121 .S (PSSLPT,PSSLPTX,PSSLPNO)=0 F PSSLP=0:0 S PSSLP=$O(^PSDRUG(PSSDIEN,"DOS2",PSSLP)) Q:'PSSLP S PSSLPTX=PSSLPTX+1 S PSSLPT=PSSLP I PSNOUNPT=$P($G(^PSDRUG(PSSDIEN,"DOS2",PSSLP,0)),"^") S PSSLPNO=1
122 .Q:PSSLPNO
123 .S PSSLPT=PSSLPT+1,PSSLPTX=PSSLPTX+1
124 .S ^PSDRUG(PSSDIEN,"DOS2",PSSLPT,0)=$G(PSNOUNPT)_"^"_$G(PSNOUNPA),^PSDRUG(PSSDIEN,"DOS2","B",$E(PSNOUNPT,1,30),PSSLPT)="",^PSDRUG(PSSDIEN,"DOS2",0)="^50.0904^"_$G(PSSLPT)_"^"_$G(PSSLPTX)
125 Q
Note: See TracBrowser for help on using the repository browser.