1 | GPLCCR ; CCDCCR/GPL - CCR MAIN PROCESSING; 6/6/08
|
---|
2 | ;;0.1;CCDCCR;nopatch;noreleasedate
|
---|
3 | ;
|
---|
4 | ; EXPORT A CCR
|
---|
5 | ;
|
---|
6 | EXPORT ; EXPORT ENTRY POINT FOR CCR
|
---|
7 | ; Select a patient for real.
|
---|
8 | S DIC=2,DIC(0)="AEMQ" D ^DIC
|
---|
9 | I Y<1 Q ; EXIT
|
---|
10 | S DFN=$P(Y,U,1) ; SET THE PATIENT
|
---|
11 | N CCRGLO
|
---|
12 | D CCRRPC(.CCRGLO,DFN,"CCR")
|
---|
13 | S OARY=$NA(^TMP($J,DFN,"CCR",1))
|
---|
14 | S ONAM="PAT_"_DFN_"_CCR_V1.xml"
|
---|
15 | S ODIR="/home/glilly/CCROUT"
|
---|
16 | D OUTPUT^GPLXPATH(OARY,ONAM,ODIR)
|
---|
17 | Q
|
---|
18 | ;
|
---|
19 | CCRRPC(CCRGRTN,DFN,CCRPART) ; RPC ENTRY POINT FOR CCR OUTPUT
|
---|
20 | S DEBUG=0
|
---|
21 | S TGLOBAL=$NA(^TMP($J,"TEMPLATE")) ; GLOBAL FOR STORING TEMPLATE
|
---|
22 | S CCRGLO=$NA(^TMP($J,DFN,"CCR")) ; GLOBAL FOR BUILDING THE CCR
|
---|
23 | S ACTGLO=$NA(^TMP($J,DFN,"ACTORS")); GLOBAL FOR ALL ACTORS IN CCR
|
---|
24 | ; TO GET PART OF THE CCR RETURNED, PASS CCRPART="PROBLEMS" ETC
|
---|
25 | S CCRGRTN=$NA(^TMP($J,DFN,CCRPART)) ; RTN GLO NM OF PART OR ALL OF CCR
|
---|
26 | D LOAD^GPLCCR0(TGLOBAL) ; LOAD THE CCR TEMPLATE
|
---|
27 | D CP^GPLXPATH(TGLOBAL,CCRGLO) ; COPY THE TEMPLATE TO THE CCR GLOBAL
|
---|
28 | ;
|
---|
29 | ; DELETE THE BODY, ACTORS AND SIGNATURES SECTIONS FROM THE CCR GLOBAL
|
---|
30 | ; THESE WILL BE POPULATED AFTER CALLS TO THE XPATH PROCESSING ROUTINES
|
---|
31 | D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Body")
|
---|
32 | D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Actors")
|
---|
33 | D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Signatures")
|
---|
34 | I DEBUG F I=1:1:@CCRGLO@(0) W @CCRGLO@(I),!
|
---|
35 | ;
|
---|
36 | D CCRHDR(CCRGLO,DFN) ; MAP HEADER VARIABLES
|
---|
37 | S CCRXTAB="^TMP($J,""CCRSTEP"")" ; GLOBAL TO STORE CCR PROCESSING STEPS
|
---|
38 | D INITSTPS(CCRXTAB) ; INITIALIZED CCR PROCESSING STEPS
|
---|
39 | N I,XI,TAG,RTN,CALL,XPATH,IXML,OXML,INXML,CCRBLD
|
---|
40 | F I=1:1:@CCRXTAB@(0) D ; PROCESS THE CCR BODY SECTIONS
|
---|
41 | . S XI=@CCRXTAB@(I) ; CALL COPONENTS TO PARSE
|
---|
42 | . S RTN=$P(XI,";",2) ; NAME OF ROUTINE TO CALL
|
---|
43 | . S TAG=$P(XI,";",1) ; LABEL INSIDE ROUTINE TO CALL
|
---|
44 | . S XPATH=$P(XI,";",3) ; XPATH TO XML TO PASS TO ROUTINE
|
---|
45 | . D QUERY^GPLXPATH(TGLOBAL,XPATH,"INXML") ; EXTRACT XML TO PASS
|
---|
46 | . S IXML="INXML"
|
---|
47 | . S OXML=$P(XI,";",4) ; ARRAY FOR SECTION VALUES
|
---|
48 | . ; W OXML,!
|
---|
49 | . S CALL="D "_TAG_"^"_RTN_"(IXML,DFN,OXML)" ; SETUP THE CALL
|
---|
50 | . W "RUNNING ",CALL,!
|
---|
51 | . X CALL
|
---|
52 | . ; NOW INSERT THE RESULTS IN THE CCR BUFFER
|
---|
53 | . D INSERT^GPLXPATH(CCRGLO,OXML,"//ContinuityOfCareRecord/Body")
|
---|
54 | . I DEBUG F GPLI=1:1:@OXML@(0) W @OXML@(GPLI),!
|
---|
55 | . D ACTLST^GPLCCR(CCRGLO,ACTGLO)
|
---|
56 | Q
|
---|
57 | ;
|
---|
58 | INITSTPS(TAB) ; INITIALIZE CCR PROCESSING STEPS
|
---|
59 | ; TAB IS PASSED BY NAME
|
---|
60 | ; W "TAB= ",TAB,!
|
---|
61 | ; D PUSH^GPLXPATH(TAB,"EXTRACT;GPLVITALS;//ContinuityOfCareRecord/Body/VitalSigns;^TMP($J,DFN,""VITALS"")")
|
---|
62 | D PUSH^GPLXPATH(TAB,"EXTRACT;GPLPROBS;//ContinuityOfCareRecord/Body/Problems;^TMP($J,DFN,""PROBLEMS"")")
|
---|
63 | Q
|
---|
64 | ;
|
---|
65 | CCRHDR(CXML,DFN) ; MAP HEADER VARIABLES: FROM, TO ECT
|
---|
66 | N VMAP S VMAP=$NA(^TMP($J,DFN,"HEADER"))
|
---|
67 | ; K @VMAP
|
---|
68 | S @VMAP@("ACTORPATIENT")="ACTORPATIENT_"_DFN
|
---|
69 | S @VMAP@("ACTORFROM")="ACTORPROVIDER_"_DUZ ; FROM DUZ - ???
|
---|
70 | S @VMAP@("ACTORFROM2")="ACTORPROVIDER_"_DUZ ; NEED A BETTER WAY
|
---|
71 | S @VMAP@("ACTORTO")="ACTORPATIENT_"_DFN ; FOR TEST PURPOSES,
|
---|
72 | ; THIS IS THE USE CASE FOR THE PHR WHERE "TO" IS THE PATIENT
|
---|
73 | N CTMP
|
---|
74 | D MAP^GPLXPATH(CXML,VMAP,"CTMP")
|
---|
75 | D CP^GPLXPATH("CTMP",CXML)
|
---|
76 | Q
|
---|
77 | ;
|
---|
78 | ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
|
---|
79 | ; AXML AND ACTRTN ARE PASSED BY NAME
|
---|
80 | N I,J,K
|
---|
81 | K @ACTRTN ; CLEAR RETURN ARRAY
|
---|
82 | F I=1:1:@AXML@(0) D ; SCAN ALL LINES
|
---|
83 | . I @AXML@(I)?.E1"<ActorID>".E D ; THERE IS AN ACTOR ON THIS LINE
|
---|
84 | . . S J=$P($P(@AXML@(I),"<ActorID>",2),"</ActorID>",1)
|
---|
85 | . . W "<ActorID>=>",J,!
|
---|
86 | . . S K(J)="" ; HASHING ACTOR TO GET RID OF MULTIPLES
|
---|
87 | S I="" ; GOING TO $O THROUGH THE HASH
|
---|
88 | F J=0:0 D Q:$O(K(I))=""
|
---|
89 | . S I=$O(K(I)) ; WALK THROUGH THE HASH OF ACTORS
|
---|
90 | . D PUSH^GPLXPATH(ACTRTN,I) ; ADD THE ACTOR TO THE RETURN ARRAY
|
---|
91 | Q
|
---|
92 | ;
|
---|
93 | TEST ; RUN ALL THE TEST CASES
|
---|
94 | ;D TESTALL^GPLUNIT("GPLCCR")
|
---|
95 | D ZTEST^GPLCCR("PROBLEMS")
|
---|
96 | W "TESTING RETURNED FROM PROBLMES",!
|
---|
97 | D ZTEST^GPLCCR("CCR")
|
---|
98 | Q
|
---|
99 | ;
|
---|
100 | ZTEST(WHICH) ; RUN ONE SET OF TESTS
|
---|
101 | N ZTMP
|
---|
102 | D ZLOAD^GPLUNIT("ZTMP","GPLCCR")
|
---|
103 | D ZTEST^GPLUNIT(.ZTMP,WHICH)
|
---|
104 | Q
|
---|
105 | ;
|
---|
106 | TLIST ; LIST THE TESTS
|
---|
107 | N ZTMP
|
---|
108 | D ZLOAD^GPLUNIT("ZTMP","GPLCCR")
|
---|
109 | D TLIST^GPLUNIT(.ZTMP)
|
---|
110 | Q
|
---|
111 | ;
|
---|
112 | ;;><TEST>
|
---|
113 | ;;><PROBLEMS>
|
---|
114 | ;;>>>K GPL S GPL=""
|
---|
115 | ;;>>>D CCRRPC^GPLCCR(.GPL,"2","PROBLEMS")
|
---|
116 | ;;>>?@GPL@(@GPL@(0))="</Problems>"
|
---|
117 | ;;><CCR>
|
---|
118 | ;;>>>K GPL S GPL=""
|
---|
119 | ;;>>>D CCRRPC^GPLCCR(.GPL,"2","CCR")
|
---|
120 | ;;>>?@GPL@(@GPL@(0))="</ContinutiyOfCareRecord>"
|
---|
121 | ;;><ACTLST>
|
---|
122 | ;;>>>N TCCR
|
---|
123 | ;;>>>D CCRRPC^GPLCCR(.TCCR,"2","CCR")
|
---|
124 | ;;>>>D ACTLST^GPLCCR("TCCR","ACTTEST")
|
---|
125 | ;;></TEST>
|
---|