Index: ccr/trunk/p/GPLCCD.m
===================================================================
--- ccr/trunk/p/GPLCCD.m	(revision 134)
+++ ccr/trunk/p/GPLCCD.m	(revision 391)
@@ -1,6 +1,7 @@
-GPLCCD   ; CCDCCR/GPL - CCD MAIN PROCESSING; 6/6/08
+C0CCCD   ; CCDCCR/GPL - CCD MAIN PROCESSING; 6/6/08
  ;;0.1;CCDCCR;nopatch;noreleasedate
- ;Copyright 2008 WorldVistA.  Licensed under the terms of the GNU
- ;General Public License See attached copy of the License.
+ ;Copyright 2008,2009 George Lilly, University of Minnesota.
+ ;Licensed under the terms of the GNU General Public License.
+ ;See attached copy of the License.
  ;
  ;This program is free software; you can redistribute it and/or modify
@@ -29,12 +30,12 @@
        ;
 XPAT(DFN,DIR,FN) ; EXPORT ONE PATIENT TO A FILE
-       ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("GPLCCR","ODIR")
+       ; DIR IS THE DIRECTORY, DEFAULTS IF NULL TO ^TMP("C0CCCR","ODIR")
        ; FN IS FILE NAME, DEFAULTS IF NULL
        ; N CCDGLO
        D CCDRPC(.CCDGLO,DFN,"CCD","","","")
-       S OARY=$NA(^TMP("GPLCCR",$J,DFN,"CCD",1))
+       S OARY=$NA(^TMP("C0CCCR",$J,DFN,"CCD",1))
        S ONAM=FN
        I FN="" S ONAM="PAT_"_DFN_"_CCD_V1.xml"
-       S ODIRGLB=$NA(^TMP("GPLCCR","ODIR"))
+       S ODIRGLB=$NA(^TMP("C0CCCR","ODIR"))
        I '$D(@ODIRGLB) D  ; IF NOT ODIR HAS BEEN SET
        . S @ODIRGLB="/home/glilly/CCROUT"
@@ -44,5 +45,5 @@
        I DIR="" S ODIR=@ODIRGLB
        N ZY
-       S ZY=$$OUTPUT^GPLXPATH(OARY,ONAM,ODIR)
+       S ZY=$$OUTPUT^C0CXPATH(OARY,ONAM,ODIR)
        W $P(ZY,U,2)
        Q
@@ -62,13 +63,13 @@
     N CCD S CCD=0 ; FLAG FOR PROCESSING A CCD
     I CCRPART="CCD" S CCD=1 ; WE ARE PROCESSING A CCD
-    S TGLOBAL=$NA(^TMP("GPLCCR",$J,"TEMPLATE")) ; GLOBAL FOR STORING TEMPLATE
-    I CCD S CCDGLO=$NA(^TMP("GPLCCR",$J,DFN,"CCD")) ; GLOBAL FOR THE CCD
-    E  S CCDGLO=$NA(^TMP("GPLCCR",$J,DFN,"CCR")) ; GLOBAL FOR BUILDING THE CCR
-    S ACTGLO=$NA(^TMP("GPLCCR",$J,DFN,"ACTORS")) ; GLOBAL FOR ALL ACTORS
+    S TGLOBAL=$NA(^TMP("C0CCCR",$J,"TEMPLATE")) ; GLOBAL FOR STORING TEMPLATE
+    I CCD S CCDGLO=$NA(^TMP("C0CCCR",$J,DFN,"CCD")) ; GLOBAL FOR THE CCD
+    E  S CCDGLO=$NA(^TMP("C0CCCR",$J,DFN,"CCR")) ; GLOBAL FOR BUILDING THE CCR
+    S ACTGLO=$NA(^TMP("C0CCCR",$J,DFN,"ACTORS")) ; GLOBAL FOR ALL ACTORS
     ; TO GET PART OF THE CCR RETURNED, PASS CCRPART="PROBLEMS" ETC
