source: WorldVistAEHR/trunk/r/CLINICAL_REMINDERS-PXRM/PXRMEXU3.m@ 701

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

initial load of WorldVistAEHR

File size: 2.6 KB
Line 
1PXRMEXU3 ; SLC/PKR - Reminder exchange XML utilities, #3. ;12/22/2004
2 ;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
3 ;===========================================
4DESC(XMLSRC,DESC) ;Find the description in the XML source and load it
5 ;into DESC.
6 N DFOUND,DONE,IND,JND,SAVE,TAG,XMLLINE
7 S (DFOUND,DONE,JND,SAVE)=0
8 F IND=1:1 Q:DONE D
9 . S XMLLINE=@XMLSRC@(IND,0)
10 . I 'DFOUND S TAG=$$GETTAG(XMLLINE)
11 . I TAG="<DESCRIPTION>" S DFOUND=1,TAG=""
12 . I DFOUND,'SAVE,XMLLINE["<![CDATA[" S SAVE=1 Q
13 . I SAVE,XMLLINE["]]>" S SAVE=0
14 . I 'SAVE,XMLLINE["</DESCRIPTION>" S DONE=1 Q
15 . I SAVE S JND=JND+1,DESC(1,JND,0)=XMLLINE
16 S DESC(1,0)=U_U_U_JND
17 Q
18 ;
19 ;===========================================
20FROMXML(TEXT) ;If text contains any of the XML predefined entity references
21 ;convert them to the standard characters.
22 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&amp;","&")
23 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&lt;","<")
24 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&gt;",">")
25 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&quot;","""")
26 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&apos;","'")
27 Q TEXT
28 ;
29 ;===========================================
30GETTAG(XMLLINE) ;Return the XML tag.
31 N END,START,VALUE
32 S START=$F(XMLLINE,"<",1)-1
33 S END=$F(XMLLINE,">",START)-1
34 S VALUE=$E(XMLLINE,START,END)
35 Q VALUE
36 ;
37 ;===========================================
38GETTAGV(XMLLINE,TAG,FROMXML) ;Return the value associated with the XML tag.
39 N END,ENDTAG,START,TAGL,VALUE
40 S TAGL=$L(TAG)
41 S ENDTAG="</"_$E(TAG,2,TAGL)
42 S START=$F(XMLLINE,TAG,1)
43 S END=$F(XMLLINE,ENDTAG,START)-(TAGL+2)
44 S VALUE=$E(XMLLINE,START,END)
45 I $G(FROMXML) S VALUE=$$FROMXML(VALUE)
46 Q VALUE
47 ;
48 ;===========================================
49GETATTR(XMLLINE,ATTR) ;Return the value of attribute ATTR from the XML line
50 ;XMLLINE
51 N END,START,VALUE
52 S ATTR=ATTR_"="""
53 S START=$F(XMLLINE,ATTR,1)
54 S END=$F(XMLLINE,"""",START)-2
55 S VALUE=$E(XMLLINE,START,END)
56 Q VALUE
57 ;
58 ;===========================================
59KEYWORD(XMLSRC,KEYWORD) ;Find the keywords in the XML source and load it
60 ;into KEYWORD.
61 N DONE,IND,JND,TAG,XMLLINE
62 S (DONE,JND)=0
63 F IND=1:1 Q:DONE D
64 . S XMLLINE=@XMLSRC@(IND,0)
65 . S TAG=$$GETTAG(XMLLINE)
66 . I TAG="<KEYWORD>" D Q
67 .. S JND=JND+1
68 .. S KEYWORD(1,JND,0)=$$GETTAGV(XMLLINE,TAG,1)
69 . I TAG="</KEYWORDS>" S DONE=1 Q
70 S KEYWORD(1,0)=U_U_U_JND
71 Q
72 ;
73 ;===========================================
74TOXML(TEXT) ;If text contains any of the XML markup characters convert
75 ;them to the predefined entity reference.
76 S TEXT=$$STRREP^PXRMUTIL(TEXT,"&","&amp;")
77 S TEXT=$$STRREP^PXRMUTIL(TEXT,"<","&lt;")
78 S TEXT=$$STRREP^PXRMUTIL(TEXT,">","&gt;")
79 S TEXT=$$STRREP^PXRMUTIL(TEXT,"""","&quot;")
80 S TEXT=$$STRREP^PXRMUTIL(TEXT,"'","&apos;")
81 Q TEXT
82 ;
Note: See TracBrowser for help on using the repository browser.