source: WorldVistAEHR/trunk/r/ENGINEERING-EN/ENXLFIX.m@ 1766

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

initial load of WorldVistAEHR

File size: 4.7 KB
Line 
1ENXLFIX ;WISC/SAB-FIX POINTERS TO ENG SPACE FILE ;1-24-94
2 ;;7.0;ENGINEERING;**1**;Aug 17, 1993
3EN S DIR(0)="S^EQ:EQUIPMENT FILE;WO:WORK ORDER FILE;"
4 S DIR("A")=$S(ENCVTM:"Convert",1:"Report of")_" location fields in which file"
5 S DIR("?")="Enter EQ or WO to select the desired file."
6 S DIR("?",1)="You must choose which file to process. The LOCATION"
7 S DIR("?",2)="field of the selected file will be checked and"
8 I ENCVTM D
9 .S DIR("?",3)="any free-text values which match an entry in the space"
10 .S DIR("?",4)="file will be converted to pointers. Any unconverted"
11 .S DIR("?",5)="free-text values will be identified by a leading '*'"
12 E D
13 .S DIR("?",3)="the number and type of free-text entries in this"
14 .S DIR("?",4)="pointer field will be reported."
15 S DIR("?",9)=" "
16 D ^DIR K DIR I $D(DIRUT) G EXIT
17 S ENFL=Y
18 S ENDETAIL=1
19 I ENCVTM D D ^DIR K DIR S ENDETAIL=Y I $D(DIRUT) G EXIT
20 .S DIR(0)="Y",DIR("A")="Should locations be listed on output? Y/N"
21 .S DIR("?")="Enter Y or N"
22 .S DIR("?",1)="If you answer yes a line will be printed for each"
23 .S DIR("?",2)="unique free-text location. The line will contain"
24 .S DIR("?",3)="the location, the number of entries with that location,"
25 .S DIR("?",4)="and if the location was converted to a pointer."
26 S %ZIS="QM" D ^%ZIS G EXIT:POP
27 I $D(IO("Q")) D G EXIT
28 .S ZTRTN="DQ^ENXLFIX"
29 .S ZTSAVE("ENCVTM")="",ZTSAVE("ENFL")="",ZTSAVE("ENDETAIL")=""
30 .S ZTDESC=$S(ENCVTM:"Convert",1:"Report of")_" Locations in "_$S(ENFL="EQ":"EQUIP",1:"W.O.")_" file"
31 .D ^%ZTLOAD D HOME^%ZIS K IO("Q")
32DQ ; queued entry
33 S Y=DT D DD^%DT S ENDATE=Y
34 S (END,ENPG,ENT("LOC"),ENT("REC"),ENT("LOC_CVT"),ENT("REC_CVT"))=0
35 S ENFLNM=$S(ENFL="EQ":"Equipment File",1:"Work Order File")
36 S ENXRF=$S(ENFL="EQ":"^ENG(6914,""D"",",1:"^ENG(6920,""C"",")
37 S ENODE=$S(ENFL="EQ":"^ENG(6914,ENDA,3)",1:"^ENG(6920,ENDA,0)")
38 S ENPIECE=$S(ENFL="EQ":5,1:4)
39 U IO D HDR
40 I 'ENDETAIL W !," Locations not listed by user request",!
41 ; loop thru free-text locations
42 S ENLOC=" " F S ENLOC=$O(@(ENXRF_"ENLOC)")) Q:ENLOC=""!END D LOCAT
43 I 'END D
44 .I ENCVTM,$Y+6+$S(ENT("REC"):6,1:2)+$S(ENT("REC_CVT"):3,1:0)>IOSL D HDR
45 .I 'ENCVTM,$Y+6+$S(ENT("REC"):7,1:2)+$S(ENT("REC_CVT"):6,1:0)>IOSL D HDR
46 I END W !,"HALTED BY USER REQUEST",!
47 E D RFTR^ENXLFIX0
48 D ^%ZISC
49EXIT I $D(ZTQUEUED),'$D(ZTSTOP) S ZTREQ="Q"
50 K %ZIS,DA,DIE,DIRUT,DR
51 K ENCVTM,ENCVTS,END,ENDA,ENDATE,ENDETAIL,ENFL,ENFLNM,ENLOC,ENODE
52 K ENPG,ENPIECE,ENSPDA,ENSPLOC,ENT,ENXRF,POP,X,Y
53 Q
54LOCAT ; process location
55 I ENCVTM,$E(ENLOC,1)=" " D SPACES^ENXLFIX0 Q ; handle leading spaces
56 S ENCVTS=0,ENT("LOC")=ENT("LOC")+1
57 ; strip * for match
58 S ENSPLOC=$E(ENLOC,$S($E(ENLOC,1)="*":2,1:1),$L(ENLOC))
59 I ENSPLOC']"" S ENSPLOC=ENLOC
60 ; match space .01?
61 S ENSPDA=$O(^ENG("SP","B",ENSPLOC,""))
62 ; if not match and has lowercase, uppercase match .01?
63 I 'ENSPDA,ENSPLOC?.E1L.E D
64 .S X=ENSPLOC X ^%ZOSF("UPPERCASE")
65 .S ENSPDA=$O(^ENG("SP","B",Y,""))
66 ; if we found a match to .01 (either method)
67 I ENSPDA S ENCVTS=1,ENT("LOC_CVT")=ENT("LOC_CVT")+1
68 ; if not match, match space synonym?
69 I 'ENSPDA S ENSPDA=$O(^ENG("SP","F",ENSPLOC,"")) D:ENSPDA
70 .I $O(^ENG("SP","F",ENSPLOC,ENSPDA)) S ENCVTS="M"
71 .E S ENCVTS=2,ENT("LOC_CVT")=ENT("LOC_CVT")+1
72 ; if still no match and free-text location has *, match synonym?
73 I 'ENSPDA,ENSPLOC'=ENLOC S ENSPDA=$O(^ENG("SP","F",ENLOC,"")) D:ENSPDA
74 .I $O(^ENG("SP","F",ENLOC,ENSPDA)) S ENCVTS="M"
75 .E S ENCVTS=2,ENT("LOC_CVT")=ENT("LOC_CVT")+1
76 ; loop thru records within location
77 S ENT("REC_IN_LOC")=0,ENDA=""
78 F S ENDA=$O(@(ENXRF_"ENLOC,ENDA)")) Q:'ENDA D
79 .I '$D(@ENODE) K @(ENXRF_"ENLOC,ENDA)") Q ; invalid x-ref node
80 .S ENT("REC_IN_LOC")=ENT("REC_IN_LOC")+1
81 .I ENCVTM,ENCVTS D ; convert to pointer
82 ..I ENFL="EQ",ENLOC["E" K ^ENG(6914,"D",ENLOC,ENDA) S $P(^ENG(6914,ENDA,3),U,5)=""
83 ..S DIE=$S(ENFL="EQ":"^ENG(6914,",1:"^ENG(6920,"),DA=ENDA
84 ..S DR=$S(ENFL="EQ":"24",1:"3")_"////"_ENSPDA D ^DIE
85 .I ENCVTM,'ENCVTS,$E(ENLOC,1)'="*" D ; add leading *
86 ..S $P(@ENODE,U,ENPIECE)="*"_$P(@ENODE,U,ENPIECE)
87 ..K @(ENXRF_"ENLOC,ENDA)") ; old x-ref
88 ..S @(ENXRF_"""*"_ENLOC_""","_ENDA_")")="" ; new x-ref
89 S ENT("REC")=ENT("REC")+ENT("REC_IN_LOC")
90 I ENCVTS S ENT("REC_CVT")=ENT("REC_CVT")+ENT("REC_IN_LOC")
91 W:ENDETAIL ?5,ENLOC,?30,ENT("REC_IN_LOC"),?40,$S($E(ENLOC,1)=" ":"?? (leading spaces)",ENCVTS=1:"YES, by room number",ENCVTS=2:"YES, by synonym",ENCVTS="M":"NO, multiple synonyms",1:"NO"),!
92 I $Y+4>IOSL D HDR
93 Q
94HDR ; page header
95 I $$S^%ZTLOAD S (END,ZTSTOP)=1 Q
96 I ENPG,$E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR S END='Y Q:END
97 W:'($E(IOST,1,2)'="C-"&'ENPG) @IOF
98 S ENPG=ENPG+1
99 W ?5,"Free-Text Values in ",ENFLNM," LOCATION Fields"
100 W ?60,ENDATE,?73,"page ",ENPG,!!
101 W ?5,"Free-Text Location",?30,"Count"
102 W ?40,"Convert"_$S(ENCVTM:"ed?",1:"ible?"),!
103 W ?5,"------------------",?30,"-----",?40,"------------",!!
104 Q
Note: See TracBrowser for help on using the repository browser.