1 | HDISXML ; CT/GRR - XML UTILITY ROUTINE; 16-FEB-2004 ; 02 Mar 2005 4:17 PM
|
---|
2 | ;;1.0;HEALTH DATA & INFORMATICS;;Feb 22, 2005
|
---|
3 | ;
|
---|
4 | XMLOUT(HDISTEMP,HDISE,HDISF,HDIST,HDISERR) ;
|
---|
5 | ;;Input Parameters (all required)
|
---|
6 | ;;
|
---|
7 | ;;HDISTEMP - IEN of XML Template
|
---|
8 | ;;
|
---|
9 | ;;HDISE - Element Number(s), separated by a comma, to be formatted
|
---|
10 | ;; and moved to the output array
|
---|
11 | ;;
|
---|
12 | ;;HDISF - Reference of the input array
|
---|
13 | ;;
|
---|
14 | ;;HDIST - Reference of the target array
|
---|
15 | ;;
|
---|
16 | ;;HDISERR - reference of error variable
|
---|
17 | ;;
|
---|
18 | ;;
|
---|
19 | I HDISTEMP=""!(HDISE="")!(HDISF="")!(HDIST="") S @HDISERR="Missing Input Parameter",HDISOK=0 G XMLOUTQ
|
---|
20 | N BLANK,CLOSE,DA,ELEV,HASKID,HDENT,HDISFE,HDISFO,HDISFT,HDISOK,IEN,IND,ISMULTI,LASTIEN,LINE,OPEN,QUOTE,REQ,TEXTIN,TRANSTXT,Y,ENAME
|
---|
21 | S:HDISE'["," HDISE=HDISE_","
|
---|
22 | D INIT
|
---|
23 | F I=1:1 S E=$P(HDISE,",",I) Q:E="" D
|
---|
24 | .S (HDISFT,HDISFE)=$NA(@HDISF@(E))
|
---|
25 | .I E["/" S E=$P(E,"/",1) D CLOSE(HDISTEMP,E,HDISF,HDIST,.HDERR) Q
|
---|
26 | .D PROCESS(E)
|
---|
27 | XMLOUTQ Q
|
---|
28 | ;
|
---|
29 | GETED(E) ;
|
---|
30 | S IEN=$O(^HDIS(7115.3,HDISTEMP,"SEQ","B",E,0))
|
---|
31 | S Y(0)=$G(^HDIS(7115.3,HDISTEMP,"SEQ",IEN,0))
|
---|
32 | S REQ=$P(Y(0),"^",3),ENAME=$P(Y(0),"^",2),ELEV=$P(Y(0),"^",5),HASKID=$P(Y(0),"^",6),ISMULTI=$P(Y(0),"^",7)
|
---|
33 | Q
|
---|
34 | ;
|
---|
35 | PROCESS(E) ;
|
---|
36 | D GETED(E)
|
---|
37 | I 'ISMULTI D FORMAT Q
|
---|
38 | S DA=0 F S DA=$O(@HDISFE@(DA)) Q:DA'>0 S HDISF=$NA(@HDISFE@(DA)) D FORMAT
|
---|
39 | Q
|
---|
40 | INIT ;
|
---|
41 | ;N OPEN,CLOSE,QUOTE,IND,REQ,BLANK
|
---|
42 | S OPEN="<",CLOSE=">",QUOTE="""",BLANK=" ",$P(BLANK," ",100)=" "
|
---|
43 | S IND=$P(^HDIS(7115.3,HDISTEMP,0),"^",5)
|
---|
44 | S LASTIEN=$O(@HDIST@(9999999),-1)
|
---|
45 | S HDISOK=1,HDISFO=HDISF
|
---|
46 | Q
|
---|
47 | ;
|
---|
48 | FORMAT ;
|
---|
49 | I 'HASKID S TEXTIN=@HDISFE Q:TEXTIN=""&'(REQ) S TRANSTXT=$$TRANSLAT(TEXTIN)
|
---|
50 | S LINE=""
|
---|
51 | S LINE=$E(BLANK,1,(IND*ELEV))_OPEN_ENAME_CLOSE
|
---|
52 | I 'HASKID S LINE=LINE_TRANSTXT_OPEN_"/"_ENAME_CLOSE
|
---|
53 | S LASTIEN=LASTIEN+1
|
---|
54 | S @HDIST@(LASTIEN)=LINE
|
---|
55 | Q
|
---|
56 | ;
|
---|
57 | CLOSE(HDISTEMP,HDISE,HDISF,HDIST,HDERR) ;
|
---|
58 | D INIT
|
---|
59 | D GETED(HDISE)
|
---|
60 | S LINE=""
|
---|
61 | S LINE=$E(BLANK,1,(IND*ELEV))_OPEN_"/"_ENAME_CLOSE
|
---|
62 | S LASTIEN=LASTIEN+1
|
---|
63 | S @HDIST@(LASTIEN)=LINE
|
---|
64 | Q
|
---|
65 | ;
|
---|
66 | TRANSLAT(X) ;
|
---|
67 | N HDPAT,I
|
---|
68 | I X["&" F I=1:1 Q:I=$L(X) I $E(X,I)="&" S X=$E(X,1,(I-1))_"&"_$E(X,I+1,$L(X))
|
---|
69 | F HDPAT="'","""",">","<" F Q:X'[HDPAT D
|
---|
70 | .S HDENT=""
|
---|
71 | .I HDPAT="'" S HDENT="'"
|
---|
72 | .I HDPAT="""" S HDENT="""
|
---|
73 | .I HDPAT=">" S HDENT=">"
|
---|
74 | .I HDPAT="<" S HDENT="<"
|
---|
75 | .Q:HDENT=""
|
---|
76 | .S X=$P(X,HDPAT,1)_HDENT_$P(X,HDPAT,2,99)
|
---|
77 | Q X
|
---|
78 | ;
|
---|