source: ccr/branches/ohum/p/C0CTIU1.m@ 1476

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

Update based on OHUM's latest routines

File size: 3.0 KB
Line 
1C0CTIU1 ; C0C/ELN - PROCESSING FOR TIU NOTES Contd. ; 19/10/2010
2 ;;1.2;C0C;;May 11, 2012;Build 47
3 ;ELN UTILITY PROGRAM TO SUPPORT C0CTIU
4C0CDATE(EDTE) ; Converts external date to internal date format
5 ; INPUT : EXTERNAL DATE (TIME IS OPTIONAL)
6 ; OUTOUT: INTERNAL DATE, STORAGE FORMAT YYYMMMDD
7 ; (TIME WILL BE RETURNED IF INCLUDED WITH INPUT)
8 ;
9 Q:'$D(EDTE) -1
10 N X,%DT,Y
11 S X=EDTE
12 S %DT="TS"
13 D ^%DT
14 Q Y
15 ;
16XMAP(IXML,INARY,OXML) ; SUBSTITUTE MULTIPLE @@X@@ VARS WITH VALUES IN INARY
17 ; AND PUT THE RESULTS IN OXML
18 N XCNT
19 I '$D(DEBUG) S DEBUG=0
20 I '$D(IXML) W "MALFORMED XML PASSED TO MAP",! Q
21 I '$D(@IXML@(0)) D ; INITIALIZE COUNT
22 . S XCNT=$O(@IXML@(""),-1)
23 E S XCNT=@IXML@(0) ;COUNT
24 I $O(@INARY@(""))="" W "EMPTY ARRAY PASSED TO MAP",! Q
25 ;
26 N I,J,TNAM,TVAL,TSTR
27 S @OXML@(0)=XCNT ; TOTAL LINES IN OUTPUT
28 F I=1:1:XCNT D ; LOOP THROUGH WHOLE ARRAY
29 . S @OXML@(I)=@IXML@(I),C0CSLFLG=0 ; COPY THE LINE TO OUTPUT
30 . I @OXML@(I)?.E1"@@".E D ; IS THERE A VARIABLE HERE?
31 . . S TSTR=$P(@IXML@(I),"@@",1) ; INIT TO PART BEFORE VARS
32 . . F J=2:2:10 D Q:$P(@IXML@(I),"@@",J+2)="" ; QUIT IF NO MORE VARS
33 . . . I DEBUG W "IN MAPPING LOOP: ",TSTR,! H 1
34 . . . S TNAM=$P(@OXML@(I),"@@",J) ; EXTRACT THE VARIABLE NAME
35 . . . S TVAL="@@"_$P(@IXML@(I),"@@",J)_"@@" ; DEFAULT UNCHANGED
36 . . . I $D(@INARY@(TNAM)) D ; IS THE VARIABLE IN THE MAP?
37 . . . . I $D(@INARY@(TNAM,"WP")) D Q
38 . . . . . D DOWPFLD(I,J)
39 . . . . I '$D(@INARY@(TNAM,"F")) D ; NOT A SPECIAL FIELD
40 . . . . . S TVAL=@INARY@(TNAM) ; PULL OUT MAPPED VALUE
41 . . . . E D DOFLD() ; PROCESS A FIELD ELAN
42 . . . S TVAL=$$SYMENC^MXMLUTL(TVAL) ;MAKE SURE THE VALUE IS XML SAFE
43 . . . S TSTR=TSTR_TVAL_$P(@IXML@(I),"@@",J+1) ; ADD VAR AND PART AFTER
44 . . I $G(C0CSLFLG)=1 M @OXML@(I)=TSTR Q
45 . . S @OXML@(I)=TSTR ; COPY LINE WITH MAPPED VALUES
46 . . I DEBUG W TSTR H 1
47 I DEBUG W "MAPPED",!
48 K C0CSLFLG
49 Q
50DOWPFLD(I,J) ;WORDPROCESSING FIELD MANIPULATION
51 N C0CTXCNT
52 S C0CTXCNT=0
53 F S C0CTXCNT=$O(@INARY@(TNAM,"WP",C0CTXCNT)) Q:C0CTXCNT="" D
54 . S TSTR(C0CTXCNT)=TSTR_$G(@INARY@(TNAM,"WP",C0CTXCNT))_$P(@IXML@(I),"@@",J+1)
55 S C0CSLFLG=1
56 Q
57DOFLD() ;QUIT
58 Q
59BUILD(BLIST,BDEST) ; A COPY MACHINE THAT TAKE INSTRUCTIONS IN ARRAY BLIST
60 ; WHICH HAVE ARRAY;START;FINISH AND COPIES THEM TO DEST
61 ; DEST IS CLEARED TO START
62 ; USES PUSH TO DO THE COPY
63 N I,WPSEQ
64 K @BDEST
65 F I=1:1:@BLIST@(0) D ; FOR EACH INSTRUCTION IN BLIST
66 . N J,ATMP
67 . S ATMP=$$ARRAY^C0CXPATH(@BLIST@(I))
68 . I $G(DEBUG) W "ATMP=",ATMP,!
69 . I $G(DEBUG) W @BLIST@(I),!
70 . F J=$$START^C0CXPATH(@BLIST@(I)):1:$$FINISH^C0CXPATH(@BLIST@(I)) D ;
71 . . ; FOR EACH LINE IN THIS INSTR
72 . . I $G(DEBUG) W "BDEST= ",BDEST,!
73 . . I $G(DEBUG) W "ATMP= ",@ATMP@(J),!
74 . . I $D(@ATMP@(J,1)),$G(@ATMP@(J))="<Value>@@RESULTTESTVALUE@@</Value>" D Q
75 . . . S WPSEQ=0
76 . . . D PUSH^C0CXPATH(BDEST,"<Value>")
77 . . . F S WPSEQ=$O(@ATMP@(J,WPSEQ)) Q:WPSEQ="" D
78 . . . . D PUSH^C0CXPATH(BDEST,$$SYMENC^MXMLUTL($$XVAL^C0CXPATH(@ATMP@(J,WPSEQ)))_"&#x0A;")
79 . . . D PUSH^C0CXPATH(BDEST,"</Value>")
80 . . D PUSH^C0CXPATH(BDEST,@ATMP@(J))
81 Q
Note: See TracBrowser for help on using the repository browser.