HMPWBM2 ;ASMR/RRB - Medication Order Writeback ;Jul 02, 2015@10:19:41
;;2.0;HEALTH MANAGEMENT PLATFORM;**2**;Oct 10, 2014;Build 28
;Per VA Directive 6402, this routine should not be modified.
;
ORSAVE(HMPOUT,DFN,DUZ,LOCIEN,DLG,ORDG,ORIT,ORIFN,ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF) ; Calls for saving order
; Input Parameters:
; DFN: Patient DFN acquired when the patient is selected and placed in context.
; DUZ: Provider IEN acquired during login
; LOCIEN: Ordering Location (locationIen from the Visit)
; DLG: (internalDialogName) Acquired from the ORWDXM DLGNAME RPC
; ORDG:(displayGroupPointer) From the ORWDX WRLST RPC
; ORIT: (orderDialogIen) Acquired from the ORWDX WRLST RPC
; ORIFN: (orderIen) This is only available for existing orders that are being
; changed or renewed. New orders do not have an orderIen until they are saved.)
; ORDIALOG: (orderDialogArray) An ordered array consisting of the following....
; A map of the input screen to the dialog question subscripts returned from the
; ORWDX DLGDEF RPC.
; Order checks from the ORWDXC ACCEPT RPC. These included as:
; ("ORCHECK") = number of order checks
; ("ORCHECK",Piece 1, Piece 3,increment)=Piece 2 through Piece 4 of the order
; checks delimited by "^".
; ("ORTS") = treating specialty. Will be set to 0 (zero) if not available.
; (Only applies to inpatient locations.)
; ORDEA: digital signature
; ORAPPT: date.time stamp of visit in VA format
; ORSRC: order source
; OREVTDF: (eventDefault) only used for delayed orders
;
;Associated ICRs:
; ICR#
; 3371: ORWU HASKEY
;
N HMFLTR,JOUT,ORDIEN,OUT
;
D LOCK^ORWDX(.OUT,DFN) ; Lock patient record
I OUT'=1 D G ENDSAVE
. S HMPOUT="ERROR^Patient record locked by another user."
;
; Wrap for ORWDX SAVE
; Description: This RPC saves an order
;
; Input: Parameters are as noted above for this routine, ORSAVE^HMPWBM2.
;
; Output: Order parameters for the SAVE^ORWDX Broker Call
;
; ~orderIen^Grp^OrdTm^StrtTm^StopTm^Sts^Sig^Nrs^Clk^PrvID^PrvNam^Act^Flagged[^DCType]^ChartRev^DEA#^^DigSig^LOC^[DCORIGNAL]^IsPendingDCorder^IsDelayOrder
; There may be multiple lines of text entry. All will begin with a lower case "t".
; tline 1
; tline 2
; tline 3 And so forth
;
D SAVE^ORWDX(.OUT,DFN,.DUZ,LOCIEN,DLG,ORDG,ORIT,ORIFN,.ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF)
;
S ORDIEN=+($P($E(OUT(1),2,999),"^",1)) ; Extract the orderIen from the broker output
;
; Setup and call utility to return JSON order data
;
S HMFLTR("domain")="order",HMFLTR("noHead")=1,HMFLTR("patientId")=DFN,HMFLTR("id")=ORDIEN
;
D GET^HMPDJ(.JOUT,.HMFLTR)
;
; Return JSON order data
;
;
N CNT,HMPDMN,HMPFCNT,I,II,JNAME,JSTRNG,JVALPR,JVALUE,STMPTM,UID,WRPOUT
;
M WRPOUT=@JOUT
;
; Setup HMPDMN, HMPFCNT, STMPTM, and UID variables necessary for calling ADHOC^HMPUTIL2
;
S HMPDMN="order",HMPFCNT=WRPOUT("total")
;
; Acquire stampTime and uid JSON name value pairs
;
S I=""
F S I=$O(WRPOUT(I)) Q:I=""!(I'?1.N) D
. S II=""
. F S II=$O(WRPOUT(I,II)) Q:II="" D
. . S JSTRNG=$TR($G(WRPOUT(I,II)),$CHAR(34),"")
. . F CNT=1:1:$L(JSTRNG,",") D
. . . S JVALPR=$P(JSTRNG,",",CNT)
. . . S JNAME=$TR($P(JVALPR,":"),"{",""),JVALUE=$TR($E($P(JVALPR,JNAME,2),2,999),"}","")
. . . I JNAME="stampTime"!(JNAME="uid") D
. . . . S JNAME=$S(JNAME="stampTime":"STMPTM",JNAME="uid":"UID",1:"")
. . . . S @JNAME=JVALUE ; Create the variable names STMPTM and UID, and set their respective values
;
; Call ADHOC^HMPUTIL2 to wrap JSON order data with metastamp
;
D ADHOC^HMPUTIL2(HMPDMN,HMPFCNT,DFN,UID,STMPTM)
;
; Return complete JSON order package
;
M HMPOUT=^TMP("HMPF",$J)
;
D UNLOCK^ORWDX(.OUT,DFN) ; Unlock patient record
; "Unlocking the patient record is silent and will always be 1"
;
ENDSAVE ;
;
Q
;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HHMPWBM2 4093 printed Dec 13, 2024@01:54:48 Page 2
HMPWBM2 ;ASMR/RRB - Medication Order Writeback ;Jul 02, 2015@10:19:41
+1 ;;2.0;HEALTH MANAGEMENT PLATFORM;**2**;Oct 10, 2014;Build 28
+2 ;Per VA Directive 6402, this routine should not be modified.
+3 ;
ORSAVE(HMPOUT,DFN,DUZ,LOCIEN,DLG,ORDG,ORIT,ORIFN,ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF) ; Calls for saving order
+1 ; Input Parameters:
+2 ; DFN: Patient DFN acquired when the patient is selected and placed in context.
+3 ; DUZ: Provider IEN acquired during login
+4 ; LOCIEN: Ordering Location (locationIen from the Visit)
+5 ; DLG: (internalDialogName) Acquired from the ORWDXM DLGNAME RPC
+6 ; ORDG:(displayGroupPointer) From the ORWDX WRLST RPC
+7 ; ORIT: (orderDialogIen) Acquired from the ORWDX WRLST RPC
+8 ; ORIFN: (orderIen) This is only available for existing orders that are being
+9 ; changed or renewed. New orders do not have an orderIen until they are saved.)
+10 ; ORDIALOG: (orderDialogArray) An ordered array consisting of the following....
+11 ; A map of the input screen to the dialog question subscripts returned from the
+12 ; ORWDX DLGDEF RPC.
+13 ; Order checks from the ORWDXC ACCEPT RPC. These included as:
+14 ; ("ORCHECK") = number of order checks
+15 ; ("ORCHECK",Piece 1, Piece 3,increment)=Piece 2 through Piece 4 of the order
+16 ; checks delimited by "^".
+17 ; ("ORTS") = treating specialty. Will be set to 0 (zero) if not available.
+18 ; (Only applies to inpatient locations.)
+19 ; ORDEA: digital signature
+20 ; ORAPPT: date.time stamp of visit in VA format
+21 ; ORSRC: order source
+22 ; OREVTDF: (eventDefault) only used for delayed orders
+23 ;
+24 ;Associated ICRs:
+25 ; ICR#
+26 ; 3371: ORWU HASKEY
+27 ;
+28 NEW HMFLTR,JOUT,ORDIEN,OUT
+29 ;
+30 ; Lock patient record
DO LOCK^ORWDX(.OUT,DFN)
+31 IF OUT'=1
Begin DoDot:1
+32 SET HMPOUT="ERROR^Patient record locked by another user."
End DoDot:1
GOTO ENDSAVE
+33 ;
+34 ; Wrap for ORWDX SAVE
+35 ; Description: This RPC saves an order
+36 ;
+37 ; Input: Parameters are as noted above for this routine, ORSAVE^HMPWBM2.
+38 ;
+39 ; Output: Order parameters for the SAVE^ORWDX Broker Call
+40 ;
+41 ; ~orderIen^Grp^OrdTm^StrtTm^StopTm^Sts^Sig^Nrs^Clk^PrvID^PrvNam^Act^Flagged[^DCType]^ChartRev^DEA#^^DigSig^LOC^[DCORIGNAL]^IsPendingDCorder^IsDelayOrder
+42 ; There may be multiple lines of text entry. All will begin with a lower case "t".
+43 ; tline 1
+44 ; tline 2
+45 ; tline 3 And so forth
+46 ;
+47 DO SAVE^ORWDX(.OUT,DFN,.DUZ,LOCIEN,DLG,ORDG,ORIT,ORIFN,.ORDIALOG,ORDEA,ORAPPT,ORSRC,OREVTDF)
+48 ;
+49 ; Extract the orderIen from the broker output
SET ORDIEN=+($PIECE($EXTRACT(OUT(1),2,999),"^",1))
+50 ;
+51 ; Setup and call utility to return JSON order data
+52 ;
+53 SET HMFLTR("domain")="order"
SET HMFLTR("noHead")=1
SET HMFLTR("patientId")=DFN
SET HMFLTR("id")=ORDIEN
+54 ;
+55 DO GET^HMPDJ(.JOUT,.HMFLTR)
+56 ;
+57 ; Return JSON order data
+58 ;
+59 ;
+60 NEW CNT,HMPDMN,HMPFCNT,I,II,JNAME,JSTRNG,JVALPR,JVALUE,STMPTM,UID,WRPOUT
+61 ;
+62 MERGE WRPOUT=@JOUT
+63 ;
+64 ; Setup HMPDMN, HMPFCNT, STMPTM, and UID variables necessary for calling ADHOC^HMPUTIL2
+65 ;
+66 SET HMPDMN="order"
SET HMPFCNT=WRPOUT("total")
+67 ;
+68 ; Acquire stampTime and uid JSON name value pairs
+69 ;
+70 SET I=""
+71 FOR
SET I=$ORDER(WRPOUT(I))
if I=""!(I'?1.N)
QUIT
Begin DoDot:1
+72 SET II=""
+73 FOR
SET II=$ORDER(WRPOUT(I,II))
if II=""
QUIT
Begin DoDot:2
+74 SET JSTRNG=$TRANSLATE($GET(WRPOUT(I,II)),$CHAR(34),"")
+75 FOR CNT=1:1:$LENGTH(JSTRNG,",")
Begin DoDot:3
+76 SET JVALPR=$PIECE(JSTRNG,",",CNT)
+77 SET JNAME=$TRANSLATE($PIECE(JVALPR,":"),"{","")
SET JVALUE=$TRANSLATE($EXTRACT($PIECE(JVALPR,JNAME,2),2,999),"}","")
+78 IF JNAME="stampTime"!(JNAME="uid")
Begin DoDot:4
+79 SET JNAME=$SELECT(JNAME="stampTime":"STMPTM",JNAME="uid":"UID",1:"")
+80 ; Create the variable names STMPTM and UID, and set their respective values
SET @JNAME=JVALUE
End DoDot:4
End DoDot:3
End DoDot:2
End DoDot:1
+81 ;
+82 ; Call ADHOC^HMPUTIL2 to wrap JSON order data with metastamp
+83 ;
+84 DO ADHOC^HMPUTIL2(HMPDMN,HMPFCNT,DFN,UID,STMPTM)
+85 ;
+86 ; Return complete JSON order package
+87 ;
+88 MERGE HMPOUT=^TMP("HMPF",$JOB)
+89 ;
+90 ; Unlock patient record
DO UNLOCK^ORWDX(.OUT,DFN)
+91 ; "Unlocking the patient record is silent and will always be 1"
+92 ;
ENDSAVE ;
+1 ;
+2 QUIT
+3 ;