source: WorldVistAEHR/trunk/r/HEALTHEVET_DESKTOP-XHD/XHDLXM.m@ 1361

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

initial load of WorldVistAEHR

File size: 1.6 KB
RevLine 
[613]1XHDLXM ; SLC/JER - XML Library calls for CM ; 25 Jul 2003 9:42 AM
2 ;;1.0;HEALTHEVET DESKTOP;;Jul 15, 2003
3XMLHDR(XHDY,ROOTEL,XHDI) ; Create XML Header for Mresult pass root element
4 ; as ROOTEL
5 S XHDI=+$G(XHDI)+1
6 S @XHDY@(XHDI)="<?xml version=""1.0"" encoding=""UTF-8"" ?>"
7 S XHDI=XHDI+1
8 S @XHDY@(XHDI)="<"_ROOTEL_">"
9 Q
10 ;
11XMLFOOT(XHDY,ROOTEL,XHDI) ; Appends XML closing tags
12 S XHDI=+$G(XHDI)+1,@XHDY@(XHDI)="</"_ROOTEL_">"
13 Q
14 ;
15ESCAPE(DATA) ; Escapes XML special characters in data
16 N SPEC
17 S SPEC("<")="&lt;",SPEC(">")="&gt;",SPEC("""")="&quot;"
18 S SPEC("'")="&apos;",SPEC("&")="&amp;"
19 Q $$REPLACE^XLFSTR(DATA,.SPEC)
20 ;
21FILENTRY(XHDY,FILE,IENS,FLDS,INCID,XHDI) ; Produce XML representation of entry
22 N XHDF,XHDKI,PCATAG S XHDF=0,XHDI=+$G(XHDI)
23 I +$G(INCID) D
24 . S XHDI=XHDI+1,@XHDY@("XMLDOC",XHDI)="<id>"_+IENS_"</id>"
25 D GETS^DIQ(FILE,IENS,$$FLDS(.FLDS),"IE",XHDY)
26 F S XHDF=$O(@XHDY@(FILE,IENS,XHDF)) Q:XHDF'>0 D
27 . N TAG,VAL
28 . S TAG=$TR($$FLDNAME(XHDF,FILE)," /","")
29 . S VAL=$G(@XHDY@(FILE,IENS,XHDF,$S($L(FLDS(XHDF),U)=2:$P(FLDS(XHDF),U,2),1:"E")))
30 . S XHDI=XHDI+1,@XHDY@("XMLDOC",XHDI)="<"_TAG_">"_VAL_"</"_TAG_">"
31 K @XHDY@(FILE)
32 Q
33FLDS(FLDS) ; Iterate through field list, build DR-string
34 N XHDI,XHDY S XHDI=0,XHDY=""
35 F S XHDI=$O(FLDS(XHDI)) Q:+XHDI'>0 D
36 . S XHDY=XHDY_$S(XHDY="":"",1:";")_XHDI
37 Q XHDY
38FLDNAME(XHDFN,FILENUM) ; Resolve field names
39 Q $$MIXED($P($G(^DD(FILENUM,XHDFN,0)),U))
40MIXED(X) ; Return Mixed Case X
41 N XHDI,WORD,TMP
42 S TMP="" F XHDI=1:1:$L(X," ") S WORD=$$LOW^XLFSTR($P(X," ",XHDI)),$E(WORD)=$S(XHDI=1:$E(WORD),1:$$UP^XLFSTR($E(WORD))),TMP=$S(TMP="":WORD,1:TMP_WORD)
43 Q TMP
Note: See TracBrowser for help on using the repository browser.