-    S CCRGRTN=$NA(^TMP("GPLCCR",$J,DFN,CCRPART)) ; RTN GLO NM OF PART OR ALL
-    I CCD D LOAD^GPLCCD1(TGLOBAL)  ; LOAD THE CCR TEMPLATE
-    E  D LOAD^GPLCCR0(TGLOBAL)  ; LOAD THE CCR TEMPLATE
-    D CP^GPLXPATH(TGLOBAL,CCDGLO) ; COPY THE TEMPLATE TO CCR GLOBAL
+    S CCRGRTN=$NA(^TMP("C0CCCR",$J,DFN,CCRPART)) ; RTN GLO NM OF PART OR ALL
+    I CCD D LOAD^C0CCCD1(TGLOBAL)  ; LOAD THE CCR TEMPLATE
+    E  D LOAD^C0CCCR0(TGLOBAL)  ; LOAD THE CCR TEMPLATE
+    D CP^C0CXPATH(TGLOBAL,CCDGLO) ; COPY THE TEMPLATE TO CCR GLOBAL
     N CAPSAVE,CAPSAVE2 ; FOR HOLDING THE CCD ROOT LINES
     S CAPSAVE=@TGLOBAL@(3) ; SAVE THE CCD ROOT
@@ -81,7 +82,7 @@
     ; DELETE THE BODY, ACTORS AND SIGNATURES SECTIONS FROM GLOBAL
     ; THESE WILL BE POPULATED AFTER CALLS TO THE XPATH ROUTINES
-    D REPLACE^GPLXPATH(CCDGLO,"","//ContinuityOfCareRecord/Body")
-    D REPLACE^GPLXPATH(CCDGLO,"","//ContinuityOfCareRecord/Actors")
-    I 'CCD D REPLACE^GPLXPATH(CCDGLO,"","//ContinuityOfCareRecord/Signatures")
+    D REPLACE^C0CXPATH(CCDGLO,"","//ContinuityOfCareRecord/Body")
+    D REPLACE^C0CXPATH(CCDGLO,"","//ContinuityOfCareRecord/Actors")
+    I 'CCD D REPLACE^C0CXPATH(CCDGLO,"","//ContinuityOfCareRecord/Signatures")
     I DEBUG F I=1:1:@CCDGLO@(0) W @CCDGLO@(I),!
     ;
@@ -89,17 +90,17 @@
     ; MAPPING THE PATIENT PORTION OF THE CDA HEADER
     S ZZX="//ContinuityOfCareRecord/recordTarget/patientRole/patient"
-    D QUERY^GPLXPATH(CCDGLO,ZZX,"ACTT1")
-    D PATIENT^GPLACTOR("ACTT1",DFN,"ACTORPATIENT_"_DFN,"ACTT2") ; MAP PATIENT
-    I DEBUG D PARY^GPLXPATH("ACTT2")
-    D REPLACE^GPLXPATH(CCDGLO,"ACTT2",ZZX)
-    I DEBUG D PARY^GPLXPATH(CCDGLO)
+    D QUERY^C0CXPATH(CCDGLO,ZZX,"ACTT1")
+    D PATIENT^C0CACTOR("ACTT1",DFN,"ACTORPATIENT_"_DFN,"ACTT2") ; MAP PATIENT
+    I DEBUG D PARY^C0CXPATH("ACTT2")
+    D REPLACE^C0CXPATH(CCDGLO,"ACTT2",ZZX)
+    I DEBUG D PARY^C0CXPATH(CCDGLO)
     K ACTT1 K ACCT2
     ; MAPPING THE PROVIDER ORGANIZATION,AUTHOR,INFORMANT,CUSTODIAN CDA HEADER
     ; FOR NOW, THEY ARE ALL THE SAME AND RESOLVE TO ORGANIZATION
