72 lines
3.1 KiB
Mathematica
72 lines
3.1 KiB
Mathematica
GECSXMAP ;WISC/RFJ-build template map ;01 Nov 93
|
|
;;2.0;GCS;;MAR 14, 1995
|
|
W !,"This program deletes template maps and recreates them",!,"from the input templates found in file 2101.4.",!
|
|
N %,GECSITDA
|
|
S XP="Do you want to recreate all template maps"
|
|
S %=$$YN^GECSUTIL(2) I '% Q
|
|
I %=1 D ALLMAPS Q
|
|
; ask template, build map
|
|
F S GECSITDA=$$SELTEMP Q:'GECSITDA D BUILD(GECSITDA)
|
|
Q
|
|
;
|
|
;
|
|
ALLMAPS ; build all maps
|
|
N DIC,GECSITDA,X,Y
|
|
S GECSITDA=0 F S GECSITDA=$O(^GECS(2101.4,GECSITDA)) Q:'GECSITDA D
|
|
. S X=$P(^GECS(2101.4,GECSITDA,0),"^")
|
|
. S DIC=2101.4,DIC(0)="MZ" D ^DIC
|
|
. I Y>0 W !,Y(0,0) D BUILD(GECSITDA)
|
|
Q
|
|
;
|
|
;
|
|
BUILD(GECSITDA) ; build template gecsitda
|
|
N %,GECSMAP,GECSNM
|
|
S GECSNM=$P($G(^GECS(2101.4,GECSITDA,0)),"^") I GECSNM="" W " INPUT TEMPLATE DOES NOT EXIST IN FILE 2101.4." Q
|
|
S %=$O(^DIE("B",GECSNM,0)) I '% W " INPUT TEMPLATE NOT FOUND IN FILEMANAGER." Q
|
|
D GETMAP(%) I '$D(GECSMAP) Q
|
|
K ^GECS(2101.4,GECSITDA,1) F %=1:1 Q:'$D(GECSMAP(%)) S ^GECS(2101.4,GECSITDA,1,%,0)=GECSMAP(%)
|
|
S ^GECS(2101.4,GECSITDA,1,0)="^2101.41^"_(%-1)_"^"_(%-1)
|
|
W ?40,"---Done---"
|
|
Q
|
|
;
|
|
;
|
|
FIELD ; loop fields in dr string
|
|
N GECSMAP1
|
|
F DRPIECE=1:1 S FIELDDA=$P(GECSTRIN,";",DRPIECE) Q:FIELDDA="" I +FIELDDA>0,$D(^DD(2100,+FIELDDA,0)) S DATADICT=^(0) D
|
|
. ; single field
|
|
. I $P(DATADICT,"^",2)?1A.E D Q
|
|
. . S GECSMAP(GECSMAP)=GECSMAP(GECSMAP)_+FIELDDA_";"_$P(DATADICT,"^",4)_"\"
|
|
. . I $L(GECSMAP(GECSMAP))>200 S GECSMAP=GECSMAP+1,GECSMAP(GECSMAP)=""
|
|
. ; multiple field
|
|
. I GECSMAP(GECSMAP)'="" S GECSMAP=GECSMAP+1,GECSMAP(GECSMAP)=""
|
|
. S (GECSGLOB,GECSMAP(GECSMAP))=FIELDDA_","_$P($P(DATADICT,"^",4),";")_","_+$P(DATADICT,"^",2)
|
|
. S GECSTR=DRSTRING(2,+$P(DATADICT,"^",2))
|
|
. S GECSNEXT=1,GECSPIEC=1,GECSMAP1=1
|
|
. F D Q:'GECSPIEC
|
|
. . S FIELDDA=$P(GECSTR,";",GECSPIEC),GECSPIEC=GECSPIEC+1
|
|
. . I +FIELDDA>0,$D(^DD(+$P(DATADICT,"^",2),+FIELDDA,0)) S GECSMAP(GECSMAP,GECSMAP1)=$G(GECSMAP(GECSMAP,GECSMAP1))_+FIELDDA_";"_$P(^(0),"^",4)_"\"
|
|
. . I $P(GECSTR,";",GECSPIEC)="" S GECSTR=$G(DRSTRING(2,+$P(DATADICT,"^",2),GECSNEXT)),GECSNEXT=GECSNEXT+1,GECSPIEC=1 I GECSTR="" S GECSPIEC=0 Q
|
|
. . I $L(GECSMAP(GECSMAP,GECSMAP1))>200 S GECSMAP1=GECSMAP1+1
|
|
. S GECSMAP=GECSMAP+1,GECSMAP(GECSMAP)=""
|
|
Q
|
|
;
|
|
;
|
|
GETMAP(GECSDIE) ; get the template map for input template gecsdie
|
|
; returns gecsmap() array
|
|
N DATADICT,DRPIECE,DRSTRING,FIELDDA,GECSDRDA,GECSGLOB,GECSNEXT,GECSPIEC,GECSTRIN,GECSTR,I,J,K,X
|
|
K GECSMAP
|
|
I '$D(^DIE(GECSDIE)) Q
|
|
F I=0:0 S I=$O(^DIE(GECSDIE,"DR",I)) Q:I="" F J=0:0 S J=$O(^DIE(GECSDIE,"DR",I,J)) Q:J="" S DRSTRING(I,J)=^DIE(GECSDIE,"DR",I,J) F K=0:0 S K=$O(^DIE(GECSDIE,"DR",I,J,K)) Q:'K S DRSTRING(I,J,K)=^(K)
|
|
I '$D(DRSTRING(1,2100)) W " NOT AN INPUT TEMPLATE FOR FILE 2100! MAP NOT BUILT!",! Q
|
|
S GECSMAP=1,GECSMAP(1)=""
|
|
S GECSTRIN=DRSTRING(1,2100) D FIELD
|
|
S GECSDRDA=0 F S GECSDRDA=$O(DRSTRING(1,2100,GECSDRDA)) Q:'GECSDRDA S GECSTRIN=DRSTRING(1,2100,GECSDRDA) D FIELD
|
|
Q
|
|
;
|
|
;
|
|
SELTEMP() ; select template
|
|
N %,%Y,DA,DIC,DLAYGO,X,Y
|
|
S DIC("A")="Select Template Name: ",DIC=2101.4,DIC(0)="LAEMNZ",DLAYGO=2101.4
|
|
W ! D ^DIC
|
|
Q $S(+Y>0:+Y,1:0)
|