PXRMEXU2 ; SLC/PKR/PJH - Reminder exchange repository utilities, #2. ;09/20/2004
;;2.0;CLINICAL REMINDERS;;Feb 04, 2005
;=====================================================
FDA(IND,LC,TMPIND,FILENAME) ;Build the XML FDA output.
N FIELD,FILENUM,INDEX,INDEX0,JND,SIENS,WPC
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
Q
;
;=====================================================
IENROOT(IND,LC,TMPIND,FILENAME) ;Build the XML IEN_ROOT output.
N INDEX,VALUE
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
Q
;
;=====================================================
STOREPR(SUCCESS,RTM,TMPIND,EXTYPE) ;^TMP(TMPIND,$J contains data to be
;stored in the repository. Routines will be found in
;^TMP(TMPIND,$J,"ROUTINE",ROUTINE NAME,n) where n is the line number.
;File entries will be found in ^TMP(TMPIND,$J,N,FILENAME,indexes).
;This is output from the GETS^DIQ call. There are NUMF file entries.
;Format and store it as XML in the repository.
N DATE,DTEST,FDA,FILENAME,FILENUM
N IENROOT,IND,JND,LC,LINE,NCMPNT,NEWFILE,NUMF,PT01,RNAME
N SIENS,SOURCE,TEMP,VERSN
;If anything went wrong in the packing process then ^TMP(TMPIND,$J
;will not exist.
I '$D(^TMP(TMPIND,$J)) S SUCCESS=0 Q
;
K ^TMP($J,"CIND")
K ^TMP("PXRMEXRS",$J)
S ^TMP("PXRMEXRS",$J,1,0)=""
S ^TMP("PXRMEXRS",$J,2,0)=""
S VERSN=^PXRM(800,1,"VERSION")
S ^TMP("PXRMEXRS",$J,3,0)=""_VERSN_""
;The pointer to the index will be on line 4 so leave room.
S LC=4
;Save the source information.
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
;
;Save the Exchange Type.
I EXTYPE="" S EXTYPE="REMINDER"
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_$$TOXML^PXRMEXU3(EXTYPE)_""
;
;Save the description.
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
;
;Save the keywords or phrases.
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S IND=0
F S IND=$O(^TMP(TMPIND,$J,"KEYWORD",1,IND)) Q:+IND=0 D
. S TEMP=^TMP(TMPIND,$J,"KEYWORD",1,IND,0)
. I TEMP["," D
.. F JND=1:1:$L(TEMP,",") D
... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_$$TOXML^PXRMEXU3($P(TEMP,",",JND))_""
. E S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_$$TOXML^PXRMEXU3(TEMP)_""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
;
S NCMPNT=0
;Do routines first.
S RNAME=""
F S RNAME=$O(^TMP(TMPIND,$J,"ROUTINE",RNAME)) Q:RNAME="" D
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S NCMPNT=NCMPNT+1
. S ^TMP($J,"CIND",NCMPNT,"M_ROUTINE_START")=LC
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_RNAME_""
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S ^TMP($J,"CIND",NCMPNT,"ROUTINE_CODE_END")=LC-3
;
;Do file entries.
;For word processing fields the first line is
;file number;source ien string;field~WP-start~line count
;The next line count lines are the WP data.
S NUMF=+$G(^TMP(TMPIND,$J,"NUMF"))
S FILENAME=""
F IND=1:1:NUMF D
. F S FILENAME=$O(^TMP(TMPIND,$J,IND,FILENAME)) Q:FILENAME="" D
.. I FILENAME["IENROOT" D
... S NEWFILE=0
... S IENROOT=1
.. E D
... S NEWFILE=1
... S IENROOT=0
.. I NEWFILE D
... S FILENUM=$O(^TMP(TMPIND,$J,IND,FILENAME,""))
... S SIENS=$O(^TMP(TMPIND,$J,IND,FILENAME,FILENUM,""))
... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
... S NCMPNT=NCMPNT+1
... S ^TMP($J,"CIND",NCMPNT,"FILE_START")=LC
... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_$$TOXML^PXRMEXU3(FILENAME)_""
... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_FILENUM_""
... S LC=LC+1,PT01=^TMP(TMPIND,$J,IND,FILENAME,FILENUM,SIENS,.01)
... S ^TMP("PXRMEXRS",$J,LC,0)=""_$$TOXML^PXRMEXU3(PT01)_""
... S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_+SIENS_""
... S ^TMP($J,"CIND",NCMPNT,"FDA_START")=LC+3
... D FDA(IND,.LC,TMPIND,FILENAME)
... S ^TMP($J,"CIND",NCMPNT,"FDA_END")=LC-2
..;The ien root information always comes after the FDA.
.. I IENROOT D
... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_START")=LC+3
... D IENROOT(IND,.LC,TMPIND,FILENAME)
... S ^TMP($J,"CIND",NCMPNT,"IEN_ROOT_END")=LC-2
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
;Save the index.
S LC=LC+1,^TMP("PXRMEXRS",$J,4,0)=""_LC_""
S ^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""_NCMPNT_""
F IND=1:1:NCMPNT D
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
. S JND=""
. F S JND=$O(^TMP($J,"CIND",IND,JND)) Q:JND="" D
.. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)="<"_JND_">"_^TMP($J,"CIND",IND,JND)_""_JND_">"
. S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
S LC=LC+1,^TMP("PXRMEXRS",$J,LC,0)=""
;Establish the entry in the repository.
S RNAME=$P(RTM,U,2)
S SOURCE=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
S DATE=^TMP(TMPIND,$J,"SRC","DATE")
S FDA(811.8,"+1,",.01)=RNAME
S FDA(811.8,"+1,",.02)=SOURCE
S FDA(811.8,"+1,",.03)=DATE
S FDA(811.8,"+1,",115)=EXTYPE
D UPDATE^PXRMEXPU(.SUCCESS,.FDA,.IENROOT)
I SUCCESS D
. M ^PXD(811.8,IENROOT(1),100)=^TMP("PXRMEXRS",$J)
.;Set the 0 node.
. S ^PXD(811.8,IENROOT(1),100,0)=U_811.801_U_LC_U_LC
.;Save the Exchange Type.
. S ^PXD(811.8,IENROOT(1),115)=$G(EXTYPE)
.;Create the description for this repository entry.
. N DATEP,DESC,DESL,KEYWORD,RNAME,SOURCE
. S DESL("RNAME")=^TMP(TMPIND,$J,"SRC","REMINDER")
. S DESL("SOURCE")=^TMP(TMPIND,$J,"SRC","USER")_" at "_^TMP(TMPIND,$J,"SRC","SITE")
. S DESL("DATEP")=^TMP(TMPIND,$J,"SRC","DATE")
. S DESL("VRSN")=$G(^PXRM(800,1,"VERSION"))
. S DESC="^TMP(TMPIND,$J,""DESC"")"
. S KEYWORD="^TMP(TMPIND,$J,""KEYWORD"")"
. D DESC^PXRMEXU1(IENROOT(1),.DESL,$NA(@DESC),$NA(@KEYWORD))
K ^TMP($J,"CIND")
K ^TMP("PXRMEXRS",$J)
K ^TMP(TMPIND,$J)
Q
;
;=====================================================
XMLOUT(IEN) ;Write out the XML content of repository entry ien.
N LC,NLINES
S NLINES=$O(^PXD(811.8,IEN,100,""),-1)
F LC=1:1:NLINES W !,^PXD(811.8,IEN,100,LC,0)
Q
;