-    D ORG^GPLACTOR(CCDGLO,DFN,"ACTORPATIENTORGANIZATION","ACTT2") ; MAP ORG
-    D CP^GPLXPATH("ACTT2",CCDGLO)
-    ;
-    K ^TMP("GPLCCR",$J,"CCRSTEP") ; KILL GLOBAL PRIOR TO ADDING TO IT
-    S CCRXTAB=$NA(^TMP("GPLCCR",$J,"CCRSTEP")) ; GLOBAL TO STORE CCR STEPS
+    D ORG^C0CACTOR(CCDGLO,DFN,"ACTORPATIENTORGANIZATION","ACTT2") ; MAP ORG
+    D CP^C0CXPATH("ACTT2",CCDGLO)
+    ;
+    K ^TMP("C0CCCR",$J,"CCRSTEP") ; KILL GLOBAL PRIOR TO ADDING TO IT
+    S CCRXTAB=$NA(^TMP("C0CCCR",$J,"CCRSTEP")) ; GLOBAL TO STORE CCR STEPS
     D INITSTPS(CCRXTAB) ; INITIALIZED CCR PROCESSING STEPS
     N I,XI,TAG,RTN,CALL,XPATH,IXML,OXML,INXML,CCRBLD
@@ -109,5 +110,5 @@
     . S TAG=$P(XI,";",1) ; LABEL INSIDE ROUTINE TO CALL
     . S XPATH=$P(XI,";",3) ; XPATH TO XML TO PASS TO ROUTINE
-    . D QUERY^GPLXPATH(TGLOBAL,XPATH,"INXML") ; EXTRACT XML TO PASS
+    . D QUERY^C0CXPATH(TGLOBAL,XPATH,"INXML") ; EXTRACT XML TO PASS
     . S IXML="INXML"
     . I CCD D SHAVE(IXML) ; REMOVE ALL BUT REPEATING PARTS OF TEMPLATE SECTION
@@ -118,18 +119,18 @@
     . X CALL
     . I @OXML@(0)'=0 D  ; THERE IS A RESULT
-    . . I CCD D QUERY^GPLXPATH(TGLOBAL,XPATH,"ITMP") ; XML TO UNSHAVE WITH
+    . . I CCD D QUERY^C0CXPATH(TGLOBAL,XPATH,"ITMP") ; XML TO UNSHAVE WITH
     . . I CCD D UNSHAVE("ITMP",OXML)
-    . . I CCD D UNMARK^GPLXPATH(OXML) ; REMOVE THE CCR MARKUP FROM SECTION
+    . . I CCD D UNMARK^C0CXPATH(OXML) ; REMOVE THE CCR MARKUP FROM SECTION
     . ; NOW INSERT THE RESULTS IN THE CCR BUFFER
-    . D INSERT^GPLXPATH(CCDGLO,OXML,"//ContinuityOfCareRecord/Body")
-    . I DEBUG F GPLI=1:1:@OXML@(0) W @OXML@(GPLI),!
+    . D INSERT^C0CXPATH(CCDGLO,OXML,"//ContinuityOfCareRecord/Body")
+    . I DEBUG F C0CI=1:1:@OXML@(0) W @OXML@(C0CI),!
     ; NEED TO ADD BACK IN ACTOR PROCESSING AFTER WE FIGURE OUT LINKAGE
-    ; D ACTLST^GPLCCR(CCDGLO,ACTGLO) ; GEN THE ACTOR LIST
-    ; D QUERY^GPLXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","ACTT")
-    ; D EXTRACT^GPLACTOR("ACTT",ACTGLO,"ACTT2")
-    ; D INSINNER^GPLXPATH(CCDGLO,"ACTT2","//ContinuityOfCareRecord/Actors")
+    ; D ACTLST^C0CCCR(CCDGLO,ACTGLO) ; GEN THE ACTOR LIST
+    ; D QUERY^C0CXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","ACTT")
+    ; D EXTRACT^C0CACTOR("ACTT",ACTGLO,"ACTT2")
+    ; D INSINNER^C0CXPATH(CCDGLO,"ACTT2","//ContinuityOfCareRecord/Actors")
     N I,J,DONE S DONE=0
     F I=0:0 D  Q:DONE  ; DELETE UNTIL ALL EMPTY ELEMENTS ARE GONE
