Index: ccr/trunk/p/GPLCCR.m
===================================================================
--- ccr/trunk/p/GPLCCR.m	(revision 16)
+++ ccr/trunk/p/GPLCCR.m	(revision 30)
@@ -7,4 +7,5 @@
         ; Select a patient for real.
         S DIC=2,DIC(0)="AEMQ" D ^DIC
+        I Y<1 Q ; EXIT
         S DFN=$P(Y,U,1) ; SET THE PATIENT
         N CCRGLO
@@ -12,5 +13,5 @@
         S OARY=$NA(^TMP($J,DFN,"CCR",1))
         S ONAM="PAT_"_DFN_"_CCR_V1.xml"
-        S ODIR="/home/wvehr1/EHR/CCR"
+        S ODIR="/home/glilly/CCROUT"
         D OUTPUT^GPLXPATH(OARY,ONAM,ODIR)
         Q
@@ -20,4 +21,5 @@
         S TGLOBAL=$NA(^TMP($J,"TEMPLATE")) ; GLOBAL FOR STORING TEMPLATE
         S CCRGLO=$NA(^TMP($J,DFN,"CCR")) ; GLOBAL FOR BUILDING THE CCR
+        S ACTGLO=$NA(^TMP($J,DFN,"ACTORS")); GLOBAL FOR ALL ACTORS IN CCR
         ; TO GET PART OF THE CCR RETURNED, PASS CCRPART="PROBLEMS" ETC
         S CCRGRTN=$NA(^TMP($J,DFN,CCRPART)) ; RTN GLO NM OF PART OR ALL OF CCR
@@ -26,10 +28,11 @@
         ;
         ; DELETE THE BODY, ACTORS AND SIGNATURES SECTIONS FROM THE CCR GLOBAL
-        ; THESE WILL BE POPULATED WITH CALLS TO THE XPATH PROCESSING ROUTINES
+        ; THESE WILL BE POPULATED AFTER CALLS TO THE XPATH PROCESSING ROUTINES
         D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Body")
         D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Actors")
         D REPLACE^GPLXPATH(CCRGLO,"","//ContinuityOfCareRecord/Signatures")
-        F I=1:1:@CCRGLO@(0) W @CCRGLO@(I),!
+        I DEBUG F I=1:1:@CCRGLO@(0) W @CCRGLO@(I),!
         ;
+        D CCRHDR(CCRGLO,DFN) ; MAP HEADER VARIABLES
         S CCRXTAB="^TMP($J,""CCRSTEP"")" ; GLOBAL TO STORE CCR PROCESSING STEPS
         D INITSTPS(CCRXTAB) ; INITIALIZED CCR PROCESSING STEPS
@@ -48,14 +51,7 @@
         . X CALL
         . ; NOW INSERT THE RESULTS IN THE CCR BUFFER
-        . ; D INSERT^GPLXPATH(CCRGLO,OXML,"//ContinuityOfCareRecord/Body")
+        . D INSERT^GPLXPATH(CCRGLO,OXML,"//ContinuityOfCareRecord/Body")
         . I DEBUG F GPLI=1:1:@OXML@(0) W @OXML@(GPLI),!
-        . D QOPEN^GPLXPATH("CCRBLD",CCRGLO,"//ContinuityOfCareRecord/Body")
-        . D QUEUE^GPLXPATH("CCRBLD",OXML,1,@OXML@(0))
-        . D QCLOSE^GPLXPATH("CCRBLD",CCRGLO,"//ContinuityOfCareRecord/Body")
-        . I DEBUG W "GOING TO BUILD CCR",!
-        . N CCRTMP
-        . D BUILD^GPLXPATH("CCRBLD","CCRTMP")
-        . I DEBUG F GPLI=1:1:CCRTMP(0) W CCRTMP(GPLI),!
-        . D CP^GPLXPATH("CCRTMP",CCRGLO)
+        . D ACTLST^GPLCCR(CCRGLO,ACTGLO)
         Q
         ;
@@ -67,11 +63,37 @@
         Q
          ;
+CCRHDR(CXML,DFN) ; MAP HEADER VARIABLES: FROM, TO ECT
+        N VMAP S VMAP=$NA(^TMP($J,DFN,"HEADER"))
+        ; K @VMAP
+        S @VMAP@("ACTORPATIENT")="ACTORPATIENT_"_DFN
+        S @VMAP@("ACTORFROM")="ACTORPROVIDER_"_DUZ ; FROM DUZ - ???
+        S @VMAP@("ACTORFROM2")="ACTORPROVIDER_"_DUZ ; NEED A BETTER WAY
+        S @VMAP@("ACTORTO")="ACTORPATIENT_"_DFN  ; FOR TEST PURPOSES,
+        ; THIS IS THE USE CASE FOR THE PHR WHERE "TO" IS THE PATIENT
+        N CTMP
+        D MAP^GPLXPATH(CXML,VMAP,"CTMP")
+        D CP^GPLXPATH("CTMP",CXML)
+        Q
+        ;
+ACTLST(AXML,ACTRTN) ; RETURN THE ACTOR LIST FOR THE XML IN AXML
+        ; AXML AND ACTRTN ARE PASSED BY NAME
+        N I,J,K
+        K @ACTRTN ; CLEAR RETURN ARRAY
+        F I=1:1:@AXML@(0) D  ; SCAN ALL LINES
+        . I @AXML@(I)?.E1"<ActorID>".E D  ; THERE IS AN ACTOR ON THIS LINE
+        . . S J=$P($P(@AXML@(I),"<ActorID>",2),"</ActorID>",1)
+        . . W "<ActorID>=>",J,!
+        . . S K(J)="" ; HASHING ACTOR TO GET RID OF MULTIPLES
+        S I="" ; GOING TO $O THROUGH THE HASH
+        F J=0:0 D  Q:$O(K(I))=""
+        . S I=$O(K(I)) ; WALK THROUGH THE HASH OF ACTORS
+        . D PUSH^GPLXPATH(ACTRTN,I) ; ADD THE ACTOR TO THE RETURN ARRAY
+        Q
+        ;
 TEST   ; RUN ALL THE TEST CASES
-      N ZTMP
-      D ZLOAD^GPLUNIT("ZTMP","GPLCCR")
-      D ZTEST^GPLUNIT(.ZTMP,"ALL")
-      W !
-      ; W "THE TESTS!",!
-      ; ZWR ZTMP
+      ;D TESTALL^GPLUNIT("GPLCCR")
+      D ZTEST^GPLCCR("PROBLEMS")
+      W "TESTING RETURNED FROM PROBLMES",!
+      D ZTEST^GPLCCR("CCR")
       Q
       ;
@@ -89,5 +111,15 @@
       ;
 ;;><TEST>
-;;><INIT>
+;;><PROBLEMS>
 ;;>>>K GPL S GPL=""
+;;>>>D CCRRPC^GPLCCR(.GPL,"2","PROBLEMS")
+;;>>?@GPL@(@GPL@(0))="</Problems>"
+;;><CCR>
+;;>>>K GPL S GPL=""
+;;>>>D CCRRPC^GPLCCR(.GPL,"2","CCR")
+;;>>?@GPL@(@GPL@(0))="</ContinutiyOfCareRecord>"
+;;><ACTLST>
+;;>>>N TCCR
+;;>>>D CCRRPC^GPLCCR(.TCCR,"2","CCR")
+;;>>>D ACTLST^GPLCCR("TCCR","ACTTEST")
 ;;></TEST>
