PXVWPXML ;ISP/LMT - Parse XML message from ICE ;Jul 17, 2018@07:01
;;1.0;PCE PATIENT CARE ENCOUNTER;**217**;Aug 12, 1996;Build 134
;
;
EN ; Entry Point
;
; Parse XML message from ICE in ^TMP("PXICEXML",$J).
; Return parsed data in ^TMP("PXICEWEB",$J).
;
N PXCALLBACK,PXFORECAST,PXHIST,PXLEVEL,PXN,PXOBSFOCUS,PXPATH
;
S PXHIST=0
S PXFORECAST=0
S PXPATH=""
S PXLEVEL=0
S PXOBSFOCUS=""
;
S PXCALLBACK("STARTELEMENT")="STARTEL^PXVWPXML"
S PXCALLBACK("ENDELEMENT")="ENDEL^PXVWPXML"
;S PXCALLBACK("CHARACTERS")="CHARS^PXVWPXML"
S PXCALLBACK("ERROR")="ERROR^PXVWPXML"
D EN^MXMLPRSE($NA(^TMP("PXICEXML",$J)),.PXCALLBACK,"W")
;
D FORMAT
;
Q
;
STARTEL(PXELEMENT,PXATTLIST) ; start element
;
; ZEXCEPT: PXFORECAST,PXHIST,PXLEVEL,PXN,PXPATH
;
I PXELEMENT="substanceAdministrationEvents" D Q
. S PXHIST=1
. S PXFORECAST=0
. S PXPATH=""
. S PXLEVEL=0
. K PXN
;
I PXELEMENT="substanceAdministrationProposals" D Q
. S PXHIST=0
. S PXFORECAST=1
. S PXPATH=""
. S PXLEVEL=0
. K PXN
;
I 'PXHIST,'PXFORECAST Q
;
S PXPATH=PXPATH_$S(PXPATH'="":",",1:"")_PXELEMENT
S PXLEVEL=PXLEVEL+1
;
I PXHIST D HISTORY
I PXFORECAST D FORECAST
;
Q
;
HISTORY ; Process "history" portion of XML document
;
; ZEXCEPT: PXATTLIST,PXLEVEL,PXN,PXPATH
;
N PXADMDT,PXCODE,PXCODESYS,PXDISNAME,PXX
;
I PXPATH="substanceAdministrationEvent,id" D Q
. S PXX=$G(PXATTLIST("root"))
. ;S PXN(1)=$G(PXN(1))+1
. S PXN(1)=$P(PXX,":",6)
. S PXN(2)=""
. S PXN(3)=""
. I PXN(1)="" Q
. S PXX=$G(^AUPNVIMM(+PXN(1),0))
. S PXADMDT=$P($G(^AUPNVIMM(+PXN(1),12)),U,1)
. I PXADMDT="" D
. . S PXADMDT=$P($G(^AUPNVSIT(+$P(PXX,U,3),0)),U,1)
. S PXX=$G(^AUTTIMM(+$P(PXX,U,1),0))
. S ^TMP("PXICEWEB",$J,"HISTORY",PXN(1))=$P(PXX,U,1)_U_$P(PXX,U,3)_U_PXADMDT
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement" D Q
. S PXN(2)=$G(PXN(2))+1
. S PXN(3)=""
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,doseNumber" D Q
. I $G(PXN(1))=""!($G(PXN(2))="") Q
. S PXX=$G(PXATTLIST("value"))
. S $P(^TMP("PXICEWEB",$J,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,3)=PXX
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,substance,substanceCode" D Q
. I $G(PXN(1))=""!($G(PXN(2))="") Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.12.292" D ;CVX code system
. . S $P(^TMP("PXICEWEB",$J,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,4,5)=PXCODE_U_PXDISNAME
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,observationFocus" D Q
. I $G(PXN(1))=""!($G(PXN(2))="") Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.1" D ;Vaccine Group code system
. . S $P(^TMP("PXICEWEB",$J,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,1,2)=$P(PXDISNAME," Vaccine Group",1)_U_PXDISNAME
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,observationValue,concept" D Q
. I $G(PXN(1))=""!($G(PXN(2))="") Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.2" D ;validity code system
. . S $P(^TMP("PXICEWEB",$J,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,6,7)=PXCODE_U_PXDISNAME
;
I PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,interpretation" D Q
. I $G(PXN(1))=""!($G(PXN(2))="") Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.3" D ;validity reason code system
. . S PXN(3)=$G(PXN(3))+1
. . S ^TMP("PXICEWEB",$J,"HISTORY",PXN(1),"COMPONENT",PXN(2),"REASON",PXN(3))=PXCODE_U_PXDISNAME
;
Q
;
FORECAST ; Process "forecast" portion of XML document
;
; ZEXCEPT: PXATTLIST,PXELEMENT,PXLEVEL,PXN,PXOBSFOCUS,PXPATH
;
N PXCODE,PXCODESYS,PXDISNAME,PXHIGH,PXLOW,PXX
;
I PXPATH="substanceAdministrationProposal" D Q
. S PXN(1)=$G(PXN(1))+1
. S PXN(2)=""
;
; What's being recommended
I PXPATH="substanceAdministrationProposal,substance,substanceCode" D Q
. I $G(PXN(1))="" Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.1" D ;Vaccine Group code system (most common)
. . S PXCODE="G:"_$P(PXDISNAME," Vaccine Group",1)
. . S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,2,3)=PXCODE_U_PXDISNAME
. I PXCODESYS="2.16.840.1.113883.12.292" D ;CVX code system (less common)
. . S PXCODE="C:"_PXCODE
. . S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,2,3)=PXCODE_U_PXDISNAME
;
I PXPATH="substanceAdministrationProposal,proposedAdministrationTimeInterval" D Q
. I $G(PXN(1))="" Q
. S PXLOW=$E($G(PXATTLIST("low")),1,8)
. I PXLOW'="" S PXLOW=$$HL7TFM^XLFDT(PXLOW)
. S PXHIGH=$E($G(PXATTLIST("high")),1,8)
. I PXHIGH'="" S PXHIGH=$$HL7TFM^XLFDT(PXHIGH)
. S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,4,5)=PXLOW_U_PXHIGH
;
I PXPATH="substanceAdministrationProposal,validAdministrationTimeInterval" D Q
. I $G(PXN(1))="" Q
. S PXLOW=$E($G(PXATTLIST("low")),1,8)
. I PXLOW'="" S PXLOW=$$HL7TFM^XLFDT(PXLOW)
. S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,6)=PXLOW
;
I PXPATH="substanceAdministrationProposal,relatedClinicalStatement" D Q
. S PXOBSFOCUS=""
;
; Which vaccine group recommendedation applies to
I PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationFocus" D Q
. I $G(PXN(1))="" Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.1" D ;Vaccine Group code system
. . S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,1)=$P(PXDISNAME," Vaccine Group",1)
. S PXOBSFOCUS=PXCODE_U_PXDISNAME_U_PXCODESYS
;
I PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationValue,concept" D Q
. I $G(PXN(1))="" Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.5" D
. . S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,7,8)=PXCODE_U_PXDISNAME
;
I PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,interpretation" D Q
. I $G(PXN(1))="" Q
. S PXCODE=$G(PXATTLIST("code"))
. S PXCODESYS=$G(PXATTLIST("codeSystem"))
. S PXDISNAME=$G(PXATTLIST("displayName"))
. I PXCODESYS="2.16.840.1.113883.3.795.12.100.6" D
. . S PXN(2)=$G(PXN(2))+1
. . S ^TMP("PXICEWEB",$J,"FORECAST",PXN(1),"REASON",PXN(2))=PXCODE_U_PXDISNAME
;
I PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationValue,text" D Q
. I $G(PXN(1))="" Q
. S PXX=$G(PXATTLIST("value"))
. I $P(PXOBSFOCUS,U,3)="2.16.840.1.113883.3.795.12.100.10" D
. . S $P(^TMP("PXICEWEB",$J,"FORECAST",PXN(1)),U,9)=PXX
;
Q
;
ENDEL(PXELEMENT) ; end element
;
; ZEXCEPT: PXFORECAST,PXHIST,PXLEVEL,PXPATH
;
I PXELEMENT="substanceAdministrationEvents" D Q
. S PXHIST=0
;
I PXELEMENT="substanceAdministrationProposals" D Q
. S PXFORECAST=0
;
I 'PXHIST,'PXFORECAST Q
;
S PXLEVEL=PXLEVEL-1
S PXPATH=$P(PXPATH,",",1,PXLEVEL)
;
Q
;
ERROR(PXERR) ; error encountered
;
; TODO: Deal with error handling.
;
Q
;
FORMAT ; Group everything by Vaccine Group
;
N PXCOMP,PXGRP,PXI,PXIEN,PXJ,PXNODE,PXNODE2
;
S PXI=0
F S PXI=$O(^TMP("PXICEWEB",$J,"FORECAST",PXI)) Q:'PXI D
. S PXNODE=$G(^TMP("PXICEWEB",$J,"FORECAST",PXI))
. S PXGRP=$P(PXNODE,U,1)
. I PXGRP="" Q
. S ^TMP("PXICEWEB",$J,PXGRP)=$P(PXNODE,U,2,9)
. M ^TMP("PXICEWEB",$J,PXGRP,"REASON")=^TMP("PXICEWEB",$J,"FORECAST",PXI,"REASON")
;
S PXI=0
F S PXI=$O(^TMP("PXICEWEB",$J,"HISTORY",PXI)) Q:'PXI D
. S PXNODE=$G(^TMP("PXICEWEB",$J,"HISTORY",PXI))
. S PXJ=0
. F S PXJ=$O(^TMP("PXICEWEB",$J,"HISTORY",PXI,"COMPONENT",PXJ)) Q:'PXJ D
. . S PXNODE2=$G(^TMP("PXICEWEB",$J,"HISTORY",PXI,"COMPONENT",PXJ))
. . S PXGRP=$P(PXNODE2,U,1)
. . I PXGRP="" Q
. . S ^TMP("PXICEWEB",$J,PXGRP,"HISTORY",PXI)=PXNODE_U_$P(PXNODE2,U,3,7)
. . M ^TMP("PXICEWEB",$J,PXGRP,"HISTORY",PXI,"REASON")=^TMP("PXICEWEB",$J,"HISTORY",PXI,"COMPONENT",PXJ,"REASON")
;
K ^TMP("PXICEWEB",$J,"FORECAST")
K ^TMP("PXICEWEB",$J,"HISTORY")
;
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HPXVWPXML 8944 printed Dec 13, 2024@02:32:17 Page 2
PXVWPXML ;ISP/LMT - Parse XML message from ICE ;Jul 17, 2018@07:01
+1 ;;1.0;PCE PATIENT CARE ENCOUNTER;**217**;Aug 12, 1996;Build 134
+2 ;
+3 ;
EN ; Entry Point
+1 ;
+2 ; Parse XML message from ICE in ^TMP("PXICEXML",$J).
+3 ; Return parsed data in ^TMP("PXICEWEB",$J).
+4 ;
+5 NEW PXCALLBACK,PXFORECAST,PXHIST,PXLEVEL,PXN,PXOBSFOCUS,PXPATH
+6 ;
+7 SET PXHIST=0
+8 SET PXFORECAST=0
+9 SET PXPATH=""
+10 SET PXLEVEL=0
+11 SET PXOBSFOCUS=""
+12 ;
+13 SET PXCALLBACK("STARTELEMENT")="STARTEL^PXVWPXML"
+14 SET PXCALLBACK("ENDELEMENT")="ENDEL^PXVWPXML"
+15 ;S PXCALLBACK("CHARACTERS")="CHARS^PXVWPXML"
+16 SET PXCALLBACK("ERROR")="ERROR^PXVWPXML"
+17 DO EN^MXMLPRSE($NAME(^TMP("PXICEXML",$JOB)),.PXCALLBACK,"W")
+18 ;
+19 DO FORMAT
+20 ;
+21 QUIT
+22 ;
STARTEL(PXELEMENT,PXATTLIST) ; start element
+1 ;
+2 ; ZEXCEPT: PXFORECAST,PXHIST,PXLEVEL,PXN,PXPATH
+3 ;
+4 IF PXELEMENT="substanceAdministrationEvents"
Begin DoDot:1
+5 SET PXHIST=1
+6 SET PXFORECAST=0
+7 SET PXPATH=""
+8 SET PXLEVEL=0
+9 KILL PXN
End DoDot:1
QUIT
+10 ;
+11 IF PXELEMENT="substanceAdministrationProposals"
Begin DoDot:1
+12 SET PXHIST=0
+13 SET PXFORECAST=1
+14 SET PXPATH=""
+15 SET PXLEVEL=0
+16 KILL PXN
End DoDot:1
QUIT
+17 ;
+18 IF 'PXHIST
IF 'PXFORECAST
QUIT
+19 ;
+20 SET PXPATH=PXPATH_$SELECT(PXPATH'="":",",1:"")_PXELEMENT
+21 SET PXLEVEL=PXLEVEL+1
+22 ;
+23 IF PXHIST
DO HISTORY
+24 IF PXFORECAST
DO FORECAST
+25 ;
+26 QUIT
+27 ;
HISTORY ; Process "history" portion of XML document
+1 ;
+2 ; ZEXCEPT: PXATTLIST,PXLEVEL,PXN,PXPATH
+3 ;
+4 NEW PXADMDT,PXCODE,PXCODESYS,PXDISNAME,PXX
+5 ;
+6 IF PXPATH="substanceAdministrationEvent,id"
Begin DoDot:1
+7 SET PXX=$GET(PXATTLIST("root"))
+8 ;S PXN(1)=$G(PXN(1))+1
+9 SET PXN(1)=$PIECE(PXX,":",6)
+10 SET PXN(2)=""
+11 SET PXN(3)=""
+12 IF PXN(1)=""
QUIT
+13 SET PXX=$GET(^AUPNVIMM(+PXN(1),0))
+14 SET PXADMDT=$PIECE($GET(^AUPNVIMM(+PXN(1),12)),U,1)
+15 IF PXADMDT=""
Begin DoDot:2
+16 SET PXADMDT=$PIECE($GET(^AUPNVSIT(+$PIECE(PXX,U,3),0)),U,1)
End DoDot:2
+17 SET PXX=$GET(^AUTTIMM(+$PIECE(PXX,U,1),0))
+18 SET ^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1))=$PIECE(PXX,U,1)_U_$PIECE(PXX,U,3)_U_PXADMDT
End DoDot:1
QUIT
+19 ;
+20 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement"
Begin DoDot:1
+21 SET PXN(2)=$GET(PXN(2))+1
+22 SET PXN(3)=""
End DoDot:1
QUIT
+23 ;
+24 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,doseNumber"
Begin DoDot:1
+25 IF $GET(PXN(1))=""!($GET(PXN(2))="")
QUIT
+26 SET PXX=$GET(PXATTLIST("value"))
+27 SET $PIECE(^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,3)=PXX
End DoDot:1
QUIT
+28 ;
+29 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,substance,substanceCode"
Begin DoDot:1
+30 IF $GET(PXN(1))=""!($GET(PXN(2))="")
QUIT
+31 SET PXCODE=$GET(PXATTLIST("code"))
+32 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+33 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+34 ;CVX code system
IF PXCODESYS="2.16.840.1.113883.12.292"
Begin DoDot:2
+35 SET $PIECE(^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,4,5)=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+36 ;
+37 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,observationFocus"
Begin DoDot:1
+38 IF $GET(PXN(1))=""!($GET(PXN(2))="")
QUIT
+39 SET PXCODE=$GET(PXATTLIST("code"))
+40 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+41 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+42 ;Vaccine Group code system
IF PXCODESYS="2.16.840.1.113883.3.795.12.100.1"
Begin DoDot:2
+43 SET $PIECE(^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,1,2)=$PIECE(PXDISNAME," Vaccine Group",1)_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+44 ;
+45 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,observationValue,concept"
Begin DoDot:1
+46 IF $GET(PXN(1))=""!($GET(PXN(2))="")
QUIT
+47 SET PXCODE=$GET(PXATTLIST("code"))
+48 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+49 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+50 ;validity code system
IF PXCODESYS="2.16.840.1.113883.3.795.12.100.2"
Begin DoDot:2
+51 SET $PIECE(^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1),"COMPONENT",PXN(2)),U,6,7)=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+52 ;
+53 IF PXPATH="substanceAdministrationEvent,relatedClinicalStatement,substanceAdministrationEvent,relatedClinicalStatement,observationResult,interpretation"
Begin DoDot:1
+54 IF $GET(PXN(1))=""!($GET(PXN(2))="")
QUIT
+55 SET PXCODE=$GET(PXATTLIST("code"))
+56 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+57 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+58 ;validity reason code system
IF PXCODESYS="2.16.840.1.113883.3.795.12.100.3"
Begin DoDot:2
+59 SET PXN(3)=$GET(PXN(3))+1
+60 SET ^TMP("PXICEWEB",$JOB,"HISTORY",PXN(1),"COMPONENT",PXN(2),"REASON",PXN(3))=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+61 ;
+62 QUIT
+63 ;
FORECAST ; Process "forecast" portion of XML document
+1 ;
+2 ; ZEXCEPT: PXATTLIST,PXELEMENT,PXLEVEL,PXN,PXOBSFOCUS,PXPATH
+3 ;
+4 NEW PXCODE,PXCODESYS,PXDISNAME,PXHIGH,PXLOW,PXX
+5 ;
+6 IF PXPATH="substanceAdministrationProposal"
Begin DoDot:1
+7 SET PXN(1)=$GET(PXN(1))+1
+8 SET PXN(2)=""
End DoDot:1
QUIT
+9 ;
+10 ; What's being recommended
+11 IF PXPATH="substanceAdministrationProposal,substance,substanceCode"
Begin DoDot:1
+12 IF $GET(PXN(1))=""
QUIT
+13 SET PXCODE=$GET(PXATTLIST("code"))
+14 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+15 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+16 ;Vaccine Group code system (most common)
IF PXCODESYS="2.16.840.1.113883.3.795.12.100.1"
Begin DoDot:2
+17 SET PXCODE="G:"_$PIECE(PXDISNAME," Vaccine Group",1)
+18 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,2,3)=PXCODE_U_PXDISNAME
End DoDot:2
+19 ;CVX code system (less common)
IF PXCODESYS="2.16.840.1.113883.12.292"
Begin DoDot:2
+20 SET PXCODE="C:"_PXCODE
+21 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,2,3)=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+22 ;
+23 IF PXPATH="substanceAdministrationProposal,proposedAdministrationTimeInterval"
Begin DoDot:1
+24 IF $GET(PXN(1))=""
QUIT
+25 SET PXLOW=$EXTRACT($GET(PXATTLIST("low")),1,8)
+26 IF PXLOW'=""
SET PXLOW=$$HL7TFM^XLFDT(PXLOW)
+27 SET PXHIGH=$EXTRACT($GET(PXATTLIST("high")),1,8)
+28 IF PXHIGH'=""
SET PXHIGH=$$HL7TFM^XLFDT(PXHIGH)
+29 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,4,5)=PXLOW_U_PXHIGH
End DoDot:1
QUIT
+30 ;
+31 IF PXPATH="substanceAdministrationProposal,validAdministrationTimeInterval"
Begin DoDot:1
+32 IF $GET(PXN(1))=""
QUIT
+33 SET PXLOW=$EXTRACT($GET(PXATTLIST("low")),1,8)
+34 IF PXLOW'=""
SET PXLOW=$$HL7TFM^XLFDT(PXLOW)
+35 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,6)=PXLOW
End DoDot:1
QUIT
+36 ;
+37 IF PXPATH="substanceAdministrationProposal,relatedClinicalStatement"
Begin DoDot:1
+38 SET PXOBSFOCUS=""
End DoDot:1
QUIT
+39 ;
+40 ; Which vaccine group recommendedation applies to
+41 IF PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationFocus"
Begin DoDot:1
+42 IF $GET(PXN(1))=""
QUIT
+43 SET PXCODE=$GET(PXATTLIST("code"))
+44 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+45 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+46 ;Vaccine Group code system
IF PXCODESYS="2.16.840.1.113883.3.795.12.100.1"
Begin DoDot:2
+47 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,1)=$PIECE(PXDISNAME," Vaccine Group",1)
End DoDot:2
+48 SET PXOBSFOCUS=PXCODE_U_PXDISNAME_U_PXCODESYS
End DoDot:1
QUIT
+49 ;
+50 IF PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationValue,concept"
Begin DoDot:1
+51 IF $GET(PXN(1))=""
QUIT
+52 SET PXCODE=$GET(PXATTLIST("code"))
+53 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+54 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+55 IF PXCODESYS="2.16.840.1.113883.3.795.12.100.5"
Begin DoDot:2
+56 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,7,8)=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+57 ;
+58 IF PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,interpretation"
Begin DoDot:1
+59 IF $GET(PXN(1))=""
QUIT
+60 SET PXCODE=$GET(PXATTLIST("code"))
+61 SET PXCODESYS=$GET(PXATTLIST("codeSystem"))
+62 SET PXDISNAME=$GET(PXATTLIST("displayName"))
+63 IF PXCODESYS="2.16.840.1.113883.3.795.12.100.6"
Begin DoDot:2
+64 SET PXN(2)=$GET(PXN(2))+1
+65 SET ^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1),"REASON",PXN(2))=PXCODE_U_PXDISNAME
End DoDot:2
End DoDot:1
QUIT
+66 ;
+67 IF PXPATH="substanceAdministrationProposal,relatedClinicalStatement,observationResult,observationValue,text"
Begin DoDot:1
+68 IF $GET(PXN(1))=""
QUIT
+69 SET PXX=$GET(PXATTLIST("value"))
+70 IF $PIECE(PXOBSFOCUS,U,3)="2.16.840.1.113883.3.795.12.100.10"
Begin DoDot:2
+71 SET $PIECE(^TMP("PXICEWEB",$JOB,"FORECAST",PXN(1)),U,9)=PXX
End DoDot:2
End DoDot:1
QUIT
+72 ;
+73 QUIT
+74 ;
ENDEL(PXELEMENT) ; end element
+1 ;
+2 ; ZEXCEPT: PXFORECAST,PXHIST,PXLEVEL,PXPATH
+3 ;
+4 IF PXELEMENT="substanceAdministrationEvents"
Begin DoDot:1
+5 SET PXHIST=0
End DoDot:1
QUIT
+6 ;
+7 IF PXELEMENT="substanceAdministrationProposals"
Begin DoDot:1
+8 SET PXFORECAST=0
End DoDot:1
QUIT
+9 ;
+10 IF 'PXHIST
IF 'PXFORECAST
QUIT
+11 ;
+12 SET PXLEVEL=PXLEVEL-1
+13 SET PXPATH=$PIECE(PXPATH,",",1,PXLEVEL)
+14 ;
+15 QUIT
+16 ;
ERROR(PXERR) ; error encountered
+1 ;
+2 ; TODO: Deal with error handling.
+3 ;
+4 QUIT
+5 ;
FORMAT ; Group everything by Vaccine Group
+1 ;
+2 NEW PXCOMP,PXGRP,PXI,PXIEN,PXJ,PXNODE,PXNODE2
+3 ;
+4 SET PXI=0
+5 FOR
SET PXI=$ORDER(^TMP("PXICEWEB",$JOB,"FORECAST",PXI))
if 'PXI
QUIT
Begin DoDot:1
+6 SET PXNODE=$GET(^TMP("PXICEWEB",$JOB,"FORECAST",PXI))
+7 SET PXGRP=$PIECE(PXNODE,U,1)
+8 IF PXGRP=""
QUIT
+9 SET ^TMP("PXICEWEB",$JOB,PXGRP)=$PIECE(PXNODE,U,2,9)
+10 MERGE ^TMP("PXICEWEB",$JOB,PXGRP,"REASON")=^TMP("PXICEWEB",$JOB,"FORECAST",PXI,"REASON")
End DoDot:1
+11 ;
+12 SET PXI=0
+13 FOR
SET PXI=$ORDER(^TMP("PXICEWEB",$JOB,"HISTORY",PXI))
if 'PXI
QUIT
Begin DoDot:1
+14 SET PXNODE=$GET(^TMP("PXICEWEB",$JOB,"HISTORY",PXI))
+15 SET PXJ=0
+16 FOR
SET PXJ=$ORDER(^TMP("PXICEWEB",$JOB,"HISTORY",PXI,"COMPONENT",PXJ))
if 'PXJ
QUIT
Begin DoDot:2
+17 SET PXNODE2=$GET(^TMP("PXICEWEB",$JOB,"HISTORY",PXI,"COMPONENT",PXJ))
+18 SET PXGRP=$PIECE(PXNODE2,U,1)
+19 IF PXGRP=""
QUIT
+20 SET ^TMP("PXICEWEB",$JOB,PXGRP,"HISTORY",PXI)=PXNODE_U_$PIECE(PXNODE2,U,3,7)
+21 MERGE ^TMP("PXICEWEB",$JOB,PXGRP,"HISTORY",PXI,"REASON")=^TMP("PXICEWEB",$JOB,"HISTORY",PXI,"COMPONENT",PXJ,"REASON")
End DoDot:2
End DoDot:1
+22 ;
+23 KILL ^TMP("PXICEWEB",$JOB,"FORECAST")
+24 KILL ^TMP("PXICEWEB",$JOB,"HISTORY")
+25 ;
+26 QUIT