updates for certification

This commit is contained in:
george 2011-06-08 21:15:57 +00:00
parent d487ba4ccd
commit ac1f7a441b
3 changed files with 985 additions and 393 deletions

317
p/C0CDOM.m Normal file
View File

@ -0,0 +1,317 @@
C0CDOM ; GPL - DOM PROCESSING ROUTINES ;6/6/11 17:05
;;0.1;C0C;nopatch;noreleasedate;Build 38
;Copyright 2011 George Lilly. 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
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
Q
;
DOMO(ZOID,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; RECURSIVE ROUTINE TO POPULATE
; THE XPATH INDEX ZXIDX, PASSED BY NAME
; THE XPATH ARRAY XPARY, PASSED BY NAME
; ZOID IS THE STARTING OID
; ZPATH IS THE STARTING XPATH, USUALLY "/"
; ZNUM IS THE MULTIPLE NUMBER [x], USUALLY NULL WHEN ON THE TOP NODE
; ZREDUX IS THE XPATH REDUCTION STRING, TAKEN OUT OF EACH XPATH IF PRESENT
I $G(ZREDUX)="" S ZREDUX=""
N NEWPATH,NARY ; NEWPATH IS AN XPATH NARY IS AN NHIN MUMPS ARRAY
N NEWNUM S NEWNUM=""
I $G(ZNUM)>0 S NEWNUM="["_ZNUM_"]"
S NEWPATH=ZPATH_"/"_$$TAG(ZOID)_NEWNUM ; CREATE THE XPATH FOR THIS NODE
I $G(ZREDUX)'="" D ; REDUX PROVIDED?
. N GT S GT=$P(NEWPATH,ZREDUX,2)
. I GT'="" S NEWPATH=GT
S @ZXIDX@(NEWPATH)=ZOID ; ADD THE XPATH FOR THIS NODE TO THE XPATH INDEX
N GA D ATT("GA",ZOID) ; GET ATTRIBUTES FOR THIS NODE
I $D(GA) D ; PROCESS THE ATTRIBUTES
. N ZI S ZI=""
. F S ZI=$O(GA(ZI)) Q:ZI="" D ; FOR EACH ATTRIBUTE
. . N ZP S ZP=NEWPATH_"@"_ZI ; PATH FOR ATTRIBUTE
. . S @ZXPARY@(ZP)=GA(ZI) ; ADD THE ATTRIBUTE XPATH TO THE XP ARRAY
. . I GA(ZI)'="" D ADDNARY(ZP,GA(ZI)) ; ADD THE NHIN ARRAY VALUE
N GD D DATA("GD",ZOID) ; SEE IF THERE IS DATA FOR THIS NODE
I $D(GD(2)) D ;
. M @ZXPARY@(NEWPATH)=GD ; IF MULITPLE DATA MERGE TO THE ARRAY
E I $D(GD(1)) D ;
. S @ZXPARY@(NEWPATH)=GD(1) ; IF SINGLE VALUE, ADD TO ARRAY
. I GD(1)'="" D ADDNARY(NEWPATH,GD(1)) ; ADD TO NHIN ARRAY
N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
I ZFRST'=0 D ; THERE IS A CHILD
. N ZNUM
. N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
. D DOMO(ZFRST,NEWPATH,ZNARY,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; THE CHILD
N GNXT S GNXT=$$NXTSIB(ZOID)
I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
I GNXT'=0 D ;
. N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
. I (ZNUM="")&(ZMULT) D ; SIBLING IS FIRST OF MULTIPLES
. . N ZNUM S ZNUM=1 ;
. . D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
. E D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; SIB
Q
;
ADDNARY(ZXP,ZVALUE) ; ADD AN NHIN ARRAY VALUE TO ZNARY
;
; IF ZATT=1 THE ARRAY IS ADDED AS ATTRIBUTES
;
N ZZI,ZZJ,ZZN
S ZZI=$P(ZXP,"/",1) ; FIRST PIECE OF XPATH ARRAY
I ZZI="" Q ; DON'T ADD THIS ONE .. PROBABLY THE //results NODE
S ZZJ=$P(ZXP,ZZI_"/",2) ; REST OF XPATH ARRAY
S ZZJ=$TR(ZZJ,"/",".") ; REPLACE / WITH .
I ZZI'["]" D ; A SINGLETON
. S ZZN=1
E D ; THERE IS AN [x] OCCURANCE
. S ZZN=$P($P(ZZI,"[",2),"]",1) ; PULL OUT THE OCCURANCE
. S ZZI=$P(ZZI,"[",1) ; TAKE OUT THE [X]
I ZZJ'="" D ; TIME TO ADD THE VALUE
. S @ZNARY@(ZZI,ZZN,ZZJ)=ZVALUE
Q
;
PARSE(INXML,INDOC) ;CALL THE MXML PARSER ON INXML, PASSED BY NAME
; INDOC IS PASSED AS THE DOCUMENT NAME - DON'T KNOW WHERE TO STORE THIS NOW
; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY MXML
;Q $$EN^MXMLDOM(INXML)
Q $$EN^MXMLDOM(INXML,"W")
;
ISMULT(ZOID) ; RETURN TRUE IF ZOID IS ONE OF A MULTIPLE
N ZN
;I $$TAG(ZOID)["entry" B
S ZN=$$NXTSIB(ZOID)
I ZN'="" Q $$TAG(ZOID)=$$TAG(ZN) ; IF TAG IS THE SAME AS NEXT SIB TAG
Q 0
;
FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID
Q $$CHILD^MXMLDOM(C0CDOCID,ZOID)
;
PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID
Q $$PARENT^MXMLDOM(C0CDOCID,ZOID)
;
ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID
S HANDLE=C0CDOCID
K @RTN
D GETTXT^MXMLDOM("A")
Q
;
TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE
;I ZOID=149 B ;GPLTEST
N X,Y
S Y=""
S X=$G(C0CCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
I Y="" S Y=$$NAME^MXMLDOM(C0CDOCID,ZOID)
Q Y
;
NXTSIB(ZOID) ; RETURNS THE NEXT SIBLING
Q $$SIBLING^MXMLDOM(C0CDOCID,ZOID)
;
DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE
;N ZT,ZN S ZT=""
;S C0CDOM=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
;Q $G(@C0CDOM@(ZOID,"T",1))
S ZN=$$TEXT^MXMLDOM(C0CDOCID,ZOID,ZT)
Q
;
OUTXML(ZRTN,INID) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
;
S C0CDOCID=INID
D START^C0CMXMLB($$TAG(1),,"G")
D NDOUT($$FIRST(1))
D END^C0CMXMLB ;END THE DOCUMENT
M @ZRTN=^TMP("MXMLBLD",$J)
K ^TMP("MXMLBLD",$J)
Q
;
NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
N ZI S ZI=$$FIRST(ZOID)
I ZI'=0 D ; THERE IS A CHILD
. N ZATT D ATT("ZATT",ZOID) ; THESE ARE THE ATTRIBUTES MOVED TO ZATT
. D MULTI^C0CMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0CMXML(ZI)") ;HAVE CHILDREN
E D ; NO CHILD - IF NO CHILDREN, A NODE HAS DATA, IS AN ENDPOINT
. ;W "DOING",ZOID,!
. N ZD D DATA("ZD",ZOID) ;NODES WITHOUT CHILDREN HAVE DATA
. N ZATT D ATT("ZATT",ZOID) ;ATTRIBUTES
. D ITEM^C0CMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1))) ;NO CHILDREN
I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING
. D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS
Q
;
WNHIN(ZDFN) ; WRITES THE XML OUTPUT OF GET^NHINV TO AN XML FILE
;
N GN,GN2
D GET^NHINV(.GN,ZDFN) ; EXTRACT THE XML
S GN2=$NA(@GN@(1))
W $$OUTPUT^C0CXPATH(GN2,"nhin_"_ZDFN_".xml","/home/wvehr3-09/")
Q
;
; EXAMPLE OF NHIN ARRAY FORMAT - THIS IS AN OUTPUT OF DOMO ABOVE WHEN RUN
; AGAINST THE OUTPUT OF THE GET^NHINV ROUTINE. (THIS IS NOT REAL PATIENT DATA)
;
;GNARY("med",1,"doses.dose@dose")=10
;GNARY("med",1,"doses.dose@noun")="TABLET"
;GNARY("med",1,"doses.dose@route")="PO"
;GNARY("med",1,"doses.dose@schedule")="QD"
;GNARY("med",1,"doses.dose@units")="MG"
;GNARY("med",1,"doses.dose@unitsPerDose")=1
;GNARY("med",1,"facility@code")=100
;GNARY("med",1,"facility@name")="VOE OFFICE INSTITUTION"
;GNARY("med",1,"form@value")="TAB"
;GNARY("med",1,"id@value")="1N;O"
;GNARY("med",1,"location@code")=5
;GNARY("med",1,"location@name")="3 WEST"
;GNARY("med",1,"name@value")="LISINOPRIL TAB"
;GNARY("med",1,"orderID@value")=294
;GNARY("med",1,"ordered@value")=3110531.001233
;GNARY("med",1,"orderingProvider@code")=63
;GNARY("med",1,"orderingProvider@name")="KING,MATTHEW MICHAEL"
;GNARY("med",1,"products.product.class@code")="ACE INHIBITORS"
;GNARY("med",1,"products.product.vaGeneric@code")=1990
;GNARY("med",1,"products.product.vaGeneric@name")="LISINOPRIL"
;GNARY("med",1,"products.product.vaGeneric@vuid")=4019380
;GNARY("med",1,"products.product.vaProduct@code")=8118
;GNARY("med",1,"products.product.vaProduct@name")="LISINOPRIL 10MG TAB"
;GNARY("med",1,"products.product.vaProduct@vuid")=4008593
;GNARY("med",1,"products.product@code")=6174
;GNARY("med",1,"products.product@name")="LISINOPRIL 10MG U/D"
;GNARY("med",1,"products.product@role")="D"
;GNARY("med",1,"sig")="10MG BY MOUTH EVERY DAY"
;GNARY("med",1,"sig@xml:space")="preserve"
;GNARY("med",1,"status@value")="active"
;GNARY("med",1,"type@value")="OTC"
;GNARY("med",1,"vaType@value")="N"
;
; DOMI is an extrinsic to insert NHIN ARRAY FORMAT arrays into the DOM
; it returns 0 or 1 based on success.
;
; INARY is passed by name and has the format shown above
; HANDLE is the document number in the DOM (both MXML and EWD DOMs will
; be supported eventually - initial implementation is for MXML
;
; PARENT is the node id or tag of the parent under which the DOM will
; be populated. If it is numeric, it is a node. If it is a string, the DOM
; will be searched to find the tag. If not found and there is no root,
; it will be inserted as the root. If not found and there is a root, it
; will be inserted under the root.
;
; For the above example the call would be OK=$$DOMI("GNARY",0,"results")
; because "results" is the root tag. Use OUTXML to render the xml from
; the DOM.
;
DOMI(INARY,HANDLE,PARENT) ; EXTRINSIC TO INSERT NHIN ARRAYS TO A DOM
;
N ZPARNODE
S (SUCCESS,LEVEL,LEVEL(0),NODE)=0
I '$D(INARY) Q 0 ; NO ARRAY PASSED
I '$D(HANDLE) S HANDLE=$$NEWDOM() ; MAKE A NEW DOM
I +$G(PARENT)>0 S ZPARNODE=PARENT ; WE HAVE BEEN PASSED A PARENT NODE ID
E I $L(PARENT)>0 D ; TBD FIND THE PARENT IN THE DOM AND SET LEVEL
. D STARTELE^MXMLDOM(PARENT) ; INSERT THE PARENT NODE
. S ZPARNODE=1 ;
; WE NOW HAVE A HANDLE AND A PARENT NODE AND LEVEL HAS BEEN SET
D MAJOR(INARY,"",0) ; PROCESS ALL THE NODES TO BE ADDED
I $L(PARENT)>0 D ENDELE^MXMLDOM(PARENT) ; CLOSE OUT THE PARENT NODE
Q 1 ; SUCCESS
;
MAJOR(ZARY,ZTAG,ZNUM) ; RECURSIVE ROUTINE FOR INTERMEDIATE NODES
N ZI S ZI=""
F S ZI=$O(@ZARY@(ZI)) Q:ZI="" D ; FOR EACH SECTION
. N ZN S ZN=0
. F S ZN=$O(@ZARY@(ZI,ZN)) Q:ZN="" D ; FOR EACH MULTIPLE
. . N ZS S ZS=""
. . I $O(@ZARY@(ZI,ZN,ZS))'["." D ; END NODES HERE
. . . N NEWARY
. . . S NEWARY=$NA(@ZARY@(ZI,ZN))
. . . D MINOR("NEWARY") ; INSERT THE END NODES
. . E F S ZS=$O(@ZARY@(ZI,ZN,ZS)) Q:ZS="" D ; FOR EACH STRING
. . . I ZS["." D ; INTERMEDIATE NODE FOUND
. . . . W !,"IM:",ZS
. . . W !,ZI,":",ZN,":",ZS_" : ",@ZARY@(ZI,ZN,ZS)
Q
;
MINOR(ZINARY) ; DOES THE WORK FOR END NODES, HANDLES ATTRIBUTES
;
N ZZI S ZZI=""
F S ZZI=$O(@ZINARY@(ZZI)) Q:ZZI="" D ;
. W !,"MINOR",ZZI,":",@ZINARY@(ZZI)
Q
;
EXPAND(ZZOUT,ZZIN) ; EXPANDS NHIN ARRAY FORMAT TO AN EXPANDED
; CONSISTENT FORMAT
; GNARY("patient",1,"facilities[2].facility@code")="050"
; becomes G2ARY("patient",1,"facilities",2,"facility@",1,"code")="050"
; for easier processing (this is fileman format genius)
; basically removes the dot notation from the strings
;
N ZZI
S ZZI=""
F S ZZI=$O(@ZZIN@(ZZI)) Q:ZZI="" D ;
. N ZZN S ZZN=0
. F S ZZN=$O(@ZZIN@(ZZI,ZZN)) Q:ZZN="" D ;
. . N ZZS S ZZS=""
. . N GA ;PUSH STACK
. . F S ZZS=$O(@ZZIN@(ZZI,ZZN,ZZS)) Q:ZZS="" D ;
. . . K GA ; NEW STACK
. . . D PUSH^C0CXPATH("GA",ZZI_"^"_ZZN) ; PUSH PARENT
. . . N ZZV ; PLACE TO STASH THE VALUE
. . . S ZZV=@ZZIN@(ZZI,ZZN,ZZS) ; VALUE
. . . N GK ; COUNTER
. . . F GK=1:1:$L(ZZS,".") D ; FOR EACH INTERMEDIATE NODE
. . . . N ZZN2 S ZZN2=1 ; DEFAULT IF NO [X]
. . . . N GM S GM=$P(ZZS,".",GK) ; TAG
. . . . I GM["[" D ; IT'S A MULTIPLE
. . . . . S ZZN2=$P($P(GM,"[",2),"]",1) ; PULL OUT THE NUMBER
. . . . . S GM=$P(GM,"[",1) ; PULL OUT THE TAG
. . . . I GM["@" D ; IT'S GOT ATTRIBUTES
. . . . . N GM2 S GM2=$P(GM,"@",2) ; PULLOUT THE ATTRIBUTE NAME
. . . . . D PUSH^C0CXPATH("GA",$P(GM,"@",1)_"@"_"^"_ZZN2) ; PUSH THE TAG
. . . . . D PUSH^C0CXPATH("GA",GM2_"^"_ZZN2)
. . . . E D PUSH^C0CXPATH("GA",GM_"^"_ZZN2) ;
. . . S GA(GA(0))=$P(GA(GA(0)),"^",1)_"^" ; GET RID OF THE LAST "1"
. . . N GZI S GZI="" ; STRING FOR THE INDEX
. . . F GK=1:1:GA(0) D ; TIME TO REVERSE POP THE TAGS
. . . . S GM=$P(GA(GK),"^",1) ; THE TAG
. . . . S ZZN2=$P(GA(GK),"^",2) ; THE NUMBER IF ANY
. . . . I ZZN2="" S GZI=GZI_""""_GM_"""" ; FOR THE LAST ONE
. . . . E S GZI=GZI_""""_GM_""""_","_ZZN2_"," ; FOR THE REST
. . . S GZI2=ZZOUT_"("_GZI_")" ; INCLUDE THE ARRAY NAME
. . . W !,GZI
. . . S @GZI2=ZZV ; REMEMBER THE VALUE?
Q
;
POP(OSTR,ISTR) ; EXTRINSIC WHICH RETURNS TRUE IF ISTR IS EMPTY
; IF ISTR IS NOT EMPTY, LOOKS FOR "." AND "@" AND RETURNS
; xxx,1,yyyetc for xxx.yyyetc and xx@,1,yyy for xxx@yyyetc
; OSTR IS PASSED BY REFERENCE AND CONTAINS yyyetc
I $L(ISTR)=0 Q 1 ; WE ARE DONE
N ZG,ZN,ZR
S ZN=1
I ISTR["." D ;
. S ZG=$P(ISTR,".",1)
. S OSTR=$P(ISTR,".",2)
. S ZR=ZG_","_ZN_","_OSTR
Q ZR
;
NEWDOM() ; extrinsic which creates a new DOM and returns the HANDLE
N CBK,SUCCESS,LEVEL,NODE,HANDLE
K ^TMP("MXMLERR",$J)
L +^TMP("MXMLDOM",$J):5
E Q 0
S HANDLE=$O(^TMP("MXMLDOM",$J,""),-1)+1,^(HANDLE)=""
L -^TMP("MXMLDOM",$J)
Q HANDLE
;

255
p/C0CNHIN.m Normal file
View File

@ -0,0 +1,255 @@
C0CNHIN ; GPL - PROCESSING FOR OUTPUT OF NHINV ROUTINES;6/3/11 17:05
;;0.1;C0C;nopatch;noreleasedate;Build 38
;Copyright 2011 George Lilly. 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
;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version.
;
;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details.
;
;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;
Q
EN(ZRTN,ZDFN) ; GENERATE AN NHIN ARRAY FOR A PATIENT
;
K GARY,GNARY,GIDX,C0CDOCID
N GN
K ^TMP("NHINV",$J) ; CLEAN UP FROM LAST CALL
K ^TMP("MXMLDOM",$J) ; CLEAN UP DOM
K ^TMP("MXMLERR",$J) ; CLEAN UP MXML ERRORS
D GET^NHINV(.GN,ZDFN) ; CALL NHINV ROUTINES TO PULL XML
S GN=$P(GN,")",1)_")" ; CUT OFF THE REST OF LINE PROTOCOL
S C0CDOCID=$$PARSE(GN,"NHINARRAY") ; PARSE WITH MXML
D DOMO^C0CDOM(C0CDOCID,"/","ZRTN","GIDX","GARY",,"/results/") ; BLD ARRAYS
Q
;
LOADSMRT ;
;
K ^GPL("SMART")
S GN=$NA(^GPL("SMART",1))
I $$FTG^%ZISH("/home/george/","alex-lewis2.xml",GN,2) W !,"SMART FILE LOADED"
Q
;
SMART ; TRY IT WITH SMART
;
S GN=$NA(^GPL("SMART"))
;K ^TMP("MXMLDOM",$J)
K ^TMP("MXMLERR",$J)
S C0CDOCID=$$PARSE(GN,"SMART")
D DOMO^C0CDOM(C0CDOCID,"/","GNARY","GIDX","GARY",,"//rdf:RDF/")
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
Q
;
CCR ; TRY IT WITH A CCR
;
S GN=$NA(^GPL("CCR"))
;K ^TMP("MXMLDOM",$J)
K ^TMP("MXMLERR",$J)
S C0CDOCID=$$PARSE(GN,"CCR")
D DOMO^C0CDOM(C0CDOCID,"/","GNARY","GIDX","GARY",,"//ContinuityOfCareRecord/Body/")
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
Q
;
CCD ; TRY IT WITH A CCD
;
S GN=$NA(^GPL("CCD"))
;K ^TMP("MXMLDOM",$J)
K ^TMP("MXMLERR",$J)
S C0CDOCID=$$PARSE(GN,"CCD")
D DOMO^C0CDOM(C0CDOCID,"/","GNARY","GIDX","GARY",,"//ClinicalDocument/component/structuredBody/")
;K ^TMP("MXMLDOM",$J) ;CLEAN UP... IT'S BIG
Q
;
TEST1 ; TEST NHINV OUTPUT IN ^GPL("NIHIN")
; PARSED WITH MXML
; RUN THROUGH XPATH
K GARY,GIDX,C0CDOCID
S GN=$NA(^GPL("NHIN"))
S C0CDOCID=$$PARSE(GN,"GPLTEST")
D DOMO^C0CDOM(C0CDOCID,"/","GNARY","GIDX","GARY",,"/results/")
Q
;
DOMO(ZOID,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; RECURSIVE ROUTINE TO POPULATE
; THE XPATH INDEX ZXIDX, PASSED BY NAME
; THE XPATH ARRAY XPARY, PASSED BY NAME
; ZOID IS THE STARTING OID
; ZPATH IS THE STARTING XPATH, USUALLY "/"
; ZNUM IS THE MULTIPLE NUMBER [x], USUALLY NULL WHEN ON THE TOP NODE
; ZREDUX IS THE XPATH REDUCTION STRING, TAKEN OUT OF EACH XPATH IF PRESENT
I $G(ZREDUX)="" S ZREDUX=""
N NEWPATH,NARY ; NEWPATH IS AN XPATH NARY IS AN NHIN MUMPS ARRAY
N NEWNUM S NEWNUM=""
I $G(ZNUM)>0 S NEWNUM="["_ZNUM_"]"
S NEWPATH=ZPATH_"/"_$$TAG(ZOID)_NEWNUM ; CREATE THE XPATH FOR THIS NODE
I $G(ZREDUX)'="" D ; REDUX PROVIDED?
. N GT S GT=$P(NEWPATH,ZREDUX,2)
. I GT'="" S NEWPATH=GT
S @ZXIDX@(NEWPATH)=ZOID ; ADD THE XPATH FOR THIS NODE TO THE XPATH INDEX
N GA D ATT("GA",ZOID) ; GET ATTRIBUTES FOR THIS NODE
I $D(GA) D ; PROCESS THE ATTRIBUTES
. N ZI S ZI=""
. F S ZI=$O(GA(ZI)) Q:ZI="" D ; FOR EACH ATTRIBUTE
. . N ZP S ZP=NEWPATH_"/"_ZI ; PATH FOR ATTRIBUTE
. . S @ZXPARY@(ZP)=GA(ZI) ; ADD THE ATTRIBUTE XPATH TO THE XP ARRAY
. . I GA(ZI)'="" D ADDNARY(ZP,GA(ZI)) ; ADD THE NHIN ARRAY VALUE
N GD D DATA("GD",ZOID) ; SEE IF THERE IS DATA FOR THIS NODE
I $D(GD(2)) D ;
. M @ZXPARY@(NEWPATH)=GD ; IF MULITPLE DATA MERGE TO THE ARRAY
E I $D(GD(1)) D ;
. S @ZXPARY@(NEWPATH)=GD(1) ; IF SINGLE VALUE, ADD TO ARRAY
. I GD(1)'="" D ADDNARY(NEWPATH,GD(1)) ; ADD TO NHIN ARRAY
N ZFRST S ZFRST=$$FIRST(ZOID) ; SET FIRST CHILD
I ZFRST'=0 D ; THERE IS A CHILD
. N ZNUM
. N ZMULT S ZMULT=$$ISMULT(ZFRST) ; IS FIRST CHILD A MULTIPLE
. D DOMO(ZFRST,NEWPATH,ZNARY,ZXIDX,ZXPARY,$S(ZMULT:1,1:""),ZREDUX) ; THE CHILD
N GNXT S GNXT=$$NXTSIB(ZOID)
I $$TAG(GNXT)'=$$TAG(ZOID) S ZNUM="" ; RESET COUNTING AFTER MULTIPLES
I GNXT'=0 D ;
. N ZMULT S ZMULT=$$ISMULT(GNXT) ; IS THE SIBLING A MULTIPLE?
. I (ZNUM="")&(ZMULT) D ; SIBLING IS FIRST OF MULTIPLES
. . N ZNUM S ZNUM=1 ;
. . D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,ZNUM,ZREDUX) ; DO NEXT SIB
. E D DOMO(GNXT,ZPATH,ZNARY,ZXIDX,ZXPARY,$S(ZNUM>0:ZNUM+1,1:""),ZREDUX) ; SIB
Q
;
ADDNARY(ZXP,ZVALUE) ; ADD AN NHIN ARRAY VALUE TO ZNARY
;
N ZZI,ZZJ,ZZN
S ZZI=$P(ZXP,"/",1) ; FIRST PIECE OF XPATH ARRAY
I ZZI="" Q ; DON'T ADD THIS ONE .. PROBABLY THE //results NODE
S ZZJ=$P(ZXP,ZZI_"/",2) ; REST OF XPATH ARRAY
S ZZJ=$TR(ZZJ,"/",".") ; REPLACE / WITH .
I ZZI'["]" D ; A SINGLETON
. S ZZN=1
E D ; THERE IS AN [x] OCCURANCE
. S ZZN=$P($P(ZZI,"[",2),"]",1) ; PULL OUT THE OCCURANCE
. S ZZI=$P(ZZI,"[",1) ; TAKE OUT THE [X]
I ZZJ'="" S @ZNARY@(ZZI,ZZN,ZZJ)=ZVALUE
Q
;
PARSE(INXML,INDOC) ;CALL THE MXML PARSER ON INXML, PASSED BY NAME
; INDOC IS PASSED AS THE DOCUMENT NAME - DON'T KNOW WHERE TO STORE THIS NOW
; EXTRINSIC WHICH RETURNS THE DOCID ASSIGNED BY MXML
;Q $$EN^MXMLDOM(INXML)
Q $$EN^MXMLDOM(INXML,"W")
;
ISMULT(ZOID) ; RETURN TRUE IF ZOID IS ONE OF A MULTIPLE
N ZN
;I $$TAG(ZOID)["entry" B
S ZN=$$NXTSIB(ZOID)
I ZN'="" Q $$TAG(ZOID)=$$TAG(ZN) ; IF TAG IS THE SAME AS NEXT SIB TAG
Q 0
;
FIRST(ZOID) ;RETURNS THE OID OF THE FIRST CHILD OF ZOID
Q $$CHILD^MXMLDOM(C0CDOCID,ZOID)
;
PARENT(ZOID) ;RETURNS THE OID OF THE PARENT OF ZOID
Q $$PARENT^MXMLDOM(C0CDOCID,ZOID)
;
ATT(RTN,NODE) ;GET ATTRIBUTES FOR ZOID
S HANDLE=C0CDOCID
K @RTN
D GETTXT^MXMLDOM("A")
Q
;
TAG(ZOID) ; RETURNS THE XML TAG FOR THE NODE
;I ZOID=149 B ;GPLTEST
N X,Y
S Y=""
S X=$G(C0CCBK("TAG")) ;IS THERE A CALLBACK FOR THIS ROUTINE
I X'="" X X ; EXECUTE THE CALLBACK, SHOULD SET Y
I Y="" S Y=$$NAME^MXMLDOM(C0CDOCID,ZOID)
Q Y
;
NXTSIB(ZOID) ; RETURNS THE NEXT SIBLING
Q $$SIBLING^MXMLDOM(C0CDOCID,ZOID)
;
DATA(ZT,ZOID) ; RETURNS DATA FOR THE NODE
;N ZT,ZN S ZT=""
;S C0CDOM=$NA(^TMP("MXMLDOM",$J,C0CDOCID))
;Q $G(@C0CDOM@(ZOID,"T",1))
S ZN=$$TEXT^MXMLDOM(C0CDOCID,ZOID,ZT)
Q
;
OUTXML(ZRTN,INID) ; USES C0CMXMLB (MXMLBLD) TO OUTPUT XML FROM AN MXMLDOM
;
S C0CDOCID=INID
D START^C0CMXMLB($$TAG(1),,"G")
D NDOUT($$FIRST(1))
D END^C0CMXMLB ;END THE DOCUMENT
M @ZRTN=^TMP("MXMLBLD",$J)
K ^TMP("MXMLBLD",$J)
Q
;
NDOUT(ZOID) ;CALLBACK ROUTINE - IT IS RECURSIVE
N ZI S ZI=$$FIRST(ZOID)
I ZI'=0 D ; THERE IS A CHILD
. N ZATT D ATT("ZATT",ZOID) ; THESE ARE THE ATTRIBUTES MOVED TO ZATT
. D MULTI^C0CMXMLB("",$$TAG(ZOID),.ZATT,"NDOUT^C0CMXML(ZI)") ;HAVE CHILDREN
E D ; NO CHILD - IF NO CHILDREN, A NODE HAS DATA, IS AN ENDPOINT
. ;W "DOING",ZOID,!
. N ZD D DATA("ZD",ZOID) ;NODES WITHOUT CHILDREN HAVE DATA
. N ZATT D ATT("ZATT",ZOID) ;ATTRIBUTES
. D ITEM^C0CMXMLB("",$$TAG(ZOID),.ZATT,$G(ZD(1))) ;NO CHILDREN
I $$NXTSIB(ZOID)'=0 D ; THERE IS A SIBLING
. D NDOUT($$NXTSIB(ZOID)) ;RECURSE FOR SIBLINGS
Q
;
WNHIN(ZDFN) ; WRITES THE XML OUTPUT OF GET^NHINV TO AN XML FILE
;
N GN,GN2
D GET^NHINV(.GN,ZDFN) ; EXTRACT THE XML
S GN2=$NA(@GN@(1))
W $$OUTPUT^C0CXPATH(GN2,"nhin_"_ZDFN_".xml","/home/wvehr3-09/")
Q
;
TESTNARY ; TEST MAKING A NHIN ARRAY
N ZI S ZI=""
N ZH ; DOM HANDLE
D TEST1 ; PARSE AN NHIN RESULT INTO THE DOM
S ZH=C0CDOCID ; SET THE HANDLE
N ZD S ZD=$NA(^TMP("MXMLDOM",$J,ZH))
F S ZI=$O(@ZD@(ZI)) Q:ZI="" D ; FOR EACH NODE
. N ZATT
. D MNARY(.ZATT,ZH,ZI)
. N ZPRE,ZN
. S ZPRE=$$PRE(ZI)
. S ZN=$P(ZPRE,",",2)
. S ZPRE=$P(ZPRE,",",1)
. ;I $D(ZATT) ZWR ZATT
. N ZJ S ZJ=""
. F S ZJ=$O(ZATT(ZJ)) Q:ZJ="" D ; FOR EACH ATTRIBUTE
. . W ZPRE_"["_ZN_"]"_$$TAG(ZI)_"."_ZJ_"="_ZATT(ZJ),!
. . S GOUT(ZPRE,ZN,$$TAG(ZI)_"."_ZJ)=ZATT(ZJ)
Q
;
PRE(ZNODE) ; EXTRINSIC WHICH RETURNS THE PREFIX FOR A NODE
;
N GI,GI2,GPT,GJ,GN
S GI=$$PARENT(ZNODE) ; PARENT NODE
I GI=0 Q "" ; NO PARENT
S GPT=$$TAG(GI) ; TAG OF PARENT
S GI2=$$PARENT(GI) ; PARENT OF PARENT
I (GI2'=0)&($$TAG(GI2)'="results") S GPT=$$TAG(GI2)_"."_GPT
S GJ=$$FIRST(GI) ; NODE OF FIRST SIB
I GJ=ZNODE Q:$$TAG(GI)_",1"
F GN=2:1 Q:GJ=ZNODE D ;
. S GJ=$$NXTSIB(GJ) ; NEXT SIBLING
Q GPT_","_GN
;
MNARY(ZRTN,ZHANDLE,ZOID) ; MAKE A NHIN ARRAY FROM A DOM NODE
; RETURNED IN ZRTN, PASSED BY REFERENCE
; ZHANDLE IS THE DOM DOCUMENT ID
; ZOID IS THE DOM NODE
D ATT("ZRTN",ZOID)
Q
;

View File

@ -1,393 +1,413 @@
C0CVITAL ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08 C0CVITAL ; CCDCCR/CJE/GPL - CCR/CCD PROCESSING FOR VITALS ; 07/16/08
;;1.0;C0C;;May 19, 2009; ;;1.0;C0C;;May 19, 2009;Build 38
;Copyright 2008,2009 George Lilly, University of Minnesota and others. ;Copyright 2008,2009 George Lilly, University of Minnesota and others.
;Licensed under the terms of the GNU General Public License. ;Licensed under the terms of the GNU General Public License.
;See attached copy of the License. ;See attached copy of the License.
; ;
;This program is free software; you can redistribute it and/or modify ;This program is free software; you can redistribute it and/or modify
;it under the terms of the GNU General Public License as published by ;it under the terms of the GNU General Public License as published by
;the Free Software Foundation; either version 2 of the License, or ;the Free Software Foundation; either version 2 of the License, or
;(at your option) any later version. ;(at your option) any later version.
; ;
;This program is distributed in the hope that it will be useful, ;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of ;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;GNU General Public License for more details. ;GNU General Public License for more details.
; ;
;You should have received a copy of the GNU General Public License along ;You should have received a copy of the GNU General Public License along
;with this program; if not, write to the Free Software Foundation, Inc., ;with this program; if not, write to the Free Software Foundation, Inc.,
;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ;51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; ;
W "NO ENTRY FROM TOP",! W "NO ENTRY FROM TOP",!
Q Q
; ;
EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE EXTRACT(VITXML,DFN,VITOUTXML) ; EXTRACT VITALS INTO PROVIDED XML TEMPLATE
; ;
; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED ; VITXML AND OUTXML ARE PASSED BY NAME SO GLOBALS CAN BE USED
; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE ; IVITXML CONTAINS ONLY THE VITALS SECTION OF THE OVERALL TEMPLATE
; ;
N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR N VITRSLT,J,K,VITPTMP,X,VITVMAP,TBUF,VORDR
S C0CVLMT=$$GET^C0CPARMS("VITLIMIT") ; GET THE LIMIT PARM S C0CVLMT=$$GET^C0CPARMS("VITLIMIT") ; GET THE LIMIT PARM
S C0CVSTRT=$$GET^C0CPARMS("VITSTART") ; GET START PARM S C0CVSTRT=$$GET^C0CPARMS("VITSTART") ; GET START PARM
D DT^DILF(,C0CVLMT,.C0CEDT) ; D DT^DILF(,C0CVLMT,.C0CEDT) ;
D DT^DILF(,C0CVSTRT,.C0CSDT) ; D DT^DILF(,C0CVSTRT,.C0CSDT) ;
;D DT^DILF(,C0CVLMT,.C0CSDT) ; GPL TESTING ;D DT^DILF(,C0CVLMT,.C0CSDT) ; GPL TESTING
;D DT^DILF(,C0CVSTRT,.C0CEDT) ; ;D DT^DILF(,C0CVSTRT,.C0CEDT) ;
W "VITALS START: ",C0CVSTRT," LIMIT: ",C0CVLMT,! W "VITALS START: ",C0CVSTRT," LIMIT: ",C0CVLMT,!
I $$RPMS^C0CUTIL() D VITRPMS QUIT I $$RPMS^C0CUTIL() D VITRPMS QUIT
I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VITVISTA QUIT I ($$VISTA^C0CUTIL())!($$WV^C0CUTIL())!($$OV^C0CUTIL()) D VITVISTA QUIT
;I $$SYSNAME^C0CSYS()="RPMS" D VITRPMS ;I $$SYSNAME^C0CSYS()="RPMS" D VITRPMS
;E D VITVISTA ;E D VITVISTA
Q Q
; ;
VITVISTA ; EXTRACT VITALS FROM VISTA INTO PROVIDED XML TEMPLATE VITVISTA ; EXTRACT VITALS FROM VISTA INTO PROVIDED XML TEMPLATE
D FASTVIT^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ; GPL THIS ONE WORKS FOR AT D FASTVIT^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ; GPL THIS ONE WORKS FOR AT
; LEAST ONE SET OF VITALS - TO DO, CALL IT REPETIVELY TO GET EARLIER VITALS ; LEAST ONE SET OF VITALS - TO DO, CALL IT REPETIVELY TO GET EARLIER VITALS
;D VITALS^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT) ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CEDT,C0CSDT)
;D VITALS^ORQQVI(.VITRSLT,DFN,C0CSDT,C0CEDT) ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CSDT,C0CEDT)
;D VITALS^ORQQVI(.VITRSLT,DFN,C0CVSTRT,C0CVLMT) ; GPL LET GMR HANDLE THE DATES ;D VITALS^ORQQVI(.VITRSLT,DFN,C0CVSTRT,C0CVLMT) ; GPL LET GMR HANDLE THE DATES
I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT I '$D(VITRSLT(1)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC I $P(VITRSLT(1),U,2)="No vitals found." D Q ; NULL RESULT FROM RPC
. I DEBUG W "NO VITALS FOUND FROM VITALS RPC",! . I DEBUG W "NO VITALS FOUND FROM VITALS RPC",!
. S @VITOUTXML@(0)=0 . S @VITOUTXML@(0)=0
I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT I $P(VITRSLT(1),U,2)="No vitals found." Q ; QUIT
; ZWR RPCRSLT ; ZWR RPCRSLT
S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS")) S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP")) S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
D VITDVISTA(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY D VITDVISTA(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
; I DEBUG ZWR VDATES ;DEBUG I DEBUG ZWR VDATES ;DEBUG
S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. I $D(VITRSLT(VSORT(J))) D . I $D(VITRSLT(VSORT(J))) D
. . S VITVMAP=$NA(@VITTVMAP@(J)) . . S VITVMAP=$NA(@VITTVMAP@(J))
. . K @VITVMAP . . K @VITVMAP
. . I DEBUG W "VMAP= ",VITVMAP,! . . I DEBUG W "VMAP= ",VITVMAP,!
. . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY . . S VITPTMP=VITRSLT(VSORT(J)) ; DATE SORTED VITAL FROM RETURN ARRAY
. . I DEBUG W "VITAL ",VSORT(J),! . . I DEBUG W "VITAL ",VSORT(J),!
. . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),! . . I DEBUG W VITRSLT(VSORT(J))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
. . I DEBUG W $P(VITPTMP,U,4),! . . I DEBUG W $P(VITPTMP,U,4),!
. . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
. . I $P(VITPTMP,U,2)="HT" D . . ;B ;gpl
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D ;
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . I $P(VITPTMP,U,2)="HT" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="WT" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="in"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="WT" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="BP" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="lbs"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="BP" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="T" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="T" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="R" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="F"
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="R" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="P" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="P" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E I $P(VITPTMP,U,2)="PN" D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . E I $P(VITPTMP,U,2)="PN" D
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . E D . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . ;W "IN VITAL: OTHER",! . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL" . . E I $P(VITPTMP,U,2)="BMI" D
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . ;S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . ;S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="" . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BMI"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="60621009"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3) . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . S VITARYTMP=$NA(@VITTARYTMP@(J)) . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P(^GMR(120.5,$P(VITPTMP,U,1),0),U,6)
. . K @VITARYTMP . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
. . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP) . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=""
. . I J=1 D ; FIRST ONE IS JUST A COPY . . E D
. . . ; W "FIRST ONE",! . . . ;W "IN VITAL: OTHER",!
. . . D CP^C0CXPATH(VITARYTMP,VITOUTXML) . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . I DEBUG W "VITOUTXML ",VITOUTXML,! . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . I J>1 D ; AFTER THE FIRST, INSERT INNER XML . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER VITAL"
. . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP) . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
; ZWR ^TMP($J,"VITALS",*) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="UNKNOWN"
I DEBUG D PARY^C0CXPATH(VITOUTXML) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="OTHER"
N VITTMP,I . . . ;S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS . . . ;S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . . . ;S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. W "VITALS MISSING ",! . . . ;S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^GMR(120.5,$P(VITPTMP,U,1),0)),U,6)
. F I=1:1:VITTMP(0) W VITTMP(I),! . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P(VITPTMP,U,3)
Q . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")="UNKNOWN"
; . . I @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_" D ;
VITRPMS ; EXTRACT VITALS FROM RPMS INTO PROVIDED XML TEMPLATE . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORSYSTEM_1" ;
; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE . . S VITARYTMP=$NA(@VITTARYTMP@(J))
; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE . . K @VITARYTMP
N END,START,DATA . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
D DT^DILF("",C0CVLMT,.END) . . I J=1 D ; FIRST ONE IS JUST A COPY
D DT^DILF("",C0CVSTRT,.START) . . . ; W "FIRST ONE",!
; RPC OUTPUT FORMAT: . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric) . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
I '$D(^TMP("CIAVMRPC",$J)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
;ZW ^TMP("CIAVMRPC",$J) ; ZWR ^TMP($J,"VITALS",*)
S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS")) ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP")) I DEBUG D PARY^C0CXPATH(VITOUTXML)
K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES N VITTMP,I
N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
D VITDRPMS(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE . W "VITALS MISSING ",!
; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY . F I=1:1:VITTMP(0) W VITTMP(I),!
S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS Q
F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST ;
. I $D(^TMP("CIAVMRPC",$J,0,(VSORT(J)))) D VITRPMS ; EXTRACT VITALS FROM RPMS INTO PROVIDED XML TEMPLATE
. . S VITVMAP=$NA(@VITTVMAP@(J)) ; RPMS VITAL RPC ONLY RETURNS LATEST VITAL IN SPECIFIED DATE RANGE NOT ALL VITALS IN DATE RANGE
. . K @VITVMAP ; WE NEED TO SETUP THE VARIABLES THE INTERNAL CALL NEEDS TO BYPASS A HARD CODE OF ONE VITAL FOR DATE RANGE
. . I DEBUG W "VMAP= ",VITVMAP,! N END,START,DATA
. . S VITPTMP=^TMP("CIAVMRPC",$J,0,(VSORT(J))) ; DATE SORTED VITAL FROM RETURN ARRAY D DT^DILF("",C0CVLMT,.END)
. . I DEBUG W "VITAL ",VSORT(J),! D DT^DILF("",C0CVSTRT,.START)
. . I DEBUG W ^TMP("CIAVMRPC",$J,0,(VSORT(J)))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),! ; RPC OUTPUT FORMAT:
. . I DEBUG W $P(VITPTMP,U,4),! ; vfile ien^vital name^vital abbr^date/time taken(FM FORMAT)^value+units (US & metric)
. . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID D QUERY^BEHOVM("LISTX") ; RUN QUERY VITALS CALL
. . I $P(VITPTMP,U,3)="HT" D I '$D(^TMP("CIAVMRPC",$J)) S @VITOUTXML@(0)=0 Q ; RETURN NOT FOUND AND QUIT
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" ;ZW ^TMP("CIAVMRPC",$J)
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") S VITTVMAP=$NA(^TMP("C0CCCR",$J,"VITALS"))
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" S VITTARYTMP=$NA(^TMP("C0CCCR",$J,"VITALARYTMP"))
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" K @VITTVMAP,@VITTARYTMP ; KILL OLD ARRAY VALUES
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J N VSORT,VDATES,VCNT ; ARRAY FOR DATE SORTED VITALS INDEX
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" D VITDRPMS(.VDATES) ; PULL OUT THE DATES INTO AN ARRAY
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT" S VCNT=$$SORTDT^C0CUTIL(.VSORT,.VDATES,-1) ; PUT VITALS IN REVERSE
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008" ; DATE ORDER AND COUNT THEM. VSORT CONTAINS INDIRECT INDEXES ONLY
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" S @VITTVMAP@(0)=VCNT ; SAVE NUMBER OF VITALS
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" F J=1:1:VCNT D ; FOR EACH VITAL IN THE LIST
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . I $D(^TMP("CIAVMRPC",$J,0,(VSORT(J)))) D
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . S VITVMAP=$NA(@VITTVMAP@(J))
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . K @VITVMAP
. . E I $P(VITPTMP,U,3)="WT" D . . I DEBUG W "VMAP= ",VITVMAP,!
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . S VITPTMP=^TMP("CIAVMRPC",$J,0,(VSORT(J))) ; DATE SORTED VITAL FROM RETURN ARRAY
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . I DEBUG W "VITAL ",VSORT(J),!
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . I DEBUG W ^TMP("CIAVMRPC",$J,0,(VSORT(J)))," ",$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT"),!
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . I DEBUG W $P(VITPTMP,U,4),!
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . S @VITVMAP@("VITALSIGNSDATAOBJECTID")="VITAL"_J ; UNIQUE OBJID
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . I $P(VITPTMP,U,3)="HT" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="HEIGHT"
. . E I $P(VITPTMP,U,3)="BP" D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="248327008"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . E I $P(VITPTMP,U,3)="WT" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="WEIGHT"
. . E I $P(VITPTMP,U,3)="TMP" D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="107647005"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . E I $P(VITPTMP,U,3)="BP" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="BLOOD PRESSURE"
. . E I $P(VITPTMP,U,3)="RS" D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="392570002"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . E I $P(VITPTMP,U,3)="TMP" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="TEMPERATURE"
. . E I $P(VITPTMP,U,3)="PU" D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="309646008"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . E I $P(VITPTMP,U,3)="RS" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="RESPIRATION"
. . E I $P(VITPTMP,U,3)="PA" D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366147009"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . E I $P(VITPTMP,U,3)="PU" D
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000" . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PULSE"
. . E D . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="366199006"
. . . ;W "IN VITAL: OTHER",! . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT") . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2) . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1" . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J . . E I $P(VITPTMP,U,3)="PA" D
. . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED" . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2) . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
. . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="" . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="" . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
. . . S @VITVMAP@("VITALSIGNSCODEVERSION")="" . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
. . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4) . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")="PAIN"
. . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2) . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")="22253000"
. . S VITARYTMP=$NA(@VITTARYTMP@(J)) . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")="SNOMED"
. . K @VITARYTMP . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
. . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP) . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
. . I J=1 D ; FIRST ONE IS JUST A COPY . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
. . . ; W "FIRST ONE",! . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
. . . D CP^C0CXPATH(VITARYTMP,VITOUTXML) . . E D
. . . I DEBUG W "VITOUTXML ",VITOUTXML,! . . . ;W "IN VITAL: OTHER",!
. . I J>1 D ; AFTER THE FIRST, INSERT INNER XML . . . S @VITVMAP@("VITALSIGNSDATETIMETYPETEXT")="OBSERVED"
. . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP) . . . S @VITVMAP@("VITALSIGNSEXACTDATETIME")=$$FMDTOUTC^C0CUTIL($P(VITPTMP,U,4),"DT")
; ZWR ^TMP($J,"VITALS",*) . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS . . . S @VITVMAP@("VITALSIGNSSOURCEACTORID")="ACTORSYSTEM_1"
I DEBUG D PARY^C0CXPATH(VITOUTXML) . . . S @VITVMAP@("VITALSIGNSTESTOBJECTID")="VITALTEST"_J
N VITTMP,I . . . S @VITVMAP@("VITALSIGNSTESTTYPETEXT")="OBSERVED"
D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS . . . S @VITVMAP@("VITALSIGNSDESCRIPTIONTEXT")=$P(VITPTMP,U,2)
I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@ . . . S @VITVMAP@("VITALSIGNSDESCCODEVALUE")=""
. W "VITALS MISSING ",! . . . S @VITVMAP@("VITALSIGNSDESCCODINGSYSTEM")=""
. F I=1:1:VITTMP(0) W VITTMP(I),! . . . S @VITVMAP@("VITALSIGNSCODEVERSION")=""
K ^TMP("CIAVMRPC",$J) . . . S @VITVMAP@("VITALSIGNSTESTSOURCEACTORID")="ACTORPROVIDER_"_$P($G(^AUPNVMSR($P(VITPTMP,U,1),12)),U,4)
Q . . . S @VITVMAP@("VITALSIGNSTESTRESULTVALUE")=$P($P(VITPTMP,U,5)," ",1)
; . . . S @VITVMAP@("VITALSIGNSTESTRESULTUNIT")=$P($P(VITPTMP,U,5)," ",2)
VITDRPMS(VDT) ; RUN DATE SORTING ALGORITHM FOR RPMS . . S VITARYTMP=$NA(@VITTARYTMP@(J))
; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY . . K @VITARYTMP
; OF DATES IN THE VITALS RESULTS . . D MAP^C0CXPATH(VITXML,VITVMAP,VITARYTMP)
N VDTI,VDTJ,VTDCNT . . I J=1 D ; FIRST ONE IS JUST A COPY
S VTDCNT=0 ; COUNT TO BUILD ARRAY . . . ; W "FIRST ONE",!
S VDTJ="" ; USED TO VISIT THE RESULTS . . . D CP^C0CXPATH(VITARYTMP,VITOUTXML)
F VDTI=0:0 D Q:$O(^TMP("CIAVMRPC",$J,0,VDTJ))="" ; VISIT ALL RESULTS . . . I DEBUG W "VITOUTXML ",VITOUTXML,!
. S VDTJ=$O(^TMP("CIAVMRPC",$J,0,VDTJ)) ; NEXT RESULT . . I J>1 D ; AFTER THE FIRST, INSERT INNER XML
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER . . . D INSINNER^C0CXPATH(VITOUTXML,VITARYTMP)
. S VDT(VTDCNT)=$P(^TMP("CIAVMRPC",$J,0,VDTJ),U,4) ; PULL OUT THE DATE ; ZWR ^TMP($J,"VITALS",*)
S VDT(0)=VTDCNT ; ZWR ^TMP($J,"VITALARYTMP",*) ; SHOW THE RESULTS
Q I DEBUG D PARY^C0CXPATH(VITOUTXML)
; N VITTMP,I
VITDVISTA(VDT) ; RUN DATE SORTING ALGORITHM FOR VISTA D MISSING^C0CXPATH(VITOUTXML,"VITTMP") ; SEARCH XML FOR MISSING VARS
; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY I VITTMP(0)>0 D ; IF THERE ARE MISSING VARS - MARKED AS @@X@@
; OF DATES IN THE VITALS RESULTS . W "VITALS MISSING ",!
N VDTI,VDTJ,VTDCNT . F I=1:1:VITTMP(0) W VITTMP(I),!
S VTDCNT=0 ; COUNT TO BUILD ARRAY K ^TMP("CIAVMRPC",$J)
S VDTJ="" ; USED TO VISIT THE RESULTS Q
F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS ;
. S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT VITDRPMS(VDT) ; RUN DATE SORTING ALGORITHM FOR RPMS
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER ; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
. S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE ; OF DATES IN THE VITALS RESULTS
S VDT(0)=VTDCNT N VDTI,VDTJ,VTDCNT
Q S VTDCNT=0 ; COUNT TO BUILD ARRAY
; S VDTJ="" ; USED TO VISIT THE RESULTS
F VDTI=0:0 D Q:$O(^TMP("CIAVMRPC",$J,0,VDTJ))="" ; VISIT ALL RESULTS
. S VDTJ=$O(^TMP("CIAVMRPC",$J,0,VDTJ)) ; NEXT RESULT
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
. S VDT(VTDCNT)=$P(^TMP("CIAVMRPC",$J,0,VDTJ),U,4) ; PULL OUT THE DATE
S VDT(0)=VTDCNT
Q
;
VITDVISTA(VDT) ; RUN DATE SORTING ALGORITHM FOR VISTA
; VDT IS PASSED BY REFERENCE AND WILL CONTAIN THE ARRAY
; OF DATES IN THE VITALS RESULTS
N VDTI,VDTJ,VTDCNT
S VTDCNT=0 ; COUNT TO BUILD ARRAY
S VDTJ="" ; USED TO VISIT THE RESULTS
F VDTI=0:0 D Q:$O(VITRSLT(VDTJ))="" ; VISIT ALL RESULTS
. S VDTJ=$O(VITRSLT(VDTJ)) ; NEXT RESULT
. S VTDCNT=VTDCNT+1 ; INCREMENT COUNTER
. S VDT(VTDCNT)=$P(VITRSLT(VDTJ),U,4) ; PULL OUT THE DATE
S VDT(0)=VTDCNT
Q
;