-    . S J=$$TRIM^GPLXPATH(CCDGLO) ; DELETE EMPTY ELEMENTS
+    . S J=$$TRIM^C0CXPATH(CCDGLO) ; DELETE EMPTY ELEMENTS
     . W "TRIMMED",J,!
     . I J=0 S DONE=1 ; DONE WHEN TRIM RETURNS FALSE
@@ -149,7 +150,7 @@
     W "TAB= ",TAB,!
     ; ORDER FOR CCR IS PROBLEMS,FAMILYHISTORY,SOCIALHISTORY,MEDICATIONS,VITALSIGNS,RESULTS,HEALTHCAREPROVIDERS
-    D PUSH^GPLXPATH(TAB,"EXTRACT;GPLPROBS;//ContinuityOfCareRecord/Body/Problems;^TMP(""GPLCCR"",$J,DFN,""PROBLEMS"")")
-    ;D PUSH^GPLXPATH(TAB,"EXTRACT;GPLMEDS;//ContinuityOfCareRecord/Body/Medications;^TMP(""GPLCCR"",$J,DFN,""MEDICATIONS"")")
-    I 'CCD D PUSH^GPLXPATH(TAB,"EXTRACT;GPLVITAL;//ContinuityOfCareRecord/Body/VitalSigns;^TMP(""GPLCCR"",$J,DFN,""VITALS"")")
+    D PUSH^C0CXPATH(TAB,"EXTRACT;C0CPROBS;//ContinuityOfCareRecord/Body/Problems;^TMP(""C0CCCR"",$J,DFN,""PROBLEMS"")")
+    ;D PUSH^C0CXPATH(TAB,"EXTRACT;C0CMEDS;//ContinuityOfCareRecord/Body/Medications;^TMP(""C0CCCR"",$J,DFN,""MEDICATIONS"")")
+    I 'CCD D PUSH^C0CXPATH(TAB,"EXTRACT;C0CVITAL;//ContinuityOfCareRecord/Body/VitalSigns;^TMP(""C0CCCR"",$J,DFN,""VITALS"")")
     Q
     ;
@@ -159,10 +160,10 @@
     W SHXML,!
     W @SHXML@(1),!
-    D QUEUE^GPLXPATH("SHBLD",SHXML,1,1) ; THE FIRST LINE IS NEEDED
-    D QUEUE^GPLXPATH("SHBLD",SHXML,7,@SHXML@(0)-3) ; REPEATING PART
-    D QUEUE^GPLXPATH("SHBLD",SHXML,@SHXML@(0),@SHXML@(0)) ; LAST LINE
-    D PARY^GPLXPATH("SHBLD") ; PRINT BUILD LIST
-    D BUILD^GPLXPATH("SHBLD","SHTMP") ; BUILD EDITED SECTION
-    D CP^GPLXPATH("SHTMP",SHXML) ; COPY RESULT TO PASSED ARRAY
+    D QUEUE^C0CXPATH("SHBLD",SHXML,1,1) ; THE FIRST LINE IS NEEDED
+    D QUEUE^C0CXPATH("SHBLD",SHXML,7,@SHXML@(0)-3) ; REPEATING PART
+    D QUEUE^C0CXPATH("SHBLD",SHXML,@SHXML@(0),@SHXML@(0)) ; LAST LINE
+    D PARY^C0CXPATH("SHBLD") ; PRINT BUILD LIST
+    D BUILD^C0CXPATH("SHBLD","SHTMP") ; BUILD EDITED SECTION
+    D CP^C0CXPATH("SHTMP",SHXML) ; COPY RESULT TO PASSED ARRAY
     Q
     ;
