Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ENXLFIX

ENXLFIX.m

Go to the documentation of this file.
  1. ENXLFIX ;WISC/SAB-FIX POINTERS TO ENG SPACE FILE ;1-24-94
  1. ;;7.0;ENGINEERING;**1**;Aug 17, 1993
  1. EN S DIR(0)="S^EQ:EQUIPMENT FILE;WO:WORK ORDER FILE;"
  1. S DIR("A")=$S(ENCVTM:"Convert",1:"Report of")_" location fields in which file"
  1. S DIR("?")="Enter EQ or WO to select the desired file."
  1. S DIR("?",1)="You must choose which file to process. The LOCATION"
  1. S DIR("?",2)="field of the selected file will be checked and"
  1. I ENCVTM D
  1. .S DIR("?",3)="any free-text values which match an entry in the space"
  1. .S DIR("?",4)="file will be converted to pointers. Any unconverted"
  1. .S DIR("?",5)="free-text values will be identified by a leading '*'"
  1. E D
  1. .S DIR("?",3)="the number and type of free-text entries in this"
  1. .S DIR("?",4)="pointer field will be reported."
  1. S DIR("?",9)=" "
  1. D ^DIR K DIR I $D(DIRUT) G EXIT
  1. S ENFL=Y
  1. S ENDETAIL=1
  1. I ENCVTM D D ^DIR K DIR S ENDETAIL=Y I $D(DIRUT) G EXIT
  1. .S DIR(0)="Y",DIR("A")="Should locations be listed on output? Y/N"
  1. .S DIR("?")="Enter Y or N"
  1. .S DIR("?",1)="If you answer yes a line will be printed for each"
  1. .S DIR("?",2)="unique free-text location. The line will contain"
  1. .S DIR("?",3)="the location, the number of entries with that location,"
  1. .S DIR("?",4)="and if the location was converted to a pointer."
  1. S %ZIS="QM" D ^%ZIS G EXIT:POP
  1. I $D(IO("Q")) D G EXIT
  1. .S ZTRTN="DQ^ENXLFIX"
  1. .S ZTSAVE("ENCVTM")="",ZTSAVE("ENFL")="",ZTSAVE("ENDETAIL")=""
  1. .S ZTDESC=$S(ENCVTM:"Convert",1:"Report of")_" Locations in "_$S(ENFL="EQ":"EQUIP",1:"W.O.")_" file"
  1. .D ^%ZTLOAD D HOME^%ZIS K IO("Q")
  1. DQ ; queued entry
  1. S Y=DT D DD^%DT S ENDATE=Y
  1. S (END,ENPG,ENT("LOC"),ENT("REC"),ENT("LOC_CVT"),ENT("REC_CVT"))=0
  1. S ENFLNM=$S(ENFL="EQ":"Equipment File",1:"Work Order File")
  1. S ENXRF=$S(ENFL="EQ":"^ENG(6914,""D"",",1:"^ENG(6920,""C"",")
  1. S ENODE=$S(ENFL="EQ":"^ENG(6914,ENDA,3)",1:"^ENG(6920,ENDA,0)")
  1. S ENPIECE=$S(ENFL="EQ":5,1:4)
  1. U IO D HDR
  1. I 'ENDETAIL W !," Locations not listed by user request",!
  1. ; loop thru free-text locations
  1. S ENLOC=" " F S ENLOC=$O(@(ENXRF_"ENLOC)")) Q:ENLOC=""!END D LOCAT
  1. I 'END D
  1. .I ENCVTM,$Y+6+$S(ENT("REC"):6,1:2)+$S(ENT("REC_CVT"):3,1:0)>IOSL D HDR
  1. .I 'ENCVTM,$Y+6+$S(ENT("REC"):7,1:2)+$S(ENT("REC_CVT"):6,1:0)>IOSL D HDR
  1. I END W !,"HALTED BY USER REQUEST",!
  1. E D RFTR^ENXLFIX0
  1. D ^%ZISC
  1. EXIT I $D(ZTQUEUED),'$D(ZTSTOP) S ZTREQ="Q"
  1. K %ZIS,DA,DIE,DIRUT,DR
  1. K ENCVTM,ENCVTS,END,ENDA,ENDATE,ENDETAIL,ENFL,ENFLNM,ENLOC,ENODE
  1. K ENPG,ENPIECE,ENSPDA,ENSPLOC,ENT,ENXRF,POP,X,Y
  1. Q
  1. LOCAT ; process location
  1. I ENCVTM,$E(ENLOC,1)=" " D SPACES^ENXLFIX0 Q ; handle leading spaces
  1. S ENCVTS=0,ENT("LOC")=ENT("LOC")+1
  1. ; strip * for match
  1. S ENSPLOC=$E(ENLOC,$S($E(ENLOC,1)="*":2,1:1),$L(ENLOC))
  1. I ENSPLOC']"" S ENSPLOC=ENLOC
  1. ; match space .01?
  1. S ENSPDA=$O(^ENG("SP","B",ENSPLOC,""))
  1. ; if not match and has lowercase, uppercase match .01?
  1. I 'ENSPDA,ENSPLOC?.E1L.E D
  1. .S X=ENSPLOC X ^%ZOSF("UPPERCASE")
  1. .S ENSPDA=$O(^ENG("SP","B",Y,""))
  1. ; if we found a match to .01 (either method)
  1. I ENSPDA S ENCVTS=1,ENT("LOC_CVT")=ENT("LOC_CVT")+1
  1. ; if not match, match space synonym?
  1. I 'ENSPDA S ENSPDA=$O(^ENG("SP","F",ENSPLOC,"")) D:ENSPDA
  1. .I $O(^ENG("SP","F",ENSPLOC,ENSPDA)) S ENCVTS="M"
  1. .E S ENCVTS=2,ENT("LOC_CVT")=ENT("LOC_CVT")+1
  1. ; if still no match and free-text location has *, match synonym?
  1. I 'ENSPDA,ENSPLOC'=ENLOC S ENSPDA=$O(^ENG("SP","F",ENLOC,"")) D:ENSPDA
  1. .I $O(^ENG("SP","F",ENLOC,ENSPDA)) S ENCVTS="M"
  1. .E S ENCVTS=2,ENT("LOC_CVT")=ENT("LOC_CVT")+1
  1. ; loop thru records within location
  1. S ENT("REC_IN_LOC")=0,ENDA=""
  1. F S ENDA=$O(@(ENXRF_"ENLOC,ENDA)")) Q:'ENDA D
  1. .I '$D(@ENODE) K @(ENXRF_"ENLOC,ENDA)") Q ; invalid x-ref node
  1. .S ENT("REC_IN_LOC")=ENT("REC_IN_LOC")+1
  1. .I ENCVTM,ENCVTS D ; convert to pointer
  1. ..I ENFL="EQ",ENLOC["E" K ^ENG(6914,"D",ENLOC,ENDA) S $P(^ENG(6914,ENDA,3),U,5)=""
  1. ..S DIE=$S(ENFL="EQ":"^ENG(6914,",1:"^ENG(6920,"),DA=ENDA
  1. ..S DR=$S(ENFL="EQ":"24",1:"3")_"////"_ENSPDA D ^DIE
  1. .I ENCVTM,'ENCVTS,$E(ENLOC,1)'="*" D ; add leading *
  1. ..S $P(@ENODE,U,ENPIECE)="*"_$P(@ENODE,U,ENPIECE)
  1. ..K @(ENXRF_"ENLOC,ENDA)") ; old x-ref
  1. ..S @(ENXRF_"""*"_ENLOC_""","_ENDA_")")="" ; new x-ref
  1. S ENT("REC")=ENT("REC")+ENT("REC_IN_LOC")
  1. I ENCVTS S ENT("REC_CVT")=ENT("REC_CVT")+ENT("REC_IN_LOC")
  1. 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"),!
  1. I $Y+4>IOSL D HDR
  1. Q
  1. HDR ; page header
  1. I $$S^%ZTLOAD S (END,ZTSTOP)=1 Q
  1. I ENPG,$E(IOST,1,2)="C-" S DIR(0)="E" D ^DIR K DIR S END='Y Q:END
  1. W:'($E(IOST,1,2)'="C-"&'ENPG) @IOF
  1. S ENPG=ENPG+1
  1. W ?5,"Free-Text Values in ",ENFLNM," LOCATION Fields"
  1. W ?60,ENDATE,?73,"page ",ENPG,!!
  1. W ?5,"Free-Text Location",?30,"Count"
  1. W ?40,"Convert"_$S(ENCVTM:"ed?",1:"ible?"),!
  1. W ?5,"------------------",?30,"-----",?40,"------------",!!
  1. Q