source: FOIAVistA/trunk/r/TEXT_INTEGRATION_UTILITIES-GMRP-TIU/TIUMAP1.m@ 1397

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

initial load of FOIAVistA 6/30/08 version

File size: 9.3 KB
Line 
1TIUMAP1 ; ISL/JER - TIU/VHA Enterprise Document Type Ontology Mapper ;10/24/06 09:01
2 ;;1.0;TEXT INTEGRATION UTILITIES;**211**;Jun 20, 1997;Build 26
3PARSE(RESULT,TIUNM) ; Attempt to map each word to one of the LOINC axes - build parse tree
4 N TIUI,TIUPTREE,TIUWORD,TIULOCAL,TIUY S TIULOCAL=TIUNM,TIUY=0
5 S TIUPTREE=$NA(^TMP("TIUMAP",$J)) K @TIUPTREE
6 ; Test whether each word maps to a Subject Matter Domain
7 F TIUI=1:1:$L(TIUNM," ") S TIUWORD=$P(TIUNM," ",TIUI) Q:TIUWORD']"" D SMD(TIUPTREE,TIUWORD,.TIUNM,TIUI) Q:+$G(@TIUPTREE@("SubjectMatterDomain"))!+$G(DIRUT)
8 Q:+$G(DIRUT)
9 ; Test whether each REMAINING word maps to a Role
10 F TIUI=1:1:$L(TIUNM," ") S TIUWORD=$P(TIUNM," ",TIUI) Q:TIUWORD']"" D ROLE(TIUPTREE,TIUWORD,.TIUNM,TIUI) Q:+$G(@TIUPTREE@("Role"))!+$G(DIRUT)
11 Q:+$G(DIRUT)
12 ; Test whether each REMAINING word maps to a Setting
13 F TIUI=1:1:$L(TIUNM," ") S TIUWORD=$P(TIUNM," ",TIUI) Q:TIUWORD']"" D SET(TIUPTREE,TIUWORD,.TIUNM,TIUI) Q:+$G(@TIUPTREE@("Setting"))!+$G(DIRUT)
14 Q:+$G(DIRUT)
15 ; Test whether each REMAINING word maps to a Service
16 F TIUI=1:1:$L(TIUNM," ") S TIUWORD=$P(TIUNM," ",TIUI) Q:TIUWORD']"" D SVC(TIUPTREE,TIUWORD,.TIUNM,TIUI) Q:+$G(@TIUPTREE@("Service"))!+$G(DIRUT)
17 Q:+$G(DIRUT)
18 ; Test whether each REMAINING word maps to a Document Type
19 F TIUI=1:1:$L(TIUNM," ") S TIUWORD=$P(TIUNM," ",TIUI) Q:TIUWORD']"" D DTYP(TIUPTREE,TIUWORD,.TIUNM,TIUI) Q:+$G(@TIUPTREE@("DocumentType"))!+$G(DIRUT)
20 Q:+$G(DIRUT)
21 I $D(@TIUPTREE) D
22 . N SMD,ROLE,SET,SVC,DTYP,SCRN,DIC,X S SCRN="I ",X=""
23 . S SMD=$G(@TIUPTREE@("SubjectMatterDomain"))
24 . S ROLE=$G(@TIUPTREE@("Role"))
25 . S SET=$G(@TIUPTREE@("Setting"))
26 . S SVC=$G(@TIUPTREE@("Service"))
27 . S DTYP=$G(@TIUPTREE@("DocumentType"))
28 . I DTYP="" S DTYP=+$O(^TIU(8926.6,"B","NOTE",0))_U_"NOTE"
29 . I W !,"No Document Type found...Setting Document Type to 'NOTE.'",!
30 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Now, we'll query the VHA Enterprise Standard Titles for an entry with:",!
31 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?12,"LOCAL Title: ",TIULOCAL
32 . I +SMD D
33 . . S SCRN=SCRN_"$P(^(0),U,4)="_+SMD
34 . . S:X="" X=$P(SMD,U,2)
35 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?2,"Subject Matter Domain: ",$P(SMD,U,2)
36 . I +ROLE D
37 . . S SCRN=SCRN_$S(SCRN="I ":"",1:",")_"$P(^(0),U,5)="_+ROLE
38 . . S:X="" X=$P(ROLE,U,2)
39 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?19,"Role: ",$P(ROLE,U,2)
40 . I +SET D
41 . . S SCRN=SCRN_$S(SCRN="I ":"",1:",")_"$P(^(0),U,6)="_+SET
42 . . S:X="" X=$P(SET,U,2)
43 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?16,"Setting: ",$P(SET,U,2)
44 . I +SVC D
45 . . S SCRN=SCRN_$S(SCRN="I ":"",1:",")_"$P(^(0),U,7)="_+SVC
46 . . S:X="" X=$P(SVC,U,2)
47 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?16,"Service: ",$P(SVC,U,2)
48 . I +DTYP D
49 . . S SCRN=SCRN_$S(SCRN="I ":"",1:",")_"$P(^(0),U,8)="_+DTYP
50 . . S:X="" X=$P(DTYP,U,2)
51 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !?10,"Document Type: ",$P(DTYP,U,2)
52 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !!,"First, we'll try an EXCLUSIVE match (i.e., ALL conditions met):"
53 . S DIC("S")=SCRN_",'$$SCREEN^XTID(8926.1,"""",+Y_"","")",DIC=8926.1
54 . S TIUY=$$ASK(X,.DIC) Q:+$G(DIRUT)
55 . I +TIUY'>0,($L(SCRN,"$P")>2) D Q:+$G(DIRUT)
56 . . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !!,"Since that failed, we'll try an INCLUSIVE match (i.e., ANY conditions met):"
57 . . S SCRN=$$ANDTOOR(SCRN)
58 . . S DIC("S")=SCRN_",'$$SCREEN^XTID(8926.1,"""",+Y_"","")",DIC=8926.1
59 . . S TIUY=$$ASK(X,.DIC)
60 I +TIUY'>0 D Q:+$G(DIRUT)
61 . N TIUCONT S TIUCONT=1
62 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !!,$$EXPLAT," Let's try a manual look-up..."
63 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Again, your LOCAL Title is: ",TIULOCAL,!!," NOTE: Only ACTIVE Titles may be selected...",!
64 . F D Q:+TIUCONT'>0
65 . . N DIC S DIC=8926.1,DIC(0)="AEMQ",DIC("A")="Select VHA ENTERPRISE STANDARD TITLE: "
66 . . S DIC("S")="I '$$SCREEN^XTID(8926.1,"""",+Y_"","")"
67 . . S TIUY=$$ASK("",.DIC) I +TIUY>0 S TIUCONT=0 Q
68 . . I '$$PAGE^TIUMAP2(TIULOCAL) S TIUCONT=0 Q
69 . . W !!,"You didn't select a VHA Enterprise Standard Title...",!
70 . . S TIUCONT=$$READ^TIUU("Y","... Try to map "_TIULOCAL_" again","NO") W !
71 . . S:+$G(DIRUT) TIUOUT=1
72 Q:+TIUY'>0!+$G(DIRUT)
73 S RESULT=+TIUY,RESULT(1)=TIUY_U_TIULOCAL
74 Q
75LOG(TIULOCAL,DA) ; Log a mapping failure
76 N DIE,DR
77 W !!,"Recording the unmapped LOCAL Title: ",TIULOCAL,!
78 S ^XTMP("TIUMAP","FAIL",TIULOCAL,DA)=""
79 S DIE=8925.1,DR="1502////^S X="_$$NOW^XLFDT_";1503////^S X="_DUZ D ^DIE
80 ; Drop LOCK
81 L -^TIU(8925.1,DA,15):1
82 Q
83EXPLAT() ; Random selector of explatives
84 N EXP S EXP="AUGH!;OUCH!;YUCK!;BLECH!;OY VEY!;UFF DAH!"
85 Q $P(EXP,";",$R(6)+1)
86ANDTOOR(SCRN) ; Replaces AND operators with OR
87 F Q:'$F(SCRN,",$P") S $E(SCRN,$F(SCRN,",$P")-3)="!"
88 Q SCRN
89SMD(RESULT,TIUWORD,TIUNM,TIUI) ; Is word a SMD?
90 N TIUY S TIUY=0
91 Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a Subject Matter Domain? "
92 S TIUY=$$ASK(TIUWORD,8926.2) I +$G(DIRUT) Q
93 ; First, inquire to the SMD file (#8926.2)
94 I +TIUY>0 S @RESULT@("SubjectMatterDomain")=TIUY D PLUCK(.TIUNM,TIUWORD,TIUI) I 1
95 ; That failing, try the SMD Synonyms File (#8926.72)
96 E D Q:+$G(DIRUT)
97 . W "No."
98 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a SYNONYM for a Subject Matter Domain? "
99 . S TIUY=$$ASK(TIUWORD,8926.72) Q:+$G(DIRUT)
100 . I +TIUY>0 D
101 . . S TIUY=+$P($G(^TIU(8926.72,+TIUY,0)),U,2)
102 . . S TIUY=TIUY_U_$P($G(^TIU(8926.2,+TIUY,0)),U)
103 . . S @RESULT@("SubjectMatterDomain")=TIUY
104 . . D PLUCK(.TIUNM,TIUWORD,TIUI)
105 I +TIUY'>0 W "No.",!
106 Q
107ROLE(RESULT,TIUWORD,TIUNM,TIUI) ; Is word a ROLE?
108 N TIUY S TIUY=0
109 Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a LOINC Role? "
110 ; First, inquire to the ROLE file (#8926.3)
111 S TIUY=$$ASK(TIUWORD,8926.3) Q:+$G(DIRUT)
112 I +TIUY>0 S @RESULT@("Role")=TIUY D PLUCK(.TIUNM,TIUWORD,TIUI) I 1
113 ; That failing, try the Role Synonyms File (#8926.73)
114 E D Q:+$G(DIRUT)
115 . W "No."
116 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a SYNONYM for a LOINC Role? "
117 . S TIUY=$$ASK(TIUWORD,8926.73) Q:+$G(DIRUT)
118 . I +TIUY>0 D
119 . . S TIUY=+$P($G(^TIU(8926.73,+TIUY,0)),U,2)
120 . . S TIUY=TIUY_U_$P($G(^TIU(8926.3,+TIUY,0)),U)
121 . . S @RESULT@("Role")=TIUY
122 . . D PLUCK(.TIUNM,TIUWORD,TIUI)
123 I +TIUY'>0 W "No.",!
124 Q
125SET(RESULT,TIUWORD,TIUNM,TIUI) ; Is word a SETTING?
126 N TIUY S TIUY=0
127 Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a Setting? "
128 ; First, inquire to the Setting file (#8926.4)
129 S TIUY=$$ASK(TIUWORD,8926.4) Q:+$G(DIRUT)
130 I +TIUY>0 S @RESULT@("Setting")=TIUY D PLUCK(.TIUNM,TIUWORD,TIUI) I 1
131 ; That failing, try the Setting Synonyms File (#8926.74)
132 E D Q:+$G(DIRUT)
133 . W "No."
134 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a SYNONYM for a Setting? "
135 . S TIUY=$$ASK(TIUWORD,8926.74) Q:+$G(DIRUT)
136 . I +TIUY>0 D
137 . . S TIUY=+$P($G(^TIU(8926.74,+TIUY,0)),U,2)
138 . . S TIUY=TIUY_U_$P($G(^TIU(8926.4,+TIUY,0)),U)
139 . . S @RESULT@("Setting")=TIUY
140 . . D PLUCK(.TIUNM,TIUWORD,TIUI)
141 I +TIUY'>0 W "No.",!
142 Q
143SVC(RESULT,TIUWORD,TIUNM,TIUI) ; Is word a SERVICE?
144 N TIUY S TIUY=0
145 Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a Service? "
146 ; First, inquire to the Service file (#8926.5)
147 S TIUY=$$ASK(TIUWORD,8926.5) Q:+$G(DIRUT)
148 I +TIUY>0 S @RESULT@("Service")=TIUY D PLUCK(.TIUNM,TIUWORD,TIUI) I 1
149 ; That failing, try the Role Synonyms File (#8926.75)
150 E D Q:+$G(DIRUT)
151 . W "No."
152 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a SYNONYM for a Service? "
153 . S TIUY=$$ASK(TIUWORD,8926.75) Q:+$G(DIRUT)
154 . I +TIUY>0 D
155 . . S TIUY=+$P($G(^TIU(8926.75,+TIUY,0)),U,2)
156 . . S TIUY=TIUY_U_$P($G(^TIU(8926.5,+TIUY,0)),U)
157 . . S @RESULT@("Service")=TIUY
158 . . D PLUCK(.TIUNM,TIUWORD,TIUI)
159 I +TIUY'>0 W "No.",!
160 Q
161DTYP(RESULT,TIUWORD,TIUNM,TIUI) ; Is word a DOCUMENT TYPE?
162 N TIUY S TIUY=0
163 Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a Document Type? "
164 ; First, inquire to the Document Type file (#8926.6)
165 S TIUY=$$ASK(TIUWORD,8926.6) Q:+$G(DIRUT)
166 I +TIUY>0 S @RESULT@("DocumentType")=TIUY D PLUCK(.TIUNM,TIUWORD,TIUI) I 1
167 ; That failing, try the Role Synonyms File (#8926.76)
168 E D Q:+$G(DIRUT)
169 . W "No."
170 . Q:'$$PAGE^TIUMAP2(TIULOCAL) W !,"Is """,TIUWORD,""" a SYNONYM for a Document Type? "
171 . S TIUY=$$ASK(TIUWORD,8926.76) Q:+$G(DIRUT)
172 . I +TIUY>0 D
173 . . S TIUY=+$P($G(^TIU(8926.76,+TIUY,0)),U,2)
174 . . S TIUY=TIUY_U_$P($G(^TIU(8926.6,+TIUY,0)),U)
175 . . S @RESULT@("DocumentType")=TIUY
176 . . D PLUCK(.TIUNM,TIUWORD,TIUI)
177 I +TIUY'>0 W "No.",!
178 Q
179PLUCK(TIUNM,TIUWORD,TIUI) ; Pluck word from name
180 N TIUOUT S TIUOUT=$P(TIUNM," ",TIUI) Q:TIUOUT'=TIUWORD
181 S TIUNM=$S(TIUI=1:$P(TIUNM," ",2,$L(TIUNM," ")),1:$P(TIUNM," ",1,(TIUI-1))_$S(TIUI=$L(TIUNM," "):"",1:" "_$P(TIUNM," ",(TIUI+1),$L(TIUNM," "))))
182 Q
183CONFIRM(RESULT,DEFAULT) ; Show selected title to user, ask to confirm
184 N TIUY,DUOUT,DTOUT,DIRUT S TIUY=0
185 W !?5,"Ready to map LOCAL Title: ",$P(RESULT(1),U,3)," to",!,"VHA Enterprise Standard Title: ",$P(RESULT(1),U,2),"."
186 S TIUY=$$READ^TIUU("YA"," ... OK? ",DEFAULT)
187 I +TIUY'>0 S RESULT=0 K RESULT(1)
188 Q
189ASK(X,DIC) ; Call DIC to perform look-up
190 N Y,TIUY,TIUSYN,TIUSNM S TIUY=0,TIUSNM=""
191 S TIUSNM=$S(DIC=8926.72:"Subject Matter Domain",DIC=8926.73:"LOINC Role",DIC=8926.74:"Setting",DIC=8926.75:"Service",DIC=8926.76:"Document Type",1:"")
192 S TIUSYN=$S(DIC=8926.72:8926.2,DIC=8926.73:8926.3,DIC=8926.74:8926.4,DIC=8926.75:8926.5,DIC=8926.76:8926.6,1:0)
193 S:'$D(DIC(0)) DIC(0)="EM"
194 S:TIUSYN&(DIC(0)'["Z") DIC(0)=DIC(0)_"Z"
195 D ^DIC I $D(DTOUT)!$D(DUOUT) S DIRUT=1 S:X="^^" DIROUT=1
196 I +Y>0 D
197 . W !?4,"I found a match of: ",$P(Y,U,2)
198 . I +TIUSYN,$D(Y(0)) W !?(22-$L(TIUSNM)),TIUSNM,": ",$P($G(^TIU(TIUSYN,+$P(Y(0),U,2),0)),U)
199 . S TIUY=$$READ^TIUU("YA"," ... OK? ","Yes") W !
200 . S:+TIUY'>0 Y=-1
201 Q Y
Note: See TracBrowser for help on using the repository browser.