source: WorldVistAEHR/trunk/r/LAB_SERVICE-LR-LS/LR7OU4.m@ 841

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

initial load of WorldVistAEHR

File size: 5.1 KB
Line 
1LR7OU4 ;DALOI/DCM/FHS/RLM-NLT LINKING UTILITY AUTO ;8/11/97
2 ;;5.2;LAB SERVICE;**127,163,272**;Sep 27, 1994
3 ; Reference to ^DIC supported by IA #10007
4 ; Reference to YN^DICN supported by IA #10009
5 ; Reference to ^DIE supported by IA #10018
6 ; Reference to ^DIK supported by IA #10013
7 ; Reference to ^DIR supported by IA #10026
8 ; Reference to $$CJ^XLFSTR supported by IA #10104
9 ; Reference to $$LOW^XLFSTR supported by IA #10104
10EN ;
1164 ;Find matches between file 64 and 60
12 W !,$$CJ^XLFSTR("This option will look for potential matches between file 64 (NLT) and file 60.",80),!,$$CJ^XLFSTR("You will be allowed to create a permanent link between matching entries in",80)
13 W !,$$CJ^XLFSTR("these files. Tests with the type of NEITHER will be omitted during link phase.",80)
14 W !!,$$CJ^XLFSTR("ONLY GENERIC NLT CODES CAN BE LINKED TO LAB TEST ",80),!!
15 W !,$$CJ^XLFSTR("Those LAB TEST already linked to the NLT file will also be omitted.",80),!
16LIST ;
17 K DIR S DIR("A")="Would you like a list of WKLD CODES from LABORATORY TEST file",DIR(0)="Y",DIR("B")="No"
18 D ^DIR G:$D(DIRUT)!($D(DTOUT))!($D(DUOUT)) END I Y=1 D G:$D(DIRUT)!($D(DTOUT))!($D(DUOUT))!(Y=0) END G LK
19 . D ^LRCAPD K DIR S DIR("A")="Ready to start linkage procedure ",DIR(0)="Y"
20 . D ^DIR
21 W ! K DIR S DIR("A")="Ready to proceed",DIR(0)="Y"
22 D ^DIR G:$D(DTOUT)!($D(DUOUT))!($D(DIROUT))!(Y'=1) END
23LK W !!,$$CJ^XLFSTR("Do you want to automatically link entries when there is an exact match",80)
24 W !,$$CJ^XLFSTR("on the NAME in both files",80) S %=2 D YN^DICN G:%=-1 END
25 I %=0 W !!,$$CJ^XLFSTR("Answer YES to automatically link the entries, or NO to be prompted for each",80) G LK
26 S AUTO=$S(%=1:1,1:0)
27LAB ;
28 S (END,LRN)="" F S LRN=$O(^LAB(60,"B",LRN)) Q:LRN=""!($G(END)) D
29 . S LRIEN="" F S LRIEN=+$O(^LAB(60,"B",LRN,LRIEN)) Q:LRIEN<1!($G(END)) I '$G(^(LRIEN)) D CHECK
30 W:'$G(END) !!,$$CJ^XLFSTR("End of loop",80),!
31 G END
32 Q
33CHECK ;
34 Q:'$D(^LAB(60,LRIEN,0))#2!($G(^LAB(60,LRIEN,64)))!($G(END))
35 S LRDATA=$P(^LAB(60,LRIEN,0),U),LRTY=$P(^(0),U,3) Q:LRTY=""!(LRTY="N")
36 S LRNU=$$UPPER(LRN),LRMIEN=+$O(^LAM("D",LRNU,0)) D:'LRMIEN 91 Q:(('LRMIEN)!($G(END)))
37 Q:'$D(^LAM(LRMIEN,0))#2 S LRCODE=$P($P(^(0),U,2),".",1)_".0000 " Q:'LRCODE
38 S LRMIEN=$O(^LAM("C",LRCODE,0)) Q:('LRMIEN)!('$D(^LAM(LRMIEN,0))#2)
39 S LRMNAME=$P(^LAM(LRMIEN,0),U)
40 Q:'$D(^LAM(LRMIEN,0)) S LRMNAME=$P(^(0),U)
41 W !!,"60 = ",LRDATA,!,"64 = ",LRMNAME_" "_LRCODE
42 D LINK(LRIEN,LRMIEN,AUTO)
43 Q
4491 ;Look for Accession WKLD codes
45 G:'$O(^LAB(60,LRIEN,9.1,0)) 9
46 W !!,$C(7),?5,"Did not find a exact name match for Lab Test "_LRDATA
47 W !," Want to use a Accession WKLD code instead?",!
48 S I=0 F S I=$O(^LAB(60,LRIEN,9.1,I)) Q:I<1 W:$D(^LAM(I,0))#2 !?2,$P(^(0),U),?50,$P(^(0),U,2)
49 W ! K DIC S DIC="^LAB(60,"_LRIEN_",9.1,",DIC(0)="AQNMZ",DIC("A")="Select Accession WKLD if appropriate " D ^DIC W !
50 S:$E(X)=U!($G(DTOUT)) END=1 Q:$G(END) I Y>0 S LRMIEN=+Y Q
519 ;Look for Verify WKLD codes
52 Q:'$O(^LAB(60,LRIEN,9,0))
53 W !!,$C(7),?5,"Did not find a exact name match for Lab Test "_LRDATA
54 W !," Want to use a Verify WKLD code instead?",!
55 S I=0 F S I=$O(^LAB(60,LRIEN,9,I)) Q:I<1 W:$D(^LAM(I,0))#2 !?2,$P(^(0),U),?50,$P(^(0),U,2)
56 W ! K DIC S DIC="^LAB(60,"_LRIEN_",9,",DIC(0)="AQNMZ",DIC("A")="Select Verify WKLD if appropriate " D ^DIC W !
57 S:$E(X)=U!($G(DTOUT)) END=1 Q:$G(END)!(Y<1) S LRMIEN=+Y
58 Q
59LINK(X60,X64,DOIT) ;Link the 2 files
60 S LRDATA="`"_X60 I DOIT S %=1 G L2
61L1 W !?5,"Link the two entries" S %=2 D YN^DICN Q:%=2 I %=-1 S END=1 Q
62 I $G(DTOUT) S END=1 Q
63 I %=0 W !,"Enter Yes to link the entries, No to leave it alone." G L1
64L2 D:$G(^LAB(60,X60,64)) DXSS
65 K DIE,DA,DR,DIC S DIE="^LAB(60,",DA=X60,DR="64////^S X=X64",DLAYGO=60 D ^DIE K DLAYGO
66XSS K DIE,DA,DR,DIC S DIE="^LAM(",DA=X64,DR="23///^S X=LRDATA;",DR(1,64)="23///^S X=LRDATA;",DR(2,64.023)=".01////LRDATA;",DLAYGO=64
67 S DIC("V")="I +Y(0)=60" D ^DIE K DIC K DLAYGO
68 I $G(^LAB(60,X60,64))&($D(^LAM("AE","LAB(60,",X60))) W !?32,"o----LINKED----o",! H 1 Q
69 W !!?15,"***************** NOT LINKED ***************",!
70 W !!?5,"Press Return to continue" R X:DTIME S:$G(DTOUT)!($E(X)=U) END=1
71 Q
72DXSS N DIE,DA,DR,DIC,DIK,DLAYGO
73 S DA(1)=+$G(^LAB(60,X60,64)),DIK="^LAM("_DA(1)_",7,",DLAYGO=64
74 S DA=$O(^LAM(DA(1),7,"B",X60_";LAB(60,",0))
75 D:DA&(DA(1)) ^DIK
76 Q
77END ;
78 Q:$G(LRDBUG)
79 K %,AUTO,DA,DIC,DIE,DIR,DOIT,DR,END,LRDATA,LRIEN,LRMIEN,LRN,LRNU
80 K LRSUF,LRTY,X,X60,X64,Y,LRMNAME,D1,D0,DLAYGO,I,LRCODE,END
81 K FLG,XXX,ZZ,ZZ1,X,Y,Y64,DLAYGO
82 Q
83UPPER(X) ; Convert lower case X to UPPER CASE
84 Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
8560(X) ;Find matching item in file 60
86 N XXX S XXX=X K SSS
87 S X=$O(^LAB(60,"B",X,0)),ZZ1="",ZZ=""
88 I 'X S X=$O(^LAB(60,"B",XXX)),X=$S($E(X,$L(X))="S"&($E(X,1,$L(X)-1)=XXX):$O(^LAB(60,"B",XXX,0)),1:"") S:$L(X) SSS=1
89 I X S ZZ=X,X=$P(^LAB(60,X,0),"^"),ZZ1=$P($G(^(64)),"^")
90 I ZZ1 W !,$P(^LAM(ZZ1,0),"^")_" => "_X,?60,"Already linked" S X="",LINKED=1
91 Q X
92MIXED(X,FLG) ;Return mixed case
93 ;X=TEXT
94 ;FLG-1 all text lower case, 0 mixed case, 2 1st letter of each word caps
95 N Z,I
96 I 'FLG S X=$E(X,1)_$$LOW^XLFSTR($E(X,2,$L(X)))
97 I FLG=1 S X=$$LOW^XLFSTR($E(X,1,$L(X)))
98 I FLG=2 S Z="" D
99 . F I=1:1:$L(X," ") S Z=Z_$S(I>1:" ",1:"")_$$MIXED($P(X," ",I),0)
100 . S X=Z
101 Q X
Note: See TracBrowser for help on using the repository browser.