@@ -172,14 +173,14 @@
     W SHXML,!
     W @SHXML@(1),!
-    D QUEUE^GPLXPATH("SHBLD",ORIGXML,1,6) ; FIRST 6 LINES OF TEMPLATE
-    D QUEUE^GPLXPATH("SHBLD",SHXML,2,@SHXML@(0)-1) ; INS ALL BUT FIRST/LAST
-    D QUEUE^GPLXPATH("SHBLD",ORIGXML,@ORIGXML@(0)-2,@ORIGXML@(0)) ; FROM TEMP
-    D PARY^GPLXPATH("SHBLD") ; PRINT BUILD LIST
-    D BUILD^GPLXPATH("SHBLD","SHTMP") ; BUILD EDITED SECTION
-    D CP^GPLXPATH("SHTMP",SHXML) ; COPY RESULT TO PASSED ARRAY
+    D QUEUE^C0CXPATH("SHBLD",ORIGXML,1,6) ; FIRST 6 LINES OF TEMPLATE
+    D QUEUE^C0CXPATH("SHBLD",SHXML,2,@SHXML@(0)-1) ; INS ALL BUT FIRST/LAST
+    D QUEUE^C0CXPATH("SHBLD",ORIGXML,@ORIGXML@(0)-2,@ORIGXML@(0)) ; FROM TEMP
+    D PARY^C0CXPATH("SHBLD") ; PRINT BUILD LIST
+    D BUILD^C0CXPATH("SHBLD","SHTMP") ; BUILD EDITED SECTION
+    D CP^C0CXPATH("SHTMP",SHXML) ; COPY RESULT TO PASSED ARRAY
     Q
     ;
 HDRMAP(CXML,DFN,IHDR)   ; MAP HEADER VARIABLES: FROM, TO ECT
-    N VMAP S VMAP=$NA(^TMP("GPLCCR",$J,DFN,"HEADER"))
+    N VMAP S VMAP=$NA(^TMP("C0CCCR",$J,DFN,"HEADER"))
     ; K @VMAP
     S @VMAP@("DATETIME")=$$FMDTOUTC^CCRUTIL($$NOW^XLFDT,"DT")
@@ -193,8 +194,8 @@
     . ; THIS IS THE USE CASE FOR THE PHR WHERE "TO" IS THE PATIENT
     I IHDR'="" D  ; HEADER VALUES ARE PROVIDED
-    . D CP^GPLXPATH(IHDR,VMAP) ; COPY HEADER VARIABLES TO MAP ARRAY
+    . D CP^C0CXPATH(IHDR,VMAP) ; COPY HEADER VARIABLES TO MAP ARRAY
     N CTMP
-    D MAP^GPLXPATH(CXML,VMAP,"CTMP")
-    D CP^GPLXPATH("CTMP",CXML)
+    D MAP^C0CXPATH(CXML,VMAP,"CTMP")
+    D CP^C0CXPATH("CTMP",CXML)
     Q
     ;
@@ -221,51 +222,51 @@
     . S $P(L,U,2)=$P($P(I,"ACTOR",2),"_",1) ; ACTOR TYPE
     . S $P(L,U,3)=$P(I,"_",2) ; IEN RECORD NUMBER FOR ACTOR
-    . D PUSH^GPLXPATH(ACTRTN,L) ; ADD THE ACTOR TO THE RETURN ARRAY
+    . D PUSH^C0CXPATH(ACTRTN,L) ; ADD THE ACTOR TO THE RETURN ARRAY
     Q
     ;
 TEST ; RUN ALL THE TEST CASES
-  D TESTALL^GPLUNIT("GPLCCR")
+  D TESTALL^C0CUNIT("C0CCCR")
   Q
   ;
 ZTEST(WHICH)  ; RUN ONE SET OF TESTS
   N ZTMP
-  D ZLOAD^GPLUNIT("ZTMP","GPLCCR")
-  D ZTEST^GPLUNIT(.ZTMP,WHICH)
+  D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
+  D ZTEST^C0CUNIT(.ZTMP,WHICH)
   Q
   ;
 TLIST  ; LIST THE TESTS
   N ZTMP
