VBECRPCP ;HIOFO/BNT - Patient Medication Profile Lookup ;24 May 2004
;;2.0;VBEC;;Jun 05, 2015;Build 4
;
; Note: This routine supports data exchange with an FDA registered
; medical device. As such, it may not be changed in any way without
; prior written approval from the medical device manufacturer.
;
; Integration Agreements:
; Reference to OCL^PSOORRL supported by IA #2400
; Reference to DEM^VADPT supported by IA #10061
; Reference to $$FMTHL7^XLFDT supported by IA #10103
; Reference to $$HL7TFM^XLFDT supported by IA #10103
; Reference to $$CHARCHK^XOBVLIB supported by IA #4090
;
;
QUIT
;
; --------------------------------------------------------
; Private method supports IA #4613
; --------------------------------------------------------
RX(RESULTS,DFN,SDATE,EDATE) ; Get Medication Profile from Pharmacy API
N X,Y,BDT,EDT,RX0,ISDT
S VBECCNT=0
S RESULTS=$NA(^TMP("VBECMEDPROFILE",$J))
;
S EDT=$$HL7TFM^XLFDT(EDATE)
S BDT=$$HL7TFM^XLFDT(SDATE)
D BEGROOT^VBECRPC("MedicationProfile")
I DFN]"" D DEM^VADPT
I $G(VADM(1))="" D D ENDROOT^VBECRPC("MedicationProfile") Q
. D ADD^VBECRPC("<PatientName>Invalid Patient ID ("_$$CHARCHK^XOBVLIB(DFN)_")</PatientName><PatientSsn></PatientSsn><PatientDob></PatientDob><BeginningSearchDate></BeginningSearchDate><EndingSearchDate></EndingSearchDate>")
. D ADD^VBECRPC("<Order><OrderNumber></OrderNumber><DrugName></DrugName><IssueStartDate></IssueStartDate><Status></Status><InpatientOutpatientIndicator></InpatientOutpatientIndicator></Order>")
I BDT]"" S X=BDT D ^%DT S BDT=$S(Y<0:"",1:Y)
I BDT']"" S X1=EDT,X2=-180 D C^%DTC S BDT=X
D OCL^PSOORRL(DFN,BDT,EDT)
D ADD^VBECRPC("<PatientName>"_$$CHARCHK^XOBVLIB($G(VADM(1)))_"</PatientName>")
D ADD^VBECRPC("<PatientSsn>"_$$CHARCHK^XOBVLIB($P($G(VADM(2)),U,2))_"</PatientSsn>")
D ADD^VBECRPC("<PatientDob>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT($P($G(VADM(3)),U,1)))_"</PatientDob>")
D ADD^VBECRPC("<BeginningSearchDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT(BDT))_"</BeginningSearchDate>")
D ADD^VBECRPC("<EndingSearchDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT(EDT))_"</EndingSearchDate>")
I $D(^TMP("PS",$J)) D
. S I=0 F S I=$O(^TMP("PS",$J,I)) Q:I="" D
. . S RX0=^TMP("PS",$J,I,0)
. . Q:$P(RX0,U,15)<BDT
. . D ADD^VBECRPC("<Order><OrderNumber>"_$$CHARCHK^XOBVLIB($$STRIPL3^VBECRPC($P(RX0,U)))_"</OrderNumber>")
. . D ADD^VBECRPC("<DrugName>"_$$CHARCHK^XOBVLIB($P(^TMP("PS",$J,I,0),U,2))_"</DrugName>")
. . D ADD^VBECRPC("<IssueStartDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT($P(RX0,U,15)))_"</IssueStartDate>")
. . D ADD^VBECRPC("<Status>"_$$CHARCHK^XOBVLIB($P(RX0,U,9))_"</Status>")
. . D ADD^VBECRPC("<InpatientOutpatientIndicator>"_$$CHARCHK^XOBVLIB($P($P(RX0,U,1),";",2))_"</InpatientOutpatientIndicator>")
. . D ADD^VBECRPC("</Order>")
I '$D(^TMP("PS",$J)) D
. D ADD^VBECRPC("<Order><OrderNumber></OrderNumber><DrugName>No medications were found for the date range. You may repeat the query with a different date range.</DrugName>")
. D ADD^VBECRPC("<IssueStartDate></IssueStartDate><Status></Status><InpatientOutpatientIndicator></InpatientOutpatientIndicator></Order>")
D ENDROOT^VBECRPC("MedicationProfile")
;
K VBECCNT
Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HVBECRPCP 3237 printed Dec 13, 2024@02:44:34 Page 2
VBECRPCP ;HIOFO/BNT - Patient Medication Profile Lookup ;24 May 2004
+1 ;;2.0;VBEC;;Jun 05, 2015;Build 4
+2 ;
+3 ; Note: This routine supports data exchange with an FDA registered
+4 ; medical device. As such, it may not be changed in any way without
+5 ; prior written approval from the medical device manufacturer.
+6 ;
+7 ; Integration Agreements:
+8 ; Reference to OCL^PSOORRL supported by IA #2400
+9 ; Reference to DEM^VADPT supported by IA #10061
+10 ; Reference to $$FMTHL7^XLFDT supported by IA #10103
+11 ; Reference to $$HL7TFM^XLFDT supported by IA #10103
+12 ; Reference to $$CHARCHK^XOBVLIB supported by IA #4090
+13 ;
+14 ;
+15 QUIT
+16 ;
+17 ; --------------------------------------------------------
+18 ; Private method supports IA #4613
+19 ; --------------------------------------------------------
RX(RESULTS,DFN,SDATE,EDATE) ; Get Medication Profile from Pharmacy API
+1 NEW X,Y,BDT,EDT,RX0,ISDT
+2 SET VBECCNT=0
+3 SET RESULTS=$NAME(^TMP("VBECMEDPROFILE",$JOB))
+4 ;
+5 SET EDT=$$HL7TFM^XLFDT(EDATE)
+6 SET BDT=$$HL7TFM^XLFDT(SDATE)
+7 DO BEGROOT^VBECRPC("MedicationProfile")
+8 IF DFN]""
DO DEM^VADPT
+9 IF $GET(VADM(1))=""
Begin DoDot:1
+10 DO ADD^VBECRPC("<PatientName>Invalid Patient ID ("_$$CHARCHK^XOBVLIB(DFN)_")</PatientName><PatientSsn></PatientSsn><PatientDob></PatientDob><BeginningSearchDate></BeginningSearchDate><EndingSearchDate></EndingSearchDate>")
+11 DO ADD^VBECRPC("<Order><OrderNumber></OrderNumber><DrugName></DrugName><IssueStartDate></IssueStartDate><Status></Status><InpatientOutpatientIndicator></InpatientOutpatientIndicator></Order>")
End DoDot:1
DO ENDROOT^VBECRPC("MedicationProfile")
QUIT
+12 IF BDT]""
SET X=BDT
DO ^%DT
SET BDT=$SELECT(Y<0:"",1:Y)
+13 IF BDT']""
SET X1=EDT
SET X2=-180
DO C^%DTC
SET BDT=X
+14 DO OCL^PSOORRL(DFN,BDT,EDT)
+15 DO ADD^VBECRPC("<PatientName>"_$$CHARCHK^XOBVLIB($GET(VADM(1)))_"</PatientName>")
+16 DO ADD^VBECRPC("<PatientSsn>"_$$CHARCHK^XOBVLIB($PIECE($GET(VADM(2)),U,2))_"</PatientSsn>")
+17 DO ADD^VBECRPC("<PatientDob>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT($PIECE($GET(VADM(3)),U,1)))_"</PatientDob>")
+18 DO ADD^VBECRPC("<BeginningSearchDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT(BDT))_"</BeginningSearchDate>")
+19 DO ADD^VBECRPC("<EndingSearchDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT(EDT))_"</EndingSearchDate>")
+20 IF $DATA(^TMP("PS",$JOB))
Begin DoDot:1
+21 SET I=0
FOR
SET I=$ORDER(^TMP("PS",$JOB,I))
if I=""
QUIT
Begin DoDot:2
+22 SET RX0=^TMP("PS",$JOB,I,0)
+23 if $PIECE(RX0,U,15)<BDT
QUIT
+24 DO ADD^VBECRPC("<Order><OrderNumber>"_$$CHARCHK^XOBVLIB($$STRIPL3^VBECRPC($PIECE(RX0,U)))_"</OrderNumber>")
+25 DO ADD^VBECRPC("<DrugName>"_$$CHARCHK^XOBVLIB($PIECE(^TMP("PS",$JOB,I,0),U,2))_"</DrugName>")
+26 DO ADD^VBECRPC("<IssueStartDate>"_$$CHARCHK^XOBVLIB($$FMTHL7^XLFDT($PIECE(RX0,U,15)))_"</IssueStartDate>")
+27 DO ADD^VBECRPC("<Status>"_$$CHARCHK^XOBVLIB($PIECE(RX0,U,9))_"</Status>")
+28 DO ADD^VBECRPC("<InpatientOutpatientIndicator>"_$$CHARCHK^XOBVLIB($PIECE($PIECE(RX0,U,1),";",2))_"</InpatientOutpatientIndicator>")
+29 DO ADD^VBECRPC("</Order>")
End DoDot:2
End DoDot:1
+30 IF '$DATA(^TMP("PS",$JOB))
Begin DoDot:1
+31 DO ADD^VBECRPC("<Order><OrderNumber></OrderNumber><DrugName>No medications were found for the date range. You may repeat the query with a different date range.</DrugName>")
+32 DO ADD^VBECRPC("<IssueStartDate></IssueStartDate><Status></Status><InpatientOutpatientIndicator></InpatientOutpatientIndicator></Order>")
End DoDot:1
+33 DO ENDROOT^VBECRPC("MedicationProfile")
+34 ;
+35 KILL VBECCNT
+36 QUIT