source: ccr/trunk/p/C0CTIU1.m@ 1742

Last change on this file since 1742 was 1586, checked in by Sam Habiel, 12 years ago

Changed license to AGPL. Some clean-up for XINDEX

File size: 3.7 KB
RevLine 
[1544]1C0CTIU1 ; C0C/ELN - PROCESSING FOR TIU NOTES Contd. ; 19/10/2010
[1586]2 ;;1.2;CCD/CCR GENERATION UTILITIES;;Oct 30, 2012;Build 50
[1544]3 ;ELN UTILITY PROGRAM TO SUPPORT C0CTIU
[1586]4 ; (C) ELN 2010.
5 ;
6 ; This program is free software: you can redistribute it and/or modify
7 ; it under the terms of the GNU Affero General Public License as
8 ; published by the Free Software Foundation, either version 3 of the
9 ; License, or (at your option) any later version.
10 ;
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU Affero General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU Affero General Public License
17 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 ;
[1544]19C0CDATE(EDTE) ; Converts external date to internal date format
20 ; INPUT : EXTERNAL DATE (TIME IS OPTIONAL)
21 ; OUTOUT: INTERNAL DATE, STORAGE FORMAT YYYMMMDD
22 ; (TIME WILL BE RETURNED IF INCLUDED WITH INPUT)
23 ;
24 Q:'$D(EDTE) -1
25 N X,%DT,Y
26 S X=EDTE
27 S %DT="TS"
28 D ^%DT
29 Q Y
30 ;
31XMAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
32 ; AND PUT THE RESULTS IN OXML
33 N XCNT
34 I '$D(DEBUG) S DEBUG=0
35 I '$D(IXML) W "MALFORMED XML PASSED TO MAP",! Q
36 I '$D(@IXML@(0)) D ; INITIALIZE COUNT
37 . S XCNT=$O(@IXML@(""),-1)
38 E S XCNT=@IXML@(0) ;COUNT
39 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q
40 ;
41 N I,J,TNAM,TVAL,TSTR
42 S @OXML@(0)=XCNT ; TOTAL LINES IN OUTPUT
43 F I=1:1:XCNT D ; LOOP THROUGH WHOLE ARRAY
44 . S @OXML@(I)=@IXML@(I),C0CSLFLG=0 ; COPY THE LINE TO OUTPUT
45 . I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?
46 . . S TSTR=$P(@IXML@(I),"@@",1) ; INIT TO PART BEFORE VARS
47 . . F J=2:2:10 D Q:$P(@IXML@(I),"@@",J+2)="" ; QUIT IF NO MORE VARS
48 . . . I DEBUG W "IN MAPPING LOOP: ",TSTR,! H 1
49 . . . S TNAM=$P(@OXML@(I),"@@",J) ; EXTRACT THE VARIABLE NAME
50 . . . S TVAL="@@"_$P(@IXML@(I),"@@",J)_"@@" ; DEFAULT UNCHANGED
51 . . . I $D(@INARY@(TNAM)) D ; IS THE VARIABLE IN THE MAP?
52 . . . . I $D(@INARY@(TNAM,"WP")) D Q
53 . . . . . D DOWPFLD(I,J)
54 . . . . I '$D(@INARY@(TNAM,"F")) D ; NOT A SPECIAL FIELD
55 . . . . . S TVAL=@INARY@(TNAM) ; PULL OUT MAPPED VALUE
56 . . . . E D DOFLD() ; PROCESS A FIELD ELAN
57 . . . S TVAL=$$SYMENC^MXMLUTL(TVAL) ;MAKE SURE THE VALUE IS XML SAFE
58 . . . S TSTR=TSTR_TVAL_$P(@IXML@(I),"@@",J+1) ; ADD VAR AND PART AFTER
59 . . I $G(C0CSLFLG)=1 M @OXML@(I)=TSTR Q
60 . . S @OXML@(I)=TSTR ; COPY LINE WITH MAPPED VALUES
61 . . I DEBUG W TSTR H 1
62 I DEBUG W "MAPPED",!
63 K C0CSLFLG
64 Q
65DOWPFLD(I,J) ;WORDPROCESSING FIELD MANIPULATION
66 N C0CTXCNT
67 S C0CTXCNT=0
68 F S C0CTXCNT=$O(@INARY@(TNAM,"WP",C0CTXCNT)) Q:C0CTXCNT="" D
69 . S TSTR(C0CTXCNT)=TSTR_$G(@INARY@(TNAM,"WP",C0CTXCNT))_$P(@IXML@(I),"@@",J+1)
70 S C0CSLFLG=1
71 Q
72DOFLD() ;QUIT
73 Q
74BUILD(BLIST,BDEST) ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
75 ; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST
76 ; DEST IS CLEARED TO START
77 ; USES PUSH TO DO THE COPY
78 N I,WPSEQ
79 K @BDEST
80 F I=1:1:@BLIST@(0) D ; FOR EACH INSTRUCTION IN BLIST
81 . N J,ATMP
82 . S ATMP=$$ARRAY^C0CXPATH(@BLIST@(I))
83 . I $G(DEBUG) W "ATMP=",ATMP,!
84 . I $G(DEBUG) W @BLIST@(I),!
85 . F J=$$START^C0CXPATH(@BLIST@(I)):1:$$FINISH^C0CXPATH(@BLIST@(I)) D ;
86 . . ; FOR EACH LINE IN THIS INSTR
87 . . I $G(DEBUG) W "BDEST= ",BDEST,!
88 . . I $G(DEBUG) W "ATMP= ",@ATMP@(J),!
89 . . I $D(@ATMP@(J,1)),$G(@ATMP@(J))="<Value>@@RESULTTESTVALUE@@</Value>" D Q
90 . . . S WPSEQ=0
91 . . . D PUSH^C0CXPATH(BDEST,"<Value>")
92 . . . F S WPSEQ=$O(@ATMP@(J,WPSEQ)) Q:WPSEQ="" D
93 . . . . D PUSH^C0CXPATH(BDEST,$$SYMENC^MXMLUTL($$XVAL^C0CXPATH(@ATMP@(J,WPSEQ)))_"&#x0A;")
94 . . . D PUSH^C0CXPATH(BDEST,"</Value>")
95 . . D PUSH^C0CXPATH(BDEST,@ATMP@(J))
96 Q
Note: See TracBrowser for help on using the repository browser.