-  D ZLOAD^GPLUNIT("ZTMP","GPLCCR")
-  D TLIST^GPLUNIT(.ZTMP)
+  D ZLOAD^C0CUNIT("ZTMP","C0CCCR")
+  D TLIST^C0CUNIT(.ZTMP)
   Q
   ;
  ;;><TEST>
  ;;><PROBLEMS>
- ;;>>>K GPL S GPL=""
- ;;>>>D CCRRPC^GPLCCR(.GPL,"2","PROBLEMS","","","")
- ;;>>?@GPL@(@GPL@(0))["</Problems>"
+ ;;>>>K C0C S C0C=""
+ ;;>>>D CCRRPC^C0CCCR(.C0C,"2","PROBLEMS","","","")
+ ;;>>?@C0C@(@C0C@(0))["</Problems>"
  ;;><VITALS>
- ;;>>>K GPL S GPL=""
- ;;>>>D CCRRPC^GPLCCR(.GPL,"2","VITALS","","","")
- ;;>>?@GPL@(@GPL@(0))["</VitalSigns>"
+ ;;>>>K C0C S C0C=""
+ ;;>>>D CCRRPC^C0CCCR(.C0C,"2","VITALS","","","")
+ ;;>>?@C0C@(@C0C@(0))["</VitalSigns>"
  ;;><CCR>
- ;;>>>K GPL S GPL=""
- ;;>>>D CCRRPC^GPLCCR(.GPL,"2","CCR","","","")
- ;;>>?@GPL@(@GPL@(0))["</ContinuityOfCareRecord>"
+ ;;>>>K C0C S C0C=""
+ ;;>>>D CCRRPC^C0CCCR(.C0C,"2","CCR","","","")
+ ;;>>?@C0C@(@C0C@(0))["</ContinuityOfCareRecord>"
  ;;><ACTLST>
- ;;>>>K GPL S GPL=""
- ;;>>>D CCRRPC^GPLCCR(.GPL,"2","CCR","","","")
- ;;>>>D ACTLST^GPLCCR(GPL,"ACTTEST")
+ ;;>>>K C0C S C0C=""
+ ;;>>>D CCRRPC^C0CCCR(.C0C,"2","CCR","","","")
+ ;;>>>D ACTLST^C0CCCR(C0C,"ACTTEST")
  ;;><ACTORS>
- ;;>>>D ZTEST^GPLCCR("ACTLST")
- ;;>>>D QUERY^GPLXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","G2")
- ;;>>>D EXTRACT^GPLACTOR("G2","ACTTEST","G3")
+ ;;>>>D ZTEST^C0CCCR("ACTLST")
+ ;;>>>D QUERY^C0CXPATH(TGLOBAL,"//ContinuityOfCareRecord/Actors","G2")
+ ;;>>>D EXTRACT^C0CACTOR("G2","ACTTEST","G3")
  ;;>>?G3(G3(0))["</Actors>"
  ;;><TRIM>
- ;;>>>D ZTEST^GPLCCR("CCR")
- ;;>>>W $$TRIM^GPLXPATH(CCDGLO)
+ ;;>>>D ZTEST^C0CCCR("CCR")
+ ;;>>>W $$TRIM^C0CXPATH(CCDGLO)
  ;;><CCD>
- ;;>>>K GPL S GPL=""
- ;;>>>D CCRRPC^GPLCCR(.GPL,"2","CCD","","","")
- ;;>>?@GPL@(@GPL@(0))["</ContinuityOfCareRecord>"
+ ;;>>>K C0C S C0C=""
+ ;;>>>D CCRRPC^C0CCCR(.C0C,"2","CCD","","","")
+ ;;>>?@C0C@(@C0C@(0))["</ContinuityOfCareRecord>"
  ;;></TEST>
